Skip to content

refactor(shell): enhance shell detection and add VP_SHELL override#1658

Open
nekomoyi wants to merge 12 commits into
voidzero-dev:mainfrom
nekomoyi:feat/vp-shell-env
Open

refactor(shell): enhance shell detection and add VP_SHELL override#1658
nekomoyi wants to merge 12 commits into
voidzero-dev:mainfrom
nekomoyi:feat/vp-shell-env

Conversation

@nekomoyi
Copy link
Copy Markdown
Collaborator

@nekomoyi nekomoyi commented May 21, 2026

What changed

  • Replaced VP_SHELL_NU and VP_SHELL_PWSH with one env var: VP_SHELL
  • Added shell parsing that accepts bash, zsh, fish, nu, pwsh, and cmd

Why

The old approach depended on a few shell-specific flags and inherited env vars. It could mis-detect nested shells and is harder to maintain.

The new shell detection stages:

  1. VP_SHELL if it is set
  2. Fallback to posix or cmd

nekomoyi added 4 commits May 22, 2026 01:50
Replace VP_SHELL_NU and VP_SHELL_PWSH with a single VP_SHELL env var
that accepts shell names (bash, fish, nu, pwsh, cmd). Detection now
follows: VP_SHELL → process tree inference → platform default.

- Add Shell::from_str for case-insensitive name parsing
- Add process tree walking to infer shell from parent processes
- Add sysinfo dep for Windows process enumeration
- Update shell wrapper scripts to remove shell-specific env vars
These tests assert on `detect_shell()` default fallback, but process
tree inference varies across environments (CI uses `shell: bash` on
Windows, local machines may have Git Bash), making the result
non-deterministic.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 21, 2026

Deploy Preview for viteplus-preview ready!

Name Link
🔨 Latest commit 9c9aec4
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a1000a9fe6f7b0008399ac3
😎 Deploy Preview https://deploy-preview-1658--viteplus-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors shell detection for the global CLI by consolidating multiple shell-specific env flags into a single VP_SHELL override, and adding process-tree inference to better detect the active shell for output formatting (notably vp env use eval output).

Changes:

  • Replaced VP_SHELL_NU / VP_SHELL_PWSH with a single VP_SHELL env var (case-insensitive parsing + aliases).
  • Added process-tree based shell inference (ps on Unix, sysinfo on Windows) with a platform-default fallback.
  • Added global snap tests validating VP_SHELL-driven formatting across supported shells.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/cli/snap-tests-global/command-env-use-shells/steps.json Adds snap-test commands covering VP_SHELL parsing and formatting.
packages/cli/snap-tests-global/command-env-use-shells/snap.txt Snapshot output for the new VP_SHELL shell-formatting coverage.
packages/cli/snap-tests-global/command-env-use-shells/package.json Fixture metadata for the new snap-test case.
crates/vite_shared/src/env_vars.rs Replaces shell marker constants with VP_SHELL.
crates/vite_shared/src/env_config.rs Updates EnvConfig to read VP_SHELL (and removes old marker fields).
crates/vite_global_cli/src/commands/shell.rs Implements Shell::FromStr, VP_SHELL override, and process-tree inference.
crates/vite_global_cli/src/commands/env/use.rs Updates tests to use vp_shell: Some(...) instead of old marker booleans.
crates/vite_global_cli/src/commands/env/setup.rs Removes wrapper-set env markers (VP_SHELL_NU, VP_SHELL_PWSH) from generated shell setup scripts.
crates/vite_global_cli/Cargo.toml Adds Windows-only sysinfo dependency for process-tree inference.
Cargo.toml Adds sysinfo to workspace dependencies.
Cargo.lock Lockfile updates due to dependency graph changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/vite_global_cli/src/commands/env/setup.rs Outdated
Comment thread crates/vite_global_cli/src/commands/env/setup.rs
Comment thread crates/vite_global_cli/src/commands/shell.rs Outdated
Comment thread packages/cli/snap-tests-global/command-env-use-shells/steps.json Outdated
Comment thread crates/vite_shared/src/env_config.rs Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a3ed1ceb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vite_global_cli/src/commands/shell.rs Outdated
@nekomoyi nekomoyi marked this pull request as ready for review May 21, 2026 20:12
@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented May 22, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 271fbd296e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vite_global_cli/src/commands/shell.rs
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: create-e2e Run `vp create` e2e tests labels May 22, 2026
Comment thread crates/vite_global_cli/src/commands/shell.rs Outdated
@fengmk2 fengmk2 requested a review from naokihaba May 22, 2026 07:07
@fengmk2 fengmk2 self-assigned this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants