Skip to content

Commit c462827

Browse files
branchseerclaude
andauthored
feat(run): refine outputs & add summary (#157)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 53850c6 commit c462827

36 files changed

Lines changed: 1194 additions & 131 deletions

File tree

crates/vite_task/src/cache.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::{fmt::Display, io::Write, sync::Arc};
22

33
// use bincode::config::{Configuration, standard};
44
use bincode::{Decode, Encode, decode_from_slice, encode_to_vec};
5-
use diff::Diff;
65
use rusqlite::{Connection, OptionalExtension as _};
76
use serde::Serialize;
87
use tokio::sync::Mutex;
@@ -11,7 +10,7 @@ use vite_str::Str;
1110

1211
use crate::{
1312
Error,
14-
config::{CommandFingerprint, CommandFingerprintDiff, ResolvedTask, TaskId},
13+
config::{CommandFingerprint, ResolvedTask, TaskId},
1514
execute::{ExecutedTask, StdOutput},
1615
fingerprint::{PostRunFingerprint, PostRunFingerprintMismatch},
1716
fs::FileSystem,
@@ -62,7 +61,7 @@ pub enum CacheMiss {
6261
pub enum FingerprintMismatch {
6362
/// Found the cache entry of the same task run, but the command fingerprint mismatches
6463
/// this happens when the command itself or an env changes.
65-
CommandFingerprintMismatch(CommandFingerprintDiff),
64+
CommandFingerprintMismatch(CommandFingerprint),
6665
/// Found the cache entry with the same command fingerprint, but the post-run fingerprint mismatches
6766
PostRunFingerprintMismatch(PostRunFingerprintMismatch),
6867
}
@@ -156,16 +155,14 @@ impl TaskCache {
156155
self.upsert_taskrun_to_command(&task_run_key, command_fingerprint).await?;
157156
Ok(Ok(cache_value))
158157
}
159-
} else if let Some(task_run_fingerprint) =
158+
} else if let Some(command_fingerprint_in_cache) =
160159
self.get_command_fingerprint_by_task_run_key(&task_run_key).await?
161160
{
162161
// No command cache found with the current command fingerprint,
163162
// but found a command fingerprint associated with the same task run key,
164163
// meaning the command or env has changed since last run
165164
Ok(Err(CacheMiss::FingerprintMismatch(
166-
FingerprintMismatch::CommandFingerprintMismatch(
167-
command_fingerprint.diff(&task_run_fingerprint),
168-
),
165+
FingerprintMismatch::CommandFingerprintMismatch(command_fingerprint_in_cache),
169166
)))
170167
} else {
171168
Ok(Err(CacheMiss::NotFound))

crates/vite_task/src/config/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,15 @@ impl ResolvedTask {
9393
task_group_id: TaskGroupId {
9494
task_group_name: self.name.task_group_name.clone(),
9595
config_path: self.resolved_config.config_dir.clone(),
96-
is_builtin: self.name.package_name.is_none(),
96+
is_builtin: self.is_builtin(),
9797
},
9898
}
9999
}
100100

101+
pub fn is_builtin(&self) -> bool {
102+
self.name.package_name.is_none()
103+
}
104+
101105
pub fn matches(&self, task_request: &str, current_package_path: Option<&RelativePath>) -> bool {
102106
if self.name.subcommand_index.is_some() {
103107
// never match non-last subcommand

crates/vite_task/src/schedule.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use futures_core::future::BoxFuture;
44
use futures_util::future::FutureExt as _;
55
use petgraph::{algo::toposort, stable_graph::StableDiGraph};
66
use tokio::io::AsyncWriteExt as _;
7-
use vite_path::{AbsolutePath, RelativePathBuf};
7+
use vite_path::AbsolutePath;
88

99
use crate::{
1010
Error,
1111
cache::{CacheMiss, CommandCacheValue, TaskCache},
12-
config::{DisplayOptions, ResolvedTask, TaskCommand, Workspace},
12+
config::{DisplayOptions, ResolvedTask, Workspace},
1313
execute::{OutputKind, execute_task},
1414
fs::FileSystem,
1515
};
@@ -24,8 +24,7 @@ pub struct ExecutionPlan {
2424
/// Status of a task before execution
2525
#[derive(Debug)]
2626
pub struct PreExecutionStatus {
27-
pub command: TaskCommand,
28-
pub cwd: RelativePathBuf,
27+
pub task: ResolvedTask,
2928
pub cache_status: CacheStatus,
3029
pub display_options: DisplayOptions,
3130
}
@@ -42,7 +41,6 @@ pub enum CacheStatus {
4241
/// Status of a task execution
4342
#[derive(Debug)]
4443
pub struct ExecutionStatus {
45-
#[expect(dead_code)]
4644
pub pre_execution_status: PreExecutionStatus,
4745
/// `Ok` variant means the task was executed (or replayed), no matter the exit status is zero or non-zero.
4846
///
@@ -132,28 +130,24 @@ impl ExecutionPlan {
132130
workspace: &mut Workspace,
133131
) -> anyhow::Result<ExecutionStatus> {
134132
tracing::debug!("Executing task {}", step.display_name());
135-
136-
let command = step.resolved_command.fingerprint.command.clone();
137-
let cwd = step.resolved_command.fingerprint.cwd.clone();
138-
139133
let display_options = step.display_options;
140134

141135
// Check cache and prepare execution
142136
let (cache_status, execute_or_replay) = get_cached_or_execute(
143-
step,
137+
step.clone(),
144138
&mut workspace.task_cache,
145139
&workspace.fs,
146140
&workspace.workspace_dir,
147141
)
148142
.await?;
149143

150-
let pre_execution_status =
151-
PreExecutionStatus { command, cwd, cache_status, display_options };
144+
let pre_execution_status = PreExecutionStatus { task: step, cache_status, display_options };
152145

153146
print!("{}", pre_execution_status);
154147

155148
// Execute or replay the task
156149
let exit_status = execute_or_replay.await?;
150+
println!();
157151
Ok(ExecutionStatus { pre_execution_status, execution_result: Ok(exit_status) })
158152
}
159153
}

0 commit comments

Comments
 (0)