feat(cli): global -C flag for working-directory switching#2031
Draft
fengmk2 wants to merge 6 commits into
Draft
Conversation
✅ Deploy Preview for viteplus-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…pp commands Implements rfcs/cwd-flag.md (RFC #2022): - vp -C <dir> <cmd> runs any command as if started in <dir> (git/make/pnpm convention), parsed by both the global binary and the local bin; the spawned tool gets <dir> as its working directory, no process.chdir - bare dev/build/preview/pack at a workspace root now resolve a target: defaultPackage from the root config (static extraction, works without a vite-plus install), single-runnable auto-select in interactive terminals, otherwise a package listing with -C hints and exit 1 - positional semantics are untouched: vite [root] and tsdown entries behave exactly as before (covered by a parity regression snap test) - interactive picker is a follow-up pending vite_select prompt support
…malize -C paths Post-review cleanup: - hoist the CI/interactive-terminal gate into vite_shared and reuse it from the command picker, vite_install, and app-target elicitation (the new copy had drifted to 6 of 11 CI vars) - expose vite_static_config::has_config_file and use it for runnable ranking (the hand-rolled list missed vite.config.cjs/.cts) - normalize -C and defaultPackage joins with clean() so upward workspace walks never see ./ or .. components - read defaultPackage before the workspace lookup so package.json-less framework roots (the RFC's motivating shape) work - exempt -h/--help/-V/--version from elicitation so vp dev --help always reaches the tool - accept -C=dir in bin.ts to match the clap grammar; simplify row construction, single-runnable check, and the target binding in mod.rs
…and defaultPackage Review follow-ups: - reuse vite_powershell::is_stdin_terminal (memoized) and add memoized stdout/stderr wrappers in vite_shared; migrate all 19 direct is_terminal() call sites and enforce via disallowed-methods in .clippy.toml - keep the CI env check in is_interactive_terminal: it is not covered by the TTY checks because some CI systems run jobs in a PTY (Buildkite does by default); documented in the code - document -C and the workspace-root behavior in docs/guide/monorepo.md and defaultPackage in docs/config/index.md
Contributor
|
✅ Staging deployment successful! Preview: https://viteplus-staging.void.app/ |
…xtures - cargo fmt: alphabetize the interactivity module/exports in vite_shared (the Lint CI failure) and reflow touched files - drop `|| echo` from the app-root-listing, default-package-missing, and cwd-flag fixtures so the snapshots capture the real exit code (via the runner's [N] prefix) and full error output directly
Expand the App Commands section into subsections with real terminal output: single-app auto-select, the multi-app listing with -C hints, -C targeting, and defaultPackage (including the non-workspace framework case).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the approved RFC, now included in this PR as
rfcs/cwd-flag.md(moved from #2022).vp -C <dir> <cmd>behaves exactly likecd <dir> && vp <cmd>for every command, parsed by the global Rust binary (crates/vite_global_cli) and by the local bin (packages/cli/src/bin.ts); the tool child process is spawned with<dir>as cwd, noprocess.chdirin the Rust layer.vp dev/build/preview/packat a workspace root now resolve a target instead of silently running against the root:defaultPackagefrom the root config (statically extracted, so it works at roots without a vite-plus install), single-runnable auto-select in interactive terminals, otherwise a ranked package listing with-Chints and exit 1.[root], tsdown entries); a parity regression snap test locks that in.Snap tests:
command-cwd-flag(equivalence with thecdform, missing-dir error, positional parity),command-app-root-listing(bare build/dev at root),command-default-packageandcommand-default-package-missing. Fullsnap-test-localsuite passes with no snapshot changes to existing fixtures; clippy, unit tests, and a manual global-binary run (-Cpack, missing dir,--help) verified.Follow-ups: interactive package picker (needs a prompt-text parameter in
vite_selectupstream first), docs pages,snap-tests-globalcoverage for the Rust-binary-Cpath.