Skip to content

Commit f8e5f4b

Browse files
authored
fix(global): monitor workspaces dir change (#337)
### TL;DR Added `is_monorepo` flag to `PackageManager` to properly handle monorepo workspace packages in fingerprint ignores. ### What changed? - Added an `is_monorepo` field to the `PackageManager` struct to track whether the workspace is a monorepo - Modified `get_fingerprint_ignores()` to return a `Result` and include parent directories of workspace packages in monorepos - Added detection logic to determine if a workspace is a monorepo based on the presence of workspace configuration files - Updated all test fixtures to include the new `is_monorepo` field - Added a new snap test for issue [#31](voidzero-dev/vite-task#31) to verify the fix works correctly <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Detects monorepos and updates fingerprint ignores to watch workspace parent dirs, wires the change through install, and adds a snap test; also whitelists VITE_* env vars. > > - **vite_install (core)**: > - `PackageManager`: > - Add `is_monorepo` flag; detect via `WorkspaceFile` in builder. > - Change `get_fingerprint_ignores()` to return `Result` and, when monorepo, include parent dirs of workspace packages using `get_package_graph()`. > - Import `get_package_graph` and update ignores logic/tests (add monorepo-specific test). > - Update test helpers across `commands/*` to set `is_monorepo: false`. > - **CLI (install)**: > - Propagate errors from `package_manager.get_fingerprint_ignores()?` when building the task. > - **Tests/Snaps**: > - Add `packages/global/snap-tests/command-install-bug-31/*` to verify workspace dir changes are detected (issue #31). > - **Tools**: > - Allow `VITE_*` env vars to pass through in `packages/tools/src/utils.ts`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6e76efa. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 3f2b8a1 commit f8e5f4b

24 files changed

Lines changed: 166 additions & 13 deletions

File tree

crates/vite_install/src/commands/add.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ mod tests {
230230
hash: None,
231231
bin_name: pm_type.to_string().into(),
232232
workspace_root: temp_dir_path.clone(),
233+
is_monorepo: false,
233234
install_dir,
234235
}
235236
}

crates/vite_install/src/commands/cache.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ mod tests {
151151
hash: None,
152152
bin_name: pm_type.to_string().into(),
153153
workspace_root: temp_dir_path.clone(),
154+
is_monorepo: false,
154155
install_dir,
155156
}
156157
}

crates/vite_install/src/commands/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ mod tests {
161161
hash: None,
162162
bin_name: pm_type.to_string().into(),
163163
workspace_root: temp_dir_path.clone(),
164+
is_monorepo: false,
164165
install_dir,
165166
}
166167
}

crates/vite_install/src/commands/dedupe.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ mod tests {
9898
hash: None,
9999
bin_name: pm_type.to_string().into(),
100100
workspace_root: temp_dir_path.clone(),
101+
is_monorepo: false,
101102
install_dir,
102103
}
103104
}

crates/vite_install/src/commands/link.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ mod tests {
8989
hash: None,
9090
bin_name: pm_type.to_string().into(),
9191
workspace_root: temp_dir_path.clone(),
92+
is_monorepo: false,
9293
install_dir,
9394
}
9495
}

crates/vite_install/src/commands/list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ mod tests {
303303
hash: None,
304304
bin_name: pm_type.to_string().into(),
305305
workspace_root: temp_dir_path.clone(),
306+
is_monorepo: false,
306307
install_dir,
307308
}
308309
}

crates/vite_install/src/commands/outdated.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ mod tests {
306306
hash: None,
307307
bin_name: pm_type.to_string().into(),
308308
workspace_root: temp_dir_path.clone(),
309+
is_monorepo: false,
309310
install_dir,
310311
}
311312
}

crates/vite_install/src/commands/owner.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ mod tests {
9898
hash: None,
9999
bin_name: pm_type.to_string().into(),
100100
workspace_root: temp_dir_path.clone(),
101+
is_monorepo: false,
101102
install_dir,
102103
}
103104
}

crates/vite_install/src/commands/pack.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ mod tests {
209209
hash: None,
210210
bin_name: pm_type.to_string().into(),
211211
workspace_root: temp_dir_path.clone(),
212+
is_monorepo: false,
212213
install_dir,
213214
}
214215
}
@@ -497,6 +498,7 @@ mod tests {
497498
hash: None,
498499
bin_name: "npm".into(),
499500
workspace_root: temp_dir_path.clone(),
501+
is_monorepo: false,
500502
install_dir,
501503
};
502504

@@ -531,6 +533,7 @@ mod tests {
531533
hash: None,
532534
bin_name: "pnpm".into(),
533535
workspace_root: temp_dir_path.clone(),
536+
is_monorepo: false,
534537
install_dir,
535538
};
536539

crates/vite_install/src/commands/prune.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ mod tests {
109109
hash: None,
110110
bin_name: pm_type.to_string().into(),
111111
workspace_root: temp_dir_path.clone(),
112+
is_monorepo: false,
112113
install_dir,
113114
}
114115
}

0 commit comments

Comments
 (0)