Skip to content

Commit 3ff1acf

Browse files
authored
Merge branch 'main' into copilot/fix-e6512409-db0e-43a7-b197-43faca866334
2 parents 9265cb4 + f8be683 commit 3ff1acf

7 files changed

Lines changed: 420 additions & 480 deletions

File tree

crates/vite_task/src/cache.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ impl TaskCache {
5555
pub fn load_from_file(path: impl AsRef<AbsolutePath>) -> Result<Self, Error> {
5656
let path = path.as_ref();
5757
let conn = Connection::open(path.as_path())?;
58-
conn.execute_batch("PRAGMA journal_mode=WAL")?;
59-
conn.execute("BEGIN EXCLUSIVE", ())?;
58+
conn.execute_batch("PRAGMA journal_mode=WAL; BEGIN EXCLUSIVE;")?;
6059
loop {
6160
let user_version: u32 = conn.query_one("PRAGMA user_version", (), |row| row.get(0))?;
6261
match user_version {
@@ -70,13 +69,13 @@ impl TaskCache {
7069
2.. => return Err(Error::UnrecognizedDbVersion(user_version)),
7170
}
7271
}
72+
conn.execute_batch("COMMIT")?;
7373
Ok(Self { conn: Mutex::new(conn) })
7474
}
7575

7676
#[tracing::instrument]
7777
pub async fn save(self) -> Result<(), Error> {
78-
let conn = self.conn.lock().await;
79-
conn.execute("COMMIT", ())?;
78+
// do some cleanup in the future
8079
Ok(())
8180
}
8281

crates/vite_task/src/config/task_command.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ impl From<TaskCommand> for TaskConfig {
4141
}
4242
}
4343

44+
impl TaskCommand {
45+
pub fn is_vite(&self) -> bool {
46+
matches!(self, Self::Parsed(parsed_command) if parsed_command.program == "vite")
47+
}
48+
}
49+
4450
#[derive(Encode, Decode, Debug, Serialize, PartialEq, Eq, Diff, Clone)]
4551
#[diff(attr(#[derive(Debug)]))]
4652
pub struct ResolvedTaskConfig {

crates/vite_task/src/execute.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use bincode::{Decode, Encode};
1010
use fspy::{AccessMode, Spy, TrackedChild};
1111
use supports_color::{Stream, on};
1212

13-
use futures_util::future::try_join4;
13+
use futures_util::future::{try_join3, try_join4};
1414
use serde::{Deserialize, Serialize};
1515
use tokio::io::{AsyncRead, AsyncReadExt as _, AsyncWrite, AsyncWriteExt as _};
1616
use vite_path::{AbsolutePath, RelativePathBuf};
@@ -292,6 +292,32 @@ pub async fn execute_task(
292292
cmd
293293
}
294294
TaskCommand::Parsed(task_parsed_command) => {
295+
if resolved_command.fingerprint.command.is_vite() {
296+
let mut child = tokio::process::Command::new("vite")
297+
.args(&task_parsed_command.args)
298+
.envs(&resolved_command.all_envs)
299+
.envs(&task_parsed_command.envs)
300+
.current_dir(base_dir.join(&resolved_command.fingerprint.cwd))
301+
.stdout(Stdio::piped())
302+
.stderr(Stdio::piped())
303+
.spawn()?;
304+
let child_stdout = child.stdout.take().unwrap();
305+
let child_stderr = child.stderr.take().unwrap();
306+
307+
let outputs = Mutex::new(Vec::<StdOutput>::new());
308+
let ((), (), exit_status) = try_join3(
309+
collect_std_outputs(&outputs, child_stdout, OutputKind::StdOut),
310+
collect_std_outputs(&outputs, child_stderr, OutputKind::StdErr),
311+
async move { Ok(child.wait().await?) },
312+
)
313+
.await?;
314+
return Ok(ExecutedTask {
315+
std_outputs: outputs.into_inner().unwrap().into(),
316+
exit_status,
317+
path_reads: HashMap::new(),
318+
path_writes: HashMap::new(),
319+
});
320+
}
295321
let mut cmd = spy.new_command(&task_parsed_command.program);
296322
cmd.args(&task_parsed_command.args);
297323
cmd.envs(&resolved_command.all_envs);

crates/vite_task/src/schedule.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,13 @@ async fn get_cached_or_execute<'a>(
158158
Err(cache_miss) => (
159159
Some(cache_miss),
160160
async move {
161+
let is_vite = task.resolved_command.fingerprint.command.is_vite();
161162
let executed_task = execute_task(&task.resolved_command, base_dir).await?;
162-
let cached_task = CachedTask::create(task.clone(), executed_task, fs, base_dir)?;
163-
cache.update(&task, cached_task).await?;
163+
if !is_vite {
164+
let cached_task =
165+
CachedTask::create(task.clone(), executed_task, fs, base_dir)?;
166+
cache.update(&task, cached_task).await?;
167+
}
164168
Ok(())
165169
}
166170
.boxed(),

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
22
"name": "vite-plus-monorepo",
33
"private": true,
4-
"packageManager": "pnpm@10.14.0",
4+
"packageManager": "pnpm@10.15.1",
55
"volta": {
66
"node": "22.17.0"
77
},
88
"scripts": {
99
"bootstrap-cli": "pnpm --filter=@voidzero-dev/vite-plus build && cp -r ./packages/cli/binding/*.node ./packages/global/dist && pnpm --filter=@voidzero-dev/global build && npm install -g ./packages/global",
1010
"bootstrap-cli:ci": "pnpm --filter=@voidzero-dev/vite-plus build:ts && pnpm --filter=@voidzero-dev/global build && npm install -g ./packages/global",
1111
"typecheck": "tsc -b tsconfig.json",
12+
"lint": "vite lint",
1213
"prepare": "husky"
1314
},
1415
"devDependencies": {
1516
"@oxc-node/cli": "catalog:",
1617
"@oxc-node/core": "catalog:",
1718
"@types/node": "catalog:",
19+
"@voidzero-dev/vite-plus": "workspace:*",
1820
"husky": "^9.1.7",
19-
"lint-staged": "^16.1.2",
21+
"lint-staged": "^16.1.6",
2022
"oxlint": "catalog:",
21-
"typescript": "catalog:",
22-
"rolldown-vite": "catalog:",
23-
"@voidzero-dev/vite-plus": "workspace:*"
23+
"typescript": "catalog:"
2424
},
2525
"lint-staged": {
2626
"*.@(js|ts|tsx|yml|yaml|md|json|html|toml)": [

0 commit comments

Comments
 (0)