diff --git a/.claude/skills/add-ecosystem-ci/SKILL.md b/.claude/skills/add-ecosystem-ci/SKILL.md index 34c99635de..11db2b3817 100644 --- a/.claude/skills/add-ecosystem-ci/SKILL.md +++ b/.claude/skills/add-ecosystem-ci/SKILL.md @@ -41,7 +41,7 @@ Look for common patterns in workflow files: - `pnpm run ` / `npm run ` / `yarn ` - Commands like: `lint`, `build`, `test`, `type-check`, `typecheck`, `format`, `format:check` -- Map detected commands to vite equivalents: `vite run lint`, `vite run build`, etc. +- Map detected commands to `vp` equivalents: `vp run lint`, `vp run build`, etc. ### 2.3 Ask User to Confirm @@ -73,8 +73,8 @@ Present the auto-detected configuration and ask user to confirm or modify: node-version: 24 directory: web # only if subdirectory is needed command: | - vite run lint - vite run build + vp run lint + vp run build ``` ## Step 4: Verify @@ -109,5 +109,5 @@ node ecosystem-ci/clone.ts project-name - The `directory` field is optional - only add it if the package.json is not in the project root - If `directory` is specified in repo.json, it must also be specified in the workflow matrix -- `patch-project.ts` automatically handles running `vite migrate` in the correct directory +- `patch-project.ts` automatically handles running `vp migrate` in the correct directory - OS exclusions are added to the existing `exclude` section in the workflow matrix diff --git a/.github/actions/build-upstream/action.yml b/.github/actions/build-upstream/action.yml index 75ac05749f..3836e47096 100644 --- a/.github/actions/build-upstream/action.yml +++ b/.github/actions/build-upstream/action.yml @@ -4,9 +4,6 @@ inputs: target: description: 'The target platform' required: true - print-after-build: - description: 'Print the output after the build' - required: false runs: using: 'composite' @@ -24,9 +21,9 @@ runs: id: cache-key shell: bash run: | - echo "key=napi-binding-v1-${{ inputs.target }}-${{ env.RELEASE_BUILD }}-${{ env.DEBUG }}-${{ env.VERSION }}-${{ hashFiles('packages/tools/.upstream-versions.json', 'Cargo.lock', 'crates/**/*.rs', 'crates/*/Cargo.toml', 'packages/*/binding/**/*.rs', 'packages/*/binding/Cargo.toml', 'Cargo.toml', '.cargo/config.toml', 'packages/cli/package.json', 'packages/cli/build.ts', 'packages/global/package.json', 'packages/global/build.ts') }}" >> $GITHUB_OUTPUT + echo "key=napi-binding-v2-${{ inputs.target }}-${{ env.RELEASE_BUILD }}-${{ env.DEBUG }}-${{ env.VERSION }}-${{ env.NPM_TAG }}-${{ hashFiles('packages/tools/.upstream-versions.json', 'Cargo.lock', 'crates/**/*.rs', 'crates/*/Cargo.toml', 'packages/*/binding/**/*.rs', 'packages/*/binding/Cargo.toml', 'Cargo.toml', '.cargo/config.toml', 'packages/cli/package.json', 'packages/cli/build.ts', 'packages/global/package.json', 'packages/global/build.ts') }}" >> $GITHUB_OUTPUT - # Cache only NAPI bindings (the slow part, especially on Windows) + # Cache NAPI bindings and Rust CLI binary (the slow parts, especially on Windows) - name: Restore NAPI binding cache id: cache-restore uses: actions/cache/restore@94b89442628ad1d101e352b7ee38f30e1bef108e # v5 @@ -40,6 +37,8 @@ runs: packages/global/binding/*.node packages/global/binding/index.js packages/global/binding/index.d.ts + target/${{ inputs.target }}/release/vp + target/${{ inputs.target }}/release/vp.exe key: ${{ steps.cache-key.outputs.key }} # Build upstream TypeScript packages first (don't depend on native bindings) @@ -56,7 +55,7 @@ runs: # NAPI builds - only run on cache miss (slow, especially on Windows) # Must run before vite-plus/vite-plus-cli TypeScript builds which depend on the bindings - - name: Build NAPI bindings + - name: Build NAPI bindings (x86_64-linux) shell: bash if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'x86_64-unknown-linux-gnu' run: | @@ -66,17 +65,18 @@ runs: TARGET_CC: clang DEBUG: napi:* - - name: Build NAPI bindings + - name: Build NAPI bindings (aarch64-linux) shell: bash if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'aarch64-unknown-linux-gnu' run: | - TARGET_CFLAGS="-D_BSD_SOURCE" pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross - TARGET_CFLAGS="-D_BSD_SOURCE" pnpm --filter=vite-plus-cli build-native --target ${{ inputs.target }} --use-napi-cross + pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross + pnpm --filter=vite-plus-cli build-native --target ${{ inputs.target }} --use-napi-cross env: TARGET_CC: clang + TARGET_CFLAGS: '-D_BSD_SOURCE' DEBUG: napi:* - - name: Build NAPI bindings + - name: Build NAPI bindings (non-Linux targets) shell: bash if: steps.cache-restore.outputs.cache-hit != 'true' && !contains(inputs.target, 'linux') run: | @@ -85,16 +85,29 @@ runs: env: DEBUG: napi:* - - name: Print output after build + - name: Build Rust CLI binary (x86_64-linux) + if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'x86_64-unknown-linux-gnu' shell: bash - if: inputs.print-after-build == 'true' run: | - pnpm vite -h - pnpm vite run -h - pnpm vite lint -h - pnpm vite test -h - pnpm vite build -h - pnpm vite fmt -h + pnpm exec napi build --use-napi-cross --target ${{ inputs.target }} --release -p vite_global_cli + env: + TARGET_CC: clang + DEBUG: napi:* + + - name: Build Rust CLI binary (aarch64-linux) + if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'aarch64-unknown-linux-gnu' + shell: bash + run: | + pnpm exec napi build --use-napi-cross --target ${{ inputs.target }} --release -p vite_global_cli + env: + TARGET_CC: clang + TARGET_CFLAGS: '-D_BSD_SOURCE' + DEBUG: napi:* + + - name: Build Rust CLI binary (non-Linux targets) + if: steps.cache-restore.outputs.cache-hit != 'true' && !contains(inputs.target, 'linux') + shell: bash + run: cargo build --release --target ${{ inputs.target }} -p vite_global_cli - name: Save NAPI binding cache if: steps.cache-restore.outputs.cache-hit != 'true' @@ -109,4 +122,34 @@ runs: packages/global/binding/*.node packages/global/binding/index.js packages/global/binding/index.d.ts + target/${{ inputs.target }}/release/vp + target/${{ inputs.target }}/release/vp.exe key: ${{ steps.cache-key.outputs.key }} + + # Copy Rust CLI binary to packages/global/bin/ (runs on both cache hit and miss) + - name: Copy Rust CLI binary + shell: bash + run: | + if [[ "${{ inputs.target }}" == *"windows"* ]]; then + cp target/${{ inputs.target }}/release/vp.exe packages/global/bin/vp.exe + else + cp target/${{ inputs.target }}/release/vp packages/global/bin/vp + fi + + # Build vite-plus TypeScript after native bindings are ready + - name: Build vite-plus TypeScript packages + shell: bash + run: | + pnpm --filter=vite-plus build-ts + pnpm --filter=vite-plus-cli build-ts + + - name: Print output after build + shell: bash + if: inputs.print-after-build == 'true' + run: | + pnpm vite -h + pnpm vite run -h + pnpm vite lint -h + pnpm vite test -h + pnpm vite build -h + pnpm vite fmt -h diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a93955aa14..5c704a1e2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,8 @@ jobs: env: RUSTFLAGS: '-D warnings --cfg tokio_unstable' # also update .cargo/config.toml - - run: cargo test -p vite_command -p vite_install -p vite_migration + # Test all crates/* packages. New crates are automatically included. + - run: cargo test $(for d in crates/*/; do echo -n "-p $(basename $d) "; done) lint: name: Lint @@ -136,13 +137,13 @@ jobs: - name: Print help for built-in commands run: | - which vite - vite -h - vite run -h - vite lint -h - vite test -h - vite build -h - vite fmt -h + which vp + vp -h + vp run -h + vp lint -h + vp test -h + vp build -h + vp fmt -h cli-e2e-test: name: CLI E2E test @@ -194,31 +195,33 @@ jobs: - name: Build CLI run: | pnpm bootstrap-cli:ci - which vite - vite --version - vite -h + which vp + vp --version + vp -h + + - name: Check CLI JS execution on Windows rust binary + if: ${{ matrix.os == 'windows-latest' }} + run: | + ls -al packages/global/bin + VITE_LOG=trace ./packages/global/bin/vp.exe -V + VITE_LOG=trace ./packages/global/bin/vp.exe pm cache dir - name: Run CLI fmt - run: vite fmt --check + run: vp fmt --check - name: Run CLI lint - run: vite run lint + run: vp run lint - name: Install Playwright browsers run: pnpx playwright install chromium - - name: Create vite.cmd shim file for Windows - if: ${{ matrix.os == 'windows-latest' }} - run: | - printf '@echo off\nnode "%%~dp0vite" %%*\n' > packages/global/bin/vite.cmd - - name: Run CLI snapshot tests run: | RUST_BACKTRACE=1 pnpm test git diff --exit-code install-e2e-test: - name: vite install E2E test + name: Local CLI `vite install` E2E test needs: - download-previous-rolldown-binaries runs-on: ubuntu-latest @@ -254,7 +257,7 @@ jobs: - name: Build CLI run: pnpm bootstrap-cli:ci - - name: Run local CLI vite install + - name: Run local CLI `vite install` run: | export PATH=$PWD/node_modules/.bin:$PATH vite -h diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 5854b4c48c..490f0a1778 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -16,7 +16,7 @@ on: types: [opened, synchronize, labeled] concurrency: - group: ${{ github.workflow }}-${{ github.sha }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: ${{ github.ref_name != 'main' }} defaults: @@ -142,46 +142,46 @@ jobs: command: | npx playwright install chromium # FIXME: Failed to load JS plugin: ./plugins/debugger.js - # vite run ready - vite fmt - vite test - vite run build + # vp run ready + vp fmt + vp test + vp run build # FIXME: TypeError: Failed to fetch dynamically imported module # - name: skeleton # node-version: 24 # command: | - # vite run format - # vite run lint:check - # vite run check + # vp run format + # vp run lint:check + # vp run check # npx playwright install chromium - # vite run test + # vp run test - name: rollipop node-version: 22 command: | - vite run -r build + vp run -r build # FIXME: typescript-eslint(no-redundant-type-constituents): 'rolldownExperimental.DevEngine' is an 'error' type that acts as 'any' and overrides all other types in this union type. - vite run lint || true + vp run lint || true # FIXME: src/bundler-pool.ts(8,8): error TS2307: Cannot find module '@rollipop/core' or its corresponding type declarations. - vite run -r typecheck || true - vite run format - vite run @rollipop/common#test - vite run @rollipop/core#test - vite run @rollipop/dev-server#test + vp run -r typecheck || true + vp run format + vp run @rollipop/common#test + vp run @rollipop/core#test + vp run @rollipop/dev-server#test - name: frm-stack node-version: 24 command: | - vite run lint:check - vite run format:check - vite run typecheck - vite run @yourcompany/api#test - vite run @yourcompany/backend-core#test + vp run lint:check + vp run format:check + vp run typecheck + vp run @yourcompany/api#test + vp run @yourcompany/backend-core#test - name: vue-mini node-version: 24 command: | - vite run format - vite run lint - vite run type - vite run test -- --coverage + vp run format + vp run lint + vp run type + vp run test -- --coverage # SKIP: vite-plugin-react - vite-task config loading incompatibility # vite-task needs to load vite.config.js for all workspace packages to build the task graph, # but the vite-plus process starts with workspace root as cwd. @@ -199,43 +199,43 @@ jobs: # - name: vite-plugin-react # node-version: 22 # command: | - # vite run format - # vite run lint -- --fix + # vp run format + # vp run lint -- --fix # # TODO(fengmk2): run all builds and tests after tsdown version upgrade - # vite run @vitejs/plugin-rsc#build - # vite run @vitejs/plugin-rsc#test + # vp run @vitejs/plugin-rsc#build + # vp run @vitejs/plugin-rsc#test - name: vitepress node-version: 24 command: | npx playwright install chromium - vite run format - vite run build - vite test run -r __tests__/unit - vite run tests-e2e#test - VITE_TEST_BUILD=1 vite run tests-e2e#test - vite run tests-init#test + vp run format + vp run build + vp test run -r __tests__/unit + vp run tests-e2e#test + VITE_TEST_BUILD=1 vp run tests-e2e#test + vp run tests-init#test - name: tanstack-start-helloworld node-version: 24 command: | npx playwright install chromium - vite run test - vite run build + vp run test + vp run build - name: oxlint-plugin-complexity node-version: 22 command: | - vite run format - vite run format:check - vite run build - vite run lint - vite run test:run + vp run format + vp run format:check + vp run build + vp run lint + vp run test:run npx tsc --noEmit - name: dify node-version: 24 directory: web command: | - vite run type-check:tsgo - vite run build - vite run test navigation-utils.test.ts real-browser-flicker.test.tsx workflow-parallel-limit.test.tsx + vp run type-check:tsgo + vp run build + vp run test navigation-utils.test.ts real-browser-flicker.test.tsx workflow-parallel-limit.test.tsx exclude: # frm-stack uses Docker (testcontainers) which doesn't work the same way on Windows - os: windows-latest @@ -269,7 +269,7 @@ jobs: # install global CLI first npm install -g $GITHUB_WORKSPACE/tmp/tgz/vite-plus-cli-0.0.0.tgz node $GITHUB_WORKSPACE/ecosystem-ci/patch-project.ts ${{ matrix.project.name }} - vite install --no-frozen-lockfile + vp install --no-frozen-lockfile - name: Run vite-plus commands in ${{ matrix.project.name }} working-directory: ${{ runner.temp }}/vite-plus-ecosystem-ci/${{ matrix.project.name }}${{ matrix.project.directory && format('/{0}', matrix.project.directory) || '' }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43efc21bcf..f2ae43b544 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,12 +2,22 @@ name: Release on: workflow_dispatch: + inputs: + npm_tag: + description: 'npm tag for publish' + required: true + default: 'latest' + type: choice + options: + - latest + - test permissions: {} env: RELEASE_BUILD: 'true' DEBUG: 'napi:*' + NPM_TAG: ${{ inputs.npm_tag }} jobs: prepare: @@ -91,6 +101,15 @@ jobs: path: ./packages/global/binding/*.node if-no-files-found: error + - name: Upload Rust CLI binary artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: vite-global-cli-${{ matrix.settings.target }} + path: | + ./target/${{ matrix.settings.target }}/release/vp + ./target/${{ matrix.settings.target }}/release/vp.exe + if-no-files-found: error + - name: Remove .node files before upload dist if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }} run: | @@ -187,6 +206,36 @@ jobs: path: packages/global/artifacts pattern: vite-plus-cli-native-* + - name: Download Rust CLI binaries + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + path: rust-cli-artifacts + pattern: vite-global-cli-* + + - name: Move Rust CLI binaries to target directories + run: | + # Move each artifact's binary to the correct target directory + for artifact_dir in rust-cli-artifacts/vite-global-cli-*/; do + if [ -d "$artifact_dir" ]; then + # Extract target name from directory (e.g., vite-global-cli-x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu) + dir_name=$(basename "$artifact_dir") + target_name=${dir_name#vite-global-cli-} + # Create target directory and copy binary + mkdir -p "target/${target_name}/release" + cp -r "$artifact_dir"* "target/${target_name}/release/" + fi + done + # Show what we have (fail if no binaries found) + vp_files=$(find target -name "vp*" -type f 2>/dev/null || echo "") + if [ -z "$vp_files" ]; then + echo "Error: No vp binaries found in target directory" + echo "Artifact contents:" + find rust-cli-artifacts -type f || true + exit 1 + fi + echo "Found binaries:" + echo "$vp_files" + - name: Set npm packages version run: | sed -i 's/"version": "0.0.0"/"version": "${{ env.VERSION }}"/' packages/core/package.json @@ -208,13 +257,20 @@ jobs: - name: Publish run: | - pnpm publish --filter=./packages/core --access public --no-git-checks - pnpm publish --filter=./packages/test --access public --no-git-checks - pnpm publish --filter=./packages/cli --access public --no-git-checks - pnpm publish --filter=./packages/global --access public --no-git-checks + pnpm publish --filter=./packages/core --tag ${{ inputs.npm_tag }} --access public --no-git-checks + pnpm publish --filter=./packages/test --tag ${{ inputs.npm_tag }} --access public --no-git-checks + pnpm publish --filter=./packages/cli --tag ${{ inputs.npm_tag }} --access public --no-git-checks + pnpm publish --filter=./packages/global --tag ${{ inputs.npm_tag }} --access public --no-git-checks - name: Create release body run: | + if [[ "${{ inputs.npm_tag }}" == "latest" ]]; then + INSTALL_BASH="curl -fsSL https://viteplus.dev/install.sh | bash" + INSTALL_PS1="irm https://viteplus.dev/install.ps1 | iex" + else + INSTALL_BASH="curl -fsSL https://viteplus.dev/install.sh | VITE_PLUS_VERSION=${{ env.VERSION }} bash" + INSTALL_PS1="\\\$env:VITE_PLUS_VERSION=\\\"${{ env.VERSION }}\\\"; irm https://viteplus.dev/install.ps1 | iex" + fi cat > ./RELEASE_BODY.md <, +} + +/// Available commands +#[derive(Subcommand, Debug)] +pub enum Commands { + // ========================================================================= + // Category A: Package Manager Commands + // ========================================================================= + /// Install all dependencies, or add packages if package names are provided + #[command(alias = "i")] + Install { + /// Do not install devDependencies + #[arg(short = 'P', long)] + prod: bool, + + /// Only install devDependencies (install) / Save to devDependencies (add) + #[arg(short = 'D', long)] + dev: bool, + + /// Do not install optionalDependencies + #[arg(long)] + no_optional: bool, + + /// Fail if lockfile needs to be updated (CI mode) + #[arg(long, overrides_with = "no_frozen_lockfile")] + frozen_lockfile: bool, + + /// Allow lockfile updates (opposite of --frozen-lockfile) + #[arg(long, overrides_with = "frozen_lockfile")] + no_frozen_lockfile: bool, + + /// Only update lockfile, don't install + #[arg(long)] + lockfile_only: bool, + + /// Use cached packages when available + #[arg(long)] + prefer_offline: bool, + + /// Only use packages already in cache + #[arg(long)] + offline: bool, + + /// Force reinstall all dependencies + #[arg(short = 'f', long)] + force: bool, + + /// Do not run lifecycle scripts + #[arg(long)] + ignore_scripts: bool, + + /// Don't read or generate lockfile + #[arg(long)] + no_lockfile: bool, + + /// Fix broken lockfile entries (pnpm and yarn@2+ only) + #[arg(long)] + fix_lockfile: bool, + + /// Create flat `node_modules` (pnpm only) + #[arg(long)] + shamefully_hoist: bool, + + /// Re-run resolution for peer dependency analysis (pnpm only) + #[arg(long)] + resolution_only: bool, + + /// Suppress output (silent mode) + #[arg(long)] + silent: bool, + + /// Filter packages in monorepo (can be used multiple times) + #[arg(long, value_name = "PATTERN")] + filter: Option>, + + /// Install in workspace root only + #[arg(short = 'w', long)] + workspace_root: bool, + + /// Save exact version (only when adding packages) + #[arg(short = 'E', long)] + save_exact: bool, + + /// Save to peerDependencies (only when adding packages) + #[arg(long)] + save_peer: bool, + + /// Save to optionalDependencies (only when adding packages) + #[arg(short = 'O', long)] + save_optional: bool, + + /// Save the new dependency to the default catalog (only when adding packages) + #[arg(long)] + save_catalog: bool, + + /// Install globally (only when adding packages) + #[arg(short = 'g', long)] + global: bool, + + /// Packages to add (if provided, acts as `vp add`) + #[arg(required = false)] + packages: Option>, + + /// Additional arguments to pass through to the package manager + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Add packages to dependencies + Add { + /// Save to `dependencies` (default) + #[arg(short = 'P', long)] + save_prod: bool, + + /// Save to `devDependencies` + #[arg(short = 'D', long)] + save_dev: bool, + + /// Save to `peerDependencies` and `devDependencies` + #[arg(long)] + save_peer: bool, + + /// Save to `optionalDependencies` + #[arg(short = 'O', long)] + save_optional: bool, + + /// Save exact version rather than semver range + #[arg(short = 'E', long)] + save_exact: bool, + + /// Save the new dependency to the specified catalog name + #[arg(long, value_name = "CATALOG_NAME")] + save_catalog_name: Option, + + /// Save the new dependency to the default catalog + #[arg(long)] + save_catalog: bool, + + /// A list of package names allowed to run postinstall + #[arg(long, value_name = "NAMES")] + allow_build: Option, + + /// Filter packages in monorepo (can be used multiple times) + #[arg(long, value_name = "PATTERN")] + filter: Option>, + + /// Add to workspace root + #[arg(short = 'w', long)] + workspace_root: bool, + + /// Only add if package exists in workspace (pnpm-specific) + #[arg(long)] + workspace: bool, + + /// Install globally + #[arg(short = 'g', long)] + global: bool, + + /// Packages to add + #[arg(required = true)] + packages: Vec, + + /// Additional arguments to pass through to the package manager + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Remove packages from dependencies + #[command(alias = "rm", alias = "un", alias = "uninstall")] + Remove { + /// Only remove from `devDependencies` (pnpm-specific) + #[arg(short = 'D', long)] + save_dev: bool, + + /// Only remove from `optionalDependencies` (pnpm-specific) + #[arg(short = 'O', long)] + save_optional: bool, + + /// Only remove from `dependencies` (pnpm-specific) + #[arg(short = 'P', long)] + save_prod: bool, + + /// Filter packages in monorepo (can be used multiple times) + #[arg(long, value_name = "PATTERN")] + filter: Option>, + + /// Remove from workspace root + #[arg(short = 'w', long)] + workspace_root: bool, + + /// Remove recursively from all workspace packages + #[arg(short = 'r', long)] + recursive: bool, + + /// Remove global packages + #[arg(short = 'g', long)] + global: bool, + + /// Packages to remove + #[arg(required = true)] + packages: Vec, + + /// Additional arguments to pass through to the package manager + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Update packages to their latest versions + #[command(alias = "up")] + Update { + /// Update to latest version (ignore semver range) + #[arg(short = 'L', long)] + latest: bool, + + /// Update global packages + #[arg(short = 'g', long)] + global: bool, + + /// Update recursively in all workspace packages + #[arg(short = 'r', long)] + recursive: bool, + + /// Filter packages in monorepo (can be used multiple times) + #[arg(long, value_name = "PATTERN")] + filter: Option>, + + /// Include workspace root + #[arg(short = 'w', long)] + workspace_root: bool, + + /// Update only devDependencies + #[arg(short = 'D', long)] + dev: bool, + + /// Update only dependencies (production) + #[arg(short = 'P', long)] + prod: bool, + + /// Interactive mode + #[arg(short = 'i', long)] + interactive: bool, + + /// Don't update optionalDependencies + #[arg(long)] + no_optional: bool, + + /// Update lockfile only, don't modify package.json + #[arg(long)] + no_save: bool, + + /// Only update if package exists in workspace (pnpm-specific) + #[arg(long)] + workspace: bool, + + /// Packages to update (optional - updates all if omitted) + packages: Vec, + + /// Additional arguments to pass through to the package manager + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Deduplicate dependencies + #[command(alias = "ddp")] + Dedupe { + /// Check if deduplication would make changes + #[arg(long)] + check: bool, + + /// Additional arguments to pass through to the package manager + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Check for outdated packages + Outdated { + /// Package name(s) to check + packages: Vec, + + /// Show extended information + #[arg(long)] + long: bool, + + /// Output format: table (default), list, or json + #[arg(long, value_name = "FORMAT", value_parser = clap::value_parser!(Format))] + format: Option, + + /// Check recursively across all workspaces + #[arg(short = 'r', long)] + recursive: bool, + + /// Filter packages in monorepo + #[arg(long, value_name = "PATTERN")] + filter: Option>, + + /// Include workspace root + #[arg(short = 'w', long)] + workspace_root: bool, + + /// Only production and optional dependencies + #[arg(short = 'P', long)] + prod: bool, + + /// Only dev dependencies + #[arg(short = 'D', long)] + dev: bool, + + /// Exclude optional dependencies + #[arg(long)] + no_optional: bool, + + /// Only show compatible versions + #[arg(long)] + compatible: bool, + + /// Sort results by field + #[arg(long, value_name = "FIELD")] + sort_by: Option, + + /// Check globally installed packages + #[arg(short = 'g', long)] + global: bool, + + /// Additional arguments to pass through to the package manager + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Show why a package is installed + #[command(alias = "explain")] + Why { + /// Package(s) to check + #[arg(required = true)] + packages: Vec, + + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Show extended information + #[arg(long)] + long: bool, + + /// Show parseable output + #[arg(long)] + parseable: bool, + + /// Check recursively across all workspaces + #[arg(short = 'r', long)] + recursive: bool, + + /// Filter packages in monorepo + #[arg(long, value_name = "PATTERN")] + filter: Option>, + + /// Check in workspace root + #[arg(short = 'w', long)] + workspace_root: bool, + + /// Only production dependencies + #[arg(short = 'P', long)] + prod: bool, + + /// Only dev dependencies + #[arg(short = 'D', long)] + dev: bool, + + /// Limit tree depth + #[arg(long)] + depth: Option, + + /// Exclude optional dependencies + #[arg(long)] + no_optional: bool, + + /// Check globally installed packages + #[arg(short = 'g', long)] + global: bool, + + /// Exclude peer dependencies + #[arg(long)] + exclude_peers: bool, + + /// Use a finder function defined in .pnpmfile.cjs + #[arg(long, value_name = "FINDER_NAME")] + find_by: Option, + + /// Additional arguments to pass through to the package manager + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// View package information from the registry + #[command(alias = "view", alias = "show")] + Info { + /// Package name with optional version + #[arg(required = true)] + package: String, + + /// Specific field to view + field: Option, + + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Additional arguments to pass through to the package manager + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Link packages for local development + #[command(alias = "ln")] + Link { + /// Package name or directory to link + #[arg(value_name = "PACKAGE|DIR")] + package: Option, + + /// Arguments to pass to package manager + #[arg(allow_hyphen_values = true, trailing_var_arg = true)] + args: Vec, + }, + + /// Unlink packages + Unlink { + /// Package name to unlink + #[arg(value_name = "PACKAGE|DIR")] + package: Option, + + /// Unlink in every workspace package + #[arg(short = 'r', long)] + recursive: bool, + + /// Arguments to pass to package manager + #[arg(allow_hyphen_values = true, trailing_var_arg = true)] + args: Vec, + }, + + /// Execute a package binary without installing it + Dlx { + /// Package(s) to install before running + #[arg(long, short = 'p', value_name = "NAME")] + package: Vec, + + /// Execute within a shell environment + #[arg(long = "shell-mode", short = 'c')] + shell_mode: bool, + + /// Suppress all output except the executed command's output + #[arg(long, short = 's')] + silent: bool, + + /// Package to execute and arguments + #[arg(required = true, trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Forward a command to the package manager + #[command(subcommand)] + Pm(PmCommands), + + // ========================================================================= + // Category B: JS Script Commands + // These commands are implemented in JavaScript and executed via managed Node.js + // ========================================================================= + /// Create a new project from a template (delegates to JS) + #[command(disable_help_flag = true)] + New { + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Migrate an existing project to Vite+ (delegates to JS) + #[command(disable_help_flag = true)] + Migrate { + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + // ========================================================================= + // Category C: Local CLI Delegation (stubs for now) + // ========================================================================= + /// Run the development server + Dev { + /// Additional arguments + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Build application + Build { + /// Additional arguments + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Run tests + Test { + /// Additional arguments + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Lint code + Lint { + /// Additional arguments + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Format code + Fmt { + /// Additional arguments + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Run tasks + Run { + /// Additional arguments + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Preview production build + Preview { + /// Additional arguments + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, + + /// Manage the task cache + Cache { + /// Additional arguments + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + args: Vec, + }, +} + +/// Package manager subcommands +#[derive(Subcommand, Debug, Clone)] +pub enum PmCommands { + /// Remove unnecessary packages + Prune { + /// Remove devDependencies + #[arg(long)] + prod: bool, + + /// Remove optional dependencies + #[arg(long)] + no_optional: bool, + + /// Additional arguments + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Create a tarball of the package + Pack { + /// Pack all workspace packages + #[arg(short = 'r', long)] + recursive: bool, + + /// Filter packages to pack + #[arg(long, value_name = "PATTERN")] + filter: Option>, + + /// Output path for the tarball + #[arg(long)] + out: Option, + + /// Directory where the tarball will be saved + #[arg(long)] + pack_destination: Option, + + /// Gzip compression level (0-9) + #[arg(long)] + pack_gzip_level: Option, + + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Additional arguments + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// List installed packages + #[command(alias = "ls")] + List { + /// Package pattern to filter + pattern: Option, + + /// Maximum depth of dependency tree + #[arg(long)] + depth: Option, + + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Show extended information + #[arg(long)] + long: bool, + + /// Parseable output format + #[arg(long)] + parseable: bool, + + /// Only production dependencies + #[arg(short = 'P', long)] + prod: bool, + + /// Only dev dependencies + #[arg(short = 'D', long)] + dev: bool, + + /// Exclude optional dependencies + #[arg(long)] + no_optional: bool, + + /// Exclude peer dependencies + #[arg(long)] + exclude_peers: bool, + + /// Show only project packages + #[arg(long)] + only_projects: bool, + + /// Use a finder function + #[arg(long, value_name = "FINDER_NAME")] + find_by: Option, + + /// List across all workspaces + #[arg(short = 'r', long)] + recursive: bool, + + /// Filter packages in monorepo + #[arg(long, value_name = "PATTERN")] + filter: Vec, + + /// List global packages + #[arg(short = 'g', long)] + global: bool, + + /// Additional arguments + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// View package information from the registry + #[command(alias = "info", alias = "show")] + View { + /// Package name with optional version + #[arg(required = true)] + package: String, + + /// Specific field to view + field: Option, + + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Additional arguments + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Publish package to registry + Publish { + /// Tarball or folder to publish + #[arg(value_name = "TARBALL|FOLDER")] + target: Option, + + /// Preview without publishing + #[arg(long)] + dry_run: bool, + + /// Publish tag + #[arg(long)] + tag: Option, + + /// Access level (public/restricted) + #[arg(long)] + access: Option, + + /// One-time password for authentication + #[arg(long, value_name = "OTP")] + otp: Option, + + /// Skip git checks + #[arg(long)] + no_git_checks: bool, + + /// Set the branch name to publish from + #[arg(long, value_name = "BRANCH")] + publish_branch: Option, + + /// Save publish summary + #[arg(long)] + report_summary: bool, + + /// Force publish + #[arg(long)] + force: bool, + + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Publish all workspace packages + #[arg(short = 'r', long)] + recursive: bool, + + /// Filter packages in monorepo + #[arg(long, value_name = "PATTERN")] + filter: Option>, + + /// Additional arguments + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Manage package owners + #[command(subcommand, alias = "author")] + Owner(OwnerCommands), + + /// Manage package cache + Cache { + /// Subcommand: dir, path, clean + #[arg(required = true)] + subcommand: String, + + /// Additional arguments + #[arg(last = true, allow_hyphen_values = true)] + pass_through_args: Option>, + }, + + /// Manage package manager configuration + #[command(subcommand, alias = "c")] + Config(ConfigCommands), +} + +/// Configuration subcommands +#[derive(Subcommand, Debug, Clone)] +pub enum ConfigCommands { + /// List all configuration + List { + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Use global config + #[arg(short = 'g', long)] + global: bool, + + /// Config location: project (default) or global + #[arg(long, value_name = "LOCATION")] + location: Option, + }, + + /// Get configuration value + Get { + /// Config key + key: String, + + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Use global config + #[arg(short = 'g', long)] + global: bool, + + /// Config location + #[arg(long, value_name = "LOCATION")] + location: Option, + }, + + /// Set configuration value + Set { + /// Config key + key: String, + + /// Config value + value: String, + + /// Output in JSON format + #[arg(long)] + json: bool, + + /// Use global config + #[arg(short = 'g', long)] + global: bool, + + /// Config location + #[arg(long, value_name = "LOCATION")] + location: Option, + }, + + /// Delete configuration key + Delete { + /// Config key + key: String, + + /// Use global config + #[arg(short = 'g', long)] + global: bool, + + /// Config location + #[arg(long, value_name = "LOCATION")] + location: Option, + }, +} + +/// Owner subcommands +#[derive(Subcommand, Debug, Clone)] +pub enum OwnerCommands { + /// List package owners + #[command(alias = "ls")] + List { + /// Package name + package: String, + + /// One-time password for authentication + #[arg(long, value_name = "OTP")] + otp: Option, + }, + + /// Add package owner + Add { + /// Username + user: String, + /// Package name + package: String, + + /// One-time password for authentication + #[arg(long, value_name = "OTP")] + otp: Option, + }, + + /// Remove package owner + Rm { + /// Username + user: String, + /// Package name + package: String, + + /// One-time password for authentication + #[arg(long, value_name = "OTP")] + otp: Option, + }, +} + +/// Determine the save dependency type from CLI flags. +fn determine_save_dependency_type( + save_dev: bool, + save_peer: bool, + save_optional: bool, + save_prod: bool, +) -> Option { + if save_dev { + Some(SaveDependencyType::Dev) + } else if save_peer { + Some(SaveDependencyType::Peer) + } else if save_optional { + Some(SaveDependencyType::Optional) + } else if save_prod { + Some(SaveDependencyType::Production) + } else { + None + } +} + +/// Run the CLI command. +pub async fn run_command(cwd: AbsolutePathBuf, args: Args) -> Result { + // Handle --version flag (Category B: delegates to JS) + if args.version { + return commands::version::execute(cwd).await; + } + + // If no command provided, show help and exit + let Some(command) = args.command else { + // Use custom help formatting to match the JS CLI output + command_with_help().print_help().ok(); + println!(); + // Return a successful exit status since help was requested implicitly + return Ok(std::process::ExitStatus::default()); + }; + + match command { + // Category A: Package Manager Commands + Commands::Install { + prod, + dev, + no_optional, + frozen_lockfile, + no_frozen_lockfile, + lockfile_only, + prefer_offline, + offline, + force, + ignore_scripts, + no_lockfile, + fix_lockfile, + shamefully_hoist, + resolution_only, + silent, + filter, + workspace_root, + save_exact, + save_peer, + save_optional, + save_catalog, + global, + packages, + pass_through_args, + } => { + // If packages are provided, redirect to Add command + if let Some(pkgs) = packages + && !pkgs.is_empty() + { + let save_dependency_type = + determine_save_dependency_type(dev, save_peer, save_optional, prod); + + return AddCommand::new(cwd) + .execute( + &pkgs, + save_dependency_type, + save_exact, + if save_catalog { Some("default") } else { None }, + filter.as_deref(), + workspace_root, + false, // workspace_only + global, + None, // allow_build + pass_through_args.as_deref(), + ) + .await; + } + + // No packages provided, run regular install + let options = InstallCommandOptions { + prod, + dev, + no_optional, + frozen_lockfile, + no_frozen_lockfile, + lockfile_only, + prefer_offline, + offline, + force, + ignore_scripts, + no_lockfile, + fix_lockfile, + shamefully_hoist, + resolution_only, + silent, + filters: filter.as_deref(), + workspace_root, + pass_through_args: pass_through_args.as_deref(), + }; + InstallCommand::new(cwd).execute(&options).await + } + + Commands::Add { + save_prod, + save_dev, + save_peer, + save_optional, + save_exact, + save_catalog_name, + save_catalog, + allow_build, + filter, + workspace_root, + workspace, + global, + packages, + pass_through_args, + } => { + let save_dependency_type = + determine_save_dependency_type(save_dev, save_peer, save_optional, save_prod); + + let catalog_name = + if save_catalog { Some("default") } else { save_catalog_name.as_deref() }; + + AddCommand::new(cwd) + .execute( + &packages, + save_dependency_type, + save_exact, + catalog_name, + filter.as_deref(), + workspace_root, + workspace, + global, + allow_build.as_deref(), + pass_through_args.as_deref(), + ) + .await + } + + Commands::Remove { + save_dev, + save_optional, + save_prod, + filter, + workspace_root, + recursive, + global, + packages, + pass_through_args, + } => { + RemoveCommand::new(cwd) + .execute( + &packages, + save_dev, + save_optional, + save_prod, + filter.as_deref(), + workspace_root, + recursive, + global, + pass_through_args.as_deref(), + ) + .await + } + + Commands::Update { + latest, + global, + recursive, + filter, + workspace_root, + dev, + prod, + interactive, + no_optional, + no_save, + workspace, + packages, + pass_through_args, + } => { + UpdateCommand::new(cwd) + .execute( + &packages, + latest, + global, + recursive, + filter.as_deref(), + workspace_root, + dev, + prod, + interactive, + no_optional, + no_save, + workspace, + pass_through_args.as_deref(), + ) + .await + } + + Commands::Dedupe { check, pass_through_args } => { + DedupeCommand::new(cwd).execute(check, pass_through_args.as_deref()).await + } + + Commands::Outdated { + packages, + long, + format, + recursive, + filter, + workspace_root, + prod, + dev, + no_optional, + compatible, + sort_by, + global, + pass_through_args, + } => { + OutdatedCommand::new(cwd) + .execute( + &packages, + long, + format, + recursive, + filter.as_deref(), + workspace_root, + prod, + dev, + no_optional, + compatible, + sort_by.as_deref(), + global, + pass_through_args.as_deref(), + ) + .await + } + + Commands::Why { + packages, + json, + long, + parseable, + recursive, + filter, + workspace_root, + prod, + dev, + depth, + no_optional, + global, + exclude_peers, + find_by, + pass_through_args, + } => { + WhyCommand::new(cwd) + .execute( + &packages, + json, + long, + parseable, + recursive, + filter.as_deref(), + workspace_root, + prod, + dev, + depth, + no_optional, + global, + exclude_peers, + find_by.as_deref(), + pass_through_args.as_deref(), + ) + .await + } + + Commands::Info { package, field, json, pass_through_args } => { + commands::pm::execute_info( + cwd, + &package, + field.as_deref(), + json, + pass_through_args.as_deref(), + ) + .await + } + + Commands::Link { package, args } => { + let pass_through = if args.is_empty() { None } else { Some(args.as_slice()) }; + LinkCommand::new(cwd).execute(package.as_deref(), pass_through).await + } + + Commands::Unlink { package, recursive, args } => { + let pass_through = if args.is_empty() { None } else { Some(args.as_slice()) }; + UnlinkCommand::new(cwd).execute(package.as_deref(), recursive, pass_through).await + } + + Commands::Dlx { package, shell_mode, silent, args } => { + DlxCommand::new(cwd).execute(package, shell_mode, silent, args).await + } + + Commands::Pm(pm_command) => commands::pm::execute_pm_subcommand(cwd, pm_command).await, + + // Category B: JS Script Commands + Commands::New { args } => commands::new::execute(cwd, &args).await, + + Commands::Migrate { args } => commands::migrate::execute(cwd, &args).await, + + // Category C: Local CLI Delegation (stubs) + Commands::Dev { args } => commands::delegate::execute(cwd, "dev", &args).await, + + Commands::Build { args } => commands::delegate::execute(cwd, "build", &args).await, + + Commands::Test { args } => commands::delegate::execute(cwd, "test", &args).await, + + Commands::Lint { args } => commands::delegate::execute(cwd, "lint", &args).await, + + Commands::Fmt { args } => commands::delegate::execute(cwd, "fmt", &args).await, + + Commands::Run { args } => commands::delegate::execute(cwd, "run", &args).await, + + Commands::Preview { args } => commands::delegate::execute(cwd, "preview", &args).await, + + Commands::Cache { args } => commands::delegate::execute(cwd, "cache", &args).await, + } +} + +/// Build a clap Command with custom help formatting matching the JS CLI output. +pub fn command_with_help() -> clap::Command { + apply_custom_help(Args::command()) +} + +/// Apply custom help formatting to a clap Command to match the JS CLI output. +fn apply_custom_help(cmd: clap::Command) -> clap::Command { + let bold = "\x1b[1m"; + let bold_underline = "\x1b[1;4m"; + let reset = "\x1b[0m"; + let version = env!("CARGO_PKG_VERSION"); + + let after_help = format!( + "{bold_underline}Vite+ Commands:{reset} + {bold}dev{reset} Run the development server + {bold}build{reset} Build for production + {bold}lint{reset} Lint code + {bold}test{reset} Run tests + {bold}fmt{reset} Format code + {bold}lib{reset} Build library + {bold}migrate{reset} Migrate an existing project to Vite+ + {bold}cache{reset} Manage the task cache + {bold}new{reset} Generate a new project + {bold}run{reset} Run tasks + +{bold_underline}Package Manager Commands:{reset} + {bold}install{reset} Install all dependencies, or add packages if package names are provided + {bold}add{reset} Add packages to dependencies + {bold}remove{reset} Remove packages from dependencies + {bold}dedupe{reset} Deduplicate dependencies by removing older versions + {bold}dlx{reset} Execute a package binary without installing it as a dependency + {bold}info{reset} View package information from the registry + {bold}link{reset} Link packages for local development + {bold}outdated{reset} Check for outdated packages + {bold}pm{reset} Forward a command to the package manager + {bold}unlink{reset} Unlink packages + {bold}update{reset} Update packages to their latest versions + {bold}why{reset} Show why a package is installed +" + ); + let help_template = format!( + "Vite+/{version} + +{{usage-heading}} {{usage}}{{after-help}} +{bold_underline}Options:{reset} +{{options}} +" + ); + + cmd.after_help(after_help).help_template(help_template) +} + +/// Parse CLI arguments from a custom args iterator with custom help formatting. +pub fn parse_args_from(args: impl IntoIterator) -> Args { + let cmd = apply_custom_help(Args::command()); + Args::from_arg_matches(&cmd.get_matches_from(args)).expect("Failed to parse CLI arguments") +} diff --git a/packages/global/binding/src/commands/add.rs b/crates/vite_global_cli/src/commands/add.rs similarity index 89% rename from packages/global/binding/src/commands/add.rs rename to crates/vite_global_cli/src/commands/add.rs index a0944e5e93..4cd90cdffc 100644 --- a/packages/global/binding/src/commands/add.rs +++ b/crates/vite_global_cli/src/commands/add.rs @@ -6,7 +6,8 @@ use vite_install::{ }; use vite_path::AbsolutePathBuf; -use crate::Error; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; /// Add command for adding packages to dependencies. /// @@ -34,6 +35,8 @@ impl AddCommand { allow_build: Option<&str>, pass_through_args: Option<&[String]>, ) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + let add_command_options = AddCommandOptions { packages, save_dependency_type, @@ -50,7 +53,7 @@ impl AddCommand { // Detect package manager let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; - package_manager.run_add_command(&add_command_options, &self.cwd).await + Ok(package_manager.run_add_command(&add_command_options, &self.cwd).await?) } } diff --git a/packages/global/binding/src/commands/dedupe.rs b/crates/vite_global_cli/src/commands/dedupe.rs similarity index 85% rename from packages/global/binding/src/commands/dedupe.rs rename to crates/vite_global_cli/src/commands/dedupe.rs index f1e407ab8e..f99b392de4 100644 --- a/packages/global/binding/src/commands/dedupe.rs +++ b/crates/vite_global_cli/src/commands/dedupe.rs @@ -3,7 +3,8 @@ use std::process::ExitStatus; use vite_install::{commands::dedupe::DedupeCommandOptions, package_manager::PackageManager}; use vite_path::AbsolutePathBuf; -use crate::Error; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; /// Dedupe command for deduplicating dependencies by removing older versions. /// @@ -23,11 +24,13 @@ impl DedupeCommand { check: bool, pass_through_args: Option<&[String]>, ) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + // Detect package manager let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; let dedupe_command_options = DedupeCommandOptions { check, pass_through_args }; - package_manager.run_dedupe_command(&dedupe_command_options, &self.cwd).await + Ok(package_manager.run_dedupe_command(&dedupe_command_options, &self.cwd).await?) } } diff --git a/crates/vite_global_cli/src/commands/delegate.rs b/crates/vite_global_cli/src/commands/delegate.rs new file mode 100644 index 0000000000..db0896a4e1 --- /dev/null +++ b/crates/vite_global_cli/src/commands/delegate.rs @@ -0,0 +1,28 @@ +//! Local CLI delegation (Category C: Local CLI Command). + +use std::process::ExitStatus; + +use vite_path::AbsolutePathBuf; + +use crate::{error::Error, js_executor::JsExecutor}; + +/// Execute a command by delegating to the local `vite-plus` CLI. +pub async fn execute( + cwd: AbsolutePathBuf, + command: &str, + args: &[String], +) -> Result { + let mut executor = JsExecutor::new(None); + let mut full_args = vec![command.to_string()]; + full_args.extend(args.iter().cloned()); + executor.delegate_to_local_cli(&cwd, &full_args).await +} + +#[cfg(test)] +mod tests { + #[test] + fn test_delegate_command_module_exists() { + // Basic test to ensure the module compiles + assert!(true); + } +} diff --git a/packages/global/binding/src/commands/dlx.rs b/crates/vite_global_cli/src/commands/dlx.rs similarity index 85% rename from packages/global/binding/src/commands/dlx.rs rename to crates/vite_global_cli/src/commands/dlx.rs index 714b016885..605bf14c7b 100644 --- a/packages/global/binding/src/commands/dlx.rs +++ b/crates/vite_global_cli/src/commands/dlx.rs @@ -1,9 +1,11 @@ use std::process::ExitStatus; -use vite_error::Error; use vite_install::{commands::dlx::DlxCommandOptions, package_manager::PackageManager}; use vite_path::AbsolutePathBuf; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; + /// Dlx command for executing packages without installing them as dependencies. /// /// This command automatically detects the package manager and translates @@ -29,9 +31,11 @@ impl DlxCommand { args: Vec, ) -> Result { if args.is_empty() { - return Err(Error::InvalidArgument("dlx requires a package name".into())); + return Err(Error::Other("dlx requires a package name".into())); } + prepend_js_runtime_to_path_env(&self.cwd).await?; + // First arg is the package spec, rest are command args let package_spec = &args[0]; let command_args: Vec = args[1..].to_vec(); @@ -47,7 +51,7 @@ impl DlxCommand { silent, }; - package_manager.run_dlx_command(&dlx_command_options, &self.cwd).await + Ok(package_manager.run_dlx_command(&dlx_command_options, &self.cwd).await?) } } diff --git a/packages/global/binding/src/commands/install.rs b/crates/vite_global_cli/src/commands/install.rs similarity index 92% rename from packages/global/binding/src/commands/install.rs rename to crates/vite_global_cli/src/commands/install.rs index aab634bf09..fb6e719b9c 100644 --- a/packages/global/binding/src/commands/install.rs +++ b/crates/vite_global_cli/src/commands/install.rs @@ -1,9 +1,11 @@ use std::process::ExitStatus; -use vite_error::Error; use vite_install::{PackageManager, commands::install::InstallCommandOptions}; use vite_path::AbsolutePathBuf; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; + /// Install command. pub struct InstallCommand { cwd: AbsolutePathBuf, @@ -15,9 +17,11 @@ impl InstallCommand { } pub async fn execute(self, options: &InstallCommandOptions<'_>) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; - package_manager.run_install_command(options, &self.cwd).await + Ok(package_manager.run_install_command(options, &self.cwd).await?) } } @@ -60,7 +64,6 @@ mod tests { } #[tokio::test] - #[cfg(not(windows))] // FIXME async fn test_install_command_with_package_json_with_package_manager() { let temp_dir = TempDir::new().unwrap(); let workspace_root = AbsolutePathBuf::new(temp_dir.path().to_path_buf()).unwrap(); @@ -87,7 +90,6 @@ mod tests { let command = InstallCommand::new(workspace_root); let result = command.execute(&InstallCommandOptions::default()).await; - let err = result.unwrap_err(); - assert!(matches!(err, Error::WorkspaceError(_))); + assert!(result.is_err()); } } diff --git a/packages/global/binding/src/commands/link.rs b/crates/vite_global_cli/src/commands/link.rs similarity index 85% rename from packages/global/binding/src/commands/link.rs rename to crates/vite_global_cli/src/commands/link.rs index 681a904b1c..34b310d623 100644 --- a/packages/global/binding/src/commands/link.rs +++ b/crates/vite_global_cli/src/commands/link.rs @@ -3,7 +3,8 @@ use std::process::ExitStatus; use vite_install::{commands::link::LinkCommandOptions, package_manager::PackageManager}; use vite_path::AbsolutePathBuf; -use crate::Error; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; /// Link command for local package development. /// @@ -23,11 +24,13 @@ impl LinkCommand { package: Option<&str>, pass_through_args: Option<&[String]>, ) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + // Detect package manager let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; let link_command_options = LinkCommandOptions { package, pass_through_args }; - package_manager.run_link_command(&link_command_options, &self.cwd).await + Ok(package_manager.run_link_command(&link_command_options, &self.cwd).await?) } } diff --git a/crates/vite_global_cli/src/commands/migrate.rs b/crates/vite_global_cli/src/commands/migrate.rs new file mode 100644 index 0000000000..eb46a607ab --- /dev/null +++ b/crates/vite_global_cli/src/commands/migrate.rs @@ -0,0 +1,25 @@ +//! Migration command (Category B: JS Script Command). + +use std::process::ExitStatus; + +use vite_path::AbsolutePathBuf; + +use crate::{error::Error, js_executor::JsExecutor}; + +/// Execute the `migrate` command by delegating to the bundled JavaScript implementation. +pub async fn execute(cwd: AbsolutePathBuf, args: &[String]) -> Result { + let mut executor = JsExecutor::new(None); + + // Execute the bundled JS script with the "migrate" command + // The JS script handles all migration logic + executor.execute_cli_script("index.js", "migrate", args, &cwd).await +} + +#[cfg(test)] +mod tests { + #[test] + fn test_migrate_command_module_exists() { + // Basic test to ensure the module compiles + assert!(true); + } +} diff --git a/crates/vite_global_cli/src/commands/mod.rs b/crates/vite_global_cli/src/commands/mod.rs new file mode 100644 index 0000000000..13f62d0c5e --- /dev/null +++ b/crates/vite_global_cli/src/commands/mod.rs @@ -0,0 +1,100 @@ +//! Command implementations for the global CLI. +//! +//! Commands are organized by category: +//! +//! Category A - Package manager commands: +//! - `add`: Add packages to dependencies +//! - `install`: Install all dependencies +//! - `remove`: Remove packages from dependencies +//! - `update`: Update packages to their latest versions +//! - `dedupe`: Deduplicate dependencies +//! - `outdated`: Check for outdated packages +//! - `why`: Show why a package is installed +//! - `link`: Link packages for local development +//! - `unlink`: Unlink packages +//! - `dlx`: Execute a package binary without installing it +//! - `pm`: Forward commands to the package manager +//! +//! Category B - JS Script Commands: +//! - `new`: Project scaffolding +//! - `migrate`: Migration command +//! - `version`: Version display +//! +//! Category C - Local CLI Delegation: +//! - `delegate`: Local CLI delegation + +use vite_path::AbsolutePath; + +use crate::{error::Error, js_executor::JsExecutor}; + +/// Ensure the JS runtime is downloaded and prepend its bin directory to PATH. +/// This should be called before executing any package manager command. +/// +/// If `project_path` contains a package.json, uses the project's runtime +/// (based on devEngines.runtime). Otherwise, falls back to the CLI's runtime. +pub async fn prepend_js_runtime_to_path_env(project_path: &AbsolutePath) -> Result<(), Error> { + let mut executor = JsExecutor::new(None); + + // Use project runtime if package.json exists, otherwise use CLI runtime + let package_json_path = project_path.join("package.json"); + let runtime = if package_json_path.as_path().exists() { + executor.ensure_project_runtime(project_path).await? + } else { + executor.ensure_cli_runtime().await? + }; + + let node_bin_path = runtime.get_bin_prefix().as_path().to_path_buf(); + + // Check if node bin path already exists in PATH to avoid duplicates + let current_path = std::env::var_os("PATH").unwrap_or_default(); + let paths: Vec<_> = std::env::split_paths(¤t_path).collect(); + + if paths.iter().any(|p| p == &node_bin_path) { + return Ok(()); + } + + // Prepend node bin to PATH + let mut new_paths = vec![node_bin_path]; + new_paths.extend(paths); + let new_path = std::env::join_paths(new_paths).expect("Failed to join paths"); + tracing::debug!("Set PATH to {:?}", new_path); + // SAFETY: We're modifying PATH at the start of command execution before any + // parallel operations. This is safe because package manager commands run + // sequentially and child processes inherit the modified environment. + unsafe { std::env::set_var("PATH", new_path) }; + + Ok(()) +} + +// Category A: Package manager commands +pub mod add; +pub mod dedupe; +pub mod dlx; +pub mod install; +pub mod link; +pub mod outdated; +pub mod pm; +pub mod remove; +pub mod unlink; +pub mod update; +pub mod why; + +// Category B: JS Script Commands +pub mod migrate; +pub mod new; +pub mod version; + +// Category C: Local CLI Delegation +pub mod delegate; + +// Re-export command structs for convenient access +pub use add::AddCommand; +pub use dedupe::DedupeCommand; +pub use dlx::DlxCommand; +pub use install::InstallCommand; +pub use link::LinkCommand; +pub use outdated::OutdatedCommand; +pub use remove::RemoveCommand; +pub use unlink::UnlinkCommand; +pub use update::UpdateCommand; +pub use why::WhyCommand; diff --git a/crates/vite_global_cli/src/commands/new.rs b/crates/vite_global_cli/src/commands/new.rs new file mode 100644 index 0000000000..aed4e4345d --- /dev/null +++ b/crates/vite_global_cli/src/commands/new.rs @@ -0,0 +1,25 @@ +//! Project scaffolding command (Category B: JS Script Command). + +use std::process::ExitStatus; + +use vite_path::AbsolutePathBuf; + +use crate::{error::Error, js_executor::JsExecutor}; + +/// Execute the `new` command by delegating to the bundled JavaScript implementation. +pub async fn execute(cwd: AbsolutePathBuf, args: &[String]) -> Result { + let mut executor = JsExecutor::new(None); + + // Execute the bundled JS script with the "new" command + // The JS script handles all argument parsing, template discovery, and execution + executor.execute_cli_script("index.js", "new", args, &cwd).await +} + +#[cfg(test)] +mod tests { + #[test] + fn test_new_command_module_exists() { + // Basic test to ensure the module compiles + assert!(true); + } +} diff --git a/packages/global/binding/src/commands/outdated.rs b/crates/vite_global_cli/src/commands/outdated.rs similarity index 89% rename from packages/global/binding/src/commands/outdated.rs rename to crates/vite_global_cli/src/commands/outdated.rs index e1d8f4fdb6..e1557de8c5 100644 --- a/packages/global/binding/src/commands/outdated.rs +++ b/crates/vite_global_cli/src/commands/outdated.rs @@ -6,7 +6,8 @@ use vite_install::{ }; use vite_path::AbsolutePathBuf; -use crate::Error; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; /// Outdated command for checking outdated packages. /// @@ -38,6 +39,8 @@ impl OutdatedCommand { global: bool, pass_through_args: Option<&[String]>, ) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + // Detect package manager let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; @@ -56,7 +59,7 @@ impl OutdatedCommand { global, pass_through_args, }; - package_manager.run_outdated_command(&outdated_command_options, &self.cwd).await + Ok(package_manager.run_outdated_command(&outdated_command_options, &self.cwd).await?) } } diff --git a/crates/vite_global_cli/src/commands/pm.rs b/crates/vite_global_cli/src/commands/pm.rs new file mode 100644 index 0000000000..e93a923b6b --- /dev/null +++ b/crates/vite_global_cli/src/commands/pm.rs @@ -0,0 +1,241 @@ +//! Package manager commands (Category A). +//! +//! This module handles the `pm` subcommand and the `info` command which are +//! routed through helper functions. Other PM commands (add, install, remove, etc.) +//! are implemented as separate command modules with struct-based patterns. + +use std::process::ExitStatus; + +use vite_install::{ + PackageManager, + commands::{ + cache::CacheCommandOptions, config::ConfigCommandOptions, list::ListCommandOptions, + owner::OwnerSubcommand, pack::PackCommandOptions, prune::PruneCommandOptions, + publish::PublishCommandOptions, view::ViewCommandOptions, + }, +}; +use vite_path::AbsolutePathBuf; + +use super::prepend_js_runtime_to_path_env; +use crate::{ + cli::{ConfigCommands, OwnerCommands, PmCommands}, + error::Error, +}; + +/// Execute the info command. +pub async fn execute_info( + cwd: AbsolutePathBuf, + package: &str, + field: Option<&str>, + json: bool, + pass_through_args: Option<&[String]>, +) -> Result { + prepend_js_runtime_to_path_env(&cwd).await?; + + let package_manager = PackageManager::builder(&cwd).build_with_default().await?; + + let options = ViewCommandOptions { package, field, json, pass_through_args }; + + Ok(package_manager.run_view_command(&options, &cwd).await?) +} + +/// Execute a pm subcommand. +pub async fn execute_pm_subcommand( + cwd: AbsolutePathBuf, + command: PmCommands, +) -> Result { + prepend_js_runtime_to_path_env(&cwd).await?; + + let package_manager = PackageManager::builder(&cwd).build_with_default().await?; + + match command { + PmCommands::Prune { prod, no_optional, pass_through_args } => { + let options = PruneCommandOptions { + prod, + no_optional, + pass_through_args: pass_through_args.as_deref(), + }; + Ok(package_manager.run_prune_command(&options, &cwd).await?) + } + + PmCommands::Pack { + recursive, + filter, + out, + pack_destination, + pack_gzip_level, + json, + pass_through_args, + } => { + let options = PackCommandOptions { + recursive, + filters: filter.as_deref(), + out: out.as_deref(), + pack_destination: pack_destination.as_deref(), + pack_gzip_level, + json, + pass_through_args: pass_through_args.as_deref(), + }; + Ok(package_manager.run_pack_command(&options, &cwd).await?) + } + + PmCommands::List { + pattern, + depth, + json, + long, + parseable, + prod, + dev, + no_optional, + exclude_peers, + only_projects, + find_by, + recursive, + filter, + global, + pass_through_args, + } => { + let options = ListCommandOptions { + pattern: pattern.as_deref(), + depth, + json, + long, + parseable, + prod, + dev, + no_optional, + exclude_peers, + only_projects, + find_by: find_by.as_deref(), + recursive, + filters: if filter.is_empty() { None } else { Some(&filter) }, + global, + pass_through_args: pass_through_args.as_deref(), + }; + Ok(package_manager.run_list_command(&options, &cwd).await?) + } + + PmCommands::View { package, field, json, pass_through_args } => { + let options = ViewCommandOptions { + package: &package, + field: field.as_deref(), + json, + pass_through_args: pass_through_args.as_deref(), + }; + Ok(package_manager.run_view_command(&options, &cwd).await?) + } + + PmCommands::Publish { + target, + dry_run, + tag, + access, + otp, + no_git_checks, + publish_branch, + report_summary, + force, + json, + recursive, + filter, + pass_through_args, + } => { + let options = PublishCommandOptions { + target: target.as_deref(), + dry_run, + tag: tag.as_deref(), + access: access.as_deref(), + otp: otp.as_deref(), + no_git_checks, + publish_branch: publish_branch.as_deref(), + report_summary, + force, + json, + recursive, + filters: filter.as_deref(), + pass_through_args: pass_through_args.as_deref(), + }; + Ok(package_manager.run_publish_command(&options, &cwd).await?) + } + + PmCommands::Owner(owner_command) => { + let subcommand = match owner_command { + OwnerCommands::List { package, otp } => OwnerSubcommand::List { package, otp }, + OwnerCommands::Add { user, package, otp } => { + OwnerSubcommand::Add { user, package, otp } + } + OwnerCommands::Rm { user, package, otp } => { + OwnerSubcommand::Rm { user, package, otp } + } + }; + Ok(package_manager.run_owner_command(&subcommand, &cwd).await?) + } + + PmCommands::Cache { subcommand, pass_through_args } => { + let options = CacheCommandOptions { + subcommand: &subcommand, + pass_through_args: pass_through_args.as_deref(), + }; + Ok(package_manager.run_cache_command(&options, &cwd).await?) + } + + PmCommands::Config(config_command) => match config_command { + ConfigCommands::List { json, global, location } => { + let options = ConfigCommandOptions { + subcommand: "list", + key: None, + value: None, + json, + location: if global { Some("global") } else { location.as_deref() }, + pass_through_args: None, + }; + Ok(package_manager.run_config_command(&options, &cwd).await?) + } + ConfigCommands::Get { key, json, global, location } => { + let options = ConfigCommandOptions { + subcommand: "get", + key: Some(key.as_str()), + value: None, + json, + location: if global { Some("global") } else { location.as_deref() }, + pass_through_args: None, + }; + Ok(package_manager.run_config_command(&options, &cwd).await?) + } + ConfigCommands::Set { key, value, json, global, location } => { + let options = ConfigCommandOptions { + subcommand: "set", + key: Some(key.as_str()), + value: Some(value.as_str()), + json, + location: if global { Some("global") } else { location.as_deref() }, + pass_through_args: None, + }; + Ok(package_manager.run_config_command(&options, &cwd).await?) + } + ConfigCommands::Delete { key, global, location } => { + let options = ConfigCommandOptions { + subcommand: "delete", + key: Some(key.as_str()), + value: None, + json: false, + location: if global { Some("global") } else { location.as_deref() }, + pass_through_args: None, + }; + Ok(package_manager.run_config_command(&options, &cwd).await?) + } + }, + } +} + +#[cfg(test)] +mod tests { + use vite_install::commands::add::SaveDependencyType; + + #[test] + fn test_save_dependency_type() { + assert!(matches!(SaveDependencyType::Dev, SaveDependencyType::Dev)); + assert!(matches!(SaveDependencyType::Production, SaveDependencyType::Production)); + } +} diff --git a/packages/global/binding/src/commands/remove.rs b/crates/vite_global_cli/src/commands/remove.rs similarity index 88% rename from packages/global/binding/src/commands/remove.rs rename to crates/vite_global_cli/src/commands/remove.rs index f227bbc3ca..dfe4c1f026 100644 --- a/packages/global/binding/src/commands/remove.rs +++ b/crates/vite_global_cli/src/commands/remove.rs @@ -3,7 +3,8 @@ use std::process::ExitStatus; use vite_install::{commands::remove::RemoveCommandOptions, package_manager::PackageManager}; use vite_path::AbsolutePathBuf; -use crate::Error; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; /// Remove command for removing packages from dependencies. /// @@ -30,6 +31,8 @@ impl RemoveCommand { global: bool, pass_through_args: Option<&[String]>, ) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + // Detect package manager let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; @@ -44,7 +47,7 @@ impl RemoveCommand { save_prod, pass_through_args, }; - package_manager.run_remove_command(&remove_command_options, &self.cwd).await + Ok(package_manager.run_remove_command(&remove_command_options, &self.cwd).await?) } } diff --git a/packages/global/binding/src/commands/unlink.rs b/crates/vite_global_cli/src/commands/unlink.rs similarity index 85% rename from packages/global/binding/src/commands/unlink.rs rename to crates/vite_global_cli/src/commands/unlink.rs index ea72b62421..8f88c869e7 100644 --- a/packages/global/binding/src/commands/unlink.rs +++ b/crates/vite_global_cli/src/commands/unlink.rs @@ -3,7 +3,8 @@ use std::process::ExitStatus; use vite_install::{commands::unlink::UnlinkCommandOptions, package_manager::PackageManager}; use vite_path::AbsolutePathBuf; -use crate::Error; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; /// Unlink command for removing package links. /// @@ -24,11 +25,13 @@ impl UnlinkCommand { recursive: bool, pass_through_args: Option<&[String]>, ) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + // Detect package manager let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; let unlink_command_options = UnlinkCommandOptions { package, recursive, pass_through_args }; - package_manager.run_unlink_command(&unlink_command_options, &self.cwd).await + Ok(package_manager.run_unlink_command(&unlink_command_options, &self.cwd).await?) } } diff --git a/packages/global/binding/src/commands/update.rs b/crates/vite_global_cli/src/commands/update.rs similarity index 87% rename from packages/global/binding/src/commands/update.rs rename to crates/vite_global_cli/src/commands/update.rs index eb84142137..86a30727ae 100644 --- a/packages/global/binding/src/commands/update.rs +++ b/crates/vite_global_cli/src/commands/update.rs @@ -3,7 +3,8 @@ use std::process::ExitStatus; use vite_install::{commands::update::UpdateCommandOptions, package_manager::PackageManager}; use vite_path::AbsolutePathBuf; -use crate::Error; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; /// Update command for updating packages to their latest versions. /// @@ -18,6 +19,7 @@ impl UpdateCommand { Self { cwd } } + #[allow(clippy::too_many_arguments)] pub async fn execute( self, packages: &[String], @@ -34,6 +36,8 @@ impl UpdateCommand { workspace_only: bool, pass_through_args: Option<&[String]>, ) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + // Detect package manager let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; @@ -52,7 +56,7 @@ impl UpdateCommand { workspace_only, pass_through_args, }; - package_manager.run_update_command(&update_command_options, &self.cwd).await + Ok(package_manager.run_update_command(&update_command_options, &self.cwd).await?) } } diff --git a/crates/vite_global_cli/src/commands/version.rs b/crates/vite_global_cli/src/commands/version.rs new file mode 100644 index 0000000000..14ba4af197 --- /dev/null +++ b/crates/vite_global_cli/src/commands/version.rs @@ -0,0 +1,22 @@ +//! Version command (Category B: JS Script Command). + +use std::process::ExitStatus; + +use vite_path::AbsolutePathBuf; + +use crate::{error::Error, js_executor::JsExecutor}; + +/// Execute the `--version` command by delegating to the bundled JavaScript implementation. +pub async fn execute(cwd: AbsolutePathBuf) -> Result { + let mut executor = JsExecutor::new(None); + executor.execute_cli_script("index.js", "--version", &[], &cwd).await +} + +#[cfg(test)] +mod tests { + #[test] + fn test_version_command_module_exists() { + // Basic test to ensure the module compiles + assert!(true); + } +} diff --git a/packages/global/binding/src/commands/why.rs b/crates/vite_global_cli/src/commands/why.rs similarity index 90% rename from packages/global/binding/src/commands/why.rs rename to crates/vite_global_cli/src/commands/why.rs index 67366bcd62..f2008abe52 100644 --- a/packages/global/binding/src/commands/why.rs +++ b/crates/vite_global_cli/src/commands/why.rs @@ -3,7 +3,8 @@ use std::process::ExitStatus; use vite_install::{commands::why::WhyCommandOptions, package_manager::PackageManager}; use vite_path::AbsolutePathBuf; -use crate::Error; +use super::prepend_js_runtime_to_path_env; +use crate::error::Error; /// Why command for showing why a package is installed. /// @@ -37,6 +38,8 @@ impl WhyCommand { find_by: Option<&str>, pass_through_args: Option<&[String]>, ) -> Result { + prepend_js_runtime_to_path_env(&self.cwd).await?; + // Detect package manager let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; @@ -57,7 +60,7 @@ impl WhyCommand { find_by, pass_through_args, }; - package_manager.run_why_command(&why_command_options, &self.cwd).await + Ok(package_manager.run_why_command(&why_command_options, &self.cwd).await?) } } diff --git a/crates/vite_global_cli/src/error.rs b/crates/vite_global_cli/src/error.rs new file mode 100644 index 0000000000..d12bfc5f5d --- /dev/null +++ b/crates/vite_global_cli/src/error.rs @@ -0,0 +1,39 @@ +//! Error types for the global CLI. + +use std::io; + +use vite_str::Str; + +/// Error type for the global CLI. +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[allow(dead_code)] // Will be used for better error messages + #[error("No package manager detected. Please run in a project directory with a package.json.")] + NoPackageManager, + + #[error("Failed to download Node.js runtime: {0}")] + RuntimeDownload(#[from] vite_js_runtime::Error), + + #[error("Command execution failed: {0}")] + CommandExecution(#[from] io::Error), + + #[error( + "JS scripts directory not found. Set VITE_GLOBAL_CLI_JS_SCRIPTS_DIR or ensure scripts are bundled." + )] + JsScriptsDirNotFound, + + #[error("Failed to determine CLI binary path")] + CliBinaryNotFound, + + #[error("JS entry point not found at {0}")] + JsEntryPointNotFound(Str), + + #[error("Workspace error: {0}")] + Workspace(#[from] vite_workspace::Error), + + #[error("Install error: {0}")] + Install(#[from] vite_error::Error), + + #[error("{0}")] + Other(Str), +} diff --git a/crates/vite_global_cli/src/js_executor.rs b/crates/vite_global_cli/src/js_executor.rs new file mode 100644 index 0000000000..b53786fd38 --- /dev/null +++ b/crates/vite_global_cli/src/js_executor.rs @@ -0,0 +1,316 @@ +//! JavaScript execution via managed Node.js runtime. +//! +//! This module handles downloading and caching Node.js via `vite_js_runtime`, +//! and executing JavaScript scripts using the managed runtime. + +use std::process::ExitStatus; + +use tokio::process::Command; +use vite_js_runtime::{JsRuntime, JsRuntimeType, download_runtime, download_runtime_for_project}; +use vite_path::{AbsolutePath, AbsolutePathBuf}; + +use crate::error::Error; + +/// JavaScript executor using managed Node.js runtime. +/// +/// Handles two runtime resolution strategies: +/// - CLI runtime: For package manager commands and bundled JS scripts (Categories A & B) +/// - Project runtime: For delegating to local vite-plus CLI (Category C) +pub struct JsExecutor { + /// Cached runtime for CLI commands (Categories A & B) + cli_runtime: Option, + /// Cached runtime for project delegation (Category C) + project_runtime: Option, + /// Directory containing JS scripts (from `VITE_GLOBAL_CLI_JS_SCRIPTS_DIR`) + scripts_dir: Option, +} + +impl JsExecutor { + /// Create a new JS executor. + /// + /// # Arguments + /// * `scripts_dir` - Optional path to the JS scripts directory. + /// If not provided, will be auto-detected from the binary location. + #[must_use] + pub const fn new(scripts_dir: Option) -> Self { + Self { cli_runtime: None, project_runtime: None, scripts_dir } + } + + /// Get the JS scripts directory. + /// + /// Resolution order: + /// 1. Explicitly provided `scripts_dir` + /// 2. `VITE_GLOBAL_CLI_JS_SCRIPTS_DIR` environment variable + /// 3. Auto-detect from binary location (../dist relative to binary) + pub fn get_scripts_dir(&self) -> Result { + // 1. Use explicitly provided scripts_dir + if let Some(dir) = &self.scripts_dir { + return Ok(dir.clone()); + } + + // 2. Check environment variable + if let Ok(dir) = std::env::var("VITE_GLOBAL_CLI_JS_SCRIPTS_DIR") { + return AbsolutePathBuf::new(dir.into()).ok_or(Error::JsScriptsDirNotFound); + } + + // 3. Auto-detect from binary location + // JS scripts are at ../dist relative to bin/ + // e.g., packages/global/bin/vp -> packages/global/dist/ + let exe_path = std::env::current_exe().map_err(|_| Error::JsScriptsDirNotFound)?; + // Resolve symlinks to get the real binary path (Unix only) + // This is important when vp is symlinked from ~/.local/bin/vp + // Skip on Windows to avoid path resolution issues + #[cfg(unix)] + let exe_path = std::fs::canonicalize(&exe_path).map_err(|_| Error::JsScriptsDirNotFound)?; + let bin_dir = exe_path.parent().ok_or(Error::JsScriptsDirNotFound)?; + let package_dir = bin_dir.parent().ok_or(Error::JsScriptsDirNotFound)?; + let scripts_dir = package_dir.join("dist"); + + AbsolutePathBuf::new(scripts_dir).ok_or(Error::JsScriptsDirNotFound) + } + + /// Get the path to the current Rust binary (vp). + /// + /// This is passed to JS scripts via `VITE_PLUS_CLI_BIN` environment variable + /// so they can invoke vp commands when needed. + fn get_bin_path() -> Result { + let exe_path = std::env::current_exe().map_err(|_| Error::CliBinaryNotFound)?; + AbsolutePathBuf::new(exe_path).ok_or(Error::CliBinaryNotFound) + } + + /// Create a JS runtime command with common environment variables set. + /// + /// Sets up: + /// - `VITE_PLUS_CLI_BIN`: So JS scripts can invoke vp commands + /// - `PATH`: Prepends the runtime bin directory so child processes can find the JS runtime + fn create_js_command( + runtime_binary: &AbsolutePath, + runtime_bin_prefix: &AbsolutePath, + ) -> Command { + let mut cmd = Command::new(runtime_binary.as_path()); + if let Ok(bin_path) = Self::get_bin_path() { + tracing::debug!("Set VITE_PLUS_CLI_BIN to {:?}", bin_path); + cmd.env("VITE_PLUS_CLI_BIN", bin_path.as_path()); + } + + // Prepend runtime bin to PATH so child processes can find the JS runtime + let runtime_bin_path = runtime_bin_prefix.as_path().to_path_buf(); + let current_path = std::env::var_os("PATH").unwrap_or_default(); + let paths: Vec<_> = std::env::split_paths(¤t_path).collect(); + + if !paths.iter().any(|p| p == &runtime_bin_path) { + let mut new_paths = vec![runtime_bin_path]; + new_paths.extend(paths); + if let Ok(new_path) = std::env::join_paths(new_paths) { + tracing::debug!("Set PATH to {:?}", new_path); + cmd.env("PATH", new_path); + } + } + + cmd + } + + /// Get the CLI's package.json directory (parent of `scripts_dir`). + /// + /// This is used for resolving the CLI's default Node.js version + /// from `devEngines.runtime` in the CLI's package.json. + fn get_cli_package_dir(&self) -> Result { + let scripts_dir = self.get_scripts_dir()?; + // scripts_dir is typically packages/global/dist, so parent is packages/global + scripts_dir + .parent() + .map(vite_path::AbsolutePath::to_absolute_path_buf) + .ok_or(Error::JsScriptsDirNotFound) + } + + /// Ensure the CLI runtime is downloaded and cached. + /// + /// Uses the CLI's package.json `devEngines.runtime` configuration + /// to determine which Node.js version to use. + pub async fn ensure_cli_runtime(&mut self) -> Result<&JsRuntime, Error> { + if self.cli_runtime.is_none() { + let cli_dir = self.get_cli_package_dir()?; + tracing::debug!("Resolving CLI runtime from {:?}", cli_dir); + let runtime = download_runtime_for_project(&cli_dir).await?; + self.cli_runtime = Some(runtime); + } + Ok(self.cli_runtime.as_ref().unwrap()) + } + + /// Ensure the project runtime is downloaded and cached. + /// + /// Uses the project's package.json `devEngines.runtime` configuration + /// to determine which Node.js version to use. + pub async fn ensure_project_runtime( + &mut self, + project_path: &AbsolutePath, + ) -> Result<&JsRuntime, Error> { + if self.project_runtime.is_none() { + tracing::debug!("Resolving project runtime from {:?}", project_path); + let runtime = download_runtime_for_project(project_path).await?; + self.project_runtime = Some(runtime); + } + Ok(self.project_runtime.as_ref().unwrap()) + } + + /// Download a specific Node.js version. + /// + /// This is used when we need a specific version regardless of + /// package.json configuration. + #[allow(dead_code)] // Will be used in future phases + pub async fn download_node(&self, version: &str) -> Result { + Ok(download_runtime(JsRuntimeType::Node, version).await?) + } + + /// Execute a CLI bundled JS script (Category B commands). + /// + /// # Arguments + /// * `script_name` - Name of the script file (e.g., "index.js") + /// * `command` - Command to pass to the script (e.g., "new", "migrate") + /// * `args` - Additional arguments for the command + /// * `cwd` - Working directory for the script execution + pub async fn execute_cli_script( + &mut self, + script_name: &str, + command: &str, + args: &[String], + cwd: &AbsolutePath, + ) -> Result { + let scripts_dir = self.get_scripts_dir()?; + let script_path = scripts_dir.join(script_name); + + if !tokio::fs::try_exists(script_path.as_path()).await.unwrap_or(false) { + return Err(Error::JsEntryPointNotFound(format!("{script_path:?}").into())); + } + + let runtime = self.ensure_cli_runtime().await?; + let binary_path = runtime.get_binary_path(); + let bin_prefix = runtime.get_bin_prefix(); + + tracing::debug!( + "Executing CLI script: {:?} {:?} {:?} {:?} in {:?}", + binary_path, + script_path, + command, + args, + cwd + ); + + let mut cmd = Self::create_js_command(&binary_path, &bin_prefix); + cmd.arg(script_path.as_path()).arg(command).args(args).current_dir(cwd.as_path()); + + let status = cmd.status().await?; + Ok(status) + } + + /// Delegate to local vite-plus CLI (Category C commands). + /// + /// Uses the project's runtime version via `download_runtime_for_project`. + /// Passes the command through `dist/index.js` which handles: + /// - Detecting if vite-plus is installed locally + /// - Auto-installing if it's a dependency but not installed + /// - Prompting user to add it if not found + /// - Delegating to the local CLI's `dist/bin.js` + /// + /// # Arguments + /// * `project_path` - Path to the project directory + /// * `args` - Arguments to pass to the local CLI + pub async fn delegate_to_local_cli( + &mut self, + project_path: &AbsolutePath, + args: &[String], + ) -> Result { + // Use project's runtime based on its devEngines.runtime configuration + let runtime = self.ensure_project_runtime(project_path).await?; + let node_binary = runtime.get_binary_path(); + let bin_prefix = runtime.get_bin_prefix(); + + // Get the JS entry point (dist/index.js) + let scripts_dir = self.get_scripts_dir()?; + let entry_point = scripts_dir.join("index.js"); + + tracing::debug!("Delegating to local CLI via JS entry point: {:?} {:?}", entry_point, args); + + // Execute dist/index.js with the command and args + // The JS layer handles detecting/installing local vite-plus + let mut cmd = Self::create_js_command(&node_binary, &bin_prefix); + cmd.arg(entry_point.as_path()).args(args).current_dir(project_path.as_path()); + + let status = cmd.status().await?; + Ok(status) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_js_executor_new() { + let executor = JsExecutor::new(None); + assert!(executor.cli_runtime.is_none()); + assert!(executor.project_runtime.is_none()); + assert!(executor.scripts_dir.is_none()); + } + + #[test] + fn test_js_executor_with_scripts_dir() { + let scripts_dir = if cfg!(windows) { + AbsolutePathBuf::new("C:\\test\\scripts".into()).unwrap() + } else { + AbsolutePathBuf::new("/test/scripts".into()).unwrap() + }; + + let executor = JsExecutor::new(Some(scripts_dir.clone())); + assert_eq!(executor.get_scripts_dir().unwrap(), scripts_dir); + } + + #[test] + fn test_create_js_command_uses_direct_binary() { + use std::ffi::OsStr; + + let (runtime_binary, runtime_bin_prefix, expected_program) = if cfg!(windows) { + ( + AbsolutePathBuf::new("C:\\node\\node.exe".into()).unwrap(), + AbsolutePathBuf::new("C:\\node".into()).unwrap(), + "C:\\node\\node.exe", + ) + } else { + ( + AbsolutePathBuf::new("/usr/local/bin/node".into()).unwrap(), + AbsolutePathBuf::new("/usr/local/bin".into()).unwrap(), + "/usr/local/bin/node", + ) + }; + + let cmd = JsExecutor::create_js_command(&runtime_binary, &runtime_bin_prefix); + + // The command should use the node binary directly + assert_eq!(cmd.as_std().get_program(), OsStr::new(expected_program)); + } + + #[tokio::test] + async fn test_execute_cli_script_prints_node_version() { + use std::io::Write; + + use tempfile::TempDir; + + // Create a temporary directory for the scripts + let temp_dir = TempDir::new().unwrap(); + let scripts_dir = AbsolutePathBuf::new(temp_dir.path().to_path_buf()).unwrap(); + + // Create a simple JS script that prints process.version + let script_path = temp_dir.path().join("test-version.js"); + let mut file = std::fs::File::create(&script_path).unwrap(); + writeln!(file, "console.log(process.version);").unwrap(); + + // Create executor with the temp scripts directory + let mut executor = JsExecutor::new(Some(scripts_dir.clone())); + + // Execute the script + let status = + executor.execute_cli_script("test-version.js", "", &[], &scripts_dir).await.unwrap(); + + assert!(status.success(), "Script should execute successfully"); + } +} diff --git a/crates/vite_global_cli/src/main.rs b/crates/vite_global_cli/src/main.rs new file mode 100644 index 0000000000..ec27a38597 --- /dev/null +++ b/crates/vite_global_cli/src/main.rs @@ -0,0 +1,90 @@ +//! Vite+ Global CLI +//! +//! A standalone Rust binary for the vite+ global CLI that can run without +//! pre-installed Node.js. Uses managed Node.js from `vite_js_runtime` for +//! package manager commands and JS script execution. + +// Allow printing to stderr for CLI error messages +#![allow(clippy::print_stderr)] + +mod cli; +mod commands; +mod error; +mod js_executor; + +use std::process::ExitCode; + +use vite_path::AbsolutePathBuf; + +use crate::cli::{parse_args_from, run_command}; + +/// Normalize help arguments: transform `help [command]` into `[command] --help` +fn normalize_help_args() -> Vec { + let args: Vec = std::env::args().collect(); + + // Skip the binary name (args[0]) + match args.get(1).map(String::as_str) { + // `vp help` alone -> show main help + Some("help") if args.len() == 2 => vec![args[0].clone(), "--help".to_string()], + // `vp help [command] [args...]` -> `vp [command] --help [args...]` + Some("help") if args.len() > 2 => { + let mut normalized = Vec::with_capacity(args.len()); + normalized.push(args[0].clone()); // binary name + normalized.push(args[2].clone()); // command + normalized.push("--help".to_string()); + normalized.extend(args[3..].iter().cloned()); // remaining args + normalized + } + // No transformation needed + _ => args, + } +} + +fn main() -> ExitCode { + // Initialize tracing + vite_shared::init_tracing(); + + // Get current working directory + let cwd = match std::env::current_dir() { + Ok(path) => { + if let Some(abs_path) = AbsolutePathBuf::new(path) { + abs_path + } else { + eprintln!("Error: Invalid current directory path"); + return ExitCode::FAILURE; + } + } + Err(e) => { + eprintln!("Error: Failed to get current directory: {e}"); + return ExitCode::FAILURE; + } + }; + + // Normalize help arguments: transform `help [command]` into `[command] --help` + let normalized_args = normalize_help_args(); + + // Parse CLI arguments (using custom help formatting) + let args = parse_args_from(normalized_args); + + // Run the async runtime + let runtime = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .expect("Failed to create Tokio runtime"); + + match runtime.block_on(run_command(cwd, args)) { + Ok(exit_status) => { + if exit_status.success() { + ExitCode::SUCCESS + } else { + // Exit codes are typically 0-255 on Unix systems + #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] + exit_status.code().map_or(ExitCode::FAILURE, |c| ExitCode::from(c as u8)) + } + } + Err(e) => { + eprintln!("Error: {e}"); + ExitCode::FAILURE + } + } +} diff --git a/crates/vite_install/src/package_manager.rs b/crates/vite_install/src/package_manager.rs index c6c4889478..7e5dfbefad 100644 --- a/crates/vite_install/src/package_manager.rs +++ b/crates/vite_install/src/package_manager.rs @@ -708,13 +708,13 @@ fn interactive_package_manager_menu() -> Result { fn prompt_package_manager_selection() -> Result { // In CI environment, automatically use pnpm without prompting if is_ci_environment() { - println!("CI environment detected. Using default package manager: pnpm"); + tracing::info!("CI environment detected. Using default package manager: pnpm"); return Ok(PackageManagerType::Pnpm); } // Check if stdin is a TTY (terminal) - if not, use default if !io::stdin().is_terminal() { - println!("Non-interactive environment detected. Using default package manager: pnpm"); + tracing::info!("Non-interactive environment detected. Using default package manager: pnpm"); return Ok(PackageManagerType::Pnpm); } diff --git a/crates/vite_install/src/shim.rs b/crates/vite_install/src/shim.rs index d238b346cc..a19071b57f 100644 --- a/crates/vite_install/src/shim.rs +++ b/crates/vite_install/src/shim.rs @@ -27,6 +27,8 @@ pub async fn write_shims( use std::os::unix::fs::PermissionsExt; tokio::fs::set_permissions(to_bin, std::fs::Permissions::from_mode(0o755)).await?; } + + tracing::debug!("write_shims: {:?} -> {:?}", to_bin, relative_file); Ok(()) } diff --git a/crates/vite_js_runtime/src/runtime.rs b/crates/vite_js_runtime/src/runtime.rs index 7e542b1d8c..bc76da35ae 100644 --- a/crates/vite_js_runtime/src/runtime.rs +++ b/crates/vite_js_runtime/src/runtime.rs @@ -115,7 +115,7 @@ pub async fn download_runtime_with_provider( let bin_dir_relative_path = provider.bin_dir_relative_path(platform); // Cache path: $CACHE_DIR/vite-plus/js_runtime/{runtime}/{version}/ - let install_dir = cache_dir.join(vite_str::format!("{}/{version}", provider.name())); + let install_dir = cache_dir.join(provider.name()).join(version); // Check if already cached let binary_path = install_dir.join(&binary_relative_path); @@ -446,6 +446,41 @@ mod tests { assert_eq!(JsRuntimeType::Node.to_string(), "node"); } + /// Test that install_dir path is constructed correctly without embedded forward slashes. + /// This ensures Windows compatibility by using separate join() calls. + #[test] + fn test_install_dir_path_construction() { + let cache_dir = AbsolutePathBuf::new(std::path::PathBuf::from(if cfg!(windows) { + "C:\\Users\\test\\.cache\\vite-plus\\js_runtime" + } else { + "/home/test/.cache/vite-plus/js_runtime" + })) + .unwrap(); + + let provider_name = "node"; + let version = "20.18.0"; + + // This is how install_dir is constructed in download_runtime_with_provider + let install_dir = cache_dir.join(provider_name).join(version); + + // The path should use native separators, not embedded forward slashes + let path_str = install_dir.as_path().to_string_lossy(); + if cfg!(windows) { + // On Windows, we should have backslashes, not forward slashes + assert!( + !path_str.contains("node/"), + "Path should not contain 'node/' on Windows: {path_str}" + ); + assert!( + path_str.contains("node\\"), + "Path should contain 'node\\' on Windows: {path_str}" + ); + } else { + // On Unix, forward slashes are expected + assert!(path_str.contains("node/"), "Path should contain 'node/' on Unix: {path_str}"); + } + } + #[tokio::test] async fn test_download_runtime_for_project_with_dev_engines() { let temp_dir = TempDir::new().unwrap(); @@ -705,7 +740,7 @@ mod tests { // Clear any existing cache for this version let cache_dir = crate::cache::get_cache_dir().unwrap(); - let install_dir = cache_dir.join(vite_str::format!("node/{version}")); + let install_dir = cache_dir.join("node").join(version); if tokio::fs::try_exists(&install_dir).await.unwrap_or(false) { tokio::fs::remove_dir_all(&install_dir).await.unwrap(); } diff --git a/crates/vite_shared/Cargo.toml b/crates/vite_shared/Cargo.toml index d5b3e8f615..66727a6bd8 100644 --- a/crates/vite_shared/Cargo.toml +++ b/crates/vite_shared/Cargo.toml @@ -9,6 +9,7 @@ rust-version.workspace = true [dependencies] directories = { workspace = true } +tracing-subscriber = { workspace = true } vite_path = { workspace = true } [lints] diff --git a/crates/vite_shared/src/lib.rs b/crates/vite_shared/src/lib.rs index 71943286b6..3599de1a1b 100644 --- a/crates/vite_shared/src/lib.rs +++ b/crates/vite_shared/src/lib.rs @@ -1,5 +1,7 @@ //! Shared utilities for vite-plus crates mod cache; +mod tracing; pub use cache::get_cache_dir; +pub use tracing::init_tracing; diff --git a/crates/vite_shared/src/tracing.rs b/crates/vite_shared/src/tracing.rs new file mode 100644 index 0000000000..c65f4c6098 --- /dev/null +++ b/crates/vite_shared/src/tracing.rs @@ -0,0 +1,36 @@ +//! Tracing initialization for vite-plus + +use std::sync::OnceLock; + +use tracing_subscriber::{ + filter::{LevelFilter, Targets}, + prelude::*, +}; + +/// Initialize tracing with VITE_LOG environment variable. +/// +/// Uses `OnceLock` to ensure tracing is only initialized once, +/// even if called multiple times. +/// +/// # Environment Variables +/// - `VITE_LOG`: Controls log filtering (e.g., "debug", "vite_task=trace") +pub fn init_tracing() { + static TRACING: OnceLock<()> = OnceLock::new(); + TRACING.get_or_init(|| { + tracing_subscriber::registry() + .with( + std::env::var("VITE_LOG") + .map_or_else( + |_| Targets::new(), + |env_var| { + use std::str::FromStr; + Targets::from_str(&env_var).unwrap_or_default() + }, + ) + // disable brush-parser tracing + .with_targets([("tokenize", LevelFilter::OFF), ("parse", LevelFilter::OFF)]), + ) + .with(tracing_subscriber::fmt::layer()) + .init(); + }); +} diff --git a/docs/.gitignore b/docs/.gitignore index 4f2fc4ac0e..a806e1f22c 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -1 +1,3 @@ .vitepress/cache +public/install.sh +public/install.ps1 diff --git a/docs/package.json b/docs/package.json index d7c4e69df6..d9e7f1e196 100644 --- a/docs/package.json +++ b/docs/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "dev": "vitepress dev", - "build": "vitepress build", + "build": "cp ../packages/global/install.sh ../packages/global/install.ps1 public/ && vitepress build", "preview": "vitepress preview" }, "dependencies": { diff --git a/docs/vite/guide/migration.md b/docs/vite/guide/migration.md index 84982c636a..59dc855fa1 100644 --- a/docs/vite/guide/migration.md +++ b/docs/vite/guide/migration.md @@ -66,15 +66,12 @@ Vite+ provides an automated migration command that handles most of the migration ```bash # Migrate current directory -vite migration - -# Alias -vite migrate +vp migrate ``` ### What the Migration Does -The `vite migration` command automatically: +The `vp migrate` command automatically: 1. **Updates dependencies**: Replaces standalone `vite`, `vitest`, `oxlint`, and `oxfmt` with unified Vite+ packages 2. **Configures overrides**: Adds package manager overrides to ensure all dependencies use Vite+ versions @@ -87,7 +84,7 @@ The `vite migration` command automatically: When you run the migration command, you'll see a preview of changes: ```bash -$ vite migration +$ vp migrate ◇ Analyzing project... │ diff --git a/ecosystem-ci/patch-project.ts b/ecosystem-ci/patch-project.ts index b620c5f814..caeb1eb3e7 100644 --- a/ecosystem-ci/patch-project.ts +++ b/ecosystem-ci/patch-project.ts @@ -18,8 +18,9 @@ async function migrateProject(project: string) { const repoConfig = repos[project as keyof typeof repos]; const directory = 'directory' in repoConfig ? repoConfig.directory : undefined; const cwd = directory ? join(repoRoot, directory) : repoRoot; - // run vite migrate - execSync('vite migrate --no-agent', { + // run vp migrate + const cli = process.env.VITE_PLUS_CLI_BIN ?? (process.env.CI ? 'vp' : 'vp-dev'); + execSync(`${cli} migrate --no-agent --no-interactive`, { cwd, stdio: 'inherit', env: { diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000000..5238675191 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,4 @@ +[build] +base = "rfcs/" # avoid pnpm install fails on root +command = "cd ../docs && npm i --force && npm run build" +publish = "../docs/.vitepress/dist" diff --git a/package.json b/package.json index 008a413115..e8897a2183 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,12 @@ "type": "module", "scripts": { "build": "pnpm -F @voidzero-dev/* -F vite-plus build && pnpm -F vite-plus-cli build", - "bootstrap-cli": "pnpm build && pnpm install-global-cli:local", - "bootstrap-cli:ci": "pnpm install-global-cli", - "install-global-cli": "pnpm --filter=vite-plus-cli copy-binding && tool install-global-cli vite", - "install-global-cli:local": "pnpm --filter=vite-plus-cli copy-binding && tool install-global-cli vp", + "bootstrap-cli": "pnpm build && cargo build -p vite_global_cli --release && pnpm copy-vp-binary && pnpm install-global-cli", + "bootstrap-cli:ci": "pnpm install-global-cli:ci", + "copy-vp-binary": "rm -f packages/global/bin/vp packages/global/bin/vp.exe && (cp target/release/vp packages/global/bin/vp || cp target/release/vp.exe packages/global/bin/vp.exe)", + "copy-cli-binding": "pnpm --filter=vite-plus-cli copy-binding", + "install-global-cli": "pnpm copy-cli-binding && tool install-global-cli vp-dev && vp-dev --version", + "install-global-cli:ci": "pnpm copy-cli-binding && tool install-global-cli vp", "tsgo": "tsgo -b tsconfig.json", "lint": "vite lint --type-aware --threads 4", "test": "vite test run && pnpm -r snap-test", @@ -19,6 +21,7 @@ "prepare": "husky" }, "devDependencies": { + "@napi-rs/cli": "catalog:", "@oxc-node/cli": "catalog:", "@oxc-node/core": "catalog:", "@types/node": "catalog:", diff --git a/packages/cli/README.md b/packages/cli/README.md index 74b84b6b3d..a538fd280e 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -20,13 +20,21 @@ Vite+ is built to scale with your codebase while reducing your devtools to a sin ## Getting Started -Vite+ requires Node.js 22+. Install `vite-plus-cli` globally as `vite`: +Install Vite+ globally as `vp`: + +For Linux or macOS: + +```bash +curl -fsSL https://viteplus.dev/install.sh | bash +``` + +For Windows: ```bash -npm install -g vite-plus-cli +irm https://viteplus.dev/install.ps1 | iex ``` -`vite` handles the full development lifecycle such as package management, development servers, linting, formatting, testing and building for production. +`vp` handles the full development lifecycle such as package management, development servers, linting, formatting, testing and building for production. ### Vite+ Commands @@ -58,20 +66,20 @@ Vite+ automatically detects and wraps the underlying package manager such as pnp ### Scaffolding your first Vite+ project -Use `vite new` to create a new project: +Use `vp new` to create a new project: ```bash -vite new +vp new ``` -You can run `vite new` inside of a project to add new apps or libraries to your project. +You can run `vp new` inside of a project to add new apps or libraries to your project. ### Migrating an existing project You can migrate an existing project to Vite+: ```bash -vite migrate +vp migrate ``` #### Manual Installation & Migration diff --git a/packages/cli/bin/vite b/packages/cli/bin/vite index ed32f6755c..8550f94294 100755 --- a/packages/cli/bin/vite +++ b/packages/cli/bin/vite @@ -1,7 +1,7 @@ #!/usr/bin/env node -import module from 'node:module' +import module from 'node:module'; if (module.enableCompileCache) { - module.enableCompileCache() + module.enableCompileCache(); } -import '../dist/bin.js' +import '../dist/bin.js'; diff --git a/packages/cli/binding/Cargo.toml b/packages/cli/binding/Cargo.toml index b9b883bd2c..e3d1ccd76a 100644 --- a/packages/cli/binding/Cargo.toml +++ b/packages/cli/binding/Cargo.toml @@ -20,10 +20,10 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } tokio = { workspace = true, features = ["fs"] } tracing = { workspace = true } -tracing-subscriber = { workspace = true } vite_error = { workspace = true } vite_install = { workspace = true } vite_path = { workspace = true } +vite_shared = { workspace = true } vite_str = { workspace = true } vite_task = { workspace = true } vite_workspace = { workspace = true } diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index a4421179dd..b278f5c654 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -853,34 +853,7 @@ Options: ); } -pub fn init_tracing() { - use std::sync::OnceLock; - - use tracing_subscriber::{ - filter::{LevelFilter, Targets}, - prelude::__tracing_subscriber_SubscriberExt, - util::SubscriberInitExt, - }; - - static TRACING: OnceLock<()> = OnceLock::new(); - TRACING.get_or_init(|| { - tracing_subscriber::registry() - .with( - std::env::var("VITE_LOG") - .map_or_else( - |_| Targets::new(), - |env_var| { - use std::str::FromStr; - Targets::from_str(&env_var).unwrap_or_default() - }, - ) - // disable brush-parser tracing - .with_targets([("tokenize", LevelFilter::OFF), ("parse", LevelFilter::OFF)]), - ) - .with(tracing_subscriber::fmt::layer()) - .init(); - }); -} +pub use vite_shared::init_tracing; #[cfg(test)] mod tests { diff --git a/packages/cli/package.json b/packages/cli/package.json index a7483f3f09..dded0fc0a0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -300,7 +300,7 @@ "oxlint-tsgolint": "catalog:" }, "devDependencies": { - "@napi-rs/cli": "^3.4.1", + "@napi-rs/cli": "catalog:", "@oxc-node/core": "^0.0.32", "@voidzero-dev/vite-plus-tools": "workspace:", "rolldown": "workspace:*", diff --git a/packages/cli/publish-native-addons.ts b/packages/cli/publish-native-addons.ts index e614b98386..34f4c5b2b3 100644 --- a/packages/cli/publish-native-addons.ts +++ b/packages/cli/publish-native-addons.ts @@ -27,9 +27,10 @@ await cli.prePublish({ skipOptionalPublish: true, }); +const npmTag = process.env.NPM_TAG || 'latest'; const npmDir = await readdir(join(currentDir, 'npm')); for (const file of npmDir) { - execSync(`npm publish --tag latest --access public --no-git-checks`, { + execSync(`npm publish --tag ${npmTag} --access public --no-git-checks`, { cwd: join(currentDir, 'npm', file), env: process.env, stdio: 'inherit', diff --git a/packages/global/.gitignore b/packages/global/.gitignore index d4d6195c4f..18609d0909 100644 --- a/packages/global/.gitignore +++ b/packages/global/.gitignore @@ -1,2 +1,5 @@ /npm /artifacts +# Rust CLI binary (copied for local development) +/bin/vp +/bin/vp.exe diff --git a/packages/global/README.md b/packages/global/README.md index c7438b7de0..ab4eedc311 100644 --- a/packages/global/README.md +++ b/packages/global/README.md @@ -18,13 +18,21 @@ Vite+ is built to scale with your codebase while reducing your devtools to a sin ## Getting Started -Vite+ requires Node.js 22+. Install `vite-plus-cli` globally as `vite`: +Install Vite+ globally as `vp`: + +For Linux or macOS: + +```bash +curl -fsSL https://viteplus.dev/install.sh | bash +``` + +For Windows: ```bash -npm install -g vite-plus-cli +irm https://viteplus.dev/install.ps1 | iex ``` -`vite` handles the full development lifecycle such as package management, development servers, linting, formatting, testing and building for production. +`vp` handles the full development lifecycle such as package management, development servers, linting, formatting, testing and building for production. ### Vite+ Commands @@ -56,20 +64,20 @@ Vite+ automatically detects and wraps the underlying package manager such as pnp ### Scaffolding your first Vite+ project -Use `vite new` to create a new project: +Use `vp new` to create a new project: ```bash -vite new +vp new ``` -You can run `vite new` inside of a project to add new apps or libraries to your project. +You can run `vp new` inside of a project to add new apps or libraries to your project. ### Migrating an existing project You can migrate an existing project to Vite+: ```bash -vite migrate +vp migrate ``` #### Manual Installation & Migration diff --git a/packages/global/bin/vite b/packages/global/bin/vite deleted file mode 100755 index c0b66ac341..0000000000 --- a/packages/global/bin/vite +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env node - -import module from 'node:module'; -if (module.enableCompileCache) { - module.enableCompileCache(); -} -import "../dist/index.js"; diff --git a/packages/global/bin/wrapper.js b/packages/global/bin/wrapper.js new file mode 100755 index 0000000000..980951f0ce --- /dev/null +++ b/packages/global/bin/wrapper.js @@ -0,0 +1,116 @@ +#!/usr/bin/env node + +import { execFileSync } from 'node:child_process'; +import { accessSync, chmodSync, constants, existsSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { debuglog } from 'node:util'; + +const debug = debuglog('vite-plus/global/bin/wrapper'); + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const require = createRequire(import.meta.url); + +function getPackageName() { + const { platform, arch } = process; + let suffix = ''; + if (platform === 'linux') { + suffix = '-gnu'; + } else if (platform === 'win32') { + suffix = '-msvc'; + } + return `@voidzero-dev/vite-plus-cli-${platform}-${arch}${suffix}`; +} + +function getBinaryPath() { + const binaryName = process.platform === 'win32' ? 'vp.exe' : 'vp'; + + // 1. First check for local binary in same directory (local development) + const localBinaryPath = join(__dirname, binaryName); + if (existsSync(localBinaryPath)) { + return localBinaryPath; + } + + // 2. Find binary from platform-specific optionalDependency + const packageName = getPackageName(); + + // Try to find the binary in node_modules (sibling of this package) + const nodeModulesPath = join(__dirname, '..', '..', packageName, binaryName); + if (existsSync(nodeModulesPath)) { + return nodeModulesPath; + } + + // Try require.resolve for hoisted dependencies + try { + const packagePath = require.resolve(`${packageName}/package.json`); + const binaryPath = join(dirname(packagePath), binaryName); + if (existsSync(binaryPath)) { + return binaryPath; + } + } catch { + // Package not installed, fall back to JS mode + } + + return null; +} + +function ensureExecutable(binaryPath) { + // Windows doesn't need executable permission check + if (process.platform === 'win32') { + return; + } + + try { + accessSync(binaryPath, constants.X_OK); + } catch { + // Not executable, try to fix permissions + try { + chmodSync(binaryPath, 0o755); + } catch (chmodError) { + console.error(`Error: Failed to set executable permission on ${binaryPath}`); + console.error(` ${chmodError.message}`); + process.exit(1); + } + } +} + +const binaryPath = getBinaryPath(); + +if (binaryPath) { + // Ensure the binary is executable (auto-fix on non-Windows) + ensureExecutable(binaryPath); + + // Rust binary mode: execute the native binary + // Set VITE_GLOBAL_CLI_JS_SCRIPTS_DIR to point to the dist/ directory + const jsScriptsDir = join(__dirname, '..', 'dist'); + const env = { + ...process.env, + VITE_GLOBAL_CLI_JS_SCRIPTS_DIR: jsScriptsDir, + }; + const args = process.argv.slice(2); + debug('execFileSync binaryPath: %o', binaryPath); + debug('execFileSync args: %o', args); + debug('execFileSync env: %o', env); + + try { + execFileSync(binaryPath, args, { stdio: 'inherit', env }); + } catch (error) { + // execFileSync throws on non-zero exit codes, propagate the exit code + process.exit(error.status ?? 1); + } +} else { + // Binary not found - show installation instructions + const isWindows = process.platform === 'win32'; + const installCommand = isWindows + ? 'irm https://viteplus.dev/install.ps1 | iex' + : 'curl -fsSL https://viteplus.dev/install.sh | bash'; + + console.error('Error: Vite+ CLI binary not found.'); + console.error(''); + console.error('Please install vite-plus using:'); + console.error(` ${installCommand}`); + console.error(''); + console.error('For more information, visit: https://viteplus.dev'); + process.exit(1); +} diff --git a/packages/global/binding/Cargo.toml b/packages/global/binding/Cargo.toml index 24fda6e8d8..fb5b75e44b 100644 --- a/packages/global/binding/Cargo.toml +++ b/packages/global/binding/Cargo.toml @@ -1,15 +1,12 @@ [package] -name = "vite-plus-global-cli" +name = "vite-plus-global-cli-binding" version = "0.0.0" edition = "2024" -description = "Vite+ Global CLI" [dependencies] -clap = { workspace = true, features = ["derive", "help"] } fspy = { workspace = true } napi = { workspace = true } napi-derive = { workspace = true } -tokio = { workspace = true, features = ["fs"] } tracing = { workspace = true } tracing-subscriber = { workspace = true } vite_command = { workspace = true } @@ -22,8 +19,5 @@ vite_workspace = { workspace = true } [build-dependencies] napi-build = { workspace = true } -[dev-dependencies] -tempfile = { workspace = true } - [lib] crate-type = ["cdylib"] diff --git a/packages/global/binding/index.d.ts b/packages/global/binding/index.d.ts index 3b0ac96f3a..371d8db427 100644 --- a/packages/global/binding/index.d.ts +++ b/packages/global/binding/index.d.ts @@ -16,20 +16,6 @@ export interface BatchRewriteResult { errors: Array; } -/** - * Configuration options passed from JavaScript to Rust. - * - * Each field (except `cwd`) is a JavaScript function wrapped in a `ThreadsafeFunction`. - * These functions are called by Rust to resolve tool binary paths when needed. - * - * The `ThreadsafeFunction` wrapper ensures the JavaScript functions can be - * safely called from Rust's async runtime without blocking or race conditions. - */ -export interface CliOptions { - /** Optional working directory override */ - cwd?: string; -} - /** * Detect the workspace root and package manager type and version * @@ -251,29 +237,6 @@ export declare function rewriteImportsInDirectory(root: string): BatchRewriteRes */ export declare function rewriteScripts(scriptsJson: string, rulesYaml: string): string | null; -/** - * Main entry point for the CLI, called from JavaScript. - * - * This function: - * 1. Parses command-line arguments - * 2. Sets up the working directory - * 3. Creates Rust-callable wrappers for JavaScript resolver functions - * 4. Passes control to the Rust core (`cli::main`) - * - * ## JavaScript-to-Rust Bridge - * - * The resolver functions are wrapped to: - * - Call the JavaScript function asynchronously - * - Handle errors and convert them to Rust error types - * - Convert the JavaScript result to Rust's expected format - * - * ## Error Handling - * - * Errors from JavaScript resolvers are converted to specific error types - * (e.g., `LintFailed`, `ViteError`) to provide better error messages. - */ -export declare function run(options: CliOptions): Promise; - /** * Run a command with fspy tracking, callable from JavaScript. * diff --git a/packages/global/binding/index.js b/packages/global/binding/index.js index 7e4972897c..a0069f2897 100644 --- a/packages/global/binding/index.js +++ b/packages/global/binding/index.js @@ -771,7 +771,6 @@ const { mergeTsdownConfig, rewriteImportsInDirectory, rewriteScripts, - run, runCommand, } = nativeBinding; export { detectWorkspace }; @@ -780,5 +779,4 @@ export { mergeJsonConfig }; export { mergeTsdownConfig }; export { rewriteImportsInDirectory }; export { rewriteScripts }; -export { run }; export { runCommand }; diff --git a/packages/global/binding/src/cli.rs b/packages/global/binding/src/cli.rs deleted file mode 100644 index 69f3b7a861..0000000000 --- a/packages/global/binding/src/cli.rs +++ /dev/null @@ -1,2653 +0,0 @@ -use std::process::ExitStatus; - -use clap::{CommandFactory, Parser, Subcommand}; -use vite_error::Error; -use vite_install::commands::{ - add::SaveDependencyType, install::InstallCommandOptions, outdated::Format, -}; -use vite_path::AbsolutePathBuf; - -use crate::commands::{ - add::AddCommand, dedupe::DedupeCommand, dlx::DlxCommand, install::InstallCommand, - link::LinkCommand, outdated::OutdatedCommand, pm::PmCommand, remove::RemoveCommand, - unlink::UnlinkCommand, update::UpdateCommand, why::WhyCommand, -}; - -#[derive(Parser, Debug)] -#[clap(author, version, about, long_about = None)] -#[command(disable_help_subcommand = true)] -pub struct Args { - #[clap(subcommand)] - pub commands: Commands, -} - -#[derive(Subcommand, Debug)] -pub enum Commands { - // package manager commands - /// Install all dependencies, or add packages if package names are provided - #[command(alias = "i")] - Install { - /// Do not install devDependencies - #[arg(short = 'P', long)] - prod: bool, - - /// Only install devDependencies (install) / Save to devDependencies (add) - #[arg(short = 'D', long)] - dev: bool, - - /// Do not install optionalDependencies - #[arg(long)] - no_optional: bool, - - /// Fail if lockfile needs to be updated (CI mode) - #[arg(long, overrides_with = "no_frozen_lockfile")] - frozen_lockfile: bool, - - /// Allow lockfile updates (opposite of --frozen-lockfile) - #[arg(long, overrides_with = "frozen_lockfile")] - no_frozen_lockfile: bool, - - /// Only update lockfile, don't install - #[arg(long)] - lockfile_only: bool, - - /// Use cached packages when available - #[arg(long)] - prefer_offline: bool, - - /// Only use packages already in cache - #[arg(long)] - offline: bool, - - /// Force reinstall all dependencies - #[arg(short = 'f', long)] - force: bool, - - /// Do not run lifecycle scripts - #[arg(long)] - ignore_scripts: bool, - - /// Don't read or generate lockfile - #[arg(long)] - no_lockfile: bool, - - /// Fix broken lockfile entries (pnpm and yarn@2+ only) - #[arg(long)] - fix_lockfile: bool, - - /// Create flat node_modules (pnpm only) - #[arg(long)] - shamefully_hoist: bool, - - /// Re-run resolution for peer dependency analysis (pnpm only) - #[arg(long)] - resolution_only: bool, - - /// Suppress output (silent mode) - #[arg(long)] - silent: bool, - - /// Filter packages in monorepo (can be used multiple times) - #[arg(long, value_name = "PATTERN")] - filter: Option>, - - /// Install in workspace root only - #[arg(short = 'w', long)] - workspace_root: bool, - - /// Save exact version (only when adding packages) - #[arg(short = 'E', long)] - save_exact: bool, - - /// Save to peerDependencies (only when adding packages) - #[arg(long)] - save_peer: bool, - - /// Save to optionalDependencies (only when adding packages) - #[arg(short = 'O', long)] - save_optional: bool, - - /// Save the new dependency to the default catalog (only when adding packages) - #[arg(long)] - save_catalog: bool, - - /// Install globally (only when adding packages) - #[arg(short = 'g', long)] - global: bool, - - /// Packages to add (if provided, acts as `vite add`) - #[arg(required = false)] - packages: Option>, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - /// Add packages to dependencies - Add { - /// Save to `dependencies` (default) - #[arg(short = 'P', long)] - save_prod: bool, - /// Save to `devDependencies` - #[arg(short = 'D', long)] - save_dev: bool, - /// Save to `peerDependencies` and `devDependencies` - #[arg(long)] - save_peer: bool, - /// Save to `optionalDependencies` - #[arg(short = 'O', long)] - save_optional: bool, - /// Save exact version rather than semver range (e.g., `^1.0.0` -> `1.0.0`) - #[arg(short = 'E', long)] - save_exact: bool, - - /// Save the new dependency to the specified catalog name. - /// Example: `vite add vue --save-catalog-name vue3` - #[arg(long, value_name = "CATALOG_NAME")] - save_catalog_name: Option, - /// Save the new dependency to the default catalog - #[arg(long)] - save_catalog: bool, - - /// A list of package names allowed to run postinstall - #[arg(long, value_name = "NAMES")] - allow_build: Option, - - /// Filter packages in monorepo (can be used multiple times) - #[arg(long, value_name = "PATTERN")] - filter: Option>, - - /// Add to workspace root (ignore-workspace-root-check) - #[arg(short = 'w', long)] - workspace_root: bool, - - /// Only add if package exists in workspace (pnpm-specific) - #[arg(long)] - workspace: bool, - - /// Install globally - #[arg(short = 'g', long)] - global: bool, - - /// Packages to add - #[arg(required = true)] - packages: Vec, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - /// Remove packages from dependencies - #[command(alias = "rm", alias = "un", alias = "uninstall")] - Remove { - /// Only remove from `devDependencies` (pnpm-specific) - #[arg(short = 'D', long)] - save_dev: bool, - - /// Only remove from `optionalDependencies` (pnpm-specific) - #[arg(short = 'O', long)] - save_optional: bool, - - /// Only remove from `dependencies` (pnpm-specific) - #[arg(short = 'P', long)] - save_prod: bool, - - /// Filter packages in monorepo (can be used multiple times) - #[arg(long, value_name = "PATTERN")] - filter: Option>, - - /// Remove from workspace root - #[arg(short = 'w', long)] - workspace_root: bool, - - /// Remove recursively from all workspace packages, including workspace root - #[arg(short = 'r', long)] - recursive: bool, - - /// Remove global packages - #[arg(short = 'g', long)] - global: bool, - - /// Packages to remove - #[arg(required = true)] - packages: Vec, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - /// Update packages to their latest versions - #[command(alias = "up")] - Update { - /// Update to latest version (ignore semver range) - #[arg(short = 'L', long)] - latest: bool, - - /// Update global packages - #[arg(short = 'g', long)] - global: bool, - - /// Update recursively in all workspace packages - #[arg(short = 'r', long)] - recursive: bool, - - /// Filter packages in monorepo (can be used multiple times) - #[arg(long, value_name = "PATTERN")] - filter: Option>, - - /// Include workspace root - #[arg(short = 'w', long)] - workspace_root: bool, - - /// Update only devDependencies - #[arg(short = 'D', long)] - dev: bool, - - /// Update only dependencies (production) - #[arg(short = 'P', long)] - prod: bool, - - /// Interactive mode - show outdated packages and choose which to update - #[arg(short = 'i', long)] - interactive: bool, - - /// Don't update optionalDependencies - #[arg(long)] - no_optional: bool, - - /// Update lockfile only, don't modify package.json - #[arg(long)] - no_save: bool, - - /// Only update if package exists in workspace (pnpm-specific) - #[arg(long)] - workspace: bool, - - /// Packages to update (optional - updates all if omitted) - packages: Vec, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - /// Deduplicate dependencies by removing older versions - #[command(alias = "ddp")] - Dedupe { - /// Check if deduplication would make changes - #[arg(long)] - check: bool, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - /// Check for outdated packages - Outdated { - /// Package name(s) to check (supports glob patterns in pnpm) - packages: Vec, - - /// Show extended information - #[arg(long)] - long: bool, - - /// Output format: table (default), list, or json - #[arg(long, value_name = "FORMAT", value_parser = clap::value_parser!(Format))] - format: Option, - - /// Check recursively across all workspaces - #[arg(short = 'r', long)] - recursive: bool, - - /// Filter packages in monorepo (can be used multiple times) - #[arg(long, value_name = "PATTERN")] - filter: Option>, - - /// Include workspace root - #[arg(short = 'w', long)] - workspace_root: bool, - - /// Only production and optional dependencies (pnpm-specific) - #[arg(short = 'P', long)] - prod: bool, - - /// Only dev dependencies (pnpm-specific) - #[arg(short = 'D', long)] - dev: bool, - - /// Exclude optional dependencies (pnpm-specific) - #[arg(long)] - no_optional: bool, - - /// Only show compatible versions (pnpm-specific) - #[arg(long)] - compatible: bool, - - /// Sort results by field (pnpm-specific) - #[arg(long, value_name = "FIELD")] - sort_by: Option, - - /// Check globally installed packages - #[arg(short = 'g', long)] - global: bool, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - /// Show why a package is installed - #[command(alias = "explain")] - Why { - /// Package(s) to check - #[arg(required = true)] - packages: Vec, - - /// Output in JSON format - #[arg(long)] - json: bool, - - /// Show extended information (pnpm-specific) - #[arg(long)] - long: bool, - - /// Show parseable output (pnpm-specific) - #[arg(long)] - parseable: bool, - - /// Check recursively across all workspaces - #[arg(short = 'r', long)] - recursive: bool, - - /// Filter packages in monorepo (pnpm/npm-specific) - #[arg(long, value_name = "PATTERN")] - filter: Option>, - - /// Check in workspace root (pnpm-specific) - #[arg(short = 'w', long)] - workspace_root: bool, - - /// Only production dependencies (pnpm-specific) - #[arg(short = 'P', long)] - prod: bool, - - /// Only dev dependencies (pnpm-specific) - #[arg(short = 'D', long)] - dev: bool, - - /// Limit tree depth (pnpm-specific) - #[arg(long)] - depth: Option, - - /// Exclude optional dependencies (pnpm-specific) - #[arg(long)] - no_optional: bool, - - /// Check globally installed packages - #[arg(short = 'g', long)] - global: bool, - - /// Exclude peer dependencies (pnpm/yarn@2+-specific) - #[arg(long)] - exclude_peers: bool, - - /// Use a finder function defined in .pnpmfile.cjs (pnpm-specific) - #[arg(long, value_name = "FINDER_NAME")] - find_by: Option, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - /// View package information from the registry - #[command(alias = "view", alias = "show")] - Info { - /// Package name with optional version - #[arg(required = true)] - package: String, - - /// Specific field to view - field: Option, - - /// Output in JSON format - #[arg(long)] - json: bool, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - /// Link packages for local development - #[command(alias = "ln")] - Link { - /// Package name or directory to link - /// If empty, registers current package globally - #[arg(value_name = "PACKAGE|DIR")] - package: Option, - - /// Arguments to pass to package manager - #[arg(allow_hyphen_values = true, trailing_var_arg = true)] - args: Vec, - }, - /// Unlink packages - Unlink { - /// Package name to unlink - /// If empty, unlinks current package globally - #[arg(value_name = "PACKAGE|DIR")] - package: Option, - - /// Unlink in every workspace package (pnpm/yarn@2+-specific) - #[arg(short = 'r', long)] - recursive: bool, - - /// Arguments to pass to package manager - #[arg(allow_hyphen_values = true, trailing_var_arg = true)] - args: Vec, - }, - /// Forward a command to the package manager. - #[command(subcommand)] - Pm(PmCommands), - /// Execute a package binary without installing it as a dependency - Dlx { - /// Package(s) to install before running the command (can be used multiple times) - #[arg(long, short = 'p', value_name = "NAME")] - package: Vec, - - /// Execute the command within a shell environment - #[arg(long = "shell-mode", short = 'c')] - shell_mode: bool, - - /// Suppress all output except the executed command's output - #[arg(long, short = 's')] - silent: bool, - - /// Package to execute (with optional @version) and arguments - #[arg(required = true, trailing_var_arg = true, allow_hyphen_values = true)] - args: Vec, - }, - /// Generate a new project - Gen { - /// Project name - #[arg(required = true)] - name: String, - }, - /// Migrate an existing project to Vite+ - Migrate { - /// Project directory - #[arg(required = true)] - directory: String, - }, - - // below commands only used to show help message, not actually executed - /// Run the development server - Dev, - /// Build application - Build, - /// Run test - Test, - /// Lint code - Lint, - /// Format code - Fmt, - /// Build library - Lib, - #[command(hide = true)] - /// Build documentation - Doc, - /// Run tasks - Run, - /// Manage the task cache - Cache, -} - -#[derive(Subcommand, Debug, Clone)] -pub enum PmCommands { - /// Remove unnecessary packages - Prune { - /// Remove devDependencies - #[arg(long)] - prod: bool, - - /// Remove optional dependencies - #[arg(long)] - no_optional: bool, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - - /// Create a tarball of the package - Pack { - /// Pack all workspace packages - #[arg(short = 'r', long)] - recursive: bool, - - /// Filter packages to pack (can be used multiple times) - #[arg(long, value_name = "PATTERN")] - filter: Option>, - - /// Customizes the output path for the tarball. Use %s and %v to include the package name and version (pnpm and yarn@2+ only), e.g., %s.tgz or some-dir/%s-%v.tgz - #[arg(long)] - out: Option, - - /// Directory where the tarball will be saved (pnpm and npm only) - #[arg(long)] - pack_destination: Option, - - /// Gzip compression level (0-9) - #[arg(long)] - pack_gzip_level: Option, - - /// Output in JSON format - #[arg(long)] - json: bool, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - - /// List installed packages - #[command(alias = "ls")] - List { - /// Package pattern to filter - pattern: Option, - - /// Maximum depth of dependency tree - #[arg(long)] - depth: Option, - - /// Output in JSON format - #[arg(long)] - json: bool, - - /// Show extended information - #[arg(long)] - long: bool, - - /// Parseable output format - #[arg(long)] - parseable: bool, - - /// Only production dependencies - #[arg(short = 'P', long)] - prod: bool, - - /// Only dev dependencies - #[arg(short = 'D', long)] - dev: bool, - - /// Exclude optional dependencies - #[arg(long)] - no_optional: bool, - - /// Exclude peer dependencies - #[arg(long)] - exclude_peers: bool, - - /// Show only project packages (pnpm-specific) - #[arg(long)] - only_projects: bool, - - /// Use a finder function defined in .pnpmfile.cjs (pnpm-specific) - #[arg(long, value_name = "FINDER_NAME")] - find_by: Option, - - /// List across all workspaces - #[arg(short = 'r', long)] - recursive: bool, - - /// Filter packages in monorepo (can be used multiple times) - #[arg(long, value_name = "PATTERN")] - filter: Vec, - - /// List global packages - #[arg(short = 'g', long)] - global: bool, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - - /// View package information from the registry - #[command(alias = "info", alias = "show")] - View { - /// Package name with optional version - #[arg(required = true)] - package: String, - - /// Specific field to view - field: Option, - - /// Output in JSON format - #[arg(long)] - json: bool, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - - /// Publish package to registry - Publish { - /// Tarball or folder to publish - #[arg(value_name = "TARBALL|FOLDER")] - target: Option, - - /// Preview without publishing - #[arg(long)] - dry_run: bool, - - /// Publish tag (default: latest) - #[arg(long)] - tag: Option, - - /// Access level (public/restricted) - #[arg(long)] - access: Option, - - /// One-time password for authentication - #[arg(long, value_name = "OTP")] - otp: Option, - - /// Skip git checks (pnpm-specific) - #[arg(long)] - no_git_checks: bool, - - /// Set the branch name to publish from (pnpm-specific) - #[arg(long, value_name = "BRANCH")] - publish_branch: Option, - - /// Save publish summary to pnpm-publish-summary.json (pnpm-specific) - #[arg(long)] - report_summary: bool, - - /// Force publish - #[arg(long)] - force: bool, - - /// Output in JSON format (pnpm-specific) - #[arg(long)] - json: bool, - - /// Publish all workspace packages - #[arg(short = 'r', long)] - recursive: bool, - - /// Filter packages in monorepo (can be used multiple times) - #[arg(long, value_name = "PATTERN")] - filter: Option>, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - - /// Manage package owners - #[command(subcommand, alias = "author")] - Owner(OwnerCommands), - - /// Manage package cache - Cache { - /// Subcommand: dir, path, clean - #[arg(required = true)] - subcommand: String, - - /// Additional arguments to pass through to the package manager - #[arg(last = true, allow_hyphen_values = true)] - pass_through_args: Option>, - }, - - /// Manage package manager configuration - #[command(subcommand, alias = "c")] - Config(ConfigCommands), -} - -#[derive(Subcommand, Debug, Clone)] -pub enum ConfigCommands { - /// List all configuration - List { - /// Output in JSON format - #[arg(long)] - json: bool, - - /// Use global config - #[arg(short = 'g', long)] - global: bool, - - /// Config location: project (default) or global - #[arg(long, value_name = "LOCATION")] - location: Option, - }, - - /// Get configuration value - Get { - /// Config key - key: String, - - /// Output in JSON format - #[arg(long)] - json: bool, - - /// Use global config - #[arg(short = 'g', long)] - global: bool, - - /// Config location: project (default) or global - #[arg(long, value_name = "LOCATION")] - location: Option, - }, - - /// Set configuration value - Set { - /// Config key - key: String, - - /// Config value - value: String, - - /// Output in JSON format - #[arg(long)] - json: bool, - - /// Use global config - #[arg(short = 'g', long)] - global: bool, - - /// Config location: project (default) or global - #[arg(long, value_name = "LOCATION")] - location: Option, - }, - - /// Delete configuration key - Delete { - /// Config key - key: String, - - /// Use global config - #[arg(short = 'g', long)] - global: bool, - - /// Config location: project (default) or global - #[arg(long, value_name = "LOCATION")] - location: Option, - }, -} - -#[derive(Subcommand, Debug, Clone)] -pub enum OwnerCommands { - /// List package owners - #[command(alias = "ls")] - List { - /// Package name - package: String, - - /// One-time password for authentication - #[arg(long, value_name = "OTP")] - otp: Option, - }, - - /// Add package owner - Add { - /// Username - user: String, - /// Package name - package: String, - - /// One-time password for authentication - #[arg(long, value_name = "OTP")] - otp: Option, - }, - - /// Remove package owner - Rm { - /// Username - user: String, - /// Package name - package: String, - - /// One-time password for authentication - #[arg(long, value_name = "OTP")] - otp: Option, - }, -} - -#[tracing::instrument] -pub async fn main(cwd: AbsolutePathBuf, mut args: Args) -> Result { - match &mut args.commands { - // package manager commands - Commands::Install { - prod, - dev, - no_optional, - frozen_lockfile, - no_frozen_lockfile, - lockfile_only, - prefer_offline, - offline, - force, - ignore_scripts, - no_lockfile, - fix_lockfile, - shamefully_hoist, - resolution_only, - silent, - filter, - workspace_root, - save_exact, - save_peer, - save_optional, - save_catalog, - global, - packages, - pass_through_args, - } => { - // If packages are provided, redirect to Add command - // This allows `vite install ` to work as an alias for `vite add ` - if let Some(pkgs) = packages { - if !pkgs.is_empty() { - let exit_status = execute_add_command( - cwd, - pkgs, - *prod, // save_prod (maps from --prod/-P) - *dev, // save_dev (maps from --dev/-D) - *save_peer, // save_peer - *save_optional, // save_optional - *save_exact, // save_exact - *save_catalog, // save_catalog - None, // save_catalog_name - filter.as_deref(), // filter - *workspace_root, // workspace_root - false, // workspace (pnpm-specific, not in install) - *global, // global - None, // allow_build - pass_through_args.as_deref(), - ) - .await?; - return Ok(exit_status); - } - } - - // No packages provided, run regular install - let options = InstallCommandOptions { - prod: *prod, - dev: *dev, - no_optional: *no_optional, - frozen_lockfile: *frozen_lockfile, - no_frozen_lockfile: *no_frozen_lockfile, - lockfile_only: *lockfile_only, - prefer_offline: *prefer_offline, - offline: *offline, - force: *force, - ignore_scripts: *ignore_scripts, - no_lockfile: *no_lockfile, - fix_lockfile: *fix_lockfile, - shamefully_hoist: *shamefully_hoist, - resolution_only: *resolution_only, - silent: *silent, - filters: filter.as_deref(), - workspace_root: *workspace_root, - pass_through_args: pass_through_args.as_deref(), - }; - let exit_status = InstallCommand::new(cwd).execute(&options).await?; - return Ok(exit_status); - } - Commands::Add { - filter, - workspace_root, - workspace, - packages, - save_prod, - save_dev, - save_peer, - save_optional, - save_exact, - save_catalog, - save_catalog_name, - global, - allow_build, - pass_through_args, - } => { - let exit_status = execute_add_command( - cwd, - packages, - *save_prod, - *save_dev, - *save_peer, - *save_optional, - *save_exact, - *save_catalog, - save_catalog_name.as_deref(), - filter.as_deref(), - *workspace_root, - *workspace, - *global, - allow_build.as_deref(), - pass_through_args.as_deref(), - ) - .await?; - return Ok(exit_status); - } - Commands::Remove { - save_dev, - save_optional, - save_prod, - filter, - workspace_root, - recursive, - global, - packages, - pass_through_args, - } => { - let exit_status = RemoveCommand::new(cwd) - .execute( - packages, - *save_dev, - *save_optional, - *save_prod, - filter.as_deref(), - *workspace_root, - *recursive, - *global, - pass_through_args.as_deref(), - ) - .await?; - return Ok(exit_status); - } - Commands::Update { - latest, - global, - recursive, - filter, - workspace_root, - dev, - prod, - interactive, - no_optional, - no_save, - workspace, - packages, - pass_through_args, - } => { - let exit_status = UpdateCommand::new(cwd) - .execute( - packages, - *latest, - *global, - *recursive, - filter.as_deref(), - *workspace_root, - *dev, - *prod, - *interactive, - *no_optional, - *no_save, - *workspace, - pass_through_args.as_deref(), - ) - .await?; - return Ok(exit_status); - } - Commands::Dedupe { check, pass_through_args } => { - let exit_status = - DedupeCommand::new(cwd).execute(*check, pass_through_args.as_deref()).await?; - return Ok(exit_status); - } - Commands::Outdated { - packages, - long, - format, - recursive, - filter, - workspace_root, - prod, - dev, - no_optional, - compatible, - sort_by, - global, - pass_through_args, - } => { - let exit_status = OutdatedCommand::new(cwd) - .execute( - packages, - *long, - *format, - *recursive, - filter.as_deref(), - *workspace_root, - *prod, - *dev, - *no_optional, - *compatible, - sort_by.as_deref(), - *global, - pass_through_args.as_deref(), - ) - .await?; - return Ok(exit_status); - } - Commands::Link { package, args } => { - let exit_status = LinkCommand::new(cwd).execute(package.as_deref(), Some(args)).await?; - return Ok(exit_status); - } - Commands::Unlink { package, recursive, args } => { - let exit_status = - UnlinkCommand::new(cwd).execute(package.as_deref(), *recursive, Some(args)).await?; - return Ok(exit_status); - } - Commands::Why { - packages, - json, - long, - parseable, - recursive, - filter, - workspace_root, - prod, - dev, - depth, - no_optional, - global, - exclude_peers, - find_by, - pass_through_args, - } => { - let exit_status = WhyCommand::new(cwd) - .execute( - packages, - *json, - *long, - *parseable, - *recursive, - filter.as_deref(), - *workspace_root, - *prod, - *dev, - *depth, - *no_optional, - *global, - *exclude_peers, - find_by.as_deref(), - pass_through_args.as_deref(), - ) - .await?; - return Ok(exit_status); - } - Commands::Info { package, field, json, pass_through_args } => { - let exit_status = PmCommand::new(cwd) - .execute(PmCommands::View { - package: package.clone(), - field: field.clone(), - json: *json, - pass_through_args: pass_through_args.clone(), - }) - .await?; - return Ok(exit_status); - } - Commands::Pm(pm_command) => { - let exit_status = PmCommand::new(cwd).execute(pm_command.clone()).await?; - return Ok(exit_status); - } - Commands::Dlx { package, shell_mode, silent, args } => { - let exit_status = DlxCommand::new(cwd) - .execute(package.clone(), *shell_mode, *silent, args.clone()) - .await?; - return Ok(exit_status); - } - _ => unreachable!(), - }; -} - -pub fn command_with_help() -> clap::Command { - let bold = "\x1b[1m"; - let bold_underline = "\x1b[1;4m"; - let reset = "\x1b[0m"; - let version = env!("CARGO_PKG_VERSION"); - - let after_help = format!( - "{bold_underline}Vite+ Commands:{reset} - {bold}dev{reset} Run the development server - {bold}build{reset} Build for production - {bold}lint{reset} Lint code - {bold}test{reset} Run tests - {bold}fmt{reset} Format code - {bold}lib{reset} Build library - {bold}migrate{reset} Migrate an existing project to Vite+ - {bold}cache{reset} Manage the task cache - {bold}new{reset} Generate a new project - {bold}run{reset} Run tasks - -{bold_underline}Package Manager Commands:{reset} - {bold}install{reset} Install all dependencies, or add packages if package names are provided - {bold}add{reset} Add packages to dependencies - {bold}remove{reset} Remove packages from dependencies - {bold}dedupe{reset} Deduplicate dependencies by removing older versions - {bold}dlx{reset} Execute a package binary without installing it as a dependency - {bold}info{reset} View package information from the registry - {bold}link{reset} Link packages for local development - {bold}outdated{reset} Check for outdated packages - {bold}pm{reset} Forward a command to the package manager - {bold}unlink{reset} Unlink packages - {bold}update{reset} Update packages to their latest versions - {bold}why{reset} Show why a package is installed -" - ); - let help_template = format!( - "Vite+/{version} - -{{usage-heading}} {{usage}}{{after-help}} -{bold_underline}Options:{reset} -{{options}} -" - ); - - Args::command().after_help(after_help).help_template(help_template) -} - -pub fn init_tracing() { - use std::sync::OnceLock; - - use tracing_subscriber::{ - filter::{LevelFilter, Targets}, - prelude::__tracing_subscriber_SubscriberExt, - util::SubscriberInitExt, - }; - - static TRACING: OnceLock<()> = OnceLock::new(); - TRACING.get_or_init(|| { - // Usage without the `regex` feature. - // - tracing_subscriber::registry() - .with( - std::env::var("VITE_LOG") - .map_or_else( - |_| Targets::new(), - |env_var| { - use std::str::FromStr; - Targets::from_str(&env_var).unwrap_or_default() - }, - ) - // disable brush-parser tracing - .with_targets([("tokenize", LevelFilter::OFF), ("parse", LevelFilter::OFF)]), - ) - .with(tracing_subscriber::fmt::layer()) - .init(); - }); -} - -/// Execute add command with the given parameters -async fn execute_add_command( - cwd: AbsolutePathBuf, - packages: &[String], - save_prod: bool, - save_dev: bool, - save_peer: bool, - save_optional: bool, - save_exact: bool, - save_catalog: bool, - save_catalog_name: Option<&str>, - filter: Option<&[String]>, - workspace_root: bool, - workspace: bool, - global: bool, - allow_build: Option<&str>, - pass_through_args: Option<&[String]>, -) -> Result { - let save_dependency_type = if save_dev { - Some(SaveDependencyType::Dev) - } else if save_peer { - Some(SaveDependencyType::Peer) - } else if save_optional { - Some(SaveDependencyType::Optional) - } else if save_prod { - Some(SaveDependencyType::Production) - } else { - None - }; - - // empty string means save as `catalog:` - let save_catalog_name = if save_catalog { Some("") } else { save_catalog_name }; - - AddCommand::new(cwd) - .execute( - packages, - save_dependency_type, - save_exact, - save_catalog_name, - filter, - workspace_root, - workspace, - global, - allow_build, - pass_through_args, - ) - .await -} - -#[cfg(test)] -mod tests { - use clap::Parser; - - use super::*; - - mod install_command_tests { - use super::*; - - #[test] - fn test_args_install_command_basic() { - let args = Args::try_parse_from(&["vite-plus", "install"]).unwrap(); - if let Commands::Install { prod, dev, frozen_lockfile, filter, .. } = &args.commands { - assert!(!prod); - assert!(!dev); - assert!(!frozen_lockfile); - assert!(filter.is_none()); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_prod() { - let args = Args::try_parse_from(&["vite-plus", "install", "--prod"]).unwrap(); - if let Commands::Install { prod, dev, .. } = &args.commands { - assert!(prod); - assert!(!dev); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_frozen_lockfile() { - let args = - Args::try_parse_from(&["vite-plus", "install", "--frozen-lockfile"]).unwrap(); - if let Commands::Install { frozen_lockfile, no_frozen_lockfile, .. } = &args.commands { - assert!(frozen_lockfile); - assert!(!no_frozen_lockfile); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_no_frozen_lockfile() { - let args = - Args::try_parse_from(&["vite-plus", "install", "--no-frozen-lockfile"]).unwrap(); - if let Commands::Install { frozen_lockfile, no_frozen_lockfile, .. } = &args.commands { - assert!(!frozen_lockfile); - assert!(no_frozen_lockfile); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_frozen_lockfile_override() { - // --no-frozen-lockfile should override --frozen-lockfile when both are specified - // Last one wins due to overrides_with - let args = Args::try_parse_from(&[ - "vite-plus", - "install", - "--frozen-lockfile", - "--no-frozen-lockfile", - ]) - .unwrap(); - if let Commands::Install { frozen_lockfile, no_frozen_lockfile, .. } = &args.commands { - // With overrides_with, the last flag wins and resets the other - assert!(!frozen_lockfile); - assert!(no_frozen_lockfile); - } else { - panic!("Expected Install command"); - } - - // Reverse order: --frozen-lockfile after --no-frozen-lockfile - let args = Args::try_parse_from(&[ - "vite-plus", - "install", - "--no-frozen-lockfile", - "--frozen-lockfile", - ]) - .unwrap(); - if let Commands::Install { frozen_lockfile, no_frozen_lockfile, .. } = &args.commands { - assert!(frozen_lockfile); - assert!(!no_frozen_lockfile); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_filter() { - let args = Args::try_parse_from(&["vite-plus", "install", "--filter", "app"]).unwrap(); - if let Commands::Install { filter, .. } = &args.commands { - assert_eq!(filter.as_ref().unwrap(), &vec!["app".to_string()]); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_multiple_filters() { - let args = Args::try_parse_from(&[ - "vite-plus", - "install", - "--filter", - "app", - "--filter", - "web", - ]) - .unwrap(); - if let Commands::Install { filter, .. } = &args.commands { - assert_eq!(filter.as_ref().unwrap(), &vec!["app".to_string(), "web".to_string()]); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_alias() { - let args = Args::try_parse_from(&["vite-plus", "i"]).unwrap(); - assert!(matches!(args.commands, Commands::Install { .. })); - } - - #[test] - fn test_args_install_command_with_all_options() { - let args = Args::try_parse_from(&[ - "vite-plus", - "install", - "--prod", - "--frozen-lockfile", - "--prefer-offline", - "--ignore-scripts", - "--filter", - "app", - "-w", - ]) - .unwrap(); - if let Commands::Install { - prod, - frozen_lockfile, - prefer_offline, - ignore_scripts, - filter, - workspace_root, - .. - } = &args.commands - { - assert!(prod); - assert!(frozen_lockfile); - assert!(prefer_offline); - assert!(ignore_scripts); - assert_eq!(filter.as_ref().unwrap(), &vec!["app".to_string()]); - assert!(workspace_root); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_packages() { - // vite install should be parsed as Install with packages - let args = - Args::try_parse_from(&["vite-plus", "install", "react", "react-dom"]).unwrap(); - if let Commands::Install { packages, dev, save_exact, .. } = &args.commands { - assert_eq!( - packages.as_ref().unwrap(), - &vec!["react".to_string(), "react-dom".to_string()] - ); - assert!(!dev); - assert!(!save_exact); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_packages_and_dev_flag() { - // vite install -D should work like vite add -D - let args = Args::try_parse_from(&["vite-plus", "install", "-D", "typescript"]).unwrap(); - if let Commands::Install { packages, dev, .. } = &args.commands { - assert_eq!(packages.as_ref().unwrap(), &vec!["typescript".to_string()]); - assert!(dev); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_packages_and_exact_flag() { - // vite install -E should work like vite add -E - let args = - Args::try_parse_from(&["vite-plus", "install", "-E", "lodash@4.17.21"]).unwrap(); - if let Commands::Install { packages, save_exact, .. } = &args.commands { - assert_eq!(packages.as_ref().unwrap(), &vec!["lodash@4.17.21".to_string()]); - assert!(save_exact); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_packages_and_global_flag() { - // vite install -g should work like vite add -g - let args = Args::try_parse_from(&["vite-plus", "install", "-g", "typescript"]).unwrap(); - if let Commands::Install { packages, global, .. } = &args.commands { - assert_eq!(packages.as_ref().unwrap(), &vec!["typescript".to_string()]); - assert!(global); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_packages_complex() { - // Complex example: vite install -D -E --filter app typescript eslint - let args = Args::try_parse_from(&[ - "vite-plus", - "install", - "-D", - "-E", - "--filter", - "app", - "typescript", - "eslint", - ]) - .unwrap(); - if let Commands::Install { packages, dev, save_exact, filter, .. } = &args.commands { - assert_eq!( - packages.as_ref().unwrap(), - &vec!["typescript".to_string(), "eslint".to_string()] - ); - assert!(dev); - assert!(save_exact); - assert_eq!(filter.as_ref().unwrap(), &vec!["app".to_string()]); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_packages_and_save_peer_flag() { - // vite install --save-peer should work like vite add --save-peer - let args = - Args::try_parse_from(&["vite-plus", "install", "--save-peer", "react"]).unwrap(); - if let Commands::Install { packages, save_peer, .. } = &args.commands { - assert_eq!(packages.as_ref().unwrap(), &vec!["react".to_string()]); - assert!(save_peer); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_packages_and_save_catalog_flag() { - // vite install --save-catalog should work like vite add --save-catalog - let args = - Args::try_parse_from(&["vite-plus", "install", "--save-catalog", "react"]).unwrap(); - if let Commands::Install { packages, save_catalog, .. } = &args.commands { - assert_eq!(packages.as_ref().unwrap(), &vec!["react".to_string()]); - assert!(save_catalog); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_packages_and_save_optional_flag() { - // vite install -O should work like vite add -O - let args = Args::try_parse_from(&["vite-plus", "install", "-O", "fsevents"]).unwrap(); - if let Commands::Install { packages, save_optional, .. } = &args.commands { - assert_eq!(packages.as_ref().unwrap(), &vec!["fsevents".to_string()]); - assert!(save_optional); - } else { - panic!("Expected Install command"); - } - - // Also test long form - let args = - Args::try_parse_from(&["vite-plus", "install", "--save-optional", "fsevents"]) - .unwrap(); - if let Commands::Install { packages, save_optional, .. } = &args.commands { - assert_eq!(packages.as_ref().unwrap(), &vec!["fsevents".to_string()]); - assert!(save_optional); - } else { - panic!("Expected Install command"); - } - } - - #[test] - fn test_args_install_command_with_silent_flag() { - let args = Args::try_parse_from(&["vite-plus", "install", "--silent"]).unwrap(); - if let Commands::Install { silent, .. } = &args.commands { - assert!(silent); - } else { - panic!("Expected Install command"); - } - } - } - - mod add_command_tests { - use super::*; - - #[test] - fn test_args_add_command() { - let args = Args::try_parse_from(&["vite-plus", "add", "react"]).unwrap(); - if let Commands::Add { filter, workspace_root, workspace, packages, .. } = - &args.commands - { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(filter.is_none()); - assert!(!workspace_root); - assert!(!workspace); - } else { - panic!("Expected Add command"); - } - - let args = Args::try_parse_from(&["vite-plus", "add", "--save-peer", "react"]).unwrap(); - if let Commands::Add { - filter, workspace_root, workspace, packages, save_peer, .. - } = &args.commands - { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(filter.is_none()); - assert!(!workspace_root); - assert!(!workspace); - assert!(save_peer); - } else { - panic!("Expected Add command"); - } - } - - #[test] - fn test_args_add_command_with_workspace_root() { - let args = Args::try_parse_from(&["vite-plus", "add", "-w", "react"]).unwrap(); - if let Commands::Add { filter, workspace_root, workspace, packages, .. } = - &args.commands - { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(filter.is_none()); - assert!(workspace_root); - assert!(!workspace); - } else { - panic!("Expected Add command"); - } - let args = Args::try_parse_from(&["vite-plus", "add", "react", "-w"]).unwrap(); - if let Commands::Add { filter, workspace_root, workspace, packages, .. } = - &args.commands - { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(filter.is_none()); - assert!(workspace_root); - assert!(!workspace); - } else { - panic!("Expected Add command"); - } - - let args = - Args::try_parse_from(&["vite-plus", "add", "react", "--workspace-root"]).unwrap(); - if let Commands::Add { filter, workspace_root, workspace, packages, .. } = - &args.commands - { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(filter.is_none()); - assert!(workspace_root); - assert!(!workspace); - } else { - panic!("Expected Add command"); - } - } - - #[test] - fn test_args_add_command_multiple_packages() { - let args = - Args::try_parse_from(&["vite-plus", "add", "react", "react-dom", "@types/react"]) - .unwrap(); - if let Commands::Add { packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react", "react-dom", "@types/react"]); - } else { - panic!("Expected Add command"); - } - } - - #[test] - fn test_args_add_command_with_flags() { - let args = Args::try_parse_from(&[ - "vite-plus", - "add", - "--filter", - "app", - "-w", - "--workspace", - "typescript", - "-D", - ]) - .unwrap(); - if let Commands::Add { filter, workspace_root, workspace, packages, save_dev, .. } = - &args.commands - { - assert_eq!(filter, &Some(vec!["app".to_string()])); - assert!(workspace_root); - assert!(workspace); - assert_eq!(packages, &vec!["typescript"]); - assert!(save_dev); - } else { - panic!("Expected Add command"); - } - } - - #[test] - fn test_args_add_command_with_allow_build() { - let args = Args::try_parse_from(&[ - "vite-plus", - "add", - "--filter", - "app", - "-w", - "--workspace", - "typescript", - "-D", - "--allow-build=react,napi", - ]) - .unwrap(); - if let Commands::Add { - filter, - workspace_root, - workspace, - packages, - save_dev, - allow_build, - .. - } = &args.commands - { - assert_eq!(filter, &Some(vec!["app".to_string()])); - assert!(workspace_root); - assert!(workspace); - assert_eq!(packages, &vec!["typescript"]); - assert!(save_dev); - assert_eq!(allow_build, &Some("react,napi".to_string())); - } else { - panic!("Expected Add command"); - } - } - - #[test] - fn test_args_add_command_multiple_filters() { - let args = Args::try_parse_from(&[ - "vite-plus", - "add", - "--filter", - "app", - "--filter", - "web", - "react", - ]) - .unwrap(); - if let Commands::Add { filter, packages, .. } = &args.commands { - assert_eq!(filter, &Some(vec!["app".to_string(), "web".to_string()])); - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Add command"); - } - } - - #[test] - fn test_args_add_command_invalid_filter() { - let args = Args::try_parse_from(&["vite-plus", "add", "react", "--filter"]); - assert!(args.is_err()); - } - - #[test] - fn test_args_add_command_with_pass_through_args() { - let args = Args::try_parse_from(&[ - "vite-plus", - "add", - "react", - "--", - "--watch", - "--mode=production", - "--use-stderr", - ]) - .unwrap(); - if let Commands::Add { packages, pass_through_args, .. } = &args.commands { - assert_eq!(packages, &vec!["react"]); - assert_eq!( - pass_through_args, - &Some(vec![ - "--watch".to_string(), - "--mode=production".to_string(), - "--use-stderr".to_string() - ]) - ); - } else { - panic!("Expected Add command"); - } - - let args = Args::try_parse_from(&[ - "vite-plus", - "add", - "react", - "napi", - "--", - "--allow-build=react,napi", - ]) - .unwrap(); - if let Commands::Add { packages, pass_through_args, .. } = &args.commands { - assert_eq!(packages, &vec!["react", "napi"]); - assert_eq!(pass_through_args, &Some(vec!["--allow-build=react,napi".to_string()])); - } else { - panic!("Expected Add command"); - } - } - } - - mod remove_command_tests { - use super::*; - - #[test] - fn test_args_remove_command() { - let args = Args::try_parse_from(&["vite-plus", "remove", "react"]).unwrap(); - if let Commands::Remove { - save_dev, - save_optional, - save_prod, - filter, - workspace_root, - recursive, - global, - packages, - pass_through_args, - } = &args.commands - { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(!save_dev); - assert!(!save_optional); - assert!(!save_prod); - assert!(filter.is_none()); - assert!(!workspace_root); - assert!(!recursive); - assert!(!global); - assert!(pass_through_args.is_none()); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_dev_flag() { - let args = Args::try_parse_from(&["vite-plus", "remove", "-D", "typescript"]).unwrap(); - if let Commands::Remove { save_dev, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["typescript".to_string()]); - assert!(save_dev); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_optional_flag() { - let args = Args::try_parse_from(&["vite-plus", "remove", "-O", "lodash"]).unwrap(); - if let Commands::Remove { save_optional, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["lodash".to_string()]); - assert!(save_optional); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_prod_flag() { - let args = Args::try_parse_from(&["vite-plus", "remove", "-P", "express"]).unwrap(); - if let Commands::Remove { save_prod, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["express".to_string()]); - assert!(save_prod); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_workspace_root() { - let args = Args::try_parse_from(&["vite-plus", "remove", "-w", "react"]).unwrap(); - if let Commands::Remove { workspace_root, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(workspace_root); - } else { - panic!("Expected Remove command"); - } - - let args = Args::try_parse_from(&["vite-plus", "remove", "react", "--workspace-root"]) - .unwrap(); - if let Commands::Remove { workspace_root, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(workspace_root); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_recursive() { - let args = Args::try_parse_from(&["vite-plus", "remove", "-r", "react"]).unwrap(); - if let Commands::Remove { recursive, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(recursive); - } else { - panic!("Expected Remove command"); - } - - let args = - Args::try_parse_from(&["vite-plus", "remove", "react", "--recursive"]).unwrap(); - if let Commands::Remove { recursive, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react".to_string()]); - assert!(recursive); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_global() { - let args = Args::try_parse_from(&["vite-plus", "remove", "-g", "npm"]).unwrap(); - if let Commands::Remove { global, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["npm".to_string()]); - assert!(global); - } else { - panic!("Expected Remove command"); - } - - let args = Args::try_parse_from(&["vite-plus", "remove", "npm", "--global"]).unwrap(); - if let Commands::Remove { global, packages, .. } = &args.commands { - assert_eq!(packages, &vec!["npm".to_string()]); - assert!(global); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_multiple_packages() { - let args = Args::try_parse_from(&[ - "vite-plus", - "remove", - "react", - "react-dom", - "@types/react", - ]) - .unwrap(); - if let Commands::Remove { packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react", "react-dom", "@types/react"]); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_single_filter() { - let args = - Args::try_parse_from(&["vite-plus", "remove", "--filter", "app", "typescript"]) - .unwrap(); - if let Commands::Remove { filter, packages, .. } = &args.commands { - assert_eq!(filter, &Some(vec!["app".to_string()])); - assert_eq!(packages, &vec!["typescript"]); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_multiple_filters() { - let args = Args::try_parse_from(&[ - "vite-plus", - "remove", - "--filter", - "app", - "--filter", - "web", - "react", - ]) - .unwrap(); - if let Commands::Remove { filter, packages, .. } = &args.commands { - assert_eq!(filter, &Some(vec!["app".to_string(), "web".to_string()])); - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_combined_flags() { - let args = Args::try_parse_from(&[ - "vite-plus", - "remove", - "-D", - "-w", - "--filter", - "app", - "typescript", - "eslint", - ]) - .unwrap(); - if let Commands::Remove { save_dev, workspace_root, filter, packages, .. } = - &args.commands - { - assert!(save_dev); - assert!(workspace_root); - assert_eq!(filter, &Some(vec!["app".to_string()])); - assert_eq!(packages, &vec!["typescript", "eslint"]); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_with_pass_through_args() { - let args = Args::try_parse_from(&[ - "vite-plus", - "remove", - "react", - "--", - "--ignore-scripts", - "--force", - ]) - .unwrap(); - if let Commands::Remove { packages, pass_through_args, .. } = &args.commands { - assert_eq!(packages, &vec!["react"]); - assert_eq!( - pass_through_args, - &Some(vec!["--ignore-scripts".to_string(), "--force".to_string()]) - ); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_alias_rm() { - let args = Args::try_parse_from(&["vite-plus", "rm", "react"]).unwrap(); - if let Commands::Remove { packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_alias_un() { - let args = Args::try_parse_from(&["vite-plus", "un", "react"]).unwrap(); - if let Commands::Remove { packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_alias_uninstall() { - let args = Args::try_parse_from(&["vite-plus", "uninstall", "react"]).unwrap(); - if let Commands::Remove { packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Remove command"); - } - } - - #[test] - fn test_args_remove_command_invalid_filter() { - let args = Args::try_parse_from(&["vite-plus", "remove", "react", "--filter"]); - assert!(args.is_err()); - } - - #[test] - fn test_args_remove_command_complex_scenario() { - let args = Args::try_parse_from(&[ - "vite-plus", - "remove", - "-D", - "-r", - "--filter", - "app", - "--filter", - "web", - "typescript", - "eslint", - "@types/node", - "--", - "--ignore-scripts", - ]) - .unwrap(); - if let Commands::Remove { - save_dev, - recursive, - filter, - packages, - pass_through_args, - .. - } = &args.commands - { - assert!(save_dev); - assert!(recursive); - assert_eq!(filter, &Some(vec!["app".to_string(), "web".to_string()])); - assert_eq!(packages, &vec!["typescript", "eslint", "@types/node"]); - assert_eq!(pass_through_args, &Some(vec!["--ignore-scripts".to_string()])); - } else { - panic!("Expected Remove command"); - } - } - } - - mod update_command_tests { - use super::*; - - #[test] - fn test_args_update_command_basic() { - let args = Args::try_parse_from(&["vite-plus", "update"]).unwrap(); - if let Commands::Update { - latest, - global, - recursive, - filter, - workspace_root, - dev, - prod, - interactive, - no_optional, - no_save, - workspace, - packages, - .. - } = &args.commands - { - assert!(!latest); - assert!(!global); - assert!(!recursive); - assert!(filter.is_none()); - assert!(!workspace_root); - assert!(!dev); - assert!(!prod); - assert!(!interactive); - assert!(!no_optional); - assert!(!no_save); - assert!(!workspace); - assert!(packages.is_empty()); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_alias() { - let args = Args::try_parse_from(&["vite-plus", "up"]).unwrap(); - assert!(matches!(args.commands, Commands::Update { .. })); - } - - #[test] - fn test_args_update_command_with_packages() { - let args = - Args::try_parse_from(&["vite-plus", "update", "react", "react-dom"]).unwrap(); - if let Commands::Update { packages, .. } = &args.commands { - assert_eq!(packages, &vec!["react", "react-dom"]); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_latest_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "-L", "react"]).unwrap(); - if let Commands::Update { latest, packages, .. } = &args.commands { - assert!(latest); - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Update command"); - } - - let args = Args::try_parse_from(&["vite-plus", "update", "--latest", "react"]).unwrap(); - if let Commands::Update { latest, packages, .. } = &args.commands { - assert!(latest); - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_global_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "-g"]).unwrap(); - if let Commands::Update { global, .. } = &args.commands { - assert!(global); - } else { - panic!("Expected Update command"); - } - - let args = Args::try_parse_from(&["vite-plus", "update", "--global"]).unwrap(); - if let Commands::Update { global, .. } = &args.commands { - assert!(global); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_recursive_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "-r"]).unwrap(); - if let Commands::Update { recursive, .. } = &args.commands { - assert!(recursive); - } else { - panic!("Expected Update command"); - } - - let args = Args::try_parse_from(&["vite-plus", "update", "--recursive"]).unwrap(); - if let Commands::Update { recursive, .. } = &args.commands { - assert!(recursive); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_workspace_root_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "-w"]).unwrap(); - if let Commands::Update { workspace_root, .. } = &args.commands { - assert!(workspace_root); - } else { - panic!("Expected Update command"); - } - - let args = Args::try_parse_from(&["vite-plus", "update", "--workspace-root"]).unwrap(); - if let Commands::Update { workspace_root, .. } = &args.commands { - assert!(workspace_root); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_dev_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "-D"]).unwrap(); - if let Commands::Update { dev, .. } = &args.commands { - assert!(dev); - } else { - panic!("Expected Update command"); - } - - let args = Args::try_parse_from(&["vite-plus", "update", "--dev"]).unwrap(); - if let Commands::Update { dev, .. } = &args.commands { - assert!(dev); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_prod_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "-P"]).unwrap(); - if let Commands::Update { prod, .. } = &args.commands { - assert!(prod); - } else { - panic!("Expected Update command"); - } - - let args = Args::try_parse_from(&["vite-plus", "update", "--prod"]).unwrap(); - if let Commands::Update { prod, .. } = &args.commands { - assert!(prod); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_interactive_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "-i"]).unwrap(); - if let Commands::Update { interactive, .. } = &args.commands { - assert!(interactive); - } else { - panic!("Expected Update command"); - } - - let args = Args::try_parse_from(&["vite-plus", "update", "--interactive"]).unwrap(); - if let Commands::Update { interactive, .. } = &args.commands { - assert!(interactive); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_no_optional_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "--no-optional"]).unwrap(); - if let Commands::Update { no_optional, .. } = &args.commands { - assert!(no_optional); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_no_save_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "--no-save"]).unwrap(); - if let Commands::Update { no_save, .. } = &args.commands { - assert!(no_save); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_workspace_flag() { - let args = Args::try_parse_from(&["vite-plus", "update", "--workspace"]).unwrap(); - if let Commands::Update { workspace, .. } = &args.commands { - assert!(workspace); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_filter() { - let args = - Args::try_parse_from(&["vite-plus", "update", "--filter", "app", "react"]).unwrap(); - if let Commands::Update { filter, packages, .. } = &args.commands { - assert_eq!(filter, &Some(vec!["app".to_string()])); - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_multiple_filters() { - let args = Args::try_parse_from(&[ - "vite-plus", - "update", - "--filter", - "app", - "--filter", - "web", - "react", - ]) - .unwrap(); - if let Commands::Update { filter, packages, .. } = &args.commands { - assert_eq!(filter, &Some(vec!["app".to_string(), "web".to_string()])); - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_combined_flags() { - let args = Args::try_parse_from(&[ - "vite-plus", - "update", - "-L", - "-r", - "-D", - "--filter", - "app", - "typescript", - "eslint", - ]) - .unwrap(); - if let Commands::Update { latest, recursive, dev, filter, packages, .. } = - &args.commands - { - assert!(latest); - assert!(recursive); - assert!(dev); - assert_eq!(filter, &Some(vec!["app".to_string()])); - assert_eq!(packages, &vec!["typescript", "eslint"]); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_with_pass_through_args() { - let args = Args::try_parse_from(&[ - "vite-plus", - "update", - "react", - "--", - "--registry", - "https://custom-registry.com", - ]) - .unwrap(); - if let Commands::Update { packages, pass_through_args, .. } = &args.commands { - assert_eq!(packages, &vec!["react"]); - assert_eq!( - pass_through_args, - &Some(vec![ - "--registry".to_string(), - "https://custom-registry.com".to_string() - ]) - ); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_complex_scenario() { - let args = Args::try_parse_from(&[ - "vite-plus", - "update", - "-L", - "-r", - "-w", - "-D", - "--filter", - "app", - "--filter", - "web", - "--no-optional", - "react", - "vue", - "--", - "--registry", - "https://registry.npmjs.org", - ]) - .unwrap(); - if let Commands::Update { - latest, - recursive, - workspace_root, - dev, - filter, - no_optional, - packages, - pass_through_args, - .. - } = &args.commands - { - assert!(latest); - assert!(recursive); - assert!(workspace_root); - assert!(dev); - assert_eq!(filter, &Some(vec!["app".to_string(), "web".to_string()])); - assert!(no_optional); - assert_eq!(packages, &vec!["react", "vue"]); - assert_eq!( - pass_through_args, - &Some(vec!["--registry".to_string(), "https://registry.npmjs.org".to_string()]) - ); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_all_packages() { - // When no packages are specified, should update all packages - let args = Args::try_parse_from(&["vite-plus", "update", "-r"]).unwrap(); - if let Commands::Update { recursive, packages, .. } = &args.commands { - assert!(recursive); - assert!(packages.is_empty()); - } else { - panic!("Expected Update command"); - } - } - - #[test] - fn test_args_update_command_workspace_combinations() { - // Test --workspace-root with --recursive - let args = Args::try_parse_from(&["vite-plus", "update", "-w", "-r"]).unwrap(); - if let Commands::Update { workspace_root, recursive, .. } = &args.commands { - assert!(workspace_root); - assert!(recursive); - } else { - panic!("Expected Update command"); - } - - // Test --workspace flag - let args = - Args::try_parse_from(&["vite-plus", "update", "--workspace", "react"]).unwrap(); - if let Commands::Update { workspace, packages, .. } = &args.commands { - assert!(workspace); - assert_eq!(packages, &vec!["react"]); - } else { - panic!("Expected Update command"); - } - } - } - - mod dedupe_command_tests { - use super::*; - - #[test] - fn test_args_dedupe_command_basic() { - let args = Args::try_parse_from(&["vite-plus", "dedupe"]).unwrap(); - if let Commands::Dedupe { check, .. } = &args.commands { - assert!(!check); - } else { - panic!("Expected Dedupe command"); - } - } - - #[test] - fn test_args_dedupe_command_with_alias() { - let args = Args::try_parse_from(&["vite-plus", "ddp"]).unwrap(); - assert!(matches!(args.commands, Commands::Dedupe { .. })); - } - - #[test] - fn test_args_dedupe_command_with_check() { - let args = Args::try_parse_from(&["vite-plus", "dedupe", "--check"]).unwrap(); - if let Commands::Dedupe { check, .. } = &args.commands { - assert!(check); - } else { - panic!("Expected Dedupe command"); - } - } - - #[test] - fn test_args_dedupe_command_with_pass_through_args() { - let args = Args::try_parse_from(&[ - "vite-plus", - "dedupe", - "--", - "--some-flag", - "--another-flag", - ]) - .unwrap(); - if let Commands::Dedupe { pass_through_args, .. } = &args.commands { - assert_eq!( - pass_through_args, - &Some(vec!["--some-flag".to_string(), "--another-flag".to_string()]) - ); - } else { - panic!("Expected Dedupe command"); - } - } - - #[test] - fn test_args_dedupe_command_with_check_and_pass_through() { - let args = - Args::try_parse_from(&["vite-plus", "dedupe", "--check", "--", "--custom-flag"]) - .unwrap(); - if let Commands::Dedupe { check, pass_through_args, .. } = &args.commands { - assert!(check); - assert_eq!(pass_through_args, &Some(vec!["--custom-flag".to_string()])); - } else { - panic!("Expected Dedupe command"); - } - } - } - - mod dlx_command_tests { - use super::*; - - #[test] - fn test_args_dlx_command_basic() { - let args = Args::try_parse_from(&["vite-plus", "dlx", "create-vue", "my-app"]).unwrap(); - if let Commands::Dlx { package, shell_mode, silent, args: cmd_args } = &args.commands { - assert!(package.is_empty()); - assert!(!shell_mode); - assert!(!silent); - assert_eq!(cmd_args, &vec!["create-vue", "my-app"]); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_with_version() { - let args = - Args::try_parse_from(&["vite-plus", "dlx", "typescript@5.5.4", "tsc", "--version"]) - .unwrap(); - if let Commands::Dlx { args: cmd_args, .. } = &args.commands { - assert_eq!(cmd_args, &vec!["typescript@5.5.4", "tsc", "--version"]); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_with_package_flag() { - let args = Args::try_parse_from(&[ - "vite-plus", - "dlx", - "-p", - "yo", - "-p", - "generator-webapp", - "yo", - "webapp", - ]) - .unwrap(); - if let Commands::Dlx { package, args: cmd_args, .. } = &args.commands { - assert_eq!(package, &vec!["yo", "generator-webapp"]); - assert_eq!(cmd_args, &vec!["yo", "webapp"]); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_with_long_package_flag() { - let args = Args::try_parse_from(&[ - "vite-plus", - "dlx", - "--package", - "cowsay", - "--package", - "lolcatjs", - "cowsay", - "hello", - ]) - .unwrap(); - if let Commands::Dlx { package, args: cmd_args, .. } = &args.commands { - assert_eq!(package, &vec!["cowsay", "lolcatjs"]); - assert_eq!(cmd_args, &vec!["cowsay", "hello"]); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_with_shell_mode() { - let args = - Args::try_parse_from(&["vite-plus", "dlx", "-c", "echo hello | cowsay"]).unwrap(); - if let Commands::Dlx { shell_mode, args: cmd_args, .. } = &args.commands { - assert!(shell_mode); - assert_eq!(cmd_args, &vec!["echo hello | cowsay"]); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_with_shell_mode_long() { - let args = - Args::try_parse_from(&["vite-plus", "dlx", "--shell-mode", "echo hello | cowsay"]) - .unwrap(); - if let Commands::Dlx { shell_mode, .. } = &args.commands { - assert!(shell_mode); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_with_silent() { - let args = - Args::try_parse_from(&["vite-plus", "dlx", "-s", "create-vue", "my-app"]).unwrap(); - if let Commands::Dlx { silent, .. } = &args.commands { - assert!(silent); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_with_silent_long() { - let args = - Args::try_parse_from(&["vite-plus", "dlx", "--silent", "create-vue", "my-app"]) - .unwrap(); - if let Commands::Dlx { silent, .. } = &args.commands { - assert!(silent); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_combined_flags() { - let args = Args::try_parse_from(&[ - "vite-plus", - "dlx", - "-p", - "cowsay", - "-c", - "-s", - "echo hello | cowsay", - ]) - .unwrap(); - if let Commands::Dlx { package, shell_mode, silent, args: cmd_args } = &args.commands { - assert_eq!(package, &vec!["cowsay"]); - assert!(shell_mode); - assert!(silent); - assert_eq!(cmd_args, &vec!["echo hello | cowsay"]); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_with_hyphen_args() { - let args = Args::try_parse_from(&[ - "vite-plus", - "dlx", - "typescript", - "tsc", - "--noEmit", - "--strict", - ]) - .unwrap(); - if let Commands::Dlx { args: cmd_args, .. } = &args.commands { - assert_eq!(cmd_args, &vec!["typescript", "tsc", "--noEmit", "--strict"]); - } else { - panic!("Expected Dlx command"); - } - } - - #[test] - fn test_args_dlx_command_requires_package() { - // dlx requires at least one argument (the package) - let result = Args::try_parse_from(&["vite-plus", "dlx"]); - assert!(result.is_err()); - } - - #[test] - fn test_args_dlx_command_scoped_package() { - let args = - Args::try_parse_from(&["vite-plus", "dlx", "@vue/cli@5.0.0", "create", "my-app"]) - .unwrap(); - if let Commands::Dlx { args: cmd_args, .. } = &args.commands { - assert_eq!(cmd_args, &vec!["@vue/cli@5.0.0", "create", "my-app"]); - } else { - panic!("Expected Dlx command"); - } - } - } -} diff --git a/packages/global/binding/src/commands/mod.rs b/packages/global/binding/src/commands/mod.rs deleted file mode 100644 index da33cd493d..0000000000 --- a/packages/global/binding/src/commands/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub(crate) mod add; -pub(crate) mod dedupe; -pub(crate) mod dlx; -pub(crate) mod install; -pub(crate) mod link; -pub(crate) mod outdated; -pub(crate) mod pm; -pub(crate) mod remove; -pub(crate) mod unlink; -pub(crate) mod update; -pub(crate) mod why; diff --git a/packages/global/binding/src/commands/pm.rs b/packages/global/binding/src/commands/pm.rs deleted file mode 100644 index b62ca37a9a..0000000000 --- a/packages/global/binding/src/commands/pm.rs +++ /dev/null @@ -1,225 +0,0 @@ -use std::process::ExitStatus; - -use vite_install::{ - commands::{ - cache::CacheCommandOptions, config::ConfigCommandOptions, list::ListCommandOptions, - owner::OwnerSubcommand, pack::PackCommandOptions, prune::PruneCommandOptions, - publish::PublishCommandOptions, view::ViewCommandOptions, - }, - package_manager::PackageManager, -}; -use vite_path::AbsolutePathBuf; - -use crate::{ - Error, - cli::{ConfigCommands, OwnerCommands, PmCommands}, -}; - -/// Forward a command to the package manager. -/// -/// This command provides a unified interface to package manager utilities -/// across pnpm, npm, and yarn. -pub struct PmCommand { - cwd: AbsolutePathBuf, -} - -impl PmCommand { - pub fn new(cwd: AbsolutePathBuf) -> Self { - Self { cwd } - } - - pub async fn execute(self, command: PmCommands) -> Result { - // Detect package manager - let package_manager = PackageManager::builder(&self.cwd).build_with_default().await?; - - match command { - PmCommands::Prune { prod, no_optional, pass_through_args } => { - let options = PruneCommandOptions { - prod, - no_optional, - pass_through_args: pass_through_args.as_deref(), - }; - package_manager.run_prune_command(&options, &self.cwd).await - } - PmCommands::Pack { - recursive, - filter, - out, - pack_destination, - pack_gzip_level, - json, - pass_through_args, - } => { - let options = PackCommandOptions { - recursive, - filters: filter.as_deref(), - out: out.as_deref(), - pack_destination: pack_destination.as_deref(), - pack_gzip_level, - json, - pass_through_args: pass_through_args.as_deref(), - }; - package_manager.run_pack_command(&options, &self.cwd).await - } - PmCommands::List { - pattern, - depth, - json, - long, - parseable, - prod, - dev, - no_optional, - exclude_peers, - only_projects, - find_by, - recursive, - filter, - global, - pass_through_args, - } => { - let options = ListCommandOptions { - pattern: pattern.as_deref(), - depth, - json, - long, - parseable, - prod, - dev, - no_optional, - exclude_peers, - only_projects, - find_by: find_by.as_deref(), - recursive, - filters: if filter.is_empty() { None } else { Some(&filter) }, - global, - pass_through_args: pass_through_args.as_deref(), - }; - package_manager.run_list_command(&options, &self.cwd).await - } - PmCommands::View { package, field, json, pass_through_args } => { - let options = ViewCommandOptions { - package: &package, - field: field.as_deref(), - json, - pass_through_args: pass_through_args.as_deref(), - }; - package_manager.run_view_command(&options, &self.cwd).await - } - PmCommands::Publish { - target, - dry_run, - tag, - access, - otp, - no_git_checks, - publish_branch, - report_summary, - force, - json, - recursive, - filter, - pass_through_args, - } => { - let options = PublishCommandOptions { - target: target.as_deref(), - dry_run, - tag: tag.as_deref(), - access: access.as_deref(), - otp: otp.as_deref(), - no_git_checks, - publish_branch: publish_branch.as_deref(), - report_summary, - force, - json, - recursive, - filters: filter.as_deref(), - pass_through_args: pass_through_args.as_deref(), - }; - package_manager.run_publish_command(&options, &self.cwd).await - } - PmCommands::Owner(owner_command) => { - let subcommand = match owner_command { - OwnerCommands::List { package, otp } => OwnerSubcommand::List { package, otp }, - OwnerCommands::Add { user, package, otp } => { - OwnerSubcommand::Add { user, package, otp } - } - OwnerCommands::Rm { user, package, otp } => { - OwnerSubcommand::Rm { user, package, otp } - } - }; - package_manager.run_owner_command(&subcommand, &self.cwd).await - } - PmCommands::Cache { subcommand, pass_through_args } => { - let options = CacheCommandOptions { - subcommand: &subcommand, - pass_through_args: pass_through_args.as_deref(), - }; - package_manager.run_cache_command(&options, &self.cwd).await - } - PmCommands::Config(config_command) => match config_command { - ConfigCommands::List { json, global, location } => { - let options = ConfigCommandOptions { - subcommand: "list", - key: None, - value: None, - json, - location: if global { Some("global") } else { location.as_deref() }, - pass_through_args: None, - }; - package_manager.run_config_command(&options, &self.cwd).await - } - ConfigCommands::Get { key, json, global, location } => { - let options = ConfigCommandOptions { - subcommand: "get", - key: Some(key.as_str()), - value: None, - json, - location: if global { Some("global") } else { location.as_deref() }, - pass_through_args: None, - }; - package_manager.run_config_command(&options, &self.cwd).await - } - ConfigCommands::Set { key, value, json, global, location } => { - let options = ConfigCommandOptions { - subcommand: "set", - key: Some(key.as_str()), - value: Some(value.as_str()), - json, - location: if global { Some("global") } else { location.as_deref() }, - pass_through_args: None, - }; - package_manager.run_config_command(&options, &self.cwd).await - } - ConfigCommands::Delete { key, global, location } => { - let options = ConfigCommandOptions { - subcommand: "delete", - key: Some(key.as_str()), - value: None, - json: false, - location: if global { Some("global") } else { location.as_deref() }, - pass_through_args: None, - }; - package_manager.run_config_command(&options, &self.cwd).await - } - }, - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_pm_command_new() { - let workspace_root = if cfg!(windows) { - AbsolutePathBuf::new("C:\\test".into()).unwrap() - } else { - AbsolutePathBuf::new("/test".into()).unwrap() - }; - - let cmd = PmCommand::new(workspace_root.clone()); - assert_eq!(cmd.cwd, workspace_root); - } -} diff --git a/packages/global/binding/src/lib.rs b/packages/global/binding/src/lib.rs index ae71b0ac04..350bb4f076 100644 --- a/packages/global/binding/src/lib.rs +++ b/packages/global/binding/src/lib.rs @@ -1,21 +1,14 @@ //! NAPI binding layer for vite-plus global CLI +//! +//! Note: Package manager commands have been moved to the vite_global_cli crate. +//! This binding is now minimal and mainly exists for migration utilities. -mod cli; -mod commands; mod migration; mod package_manager; mod utils; -use std::ffi::{OsStr, OsString}; - -use clap::FromArgMatches as _; -use napi::{anyhow, bindgen_prelude::*}; -use napi_derive::napi; pub use utils::run_command; -use vite_error::Error; -use vite_path::current_dir; -use crate::cli::Args; pub use crate::{ migration::{ merge_json_config, merge_tsdown_config, rewrite_imports_in_directory, rewrite_scripts, @@ -26,85 +19,9 @@ pub use crate::{ /// Module initialization - sets up tracing for debugging #[napi_derive::module_init] pub fn init() { - crate::cli::init_tracing(); -} - -/// Configuration options passed from JavaScript to Rust. -/// -/// Each field (except `cwd`) is a JavaScript function wrapped in a `ThreadsafeFunction`. -/// These functions are called by Rust to resolve tool binary paths when needed. -/// -/// The `ThreadsafeFunction` wrapper ensures the JavaScript functions can be -/// safely called from Rust's async runtime without blocking or race conditions. -#[napi(object, object_to_js = false)] -pub struct CliOptions { - /// Optional working directory override - pub cwd: Option, -} - -/// Main entry point for the CLI, called from JavaScript. -/// -/// This function: -/// 1. Parses command-line arguments -/// 2. Sets up the working directory -/// 3. Creates Rust-callable wrappers for JavaScript resolver functions -/// 4. Passes control to the Rust core (`cli::main`) -/// -/// ## JavaScript-to-Rust Bridge -/// -/// The resolver functions are wrapped to: -/// - Call the JavaScript function asynchronously -/// - Handle errors and convert them to Rust error types -/// - Convert the JavaScript result to Rust's expected format -/// -/// ## Error Handling -/// -/// Errors from JavaScript resolvers are converted to specific error types -/// (e.g., `LintFailed`, `ViteError`) to provide better error messages. -#[napi] -pub async fn run(options: CliOptions) -> Result { - let args = parse_args(); - // Use provided cwd or current directory - let mut cwd = current_dir()?; - if let Some(options_cwd) = options.cwd { - cwd.push(options_cwd); - } - // Call the Rust core with wrapped resolver functions - let result = crate::cli::main(cwd, args).await; - - tracing::debug!("Result: {result:?}"); - - match result { - Ok(exit_status) => Ok(exit_status.code().unwrap_or(1)), - Err(e) => { - match e { - // Standard exit code for Ctrl+C - Error::UserCancelled => Ok(130), - _ => { - // Convert Rust errors to NAPI errors for JavaScript - tracing::error!("Rust error: {:?}", e); - Err(anyhow::Error::from(e).into()) - } - } - } + #[cfg(debug_assertions)] + { + use tracing_subscriber::{EnvFilter, fmt}; + let _ = fmt().with_env_filter(EnvFilter::from_default_env()).try_init(); } } - -fn parse_args() -> Args { - // Parse CLI arguments (skip first arg which is the node binary) - let args = normalize_help_args(std::env::args_os().skip(1).collect()); - let matches = crate::cli::command_with_help().get_matches_from(args); - Args::from_arg_matches(&matches).unwrap_or_else(|e| e.exit()) -} - -fn normalize_help_args(args: Vec) -> Vec { - if matches!(args.first(), Some(arg) if arg == OsStr::new("help")) { - return vec![OsString::from("--help")]; - } - - if args.len() >= 2 && args[1] == OsStr::new("help") { - return vec![args[0].clone(), OsString::from("--help")]; - } - - args -} diff --git a/packages/global/install.ps1 b/packages/global/install.ps1 new file mode 100644 index 0000000000..ef00afabea --- /dev/null +++ b/packages/global/install.ps1 @@ -0,0 +1,348 @@ +# Vite+ CLI Installer for Windows +# https://viteplus.dev/install.ps1 +# +# Usage: +# irm https://viteplus.dev/install.ps1 | iex +# +# Environment variables: +# VITE_PLUS_VERSION - Version to install (default: latest) +# VITE_PLUS_INSTALL_DIR - Installation directory (default: $env:USERPROFILE\.vite-plus) +# NPM_CONFIG_REGISTRY - Custom npm registry URL (default: https://registry.npmjs.org) + +$ErrorActionPreference = "Stop" + +$ViteVersion = if ($env:VITE_PLUS_VERSION) { $env:VITE_PLUS_VERSION } else { "latest" } +$InstallDir = if ($env:VITE_PLUS_INSTALL_DIR) { $env:VITE_PLUS_INSTALL_DIR } else { "$env:USERPROFILE\.vite-plus" } +# npm registry URL (strip trailing slash if present) +$NpmRegistry = if ($env:NPM_CONFIG_REGISTRY) { $env:NPM_CONFIG_REGISTRY.TrimEnd('/') } else { "https://registry.npmjs.org" } + +function Write-Info { + param([string]$Message) + Write-Host "info: " -ForegroundColor Blue -NoNewline + Write-Host $Message +} + +function Write-Success { + param([string]$Message) + Write-Host "success: " -ForegroundColor Green -NoNewline + Write-Host $Message +} + +function Write-Warn { + param([string]$Message) + Write-Host "warn: " -ForegroundColor Yellow -NoNewline + Write-Host $Message +} + +function Write-Error-Exit { + param([string]$Message) + Write-Host "error: " -ForegroundColor Red -NoNewline + Write-Host $Message + exit 1 +} + +function Get-Architecture { + if ([Environment]::Is64BitOperatingSystem) { + if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { + return "arm64" + } else { + return "x64" + } + } else { + Write-Error-Exit "32-bit Windows is not supported" + } +} + +# Cached package metadata +$script:PackageMetadata = $null + +function Get-PackageMetadata { + if ($null -eq $script:PackageMetadata) { + $versionPath = if ($ViteVersion -eq "latest") { "latest" } else { $ViteVersion } + $metadataUrl = "$NpmRegistry/vite-plus-cli/$versionPath" + try { + $script:PackageMetadata = Invoke-RestMethod $metadataUrl + } catch { + # Try to extract npm error message from response + $errorMsg = $_.ErrorDetails.Message + if ($errorMsg) { + try { + $errorJson = $errorMsg | ConvertFrom-Json + if ($errorJson.error) { + Write-Error-Exit "Failed to fetch version '${versionPath}': $($errorJson.error)" + } + } catch { + # JSON parsing failed, fall through to generic error + } + } + Write-Error-Exit "Failed to fetch package metadata from: $metadataUrl`nError: $_" + } + # Check for error in successful response + # npm can return {"error":"..."} object or a plain string like "version not found: test" + if ($script:PackageMetadata -is [string]) { + # Plain string response means error + Write-Error-Exit "Failed to fetch version '${versionPath}': $script:PackageMetadata" + } + if ($script:PackageMetadata.error) { + Write-Error-Exit "Failed to fetch version '${versionPath}': $($script:PackageMetadata.error)" + } + } + return $script:PackageMetadata +} + +function Get-VersionFromMetadata { + $metadata = Get-PackageMetadata + if (-not $metadata.version) { + Write-Error-Exit "Failed to extract version from package metadata" + } + return $metadata.version +} + +function Get-PackageSuffix { + param([string]$Platform) + + $metadata = Get-PackageMetadata + $optionalDeps = $metadata.optionalDependencies + + if ($null -eq $optionalDeps) { + Write-Error-Exit "No optionalDependencies found in package metadata" + } + + # Find matching package for platform + $prefix = "@voidzero-dev/vite-plus-cli-" + $matchingPackage = $null + + foreach ($dep in $optionalDeps.PSObject.Properties.Name) { + if ($dep.StartsWith("$prefix$Platform")) { + $matchingPackage = $dep + break + } + } + + if ($null -eq $matchingPackage) { + # List available platforms for helpful error message + $availablePlatforms = $optionalDeps.PSObject.Properties.Name | + ForEach-Object { $_.Replace($prefix, "") } | + Join-String -Separator ", " + Write-Error-Exit "Unsupported platform: $Platform. Available platforms: $availablePlatforms" + } + + # Extract suffix by removing the package prefix + return $matchingPackage.Replace($prefix, "") +} + +function Download-AndExtract { + param( + [string]$Url, + [string]$DestDir, + [string]$Filter + ) + + $tempFile = New-TemporaryFile + try { + # Suppress progress bar for cleaner output + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $Url -OutFile $tempFile + + # Create temp extraction directory + $tempExtract = Join-Path $env:TEMP "vite-install-$(Get-Random)" + New-Item -ItemType Directory -Force -Path $tempExtract | Out-Null + + # Extract using tar (available in Windows 10+) + tar -xzf $tempFile -C $tempExtract + + # Copy the specified file/directory + $sourcePath = Join-Path $tempExtract "package" $Filter + if (Test-Path $sourcePath) { + Copy-Item -Path $sourcePath -Destination $DestDir -Recurse -Force + } + + Remove-Item -Recurse -Force $tempExtract + } finally { + Remove-Item $tempFile -ErrorAction SilentlyContinue + } +} + +function Cleanup-OldVersions { + param([string]$InstallDir) + + $maxVersions = 5 + $versions = Get-ChildItem -Path $InstallDir -Directory -ErrorAction SilentlyContinue | + Where-Object { $_.Name -ne "current" } + + if ($null -eq $versions -or $versions.Count -le $maxVersions) { + return + } + + # Sort by creation time (oldest first) and select excess + $toDelete = $versions | + Sort-Object CreationTime | + Select-Object -First ($versions.Count - $maxVersions) + + foreach ($old in $toDelete) { + # Remove silently + Remove-Item -Path $old.FullName -Recurse -Force + } +} + +function Main { + Write-Host "" + Write-Host "Setting up VITE+(⚡︎)..." + Write-Host "" + + # Suppress progress bars for cleaner output + $ProgressPreference = 'SilentlyContinue' + + $arch = Get-Architecture + $platform = "win32-$arch" + + # Fetch package metadata and resolve version + $ViteVersion = Get-VersionFromMetadata + + # Set up version-specific directories + $VersionDir = "$InstallDir\$ViteVersion" + $BinDir = "$VersionDir\bin" + $DistDir = "$VersionDir\dist" + $CurrentLink = "$InstallDir\current" + + # Get package suffix from optionalDependencies (dynamic lookup) + $packageSuffix = Get-PackageSuffix -Platform $platform + $packageName = "@voidzero-dev/vite-plus-cli-$packageSuffix" + $binaryName = "vp.exe" + + # Create directories + New-Item -ItemType Directory -Force -Path $BinDir | Out-Null + New-Item -ItemType Directory -Force -Path $DistDir | Out-Null + + # Download and extract native binary and .node files from platform package + $platformUrl = "$NpmRegistry/$packageName/-/vite-plus-cli-$packageSuffix-$ViteVersion.tgz" + + $platformTempFile = New-TemporaryFile + try { + Invoke-WebRequest -Uri $platformUrl -OutFile $platformTempFile + + # Create temp extraction directory + $platformTempExtract = Join-Path $env:TEMP "vite-platform-$(Get-Random)" + New-Item -ItemType Directory -Force -Path $platformTempExtract | Out-Null + + # Extract the package + tar -xzf $platformTempFile -C $platformTempExtract + + # Copy binary to BinDir + $binarySource = Join-Path $platformTempExtract "package" $binaryName + if (Test-Path $binarySource) { + Copy-Item -Path $binarySource -Destination $BinDir -Force + } + + # Copy .node files to DistDir (delete existing first to avoid system cache issues) + $nodeFilesPath = Join-Path $platformTempExtract "package" + Get-ChildItem -Path $nodeFilesPath -Filter "*.node" -ErrorAction SilentlyContinue | ForEach-Object { + $destFile = Join-Path $DistDir $_.Name + if (Test-Path $destFile) { + Remove-Item -Path $destFile -Force + } + Copy-Item -Path $_.FullName -Destination $DistDir -Force + } + + Remove-Item -Recurse -Force $platformTempExtract + } finally { + Remove-Item $platformTempFile -ErrorAction SilentlyContinue + } + + # Download and extract JS bundle + $mainUrl = "$NpmRegistry/vite-plus-cli/-/vite-plus-cli-$ViteVersion.tgz" + + $mainTempFile = New-TemporaryFile + try { + Invoke-WebRequest -Uri $mainUrl -OutFile $mainTempFile + + # Create temp extraction directory + $mainTempExtract = Join-Path $env:TEMP "vite-main-$(Get-Random)" + New-Item -ItemType Directory -Force -Path $mainTempExtract | Out-Null + + # Extract the package + tar -xzf $mainTempFile -C $mainTempExtract + + # Copy directories and files to VersionDir + $itemsToCopy = @("dist", "templates", "rules", "AGENTS.md", "package.json") + foreach ($item in $itemsToCopy) { + $itemSource = Join-Path $mainTempExtract "package" $item + if (Test-Path $itemSource) { + Copy-Item -Path $itemSource -Destination $VersionDir -Recurse -Force + } + } + + Remove-Item -Recurse -Force $mainTempExtract + } finally { + Remove-Item $mainTempFile -ErrorAction SilentlyContinue + } + + # Remove devDependencies and optionalDependencies from package.json + # (temporary solution until deps are fully bundled) + $pkgFile = Join-Path $VersionDir "package.json" + $pkg = Get-Content $pkgFile -Raw | ConvertFrom-Json + $pkg.PSObject.Properties.Remove("devDependencies") + $pkg.PSObject.Properties.Remove("optionalDependencies") + $pkg | ConvertTo-Json -Depth 10 | Set-Content $pkgFile + + # Install production dependencies + Push-Location $VersionDir + try { + $env:CI = "true" + & "$BinDir\vp.exe" install --silent + } finally { + Pop-Location + } + + # Create/update current junction (symlink) + if (Test-Path $CurrentLink) { + # Remove existing junction + cmd /c rmdir "$CurrentLink" 2>$null + Remove-Item -Path $CurrentLink -Force -ErrorAction SilentlyContinue + } + # Create new junction pointing to the version directory + cmd /c mklink /J "$CurrentLink" "$VersionDir" | Out-Null + + # Cleanup old versions + Cleanup-OldVersions -InstallDir $InstallDir + + # Update PATH + $pathToAdd = "$InstallDir\current\bin" + $userPath = [Environment]::GetEnvironmentVariable("Path", "User") + + # Check if we need to update PATH + $needsPathUpdate = $true + if ($userPath -like "*$pathToAdd*") { + $needsPathUpdate = $false + } + + if ($needsPathUpdate) { + $newPath = "$pathToAdd;$userPath" + [Environment]::SetEnvironmentVariable("Path", $newPath, "User") + $env:Path = "$pathToAdd;$env:Path" + } + + # Print success message + Write-Host "" + Write-Host "✔ " -ForegroundColor Green -NoNewline + Write-Host "VITE+(⚡︎) successfully installed!" + Write-Host "" + Write-Host " Version: $ViteVersion" + Write-Host "" + # Use ~ shorthand if install dir is under USERPROFILE, otherwise show full path + $displayDir = $InstallDir -replace [regex]::Escape($env:USERPROFILE), '~' + Write-Host " Location: $displayDir\current\bin" + Write-Host "" + Write-Host " Next: Run vp --help to get started" + + # Show note if PATH was updated + if ($needsPathUpdate) { + Write-Host "" + Write-Host " Note: Restart your terminal or run:" + Write-Host " `$env:Path = `"$pathToAdd;`$env:Path`"" + } + + Write-Host "" +} + +Main diff --git a/packages/global/install.sh b/packages/global/install.sh new file mode 100644 index 0000000000..bb5494f83e --- /dev/null +++ b/packages/global/install.sh @@ -0,0 +1,558 @@ +#!/bin/bash +# Vite+ CLI Installer +# https://viteplus.dev/install.sh +# +# Usage: +# curl -fsSL https://viteplus.dev/install.sh | bash +# +# Environment variables: +# VITE_PLUS_VERSION - Version to install (default: latest) +# VITE_PLUS_INSTALL_DIR - Installation directory (default: ~/.vite-plus) +# NPM_CONFIG_REGISTRY - Custom npm registry URL (default: https://registry.npmjs.org) + +set -e + +VITE_PLUS_VERSION="${VITE_PLUS_VERSION:-latest}" +INSTALL_DIR="${VITE_PLUS_INSTALL_DIR:-$HOME/.vite-plus}" +# npm registry URL (strip trailing slash if present) +NPM_REGISTRY="${NPM_CONFIG_REGISTRY:-https://registry.npmjs.org}" +NPM_REGISTRY="${NPM_REGISTRY%/}" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +info() { + echo -e "${BLUE}info${NC}: $1" +} + +success() { + echo -e "${GREEN}success${NC}: $1" +} + +warn() { + echo -e "${YELLOW}warn${NC}: $1" +} + +error() { + echo -e "${RED}error${NC}: $1" + exit 1 +} + +# Print user-friendly error message for curl failures +# Arguments: exit_code url +print_curl_error() { + local exit_code="$1" + local url="$2" + + # Map curl exit codes to user-friendly messages + local error_desc + case $exit_code in + 6) + error_desc="DNS resolution failed - could not resolve hostname" + ;; + 7) + error_desc="Connection refused - the server may be down or unreachable" + ;; + 28) + error_desc="Connection timed out" + ;; + 35) + error_desc="SSL/TLS connection error" + ;; + 60) + error_desc="SSL certificate verification failed" + ;; + *) + error_desc="Network error" + ;; + esac + + echo "" + echo -e "${RED}error${NC}: ${error_desc} (curl exit code ${exit_code})" + echo "" + echo " This may be caused by:" + echo " - Network connectivity issues" + echo " - Firewall or proxy blocking the connection" + echo " - DNS configuration problems" + if [ $exit_code -eq 35 ] || [ $exit_code -eq 60 ]; then + echo " - Outdated SSL/TLS libraries" + fi + echo "" + if [ -n "$url" ]; then + echo " Failed URL: $url" + echo "" + echo " To debug, run:" + echo " curl -v \"$url\"" + echo "" + fi + exit 1 +} + +# Wrapper for curl with user-friendly error messages +# Arguments: same as curl +# Returns: exits with error message on failure, otherwise returns curl output +curl_with_error_handling() { + local url="" + local args=() + + # Parse arguments to find the URL (for error messages) + for arg in "$@"; do + case "$arg" in + http://*|https://*) + url="$arg" + ;; + esac + args+=("$arg") + done + + # Run curl and capture exit code + set +e + local output exit_code + output=$(curl "${args[@]}" 2>&1) + exit_code=$? + set -e + + if [ $exit_code -eq 0 ]; then + echo "$output" + return 0 + fi + + print_curl_error "$exit_code" "$url" +} + +# Detect libc type on Linux (gnu or musl) +detect_libc() { + # Check for musl dynamic linker (most reliable method) + if [ -e /lib/ld-musl-x86_64.so.1 ] || [ -e /lib/ld-musl-aarch64.so.1 ]; then + echo "musl" + return + fi + + # Check if ldd exists and is musl-based + if command -v ldd &> /dev/null; then + if ldd --version 2>&1 | grep -qi musl; then + echo "musl" + return + fi + fi + + # Default to gnu (glibc) + echo "gnu" +} + +# Detect platform +detect_platform() { + local os arch + + os="$(uname -s)" + arch="$(uname -m)" + + case "$os" in + Darwin) os="darwin" ;; + Linux) os="linux" ;; + MINGW*|MSYS*|CYGWIN*) os="win32" ;; + *) error "Unsupported operating system: $os" ;; + esac + + case "$arch" in + x86_64|amd64) arch="x64" ;; + arm64|aarch64) arch="arm64" ;; + *) error "Unsupported architecture: $arch" ;; + esac + + # For Linux, append libc type to distinguish gnu vs musl + if [ "$os" = "linux" ]; then + local libc + libc=$(detect_libc) + echo "${os}-${arch}-${libc}" + else + echo "${os}-${arch}" + fi +} + +# Check for required commands +check_requirements() { + local missing=() + + if ! command -v curl &> /dev/null; then + missing+=("curl") + fi + + if ! command -v tar &> /dev/null; then + missing+=("tar") + fi + + if [ ${#missing[@]} -ne 0 ]; then + error "Missing required commands: ${missing[*]}" + fi +} + +# Fetch package metadata from npm registry (cached for reuse) +# Uses VITE_PLUS_VERSION to fetch the correct version's metadata +PACKAGE_METADATA="" +fetch_package_metadata() { + if [ -z "$PACKAGE_METADATA" ]; then + local version_path metadata_url + if [ "$VITE_PLUS_VERSION" = "latest" ]; then + version_path="latest" + else + version_path="$VITE_PLUS_VERSION" + fi + metadata_url="${NPM_REGISTRY}/vite-plus-cli/${version_path}" + PACKAGE_METADATA=$(curl_with_error_handling -s "$metadata_url") + if [ -z "$PACKAGE_METADATA" ]; then + error "Failed to fetch package metadata from: $metadata_url" + fi + # Check for npm registry error response + # npm can return either {"error":"..."} or a plain JSON string like "version not found: test" + if echo "$PACKAGE_METADATA" | grep -q '"error"'; then + local error_msg + error_msg=$(echo "$PACKAGE_METADATA" | grep -o '"error":"[^"]*"' | cut -d'"' -f4) + error "Failed to fetch version '${version_path}': ${error_msg:-unknown error}" + fi + # Check if response is a plain error string (not a valid package object) + # Use '"version":' to match JSON property, not just the word "version" + if ! echo "$PACKAGE_METADATA" | grep -q '"version":'; then + # Remove surrounding quotes from the error message if present + local error_msg + error_msg=$(echo "$PACKAGE_METADATA" | sed 's/^"//;s/"$//') + error "Failed to fetch version '${version_path}': ${error_msg:-unknown error}" + fi + fi + # PACKAGE_METADATA is set as a global variable, no need to echo +} + +# Get the version from package metadata +# Sets RESOLVED_VERSION global variable +get_version_from_metadata() { + # Call fetch_package_metadata to populate PACKAGE_METADATA global + # Don't use command substitution as it would swallow the exit from error() + fetch_package_metadata + RESOLVED_VERSION=$(echo "$PACKAGE_METADATA" | grep -o '"version":"[^"]*"' | head -1 | cut -d'"' -f4) + if [ -z "$RESOLVED_VERSION" ]; then + error "Failed to extract version from package metadata" + fi +} + +# Get package suffix for platform from optionalDependencies +# Sets PACKAGE_SUFFIX global variable +# Platform format: darwin-arm64, darwin-x64, linux-x64, linux-arm64, win32-x64, etc. +# Package format: @voidzero-dev/vite-plus-cli-darwin-arm64, @voidzero-dev/vite-plus-cli-linux-x64-gnu, etc. +get_package_suffix() { + local platform="$1" + local matching_package + + # Call fetch_package_metadata to populate PACKAGE_METADATA global + # Don't use command substitution as it would swallow the exit from error() + fetch_package_metadata + + # Extract optionalDependencies keys that match the platform + # Look for packages like @voidzero-dev/vite-plus-cli-{platform}[-suffix] + matching_package=$(echo "$PACKAGE_METADATA" | grep -o "\"@voidzero-dev/vite-plus-cli-${platform}[^\"]*\"" | head -1 | tr -d '"') + + if [ -z "$matching_package" ]; then + # List available platforms for helpful error message + local available_platforms + available_platforms=$(echo "$PACKAGE_METADATA" | grep -o '"@voidzero-dev/vite-plus-cli-[^"]*"' | sed 's/"@voidzero-dev\/vite-plus-cli-//g' | tr -d '"' | tr '\n' ', ' | sed 's/,$//') + error "Unsupported platform: $platform. Available platforms: $available_platforms" + fi + + # Extract suffix by removing the package prefix + PACKAGE_SUFFIX="${matching_package#@voidzero-dev/vite-plus-cli-}" +} + +# Download and extract file (silent mode - no progress bar) +download_and_extract() { + local url="$1" + local dest_dir="$2" + local strip_components="$3" + local filter="$4" + + # Download to temp file (silent mode) + local temp_file + temp_file=$(mktemp) + + # Run curl and capture exit code for error handling + set +e + curl -sL "$url" -o "$temp_file" + local exit_code=$? + set -e + + if [ $exit_code -ne 0 ]; then + rm -f "$temp_file" + print_curl_error "$exit_code" "$url" + fi + + if [ -n "$filter" ]; then + tar xzf "$temp_file" -C "$dest_dir" --strip-components="$strip_components" "$filter" 2>/dev/null || \ + tar xzf "$temp_file" -C "$dest_dir" --strip-components="$strip_components" + else + tar xzf "$temp_file" -C "$dest_dir" --strip-components="$strip_components" + fi + rm -f "$temp_file" +} + +# Add to shell profile +# Returns: 0 = path added, 1 = file not found, 2 = path already exists +add_to_path() { + local shell_config="$1" + local path_to_add="$INSTALL_DIR/current/bin" + local path_line="export PATH=\"$path_to_add:\$PATH\"" + + if [ -f "$shell_config" ]; then + # Check if already has the current/bin path + if grep -q "$path_to_add" "$shell_config" 2>/dev/null; then + return 2 + fi + echo "" >> "$shell_config" + echo "# Added by vite-plus installer" >> "$shell_config" + echo "$path_line" >> "$shell_config" + return 0 + fi + return 1 +} + +# Cleanup old versions, keeping only the most recent ones +cleanup_old_versions() { + local max_versions=5 + local versions=() + + # List version directories (exclude 'current' symlink) + for dir in "$INSTALL_DIR"/*/; do + local name + name=$(basename "$dir") + if [ "$name" != "current" ] && [ -d "$dir" ]; then + versions+=("$dir") + fi + done + + local count=${#versions[@]} + if [ "$count" -le "$max_versions" ]; then + return 0 + fi + + # Sort by creation time (oldest first) and delete excess + local sorted_versions + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS: use stat -f %B for birth time + sorted_versions=$(for v in "${versions[@]}"; do + echo "$(stat -f %B "$v") $v" + done | sort -n | head -n $((count - max_versions)) | cut -d' ' -f2-) + else + # Linux: use stat -c %W for birth time, fallback to %Y (mtime) + sorted_versions=$(for v in "${versions[@]}"; do + local btime + btime=$(stat -c %W "$v" 2>/dev/null) + if [ "$btime" = "0" ] || [ -z "$btime" ]; then + btime=$(stat -c %Y "$v") + fi + echo "$btime $v" + done | sort -n | head -n $((count - max_versions)) | cut -d' ' -f2-) + fi + + # Delete oldest versions (silently) + for old_version in $sorted_versions; do + rm -rf "$old_version" + done +} + +# Setup PATH - try ~/.local/bin symlink first, fallback to shell profile +# Returns via global variables: +# SYMLINK_CREATED - "true" if symlink was created, "false" otherwise +# SHELL_CONFIG_UPDATED - shell config file name if updated, empty otherwise +# PATH_ALREADY_CONFIGURED - "true" if PATH was already set up +setup_path() { + local local_bin="$HOME/.local/bin" + local path_to_add="$INSTALL_DIR/current/bin" + + SYMLINK_CREATED="false" + SHELL_CONFIG_UPDATED="" + PATH_ALREADY_CONFIGURED="false" + + # Check if ~/.local/bin is in PATH + if echo "$PATH" | tr ':' '\n' | grep -qx "$local_bin"; then + # Create ~/.local/bin if it doesn't exist + mkdir -p "$local_bin" + # Create symlink (force overwrite if exists) + ln -sf "$INSTALL_DIR/current/bin/vp" "$local_bin/vp" + SYMLINK_CREATED="true" + return 0 + fi + + # Fall back to adding to shell profile + local path_result=1 # 0=added, 1=failed, 2=already exists + + case "$SHELL" in + */zsh) + add_to_path "$HOME/.zshrc" + path_result=$? + [ $path_result -ne 1 ] && SHELL_CONFIG_UPDATED=".zshrc" + ;; + */bash) + add_to_path "$HOME/.bashrc" + path_result=$? + if [ $path_result -ne 1 ]; then + SHELL_CONFIG_UPDATED=".bashrc" + else + add_to_path "$HOME/.bash_profile" + path_result=$? + [ $path_result -ne 1 ] && SHELL_CONFIG_UPDATED=".bash_profile" + fi + ;; + */fish) + local fish_config="$HOME/.config/fish/config.fish" + if [ -f "$fish_config" ]; then + if grep -q "$path_to_add" "$fish_config" 2>/dev/null; then + path_result=2 + SHELL_CONFIG_UPDATED="config.fish" + else + echo "" >> "$fish_config" + echo "# Added by vite-plus installer" >> "$fish_config" + echo "set -gx PATH $path_to_add \$PATH" >> "$fish_config" + path_result=0 + SHELL_CONFIG_UPDATED="config.fish" + fi + fi + ;; + esac + + if [ $path_result -eq 2 ]; then + PATH_ALREADY_CONFIGURED="true" + fi +} + +main() { + echo "" + echo "Setting up VITE+(⚡︎)..." + echo "" + + check_requirements + + local platform + platform=$(detect_platform) + + # Fetch package metadata and resolve version + get_version_from_metadata + VITE_PLUS_VERSION="$RESOLVED_VERSION" + + # Set up version-specific directories + VERSION_DIR="$INSTALL_DIR/$VITE_PLUS_VERSION" + BIN_DIR="$VERSION_DIR/bin" + DIST_DIR="$VERSION_DIR/dist" + CURRENT_LINK="$INSTALL_DIR/current" + + # Get package suffix from optionalDependencies (dynamic lookup) + get_package_suffix "$platform" + + local package_name="@voidzero-dev/vite-plus-cli-${PACKAGE_SUFFIX}" + local binary_name="vp" + if [[ "$platform" == win32* ]]; then + binary_name="vp.exe" + fi + + # Create directories + mkdir -p "$BIN_DIR" "$DIST_DIR" + + # Download and extract native binary and .node files from platform package + local platform_url="${NPM_REGISTRY}/${package_name}/-/vite-plus-cli-${PACKAGE_SUFFIX}-${VITE_PLUS_VERSION}.tgz" + + # Create temp directory for extraction + local platform_temp_dir + platform_temp_dir=$(mktemp -d) + download_and_extract "$platform_url" "$platform_temp_dir" 1 + + # Copy binary to BIN_DIR + cp "$platform_temp_dir/$binary_name" "$BIN_DIR/" + chmod +x "$BIN_DIR/$binary_name" + + # Copy .node files to DIST_DIR (delete existing first to avoid system cache issues) + for node_file in "$platform_temp_dir"/*.node; do + rm -f "$DIST_DIR/$(basename "$node_file")" + cp "$node_file" "$DIST_DIR/" + done + rm -rf "$platform_temp_dir" + + # Download and extract JS bundle from main package + local main_url="${NPM_REGISTRY}/vite-plus-cli/-/vite-plus-cli-${VITE_PLUS_VERSION}.tgz" + + # Create temp directory for extraction + local temp_dir + temp_dir=$(mktemp -d) + download_and_extract "$main_url" "$temp_dir" 1 + + # Copy directories and files to VERSION_DIR + local items_to_copy=("dist" "templates" "rules" "AGENTS.md" "package.json") + for item in "${items_to_copy[@]}"; do + if [ -e "$temp_dir/$item" ]; then + cp -r "$temp_dir/$item" "$VERSION_DIR/" + fi + done + rm -rf "$temp_dir" + + # Remove devDependencies and optionalDependencies from package.json + # (temporary solution until deps are fully bundled) + local pkg_file="$VERSION_DIR/package.json" + awk ' + /"(devDependencies|optionalDependencies)"[[:space:]]*:[[:space:]]*\{/ { + skip = 1 + depth = 1 + next + } + skip { + for (i = 1; i <= length($0); i++) { + c = substr($0, i, 1) + if (c == "{") depth++ + else if (c == "}") depth-- + } + if (depth <= 0) skip = 0 + next + } + { print } + ' "$pkg_file" > "$pkg_file.tmp" && mv "$pkg_file.tmp" "$pkg_file" + + # Install production dependencies + (cd "$VERSION_DIR" && CI=true "$BIN_DIR/vp" install --silent) + + # Create/update current symlink (use relative path for portability) + ln -sfn "$VITE_PLUS_VERSION" "$CURRENT_LINK" + + # Cleanup old versions + cleanup_old_versions + + # Setup PATH (sets SYMLINK_CREATED, SHELL_CONFIG_UPDATED, PATH_ALREADY_CONFIGURED) + setup_path + + # Determine display location based on how PATH was configured + local display_location + if [ "$SYMLINK_CREATED" = "true" ]; then + display_location="~/.local/bin/vp" + else + # Use ~ shorthand if install dir is under HOME, otherwise show full path + local display_dir="${INSTALL_DIR/#$HOME/~}" + display_location="${display_dir}/current/bin" + fi + + # Print success message + echo "" + echo -e "${GREEN}✔${NC} VITE+(⚡︎) successfully installed!" + echo "" + echo " Version: ${VITE_PLUS_VERSION}" + echo "" + echo " Location: ${display_location}" + echo "" + echo " Next: Run vp --help to get started" + + # Show note if shell config was updated (not symlink, not already configured) + if [ "$SYMLINK_CREATED" = "false" ] && [ -n "$SHELL_CONFIG_UPDATED" ] && [ "$PATH_ALREADY_CONFIGURED" = "false" ]; then + echo "" + echo " Note: Run \`source ~/$SHELL_CONFIG_UPDATED\` or restart your terminal." + fi + + echo "" +} + +main "$@" diff --git a/packages/global/package.json b/packages/global/package.json index ae669cd707..2ab0a006d4 100644 --- a/packages/global/package.json +++ b/packages/global/package.json @@ -6,7 +6,7 @@ "url": "https://github.com/voidzero-dev/vite-plus.git" }, "bin": { - "vite": "./bin/vite" + "vp": "./bin/wrapper.js" }, "files": [ "AGENTS.md", diff --git a/packages/global/publish-native-addons.ts b/packages/global/publish-native-addons.ts index e614b98386..383001e786 100644 --- a/packages/global/publish-native-addons.ts +++ b/packages/global/publish-native-addons.ts @@ -1,4 +1,5 @@ import { execSync } from 'node:child_process'; +import { copyFileSync, existsSync, chmodSync, readFileSync, writeFileSync } from 'node:fs'; import { readdir } from 'node:fs/promises'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -8,17 +9,21 @@ import { NapiCli } from '@napi-rs/cli'; const cli = new NapiCli(); const currentDir = dirname(fileURLToPath(import.meta.url)); +const repoRoot = join(currentDir, '..', '..'); +// Create npm directories for NAPI bindings await cli.createNpmDirs({ cwd: currentDir, packageJsonPath: './package.json', }); +// Copy NAPI artifacts await cli.artifacts({ cwd: currentDir, packageJsonPath: './package.json', }); +// Pre-publish (Update package.json and copy addons into per platform packages) await cli.prePublish({ cwd: currentDir, packageJsonPath: './package.json', @@ -27,9 +32,56 @@ await cli.prePublish({ skipOptionalPublish: true, }); -const npmDir = await readdir(join(currentDir, 'npm')); -for (const file of npmDir) { - execSync(`npm publish --tag latest --access public --no-git-checks`, { +// Mapping from npm platform directory names to Rust target triples +const RUST_TARGETS: Record = { + 'darwin-arm64': 'aarch64-apple-darwin', + 'darwin-x64': 'x86_64-apple-darwin', + 'linux-arm64-gnu': 'aarch64-unknown-linux-gnu', + 'linux-x64-gnu': 'x86_64-unknown-linux-gnu', + 'win32-arm64-msvc': 'aarch64-pc-windows-msvc', + 'win32-x64-msvc': 'x86_64-pc-windows-msvc', +}; +const npmDir = join(currentDir, 'npm'); +const platformDirs = await readdir(npmDir); + +// Copy Rust binaries to each platform package and update package.json files +for (const platformDir of platformDirs) { + const rustTarget = RUST_TARGETS[platformDir]; + if (!rustTarget) { + // eslint-disable-next-line no-console + console.log(`Skipping ${platformDir}: no Rust target mapping`); + continue; + } + + const isWindows = platformDir.startsWith('win32'); + const binaryName = isWindows ? 'vp.exe' : 'vp'; + const rustBinarySource = join(repoRoot, 'target', rustTarget, 'release', binaryName); + const rustBinaryDest = join(npmDir, platformDir, binaryName); + + if (!existsSync(rustBinarySource)) { + throw new Error(`Rust binary not found at ${rustBinarySource}`); + } + + copyFileSync(rustBinarySource, rustBinaryDest); + // Make the binary executable on Unix + if (!isWindows) { + chmodSync(rustBinaryDest, 0o755); + } + + // Add binary to package.json files field + const platformPackageJsonPath = join(npmDir, platformDir, 'package.json'); + const packageJson = JSON.parse(readFileSync(platformPackageJsonPath, 'utf-8')); + packageJson.files.push(binaryName); + writeFileSync(platformPackageJsonPath, JSON.stringify(packageJson, null, 2) + '\n'); + + // eslint-disable-next-line no-console + console.log(`Copied Rust binary: ${rustBinarySource} -> ${rustBinaryDest}`); +} + +// Publish each platform package +const npmTag = process.env.NPM_TAG || 'latest'; +for (const file of platformDirs) { + execSync(`npm publish --tag ${npmTag} --access public --no-git-checks`, { cwd: join(currentDir, 'npm', file), env: process.env, stdio: 'inherit', diff --git a/packages/global/snap-tests/cli-helper-message/snap.txt b/packages/global/snap-tests/cli-helper-message/snap.txt index e740d6bfe4..4172325a04 100644 --- a/packages/global/snap-tests/cli-helper-message/snap.txt +++ b/packages/global/snap-tests/cli-helper-message/snap.txt @@ -1,7 +1,7 @@ -> vite -h # show help message +> vp -h # show help message Vite+/ -Usage: vite +Usage: vp [COMMAND] Vite+ Commands: dev Run the development server @@ -30,23 +30,23 @@ Package Manager Commands: why Show why a package is installed Options: - -h, --help Print help -V, --version Print version + -h, --help Print help -> vite -V # show version +> vp -V # show version VITE+(⚡︎) - The Unified Toolchain for the Web PACKAGE VERSIONS: vite-plus-cli: v vite-plus: Not found -> vite install -h # show install help message +> vp install -h # show install help message Install all dependencies, or add packages if package names are provided -Usage: vite install [OPTIONS] [PACKAGES]... [-- ...] +Usage: vp install [OPTIONS] [PACKAGES]... [-- ...] Arguments: - [PACKAGES]... Packages to add (if provided, acts as `vite add`) + [PACKAGES]... Packages to add (if provided, acts as `vp add`) [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: @@ -62,7 +62,7 @@ Options: --ignore-scripts Do not run lifecycle scripts --no-lockfile Don't read or generate lockfile --fix-lockfile Fix broken lockfile entries (pnpm and yarn@2+ only) - --shamefully-hoist Create flat node_modules (pnpm only) + --shamefully-hoist Create flat `node_modules` (pnpm only) --resolution-only Re-run resolution for peer dependency analysis (pnpm only) --silent Suppress output (silent mode) --filter Filter packages in monorepo (can be used multiple times) @@ -74,47 +74,34 @@ Options: -g, --global Install globally (only when adding packages) -h, --help Print help -> vite add -h # show add help message +> vp add -h # show add help message Add packages to dependencies -Usage: vite add [OPTIONS] ... [-- ...] +Usage: vp add [OPTIONS] ... [-- ...] Arguments: ... Packages to add [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: - -P, --save-prod - Save to `dependencies` (default) - -D, --save-dev - Save to `devDependencies` - --save-peer - Save to `peerDependencies` and `devDependencies` - -O, --save-optional - Save to `optionalDependencies` - -E, --save-exact - Save exact version rather than semver range (e.g., `^1.0.0` -> `1.0.0`) - --save-catalog-name - Save the new dependency to the specified catalog name. Example: `vite add vue --save-catalog-name vue3` - --save-catalog - Save the new dependency to the default catalog - --allow-build - A list of package names allowed to run postinstall - --filter - Filter packages in monorepo (can be used multiple times) - -w, --workspace-root - Add to workspace root (ignore-workspace-root-check) - --workspace - Only add if package exists in workspace (pnpm-specific) - -g, --global - Install globally - -h, --help - Print help - -> vite remove -h # show remove help message + -P, --save-prod Save to `dependencies` (default) + -D, --save-dev Save to `devDependencies` + --save-peer Save to `peerDependencies` and `devDependencies` + -O, --save-optional Save to `optionalDependencies` + -E, --save-exact Save exact version rather than semver range + --save-catalog-name Save the new dependency to the specified catalog name + --save-catalog Save the new dependency to the default catalog + --allow-build A list of package names allowed to run postinstall + --filter Filter packages in monorepo (can be used multiple times) + -w, --workspace-root Add to workspace root + --workspace Only add if package exists in workspace (pnpm-specific) + -g, --global Install globally + -h, --help Print help + +> vp remove -h # show remove help message Remove packages from dependencies -Usage: vite remove [OPTIONS] ... [-- ...] +Usage: vp remove [OPTIONS] ... [-- ...] Arguments: ... Packages to remove @@ -126,14 +113,14 @@ Options: -P, --save-prod Only remove from `dependencies` (pnpm-specific) --filter Filter packages in monorepo (can be used multiple times) -w, --workspace-root Remove from workspace root - -r, --recursive Remove recursively from all workspace packages, including workspace root + -r, --recursive Remove recursively from all workspace packages -g, --global Remove global packages -h, --help Print help -> vite update -h # show update help message +> vp update -h # show update help message Update packages to their latest versions -Usage: vite update [OPTIONS] [PACKAGES]... [-- ...] +Usage: vp update [OPTIONS] [PACKAGES]... [-- ...] Arguments: [PACKAGES]... Packages to update (optional - updates all if omitted) @@ -147,41 +134,41 @@ Options: -w, --workspace-root Include workspace root -D, --dev Update only devDependencies -P, --prod Update only dependencies (production) - -i, --interactive Interactive mode - show outdated packages and choose which to update + -i, --interactive Interactive mode --no-optional Don't update optionalDependencies --no-save Update lockfile only, don't modify package.json --workspace Only update if package exists in workspace (pnpm-specific) -h, --help Print help -> vite link -h # show link help message +> vp link -h # show link help message Link packages for local development -Usage: vite link [PACKAGE|DIR] [ARGS]... +Usage: vp link [PACKAGE|DIR] [ARGS]... Arguments: - [PACKAGE|DIR] Package name or directory to link If empty, registers current package globally + [PACKAGE|DIR] Package name or directory to link [ARGS]... Arguments to pass to package manager Options: -h, --help Print help -> vite unlink -h # show unlink help message +> vp unlink -h # show unlink help message Unlink packages -Usage: vite unlink [OPTIONS] [PACKAGE|DIR] [ARGS]... +Usage: vp unlink [OPTIONS] [PACKAGE|DIR] [ARGS]... Arguments: - [PACKAGE|DIR] Package name to unlink If empty, unlinks current package globally + [PACKAGE|DIR] Package name to unlink [ARGS]... Arguments to pass to package manager Options: - -r, --recursive Unlink in every workspace package (pnpm/yarn@2+-specific) + -r, --recursive Unlink in every workspace package -h, --help Print help -> vite dedupe -h # show dedupe help message -Deduplicate dependencies by removing older versions +> vp dedupe -h # show dedupe help message +Deduplicate dependencies -Usage: vite dedupe [OPTIONS] [-- ...] +Usage: vp dedupe [OPTIONS] [-- ...] Arguments: [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager @@ -190,33 +177,33 @@ Options: --check Check if deduplication would make changes -h, --help Print help -> vite outdated -h # show outdated help message +> vp outdated -h # show outdated help message Check for outdated packages -Usage: vite outdated [OPTIONS] [PACKAGES]... [-- ...] +Usage: vp outdated [OPTIONS] [PACKAGES]... [-- ...] Arguments: - [PACKAGES]... Package name(s) to check (supports glob patterns in pnpm) + [PACKAGES]... Package name(s) to check [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: --long Show extended information --format Output format: table (default), list, or json -r, --recursive Check recursively across all workspaces - --filter Filter packages in monorepo (can be used multiple times) + --filter Filter packages in monorepo -w, --workspace-root Include workspace root - -P, --prod Only production and optional dependencies (pnpm-specific) - -D, --dev Only dev dependencies (pnpm-specific) - --no-optional Exclude optional dependencies (pnpm-specific) - --compatible Only show compatible versions (pnpm-specific) - --sort-by Sort results by field (pnpm-specific) + -P, --prod Only production and optional dependencies + -D, --dev Only dev dependencies + --no-optional Exclude optional dependencies + --compatible Only show compatible versions + --sort-by Sort results by field -g, --global Check globally installed packages -h, --help Print help -> vite why -h # show why help message +> vp why -h # show why help message Show why a package is installed -Usage: vite why [OPTIONS] ... [-- ...] +Usage: vp why [OPTIONS] ... [-- ...] Arguments: ... Package(s) to check @@ -224,24 +211,24 @@ Arguments: Options: --json Output in JSON format - --long Show extended information (pnpm-specific) - --parseable Show parseable output (pnpm-specific) + --long Show extended information + --parseable Show parseable output -r, --recursive Check recursively across all workspaces - --filter Filter packages in monorepo (pnpm/npm-specific) - -w, --workspace-root Check in workspace root (pnpm-specific) - -P, --prod Only production dependencies (pnpm-specific) - -D, --dev Only dev dependencies (pnpm-specific) - --depth Limit tree depth (pnpm-specific) - --no-optional Exclude optional dependencies (pnpm-specific) + --filter Filter packages in monorepo + -w, --workspace-root Check in workspace root + -P, --prod Only production dependencies + -D, --dev Only dev dependencies + --depth Limit tree depth + --no-optional Exclude optional dependencies -g, --global Check globally installed packages - --exclude-peers Exclude peer dependencies (pnpm/yarn@2+-specific) - --find-by Use a finder function defined in .pnpmfile.cjs (pnpm-specific) + --exclude-peers Exclude peer dependencies + --find-by Use a finder function defined in .pnpmfile.cjs -h, --help Print help -> vite pm -h # show pm help message +> vp pm -h # show pm help message Forward a command to the package manager -Usage: vite pm +Usage: vp pm Commands: prune Remove unnecessary packages diff --git a/packages/global/snap-tests/cli-helper-message/steps.json b/packages/global/snap-tests/cli-helper-message/steps.json index ad45b63e5f..e23370f240 100644 --- a/packages/global/snap-tests/cli-helper-message/steps.json +++ b/packages/global/snap-tests/cli-helper-message/steps.json @@ -1,16 +1,16 @@ { "commands": [ - "vite -h # show help message", - "vite -V # show version", - "vite install -h # show install help message", - "vite add -h # show add help message", - "vite remove -h # show remove help message", - "vite update -h # show update help message", - "vite link -h # show link help message", - "vite unlink -h # show unlink help message", - "vite dedupe -h # show dedupe help message", - "vite outdated -h # show outdated help message", - "vite why -h # show why help message", - "vite pm -h # show pm help message" + "vp -h # show help message", + "vp -V # show version", + "vp install -h # show install help message", + "vp add -h # show add help message", + "vp remove -h # show remove help message", + "vp update -h # show update help message", + "vp link -h # show link help message", + "vp unlink -h # show unlink help message", + "vp dedupe -h # show dedupe help message", + "vp outdated -h # show outdated help message", + "vp why -h # show why help message", + "vp pm -h # show pm help message" ] } diff --git a/packages/global/snap-tests/command-add-npm10-with-workspace/snap.txt b/packages/global/snap-tests/command-add-npm10-with-workspace/snap.txt index edd0fdfcce..89666e58f4 100644 --- a/packages/global/snap-tests/command-add-npm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-add-npm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root +> vp add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root added 3 packages in ms { @@ -21,7 +21,7 @@ added 3 packages in ms "private": true } -> vite add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root +> vp add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root up to date in ms { @@ -47,7 +47,7 @@ up to date in ms "private": true } -> vite add testnpm2 test-vite-plus-install@1.0.0 --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app +> vp add testnpm2 test-vite-plus-install@1.0.0 --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app added 1 package in ms { @@ -77,7 +77,7 @@ added 1 package in ms "private": true } -> vite add @vite-plus-test/utils --workspace --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app +> vp add @vite-plus-test/utils --workspace --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app up to date in ms { @@ -108,7 +108,7 @@ up to date in ms "private": true } -> vite add testnpm2 test-vite-plus-install@1.0.0 --filter "*" -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root +> vp add testnpm2 test-vite-plus-install@1.0.0 --filter "*" -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root up to date in ms { @@ -143,7 +143,7 @@ up to date in ms } } -> vite add -E testnpm2 test-vite-plus-install@1.0.0 --filter "*" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages include workspace root +> vp add -E testnpm2 test-vite-plus-install@1.0.0 --filter "*" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages include workspace root up to date in ms { @@ -179,7 +179,7 @@ up to date in ms } } -> vite install test-vite-plus-package@1.0.0 --filter "*" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should install packages alias for add command +> vp install test-vite-plus-package@1.0.0 --filter "*" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should install packages alias for add command added 1 package in ms { diff --git a/packages/global/snap-tests/command-add-npm10-with-workspace/steps.json b/packages/global/snap-tests/command-add-npm10-with-workspace/steps.json index f65333082f..f32dcbb18f 100644 --- a/packages/global/snap-tests/command-add-npm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-add-npm10-with-workspace/steps.json @@ -4,12 +4,12 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root", - "vite add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root", - "vite add testnpm2 test-vite-plus-install@1.0.0 --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", - "vite add @vite-plus-test/utils --workspace --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", - "vite add testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root", - "vite add -E testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages include workspace root", - "vite install test-vite-plus-package@1.0.0 --filter \"*\" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should install packages alias for add command" + "vp add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root", + "vp add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root", + "vp add testnpm2 test-vite-plus-install@1.0.0 --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", + "vp add @vite-plus-test/utils --workspace --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", + "vp add testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root", + "vp add -E testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages include workspace root", + "vp install test-vite-plus-package@1.0.0 --filter \"*\" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should install packages alias for add command" ] } diff --git a/packages/global/snap-tests/command-add-npm10/snap.txt b/packages/global/snap-tests/command-add-npm10/snap.txt index ba65b7b5be..0d5606229e 100644 --- a/packages/global/snap-tests/command-add-npm10/snap.txt +++ b/packages/global/snap-tests/command-add-npm10/snap.txt @@ -1,41 +1,28 @@ -> vite add --help # should show help +> vp add --help # should show help Add packages to dependencies -Usage: vite add [OPTIONS] ... [-- ...] +Usage: vp add [OPTIONS] ... [-- ...] Arguments: ... Packages to add [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: - -P, --save-prod - Save to `dependencies` (default) - -D, --save-dev - Save to `devDependencies` - --save-peer - Save to `peerDependencies` and `devDependencies` - -O, --save-optional - Save to `optionalDependencies` - -E, --save-exact - Save exact version rather than semver range (e.g., `^1.0.0` -> `1.0.0`) - --save-catalog-name - Save the new dependency to the specified catalog name. Example: `vite add vue --save-catalog-name vue3` - --save-catalog - Save the new dependency to the default catalog - --allow-build - A list of package names allowed to run postinstall - --filter - Filter packages in monorepo (can be used multiple times) - -w, --workspace-root - Add to workspace root (ignore-workspace-root-check) - --workspace - Only add if package exists in workspace (pnpm-specific) - -g, --global - Install globally - -h, --help - Print help + -P, --save-prod Save to `dependencies` (default) + -D, --save-dev Save to `devDependencies` + --save-peer Save to `peerDependencies` and `devDependencies` + -O, --save-optional Save to `optionalDependencies` + -E, --save-exact Save exact version rather than semver range + --save-catalog-name Save the new dependency to the specified catalog name + --save-catalog Save the new dependency to the default catalog + --allow-build A list of package names allowed to run postinstall + --filter Filter packages in monorepo (can be used multiple times) + -w, --workspace-root Add to workspace root + --workspace Only add if package exists in workspace (pnpm-specific) + -g, --global Install globally + -h, --help Print help -> vite add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies +> vp add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies added 1 package in ms { @@ -47,7 +34,7 @@ added 1 package in ms } } -> vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install -- --no-audit && cat package.json # should add packages to dependencies +> vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install -- --no-audit && cat package.json # should add packages to dependencies added 1 package in ms { @@ -62,7 +49,7 @@ added 1 package in ms } } -> vite install test-vite-plus-package@1.0.0 --save-peer -- --no-audit && cat package.json # should install package alias for add +> vp install test-vite-plus-package@1.0.0 --save-peer -- --no-audit && cat package.json # should install package alias for add added 1 package in ms { @@ -80,7 +67,7 @@ added 1 package in ms } } -> vite add test-vite-plus-package-optional -O -- --no-audit && cat package.json # should add package as optional dependencies +> vp add test-vite-plus-package-optional -O -- --no-audit && cat package.json # should add package as optional dependencies added 1 package in ms { @@ -101,7 +88,7 @@ added 1 package in ms } } -> vite add test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support pass through arguments +> vp add test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support pass through arguments up to date in ms { diff --git a/packages/global/snap-tests/command-add-npm10/steps.json b/packages/global/snap-tests/command-add-npm10/steps.json index e5ca11bdcb..c3fe3a15fb 100644 --- a/packages/global/snap-tests/command-add-npm10/steps.json +++ b/packages/global/snap-tests/command-add-npm10/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add --help # should show help", - "vite add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies", - "vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install -- --no-audit && cat package.json # should add packages to dependencies", - "vite install test-vite-plus-package@1.0.0 --save-peer -- --no-audit && cat package.json # should install package alias for add", - "vite add test-vite-plus-package-optional -O -- --no-audit && cat package.json # should add package as optional dependencies", - "vite add test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support pass through arguments" + "vp add --help # should show help", + "vp add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies", + "vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install -- --no-audit && cat package.json # should add packages to dependencies", + "vp install test-vite-plus-package@1.0.0 --save-peer -- --no-audit && cat package.json # should install package alias for add", + "vp add test-vite-plus-package-optional -O -- --no-audit && cat package.json # should add package as optional dependencies", + "vp add test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-add-npm11-with-workspace/snap.txt b/packages/global/snap-tests/command-add-npm11-with-workspace/snap.txt index db4db516d3..21a091ea1e 100644 --- a/packages/global/snap-tests/command-add-npm11-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-add-npm11-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root +> vp add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root added 3 packages in ms { @@ -21,7 +21,7 @@ added 3 packages in ms "private": true } -> vite add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root +> vp add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root up to date in ms { @@ -47,7 +47,7 @@ up to date in ms "private": true } -> vite add testnpm2 test-vite-plus-install@1.0.0 --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app +> vp add testnpm2 test-vite-plus-install@1.0.0 --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app added 1 package in ms { @@ -77,7 +77,7 @@ added 1 package in ms "private": true } -> vite add @vite-plus-test/utils --workspace --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app +> vp add @vite-plus-test/utils --workspace --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app up to date in ms { @@ -108,7 +108,7 @@ up to date in ms "private": true } -> vite add testnpm2 test-vite-plus-install@1.0.0 --filter "*" -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root +> vp add testnpm2 test-vite-plus-install@1.0.0 --filter "*" -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root up to date in ms { @@ -143,7 +143,7 @@ up to date in ms } } -> vite add -E testnpm2 test-vite-plus-install@1.0.0 --filter "*" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages include workspace root +> vp add -E testnpm2 test-vite-plus-install@1.0.0 --filter "*" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages include workspace root up to date in ms { @@ -179,7 +179,7 @@ up to date in ms } } -> vite install test-vite-plus-package@1.0.0 --filter "*" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should install packages alias for add command +> vp install test-vite-plus-package@1.0.0 --filter "*" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should install packages alias for add command added 1 package in ms { diff --git a/packages/global/snap-tests/command-add-npm11-with-workspace/steps.json b/packages/global/snap-tests/command-add-npm11-with-workspace/steps.json index f65333082f..f32dcbb18f 100644 --- a/packages/global/snap-tests/command-add-npm11-with-workspace/steps.json +++ b/packages/global/snap-tests/command-add-npm11-with-workspace/steps.json @@ -4,12 +4,12 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root", - "vite add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root", - "vite add testnpm2 test-vite-plus-install@1.0.0 --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", - "vite add @vite-plus-test/utils --workspace --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", - "vite add testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root", - "vite add -E testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages include workspace root", - "vite install test-vite-plus-package@1.0.0 --filter \"*\" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should install packages alias for add command" + "vp add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root", + "vp add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root", + "vp add testnpm2 test-vite-plus-install@1.0.0 --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", + "vp add @vite-plus-test/utils --workspace --filter app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", + "vp add testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root", + "vp add -E testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages include workspace root", + "vp install test-vite-plus-package@1.0.0 --filter \"*\" --workspace-root -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should install packages alias for add command" ] } diff --git a/packages/global/snap-tests/command-add-npm11/snap.txt b/packages/global/snap-tests/command-add-npm11/snap.txt index d207295dbb..c6ac9aa028 100644 --- a/packages/global/snap-tests/command-add-npm11/snap.txt +++ b/packages/global/snap-tests/command-add-npm11/snap.txt @@ -1,41 +1,28 @@ -> vite add --help # should show help +> vp add --help # should show help Add packages to dependencies -Usage: vite add [OPTIONS] ... [-- ...] +Usage: vp add [OPTIONS] ... [-- ...] Arguments: ... Packages to add [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: - -P, --save-prod - Save to `dependencies` (default) - -D, --save-dev - Save to `devDependencies` - --save-peer - Save to `peerDependencies` and `devDependencies` - -O, --save-optional - Save to `optionalDependencies` - -E, --save-exact - Save exact version rather than semver range (e.g., `^1.0.0` -> `1.0.0`) - --save-catalog-name - Save the new dependency to the specified catalog name. Example: `vite add vue --save-catalog-name vue3` - --save-catalog - Save the new dependency to the default catalog - --allow-build - A list of package names allowed to run postinstall - --filter - Filter packages in monorepo (can be used multiple times) - -w, --workspace-root - Add to workspace root (ignore-workspace-root-check) - --workspace - Only add if package exists in workspace (pnpm-specific) - -g, --global - Install globally - -h, --help - Print help + -P, --save-prod Save to `dependencies` (default) + -D, --save-dev Save to `devDependencies` + --save-peer Save to `peerDependencies` and `devDependencies` + -O, --save-optional Save to `optionalDependencies` + -E, --save-exact Save exact version rather than semver range + --save-catalog-name Save the new dependency to the specified catalog name + --save-catalog Save the new dependency to the default catalog + --allow-build A list of package names allowed to run postinstall + --filter Filter packages in monorepo (can be used multiple times) + -w, --workspace-root Add to workspace root + --workspace Only add if package exists in workspace (pnpm-specific) + -g, --global Install globally + -h, --help Print help -> vite add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies +> vp add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies added 1 package in ms { @@ -47,7 +34,7 @@ added 1 package in ms } } -> vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install -- --no-audit && cat package.json # should add packages to dependencies +> vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install -- --no-audit && cat package.json # should add packages to dependencies added 1 package in ms { @@ -62,7 +49,7 @@ added 1 package in ms } } -> vite install test-vite-plus-package@1.0.0 --save-peer -- --no-audit && cat package.json # should install package alias for add +> vp install test-vite-plus-package@1.0.0 --save-peer -- --no-audit && cat package.json # should install package alias for add added 1 package in ms { @@ -80,7 +67,7 @@ added 1 package in ms } } -> vite add test-vite-plus-package-optional -O -- --no-audit && cat package.json # should add package as optional dependencies +> vp add test-vite-plus-package-optional -O -- --no-audit && cat package.json # should add package as optional dependencies added 1 package in ms { @@ -101,7 +88,7 @@ added 1 package in ms } } -> vite add test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support pass through arguments +> vp add test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support pass through arguments up to date in ms { diff --git a/packages/global/snap-tests/command-add-npm11/steps.json b/packages/global/snap-tests/command-add-npm11/steps.json index e5ca11bdcb..c3fe3a15fb 100644 --- a/packages/global/snap-tests/command-add-npm11/steps.json +++ b/packages/global/snap-tests/command-add-npm11/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add --help # should show help", - "vite add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies", - "vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install -- --no-audit && cat package.json # should add packages to dependencies", - "vite install test-vite-plus-package@1.0.0 --save-peer -- --no-audit && cat package.json # should install package alias for add", - "vite add test-vite-plus-package-optional -O -- --no-audit && cat package.json # should add package as optional dependencies", - "vite add test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support pass through arguments" + "vp add --help # should show help", + "vp add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies", + "vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install -- --no-audit && cat package.json # should add packages to dependencies", + "vp install test-vite-plus-package@1.0.0 --save-peer -- --no-audit && cat package.json # should install package alias for add", + "vp add test-vite-plus-package-optional -O -- --no-audit && cat package.json # should add package as optional dependencies", + "vp add test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-add-pnpm10-with-workspace/snap.txt b/packages/global/snap-tests/command-add-pnpm10-with-workspace/snap.txt index 0c8ace52b2..d46b6376a4 100644 --- a/packages/global/snap-tests/command-add-pnpm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-add-pnpm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite add testnpm2 -D -w && cat package.json # should add package to workspace root +> vp add testnpm2 -D -w && cat package.json # should add package to workspace root Progress: resolved , reused , downloaded , added , done devDependencies: @@ -16,7 +16,7 @@ Done in ms using pnpm v } } -> vite add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root +> vp add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root Progress: resolved , reused , downloaded , added , done dependencies: @@ -36,7 +36,7 @@ Done in ms using pnpm v } } -> vite add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app +> vp add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app Progress: resolved , reused , downloaded , added , done . | +1 + Done in ms using pnpm v @@ -64,7 +64,7 @@ Done in ms using pnpm v "private": true } -> vite add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app +> vp add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v { @@ -92,7 +92,7 @@ Done in ms using pnpm v "private": true } -> vite add -E testnpm2 test-vite-plus-install --filter "*" && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root +> vp add -E testnpm2 test-vite-plus-install --filter "*" && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v { @@ -124,7 +124,7 @@ Done in ms using pnpm v } } -> vite install test-vite-plus-package@1.0.0 --filter "*" --workspace-root --save-catalog && cat package.json packages/app/package.json packages/utils/package.json pnpm-workspace.yaml # should install packages alias for add command +> vp install test-vite-plus-package@1.0.0 --filter "*" --workspace-root --save-catalog && cat package.json packages/app/package.json packages/utils/package.json pnpm-workspace.yaml # should install packages alias for add command . | +1 + Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v @@ -165,7 +165,7 @@ packages: catalog: test-vite-plus-package: -> vite add --filter app test-vite-plus-package-optional --save-catalog-name v1 && cat packages/app/package.json pnpm-workspace.yaml # should add with save-catalog-name +> vp add --filter app test-vite-plus-package-optional --save-catalog-name v1 && cat packages/app/package.json pnpm-workspace.yaml # should add with save-catalog-name Progress: resolved , reused , downloaded , added , done . | +1 + Done in ms using pnpm v @@ -189,7 +189,7 @@ catalogs: v1: test-vite-plus-package-optional: ^1.0.0 -> vite add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog-name v2 && cat packages/utils/package.json pnpm-workspace.yaml # should add other with save-catalog-name +> vp add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog-name v2 && cat packages/utils/package.json pnpm-workspace.yaml # should add other with save-catalog-name Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v { diff --git a/packages/global/snap-tests/command-add-pnpm10-with-workspace/steps.json b/packages/global/snap-tests/command-add-pnpm10-with-workspace/steps.json index 3a2636e2cd..c5a43049e9 100644 --- a/packages/global/snap-tests/command-add-pnpm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-add-pnpm10-with-workspace/steps.json @@ -4,13 +4,13 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add testnpm2 -D -w && cat package.json # should add package to workspace root", - "vite add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root", - "vite add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", - "vite add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", - "vite add -E testnpm2 test-vite-plus-install --filter \"*\" && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root", - "vite install test-vite-plus-package@1.0.0 --filter \"*\" --workspace-root --save-catalog && cat package.json packages/app/package.json packages/utils/package.json pnpm-workspace.yaml # should install packages alias for add command", - "vite add --filter app test-vite-plus-package-optional --save-catalog-name v1 && cat packages/app/package.json pnpm-workspace.yaml # should add with save-catalog-name", - "vite add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog-name v2 && cat packages/utils/package.json pnpm-workspace.yaml # should add other with save-catalog-name" + "vp add testnpm2 -D -w && cat package.json # should add package to workspace root", + "vp add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root", + "vp add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", + "vp add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", + "vp add -E testnpm2 test-vite-plus-install --filter \"*\" && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root", + "vp install test-vite-plus-package@1.0.0 --filter \"*\" --workspace-root --save-catalog && cat package.json packages/app/package.json packages/utils/package.json pnpm-workspace.yaml # should install packages alias for add command", + "vp add --filter app test-vite-plus-package-optional --save-catalog-name v1 && cat packages/app/package.json pnpm-workspace.yaml # should add with save-catalog-name", + "vp add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog-name v2 && cat packages/utils/package.json pnpm-workspace.yaml # should add other with save-catalog-name" ] } diff --git a/packages/global/snap-tests/command-add-pnpm10/snap.txt b/packages/global/snap-tests/command-add-pnpm10/snap.txt index 865d2ebb5f..52d2b4d517 100644 --- a/packages/global/snap-tests/command-add-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-add-pnpm10/snap.txt @@ -1,49 +1,36 @@ -> vite add --help # should show help +> vp add --help # should show help Add packages to dependencies -Usage: vite add [OPTIONS] ... [-- ...] +Usage: vp add [OPTIONS] ... [-- ...] Arguments: ... Packages to add [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: - -P, --save-prod - Save to `dependencies` (default) - -D, --save-dev - Save to `devDependencies` - --save-peer - Save to `peerDependencies` and `devDependencies` - -O, --save-optional - Save to `optionalDependencies` - -E, --save-exact - Save exact version rather than semver range (e.g., `^1.0.0` -> `1.0.0`) - --save-catalog-name - Save the new dependency to the specified catalog name. Example: `vite add vue --save-catalog-name vue3` - --save-catalog - Save the new dependency to the default catalog - --allow-build - A list of package names allowed to run postinstall - --filter - Filter packages in monorepo (can be used multiple times) - -w, --workspace-root - Add to workspace root (ignore-workspace-root-check) - --workspace - Only add if package exists in workspace (pnpm-specific) - -g, --global - Install globally - -h, --help - Print help - -[2]> vite add # should error because no packages specified + -P, --save-prod Save to `dependencies` (default) + -D, --save-dev Save to `devDependencies` + --save-peer Save to `peerDependencies` and `devDependencies` + -O, --save-optional Save to `optionalDependencies` + -E, --save-exact Save exact version rather than semver range + --save-catalog-name Save the new dependency to the specified catalog name + --save-catalog Save the new dependency to the default catalog + --allow-build A list of package names allowed to run postinstall + --filter Filter packages in monorepo (can be used multiple times) + -w, --workspace-root Add to workspace root + --workspace Only add if package exists in workspace (pnpm-specific) + -g, --global Install globally + -h, --help Print help + +[2]> vp add # should error because no packages specified error: the following required arguments were not provided: ... -Usage: vite add ... [-- ...] +Usage: vp add ... [-- ...] For more information, try '--help'. -> vite add testnpm2 -D -- --loglevel=verbose --verbose && cat package.json # should add package as dev dependencies +> vp add testnpm2 -D -- --loglevel=verbose --verbose && cat package.json # should add package as dev dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -61,7 +48,7 @@ Done in ms using pnpm v } } -> vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install && cat package.json # should add packages to dependencies +> vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install && cat package.json # should add packages to dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -82,7 +69,7 @@ Done in ms using pnpm v } } -> vite install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add +> vp install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add Packages: + + Progress: resolved , reused , downloaded , added , done @@ -110,7 +97,7 @@ Done in ms using pnpm v } } -> vite add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies +> vp add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -138,7 +125,7 @@ Done in ms using pnpm v } } -> vite add test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support pass through arguments +> vp add test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support pass through arguments { "name": "command-add-pnpm10", "version": "1.0.0", diff --git a/packages/global/snap-tests/command-add-pnpm10/steps.json b/packages/global/snap-tests/command-add-pnpm10/steps.json index 9a2204481b..f57443c957 100644 --- a/packages/global/snap-tests/command-add-pnpm10/steps.json +++ b/packages/global/snap-tests/command-add-pnpm10/steps.json @@ -4,12 +4,12 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add --help # should show help", - "vite add # should error because no packages specified", - "vite add testnpm2 -D -- --loglevel=verbose --verbose && cat package.json # should add package as dev dependencies", - "vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install && cat package.json # should add packages to dependencies", - "vite install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add", - "vite add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies", - "vite add test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support pass through arguments" + "vp add --help # should show help", + "vp add # should error because no packages specified", + "vp add testnpm2 -D -- --loglevel=verbose --verbose && cat package.json # should add package as dev dependencies", + "vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install && cat package.json # should add packages to dependencies", + "vp install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add", + "vp add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies", + "vp add test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-add-pnpm9-with-workspace/snap.txt b/packages/global/snap-tests/command-add-pnpm9-with-workspace/snap.txt index 144483d57b..3a8b2665e0 100644 --- a/packages/global/snap-tests/command-add-pnpm9-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-add-pnpm9-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite add testnpm2 -D -w && cat package.json # should add package to workspace root +> vp add testnpm2 -D -w && cat package.json # should add package to workspace root Progress: resolved , reused , downloaded , added , done devDependencies: @@ -16,10 +16,10 @@ Done in ms using pnpm v } } -[1]> vite add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root +[1]> vp add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root  ERR_PNPM_ADDING_TO_ROOT  Running this command will add the dependency to the workspace root, which might not be what you want - if you really meant it, make it explicit by running this command again with the -w flag (or --workspace-root). If you don't want to see this warning anymore, you may set the ignore-workspace-root-check setting to true. -> vite add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app +> vp add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app . |  WARN  `node_modules` is present. Lockfile only installation will make it out-of-date Progress: resolved , reused , downloaded , added , done . | +1 + @@ -45,7 +45,7 @@ Done in ms using pnpm v "private": true } -> vite add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app +> vp add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app . |  WARN  `node_modules` is present. Lockfile only installation will make it out-of-date Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v @@ -71,7 +71,7 @@ Done in ms using pnpm v "private": true } -> vite add -E testnpm2 test-vite-plus-install --filter "*" && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root +> vp add -E testnpm2 test-vite-plus-install --filter "*" && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v { @@ -100,7 +100,7 @@ Done in ms using pnpm v } } -> vite install test-vite-plus-package@1.0.0 --filter "*" --workspace-root && cat package.json packages/app/package.json packages/utils/package.json pnpm-workspace.yaml # should install packages alias for add command +> vp install test-vite-plus-package@1.0.0 --filter "*" --workspace-root && cat package.json packages/app/package.json packages/utils/package.json pnpm-workspace.yaml # should install packages alias for add command . | +1 + Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v @@ -137,12 +137,12 @@ Done in ms using pnpm v packages: - packages/* -[1]> vite add --filter app test-vite-plus-package-optional --save-catalog-name v1 # should error because save-catalog-name is not supported at pnpm@9 +[1]> vp add --filter app test-vite-plus-package-optional --save-catalog-name v1 # should error because save-catalog-name is not supported at pnpm@9  ERROR  Unknown option: 'save-catalog-name' Did you mean 'save-optional'? Use "--config.unknown=value" to force an unknown option. For help, run: pnpm help add -[1]> vite add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog v2 # should error because save-catalog is not supported at pnpm@9 - ERROR  Unknown option: 'save-catalog' -Did you mean 'save-exact', or 'save-prod'? Use "--config.unknown=value" to force an unknown option. +[1]> vp add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog v2 # should error because save-catalog is not supported at pnpm@9 + ERROR  Unknown option: 'save-catalog-name' +Did you mean 'save-optional'? Use "--config.unknown=value" to force an unknown option. For help, run: pnpm help add diff --git a/packages/global/snap-tests/command-add-pnpm9-with-workspace/steps.json b/packages/global/snap-tests/command-add-pnpm9-with-workspace/steps.json index bd0e5cc6e1..17bcee22b3 100644 --- a/packages/global/snap-tests/command-add-pnpm9-with-workspace/steps.json +++ b/packages/global/snap-tests/command-add-pnpm9-with-workspace/steps.json @@ -1,16 +1,17 @@ { "ignoredPlatforms": ["win32"], "env": { - "VITE_DISABLE_AUTO_INSTALL": "1" + "VITE_DISABLE_AUTO_INSTALL": "1", + "NODE_OPTIONS": "--no-deprecation" }, "commands": [ - "vite add testnpm2 -D -w && cat package.json # should add package to workspace root", - "vite add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root", - "vite add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", - "vite add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", - "vite add -E testnpm2 test-vite-plus-install --filter \"*\" && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root", - "vite install test-vite-plus-package@1.0.0 --filter \"*\" --workspace-root && cat package.json packages/app/package.json packages/utils/package.json pnpm-workspace.yaml # should install packages alias for add command", - "vite add --filter app test-vite-plus-package-optional --save-catalog-name v1 # should error because save-catalog-name is not supported at pnpm@9", - "vite add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog v2 # should error because save-catalog is not supported at pnpm@9" + "vp add testnpm2 -D -w && cat package.json # should add package to workspace root", + "vp add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root", + "vp add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", + "vp add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", + "vp add -E testnpm2 test-vite-plus-install --filter \"*\" && cat package.json packages/app/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages except workspace root", + "vp install test-vite-plus-package@1.0.0 --filter \"*\" --workspace-root && cat package.json packages/app/package.json packages/utils/package.json pnpm-workspace.yaml # should install packages alias for add command", + "vp add --filter app test-vite-plus-package-optional --save-catalog-name v1 # should error because save-catalog-name is not supported at pnpm@9", + "vp add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog v2 # should error because save-catalog is not supported at pnpm@9" ] } diff --git a/packages/global/snap-tests/command-add-pnpm9/snap.txt b/packages/global/snap-tests/command-add-pnpm9/snap.txt index 65db245d83..af331c41c5 100644 --- a/packages/global/snap-tests/command-add-pnpm9/snap.txt +++ b/packages/global/snap-tests/command-add-pnpm9/snap.txt @@ -1,41 +1,28 @@ -> vite add --help # should show help +> vp add --help # should show help Add packages to dependencies -Usage: vite add [OPTIONS] ... [-- ...] +Usage: vp add [OPTIONS] ... [-- ...] Arguments: ... Packages to add [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: - -P, --save-prod - Save to `dependencies` (default) - -D, --save-dev - Save to `devDependencies` - --save-peer - Save to `peerDependencies` and `devDependencies` - -O, --save-optional - Save to `optionalDependencies` - -E, --save-exact - Save exact version rather than semver range (e.g., `^1.0.0` -> `1.0.0`) - --save-catalog-name - Save the new dependency to the specified catalog name. Example: `vite add vue --save-catalog-name vue3` - --save-catalog - Save the new dependency to the default catalog - --allow-build - A list of package names allowed to run postinstall - --filter - Filter packages in monorepo (can be used multiple times) - -w, --workspace-root - Add to workspace root (ignore-workspace-root-check) - --workspace - Only add if package exists in workspace (pnpm-specific) - -g, --global - Install globally - -h, --help - Print help - -> vite add testnpm2 -D && cat package.json # should add package as dev dependencies + -P, --save-prod Save to `dependencies` (default) + -D, --save-dev Save to `devDependencies` + --save-peer Save to `peerDependencies` and `devDependencies` + -O, --save-optional Save to `optionalDependencies` + -E, --save-exact Save exact version rather than semver range + --save-catalog-name Save the new dependency to the specified catalog name + --save-catalog Save the new dependency to the default catalog + --allow-build A list of package names allowed to run postinstall + --filter Filter packages in monorepo (can be used multiple times) + -w, --workspace-root Add to workspace root + --workspace Only add if package exists in workspace (pnpm-specific) + -g, --global Install globally + -h, --help Print help + +> vp add testnpm2 -D && cat package.json # should add package as dev dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -53,7 +40,7 @@ Done in ms using pnpm v } } -> vite add testnpm2 test-vite-plus-install && cat package.json # should add packages to dependencies +> vp add testnpm2 test-vite-plus-install && cat package.json # should add packages to dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -74,11 +61,11 @@ Done in ms using pnpm v } } -[1]> vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install # should error because allow-build is not supported at pnpm@9 +[1]> vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install # should error because allow-build is not supported at pnpm@9  ERROR  Unknown option: 'allow-build' For help, run: pnpm help add -> vite install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add +> vp install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add Packages: + + Progress: resolved , reused , downloaded , added , done @@ -106,7 +93,7 @@ Done in ms using pnpm v } } -> vite add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies +> vp add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -134,7 +121,7 @@ Done in ms using pnpm v } } -> vite add test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support pass through arguments +> vp add test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support pass through arguments { "name": "command-add-pnpm9", "version": "1.0.0", diff --git a/packages/global/snap-tests/command-add-pnpm9/steps.json b/packages/global/snap-tests/command-add-pnpm9/steps.json index dda2656d50..6cbd91a32a 100644 --- a/packages/global/snap-tests/command-add-pnpm9/steps.json +++ b/packages/global/snap-tests/command-add-pnpm9/steps.json @@ -1,15 +1,16 @@ { "ignoredPlatforms": ["win32"], "env": { - "VITE_DISABLE_AUTO_INSTALL": "1" + "VITE_DISABLE_AUTO_INSTALL": "1", + "NODE_OPTIONS": "--no-deprecation" }, "commands": [ - "vite add --help # should show help", - "vite add testnpm2 -D && cat package.json # should add package as dev dependencies", - "vite add testnpm2 test-vite-plus-install && cat package.json # should add packages to dependencies", - "vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install # should error because allow-build is not supported at pnpm@9", - "vite install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add", - "vite add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies", - "vite add test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support pass through arguments" + "vp add --help # should show help", + "vp add testnpm2 -D && cat package.json # should add package as dev dependencies", + "vp add testnpm2 test-vite-plus-install && cat package.json # should add packages to dependencies", + "vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install # should error because allow-build is not supported at pnpm@9", + "vp install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add", + "vp add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies", + "vp add test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-add-yarn4-with-workspace/snap.txt b/packages/global/snap-tests/command-add-yarn4-with-workspace/snap.txt index 5fefeff3a4..1c4c59ab5f 100644 --- a/packages/global/snap-tests/command-add-yarn4-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-add-yarn4-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite add testnpm2 -D -w && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root +> vp add testnpm2 -D -w && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + testnpm2@npm:1.0.1 @@ -28,7 +28,7 @@ "private": true } -> vite add @vite-plus-test/utils --workspace -w && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root +> vp add @vite-plus-test/utils --workspace -w && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -60,7 +60,7 @@ "private": true } -> vite add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app +> vp add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + test-vite-plus-install@npm:1.0.0 @@ -98,7 +98,7 @@ Done in ms ms "private": true } -> vite add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app +> vp add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -136,7 +136,7 @@ Done in ms ms "private": true } -> vite add testnpm2 test-vite-plus-install@1.0.0 --filter "*" --filter @vite-plus-test/utils && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages and workspace root +> vp add testnpm2 test-vite-plus-install@1.0.0 --filter "*" --filter @vite-plus-test/utils && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages and workspace root ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -210,7 +210,7 @@ Done in ms ms } } -> vite install -O test-vite-plus-package-optional --filter "*" && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should install packages alias for add command +> vp install -O test-vite-plus-package-optional --filter "*" && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should install packages alias for add command ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + test-vite-plus-package-optional@npm:1.0.0 diff --git a/packages/global/snap-tests/command-add-yarn4-with-workspace/steps.json b/packages/global/snap-tests/command-add-yarn4-with-workspace/steps.json index dd1db27710..33b3e3295b 100644 --- a/packages/global/snap-tests/command-add-yarn4-with-workspace/steps.json +++ b/packages/global/snap-tests/command-add-yarn4-with-workspace/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add testnpm2 -D -w && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root", - "vite add @vite-plus-test/utils --workspace -w && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root", - "vite add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", - "vite add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", - "vite add testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" --filter @vite-plus-test/utils && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages and workspace root", - "vite install -O test-vite-plus-package-optional --filter \"*\" && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should install packages alias for add command" + "vp add testnpm2 -D -w && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root", + "vp add @vite-plus-test/utils --workspace -w && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root", + "vp add testnpm2 test-vite-plus-install@1.0.0 --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add packages to packages/app", + "vp add @vite-plus-test/utils --workspace --filter app && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to packages/app", + "vp add testnpm2 test-vite-plus-install@1.0.0 --filter \"*\" --filter @vite-plus-test/utils && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should add testnpm2 test-vite-plus-install to all packages and workspace root", + "vp install -O test-vite-plus-package-optional --filter \"*\" && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should install packages alias for add command" ] } diff --git a/packages/global/snap-tests/command-add-yarn4/snap.txt b/packages/global/snap-tests/command-add-yarn4/snap.txt index 4b6d380572..4eed4f55c0 100644 --- a/packages/global/snap-tests/command-add-yarn4/snap.txt +++ b/packages/global/snap-tests/command-add-yarn4/snap.txt @@ -1,41 +1,28 @@ -> vite add --help # should show help +> vp add --help # should show help Add packages to dependencies -Usage: vite add [OPTIONS] ... [-- ...] +Usage: vp add [OPTIONS] ... [-- ...] Arguments: ... Packages to add [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: - -P, --save-prod - Save to `dependencies` (default) - -D, --save-dev - Save to `devDependencies` - --save-peer - Save to `peerDependencies` and `devDependencies` - -O, --save-optional - Save to `optionalDependencies` - -E, --save-exact - Save exact version rather than semver range (e.g., `^1.0.0` -> `1.0.0`) - --save-catalog-name - Save the new dependency to the specified catalog name. Example: `vite add vue --save-catalog-name vue3` - --save-catalog - Save the new dependency to the default catalog - --allow-build - A list of package names allowed to run postinstall - --filter - Filter packages in monorepo (can be used multiple times) - -w, --workspace-root - Add to workspace root (ignore-workspace-root-check) - --workspace - Only add if package exists in workspace (pnpm-specific) - -g, --global - Install globally - -h, --help - Print help + -P, --save-prod Save to `dependencies` (default) + -D, --save-dev Save to `devDependencies` + --save-peer Save to `peerDependencies` and `devDependencies` + -O, --save-optional Save to `optionalDependencies` + -E, --save-exact Save exact version rather than semver range + --save-catalog-name Save the new dependency to the specified catalog name + --save-catalog Save the new dependency to the default catalog + --allow-build A list of package names allowed to run postinstall + --filter Filter packages in monorepo (can be used multiple times) + -w, --workspace-root Add to workspace root + --workspace Only add if package exists in workspace (pnpm-specific) + -g, --global Install globally + -h, --help Print help -> vite add testnpm2 -D && cat package.json # should add package as dev dependencies +> vp add testnpm2 -D && cat package.json # should add package as dev dependencies ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + testnpm2@npm:1.0.1 @@ -54,7 +41,7 @@ Options: } } -> vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install && cat package.json # should add packages to dependencies +> vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install && cat package.json # should add packages to dependencies ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + test-vite-plus-install@npm:1.0.0 @@ -76,7 +63,7 @@ Options: } } -> vite install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add +> vp install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -100,7 +87,7 @@ Options: } } -> vite add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies +> vp add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + test-vite-plus-package-optional@npm:1.0.0 @@ -128,7 +115,7 @@ Options: } } -> vite add test-vite-plus-package-optional -- --tilde && cat package.json # support pass through arguments +> vp add test-vite-plus-package-optional -- --tilde && cat package.json # support pass through arguments ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed diff --git a/packages/global/snap-tests/command-add-yarn4/steps.json b/packages/global/snap-tests/command-add-yarn4/steps.json index fd443593f6..4a7b03f71f 100644 --- a/packages/global/snap-tests/command-add-yarn4/steps.json +++ b/packages/global/snap-tests/command-add-yarn4/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add --help # should show help", - "vite add testnpm2 -D && cat package.json # should add package as dev dependencies", - "vite add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install && cat package.json # should add packages to dependencies", - "vite install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add", - "vite add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies", - "vite add test-vite-plus-package-optional -- --tilde && cat package.json # support pass through arguments" + "vp add --help # should show help", + "vp add testnpm2 -D && cat package.json # should add package as dev dependencies", + "vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install && cat package.json # should add packages to dependencies", + "vp install test-vite-plus-package@1.0.0 --save-peer && cat package.json # should install package alias for add", + "vp add test-vite-plus-package-optional -O && cat package.json # should add package as optional dependencies", + "vp add test-vite-plus-package-optional -- --tilde && cat package.json # support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-cache-npm10/snap.txt b/packages/global/snap-tests/command-cache-npm10/snap.txt index 8761207b7a..2391920ce8 100644 --- a/packages/global/snap-tests/command-cache-npm10/snap.txt +++ b/packages/global/snap-tests/command-cache-npm10/snap.txt @@ -1,5 +1,5 @@ -> vite pm cache dir # should show cache directory (uses npm config get cache) +> vp pm cache dir # should show cache directory (uses npm config get cache) /.npm -> vite pm cache path # should show cache path (alias for dir, uses npm config get cache) +> vp pm cache path # should show cache path (alias for dir, uses npm config get cache) /.npm diff --git a/packages/global/snap-tests/command-cache-npm10/steps.json b/packages/global/snap-tests/command-cache-npm10/steps.json index c02975f44f..0d528cd197 100644 --- a/packages/global/snap-tests/command-cache-npm10/steps.json +++ b/packages/global/snap-tests/command-cache-npm10/steps.json @@ -4,7 +4,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm cache dir # should show cache directory (uses npm config get cache)", - "vite pm cache path # should show cache path (alias for dir, uses npm config get cache)" + "vp pm cache dir # should show cache directory (uses npm config get cache)", + "vp pm cache path # should show cache path (alias for dir, uses npm config get cache)" ] } diff --git a/packages/global/snap-tests/command-cache-pnpm10/snap.txt b/packages/global/snap-tests/command-cache-pnpm10/snap.txt index dc6c4f71a8..79d1a698aa 100644 --- a/packages/global/snap-tests/command-cache-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-cache-pnpm10/snap.txt @@ -1,14 +1,14 @@ -> vite pm cache --help # should show help +> vp pm cache --help # should show help Manage package cache -Usage: vite pm cache [-- ...] +Usage: vp pm cache [-- ...] Arguments: Subcommand: dir, path, clean - [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager + [PASS_THROUGH_ARGS]... Additional arguments Options: -h, --help Print help -> vite pm cache dir > /dev/null # should show cache directory (uses pnpm store path) -> vite pm cache path > /dev/null # should show cache path (alias for dir, uses pnpm store path) \ No newline at end of file +> vp pm cache dir > /dev/null # should show cache directory (uses pnpm store path) +> vp pm cache path > /dev/null # should show cache path (alias for dir, uses pnpm store path) \ No newline at end of file diff --git a/packages/global/snap-tests/command-cache-pnpm10/steps.json b/packages/global/snap-tests/command-cache-pnpm10/steps.json index d2336d2e13..8416e89dc1 100644 --- a/packages/global/snap-tests/command-cache-pnpm10/steps.json +++ b/packages/global/snap-tests/command-cache-pnpm10/steps.json @@ -3,8 +3,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm cache --help # should show help", - "vite pm cache dir > /dev/null # should show cache directory (uses pnpm store path)", - "vite pm cache path > /dev/null # should show cache path (alias for dir, uses pnpm store path)" + "vp pm cache --help # should show help", + "vp pm cache dir > /dev/null # should show cache directory (uses pnpm store path)", + "vp pm cache path > /dev/null # should show cache path (alias for dir, uses pnpm store path)" ] } diff --git a/packages/global/snap-tests/command-cache-yarn4/snap.txt b/packages/global/snap-tests/command-cache-yarn4/snap.txt index 717d420314..35109064ee 100644 --- a/packages/global/snap-tests/command-cache-yarn4/snap.txt +++ b/packages/global/snap-tests/command-cache-yarn4/snap.txt @@ -1,5 +1,5 @@ -> vite pm cache dir # should show cache directory (uses yarn config get cacheFolder) +> vp pm cache dir # should show cache directory (uses yarn config get cacheFolder) /.yarn/berry/cache -> vite pm cache path # should show cache path (alias for dir, uses yarn config get cacheFolder) +> vp pm cache path # should show cache path (alias for dir, uses yarn config get cacheFolder) /.yarn/berry/cache diff --git a/packages/global/snap-tests/command-cache-yarn4/steps.json b/packages/global/snap-tests/command-cache-yarn4/steps.json index 7bd28f554f..f7aa5f1bf2 100644 --- a/packages/global/snap-tests/command-cache-yarn4/steps.json +++ b/packages/global/snap-tests/command-cache-yarn4/steps.json @@ -4,7 +4,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm cache dir # should show cache directory (uses yarn config get cacheFolder)", - "vite pm cache path # should show cache path (alias for dir, uses yarn config get cacheFolder)" + "vp pm cache dir # should show cache directory (uses yarn config get cacheFolder)", + "vp pm cache path # should show cache path (alias for dir, uses yarn config get cacheFolder)" ] } diff --git a/packages/global/snap-tests/command-config-npm10/snap.txt b/packages/global/snap-tests/command-config-npm10/snap.txt index 2e94c18aa1..aa28f0b3ec 100644 --- a/packages/global/snap-tests/command-config-npm10/snap.txt +++ b/packages/global/snap-tests/command-config-npm10/snap.txt @@ -1,6 +1,6 @@ > # vite pm config set vite-plus-pm-config-test-key test-value --location project # npm set will check valid keys start from npm v9, see https://github.com/npm/cli/issues/5852 -> vite pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope +> vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope test-value -> vite pm config delete vite-plus-pm-config-test-key --location project && cat .npmrc # should delete config key from project scope +> vp pm config delete vite-plus-pm-config-test-key --location project && cat .npmrc # should delete config key from project scope foo=bar diff --git a/packages/global/snap-tests/command-config-npm10/steps.json b/packages/global/snap-tests/command-config-npm10/steps.json index 263b9dca39..e7e9b6ff01 100644 --- a/packages/global/snap-tests/command-config-npm10/steps.json +++ b/packages/global/snap-tests/command-config-npm10/steps.json @@ -4,7 +4,7 @@ }, "commands": [ "# vite pm config set vite-plus-pm-config-test-key test-value --location project # npm set will check valid keys start from npm v9, see https://github.com/npm/cli/issues/5852", - "vite pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope", - "vite pm config delete vite-plus-pm-config-test-key --location project && cat .npmrc # should delete config key from project scope" + "vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope", + "vp pm config delete vite-plus-pm-config-test-key --location project && cat .npmrc # should delete config key from project scope" ] } diff --git a/packages/global/snap-tests/command-config-pnpm10/snap.txt b/packages/global/snap-tests/command-config-pnpm10/snap.txt index 7bb1bd234c..da623e9ba0 100644 --- a/packages/global/snap-tests/command-config-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-config-pnpm10/snap.txt @@ -1,7 +1,7 @@ -> vite pm config --help # should show help +> vp pm config --help # should show help Manage package manager configuration -Usage: vite pm config +Usage: vp pm config Commands: list List all configuration @@ -12,9 +12,9 @@ Commands: Options: -h, --help Print help -> vite pm config list --location project > /dev/null # should list all project configuration -> vite pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope -> vite pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope +> vp pm config list --location project > /dev/null # should list all project configuration +> vp pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope +> vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope test-value -> vite pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope \ No newline at end of file +> vp pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope \ No newline at end of file diff --git a/packages/global/snap-tests/command-config-pnpm10/steps.json b/packages/global/snap-tests/command-config-pnpm10/steps.json index 5e8c21e7e2..32ef67bbdc 100644 --- a/packages/global/snap-tests/command-config-pnpm10/steps.json +++ b/packages/global/snap-tests/command-config-pnpm10/steps.json @@ -3,10 +3,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm config --help # should show help", - "vite pm config list --location project > /dev/null # should list all project configuration", - "vite pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope", - "vite pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope", - "vite pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope" + "vp pm config --help # should show help", + "vp pm config list --location project > /dev/null # should list all project configuration", + "vp pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope", + "vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope", + "vp pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope" ] } diff --git a/packages/global/snap-tests/command-config-yarn1/snap.txt b/packages/global/snap-tests/command-config-yarn1/snap.txt index 2f091c0e4d..aed5837cf1 100644 --- a/packages/global/snap-tests/command-config-yarn1/snap.txt +++ b/packages/global/snap-tests/command-config-yarn1/snap.txt @@ -1,14 +1,14 @@ -> vite pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope (shows warning for yarn@1) +> vp pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope (shows warning for yarn@1) Warning: yarn@1 does not support --location, ignoring flag yarn config v success Set "vite-plus-pm-config-test-key" to "test-value". Done in ms. -> vite pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope (shows warning for yarn@1) +> vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope (shows warning for yarn@1) Warning: yarn@1 does not support --location, ignoring flag test-value -> vite pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope (shows warning for yarn@1) +> vp pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope (shows warning for yarn@1) Warning: yarn@1 does not support --location, ignoring flag yarn config v success Deleted "vite-plus-pm-config-test-key". diff --git a/packages/global/snap-tests/command-config-yarn1/steps.json b/packages/global/snap-tests/command-config-yarn1/steps.json index 15e2573d82..6f99d468b4 100644 --- a/packages/global/snap-tests/command-config-yarn1/steps.json +++ b/packages/global/snap-tests/command-config-yarn1/steps.json @@ -1,10 +1,11 @@ { "env": { - "VITE_DISABLE_AUTO_INSTALL": "1" + "VITE_DISABLE_AUTO_INSTALL": "1", + "NODE_OPTIONS": "--no-deprecation" }, "commands": [ - "vite pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope (shows warning for yarn@1)", - "vite pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope (shows warning for yarn@1)", - "vite pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope (shows warning for yarn@1)" + "vp pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope (shows warning for yarn@1)", + "vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope (shows warning for yarn@1)", + "vp pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope (shows warning for yarn@1)" ] } diff --git a/packages/global/snap-tests/command-config-yarn4/snap.txt b/packages/global/snap-tests/command-config-yarn4/snap.txt index 332a284239..4653857497 100644 --- a/packages/global/snap-tests/command-config-yarn4/snap.txt +++ b/packages/global/snap-tests/command-config-yarn4/snap.txt @@ -1,14 +1,14 @@ -[1]> vite pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope +[1]> vp pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope Usage Error: Couldn't find a configuration settings named "vite-plus-pm-config-test-key" $ yarn config set [--json] [-H,--home] -[1]> vite pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope +[1]> vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope Usage Error: Couldn't find a configuration settings named "vite-plus-pm-config-test-key" $ yarn config get [--why] [--json] [--no-redacted] -[1]> vite pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope (uses yarn config unset) +[1]> vp pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope (uses yarn config unset) Usage Error: Couldn't find a configuration settings named "vite-plus-pm-config-test-key" $ yarn config unset [-H,--home] diff --git a/packages/global/snap-tests/command-config-yarn4/steps.json b/packages/global/snap-tests/command-config-yarn4/steps.json index 5836a71610..931f5fc357 100644 --- a/packages/global/snap-tests/command-config-yarn4/steps.json +++ b/packages/global/snap-tests/command-config-yarn4/steps.json @@ -3,8 +3,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope", - "vite pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope", - "vite pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope (uses yarn config unset)" + "vp pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope", + "vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope", + "vp pm config delete vite-plus-pm-config-test-key --location project # should delete config key from project scope (uses yarn config unset)" ] } diff --git a/packages/global/snap-tests/command-dedupe-npm10/snap.txt b/packages/global/snap-tests/command-dedupe-npm10/snap.txt index 16718ecce5..50951e6ac9 100644 --- a/packages/global/snap-tests/command-dedupe-npm10/snap.txt +++ b/packages/global/snap-tests/command-dedupe-npm10/snap.txt @@ -1,4 +1,4 @@ -> vite dedupe && cat package.json # should dedupe dependencies +> vp dedupe && cat package.json # should dedupe dependencies added 3 packages in ms { @@ -16,7 +16,7 @@ added 3 packages in ms "packageManager": "npm@" } -> vite dedupe --check && cat package.json # should check if deduplication would make changes +> vp dedupe --check && cat package.json # should check if deduplication would make changes up to date in ms { @@ -34,7 +34,7 @@ up to date in ms "packageManager": "npm@" } -> vite ddp -- --loglevel=warn && cat package.json # support pass through arguments +> vp ddp -- --loglevel=warn && cat package.json # support pass through arguments up to date in ms { diff --git a/packages/global/snap-tests/command-dedupe-npm10/steps.json b/packages/global/snap-tests/command-dedupe-npm10/steps.json index cec8c0287d..2c7915485a 100644 --- a/packages/global/snap-tests/command-dedupe-npm10/steps.json +++ b/packages/global/snap-tests/command-dedupe-npm10/steps.json @@ -3,8 +3,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite dedupe && cat package.json # should dedupe dependencies", - "vite dedupe --check && cat package.json # should check if deduplication would make changes", - "vite ddp -- --loglevel=warn && cat package.json # support pass through arguments" + "vp dedupe && cat package.json # should dedupe dependencies", + "vp dedupe --check && cat package.json # should check if deduplication would make changes", + "vp ddp -- --loglevel=warn && cat package.json # support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-dedupe-pnpm10/snap.txt b/packages/global/snap-tests/command-dedupe-pnpm10/snap.txt index caa05cb0de..9e2a1006a1 100644 --- a/packages/global/snap-tests/command-dedupe-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-dedupe-pnpm10/snap.txt @@ -1,7 +1,7 @@ -> vite dedupe --help # should show help -Deduplicate dependencies by removing older versions +> vp dedupe --help # should show help +Deduplicate dependencies -Usage: vite dedupe [OPTIONS] [-- ...] +Usage: vp dedupe [OPTIONS] [-- ...] Arguments: [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager @@ -10,7 +10,7 @@ Options: --check Check if deduplication would make changes -h, --help Print help -> vite dedupe && cat package.json # should dedupe dependencies +> vp dedupe && cat package.json # should dedupe dependencies Already up to date Progress: resolved , reused , downloaded , added , done @@ -38,7 +38,7 @@ devDependencies: "packageManager": "pnpm@" } -> vite dedupe --check && cat package.json # should check if deduplication would make changes +> vp dedupe --check && cat package.json # should check if deduplication would make changes Progress: resolved , reused , downloaded , added , done { @@ -56,7 +56,7 @@ Progress: resolved , reused , downloaded , added < "packageManager": "pnpm@" } -> vite ddp -- --loglevel=warn && cat package.json # support pass through arguments +> vp ddp -- --loglevel=warn && cat package.json # support pass through arguments { "name": "command-dedupe-pnpm10", "version": "1.0.0", @@ -72,7 +72,7 @@ Progress: resolved , reused , downloaded , added < "packageManager": "pnpm@" } -[1]> json-edit package.json '_.dependencies = {}' && cat package.json && vite dedupe --check # should check fails because no dependencies +[1]> json-edit package.json '_.dependencies = {}' && cat package.json && vp dedupe --check # should check fails because no dependencies { "name": "command-dedupe-pnpm10", "version": "1.0.0", @@ -100,7 +100,7 @@ Packages Run pnpm dedupe to apply the changes above. -> vite dedupe && cat package.json && vite dedupe --check # should dedupe fix the change by removing the dependencies +> vp dedupe && cat package.json && vp dedupe --check # should dedupe fix the change by removing the dependencies Packages: -1 - Progress: resolved , reused , downloaded , added , done diff --git a/packages/global/snap-tests/command-dedupe-pnpm10/steps.json b/packages/global/snap-tests/command-dedupe-pnpm10/steps.json index 00dab921bc..50ba3da36b 100644 --- a/packages/global/snap-tests/command-dedupe-pnpm10/steps.json +++ b/packages/global/snap-tests/command-dedupe-pnpm10/steps.json @@ -3,11 +3,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite dedupe --help # should show help", - "vite dedupe && cat package.json # should dedupe dependencies", - "vite dedupe --check && cat package.json # should check if deduplication would make changes", - "vite ddp -- --loglevel=warn && cat package.json # support pass through arguments", - "json-edit package.json '_.dependencies = {}' && cat package.json && vite dedupe --check # should check fails because no dependencies", - "vite dedupe && cat package.json && vite dedupe --check # should dedupe fix the change by removing the dependencies" + "vp dedupe --help # should show help", + "vp dedupe && cat package.json # should dedupe dependencies", + "vp dedupe --check && cat package.json # should check if deduplication would make changes", + "vp ddp -- --loglevel=warn && cat package.json # support pass through arguments", + "json-edit package.json '_.dependencies = {}' && cat package.json && vp dedupe --check # should check fails because no dependencies", + "vp dedupe && cat package.json && vp dedupe --check # should dedupe fix the change by removing the dependencies" ] } diff --git a/packages/global/snap-tests/command-dedupe-yarn4/snap.txt b/packages/global/snap-tests/command-dedupe-yarn4/snap.txt index c3708b6fba..b75a86fad1 100644 --- a/packages/global/snap-tests/command-dedupe-yarn4/snap.txt +++ b/packages/global/snap-tests/command-dedupe-yarn4/snap.txt @@ -1,4 +1,4 @@ -> vite dedupe && cat package.json # should dedupe dependencies +> vp dedupe && cat package.json # should dedupe dependencies ➤ YN0000: ┌ Deduplication step ➤ YN0000: │ No packages can be deduped using the highest strategy ➤ YN0000: └ Completed @@ -26,7 +26,7 @@ "packageManager": "yarn@" } -> vite dedupe --check && cat package.json # should check if deduplication would make changes +> vp dedupe --check && cat package.json # should check if deduplication would make changes ➤ YN0000: ┌ Deduplication step ➤ YN0000: │ No packages can be deduped using the highest strategy ➤ YN0000: └ Completed @@ -45,7 +45,7 @@ "packageManager": "yarn@" } -> vite ddp -- --json && cat package.json # support pass through arguments +> vp ddp -- --json && cat package.json # support pass through arguments { "name": "command-dedupe-yarn4", "version": "1.0.0", diff --git a/packages/global/snap-tests/command-dedupe-yarn4/steps.json b/packages/global/snap-tests/command-dedupe-yarn4/steps.json index 0ee57e2f76..9a9232745b 100644 --- a/packages/global/snap-tests/command-dedupe-yarn4/steps.json +++ b/packages/global/snap-tests/command-dedupe-yarn4/steps.json @@ -3,8 +3,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite dedupe && cat package.json # should dedupe dependencies", - "vite dedupe --check && cat package.json # should check if deduplication would make changes", - "vite ddp -- --json && cat package.json # support pass through arguments" + "vp dedupe && cat package.json # should dedupe dependencies", + "vp dedupe --check && cat package.json # should check if deduplication would make changes", + "vp ddp -- --json && cat package.json # support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-dlx-npm10/snap.txt b/packages/global/snap-tests/command-dlx-npm10/snap.txt index ca0bb2ed11..4568ef020a 100644 --- a/packages/global/snap-tests/command-dlx-npm10/snap.txt +++ b/packages/global/snap-tests/command-dlx-npm10/snap.txt @@ -1,18 +1,18 @@ -> vite dlx --help # should show help message -Execute a package binary without installing it as a dependency +> vp dlx --help # should show help message +Execute a package binary without installing it -Usage: vite dlx [OPTIONS] ... +Usage: vp dlx [OPTIONS] ... Arguments: - ... Package to execute (with optional @version) and arguments + ... Package to execute and arguments Options: - -p, --package Package(s) to install before running the command (can be used multiple times) - -c, --shell-mode Execute the command within a shell environment + -p, --package Package(s) to install before running + -c, --shell-mode Execute within a shell environment -s, --silent Suppress all output except the executed command's output -h, --help Print help -> vite dlx -s cowsay hello # should run cowsay with npm exec +> vp dlx -s cowsay hello # should run cowsay with npm exec _______ < hello > ------- @@ -22,7 +22,7 @@ Options: ||----w | || || -> vite dlx -s cowsay@1.6.0 hello # should run specific version +> vp dlx -s cowsay@1.6.0 hello # should run specific version _______ < hello > ------- @@ -32,7 +32,7 @@ Options: ||----w | || || -> vite dlx -s -p cowsay -p lolcatjs cowsay hello # should run with multiple packages +> vp dlx -s -p cowsay -p lolcatjs cowsay hello # should run with multiple packages _______ < hello > ------- @@ -42,7 +42,7 @@ Options: ||----w | || || -> vite dlx -s -p cowsay -c "echo hello-from-shell | cowsay" # should run shell mode command +> vp dlx -s -p cowsay -c "echo hello-from-shell | cowsay" # should run shell mode command __________________ < hello-from-shell > ------------------ diff --git a/packages/global/snap-tests/command-dlx-npm10/steps.json b/packages/global/snap-tests/command-dlx-npm10/steps.json index 99e5710308..d263433453 100644 --- a/packages/global/snap-tests/command-dlx-npm10/steps.json +++ b/packages/global/snap-tests/command-dlx-npm10/steps.json @@ -4,10 +4,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite dlx --help # should show help message", - "vite dlx -s cowsay hello # should run cowsay with npm exec", - "vite dlx -s cowsay@1.6.0 hello # should run specific version", - "vite dlx -s -p cowsay -p lolcatjs cowsay hello # should run with multiple packages", - "vite dlx -s -p cowsay -c \"echo hello-from-shell | cowsay\" # should run shell mode command" + "vp dlx --help # should show help message", + "vp dlx -s cowsay hello # should run cowsay with npm exec", + "vp dlx -s cowsay@1.6.0 hello # should run specific version", + "vp dlx -s -p cowsay -p lolcatjs cowsay hello # should run with multiple packages", + "vp dlx -s -p cowsay -c \"echo hello-from-shell | cowsay\" # should run shell mode command" ] } diff --git a/packages/global/snap-tests/command-dlx-pnpm10/snap.txt b/packages/global/snap-tests/command-dlx-pnpm10/snap.txt index 67c1c29373..fbfd1700bf 100644 --- a/packages/global/snap-tests/command-dlx-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-dlx-pnpm10/snap.txt @@ -1,18 +1,18 @@ -> vite dlx --help # should show help message -Execute a package binary without installing it as a dependency +> vp dlx --help # should show help message +Execute a package binary without installing it -Usage: vite dlx [OPTIONS] ... +Usage: vp dlx [OPTIONS] ... Arguments: - ... Package to execute (with optional @version) and arguments + ... Package to execute and arguments Options: - -p, --package Package(s) to install before running the command (can be used multiple times) - -c, --shell-mode Execute the command within a shell environment + -p, --package Package(s) to install before running + -c, --shell-mode Execute within a shell environment -s, --silent Suppress all output except the executed command's output -h, --help Print help -> vite dlx -s cowsay hello # should run cowsay with pnpm dlx +> vp dlx -s cowsay hello # should run cowsay with pnpm dlx _______ < hello > ------- @@ -22,7 +22,7 @@ Options: ||----w | || || -> vite dlx -s cowsay@1.6.0 hello # should run specific version +> vp dlx -s cowsay@1.6.0 hello # should run specific version _______ < hello > ------- diff --git a/packages/global/snap-tests/command-dlx-pnpm10/steps.json b/packages/global/snap-tests/command-dlx-pnpm10/steps.json index 3748563e58..9225e7836a 100644 --- a/packages/global/snap-tests/command-dlx-pnpm10/steps.json +++ b/packages/global/snap-tests/command-dlx-pnpm10/steps.json @@ -3,8 +3,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite dlx --help # should show help message", - "vite dlx -s cowsay hello # should run cowsay with pnpm dlx", - "vite dlx -s cowsay@1.6.0 hello # should run specific version" + "vp dlx --help # should show help message", + "vp dlx -s cowsay hello # should run cowsay with pnpm dlx", + "vp dlx -s cowsay@1.6.0 hello # should run specific version" ] } diff --git a/packages/global/snap-tests/command-dlx-yarn4/snap.txt b/packages/global/snap-tests/command-dlx-yarn4/snap.txt index 7bbcc7ede3..93fd8205d3 100644 --- a/packages/global/snap-tests/command-dlx-yarn4/snap.txt +++ b/packages/global/snap-tests/command-dlx-yarn4/snap.txt @@ -1,18 +1,18 @@ -> vite dlx --help # should show help message -Execute a package binary without installing it as a dependency +> vp dlx --help # should show help message +Execute a package binary without installing it -Usage: vite dlx [OPTIONS] ... +Usage: vp dlx [OPTIONS] ... Arguments: - ... Package to execute (with optional @version) and arguments + ... Package to execute and arguments Options: - -p, --package Package(s) to install before running the command (can be used multiple times) - -c, --shell-mode Execute the command within a shell environment + -p, --package Package(s) to install before running + -c, --shell-mode Execute within a shell environment -s, --silent Suppress all output except the executed command's output -h, --help Print help -> vite dlx -s cowsay hello # should run cowsay with yarn dlx +> vp dlx -s cowsay hello # should run cowsay with yarn dlx _______ < hello > ------- @@ -22,7 +22,7 @@ Options: ||----w | || || -> vite dlx -s cowsay@1.6.0 hello # should run specific version +> vp dlx -s cowsay@1.6.0 hello # should run specific version _______ < hello > ------- diff --git a/packages/global/snap-tests/command-dlx-yarn4/steps.json b/packages/global/snap-tests/command-dlx-yarn4/steps.json index 076319ca46..8bfd7930fb 100644 --- a/packages/global/snap-tests/command-dlx-yarn4/steps.json +++ b/packages/global/snap-tests/command-dlx-yarn4/steps.json @@ -3,8 +3,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite dlx --help # should show help message", - "vite dlx -s cowsay hello # should run cowsay with yarn dlx", - "vite dlx -s cowsay@1.6.0 hello # should run specific version" + "vp dlx --help # should show help message", + "vp dlx -s cowsay hello # should run cowsay with yarn dlx", + "vp dlx -s cowsay@1.6.0 hello # should run specific version" ] } diff --git a/packages/global/snap-tests/command-install-bug-31/snap.txt b/packages/global/snap-tests/command-install-bug-31/snap.txt index 7f12c44f70..39cf478c1a 100644 --- a/packages/global/snap-tests/command-install-bug-31/snap.txt +++ b/packages/global/snap-tests/command-install-bug-31/snap.txt @@ -1,11 +1,11 @@ -> vite install --no-frozen-lockfile --silent # install dependencies work +> vp install --no-frozen-lockfile --silent # install dependencies work > mkdir -p packages/sub-project && echo '{"name": "sub-project", "dependencies": { "testnpm2": "1.0.0" }}' > packages/sub-project/package.json # create sub project and package.json -> vite install --no-frozen-lockfile --silent # install again should work and without cache +> vp install --no-frozen-lockfile --silent # install again should work and without cache > ls packages/sub-project/node_modules/testnpm2/package.json # check testnpm2 is installed packages/sub-project/node_modules/testnpm2/package.json > mkdir -p others/other && echo '{"name": "other", "dependencies": { "testnpm2": "1.0.0" }}' > others/other/package.json # create non workspace project -> vite install --no-frozen-lockfile --silent # should install cache hit +> vp install --no-frozen-lockfile --silent # should install cache hit > test -d others/other/node_modules/testnpm2 && echo 'Error: directory exists.' >&2 && exit 1 || true # check testnpm2 is not installed > rm -rf packages/sub-project # remove sub project -> vite install --no-frozen-lockfile --silent | sed -E 's|packages.*|packages*|' # should install again without cache \ No newline at end of file +> vp install --no-frozen-lockfile --silent | sed -E 's|packages.*|packages*|' # should install again without cache \ No newline at end of file diff --git a/packages/global/snap-tests/command-install-bug-31/steps.json b/packages/global/snap-tests/command-install-bug-31/steps.json index 52ff987cc8..0b360cba49 100644 --- a/packages/global/snap-tests/command-install-bug-31/steps.json +++ b/packages/global/snap-tests/command-install-bug-31/steps.json @@ -3,14 +3,14 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install --no-frozen-lockfile --silent # install dependencies work", + "vp install --no-frozen-lockfile --silent # install dependencies work", "mkdir -p packages/sub-project && echo '{\"name\": \"sub-project\", \"dependencies\": { \"testnpm2\": \"1.0.0\" }}' > packages/sub-project/package.json # create sub project and package.json", - "vite install --no-frozen-lockfile --silent # install again should work and without cache", + "vp install --no-frozen-lockfile --silent # install again should work and without cache", "ls packages/sub-project/node_modules/testnpm2/package.json # check testnpm2 is installed", "mkdir -p others/other && echo '{\"name\": \"other\", \"dependencies\": { \"testnpm2\": \"1.0.0\" }}' > others/other/package.json # create non workspace project", - "vite install --no-frozen-lockfile --silent # should install cache hit", + "vp install --no-frozen-lockfile --silent # should install cache hit", "test -d others/other/node_modules/testnpm2 && echo 'Error: directory exists.' >&2 && exit 1 || true # check testnpm2 is not installed", "rm -rf packages/sub-project # remove sub project", - "vite install --no-frozen-lockfile --silent | sed -E 's|packages.*|packages*|' # should install again without cache" + "vp install --no-frozen-lockfile --silent | sed -E 's|packages.*|packages*|' # should install again without cache" ] } diff --git a/packages/global/snap-tests/command-link-npm10/snap.txt b/packages/global/snap-tests/command-link-npm10/snap.txt index a757fc518e..de73d57d0c 100644 --- a/packages/global/snap-tests/command-link-npm10/snap.txt +++ b/packages/global/snap-tests/command-link-npm10/snap.txt @@ -1,5 +1,5 @@ > mkdir -p ../test-lib-npm && echo '{"name": "test-lib-npm", "version": "1.0.0"}' > ../test-lib-npm/package.json # create test library -> vite link ../test-lib-npm && cat package.json # should link local directory +> vp link ../test-lib-npm && cat package.json # should link local directory added 1 package in ms { @@ -8,7 +8,7 @@ added 1 package in ms "packageManager": "npm@" } -> vite ln ../test-lib-npm && cat package.json # should work with ln alias +> vp ln ../test-lib-npm && cat package.json # should work with ln alias up to date in ms { @@ -17,7 +17,7 @@ up to date in ms "packageManager": "npm@" } -> vite unlink test-lib-npm && cat package.json # cleanup temp states +> vp unlink test-lib-npm && cat package.json # cleanup temp states removed 1 package in ms { diff --git a/packages/global/snap-tests/command-link-npm10/steps.json b/packages/global/snap-tests/command-link-npm10/steps.json index 1cacb8106a..140a720583 100644 --- a/packages/global/snap-tests/command-link-npm10/steps.json +++ b/packages/global/snap-tests/command-link-npm10/steps.json @@ -5,8 +5,8 @@ }, "commands": [ "mkdir -p ../test-lib-npm && echo '{\"name\": \"test-lib-npm\", \"version\": \"1.0.0\"}' > ../test-lib-npm/package.json # create test library", - "vite link ../test-lib-npm && cat package.json # should link local directory", - "vite ln ../test-lib-npm && cat package.json # should work with ln alias", - "vite unlink test-lib-npm && cat package.json # cleanup temp states" + "vp link ../test-lib-npm && cat package.json # should link local directory", + "vp ln ../test-lib-npm && cat package.json # should work with ln alias", + "vp unlink test-lib-npm && cat package.json # cleanup temp states" ] } diff --git a/packages/global/snap-tests/command-link-pnpm10/snap.txt b/packages/global/snap-tests/command-link-pnpm10/snap.txt index 4581faa45f..fa9f090a6a 100644 --- a/packages/global/snap-tests/command-link-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-link-pnpm10/snap.txt @@ -1,16 +1,16 @@ -> vite link -h # should show help message +> vp link -h # should show help message Link packages for local development -Usage: vite link [PACKAGE|DIR] [ARGS]... +Usage: vp link [PACKAGE|DIR] [ARGS]... Arguments: - [PACKAGE|DIR] Package name or directory to link If empty, registers current package globally + [PACKAGE|DIR] Package name or directory to link [ARGS]... Arguments to pass to package manager Options: -h, --help Print help -> vite install # install initial dependencies +> vp install # install initial dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -21,7 +21,7 @@ dependencies: Done in ms using pnpm v > mkdir -p ../test-lib-pnpm && echo '{"name": "testnpm2", "version": "1.0.0"}' > ../test-lib-pnpm/package.json # create test library -> vite link ../test-lib-pnpm && cat package.json pnpm-lock.yaml # should link local directory +> vp link ../test-lib-pnpm && cat package.json pnpm-lock.yaml # should link local directory Packages: -1 - @@ -54,7 +54,7 @@ importers: specifier: link:../test-lib-pnpm version: link:../test-lib-pnpm -> vite ln ../test-lib-pnpm && cat package.json pnpm-lock.yaml # should work with ln alias +> vp ln ../test-lib-pnpm && cat package.json pnpm-lock.yaml # should work with ln alias Lockfile is up to date, resolution step is skipped { @@ -82,30 +82,10 @@ importers: specifier: link:../test-lib-pnpm version: link:../test-lib-pnpm -> vite unlink ../test-lib-pnpm && vite unlink testnpm2 && cat package.json pnpm-lock.yaml # should unlink the package +[2]> vp unlink ../test-lib-pnpm && vite unlink testnpm2 && cat package.json pnpm-lock.yaml # should unlink the package Nothing to unlink -Nothing to unlink -{ - "name": "command-link-pnpm10", - "version": "1.0.0", - "dependencies": { - "testnpm2": "*" - }, - "packageManager": "pnpm@" -} -lockfileVersion: '9.0' +error: unrecognized subcommand 'unlink' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -overrides: - testnpm2: link:../test-lib-pnpm - -importers: +Usage: vite - .: - dependencies: - testnpm2: - specifier: link:../test-lib-pnpm - version: link:../test-lib-pnpm +For more information, try '--help'. diff --git a/packages/global/snap-tests/command-link-pnpm10/steps.json b/packages/global/snap-tests/command-link-pnpm10/steps.json index 6c67333be6..59de4421ab 100644 --- a/packages/global/snap-tests/command-link-pnpm10/steps.json +++ b/packages/global/snap-tests/command-link-pnpm10/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite link -h # should show help message", - "vite install # install initial dependencies", + "vp link -h # should show help message", + "vp install # install initial dependencies", "mkdir -p ../test-lib-pnpm && echo '{\"name\": \"testnpm2\", \"version\": \"1.0.0\"}' > ../test-lib-pnpm/package.json # create test library", - "vite link ../test-lib-pnpm && cat package.json pnpm-lock.yaml # should link local directory", - "vite ln ../test-lib-pnpm && cat package.json pnpm-lock.yaml # should work with ln alias", - "vite unlink ../test-lib-pnpm && vite unlink testnpm2 && cat package.json pnpm-lock.yaml # should unlink the package" + "vp link ../test-lib-pnpm && cat package.json pnpm-lock.yaml # should link local directory", + "vp ln ../test-lib-pnpm && cat package.json pnpm-lock.yaml # should work with ln alias", + "vp unlink ../test-lib-pnpm && vite unlink testnpm2 && cat package.json pnpm-lock.yaml # should unlink the package" ] } diff --git a/packages/global/snap-tests/command-link-yarn4/snap.txt b/packages/global/snap-tests/command-link-yarn4/snap.txt index 5b8d2d28a5..5f6780dc1c 100644 --- a/packages/global/snap-tests/command-link-yarn4/snap.txt +++ b/packages/global/snap-tests/command-link-yarn4/snap.txt @@ -1,5 +1,5 @@ > mkdir -p ../test-lib-yarn && echo '{"name": "test-lib-yarn", "version": "1.0.0"}' > ../test-lib-yarn/package.json # create test library -> vite link ../test-lib-yarn && cat package.json # should link local directory +> vp link ../test-lib-yarn && cat package.json # should link local directory ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -17,7 +17,7 @@ } } -> vite ln ../test-lib-yarn && cat package.json # should work with ln alias +> vp ln ../test-lib-yarn && cat package.json # should work with ln alias ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -35,7 +35,7 @@ } } -> vite unlink test-lib-yarn && cat package.json # cleanup temp states +> vp unlink test-lib-yarn && cat package.json # cleanup temp states ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed diff --git a/packages/global/snap-tests/command-link-yarn4/steps.json b/packages/global/snap-tests/command-link-yarn4/steps.json index 260f2efccf..a50277d390 100644 --- a/packages/global/snap-tests/command-link-yarn4/steps.json +++ b/packages/global/snap-tests/command-link-yarn4/steps.json @@ -5,8 +5,8 @@ }, "commands": [ "mkdir -p ../test-lib-yarn && echo '{\"name\": \"test-lib-yarn\", \"version\": \"1.0.0\"}' > ../test-lib-yarn/package.json # create test library", - "vite link ../test-lib-yarn && cat package.json # should link local directory", - "vite ln ../test-lib-yarn && cat package.json # should work with ln alias", - "vite unlink test-lib-yarn && cat package.json # cleanup temp states" + "vp link ../test-lib-yarn && cat package.json # should link local directory", + "vp ln ../test-lib-yarn && cat package.json # should work with ln alias", + "vp unlink test-lib-yarn && cat package.json # cleanup temp states" ] } diff --git a/packages/global/snap-tests/command-list-npm10-with-workspace/snap.txt b/packages/global/snap-tests/command-list-npm10-with-workspace/snap.txt index a0ac76cd12..0cc9cbec9c 100644 --- a/packages/global/snap-tests/command-list-npm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-list-npm10-with-workspace/snap.txt @@ -1,8 +1,8 @@ -> vite install # should install packages first +> vp install # should install packages first added 4 packages in ms -> vite pm list --json # should list current workspace root dependencies +> vp pm list --json # should list current workspace root dependencies { "version": "1.0.0", "name": "command-list-npm10-with-workspace", @@ -37,7 +37,7 @@ added 4 packages in ms } } -> vite pm list --recursive --json # should list all packages in workspace (uses --workspaces) +> vp pm list --recursive --json # should list all packages in workspace (uses --workspaces) { "version": "1.0.0", "name": "command-list-npm10-with-workspace", @@ -72,7 +72,7 @@ added 4 packages in ms } } -> vite pm list --filter app --json # should list specific workspace package (uses --workspace app) +> vp pm list --filter app --json # should list specific workspace package (uses --workspace app) { "version": "1.0.0", "name": "command-list-npm10-with-workspace", @@ -97,7 +97,7 @@ added 4 packages in ms } } -> vite pm list --filter app --filter @vite-plus-test/utils --json # should list multiple workspace packages +> vp pm list --filter app --filter @vite-plus-test/utils --json # should list multiple workspace packages { "version": "1.0.0", "name": "command-list-npm10-with-workspace", @@ -132,7 +132,7 @@ added 4 packages in ms } } -> vite pm list --recursive --depth 0 --json # should list workspace packages with depth limit +> vp pm list --recursive --depth 0 --json # should list workspace packages with depth limit { "version": "1.0.0", "name": "command-list-npm10-with-workspace", diff --git a/packages/global/snap-tests/command-list-npm10-with-workspace/steps.json b/packages/global/snap-tests/command-list-npm10-with-workspace/steps.json index 23af3536f2..6dfbfa29b8 100644 --- a/packages/global/snap-tests/command-list-npm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-list-npm10-with-workspace/steps.json @@ -3,11 +3,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install # should install packages first", - "vite pm list --json # should list current workspace root dependencies", - "vite pm list --recursive --json # should list all packages in workspace (uses --workspaces)", - "vite pm list --filter app --json # should list specific workspace package (uses --workspace app)", - "vite pm list --filter app --filter @vite-plus-test/utils --json # should list multiple workspace packages", - "vite pm list --recursive --depth 0 --json # should list workspace packages with depth limit" + "vp install # should install packages first", + "vp pm list --json # should list current workspace root dependencies", + "vp pm list --recursive --json # should list all packages in workspace (uses --workspaces)", + "vp pm list --filter app --json # should list specific workspace package (uses --workspace app)", + "vp pm list --filter app --filter @vite-plus-test/utils --json # should list multiple workspace packages", + "vp pm list --recursive --depth 0 --json # should list workspace packages with depth limit" ] } diff --git a/packages/global/snap-tests/command-list-npm10/snap.txt b/packages/global/snap-tests/command-list-npm10/snap.txt index 92e56d0eeb..17c4ca12c6 100644 --- a/packages/global/snap-tests/command-list-npm10/snap.txt +++ b/packages/global/snap-tests/command-list-npm10/snap.txt @@ -1,8 +1,8 @@ -> vite install # should install packages first +> vp install # should install packages first added 3 packages in ms -> vite pm list --json # should list installed packages +> vp pm list --json # should list installed packages { "version": "1.0.0", "name": "command-list-npm10", @@ -25,7 +25,7 @@ added 3 packages in ms } } -> vite pm list testnpm2 --json # should list specific package +> vp pm list testnpm2 --json # should list specific package { "version": "1.0.0", "name": "command-list-npm10", @@ -38,7 +38,7 @@ added 3 packages in ms } } -> vite pm list --depth 0 --json # should list packages with depth limit +> vp pm list --depth 0 --json # should list packages with depth limit { "version": "1.0.0", "name": "command-list-npm10", @@ -61,7 +61,7 @@ added 3 packages in ms } } -> vite pm list --long --json # should list packages with extended info +> vp pm list --long --json # should list packages with extended info { "version": "1.0.0", "name": "command-list-npm10", @@ -126,7 +126,7 @@ added 3 packages in ms } } -> vite pm list --parseable --json # should list packages in parseable format +> vp pm list --parseable --json # should list packages in parseable format { "version": "1.0.0", "name": "command-list-npm10", @@ -149,7 +149,7 @@ added 3 packages in ms } } -> vite pm list --prod --json # should list production dependencies only (uses --include prod --include peer) +> vp pm list --prod --json # should list production dependencies only (uses --include prod --include peer) { "version": "1.0.0", "name": "command-list-npm10", @@ -172,7 +172,7 @@ added 3 packages in ms } } -> vite pm list --dev --json # should list development dependencies only (uses --include dev) +> vp pm list --dev --json # should list development dependencies only (uses --include dev) { "version": "1.0.0", "name": "command-list-npm10", @@ -195,7 +195,7 @@ added 3 packages in ms } } -> vite pm list --no-optional --json # should exclude optional dependencies (uses --omit optional) +> vp pm list --no-optional --json # should exclude optional dependencies (uses --omit optional) { "version": "1.0.0", "name": "command-list-npm10", @@ -218,7 +218,7 @@ added 3 packages in ms } } -> vite pm list --exclude-peers --json # should exclude peer dependencies (uses --omit peer) +> vp pm list --exclude-peers --json # should exclude peer dependencies (uses --omit peer) { "version": "1.0.0", "name": "command-list-npm10", @@ -236,7 +236,7 @@ added 3 packages in ms } } -> vite pm list -- --loglevel=warn --json # should support pass through arguments +> vp pm list -- --loglevel=warn --json # should support pass through arguments { "version": "1.0.0", "name": "command-list-npm10", diff --git a/packages/global/snap-tests/command-list-npm10/steps.json b/packages/global/snap-tests/command-list-npm10/steps.json index 4b766cf69e..91af807eec 100644 --- a/packages/global/snap-tests/command-list-npm10/steps.json +++ b/packages/global/snap-tests/command-list-npm10/steps.json @@ -4,16 +4,16 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install # should install packages first", - "vite pm list --json # should list installed packages", - "vite pm list testnpm2 --json # should list specific package", - "vite pm list --depth 0 --json # should list packages with depth limit", - "vite pm list --long --json # should list packages with extended info", - "vite pm list --parseable --json # should list packages in parseable format", - "vite pm list --prod --json # should list production dependencies only (uses --include prod --include peer)", - "vite pm list --dev --json # should list development dependencies only (uses --include dev)", - "vite pm list --no-optional --json # should exclude optional dependencies (uses --omit optional)", - "vite pm list --exclude-peers --json # should exclude peer dependencies (uses --omit peer)", - "vite pm list -- --loglevel=warn --json # should support pass through arguments" + "vp install # should install packages first", + "vp pm list --json # should list installed packages", + "vp pm list testnpm2 --json # should list specific package", + "vp pm list --depth 0 --json # should list packages with depth limit", + "vp pm list --long --json # should list packages with extended info", + "vp pm list --parseable --json # should list packages in parseable format", + "vp pm list --prod --json # should list production dependencies only (uses --include prod --include peer)", + "vp pm list --dev --json # should list development dependencies only (uses --include dev)", + "vp pm list --no-optional --json # should exclude optional dependencies (uses --omit optional)", + "vp pm list --exclude-peers --json # should exclude peer dependencies (uses --omit peer)", + "vp pm list -- --loglevel=warn --json # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-list-pnpm10-with-workspace/snap.txt b/packages/global/snap-tests/command-list-pnpm10-with-workspace/snap.txt index 0b1513ea3d..8b3872dce4 100644 --- a/packages/global/snap-tests/command-list-pnpm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-list-pnpm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite install # should install packages first +> vp install # should install packages first Scope: all workspace projects Packages: + + @@ -6,8 +6,8 @@ Progress: resolved , reused , downloaded , added < Done in ms using pnpm v -> vite pm list # should list current workspace root dependencies -> vite pm list --recursive # should list all packages in workspace recursively +> vp pm list # should list current workspace root dependencies +> vp pm list --recursive # should list all packages in workspace recursively Legend: production dependency, optional only, dev only app@ /packages/app @@ -21,7 +21,7 @@ test-vite-plus-package-optional dependencies: testnpm2 -> vite pm list --filter app # should list specific workspace package (uses --filter app list) +> vp pm list --filter app # should list specific workspace package (uses --filter app list) Legend: production dependency, optional only, dev only app@ /packages/app @@ -30,7 +30,7 @@ dependencies: @vite-plus-test/utils link:../utils test-vite-plus-package-optional -> vite pm list --filter app --filter @vite-plus-test/utils # should list multiple workspace packages +> vp pm list --filter app --filter @vite-plus-test/utils # should list multiple workspace packages Legend: production dependency, optional only, dev only app@ /packages/app @@ -44,7 +44,7 @@ test-vite-plus-package-optional dependencies: testnpm2 -> vite pm list --recursive --json # should list all workspace packages in JSON format +> vp pm list --recursive --json # should list all workspace packages in JSON format [ { "name": "command-list-pnpm10-with-workspace", @@ -87,7 +87,7 @@ testnpm2 } ] -> vite pm list --recursive --depth 0 # should list workspace packages with depth limit +> vp pm list --recursive --depth 0 # should list workspace packages with depth limit Legend: production dependency, optional only, dev only app@ /packages/app @@ -101,7 +101,7 @@ test-vite-plus-package-optional dependencies: testnpm2 -> vite pm list --recursive --only-projects # should list only workspace projects (pnpm-specific) +> vp pm list --recursive --only-projects # should list only workspace projects (pnpm-specific) Legend: production dependency, optional only, dev only app@ /packages/app @@ -109,7 +109,7 @@ app@ /packages/app dependencies: @vite-plus-test/utils link:../utils -> vite pm list --recursive --exclude-peers # should exclude peer dependencies in workspace +> vp pm list --recursive --exclude-peers # should exclude peer dependencies in workspace Legend: production dependency, optional only, dev only app@ /packages/app @@ -123,7 +123,7 @@ test-vite-plus-package-optional dependencies: testnpm2 -> vite pm list --recursive --prod # should list production dependencies in workspace +> vp pm list --recursive --prod # should list production dependencies in workspace Legend: production dependency, optional only, dev only app@ /packages/app diff --git a/packages/global/snap-tests/command-list-pnpm10-with-workspace/steps.json b/packages/global/snap-tests/command-list-pnpm10-with-workspace/steps.json index 7976c9eb84..bae99ad138 100644 --- a/packages/global/snap-tests/command-list-pnpm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-list-pnpm10-with-workspace/steps.json @@ -4,15 +4,15 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install # should install packages first", - "vite pm list # should list current workspace root dependencies", - "vite pm list --recursive # should list all packages in workspace recursively", - "vite pm list --filter app # should list specific workspace package (uses --filter app list)", - "vite pm list --filter app --filter @vite-plus-test/utils # should list multiple workspace packages", - "vite pm list --recursive --json # should list all workspace packages in JSON format", - "vite pm list --recursive --depth 0 # should list workspace packages with depth limit", - "vite pm list --recursive --only-projects # should list only workspace projects (pnpm-specific)", - "vite pm list --recursive --exclude-peers # should exclude peer dependencies in workspace", - "vite pm list --recursive --prod # should list production dependencies in workspace" + "vp install # should install packages first", + "vp pm list # should list current workspace root dependencies", + "vp pm list --recursive # should list all packages in workspace recursively", + "vp pm list --filter app # should list specific workspace package (uses --filter app list)", + "vp pm list --filter app --filter @vite-plus-test/utils # should list multiple workspace packages", + "vp pm list --recursive --json # should list all workspace packages in JSON format", + "vp pm list --recursive --depth 0 # should list workspace packages with depth limit", + "vp pm list --recursive --only-projects # should list only workspace projects (pnpm-specific)", + "vp pm list --recursive --exclude-peers # should exclude peer dependencies in workspace", + "vp pm list --recursive --prod # should list production dependencies in workspace" ] } diff --git a/packages/global/snap-tests/command-list-pnpm10/snap.txt b/packages/global/snap-tests/command-list-pnpm10/snap.txt index e90bb21ef2..2f55f72410 100644 --- a/packages/global/snap-tests/command-list-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-list-pnpm10/snap.txt @@ -1,4 +1,4 @@ -> vite install # should install packages first +> vp install # should install packages first Packages: + + Progress: resolved , reused , downloaded , added , done @@ -12,14 +12,14 @@ devDependencies: Done in ms using pnpm v -> vite pm list --help # should show help +> vp pm list --help # should show help List installed packages -Usage: vite pm list [OPTIONS] [PATTERN] [-- ...] +Usage: vp pm list [OPTIONS] [PATTERN] [-- ...] Arguments: [PATTERN] Package pattern to filter - [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager + [PASS_THROUGH_ARGS]... Additional arguments Options: --depth Maximum depth of dependency tree @@ -30,14 +30,14 @@ Options: -D, --dev Only dev dependencies --no-optional Exclude optional dependencies --exclude-peers Exclude peer dependencies - --only-projects Show only project packages (pnpm-specific) - --find-by Use a finder function defined in .pnpmfile.cjs (pnpm-specific) + --only-projects Show only project packages + --find-by Use a finder function -r, --recursive List across all workspaces - --filter Filter packages in monorepo (can be used multiple times) + --filter Filter packages in monorepo -g, --global List global packages -h, --help Print help -> vite pm list # should list installed packages +> vp pm list # should list installed packages Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -49,7 +49,7 @@ testnpm2 devDependencies: test-vite-plus-package -> vite pm list testnpm2 # should list specific package +> vp pm list testnpm2 # should list specific package Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -57,7 +57,7 @@ command-list-pnpm10@ dependencies: testnpm2 -> vite pm list --depth 0 # should list packages with depth limit +> vp pm list --depth 0 # should list packages with depth limit Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -69,7 +69,7 @@ testnpm2 devDependencies: test-vite-plus-package -> vite pm list --json # should list packages in JSON format +> vp pm list --json # should list packages in JSON format [ { "name": "command-list-pnpm10", @@ -101,7 +101,7 @@ test-vite-plus-package } ] -> vite pm list --long # should list packages with extended info +> vp pm list --long # should list packages with extended info Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -118,13 +118,13 @@ test-vite-plus-package just for snap-test /node_modules/.pnpm/test-vite-plus-package@/node_modules/test-vite-plus-package -> vite pm list --parseable # should list packages in parseable format +> vp pm list --parseable # should list packages in parseable format /node_modules/.pnpm/test-vite-plus-package@/node_modules/test-vite-plus-package /node_modules/.pnpm/test-vite-plus-package-optional@/node_modules/test-vite-plus-package-optional /node_modules/.pnpm/testnpm2@/node_modules/testnpm2 -> vite pm list --prod # should list production dependencies only +> vp pm list --prod # should list production dependencies only Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -133,7 +133,7 @@ dependencies: test-vite-plus-package-optional testnpm2 -> vite pm list --dev # should list development dependencies only +> vp pm list --dev # should list development dependencies only Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -141,7 +141,7 @@ command-list-pnpm10@ devDependencies: test-vite-plus-package -> vite pm list --no-optional # should exclude optional dependencies +> vp pm list --no-optional # should exclude optional dependencies Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -153,7 +153,7 @@ testnpm2 devDependencies: test-vite-plus-package -> vite pm list --exclude-peers # should exclude peer dependencies +> vp pm list --exclude-peers # should exclude peer dependencies Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -165,11 +165,11 @@ testnpm2 devDependencies: test-vite-plus-package -> vite pm list --only-projects # should list only workspace projects (pnpm-specific) -[1]> vite pm list --find-by customFinder # should use custom finder (pnpm-specific) +> vp pm list --only-projects # should list only workspace projects (pnpm-specific) +[1]> vp pm list --find-by customFinder # should use custom finder (pnpm-specific)  ERR_PNPM_FINDER_NOT_FOUND  No finder with name customFinder is found -> vite pm list --recursive # should list packages recursively in workspace +> vp pm list --recursive # should list packages recursively in workspace Legend: production dependency, optional only, dev only command-list-pnpm10@ @@ -181,7 +181,7 @@ testnpm2 devDependencies: test-vite-plus-package -> vite pm list -- --loglevel=warn # should support pass through arguments +> vp pm list -- --loglevel=warn # should support pass through arguments Legend: production dependency, optional only, dev only command-list-pnpm10@ diff --git a/packages/global/snap-tests/command-list-pnpm10/steps.json b/packages/global/snap-tests/command-list-pnpm10/steps.json index 8a200a38c8..1e6f2ac116 100644 --- a/packages/global/snap-tests/command-list-pnpm10/steps.json +++ b/packages/global/snap-tests/command-list-pnpm10/steps.json @@ -4,21 +4,21 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install # should install packages first", - "vite pm list --help # should show help", - "vite pm list # should list installed packages", - "vite pm list testnpm2 # should list specific package", - "vite pm list --depth 0 # should list packages with depth limit", - "vite pm list --json # should list packages in JSON format", - "vite pm list --long # should list packages with extended info", - "vite pm list --parseable # should list packages in parseable format", - "vite pm list --prod # should list production dependencies only", - "vite pm list --dev # should list development dependencies only", - "vite pm list --no-optional # should exclude optional dependencies", - "vite pm list --exclude-peers # should exclude peer dependencies", - "vite pm list --only-projects # should list only workspace projects (pnpm-specific)", - "vite pm list --find-by customFinder # should use custom finder (pnpm-specific)", - "vite pm list --recursive # should list packages recursively in workspace", - "vite pm list -- --loglevel=warn # should support pass through arguments" + "vp install # should install packages first", + "vp pm list --help # should show help", + "vp pm list # should list installed packages", + "vp pm list testnpm2 # should list specific package", + "vp pm list --depth 0 # should list packages with depth limit", + "vp pm list --json # should list packages in JSON format", + "vp pm list --long # should list packages with extended info", + "vp pm list --parseable # should list packages in parseable format", + "vp pm list --prod # should list production dependencies only", + "vp pm list --dev # should list development dependencies only", + "vp pm list --no-optional # should exclude optional dependencies", + "vp pm list --exclude-peers # should exclude peer dependencies", + "vp pm list --only-projects # should list only workspace projects (pnpm-specific)", + "vp pm list --find-by customFinder # should use custom finder (pnpm-specific)", + "vp pm list --recursive # should list packages recursively in workspace", + "vp pm list -- --loglevel=warn # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-list-yarn1/snap.txt b/packages/global/snap-tests/command-list-yarn1/snap.txt index 36e6eb0717..62206c6a29 100644 --- a/packages/global/snap-tests/command-list-yarn1/snap.txt +++ b/packages/global/snap-tests/command-list-yarn1/snap.txt @@ -1,4 +1,4 @@ -> vite install # should install packages first +> vp install # should install packages first yarn install v info No lockfile found. [1/4] Resolving packages... @@ -8,86 +8,86 @@ info No lockfile found. success Saved lockfile. Done in ms. -> vite pm list # should list installed packages +> vp pm list # should list installed packages yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list testnpm2 # should list specific package +> vp pm list testnpm2 # should list specific package yarn list v warning Filtering by arguments is deprecated. Please use the pattern option instead. └─ testnpm2@ Done in ms. -> vite pm list --depth 0 # should list packages with depth limit +> vp pm list --depth 0 # should list packages with depth limit yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list --json # should list packages in JSON format +> vp pm list --json # should list packages in JSON format {"type":"warning","data":"package.json: No license field"} {"type":"warning","data":"command-list-yarn1@: No license field"} {"type":"tree","data":{"type":"list","trees":[{"name":"testnpm2@","children":[],"hint":null,"color":"bold","depth":0},{"name":"test-vite-plus-package@","children":[],"hint":null,"color":"bold","depth":0}]}} -> vite pm list --prod # should show warning that --prod not supported by yarn@1 +> vp pm list --prod # should show warning that --prod not supported by yarn@1 Warning: yarn@1 does not support --prod, ignoring --prod flag yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list --dev # should show warning that --dev not supported by yarn@1 +> vp pm list --dev # should show warning that --dev not supported by yarn@1 Warning: yarn@1 does not support --dev, ignoring --dev flag yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list --no-optional # should show warning that --no-optional not supported by yarn@1 +> vp pm list --no-optional # should show warning that --no-optional not supported by yarn@1 Warning: yarn@1 does not support --no-optional, ignoring --no-optional flag yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list --exclude-peers # should show warning that --exclude-peers not supported by yarn@1 +> vp pm list --exclude-peers # should show warning that --exclude-peers not supported by yarn@1 Warning: yarn@1 does not support --exclude-peers, ignoring flag yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list --only-projects # should show warning that --only-projects not supported by yarn@1 +> vp pm list --only-projects # should show warning that --only-projects not supported by yarn@1 Warning: yarn@1 does not support --only-projects, ignoring flag yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list --find-by customFinder # should show warning that --find-by not supported by yarn@1 +> vp pm list --find-by customFinder # should show warning that --find-by not supported by yarn@1 Warning: yarn@1 does not support --find-by, ignoring flag yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list --recursive # should show warning that --recursive not supported by yarn@1 +> vp pm list --recursive # should show warning that --recursive not supported by yarn@1 Warning: yarn@1 does not support --recursive, ignoring --recursive flag yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list --filter app # should show warning that --filter not supported by yarn@1 +> vp pm list --filter app # should show warning that --filter not supported by yarn@1 Warning: yarn@1 does not support --filter, ignoring --filter flag yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ Done in ms. -> vite pm list -- --loglevel=warn # should support pass through arguments +> vp pm list -- --loglevel=warn # should support pass through arguments yarn list v ├─ test-vite-plus-package@ └─ testnpm2@ diff --git a/packages/global/snap-tests/command-list-yarn1/steps.json b/packages/global/snap-tests/command-list-yarn1/steps.json index 19755b33e6..a141e342dd 100644 --- a/packages/global/snap-tests/command-list-yarn1/steps.json +++ b/packages/global/snap-tests/command-list-yarn1/steps.json @@ -1,21 +1,22 @@ { "env": { - "VITE_DISABLE_AUTO_INSTALL": "1" + "VITE_DISABLE_AUTO_INSTALL": "1", + "NODE_OPTIONS": "--no-deprecation" }, "commands": [ - "vite install # should install packages first", - "vite pm list # should list installed packages", - "vite pm list testnpm2 # should list specific package", - "vite pm list --depth 0 # should list packages with depth limit", - "vite pm list --json # should list packages in JSON format", - "vite pm list --prod # should show warning that --prod not supported by yarn@1", - "vite pm list --dev # should show warning that --dev not supported by yarn@1", - "vite pm list --no-optional # should show warning that --no-optional not supported by yarn@1", - "vite pm list --exclude-peers # should show warning that --exclude-peers not supported by yarn@1", - "vite pm list --only-projects # should show warning that --only-projects not supported by yarn@1", - "vite pm list --find-by customFinder # should show warning that --find-by not supported by yarn@1", - "vite pm list --recursive # should show warning that --recursive not supported by yarn@1", - "vite pm list --filter app # should show warning that --filter not supported by yarn@1", - "vite pm list -- --loglevel=warn # should support pass through arguments" + "vp install # should install packages first", + "vp pm list # should list installed packages", + "vp pm list testnpm2 # should list specific package", + "vp pm list --depth 0 # should list packages with depth limit", + "vp pm list --json # should list packages in JSON format", + "vp pm list --prod # should show warning that --prod not supported by yarn@1", + "vp pm list --dev # should show warning that --dev not supported by yarn@1", + "vp pm list --no-optional # should show warning that --no-optional not supported by yarn@1", + "vp pm list --exclude-peers # should show warning that --exclude-peers not supported by yarn@1", + "vp pm list --only-projects # should show warning that --only-projects not supported by yarn@1", + "vp pm list --find-by customFinder # should show warning that --find-by not supported by yarn@1", + "vp pm list --recursive # should show warning that --recursive not supported by yarn@1", + "vp pm list --filter app # should show warning that --filter not supported by yarn@1", + "vp pm list -- --loglevel=warn # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-list-yarn4/snap.txt b/packages/global/snap-tests/command-list-yarn4/snap.txt index 45cc7f2153..8626bc0a8a 100644 --- a/packages/global/snap-tests/command-list-yarn4/snap.txt +++ b/packages/global/snap-tests/command-list-yarn4/snap.txt @@ -1,2 +1,2 @@ -> vite pm list # should show warning that yarn@2+ does not support list command +> vp pm list # should show warning that yarn@2+ does not support list command Warning: yarn@2+ does not support 'list' command diff --git a/packages/global/snap-tests/command-list-yarn4/steps.json b/packages/global/snap-tests/command-list-yarn4/steps.json index eab75bc2d3..95199c9324 100644 --- a/packages/global/snap-tests/command-list-yarn4/steps.json +++ b/packages/global/snap-tests/command-list-yarn4/steps.json @@ -2,5 +2,5 @@ "env": { "VITE_DISABLE_AUTO_INSTALL": "1" }, - "commands": ["vite pm list # should show warning that yarn@2+ does not support list command"] + "commands": ["vp pm list # should show warning that yarn@2+ does not support list command"] } diff --git a/packages/global/snap-tests/command-outdated-npm10-with-workspace/snap.txt b/packages/global/snap-tests/command-outdated-npm10-with-workspace/snap.txt index 3144986be5..ea93ed7993 100644 --- a/packages/global/snap-tests/command-outdated-npm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-outdated-npm10-with-workspace/snap.txt @@ -1,13 +1,13 @@ -> vite install +> vp install added 6 packages in ms -[1]> vite outdated testnpm2 -w # should outdated in workspace root +[1]> vp outdated testnpm2 -w # should outdated in workspace root Package Current Wanted Latest Location Depended by testnpm2 node_modules/testnpm2 command-outdated-npm10-with-workspace -> vite outdated testnpm2 --filter app # should outdated in specific package -[1]> vite outdated --filter "*" --format json # should outdated in all packages +> vp outdated testnpm2 --filter app # should outdated in specific package +[1]> vp outdated --filter "*" --format json # should outdated in all packages { "test-vite-plus-other-optional": { "current": "1.0.0", @@ -18,7 +18,7 @@ testnpm2 node_modules/testnpm2 command-outda } } -[1]> vite outdated -r # should outdated recursively +[1]> vp outdated -r # should outdated recursively Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional app@ testnpm2 node_modules/testnpm2 command-outdated-npm10-with-workspace diff --git a/packages/global/snap-tests/command-outdated-npm10-with-workspace/steps.json b/packages/global/snap-tests/command-outdated-npm10-with-workspace/steps.json index 8a610c58cc..e5c775ed0e 100644 --- a/packages/global/snap-tests/command-outdated-npm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-outdated-npm10-with-workspace/steps.json @@ -4,10 +4,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install", - "vite outdated testnpm2 -w # should outdated in workspace root", - "vite outdated testnpm2 --filter app # should outdated in specific package", - "vite outdated --filter \"*\" --format json # should outdated in all packages", - "vite outdated -r # should outdated recursively" + "vp install", + "vp outdated testnpm2 -w # should outdated in workspace root", + "vp outdated testnpm2 --filter app # should outdated in specific package", + "vp outdated --filter \"*\" --format json # should outdated in all packages", + "vp outdated -r # should outdated recursively" ] } diff --git a/packages/global/snap-tests/command-outdated-npm10/snap.txt b/packages/global/snap-tests/command-outdated-npm10/snap.txt index 9f0b2d9126..5015c3e257 100644 --- a/packages/global/snap-tests/command-outdated-npm10/snap.txt +++ b/packages/global/snap-tests/command-outdated-npm10/snap.txt @@ -1,13 +1,13 @@ -> vite install # should install packages first +> vp install # should install packages first added 4 packages in ms -[1]> vite outdated testnpm2 # should outdated package +[1]> vp outdated testnpm2 # should outdated package Package Current Wanted Latest Location Depended by testnpm2 node_modules/testnpm2 command-outdated-npm10 -> vite outdated test-vite* # should outdated with glob pattern not working on npm -[1]> vite outdated --format json # should support json output +> vp outdated test-vite* # should outdated with glob pattern not working on npm +[1]> vp outdated --format json # should support json output { "test-vite-plus-other-optional": { "current": "1.0.0", @@ -32,63 +32,63 @@ testnpm2 node_modules/testnpm2 command-outda } } -[1]> vite outdated --format list # should support list output +[1]> vp outdated --format list # should support list output /node_modules/test-vite-plus-other-optional:test-vite-plus-other-optional@:test-vite-plus-other-optional@:test-vite-plus-other-optional@:command-outdated-npm10 /node_modules/test-vite-plus-top-package:test-vite-plus-top-package@:test-vite-plus-top-package@:test-vite-plus-top-package@:command-outdated-npm10 /node_modules/testnpm2:testnpm2@:testnpm2@:testnpm2@:command-outdated-npm10 -[1]> vite outdated --format table # should support table output +[1]> vp outdated --format table # should support table output Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional command-outdated-npm10 test-vite-plus-top-package node_modules/test-vite-plus-top-package command-outdated-npm10 testnpm2 node_modules/testnpm2 command-outdated-npm10 -[1]> vite outdated testnpm2 --long # should support --long +[1]> vp outdated testnpm2 --long # should support --long Package Current Wanted Latest Location Depended by Package Type Homepage testnpm2 node_modules/testnpm2 command-outdated-npm10 dependencies -[1]> vite outdated -r # should support recursive output +[1]> vp outdated -r # should support recursive output Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional command-outdated-npm10 test-vite-plus-top-package node_modules/test-vite-plus-top-package command-outdated-npm10 testnpm2 node_modules/testnpm2 command-outdated-npm10 -[1]> vite outdated -P # should support prod output +[1]> vp outdated -P # should support prod output Warning: --prod/--dev not supported by npm Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional command-outdated-npm10 test-vite-plus-top-package node_modules/test-vite-plus-top-package command-outdated-npm10 testnpm2 node_modules/testnpm2 command-outdated-npm10 -[1]> vite outdated -D # should support dev output +[1]> vp outdated -D # should support dev output Warning: --prod/--dev not supported by npm Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional command-outdated-npm10 test-vite-plus-top-package node_modules/test-vite-plus-top-package command-outdated-npm10 testnpm2 node_modules/testnpm2 command-outdated-npm10 -[1]> vite outdated --no-optional # should support no-optional output +[1]> vp outdated --no-optional # should support no-optional output Warning: --no-optional not supported by npm Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional command-outdated-npm10 test-vite-plus-top-package node_modules/test-vite-plus-top-package command-outdated-npm10 testnpm2 node_modules/testnpm2 command-outdated-npm10 -[1]> vite outdated --compatible # should compatible output nothing +[1]> vp outdated --compatible # should compatible output nothing Warning: --compatible not supported by npm Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional command-outdated-npm10 test-vite-plus-top-package node_modules/test-vite-plus-top-package command-outdated-npm10 testnpm2 node_modules/testnpm2 command-outdated-npm10 -[1]> json-edit package.json '_.optionalDependencies["test-vite-plus-other-optional"] = "^1.0.0"' && vite outdated --compatible # should support compatible output with optional dependencies +[1]> json-edit package.json '_.optionalDependencies["test-vite-plus-other-optional"] = "^1.0.0"' && vp outdated --compatible # should support compatible output with optional dependencies Warning: --compatible not supported by npm Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional command-outdated-npm10 test-vite-plus-top-package node_modules/test-vite-plus-top-package command-outdated-npm10 testnpm2 node_modules/testnpm2 command-outdated-npm10 -[1]> vite outdated --sort-by name # should support sort-by output +[1]> vp outdated --sort-by name # should support sort-by output Warning: --sort-by not supported by npm Package Current Wanted Latest Location Depended by test-vite-plus-other-optional node_modules/test-vite-plus-other-optional command-outdated-npm10 diff --git a/packages/global/snap-tests/command-outdated-npm10/steps.json b/packages/global/snap-tests/command-outdated-npm10/steps.json index 01248208b2..fa88b61923 100644 --- a/packages/global/snap-tests/command-outdated-npm10/steps.json +++ b/packages/global/snap-tests/command-outdated-npm10/steps.json @@ -4,19 +4,19 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install # should install packages first", - "vite outdated testnpm2 # should outdated package", - "vite outdated test-vite* # should outdated with glob pattern not working on npm", - "vite outdated --format json # should support json output", - "vite outdated --format list # should support list output", - "vite outdated --format table # should support table output", - "vite outdated testnpm2 --long # should support --long", - "vite outdated -r # should support recursive output", - "vite outdated -P # should support prod output", - "vite outdated -D # should support dev output", - "vite outdated --no-optional # should support no-optional output", - "vite outdated --compatible # should compatible output nothing", - "json-edit package.json '_.optionalDependencies[\"test-vite-plus-other-optional\"] = \"^1.0.0\"' && vite outdated --compatible # should support compatible output with optional dependencies", - "vite outdated --sort-by name # should support sort-by output" + "vp install # should install packages first", + "vp outdated testnpm2 # should outdated package", + "vp outdated test-vite* # should outdated with glob pattern not working on npm", + "vp outdated --format json # should support json output", + "vp outdated --format list # should support list output", + "vp outdated --format table # should support table output", + "vp outdated testnpm2 --long # should support --long", + "vp outdated -r # should support recursive output", + "vp outdated -P # should support prod output", + "vp outdated -D # should support dev output", + "vp outdated --no-optional # should support no-optional output", + "vp outdated --compatible # should compatible output nothing", + "json-edit package.json '_.optionalDependencies[\"test-vite-plus-other-optional\"] = \"^1.0.0\"' && vp outdated --compatible # should support compatible output with optional dependencies", + "vp outdated --sort-by name # should support sort-by output" ] } diff --git a/packages/global/snap-tests/command-outdated-pnpm10-with-workspace/snap.txt b/packages/global/snap-tests/command-outdated-pnpm10-with-workspace/snap.txt index 072c0f7213..b8d7e3367b 100644 --- a/packages/global/snap-tests/command-outdated-pnpm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-outdated-pnpm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite install +> vp install Scope: all workspace projects Packages: + + @@ -9,22 +9,22 @@ dependencies: Done in ms using pnpm v -[1]> vite outdated testnpm2 -w # should outdated in workspace root +[1]> vp outdated testnpm2 -w # should outdated in workspace root ┌──────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────┼─────────┼────────┤ │ testnpm2 │ │ └──────────┴─────────┴────────┘ -[1]> vite outdated testnpm2 --filter app # should outdated in specific package +[1]> vp outdated testnpm2 --filter app # should outdated in specific package ┌──────────┬─────────┬────────┬────────────┐ │ Package │ Current │ Latest │ Dependents │ ├──────────┼─────────┼────────┼────────────┤ │ testnpm2 │ │ app │ └──────────┴─────────┴────────┴────────────┘ -> vite outdated -D --filter app # should outdated dev dependencies in app -[1]> vite outdated --filter "*" --format json # should outdated in all packages +> vp outdated -D --filter app # should outdated dev dependencies in app +[1]> vp outdated --filter "*" --format json # should outdated in all packages { "testnpm2": { "current": "1.0.0", @@ -62,7 +62,7 @@ Done in ms using pnpm v } } -[1]> vite outdated -r # should outdated recursively +[1]> vp outdated -r # should outdated recursively ┌──────────────────────────────────────────┬─────────┬────────┬────────────────────────────────┐ │ Package │ Current │ Latest │ Dependents │ ├──────────────────────────────────────────┼─────────┼────────┼────────────────────────────────┤ diff --git a/packages/global/snap-tests/command-outdated-pnpm10-with-workspace/steps.json b/packages/global/snap-tests/command-outdated-pnpm10-with-workspace/steps.json index 879e190914..7527c4280e 100644 --- a/packages/global/snap-tests/command-outdated-pnpm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-outdated-pnpm10-with-workspace/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install", - "vite outdated testnpm2 -w # should outdated in workspace root", - "vite outdated testnpm2 --filter app # should outdated in specific package", - "vite outdated -D --filter app # should outdated dev dependencies in app", - "vite outdated --filter \"*\" --format json # should outdated in all packages", - "vite outdated -r # should outdated recursively" + "vp install", + "vp outdated testnpm2 -w # should outdated in workspace root", + "vp outdated testnpm2 --filter app # should outdated in specific package", + "vp outdated -D --filter app # should outdated dev dependencies in app", + "vp outdated --filter \"*\" --format json # should outdated in all packages", + "vp outdated -r # should outdated recursively" ] } diff --git a/packages/global/snap-tests/command-outdated-pnpm10/snap.txt b/packages/global/snap-tests/command-outdated-pnpm10/snap.txt index cd200c8fb5..e3dd24cf81 100644 --- a/packages/global/snap-tests/command-outdated-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-outdated-pnpm10/snap.txt @@ -1,27 +1,27 @@ -> vite outdated --help # should show help +> vp outdated --help # should show help Check for outdated packages -Usage: vite outdated [OPTIONS] [PACKAGES]... [-- ...] +Usage: vp outdated [OPTIONS] [PACKAGES]... [-- ...] Arguments: - [PACKAGES]... Package name(s) to check (supports glob patterns in pnpm) + [PACKAGES]... Package name(s) to check [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager Options: --long Show extended information --format Output format: table (default), list, or json -r, --recursive Check recursively across all workspaces - --filter Filter packages in monorepo (can be used multiple times) + --filter Filter packages in monorepo -w, --workspace-root Include workspace root - -P, --prod Only production and optional dependencies (pnpm-specific) - -D, --dev Only dev dependencies (pnpm-specific) - --no-optional Exclude optional dependencies (pnpm-specific) - --compatible Only show compatible versions (pnpm-specific) - --sort-by Sort results by field (pnpm-specific) + -P, --prod Only production and optional dependencies + -D, --dev Only dev dependencies + --no-optional Exclude optional dependencies + --compatible Only show compatible versions + --sort-by Sort results by field -g, --global Check globally installed packages -h, --help Print help -> vite install # should install packages first +> vp install # should install packages first Packages: + + Progress: resolved , reused , downloaded , added , done @@ -37,14 +37,14 @@ devDependencies: Done in ms using pnpm v -[1]> vite outdated testnpm2 # should outdated package +[1]> vp outdated testnpm2 # should outdated package ┌──────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────┼─────────┼────────┤ │ testnpm2 │ │ └──────────┴─────────┴────────┘ -[1]> vite outdated test-vite* # should outdated with one glob pattern +[1]> vp outdated test-vite* # should outdated with one glob pattern ┌──────────────────────────────────────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────────────────────────────────────┼─────────┼────────┤ @@ -53,7 +53,7 @@ Done in ms using pnpm v │ test-vite-plus-top-package (dev) │ │ └──────────────────────────────────────────┴─────────┴────────┘ -[1]> vite outdated test-vite* '*npm*' # should outdated with multiple glob patterns +[1]> vp outdated test-vite* '*npm*' # should outdated with multiple glob patterns ┌──────────────────────────────────────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────────────────────────────────────┼─────────┼────────┤ @@ -64,7 +64,7 @@ Done in ms using pnpm v │ test-vite-plus-top-package (dev) │ │ └──────────────────────────────────────────┴─────────┴────────┘ -[1]> vite outdated --format json # should support json output +[1]> vp outdated --format json # should support json output { "testnpm2": { "current": "1.0.0", @@ -89,7 +89,7 @@ Done in ms using pnpm v } } -[1]> vite outdated --format list # should support list output +[1]> vp outdated --format list # should support list output testnpm2 => @@ -99,7 +99,7 @@ test-vite-plus-other-optional (optional) test-vite-plus-top-package (dev) => -[1]> vite outdated --format table # should support table output +[1]> vp outdated --format table # should support table output ┌──────────────────────────────────────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────────────────────────────────────┼─────────┼────────┤ @@ -110,11 +110,11 @@ test-vite-plus-top-package (dev) │ test-vite-plus-top-package (dev) │ │ └──────────────────────────────────────────┴─────────┴────────┘ -[1]> vite outdated testnpm2 --long --format list # should support --long +[1]> vp outdated testnpm2 --long --format list # should support --long testnpm2 => -[1]> vite outdated -r # should support recursive output +[1]> vp outdated -r # should support recursive output ┌──────────────────────────────────────────┬─────────┬────────┬─────────────────────────┐ │ Package │ Current │ Latest │ Dependents │ ├──────────────────────────────────────────┼─────────┼────────┼─────────────────────────┤ @@ -125,7 +125,7 @@ testnpm2 │ test-vite-plus-top-package (dev) │ │ command-outdated-pnpm10 │ └──────────────────────────────────────────┴─────────┴────────┴─────────────────────────┘ -[1]> vite outdated -P # should support prod output +[1]> vp outdated -P # should support prod output ┌──────────────────────────────────────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────────────────────────────────────┼─────────┼────────┤ @@ -134,14 +134,14 @@ testnpm2 │ test-vite-plus-other-optional (optional) │ │ └──────────────────────────────────────────┴─────────┴────────┘ -[1]> vite outdated -D # should support dev output +[1]> vp outdated -D # should support dev output ┌──────────────────────────────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────────────────────────────┼─────────┼────────┤ │ test-vite-plus-top-package (dev) │ │ └──────────────────────────────────┴─────────┴────────┘ -[1]> vite outdated --no-optional # should support no-optional output +[1]> vp outdated --no-optional # should support no-optional output ┌──────────────────────────────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────────────────────────────┼─────────┼────────┤ @@ -150,15 +150,15 @@ testnpm2 │ test-vite-plus-top-package (dev) │ │ └──────────────────────────────────┴─────────┴────────┘ -> vite outdated --compatible # should compatible output nothing -[1]> json-edit package.json '_.optionalDependencies["test-vite-plus-other-optional"] = "^1.0.0"' && vite outdated --compatible # should support compatible output with optional dependencies +> vp outdated --compatible # should compatible output nothing +[1]> json-edit package.json '_.optionalDependencies["test-vite-plus-other-optional"] = "^1.0.0"' && vp outdated --compatible # should support compatible output with optional dependencies ┌──────────────────────────────────────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────────────────────────────────────┼─────────┼────────┤ │ test-vite-plus-other-optional (optional) │ │ └──────────────────────────────────────────┴─────────┴────────┘ -[1]> vite outdated --sort-by name # should support sort-by output +[1]> vp outdated --sort-by name # should support sort-by output ┌──────────────────────────────────────────┬─────────┬────────┐ │ Package │ Current │ Latest │ ├──────────────────────────────────────────┼─────────┼────────┤ @@ -169,5 +169,5 @@ testnpm2 │ testnpm2 │ │ └──────────────────────────────────────────┴─────────┴────────┘ -> vite outdated testnpm2 -g --format json # should support global output +> vp outdated testnpm2 -g --format json # should support global output {} diff --git a/packages/global/snap-tests/command-outdated-pnpm10/steps.json b/packages/global/snap-tests/command-outdated-pnpm10/steps.json index f71c17b7e1..ccab803397 100644 --- a/packages/global/snap-tests/command-outdated-pnpm10/steps.json +++ b/packages/global/snap-tests/command-outdated-pnpm10/steps.json @@ -4,22 +4,22 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite outdated --help # should show help", - "vite install # should install packages first", - "vite outdated testnpm2 # should outdated package", - "vite outdated test-vite* # should outdated with one glob pattern", - "vite outdated test-vite* '*npm*' # should outdated with multiple glob patterns", - "vite outdated --format json # should support json output", - "vite outdated --format list # should support list output", - "vite outdated --format table # should support table output", - "vite outdated testnpm2 --long --format list # should support --long", - "vite outdated -r # should support recursive output", - "vite outdated -P # should support prod output", - "vite outdated -D # should support dev output", - "vite outdated --no-optional # should support no-optional output", - "vite outdated --compatible # should compatible output nothing", - "json-edit package.json '_.optionalDependencies[\"test-vite-plus-other-optional\"] = \"^1.0.0\"' && vite outdated --compatible # should support compatible output with optional dependencies", - "vite outdated --sort-by name # should support sort-by output", - "vite outdated testnpm2 -g --format json # should support global output" + "vp outdated --help # should show help", + "vp install # should install packages first", + "vp outdated testnpm2 # should outdated package", + "vp outdated test-vite* # should outdated with one glob pattern", + "vp outdated test-vite* '*npm*' # should outdated with multiple glob patterns", + "vp outdated --format json # should support json output", + "vp outdated --format list # should support list output", + "vp outdated --format table # should support table output", + "vp outdated testnpm2 --long --format list # should support --long", + "vp outdated -r # should support recursive output", + "vp outdated -P # should support prod output", + "vp outdated -D # should support dev output", + "vp outdated --no-optional # should support no-optional output", + "vp outdated --compatible # should compatible output nothing", + "json-edit package.json '_.optionalDependencies[\"test-vite-plus-other-optional\"] = \"^1.0.0\"' && vp outdated --compatible # should support compatible output with optional dependencies", + "vp outdated --sort-by name # should support sort-by output", + "vp outdated testnpm2 -g --format json # should support global output" ] } diff --git a/packages/global/snap-tests/command-outdated-yarn4/snap.txt b/packages/global/snap-tests/command-outdated-yarn4/snap.txt index 3c7efdc42a..00af83152a 100644 --- a/packages/global/snap-tests/command-outdated-yarn4/snap.txt +++ b/packages/global/snap-tests/command-outdated-yarn4/snap.txt @@ -1,4 +1,4 @@ -> vite outdated -- -h # should show yarn upgrade-interactive help +> vp outdated -- -h # should show yarn upgrade-interactive help Note: yarn@2+ uses 'yarn upgrade-interactive' for checking outdated packages Open the upgrade interface diff --git a/packages/global/snap-tests/command-outdated-yarn4/steps.json b/packages/global/snap-tests/command-outdated-yarn4/steps.json index 2837bc27e5..9243f097b7 100644 --- a/packages/global/snap-tests/command-outdated-yarn4/steps.json +++ b/packages/global/snap-tests/command-outdated-yarn4/steps.json @@ -3,5 +3,5 @@ "env": { "VITE_DISABLE_AUTO_INSTALL": "1" }, - "commands": ["vite outdated -- -h # should show yarn upgrade-interactive help"] + "commands": ["vp outdated -- -h # should show yarn upgrade-interactive help"] } diff --git a/packages/global/snap-tests/command-owner-npm10/snap.txt b/packages/global/snap-tests/command-owner-npm10/snap.txt index c1750cb459..4705598b5b 100644 --- a/packages/global/snap-tests/command-owner-npm10/snap.txt +++ b/packages/global/snap-tests/command-owner-npm10/snap.txt @@ -1,2 +1,2 @@ -> vite pm owner list testnpm2 # should list package owners +> vp pm owner list testnpm2 # should list package owners fengmk2 diff --git a/packages/global/snap-tests/command-owner-npm10/steps.json b/packages/global/snap-tests/command-owner-npm10/steps.json index 727a4517ac..da50da4543 100644 --- a/packages/global/snap-tests/command-owner-npm10/steps.json +++ b/packages/global/snap-tests/command-owner-npm10/steps.json @@ -2,5 +2,5 @@ "env": { "VITE_DISABLE_AUTO_INSTALL": "1" }, - "commands": ["vite pm owner list testnpm2 # should list package owners"] + "commands": ["vp pm owner list testnpm2 # should list package owners"] } diff --git a/packages/global/snap-tests/command-owner-pnpm10/snap.txt b/packages/global/snap-tests/command-owner-pnpm10/snap.txt index 8d05567358..6d7a89aed8 100644 --- a/packages/global/snap-tests/command-owner-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-owner-pnpm10/snap.txt @@ -1,7 +1,7 @@ -> vite pm owner --help # should show help +> vp pm owner --help # should show help Manage package owners -Usage: vite pm owner +Usage: vp pm owner Commands: list List package owners @@ -11,5 +11,5 @@ Commands: Options: -h, --help Print help -> vite pm owner list testnpm2 # should list package owners (uses npm owner) +> vp pm owner list testnpm2 # should list package owners (uses npm owner) fengmk2 diff --git a/packages/global/snap-tests/command-owner-pnpm10/steps.json b/packages/global/snap-tests/command-owner-pnpm10/steps.json index bc43f06d94..e50961cdd6 100644 --- a/packages/global/snap-tests/command-owner-pnpm10/steps.json +++ b/packages/global/snap-tests/command-owner-pnpm10/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm owner --help # should show help", - "vite pm owner list testnpm2 # should list package owners (uses npm owner)" + "vp pm owner --help # should show help", + "vp pm owner list testnpm2 # should list package owners (uses npm owner)" ] } diff --git a/packages/global/snap-tests/command-owner-yarn1/snap.txt b/packages/global/snap-tests/command-owner-yarn1/snap.txt index dfe98c4036..f1f1719d7e 100644 --- a/packages/global/snap-tests/command-owner-yarn1/snap.txt +++ b/packages/global/snap-tests/command-owner-yarn1/snap.txt @@ -1,2 +1,2 @@ -> vite pm owner list testnpm2 # should list package owners (uses npm owner) +> vp pm owner list testnpm2 # should list package owners (uses npm owner) fengmk2 diff --git a/packages/global/snap-tests/command-owner-yarn1/steps.json b/packages/global/snap-tests/command-owner-yarn1/steps.json index 1cc92f1924..76e9398133 100644 --- a/packages/global/snap-tests/command-owner-yarn1/steps.json +++ b/packages/global/snap-tests/command-owner-yarn1/steps.json @@ -2,5 +2,5 @@ "env": { "VITE_DISABLE_AUTO_INSTALL": "1" }, - "commands": ["vite pm owner list testnpm2 # should list package owners (uses npm owner)"] + "commands": ["vp pm owner list testnpm2 # should list package owners (uses npm owner)"] } diff --git a/packages/global/snap-tests/command-owner-yarn4/snap.txt b/packages/global/snap-tests/command-owner-yarn4/snap.txt index dfe98c4036..f1f1719d7e 100644 --- a/packages/global/snap-tests/command-owner-yarn4/snap.txt +++ b/packages/global/snap-tests/command-owner-yarn4/snap.txt @@ -1,2 +1,2 @@ -> vite pm owner list testnpm2 # should list package owners (uses npm owner) +> vp pm owner list testnpm2 # should list package owners (uses npm owner) fengmk2 diff --git a/packages/global/snap-tests/command-owner-yarn4/steps.json b/packages/global/snap-tests/command-owner-yarn4/steps.json index 1cc92f1924..76e9398133 100644 --- a/packages/global/snap-tests/command-owner-yarn4/steps.json +++ b/packages/global/snap-tests/command-owner-yarn4/steps.json @@ -2,5 +2,5 @@ "env": { "VITE_DISABLE_AUTO_INSTALL": "1" }, - "commands": ["vite pm owner list testnpm2 # should list package owners (uses npm owner)"] + "commands": ["vp pm owner list testnpm2 # should list package owners (uses npm owner)"] } diff --git a/packages/global/snap-tests/command-pack-npm10-with-workspace/snap.txt b/packages/global/snap-tests/command-pack-npm10-with-workspace/snap.txt index 6533d53a42..dcd99a5eff 100644 --- a/packages/global/snap-tests/command-pack-npm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-pack-npm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite pm pack --json # should pack current workspace root +> vp pm pack --json # should pack current workspace root [ { "id": "command-pack-npm10-with-workspace@", @@ -10,6 +10,11 @@ "integrity": "sha512-", "filename": "command-pack-npm10-with-workspace-1.0.0.tgz", "files": [ + { + "path": ".node-version", + "size": , + "mode": 420 + }, { "path": "output.log", "size": , @@ -41,12 +46,12 @@ "mode": 420 } ], - "entryCount": 6, + "entryCount": 7, "bundled": [] } ] -> vite pm pack --recursive --json && rm -rf *.tgz # should pack all packages in workspace (uses --workspaces) +> vp pm pack --recursive --json && rm -rf *.tgz # should pack all packages in workspace (uses --workspaces) [ { "id": "app@", @@ -88,7 +93,7 @@ } ] -> vite pm pack --filter app --json && rm -rf *.tgz # should pack specific package (uses --workspace app) +> vp pm pack --filter app --json && rm -rf *.tgz # should pack specific package (uses --workspace app) [ { "id": "app@", @@ -111,7 +116,7 @@ } ] -> vite pm pack --filter app --filter @vite-plus-test/utils --json && rm -rf *.tgz # should pack multiple packages +> vp pm pack --filter app --filter @vite-plus-test/utils --json && rm -rf *.tgz # should pack multiple packages [ { "id": "app@", @@ -153,7 +158,7 @@ } ] -> vite pm pack --pack-destination ./dist --json && rm -rf ./dist # should pack with destination +> vp pm pack --pack-destination ./dist --json && rm -rf ./dist # should pack with destination [ { "id": "command-pack-npm10-with-workspace@", @@ -165,6 +170,11 @@ "integrity": "sha512-", "filename": "command-pack-npm10-with-workspace-1.0.0.tgz", "files": [ + { + "path": ".node-version", + "size": , + "mode": 420 + }, { "path": "app-1.0.0.tgz", "size": , @@ -211,7 +221,7 @@ "mode": 420 } ], - "entryCount": 9, + "entryCount": 10, "bundled": [] } ] diff --git a/packages/global/snap-tests/command-pack-npm10-with-workspace/steps.json b/packages/global/snap-tests/command-pack-npm10-with-workspace/steps.json index 4b42aa56d3..5288aebc3a 100644 --- a/packages/global/snap-tests/command-pack-npm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-pack-npm10-with-workspace/steps.json @@ -4,10 +4,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm pack --json # should pack current workspace root", - "vite pm pack --recursive --json && rm -rf *.tgz # should pack all packages in workspace (uses --workspaces)", - "vite pm pack --filter app --json && rm -rf *.tgz # should pack specific package (uses --workspace app)", - "vite pm pack --filter app --filter @vite-plus-test/utils --json && rm -rf *.tgz # should pack multiple packages", - "vite pm pack --pack-destination ./dist --json && rm -rf ./dist # should pack with destination" + "vp pm pack --json # should pack current workspace root", + "vp pm pack --recursive --json && rm -rf *.tgz # should pack all packages in workspace (uses --workspaces)", + "vp pm pack --filter app --json && rm -rf *.tgz # should pack specific package (uses --workspace app)", + "vp pm pack --filter app --filter @vite-plus-test/utils --json && rm -rf *.tgz # should pack multiple packages", + "vp pm pack --pack-destination ./dist --json && rm -rf ./dist # should pack with destination" ] } diff --git a/packages/global/snap-tests/command-pack-npm10/snap.txt b/packages/global/snap-tests/command-pack-npm10/snap.txt index b0d3137c93..d4efce7401 100644 --- a/packages/global/snap-tests/command-pack-npm10/snap.txt +++ b/packages/global/snap-tests/command-pack-npm10/snap.txt @@ -1,4 +1,4 @@ -> vite pm pack --json && rm -rf *.tgz # should pack current package +> vp pm pack --json && rm -rf *.tgz # should pack current package [ { "id": "command-pack-npm10@", @@ -10,6 +10,11 @@ "integrity": "sha512-", "filename": "command-pack-npm10-1.0.0.tgz", "files": [ + { + "path": ".node-version", + "size": , + "mode": 420 + }, { "path": "output.log", "size": , @@ -31,12 +36,12 @@ "mode": 420 } ], - "entryCount": 4, + "entryCount": 5, "bundled": [] } ] -> vite pm pack --pack-destination ./dist --json && rm -rf ./dist # should pack with destination +> vp pm pack --pack-destination ./dist --json && rm -rf ./dist # should pack with destination [ { "id": "command-pack-npm10@", @@ -48,6 +53,11 @@ "integrity": "sha512-", "filename": "command-pack-npm10-1.0.0.tgz", "files": [ + { + "path": ".node-version", + "size": , + "mode": 420 + }, { "path": "command-pack-npm10-1.0.0.tgz", "size": , @@ -74,12 +84,12 @@ "mode": 420 } ], - "entryCount": 5, + "entryCount": 6, "bundled": [] } ] -> vite pm pack --json -- --loglevel=warn && rm -rf *.tgz # should support pass through arguments +> vp pm pack --json -- --loglevel=warn && rm -rf *.tgz # should support pass through arguments [ { "id": "command-pack-npm10@", @@ -91,6 +101,11 @@ "integrity": "sha512-", "filename": "command-pack-npm10-1.0.0.tgz", "files": [ + { + "path": ".node-version", + "size": , + "mode": 420 + }, { "path": "command-pack-npm10-1.0.0.tgz", "size": , @@ -117,7 +132,7 @@ "mode": 420 } ], - "entryCount": 5, + "entryCount": 6, "bundled": [] } ] diff --git a/packages/global/snap-tests/command-pack-npm10/steps.json b/packages/global/snap-tests/command-pack-npm10/steps.json index 7e73da971c..2b09f6b231 100644 --- a/packages/global/snap-tests/command-pack-npm10/steps.json +++ b/packages/global/snap-tests/command-pack-npm10/steps.json @@ -4,8 +4,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm pack --json && rm -rf *.tgz # should pack current package", - "vite pm pack --pack-destination ./dist --json && rm -rf ./dist # should pack with destination", - "vite pm pack --json -- --loglevel=warn && rm -rf *.tgz # should support pass through arguments" + "vp pm pack --json && rm -rf *.tgz # should pack current package", + "vp pm pack --pack-destination ./dist --json && rm -rf ./dist # should pack with destination", + "vp pm pack --json -- --loglevel=warn && rm -rf *.tgz # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-pack-pnpm10-with-workspace/snap.txt b/packages/global/snap-tests/command-pack-pnpm10-with-workspace/snap.txt index a4b2577d87..cb858c8d43 100644 --- a/packages/global/snap-tests/command-pack-pnpm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-pack-pnpm10-with-workspace/snap.txt @@ -1,6 +1,7 @@ -> vite pm pack && rm -rf *.tgz # should pack current workspace root +> vp pm pack && rm -rf *.tgz # should pack current workspace root 📦 command-pack-pnpm10-with-workspace@ Tarball Contents +.node-version output.log package.json packages/app/package.json @@ -11,7 +12,7 @@ steps.json Tarball Details command-pack-pnpm10-with-workspace-1.0.0.tgz -> vite pm pack --recursive --json > out.json && tool json-sort out.json '_.name' && cat out.json && rm -rf *.tgz # should pack all packages in workspace +> vp pm pack --recursive --json > out.json && tool json-sort out.json '_.name' && cat out.json && rm -rf *.tgz # should pack all packages in workspace [ { "name": "@vite-plus-test/utils", @@ -38,6 +39,9 @@ command-pack-pnpm10-with-workspace-1.0.0.tgz "version": "1.0.0", "filename": "command-pack-pnpm10-with-workspace-1.0.0.tgz", "files": [ + { + "path": ".node-version" + }, { "path": "command-pack-pnpm10-with-workspace-1.0.0.tgz" }, @@ -69,14 +73,14 @@ command-pack-pnpm10-with-workspace-1.0.0.tgz } ] -> vite pm pack --filter app && rm -rf *.tgz # should pack specific package (uses --filter app pack) +> vp pm pack --filter app && rm -rf *.tgz # should pack specific package (uses --filter app pack) 📦 app@ Tarball Contents package.json Tarball Details /app-1.0.0.tgz -> vite pm pack --filter app --filter @vite-plus-test/utils --json > out.json && tool json-sort out.json '_.name' && cat out.json && rm -rf *.tgz # should pack multiple packages +> vp pm pack --filter app --filter @vite-plus-test/utils --json > out.json && tool json-sort out.json '_.name' && cat out.json && rm -rf *.tgz # should pack multiple packages [ { "name": "@vite-plus-test/utils", @@ -100,9 +104,10 @@ Tarball Details } ] -> vite pm pack --out ./dist/package.tgz && rm -rf ./dist # should pack with output file +> vp pm pack --out ./dist/package.tgz && rm -rf ./dist # should pack with output file 📦 command-pack-pnpm10-with-workspace@ Tarball Contents +.node-version app-1.0.0.tgz command-pack-pnpm10-with-workspace-1.0.0.tgz out.json @@ -117,9 +122,10 @@ vite-plus-test-utils-1.0.0.tgz Tarball Details /dist/package.tgz -> vite pm pack --pack-destination ./dist && rm -rf ./dist # should pack with destination +> vp pm pack --pack-destination ./dist && rm -rf ./dist # should pack with destination 📦 command-pack-pnpm10-with-workspace@ Tarball Contents +.node-version app-1.0.0.tgz command-pack-pnpm10-with-workspace-1.0.0.tgz out.json @@ -134,9 +140,10 @@ vite-plus-test-utils-1.0.0.tgz Tarball Details /dist/command-pack-pnpm10-with-workspace-1.0.0.tgz -> vite pm pack --pack-gzip-level 9 && rm -rf *.tgz # should pack with gzip compression level +> vp pm pack --pack-gzip-level 9 && rm -rf *.tgz # should pack with gzip compression level 📦 command-pack-pnpm10-with-workspace@ Tarball Contents +.node-version app-1.0.0.tgz command-pack-pnpm10-with-workspace-1.0.0.tgz out.json @@ -151,12 +158,15 @@ vite-plus-test-utils-1.0.0.tgz Tarball Details command-pack-pnpm10-with-workspace-1.0.0.tgz -> vite pm pack --json --out 'foo-%s-%v.tgz' && rm -rf *.tgz # should pack with json output +> vp pm pack --json --out 'foo-%s-%v.tgz' && rm -rf *.tgz # should pack with json output { "name": "command-pack-pnpm10-with-workspace", "version": "1.0.0", "filename": "foo-command-pack-pnpm10-with-workspace-1.0.0.tgz", "files": [ + { + "path": ".node-version" + }, { "path": "app-1.0.0.tgz" }, diff --git a/packages/global/snap-tests/command-pack-pnpm10-with-workspace/steps.json b/packages/global/snap-tests/command-pack-pnpm10-with-workspace/steps.json index bbd72352ca..8c69ae20b7 100644 --- a/packages/global/snap-tests/command-pack-pnpm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-pack-pnpm10-with-workspace/steps.json @@ -4,13 +4,13 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm pack && rm -rf *.tgz # should pack current workspace root", - "vite pm pack --recursive --json > out.json && tool json-sort out.json '_.name' && cat out.json && rm -rf *.tgz # should pack all packages in workspace", - "vite pm pack --filter app && rm -rf *.tgz # should pack specific package (uses --filter app pack)", - "vite pm pack --filter app --filter @vite-plus-test/utils --json > out.json && tool json-sort out.json '_.name' && cat out.json && rm -rf *.tgz # should pack multiple packages", - "vite pm pack --out ./dist/package.tgz && rm -rf ./dist # should pack with output file", - "vite pm pack --pack-destination ./dist && rm -rf ./dist # should pack with destination", - "vite pm pack --pack-gzip-level 9 && rm -rf *.tgz # should pack with gzip compression level", - "vite pm pack --json --out 'foo-%s-%v.tgz' && rm -rf *.tgz # should pack with json output" + "vp pm pack && rm -rf *.tgz # should pack current workspace root", + "vp pm pack --recursive --json > out.json && tool json-sort out.json '_.name' && cat out.json && rm -rf *.tgz # should pack all packages in workspace", + "vp pm pack --filter app && rm -rf *.tgz # should pack specific package (uses --filter app pack)", + "vp pm pack --filter app --filter @vite-plus-test/utils --json > out.json && tool json-sort out.json '_.name' && cat out.json && rm -rf *.tgz # should pack multiple packages", + "vp pm pack --out ./dist/package.tgz && rm -rf ./dist # should pack with output file", + "vp pm pack --pack-destination ./dist && rm -rf ./dist # should pack with destination", + "vp pm pack --pack-gzip-level 9 && rm -rf *.tgz # should pack with gzip compression level", + "vp pm pack --json --out 'foo-%s-%v.tgz' && rm -rf *.tgz # should pack with json output" ] } diff --git a/packages/global/snap-tests/command-pack-pnpm10/snap.txt b/packages/global/snap-tests/command-pack-pnpm10/snap.txt index 5ef40ce4ee..ccdfcc03d9 100644 --- a/packages/global/snap-tests/command-pack-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-pack-pnpm10/snap.txt @@ -1,30 +1,24 @@ -> vite pm pack --help # should show help +> vp pm pack --help # should show help Create a tarball of the package -Usage: vite pm pack [OPTIONS] [-- ...] +Usage: vp pm pack [OPTIONS] [-- ...] Arguments: - [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager + [PASS_THROUGH_ARGS]... Additional arguments Options: - -r, --recursive - Pack all workspace packages - --filter - Filter packages to pack (can be used multiple times) - --out - Customizes the output path for the tarball. Use %s and %v to include the package name and version (pnpm and yarn@2+ only), e.g., %s.tgz or some-dir/%s-%v.tgz - --pack-destination - Directory where the tarball will be saved (pnpm and npm only) - --pack-gzip-level - Gzip compression level (0-9) - --json - Output in JSON format - -h, --help - Print help + -r, --recursive Pack all workspace packages + --filter Filter packages to pack + --out Output path for the tarball + --pack-destination Directory where the tarball will be saved + --pack-gzip-level Gzip compression level (0-9) + --json Output in JSON format + -h, --help Print help -> vite pm pack && rm -rf *.tgz # should pack current package +> vp pm pack && rm -rf *.tgz # should pack current package 📦 command-pack-pnpm10@ Tarball Contents +.node-version output.log package.json snap.txt @@ -32,9 +26,10 @@ steps.json Tarball Details command-pack-pnpm10-1.0.0.tgz -> vite pm pack --out ./dist/package.tgz && rm -rf ./dist # should pack with output file +> vp pm pack --out ./dist/package.tgz && rm -rf ./dist # should pack with output file 📦 command-pack-pnpm10@ Tarball Contents +.node-version command-pack-pnpm10-1.0.0.tgz output.log package.json @@ -43,9 +38,10 @@ steps.json Tarball Details /dist/package.tgz -> vite pm pack --pack-destination ./dist && rm -rf ./dist # should pack with destination +> vp pm pack --pack-destination ./dist && rm -rf ./dist # should pack with destination 📦 command-pack-pnpm10@ Tarball Contents +.node-version command-pack-pnpm10-1.0.0.tgz output.log package.json @@ -54,12 +50,15 @@ steps.json Tarball Details /dist/command-pack-pnpm10-1.0.0.tgz -> vite pm pack --json --pack-gzip-level 9 && rm -rf *.tgz # should pack with gzip compression level +> vp pm pack --json --pack-gzip-level 9 && rm -rf *.tgz # should pack with gzip compression level { "name": "command-pack-pnpm10", "version": "1.0.0", "filename": "command-pack-pnpm10-1.0.0.tgz", "files": [ + { + "path": ".node-version" + }, { "path": "command-pack-pnpm10-1.0.0.tgz" }, @@ -78,12 +77,15 @@ Tarball Details ] } -> vite pm pack --json && rm -rf *.tgz # should pack with json output +> vp pm pack --json && rm -rf *.tgz # should pack with json output { "name": "command-pack-pnpm10", "version": "1.0.0", "filename": "command-pack-pnpm10-1.0.0.tgz", "files": [ + { + "path": ".node-version" + }, { "path": "command-pack-pnpm10-1.0.0.tgz" }, @@ -102,9 +104,10 @@ Tarball Details ] } -> vite pm pack -- --loglevel=warn && rm -rf *.tgz # should support pass through arguments +> vp pm pack -- --loglevel=warn && rm -rf *.tgz # should support pass through arguments 📦 command-pack-pnpm10@ Tarball Contents +.node-version command-pack-pnpm10-1.0.0.tgz output.log package.json diff --git a/packages/global/snap-tests/command-pack-pnpm10/steps.json b/packages/global/snap-tests/command-pack-pnpm10/steps.json index 89e3c05482..27ece87f4e 100644 --- a/packages/global/snap-tests/command-pack-pnpm10/steps.json +++ b/packages/global/snap-tests/command-pack-pnpm10/steps.json @@ -4,12 +4,12 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm pack --help # should show help", - "vite pm pack && rm -rf *.tgz # should pack current package", - "vite pm pack --out ./dist/package.tgz && rm -rf ./dist # should pack with output file", - "vite pm pack --pack-destination ./dist && rm -rf ./dist # should pack with destination", - "vite pm pack --json --pack-gzip-level 9 && rm -rf *.tgz # should pack with gzip compression level", - "vite pm pack --json && rm -rf *.tgz # should pack with json output", - "vite pm pack -- --loglevel=warn && rm -rf *.tgz # should support pass through arguments" + "vp pm pack --help # should show help", + "vp pm pack && rm -rf *.tgz # should pack current package", + "vp pm pack --out ./dist/package.tgz && rm -rf ./dist # should pack with output file", + "vp pm pack --pack-destination ./dist && rm -rf ./dist # should pack with destination", + "vp pm pack --json --pack-gzip-level 9 && rm -rf *.tgz # should pack with gzip compression level", + "vp pm pack --json && rm -rf *.tgz # should pack with json output", + "vp pm pack -- --loglevel=warn && rm -rf *.tgz # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-pack-yarn4-with-workspace/snap.txt b/packages/global/snap-tests/command-pack-yarn4-with-workspace/snap.txt index 432f66a099..aa7e4e1ea2 100644 --- a/packages/global/snap-tests/command-pack-yarn4-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-pack-yarn4-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite install -- --mode=update-lockfile # should install packages first +> vp install -- --mode=update-lockfile # should install packages first ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -9,7 +9,8 @@ ➤ YN0000: └ Completed ➤ YN0000: · Done with warnings in ms ms -> vite pm pack # should pack current workspace root +> vp pm pack # should pack current workspace root +➤ YN0000: .node-version ➤ YN0000: output.log ➤ YN0000: package.json ➤ YN0000: snap.txt @@ -17,7 +18,8 @@ ➤ YN0000: Package archive generated in /package.tgz ➤ YN0000: Done in ms ms -> vite pm pack --recursive # should pack all packages in workspace (uses workspaces foreach --all pack) +> vp pm pack --recursive # should pack all packages in workspace (uses workspaces foreach --all pack) +➤ YN0000: .node-version ➤ YN0000: output.log ➤ YN0000: package.json ➤ YN0000: snap.txt @@ -32,13 +34,13 @@ ➤ YN0000: Done in ms ms Done in ms ms -> vite pm pack --filter app # should pack specific package (uses workspaces foreach --all --include app pack) +> vp pm pack --filter app # should pack specific package (uses workspaces foreach --all --include app pack) ➤ YN0000: package.json ➤ YN0000: Package archive generated in /packages/app/package.tgz ➤ YN0000: Done in ms ms Done in ms ms -> vite pm pack --filter app --filter @vite-plus-test/utils # should pack multiple packages +> vp pm pack --filter app --filter @vite-plus-test/utils # should pack multiple packages ➤ YN0000: package.json ➤ YN0000: Package archive generated in /packages/app/package.tgz ➤ YN0000: Done in ms ms @@ -47,7 +49,8 @@ Done in ms ms ➤ YN0000: Done in ms ms Done in ms ms -> vite pm pack --out ./dist/package.tgz # should pack with output file +> vp pm pack --out ./dist/package.tgz # should pack with output file +➤ YN0000: .node-version ➤ YN0000: output.log ➤ YN0000: package.json ➤ YN0000: snap.txt @@ -55,8 +58,9 @@ Done in ms ms ➤ YN0000: Package archive generated in /dist/package.tgz ➤ YN0000: Done in ms ms -> vite pm pack --json # should pack with json output +> vp pm pack --json # should pack with json output {"base":""} +{"location":".node-version"} {"location":"dist/package.tgz"} {"location":"output.log"} {"location":"package.json"} diff --git a/packages/global/snap-tests/command-pack-yarn4-with-workspace/steps.json b/packages/global/snap-tests/command-pack-yarn4-with-workspace/steps.json index 0b3b5269a4..ed5d854ae7 100644 --- a/packages/global/snap-tests/command-pack-yarn4-with-workspace/steps.json +++ b/packages/global/snap-tests/command-pack-yarn4-with-workspace/steps.json @@ -4,12 +4,12 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install -- --mode=update-lockfile # should install packages first", - "vite pm pack # should pack current workspace root", - "vite pm pack --recursive # should pack all packages in workspace (uses workspaces foreach --all pack)", - "vite pm pack --filter app # should pack specific package (uses workspaces foreach --all --include app pack)", - "vite pm pack --filter app --filter @vite-plus-test/utils # should pack multiple packages", - "vite pm pack --out ./dist/package.tgz # should pack with output file", - "vite pm pack --json # should pack with json output" + "vp install -- --mode=update-lockfile # should install packages first", + "vp pm pack # should pack current workspace root", + "vp pm pack --recursive # should pack all packages in workspace (uses workspaces foreach --all pack)", + "vp pm pack --filter app # should pack specific package (uses workspaces foreach --all --include app pack)", + "vp pm pack --filter app --filter @vite-plus-test/utils # should pack multiple packages", + "vp pm pack --out ./dist/package.tgz # should pack with output file", + "vp pm pack --json # should pack with json output" ] } diff --git a/packages/global/snap-tests/command-pack-yarn4/snap.txt b/packages/global/snap-tests/command-pack-yarn4/snap.txt index d787532b2d..4c022f9291 100644 --- a/packages/global/snap-tests/command-pack-yarn4/snap.txt +++ b/packages/global/snap-tests/command-pack-yarn4/snap.txt @@ -1,4 +1,5 @@ -> vite pm pack # should pack current package +> vp pm pack # should pack current package +➤ YN0000: .node-version ➤ YN0000: output.log ➤ YN0000: package.json ➤ YN0000: snap.txt @@ -6,7 +7,8 @@ ➤ YN0000: Package archive generated in /package.tgz ➤ YN0000: Done in ms ms -> vite pm pack --out ./dist/package.tgz # should pack with output file +> vp pm pack --out ./dist/package.tgz # should pack with output file +➤ YN0000: .node-version ➤ YN0000: output.log ➤ YN0000: package.json ➤ YN0000: snap.txt @@ -14,8 +16,9 @@ ➤ YN0000: Package archive generated in /dist/package.tgz ➤ YN0000: Done in ms ms -> vite pm pack --json # should pack with json output +> vp pm pack --json # should pack with json output {"base":""} +{"location":".node-version"} {"location":"dist/package.tgz"} {"location":"output.log"} {"location":"package.json"} @@ -23,7 +26,8 @@ {"location":"steps.json"} {"output":"/package.tgz"} -> vite pm pack -- --dry-run # should support pass through arguments +> vp pm pack -- --dry-run # should support pass through arguments +➤ YN0000: .node-version ➤ YN0000: dist/package.tgz ➤ YN0000: output.log ➤ YN0000: package.json diff --git a/packages/global/snap-tests/command-pack-yarn4/steps.json b/packages/global/snap-tests/command-pack-yarn4/steps.json index 81ed463435..20de1ec936 100644 --- a/packages/global/snap-tests/command-pack-yarn4/steps.json +++ b/packages/global/snap-tests/command-pack-yarn4/steps.json @@ -4,9 +4,9 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm pack # should pack current package", - "vite pm pack --out ./dist/package.tgz # should pack with output file", - "vite pm pack --json # should pack with json output", - "vite pm pack -- --dry-run # should support pass through arguments" + "vp pm pack # should pack current package", + "vp pm pack --out ./dist/package.tgz # should pack with output file", + "vp pm pack --json # should pack with json output", + "vp pm pack -- --dry-run # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-prune-npm10/snap.txt b/packages/global/snap-tests/command-prune-npm10/snap.txt index e2c0b5c036..16d078c962 100644 --- a/packages/global/snap-tests/command-prune-npm10/snap.txt +++ b/packages/global/snap-tests/command-prune-npm10/snap.txt @@ -1,36 +1,36 @@ -> vite install # should install packages first +> vp install # should install packages first added 3 packages in ms -> vite pm prune --help # should show help +> vp pm prune --help # should show help Remove unnecessary packages -Usage: vite pm prune [OPTIONS] [-- ...] +Usage: vp pm prune [OPTIONS] [-- ...] Arguments: - [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager + [PASS_THROUGH_ARGS]... Additional arguments Options: --prod Remove devDependencies --no-optional Remove optional dependencies -h, --help Print help -> vite pm prune # should prune extraneous dependencies +> vp pm prune # should prune extraneous dependencies up to date in ms -> vite pm prune --prod # should prune dev dependencies (uses --omit=dev) +> vp pm prune --prod # should prune dev dependencies (uses --omit=dev) up to date in ms -> vite pm prune --no-optional # should prune optional dependencies (uses --omit=optional) +> vp pm prune --no-optional # should prune optional dependencies (uses --omit=optional) added 1 package in ms -> vite pm prune --prod --no-optional # should prune both dev and optional dependencies +> vp pm prune --prod --no-optional # should prune both dev and optional dependencies up to date in ms -> vite pm prune -- --loglevel=warn # should support pass through arguments +> vp pm prune -- --loglevel=warn # should support pass through arguments added 2 packages in ms diff --git a/packages/global/snap-tests/command-prune-npm10/steps.json b/packages/global/snap-tests/command-prune-npm10/steps.json index 862ce3ffde..360dd84fa5 100644 --- a/packages/global/snap-tests/command-prune-npm10/steps.json +++ b/packages/global/snap-tests/command-prune-npm10/steps.json @@ -3,12 +3,12 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install # should install packages first", - "vite pm prune --help # should show help", - "vite pm prune # should prune extraneous dependencies", - "vite pm prune --prod # should prune dev dependencies (uses --omit=dev)", - "vite pm prune --no-optional # should prune optional dependencies (uses --omit=optional)", - "vite pm prune --prod --no-optional # should prune both dev and optional dependencies", - "vite pm prune -- --loglevel=warn # should support pass through arguments" + "vp install # should install packages first", + "vp pm prune --help # should show help", + "vp pm prune # should prune extraneous dependencies", + "vp pm prune --prod # should prune dev dependencies (uses --omit=dev)", + "vp pm prune --no-optional # should prune optional dependencies (uses --omit=optional)", + "vp pm prune --prod --no-optional # should prune both dev and optional dependencies", + "vp pm prune -- --loglevel=warn # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-prune-pnpm10/snap.txt b/packages/global/snap-tests/command-prune-pnpm10/snap.txt index 348891e2c3..43150ae99a 100644 --- a/packages/global/snap-tests/command-prune-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-prune-pnpm10/snap.txt @@ -1,4 +1,4 @@ -> vite install # should install packages first +> vp install # should install packages first Packages: + + Progress: resolved , reused , downloaded , added , done @@ -14,20 +14,20 @@ devDependencies: Done in ms using pnpm v -> vite pm prune --help # should show help +> vp pm prune --help # should show help Remove unnecessary packages -Usage: vite pm prune [OPTIONS] [-- ...] +Usage: vp pm prune [OPTIONS] [-- ...] Arguments: - [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager + [PASS_THROUGH_ARGS]... Additional arguments Options: --prod Remove devDependencies --no-optional Remove optional dependencies -h, --help Print help -> vite pm prune && cat package.json # should prune extraneous dependencies +> vp pm prune && cat package.json # should prune extraneous dependencies Lockfile is up to date, resolution step is skipped Already up to date @@ -46,7 +46,7 @@ Already up to date "packageManager": "pnpm@" } -> vite pm prune --prod && cat package.json # should prune dev dependencies +> vp pm prune --prod && cat package.json # should prune dev dependencies Lockfile is up to date, resolution step is skipped Packages: -1 - @@ -69,7 +69,7 @@ devDependencies: "packageManager": "pnpm@" } -> vite pm prune --no-optional && cat package.json # should prune optional dependencies +> vp pm prune --no-optional && cat package.json # should prune optional dependencies Lockfile is up to date, resolution step is skipped Packages: -1 - @@ -96,7 +96,7 @@ devDependencies: "packageManager": "pnpm@" } -> vite pm prune --prod --no-optional && cat package.json # should prune both dev and optional dependencies +> vp pm prune --prod --no-optional && cat package.json # should prune both dev and optional dependencies Lockfile is up to date, resolution step is skipped Packages: -1 - @@ -121,7 +121,7 @@ devDependencies: "packageManager": "pnpm@" } -> vite pm prune -- --loglevel=warn && cat package.json # should support pass through arguments +> vp pm prune -- --loglevel=warn && cat package.json # should support pass through arguments { "name": "command-prune-pnpm10", "version": "1.0.0", diff --git a/packages/global/snap-tests/command-prune-pnpm10/steps.json b/packages/global/snap-tests/command-prune-pnpm10/steps.json index 12e36ca597..3e624e2aa5 100644 --- a/packages/global/snap-tests/command-prune-pnpm10/steps.json +++ b/packages/global/snap-tests/command-prune-pnpm10/steps.json @@ -3,12 +3,12 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install # should install packages first", - "vite pm prune --help # should show help", - "vite pm prune && cat package.json # should prune extraneous dependencies", - "vite pm prune --prod && cat package.json # should prune dev dependencies", - "vite pm prune --no-optional && cat package.json # should prune optional dependencies", - "vite pm prune --prod --no-optional && cat package.json # should prune both dev and optional dependencies", - "vite pm prune -- --loglevel=warn && cat package.json # should support pass through arguments" + "vp install # should install packages first", + "vp pm prune --help # should show help", + "vp pm prune && cat package.json # should prune extraneous dependencies", + "vp pm prune --prod && cat package.json # should prune dev dependencies", + "vp pm prune --no-optional && cat package.json # should prune optional dependencies", + "vp pm prune --prod --no-optional && cat package.json # should prune both dev and optional dependencies", + "vp pm prune -- --loglevel=warn && cat package.json # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-prune-yarn4/snap.txt b/packages/global/snap-tests/command-prune-yarn4/snap.txt index 943a6ad875..196dce43c5 100644 --- a/packages/global/snap-tests/command-prune-yarn4/snap.txt +++ b/packages/global/snap-tests/command-prune-yarn4/snap.txt @@ -1,15 +1,15 @@ -> vite pm prune --help # should show help +> vp pm prune --help # should show help Remove unnecessary packages -Usage: vite pm prune [OPTIONS] [-- ...] +Usage: vp pm prune [OPTIONS] [-- ...] Arguments: - [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager + [PASS_THROUGH_ARGS]... Additional arguments Options: --prod Remove devDependencies --no-optional Remove optional dependencies -h, --help Print help -> vite pm prune # should show warning that yarn does not support prune command +> vp pm prune # should show warning that yarn does not support prune command Warning: yarn does not have 'prune' command. yarn install will prune extraneous packages automatically. diff --git a/packages/global/snap-tests/command-prune-yarn4/steps.json b/packages/global/snap-tests/command-prune-yarn4/steps.json index b90fc886e8..244a4c4505 100644 --- a/packages/global/snap-tests/command-prune-yarn4/steps.json +++ b/packages/global/snap-tests/command-prune-yarn4/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm prune --help # should show help", - "vite pm prune # should show warning that yarn does not support prune command" + "vp pm prune --help # should show help", + "vp pm prune # should show warning that yarn does not support prune command" ] } diff --git a/packages/global/snap-tests/command-publish-npm10/snap.txt b/packages/global/snap-tests/command-publish-npm10/snap.txt index 3c6cad5c62..6c0d0ca7ec 100644 --- a/packages/global/snap-tests/command-publish-npm10/snap.txt +++ b/packages/global/snap-tests/command-publish-npm10/snap.txt @@ -1,2 +1,2 @@ -> vite pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run) +> vp pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run) + command-publish-npm10@ diff --git a/packages/global/snap-tests/command-publish-npm10/steps.json b/packages/global/snap-tests/command-publish-npm10/steps.json index b92268e194..748e0719e2 100644 --- a/packages/global/snap-tests/command-publish-npm10/steps.json +++ b/packages/global/snap-tests/command-publish-npm10/steps.json @@ -3,6 +3,6 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run)" + "vp pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run)" ] } diff --git a/packages/global/snap-tests/command-publish-pnpm10/snap.txt b/packages/global/snap-tests/command-publish-pnpm10/snap.txt index 5595c63391..8a9e43aaea 100644 --- a/packages/global/snap-tests/command-publish-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-publish-pnpm10/snap.txt @@ -1,25 +1,25 @@ -> vite pm publish --help # should show help +> vp pm publish --help # should show help Publish package to registry -Usage: vite pm publish [OPTIONS] [TARBALL|FOLDER] [-- ...] +Usage: vp pm publish [OPTIONS] [TARBALL|FOLDER] [-- ...] Arguments: [TARBALL|FOLDER] Tarball or folder to publish - [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager + [PASS_THROUGH_ARGS]... Additional arguments Options: --dry-run Preview without publishing - --tag Publish tag (default: latest) + --tag Publish tag --access Access level (public/restricted) --otp One-time password for authentication - --no-git-checks Skip git checks (pnpm-specific) - --publish-branch Set the branch name to publish from (pnpm-specific) - --report-summary Save publish summary to pnpm-publish-summary.json (pnpm-specific) + --no-git-checks Skip git checks + --publish-branch Set the branch name to publish from + --report-summary Save publish summary --force Force publish - --json Output in JSON format (pnpm-specific) + --json Output in JSON format -r, --recursive Publish all workspace packages - --filter Filter packages in monorepo (can be used multiple times) + --filter Filter packages in monorepo -h, --help Print help -> vite pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses pnpm publish --dry-run) +> vp pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses pnpm publish --dry-run) + command-publish-pnpm10@ diff --git a/packages/global/snap-tests/command-publish-pnpm10/steps.json b/packages/global/snap-tests/command-publish-pnpm10/steps.json index 80b1dd3710..d1d096114c 100644 --- a/packages/global/snap-tests/command-publish-pnpm10/steps.json +++ b/packages/global/snap-tests/command-publish-pnpm10/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm publish --help # should show help", - "vite pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses pnpm publish --dry-run)" + "vp pm publish --help # should show help", + "vp pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses pnpm publish --dry-run)" ] } diff --git a/packages/global/snap-tests/command-publish-yarn1/snap.txt b/packages/global/snap-tests/command-publish-yarn1/snap.txt index 3f61ee1e20..c0bbc9a3b4 100644 --- a/packages/global/snap-tests/command-publish-yarn1/snap.txt +++ b/packages/global/snap-tests/command-publish-yarn1/snap.txt @@ -1,2 +1,2 @@ -> vite pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run) +> vp pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run) + command-publish-yarn1@ diff --git a/packages/global/snap-tests/command-publish-yarn1/steps.json b/packages/global/snap-tests/command-publish-yarn1/steps.json index b92268e194..748e0719e2 100644 --- a/packages/global/snap-tests/command-publish-yarn1/steps.json +++ b/packages/global/snap-tests/command-publish-yarn1/steps.json @@ -3,6 +3,6 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run)" + "vp pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run)" ] } diff --git a/packages/global/snap-tests/command-publish-yarn4/snap.txt b/packages/global/snap-tests/command-publish-yarn4/snap.txt index 7feb5f35bb..d5143b5500 100644 --- a/packages/global/snap-tests/command-publish-yarn4/snap.txt +++ b/packages/global/snap-tests/command-publish-yarn4/snap.txt @@ -1,2 +1,2 @@ -> vite pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run) +> vp pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run) + command-publish-yarn4@ diff --git a/packages/global/snap-tests/command-publish-yarn4/steps.json b/packages/global/snap-tests/command-publish-yarn4/steps.json index b92268e194..748e0719e2 100644 --- a/packages/global/snap-tests/command-publish-yarn4/steps.json +++ b/packages/global/snap-tests/command-publish-yarn4/steps.json @@ -3,6 +3,6 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run)" + "vp pm publish --dry-run -- --loglevel error # should preview publish without actually publishing (uses npm publish --dry-run)" ] } diff --git a/packages/global/snap-tests/command-remove-npm10-with-workspace/snap.txt b/packages/global/snap-tests/command-remove-npm10-with-workspace/snap.txt index e3b8c70f92..a965a744ff 100644 --- a/packages/global/snap-tests/command-remove-npm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-remove-npm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite add testnpm2 -D -w --filter=* -- --no-audit && vite add test-vite-plus-install -w --filter=* -- --no-audit && vite add test-vite-plus-package-optional -O --filter=* -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # prepare packages +> vp add testnpm2 -D -w --filter=* -- --no-audit && vp add test-vite-plus-install -w --filter=* -- --no-audit && vp add test-vite-plus-package-optional -O --filter=* -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # prepare packages added 3 packages in ms @@ -46,7 +46,7 @@ added 1 package in ms } } -> vite remove testnpm2 -r -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package from all workspaces and root +> vp remove testnpm2 -r -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package from all workspaces and root removed 1 package in ms { @@ -81,7 +81,7 @@ removed 1 package in ms } } -> vite remove -O test-vite-plus-package-optional -r -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove optional package from all workspaces +> vp remove -O test-vite-plus-package-optional -r -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove optional package from all workspaces removed 1 package in ms { @@ -110,7 +110,7 @@ removed 1 package in ms } } -> vite remove test-vite-plus-install --filter=app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=app +> vp remove test-vite-plus-install --filter=app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=app up to date in ms { @@ -136,7 +136,7 @@ up to date in ms } } -> vite remove test-vite-plus-install --filter=* -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=* +> vp remove test-vite-plus-install --filter=* -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=* up to date in ms { diff --git a/packages/global/snap-tests/command-remove-npm10-with-workspace/steps.json b/packages/global/snap-tests/command-remove-npm10-with-workspace/steps.json index 5afb98a34c..a0b369385e 100644 --- a/packages/global/snap-tests/command-remove-npm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-remove-npm10-with-workspace/steps.json @@ -4,10 +4,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add testnpm2 -D -w --filter=* -- --no-audit && vite add test-vite-plus-install -w --filter=* -- --no-audit && vite add test-vite-plus-package-optional -O --filter=* -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # prepare packages", - "vite remove testnpm2 -r -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package from all workspaces and root", - "vite remove -O test-vite-plus-package-optional -r -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove optional package from all workspaces", - "vite remove test-vite-plus-install --filter=app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=app", - "vite remove test-vite-plus-install --filter=* -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=*" + "vp add testnpm2 -D -w --filter=* -- --no-audit && vp add test-vite-plus-install -w --filter=* -- --no-audit && vp add test-vite-plus-package-optional -O --filter=* -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # prepare packages", + "vp remove testnpm2 -r -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package from all workspaces and root", + "vp remove -O test-vite-plus-package-optional -r -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove optional package from all workspaces", + "vp remove test-vite-plus-install --filter=app -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=app", + "vp remove test-vite-plus-install --filter=* -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=*" ] } diff --git a/packages/global/snap-tests/command-remove-npm10/snap.txt b/packages/global/snap-tests/command-remove-npm10/snap.txt index b5bf5c5c46..6d228daabf 100644 --- a/packages/global/snap-tests/command-remove-npm10/snap.txt +++ b/packages/global/snap-tests/command-remove-npm10/snap.txt @@ -1,4 +1,4 @@ -> vite remove testnpm2 -D -- --no-audit && cat package.json # should pass when remove not exists package +> vp remove testnpm2 -D -- --no-audit && cat package.json # should pass when remove not exists package up to date in ms { @@ -7,7 +7,7 @@ up to date in ms "packageManager": "npm@" } -> vite add testnpm2 -- --no-audit && vite add -D test-vite-plus-install -- --no-audit && vite add -O test-vite-plus-package-optional -- --no-audit && cat package.json # should add packages to dependencies +> vp add testnpm2 -- --no-audit && vp add -D test-vite-plus-install -- --no-audit && vp add -O test-vite-plus-package-optional -- --no-audit && cat package.json # should add packages to dependencies added 1 package in ms @@ -29,7 +29,7 @@ added 1 package in ms } } -> vite remove testnpm2 test-vite-plus-install -- --no-audit && cat package.json # should remove packages from dependencies +> vp remove testnpm2 test-vite-plus-install -- --no-audit && cat package.json # should remove packages from dependencies removed 2 packages in ms { @@ -41,7 +41,7 @@ removed 2 packages in ms } } -> vite remove -D test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support ignore -O flag and remove package from optional dependencies +> vp remove -D test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support ignore -O flag and remove package from optional dependencies removed 1 package in ms { @@ -50,7 +50,7 @@ removed 1 package in ms "packageManager": "npm@" } -> vite remove -g testnpm2 -- --dry-run --no-audit && cat package.json # support remove global package with dry-run +> vp remove -g testnpm2 -- --dry-run --no-audit && cat package.json # support remove global package with dry-run up to date in ms { diff --git a/packages/global/snap-tests/command-remove-npm10/steps.json b/packages/global/snap-tests/command-remove-npm10/steps.json index d7cbc370b1..dd708e924d 100644 --- a/packages/global/snap-tests/command-remove-npm10/steps.json +++ b/packages/global/snap-tests/command-remove-npm10/steps.json @@ -4,10 +4,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite remove testnpm2 -D -- --no-audit && cat package.json # should pass when remove not exists package", - "vite add testnpm2 -- --no-audit && vite add -D test-vite-plus-install -- --no-audit && vite add -O test-vite-plus-package-optional -- --no-audit && cat package.json # should add packages to dependencies", - "vite remove testnpm2 test-vite-plus-install -- --no-audit && cat package.json # should remove packages from dependencies", - "vite remove -D test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support ignore -O flag and remove package from optional dependencies", - "vite remove -g testnpm2 -- --dry-run --no-audit && cat package.json # support remove global package with dry-run" + "vp remove testnpm2 -D -- --no-audit && cat package.json # should pass when remove not exists package", + "vp add testnpm2 -- --no-audit && vp add -D test-vite-plus-install -- --no-audit && vp add -O test-vite-plus-package-optional -- --no-audit && cat package.json # should add packages to dependencies", + "vp remove testnpm2 test-vite-plus-install -- --no-audit && cat package.json # should remove packages from dependencies", + "vp remove -D test-vite-plus-package-optional -- --loglevel=warn --no-audit && cat package.json # support ignore -O flag and remove package from optional dependencies", + "vp remove -g testnpm2 -- --dry-run --no-audit && cat package.json # support remove global package with dry-run" ] } diff --git a/packages/global/snap-tests/command-remove-pnpm10-with-workspace/snap.txt b/packages/global/snap-tests/command-remove-pnpm10-with-workspace/snap.txt index 024d961e34..be0271f22f 100644 --- a/packages/global/snap-tests/command-remove-pnpm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-remove-pnpm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite add testnpm2 -D -w --filter=* && vite add test-vite-plus-install -w --filter=* && vite add test-vite-plus-package-optional -O --filter=* && cat package.json packages/app/package.json packages/utils/package.json # prepare packages +> vp add testnpm2 -D -w --filter=* && vp add test-vite-plus-install -w --filter=* && vp add test-vite-plus-package-optional -O --filter=* && cat package.json packages/app/package.json packages/utils/package.json # prepare packages . | +1 + Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v @@ -46,7 +46,7 @@ Done in ms using pnpm v } } -> vite remove testnpm2 -r && cat package.json packages/app/package.json packages/utils/package.json # should remove package from all workspaces and root +> vp remove testnpm2 -r && cat package.json packages/app/package.json packages/utils/package.json # should remove package from all workspaces and root Scope: all workspace projects . | -1 - Progress: resolved , reused , downloaded , added , done @@ -80,7 +80,7 @@ Done in ms using pnpm v } } -> vite remove -O test-vite-plus-package-optional -r && cat package.json packages/app/package.json packages/utils/package.json # should remove optional package from all workspaces +> vp remove -O test-vite-plus-package-optional -r && cat package.json packages/app/package.json packages/utils/package.json # should remove optional package from all workspaces Scope: all workspace projects . | -1 - Progress: resolved , reused , downloaded , added , done @@ -108,7 +108,7 @@ Done in ms using pnpm v } } -> vite remove test-vite-plus-install --filter=app && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=app +> vp remove test-vite-plus-install --filter=app && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=app . |  WARN  `node_modules` is present. Lockfile only installation will make it out-of-date Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v @@ -132,7 +132,7 @@ Done in ms using pnpm v } } -> vite remove test-vite-plus-install --filter=* && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=* +> vp remove test-vite-plus-install --filter=* && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=* Scope: all workspace projects . | -1 - Done in ms using pnpm v diff --git a/packages/global/snap-tests/command-remove-pnpm10-with-workspace/steps.json b/packages/global/snap-tests/command-remove-pnpm10-with-workspace/steps.json index 4b0b5457d4..0175729633 100644 --- a/packages/global/snap-tests/command-remove-pnpm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-remove-pnpm10-with-workspace/steps.json @@ -4,10 +4,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add testnpm2 -D -w --filter=* && vite add test-vite-plus-install -w --filter=* && vite add test-vite-plus-package-optional -O --filter=* && cat package.json packages/app/package.json packages/utils/package.json # prepare packages", - "vite remove testnpm2 -r && cat package.json packages/app/package.json packages/utils/package.json # should remove package from all workspaces and root", - "vite remove -O test-vite-plus-package-optional -r && cat package.json packages/app/package.json packages/utils/package.json # should remove optional package from all workspaces", - "vite remove test-vite-plus-install --filter=app && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=app", - "vite remove test-vite-plus-install --filter=* && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=*" + "vp add testnpm2 -D -w --filter=* && vp add test-vite-plus-install -w --filter=* && vp add test-vite-plus-package-optional -O --filter=* && cat package.json packages/app/package.json packages/utils/package.json # prepare packages", + "vp remove testnpm2 -r && cat package.json packages/app/package.json packages/utils/package.json # should remove package from all workspaces and root", + "vp remove -O test-vite-plus-package-optional -r && cat package.json packages/app/package.json packages/utils/package.json # should remove optional package from all workspaces", + "vp remove test-vite-plus-install --filter=app && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=app", + "vp remove test-vite-plus-install --filter=* && cat package.json packages/app/package.json packages/utils/package.json # should remove package by filter=*" ] } diff --git a/packages/global/snap-tests/command-remove-pnpm10/snap.txt b/packages/global/snap-tests/command-remove-pnpm10/snap.txt index e387efb15f..69f9f9a7de 100644 --- a/packages/global/snap-tests/command-remove-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-remove-pnpm10/snap.txt @@ -1,7 +1,7 @@ -> vite remove --help # should show help +> vp remove --help # should show help Remove packages from dependencies -Usage: vite remove [OPTIONS] ... [-- ...] +Usage: vp remove [OPTIONS] ... [-- ...] Arguments: ... Packages to remove @@ -13,22 +13,22 @@ Options: -P, --save-prod Only remove from `dependencies` (pnpm-specific) --filter Filter packages in monorepo (can be used multiple times) -w, --workspace-root Remove from workspace root - -r, --recursive Remove recursively from all workspace packages, including workspace root + -r, --recursive Remove recursively from all workspace packages -g, --global Remove global packages -h, --help Print help -[2]> vite remove # should error because no packages specified +[2]> vp remove # should error because no packages specified error: the following required arguments were not provided: ... -Usage: vite remove ... [-- ...] +Usage: vp remove ... [-- ...] For more information, try '--help'. -[1]> vite remove testnpm2 -D && cat package.json # should error when remove not exists package from dev dependencies +[1]> vp remove testnpm2 -D && cat package.json # should error when remove not exists package from dev dependencies  ERR_PNPM_CANNOT_REMOVE_MISSING_DEPS  Cannot remove 'testnpm2': project has no 'devDependencies' -> vite add testnpm2 && vite add -D test-vite-plus-install && vite add -O test-vite-plus-package-optional && cat package.json # should add packages to dependencies +> vp add testnpm2 && vp add -D test-vite-plus-install && vp add -O test-vite-plus-package-optional && cat package.json # should add packages to dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -68,7 +68,7 @@ Done in ms using pnpm v } } -> vite remove testnpm2 test-vite-plus-install && cat package.json # should remove packages from dependencies +> vp remove testnpm2 test-vite-plus-install && cat package.json # should remove packages from dependencies Packages: -2 -- Progress: resolved , reused , downloaded , added , done @@ -89,14 +89,14 @@ Done in ms using pnpm v } } -> vite remove -O test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support remove package from optional dependencies and pass through arguments +> vp remove -O test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support remove package from optional dependencies and pass through arguments { "name": "command-remove-pnpm10", "version": "1.0.0", "packageManager": "pnpm@" } -> vite remove -g testnpm2 -- --dry-run && cat package.json # support remove global package with dry-run +> vp remove -g testnpm2 -- --dry-run && cat package.json # support remove global package with dry-run up to date in ms { @@ -105,11 +105,11 @@ up to date in ms "packageManager": "pnpm@" } -[2]> vite rm --stream foo && should show tips to use pass through arguments when options are not supported +[2]> vp rm --stream foo && should show tips to use pass through arguments when options are not supported error: unexpected argument '--stream' found tip: to pass '--stream' as a value, use '-- --stream' -Usage: vite remove [OPTIONS] ... [-- ...] +Usage: vp remove [OPTIONS] ... [-- ...] For more information, try '--help'. diff --git a/packages/global/snap-tests/command-remove-pnpm10/steps.json b/packages/global/snap-tests/command-remove-pnpm10/steps.json index 48e6f52e78..797fdc0b73 100644 --- a/packages/global/snap-tests/command-remove-pnpm10/steps.json +++ b/packages/global/snap-tests/command-remove-pnpm10/steps.json @@ -4,13 +4,13 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite remove --help # should show help", - "vite remove # should error because no packages specified", - "vite remove testnpm2 -D && cat package.json # should error when remove not exists package from dev dependencies", - "vite add testnpm2 && vite add -D test-vite-plus-install && vite add -O test-vite-plus-package-optional && cat package.json # should add packages to dependencies", - "vite remove testnpm2 test-vite-plus-install && cat package.json # should remove packages from dependencies", - "vite remove -O test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support remove package from optional dependencies and pass through arguments", - "vite remove -g testnpm2 -- --dry-run && cat package.json # support remove global package with dry-run", - "vite rm --stream foo && should show tips to use pass through arguments when options are not supported" + "vp remove --help # should show help", + "vp remove # should error because no packages specified", + "vp remove testnpm2 -D && cat package.json # should error when remove not exists package from dev dependencies", + "vp add testnpm2 && vp add -D test-vite-plus-install && vp add -O test-vite-plus-package-optional && cat package.json # should add packages to dependencies", + "vp remove testnpm2 test-vite-plus-install && cat package.json # should remove packages from dependencies", + "vp remove -O test-vite-plus-package-optional -- --loglevel=warn && cat package.json # support remove package from optional dependencies and pass through arguments", + "vp remove -g testnpm2 -- --dry-run && cat package.json # support remove global package with dry-run", + "vp rm --stream foo && should show tips to use pass through arguments when options are not supported" ] } diff --git a/packages/global/snap-tests/command-remove-yarn4-with-workspace/snap.txt b/packages/global/snap-tests/command-remove-yarn4-with-workspace/snap.txt index 76738451bf..7978c0c77d 100644 --- a/packages/global/snap-tests/command-remove-yarn4-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-remove-yarn4-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite add testnpm2 -D && vite add testnpm2 -D --filter=* --filter=@vite-plus-test/utils && vite add test-vite-plus-install --filter=* --filter=@vite-plus-test/utils && vite add test-vite-plus-package-optional -O --filter=* --filter=@vite-plus-test/utils && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # prepare packages +> vp add testnpm2 -D && vp add testnpm2 -D --filter=* --filter=@vite-plus-test/utils && vp add test-vite-plus-install --filter=* --filter=@vite-plus-test/utils && vp add test-vite-plus-package-optional -O --filter=* --filter=@vite-plus-test/utils && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # prepare packages ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + testnpm2@npm:1.0.1 @@ -164,7 +164,7 @@ Done in ms ms } } -> vite remove testnpm2 -r && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package from all workspaces and root +> vp remove testnpm2 -r && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package from all workspaces and root ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ - testnpm2@npm:1.0.1 @@ -217,7 +217,7 @@ Done in ms ms } } -> vite remove -O test-vite-plus-package-optional -r && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove optional package from all workspaces +> vp remove -O test-vite-plus-package-optional -r && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove optional package from all workspaces ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ - test-vite-plus-package-optional@npm:1.0.0 @@ -258,7 +258,7 @@ Done in ms ms } } -> vite remove test-vite-plus-install --filter=app && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package by filter=app +> vp remove test-vite-plus-install --filter=app && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package by filter=app ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -296,7 +296,7 @@ Done in ms ms } } -> vite add test-vite-plus-install --filter=app && vite remove test-vite-plus-install --filter=* && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package by filter=* +> vp add test-vite-plus-install --filter=app && vp remove test-vite-plus-install --filter=* && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package by filter=* ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed diff --git a/packages/global/snap-tests/command-remove-yarn4-with-workspace/steps.json b/packages/global/snap-tests/command-remove-yarn4-with-workspace/steps.json index 503855f015..d16264681d 100644 --- a/packages/global/snap-tests/command-remove-yarn4-with-workspace/steps.json +++ b/packages/global/snap-tests/command-remove-yarn4-with-workspace/steps.json @@ -4,10 +4,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite add testnpm2 -D && vite add testnpm2 -D --filter=* --filter=@vite-plus-test/utils && vite add test-vite-plus-install --filter=* --filter=@vite-plus-test/utils && vite add test-vite-plus-package-optional -O --filter=* --filter=@vite-plus-test/utils && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # prepare packages", - "vite remove testnpm2 -r && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package from all workspaces and root", - "vite remove -O test-vite-plus-package-optional -r && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove optional package from all workspaces", - "vite remove test-vite-plus-install --filter=app && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package by filter=app", - "vite add test-vite-plus-install --filter=app && vite remove test-vite-plus-install --filter=* && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package by filter=*" + "vp add testnpm2 -D && vp add testnpm2 -D --filter=* --filter=@vite-plus-test/utils && vp add test-vite-plus-install --filter=* --filter=@vite-plus-test/utils && vp add test-vite-plus-package-optional -O --filter=* --filter=@vite-plus-test/utils && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # prepare packages", + "vp remove testnpm2 -r && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package from all workspaces and root", + "vp remove -O test-vite-plus-package-optional -r && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove optional package from all workspaces", + "vp remove test-vite-plus-install --filter=app && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package by filter=app", + "vp add test-vite-plus-install --filter=app && vp remove test-vite-plus-install --filter=* && cat package.json packages/app/package.json packages/admin/package.json packages/utils/package.json # should remove package by filter=*" ] } diff --git a/packages/global/snap-tests/command-remove-yarn4/snap.txt b/packages/global/snap-tests/command-remove-yarn4/snap.txt index ab4ee5b0e7..62718ec278 100644 --- a/packages/global/snap-tests/command-remove-yarn4/snap.txt +++ b/packages/global/snap-tests/command-remove-yarn4/snap.txt @@ -1,9 +1,9 @@ -[1]> vite remove testnpm2 -D && cat package.json # should error when remove not exists package +[1]> vp remove testnpm2 -D && cat package.json # should error when remove not exists package Usage Error: Pattern testnpm2 doesn't match any packages referenced by this workspace $ yarn remove [-A,--all] [--mode #0] ... -> vite add testnpm2 && vite add -D test-vite-plus-install && vite add -O test-vite-plus-package-optional && cat package.json # should add packages to dependencies +> vp add testnpm2 && vp add -D test-vite-plus-install && vp add -O test-vite-plus-package-optional && cat package.json # should add packages to dependencies ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + testnpm2@npm:1.0.1 @@ -46,7 +46,7 @@ $ yarn remove [-A,--all] [--mode #0] ... } } -> vite remove testnpm2 test-vite-plus-install && cat package.json # should remove packages from dependencies +> vp remove testnpm2 test-vite-plus-install && cat package.json # should remove packages from dependencies ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ - test-vite-plus-install@npm:1.0.0, testnpm2@npm:1.0.1 @@ -65,7 +65,7 @@ $ yarn remove [-A,--all] [--mode #0] ... } } -> vite remove -D test-vite-plus-package-optional && cat package.json # support ignore -O flag and remove package from optional dependencies +> vp remove -D test-vite-plus-package-optional && cat package.json # support ignore -O flag and remove package from optional dependencies ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ - test-vite-plus-package-optional@npm:1.0.0 @@ -81,7 +81,7 @@ $ yarn remove [-A,--all] [--mode #0] ... "packageManager": "yarn@" } -> vite remove -g testnpm2 -- --dry-run && cat package.json # support remove global package with dry-run +> vp remove -g testnpm2 -- --dry-run && cat package.json # support remove global package with dry-run up to date in ms { diff --git a/packages/global/snap-tests/command-remove-yarn4/steps.json b/packages/global/snap-tests/command-remove-yarn4/steps.json index 1d6421f245..4393e176f6 100644 --- a/packages/global/snap-tests/command-remove-yarn4/steps.json +++ b/packages/global/snap-tests/command-remove-yarn4/steps.json @@ -4,10 +4,10 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite remove testnpm2 -D && cat package.json # should error when remove not exists package", - "vite add testnpm2 && vite add -D test-vite-plus-install && vite add -O test-vite-plus-package-optional && cat package.json # should add packages to dependencies", - "vite remove testnpm2 test-vite-plus-install && cat package.json # should remove packages from dependencies", - "vite remove -D test-vite-plus-package-optional && cat package.json # support ignore -O flag and remove package from optional dependencies", - "vite remove -g testnpm2 -- --dry-run && cat package.json # support remove global package with dry-run" + "vp remove testnpm2 -D && cat package.json # should error when remove not exists package", + "vp add testnpm2 && vp add -D test-vite-plus-install && vp add -O test-vite-plus-package-optional && cat package.json # should add packages to dependencies", + "vp remove testnpm2 test-vite-plus-install && cat package.json # should remove packages from dependencies", + "vp remove -D test-vite-plus-package-optional && cat package.json # support ignore -O flag and remove package from optional dependencies", + "vp remove -g testnpm2 -- --dry-run && cat package.json # support remove global package with dry-run" ] } diff --git a/packages/global/snap-tests/command-unlink-npm10/snap.txt b/packages/global/snap-tests/command-unlink-npm10/snap.txt index 2493a0691d..baef4567b0 100644 --- a/packages/global/snap-tests/command-unlink-npm10/snap.txt +++ b/packages/global/snap-tests/command-unlink-npm10/snap.txt @@ -1,5 +1,5 @@ > mkdir -p ../unlink-test-lib-npm && echo '{"name": "unlink-test-lib-npm", "version": "1.0.0"}' > ../unlink-test-lib-npm/package.json # create test library -> vite link ../unlink-test-lib-npm && cat package.json # link the library first +> vp link ../unlink-test-lib-npm && cat package.json # link the library first added 1 package in ms { @@ -8,7 +8,7 @@ added 1 package in ms "packageManager": "npm@" } -> vite unlink unlink-test-lib-npm && cat package.json # should unlink the package +> vp unlink unlink-test-lib-npm && cat package.json # should unlink the package removed 1 package in ms { diff --git a/packages/global/snap-tests/command-unlink-npm10/steps.json b/packages/global/snap-tests/command-unlink-npm10/steps.json index f4c689079e..c6c69c701f 100644 --- a/packages/global/snap-tests/command-unlink-npm10/steps.json +++ b/packages/global/snap-tests/command-unlink-npm10/steps.json @@ -5,7 +5,7 @@ }, "commands": [ "mkdir -p ../unlink-test-lib-npm && echo '{\"name\": \"unlink-test-lib-npm\", \"version\": \"1.0.0\"}' > ../unlink-test-lib-npm/package.json # create test library", - "vite link ../unlink-test-lib-npm && cat package.json # link the library first", - "vite unlink unlink-test-lib-npm && cat package.json # should unlink the package" + "vp link ../unlink-test-lib-npm && cat package.json # link the library first", + "vp unlink unlink-test-lib-npm && cat package.json # should unlink the package" ] } diff --git a/packages/global/snap-tests/command-unlink-pnpm10/snap.txt b/packages/global/snap-tests/command-unlink-pnpm10/snap.txt index e2d2c91c98..09b61e2d49 100644 --- a/packages/global/snap-tests/command-unlink-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-unlink-pnpm10/snap.txt @@ -1,18 +1,18 @@ -> vite unlink -h # should show help message +> vp unlink -h # should show help message Unlink packages -Usage: vite unlink [OPTIONS] [PACKAGE|DIR] [ARGS]... +Usage: vp unlink [OPTIONS] [PACKAGE|DIR] [ARGS]... Arguments: - [PACKAGE|DIR] Package name to unlink If empty, unlinks current package globally + [PACKAGE|DIR] Package name to unlink [ARGS]... Arguments to pass to package manager Options: - -r, --recursive Unlink in every workspace package (pnpm/yarn@2+-specific) + -r, --recursive Unlink in every workspace package -h, --help Print help > mkdir -p ../unlink-test-lib && echo '{"name": "unlink-test-lib", "version": "1.0.0"}' > ../unlink-test-lib/package.json # create test library -> vite link ../unlink-test-lib && cat package.json # link the library first +> vp link ../unlink-test-lib && cat package.json # link the library first dependencies: + unlink-test-lib <- ../unlink-test-lib @@ -26,7 +26,7 @@ dependencies: } } -> vite unlink unlink-test-lib && cat package.json # should unlink the package +> vp unlink unlink-test-lib && cat package.json # should unlink the package Nothing to unlink { "name": "command-unlink-pnpm10", @@ -37,11 +37,11 @@ Nothing to unlink } } -> vite link ../unlink-test-lib # link again +> vp link ../unlink-test-lib # link again Lockfile is up to date, resolution step is skipped -> vite unlink && cat package.json # should unlink all packages +> vp unlink && cat package.json # should unlink all packages Nothing to unlink { "name": "command-unlink-pnpm10", diff --git a/packages/global/snap-tests/command-unlink-pnpm10/steps.json b/packages/global/snap-tests/command-unlink-pnpm10/steps.json index 3f95a22b28..a775f3ea87 100644 --- a/packages/global/snap-tests/command-unlink-pnpm10/steps.json +++ b/packages/global/snap-tests/command-unlink-pnpm10/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite unlink -h # should show help message", + "vp unlink -h # should show help message", "mkdir -p ../unlink-test-lib && echo '{\"name\": \"unlink-test-lib\", \"version\": \"1.0.0\"}' > ../unlink-test-lib/package.json # create test library", - "vite link ../unlink-test-lib && cat package.json # link the library first", - "vite unlink unlink-test-lib && cat package.json # should unlink the package", - "vite link ../unlink-test-lib # link again", - "vite unlink && cat package.json # should unlink all packages" + "vp link ../unlink-test-lib && cat package.json # link the library first", + "vp unlink unlink-test-lib && cat package.json # should unlink the package", + "vp link ../unlink-test-lib # link again", + "vp unlink && cat package.json # should unlink all packages" ] } diff --git a/packages/global/snap-tests/command-unlink-yarn4/snap.txt b/packages/global/snap-tests/command-unlink-yarn4/snap.txt index b272e18a00..f4039f4178 100644 --- a/packages/global/snap-tests/command-unlink-yarn4/snap.txt +++ b/packages/global/snap-tests/command-unlink-yarn4/snap.txt @@ -1,5 +1,5 @@ > mkdir -p ../unlink-test-lib-yarn && echo '{"name": "unlink-test-lib-yarn", "version": "1.0.0"}' > ../unlink-test-lib-yarn/package.json # create test library -> vite link ../unlink-test-lib-yarn && cat package.json # link the library first +> vp link ../unlink-test-lib-yarn && cat package.json # link the library first ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -17,7 +17,7 @@ } } -> vite unlink unlink-test-lib-yarn && cat package.json # should unlink the package +> vp unlink unlink-test-lib-yarn && cat package.json # should unlink the package ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -32,7 +32,7 @@ "packageManager": "yarn@" } -> vite link ../unlink-test-lib-yarn && cat package.json # link again +> vp link ../unlink-test-lib-yarn && cat package.json # link again ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -50,7 +50,7 @@ } } -> vite unlink --recursive && cat package.json # should unlink all with --all flag +> vp unlink --recursive && cat package.json # should unlink all with --all flag ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -65,7 +65,7 @@ "packageManager": "yarn@" } -> vite unlink -r && cat package.json # should work with -r short form +> vp unlink -r && cat package.json # should work with -r short form ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed diff --git a/packages/global/snap-tests/command-unlink-yarn4/steps.json b/packages/global/snap-tests/command-unlink-yarn4/steps.json index 43272040ac..a0ca20c08b 100644 --- a/packages/global/snap-tests/command-unlink-yarn4/steps.json +++ b/packages/global/snap-tests/command-unlink-yarn4/steps.json @@ -5,10 +5,10 @@ }, "commands": [ "mkdir -p ../unlink-test-lib-yarn && echo '{\"name\": \"unlink-test-lib-yarn\", \"version\": \"1.0.0\"}' > ../unlink-test-lib-yarn/package.json # create test library", - "vite link ../unlink-test-lib-yarn && cat package.json # link the library first", - "vite unlink unlink-test-lib-yarn && cat package.json # should unlink the package", - "vite link ../unlink-test-lib-yarn && cat package.json # link again", - "vite unlink --recursive && cat package.json # should unlink all with --all flag", - "vite unlink -r && cat package.json # should work with -r short form" + "vp link ../unlink-test-lib-yarn && cat package.json # link the library first", + "vp unlink unlink-test-lib-yarn && cat package.json # should unlink the package", + "vp link ../unlink-test-lib-yarn && cat package.json # link again", + "vp unlink --recursive && cat package.json # should unlink all with --all flag", + "vp unlink -r && cat package.json # should work with -r short form" ] } diff --git a/packages/global/snap-tests/command-update-npm10-with-workspace/snap.txt b/packages/global/snap-tests/command-update-npm10-with-workspace/snap.txt index e305e9f291..5fcdbe66f1 100644 --- a/packages/global/snap-tests/command-update-npm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-update-npm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite update testnpm2 -w -- --no-audit && cat package.json # should update in workspace root +> vp update testnpm2 -w -- --no-audit && cat package.json # should update in workspace root added 5 packages in ms { @@ -13,7 +13,7 @@ added 5 packages in ms "packageManager": "npm@" } -> vite update testnpm2 --latest --filter app -- --no-audit && cat packages/app/package.json # should update in specific package +> vp update testnpm2 --latest --filter app -- --no-audit && cat packages/app/package.json # should update in specific package Warning: npm doesn't support --latest flag. Updating within semver range only. up to date in ms @@ -28,7 +28,7 @@ up to date in ms } } -> vite up -D --filter app -- --no-audit && cat packages/app/package.json # should update dev dependencies in app +> vp up -D --filter app -- --no-audit && cat packages/app/package.json # should update dev dependencies in app npm warn workspaces app in filter set, but no workspace folder present up to date in ms @@ -43,7 +43,7 @@ up to date in ms } } -> vite update --filter "*" -- --no-audit && cat packages/app/package.json packages/utils/package.json # should update in all packages +> vp update --filter "*" -- --no-audit && cat packages/app/package.json packages/utils/package.json # should update in all packages npm warn workspaces app in filter set, but no workspace folder present npm warn workspaces @vite-plus-test/utils in filter set, but no workspace folder present @@ -66,7 +66,7 @@ up to date in ms } } -> vite update -r --no-save -- --no-audit && cat package.json packages/app/package.json # should update recursively without saving +> vp update -r --no-save -- --no-audit && cat package.json packages/app/package.json # should update recursively without saving npm warn workspaces app in filter set, but no workspace folder present npm warn workspaces @vite-plus-test/utils in filter set, but no workspace folder present @@ -93,7 +93,7 @@ up to date in ms } } -> vite update --workspace --filter app @vite-plus-test/utils -- --no-audit && cat packages/app/package.json # should update workspace dependency +> vp update --workspace --filter app @vite-plus-test/utils -- --no-audit && cat packages/app/package.json # should update workspace dependency up to date in ms { diff --git a/packages/global/snap-tests/command-update-npm10-with-workspace/steps.json b/packages/global/snap-tests/command-update-npm10-with-workspace/steps.json index c10e7eceb2..1d072e8b93 100644 --- a/packages/global/snap-tests/command-update-npm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-update-npm10-with-workspace/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite update testnpm2 -w -- --no-audit && cat package.json # should update in workspace root", - "vite update testnpm2 --latest --filter app -- --no-audit && cat packages/app/package.json # should update in specific package", - "vite up -D --filter app -- --no-audit && cat packages/app/package.json # should update dev dependencies in app", - "vite update --filter \"*\" -- --no-audit && cat packages/app/package.json packages/utils/package.json # should update in all packages", - "vite update -r --no-save -- --no-audit && cat package.json packages/app/package.json # should update recursively without saving", - "vite update --workspace --filter app @vite-plus-test/utils -- --no-audit && cat packages/app/package.json # should update workspace dependency" + "vp update testnpm2 -w -- --no-audit && cat package.json # should update in workspace root", + "vp update testnpm2 --latest --filter app -- --no-audit && cat packages/app/package.json # should update in specific package", + "vp up -D --filter app -- --no-audit && cat packages/app/package.json # should update dev dependencies in app", + "vp update --filter \"*\" -- --no-audit && cat packages/app/package.json packages/utils/package.json # should update in all packages", + "vp update -r --no-save -- --no-audit && cat package.json packages/app/package.json # should update recursively without saving", + "vp update --workspace --filter app @vite-plus-test/utils -- --no-audit && cat packages/app/package.json # should update workspace dependency" ] } diff --git a/packages/global/snap-tests/command-update-npm10/snap.txt b/packages/global/snap-tests/command-update-npm10/snap.txt index a67cfe1b1a..43e981ca61 100644 --- a/packages/global/snap-tests/command-update-npm10/snap.txt +++ b/packages/global/snap-tests/command-update-npm10/snap.txt @@ -1,4 +1,4 @@ -> vite update testnpm2 -- --no-audit && cat package.json # should update package within semver range +> vp update testnpm2 -- --no-audit && cat package.json # should update package within semver range added 3 packages in ms { @@ -16,7 +16,7 @@ added 3 packages in ms "packageManager": "npm@" } -> vite up testnpm2 --latest -- --no-audit && cat package.json # should to absolute latest version +> vp up testnpm2 --latest -- --no-audit && cat package.json # should to absolute latest version Warning: npm doesn't support --latest flag. Updating within semver range only. up to date in ms @@ -35,7 +35,7 @@ up to date in ms "packageManager": "npm@" } -> vite update -D -- --no-audit && cat package.json # should update only dev dependencies +> vp update -D -- --no-audit && cat package.json # should update only dev dependencies up to date in ms { @@ -53,7 +53,7 @@ up to date in ms "packageManager": "npm@" } -> vite update -P --no-save -- --no-audit && cat package.json # should update only dependencies and optionalDependencies without saving +> vp update -P --no-save -- --no-audit && cat package.json # should update only dependencies and optionalDependencies without saving up to date in ms { @@ -71,7 +71,7 @@ up to date in ms "packageManager": "npm@" } -> vite rm testnpm2 && vite add testnpm2@1.0.0 -O -- --no-audit && vite update --no-optional --latest -- --no-audit && cat package.json # should skip optional dependencies +> vp rm testnpm2 && vp add testnpm2@1.0.0 -O -- --no-audit && vp update --no-optional --latest -- --no-audit && cat package.json # should skip optional dependencies removed 1 package in ms @@ -96,7 +96,7 @@ changed 1 package in ms "packageManager": "npm@" } -> vite update -- --no-audit && cat package.json # should update all packages but won't change the package.json +> vp update -- --no-audit && cat package.json # should update all packages but won't change the package.json added 2 packages in ms { diff --git a/packages/global/snap-tests/command-update-npm10/steps.json b/packages/global/snap-tests/command-update-npm10/steps.json index a5d02db574..1c2bfaf198 100644 --- a/packages/global/snap-tests/command-update-npm10/steps.json +++ b/packages/global/snap-tests/command-update-npm10/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite update testnpm2 -- --no-audit && cat package.json # should update package within semver range", - "vite up testnpm2 --latest -- --no-audit && cat package.json # should to absolute latest version", - "vite update -D -- --no-audit && cat package.json # should update only dev dependencies", - "vite update -P --no-save -- --no-audit && cat package.json # should update only dependencies and optionalDependencies without saving", - "vite rm testnpm2 && vite add testnpm2@1.0.0 -O -- --no-audit && vite update --no-optional --latest -- --no-audit && cat package.json # should skip optional dependencies", - "vite update -- --no-audit && cat package.json # should update all packages but won't change the package.json" + "vp update testnpm2 -- --no-audit && cat package.json # should update package within semver range", + "vp up testnpm2 --latest -- --no-audit && cat package.json # should to absolute latest version", + "vp update -D -- --no-audit && cat package.json # should update only dev dependencies", + "vp update -P --no-save -- --no-audit && cat package.json # should update only dependencies and optionalDependencies without saving", + "vp rm testnpm2 && vp add testnpm2@1.0.0 -O -- --no-audit && vp update --no-optional --latest -- --no-audit && cat package.json # should skip optional dependencies", + "vp update -- --no-audit && cat package.json # should update all packages but won't change the package.json" ] } diff --git a/packages/global/snap-tests/command-update-pnpm10-with-workspace/snap.txt b/packages/global/snap-tests/command-update-pnpm10-with-workspace/snap.txt index 969fe03098..0f9805abe6 100644 --- a/packages/global/snap-tests/command-update-pnpm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-update-pnpm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite update testnpm2 --latest -w && cat package.json # should update in workspace root +> vp update testnpm2 --latest -w && cat package.json # should update in workspace root Progress: resolved , reused , downloaded , added , done Packages: + @@ -13,7 +13,7 @@ Done in ms using pnpm v "packageManager": "pnpm@" } -> vite update testnpm2 --latest --filter app && cat packages/app/package.json # should update in specific package +> vp update testnpm2 --latest --filter app && cat packages/app/package.json # should update in specific package . |  WARN  `node_modules` is present. Lockfile only installation will make it out-of-date Progress: resolved , reused , downloaded , added , done . | +2 + @@ -30,7 +30,7 @@ Done in ms using pnpm v } } -> vite up -D --filter app && cat packages/app/package.json # should update dev dependencies in app +> vp up -D --filter app && cat packages/app/package.json # should update dev dependencies in app . |  WARN  `node_modules` is present. Lockfile only installation will make it out-of-date Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v @@ -46,7 +46,7 @@ Done in ms using pnpm v } } -> vite update --latest --filter "*" && cat packages/app/package.json packages/utils/package.json # should update in all packages +> vp update --latest --filter "*" && cat packages/app/package.json packages/utils/package.json # should update in all packages Scope: all workspace projects Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v @@ -69,7 +69,7 @@ Done in ms using pnpm v } } -> vite update -r --no-save && cat package.json packages/app/package.json # should update recursively without saving +> vp update -r --no-save && cat package.json packages/app/package.json # should update recursively without saving Scope: all workspace projects Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v @@ -93,7 +93,7 @@ Done in ms using pnpm v } } -> vite update --workspace --filter app @vite-plus-test/utils && cat packages/app/package.json # should update workspace dependency +> vp update --workspace --filter app @vite-plus-test/utils && cat packages/app/package.json # should update workspace dependency . |  WARN  `node_modules` is present. Lockfile only installation will make it out-of-date Progress: resolved , reused , downloaded , added , done Done in ms using pnpm v diff --git a/packages/global/snap-tests/command-update-pnpm10-with-workspace/steps.json b/packages/global/snap-tests/command-update-pnpm10-with-workspace/steps.json index 2cf5ef583e..275504b5df 100644 --- a/packages/global/snap-tests/command-update-pnpm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-update-pnpm10-with-workspace/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite update testnpm2 --latest -w && cat package.json # should update in workspace root", - "vite update testnpm2 --latest --filter app && cat packages/app/package.json # should update in specific package", - "vite up -D --filter app && cat packages/app/package.json # should update dev dependencies in app", - "vite update --latest --filter \"*\" && cat packages/app/package.json packages/utils/package.json # should update in all packages", - "vite update -r --no-save && cat package.json packages/app/package.json # should update recursively without saving", - "vite update --workspace --filter app @vite-plus-test/utils && cat packages/app/package.json # should update workspace dependency" + "vp update testnpm2 --latest -w && cat package.json # should update in workspace root", + "vp update testnpm2 --latest --filter app && cat packages/app/package.json # should update in specific package", + "vp up -D --filter app && cat packages/app/package.json # should update dev dependencies in app", + "vp update --latest --filter \"*\" && cat packages/app/package.json packages/utils/package.json # should update in all packages", + "vp update -r --no-save && cat package.json packages/app/package.json # should update recursively without saving", + "vp update --workspace --filter app @vite-plus-test/utils && cat packages/app/package.json # should update workspace dependency" ] } diff --git a/packages/global/snap-tests/command-update-pnpm10/snap.txt b/packages/global/snap-tests/command-update-pnpm10/snap.txt index 0421e75531..b894fd8f50 100644 --- a/packages/global/snap-tests/command-update-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-update-pnpm10/snap.txt @@ -1,7 +1,7 @@ -> vite update --help # should show help +> vp update --help # should show help Update packages to their latest versions -Usage: vite update [OPTIONS] [PACKAGES]... [-- ...] +Usage: vp update [OPTIONS] [PACKAGES]... [-- ...] Arguments: [PACKAGES]... Packages to update (optional - updates all if omitted) @@ -15,13 +15,13 @@ Options: -w, --workspace-root Include workspace root -D, --dev Update only devDependencies -P, --prod Update only dependencies (production) - -i, --interactive Interactive mode - show outdated packages and choose which to update + -i, --interactive Interactive mode --no-optional Don't update optionalDependencies --no-save Update lockfile only, don't modify package.json --workspace Only update if package exists in workspace (pnpm-specific) -h, --help Print help -> vite update testnpm2 && cat package.json # should update package within semver range +> vp update testnpm2 && cat package.json # should update package within semver range Packages: + + Progress: resolved , reused , downloaded , added , done @@ -51,7 +51,7 @@ Done in ms using pnpm v "packageManager": "pnpm@" } -> vite up testnpm2 --latest && cat package.json # should to absolute latest version +> vp up testnpm2 --latest && cat package.json # should to absolute latest version Already up to date Progress: resolved , reused , downloaded , added , done @@ -71,7 +71,7 @@ Done in ms using pnpm v "packageManager": "pnpm@" } -> vite update -D && cat package.json # should update only dev dependencies +> vp update -D && cat package.json # should update only dev dependencies Already up to date Progress: resolved , reused , downloaded , added , done @@ -95,7 +95,7 @@ Done in ms using pnpm v "packageManager": "pnpm@" } -> vite update -P --no-save && cat package.json # should update only dependencies and optionalDependencies without saving +> vp update -P --no-save && cat package.json # should update only dependencies and optionalDependencies without saving Already up to date Progress: resolved , reused , downloaded , added , done @@ -117,8 +117,8 @@ Done in ms using pnpm v "packageManager": "pnpm@" } -> vite rm testnpm2 # should remove package from dependencies for the next test -> vite add testnpm2@1.0.0 -O && vite update --no-optional --latest && cat package.json # should skip optional dependencies +> vp rm testnpm2 # should remove package from dependencies for the next test +> vp add testnpm2@1.0.0 -O && vp update --no-optional --latest && cat package.json # should skip optional dependencies Packages: + + Progress: resolved , reused , downloaded , added , done @@ -149,7 +149,7 @@ Done in ms using pnpm v "packageManager": "pnpm@" } -> vite update && vite update --recursive && cat package.json # should update all packages and change the package.json +> vp update && vp update --recursive && cat package.json # should update all packages and change the package.json Packages: + + Progress: resolved , reused , downloaded , added , done diff --git a/packages/global/snap-tests/command-update-pnpm10/steps.json b/packages/global/snap-tests/command-update-pnpm10/steps.json index f4f1b5ee76..8fb832c59b 100644 --- a/packages/global/snap-tests/command-update-pnpm10/steps.json +++ b/packages/global/snap-tests/command-update-pnpm10/steps.json @@ -4,16 +4,16 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite update --help # should show help", - "vite update testnpm2 && cat package.json # should update package within semver range", - "vite up testnpm2 --latest && cat package.json # should to absolute latest version", - "vite update -D && cat package.json # should update only dev dependencies", - "vite update -P --no-save && cat package.json # should update only dependencies and optionalDependencies without saving", + "vp update --help # should show help", + "vp update testnpm2 && cat package.json # should update package within semver range", + "vp up testnpm2 --latest && cat package.json # should to absolute latest version", + "vp update -D && cat package.json # should update only dev dependencies", + "vp update -P --no-save && cat package.json # should update only dependencies and optionalDependencies without saving", { - "command": "vite rm testnpm2 # should remove package from dependencies for the next test", + "command": "vp rm testnpm2 # should remove package from dependencies for the next test", "ignoreOutput": true }, - "vite add testnpm2@1.0.0 -O && vite update --no-optional --latest && cat package.json # should skip optional dependencies", - "vite update && vite update --recursive && cat package.json # should update all packages and change the package.json" + "vp add testnpm2@1.0.0 -O && vp update --no-optional --latest && cat package.json # should skip optional dependencies", + "vp update && vp update --recursive && cat package.json # should update all packages and change the package.json" ] } diff --git a/packages/global/snap-tests/command-update-yarn4-with-workspace/snap.txt b/packages/global/snap-tests/command-update-yarn4-with-workspace/snap.txt index f0f56f087c..192fe005d2 100644 --- a/packages/global/snap-tests/command-update-yarn4-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-update-yarn4-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite update testnpm2 && cat package.json packages/utils/package.json # should update all testnpm2 versions +> vp update testnpm2 && cat package.json packages/utils/package.json # should update all testnpm2 versions ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + test-vite-plus-install@npm:1.0.0, test-vite-plus-package@npm:1.0.0, testnpm2@npm:1.0.1 @@ -27,7 +27,7 @@ } } -> vite update testnpm2 --latest --filter app && cat packages/app/package.json # should update in specific package +> vp update testnpm2 --latest --filter app && cat packages/app/package.json # should update in specific package ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + testnpm2@npm:1.0.1 @@ -50,7 +50,7 @@ Done in ms ms } } -> vite up -D --filter app && cat packages/app/package.json # should update dev dependencies in app +> vp up -D --filter app && cat packages/app/package.json # should update dev dependencies in app ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -72,7 +72,7 @@ Done in ms ms } } -> vite update --filter "*" && cat packages/app/package.json packages/utils/package.json # should update in all packages +> vp update --filter "*" && cat packages/app/package.json packages/utils/package.json # should update in all packages ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -109,7 +109,7 @@ Done in ms ms } } -> vite update -r --no-save && cat package.json packages/app/package.json # should update recursively without saving +> vp update -r --no-save && cat package.json packages/app/package.json # should update recursively without saving ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -141,7 +141,7 @@ Done in ms ms } } -> vite update --workspace --filter app @vite-plus-test/utils && cat packages/app/package.json # should update workspace dependency +> vp update --workspace --filter app @vite-plus-test/utils && cat packages/app/package.json # should update workspace dependency ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed diff --git a/packages/global/snap-tests/command-update-yarn4-with-workspace/steps.json b/packages/global/snap-tests/command-update-yarn4-with-workspace/steps.json index 07ce177e41..01132b55dc 100644 --- a/packages/global/snap-tests/command-update-yarn4-with-workspace/steps.json +++ b/packages/global/snap-tests/command-update-yarn4-with-workspace/steps.json @@ -4,11 +4,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite update testnpm2 && cat package.json packages/utils/package.json # should update all testnpm2 versions", - "vite update testnpm2 --latest --filter app && cat packages/app/package.json # should update in specific package", - "vite up -D --filter app && cat packages/app/package.json # should update dev dependencies in app", - "vite update --filter \"*\" && cat packages/app/package.json packages/utils/package.json # should update in all packages", - "vite update -r --no-save && cat package.json packages/app/package.json # should update recursively without saving", - "vite update --workspace --filter app @vite-plus-test/utils && cat packages/app/package.json # should update workspace dependency" + "vp update testnpm2 && cat package.json packages/utils/package.json # should update all testnpm2 versions", + "vp update testnpm2 --latest --filter app && cat packages/app/package.json # should update in specific package", + "vp up -D --filter app && cat packages/app/package.json # should update dev dependencies in app", + "vp update --filter \"*\" && cat packages/app/package.json packages/utils/package.json # should update in all packages", + "vp update -r --no-save && cat package.json packages/app/package.json # should update recursively without saving", + "vp update --workspace --filter app @vite-plus-test/utils && cat packages/app/package.json # should update workspace dependency" ] } diff --git a/packages/global/snap-tests/command-update-yarn4/snap.txt b/packages/global/snap-tests/command-update-yarn4/snap.txt index c57a1849ea..6b5c18b24e 100644 --- a/packages/global/snap-tests/command-update-yarn4/snap.txt +++ b/packages/global/snap-tests/command-update-yarn4/snap.txt @@ -1,4 +1,4 @@ -> vite update testnpm2 && cat package.json # should update package within semver range +> vp update testnpm2 && cat package.json # should update package within semver range ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + test-vite-plus-package-optional@npm:1.0.0, test-vite-plus-package@npm:1.0.0, testnpm2@npm:1.0.1 @@ -23,7 +23,7 @@ "packageManager": "yarn@" } -> vite rm testnpm2 && vite add testnpm2@1.0.0 -D && vite update testnpm2 --latest && cat package.json # should to absolute latest version +> vp rm testnpm2 && vp add testnpm2@1.0.0 -D && vp update testnpm2 --latest && cat package.json # should to absolute latest version ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ - testnpm2@npm:1.0.1 @@ -65,7 +65,7 @@ "packageManager": "yarn@" } -> vite update -D && cat package.json # should update and ignore -D options +> vp update -D && cat package.json # should update and ignore -D options ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed @@ -87,7 +87,7 @@ "packageManager": "yarn@" } -> vite update --recursive && cat package.json # should update all packages but won't change the package.json +> vp update --recursive && cat package.json # should update all packages but won't change the package.json ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed diff --git a/packages/global/snap-tests/command-update-yarn4/steps.json b/packages/global/snap-tests/command-update-yarn4/steps.json index eef18a8522..5451801393 100644 --- a/packages/global/snap-tests/command-update-yarn4/steps.json +++ b/packages/global/snap-tests/command-update-yarn4/steps.json @@ -4,9 +4,9 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite update testnpm2 && cat package.json # should update package within semver range", - "vite rm testnpm2 && vite add testnpm2@1.0.0 -D && vite update testnpm2 --latest && cat package.json # should to absolute latest version", - "vite update -D && cat package.json # should update and ignore -D options", - "vite update --recursive && cat package.json # should update all packages but won't change the package.json" + "vp update testnpm2 && cat package.json # should update package within semver range", + "vp rm testnpm2 && vp add testnpm2@1.0.0 -D && vp update testnpm2 --latest && cat package.json # should to absolute latest version", + "vp update -D && cat package.json # should update and ignore -D options", + "vp update --recursive && cat package.json # should update all packages but won't change the package.json" ] } diff --git a/packages/global/snap-tests/command-view-npm10/snap.txt b/packages/global/snap-tests/command-view-npm10/snap.txt index 0a2d8ad3f5..ce0ee661f1 100644 --- a/packages/global/snap-tests/command-view-npm10/snap.txt +++ b/packages/global/snap-tests/command-view-npm10/snap.txt @@ -1,8 +1,8 @@ -> vite pm view testnpm2 dist.tarball # should view testnpm2 package information +> vp pm view testnpm2 dist.tarball # should view testnpm2 package information https://registry./testnpm2/-/testnpm2-1.0.1.tgz -> vite pm info testnpm2 dist.tarball # should info alias to view +> vp pm info testnpm2 dist.tarball # should info alias to view https://registry./testnpm2/-/testnpm2-1.0.1.tgz -> vite pm show testnpm2 dist.tarball # should show alias to view +> vp pm show testnpm2 dist.tarball # should show alias to view https://registry./testnpm2/-/testnpm2-1.0.1.tgz diff --git a/packages/global/snap-tests/command-view-npm10/steps.json b/packages/global/snap-tests/command-view-npm10/steps.json index 1daaafe484..4562d0e988 100644 --- a/packages/global/snap-tests/command-view-npm10/steps.json +++ b/packages/global/snap-tests/command-view-npm10/steps.json @@ -3,8 +3,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm view testnpm2 dist.tarball # should view testnpm2 package information", - "vite pm info testnpm2 dist.tarball # should info alias to view", - "vite pm show testnpm2 dist.tarball # should show alias to view" + "vp pm view testnpm2 dist.tarball # should view testnpm2 package information", + "vp pm info testnpm2 dist.tarball # should info alias to view", + "vp pm show testnpm2 dist.tarball # should show alias to view" ] } diff --git a/packages/global/snap-tests/command-view-pnpm10/snap.txt b/packages/global/snap-tests/command-view-pnpm10/snap.txt index 2a54fb3342..124fb17ef1 100644 --- a/packages/global/snap-tests/command-view-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-view-pnpm10/snap.txt @@ -1,18 +1,18 @@ -> vite pm view --help # should show help +> vp pm view --help # should show help View package information from the registry -Usage: vite pm view [OPTIONS] [FIELD] [-- ...] +Usage: vp pm view [OPTIONS] [FIELD] [-- ...] Arguments: Package name with optional version [FIELD] Specific field to view - [PASS_THROUGH_ARGS]... Additional arguments to pass through to the package manager + [PASS_THROUGH_ARGS]... Additional arguments Options: --json Output in JSON format -h, --help Print help -> vite pm view testnpm2 # should view lodash package information (uses npm view) +> vp pm view testnpm2 # should view lodash package information (uses npm view) testnpm2@ | ISC | deps: none | versions: 2 @@ -30,10 +30,10 @@ release-1: published over a year ago by fengmk2 -> vite pm view testnpm2 version # should view lodash version field (uses npm view) +> vp pm view testnpm2 version # should view lodash version field (uses npm view) 1.0.1 -> vite pm view testnpm2@1.0.0 # should view specific version of lodash (uses npm view) +> vp pm view testnpm2@1.0.0 # should view specific version of lodash (uses npm view) testnpm2@ | ISC | deps: none | versions: 2 @@ -51,17 +51,17 @@ release-1: published over a year ago by fengmk2 -> vite pm view testnpm2 dist.tarball # should view nested field (uses npm view) +> vp pm view testnpm2 dist.tarball # should view nested field (uses npm view) https://registry./testnpm2/-/testnpm2-1.0.1.tgz -> vite pm view testnpm2 dependencies # should view dependencies object (uses npm view) -> vite pm view testnpm2 dist.tarball --json # should view package.dist.tarball info in JSON format (uses npm view) +> vp pm view testnpm2 dependencies # should view dependencies object (uses npm view) +> vp pm view testnpm2 dist.tarball --json # should view package.dist.tarball info in JSON format (uses npm view) "https://registry./testnpm2/-/testnpm2-1.0.1.tgz" -> vite pm view testnpm2 version --json # should view field in JSON format (uses npm view) +> vp pm view testnpm2 version --json # should view field in JSON format (uses npm view) "1.0.1" -> vite pm view testnpm2 -- --loglevel=warn # should support pass through arguments (uses npm view) +> vp pm view testnpm2 -- --loglevel=warn # should support pass through arguments (uses npm view) testnpm2@ | ISC | deps: none | versions: 2 diff --git a/packages/global/snap-tests/command-view-pnpm10/steps.json b/packages/global/snap-tests/command-view-pnpm10/steps.json index 4c25935839..1998548d94 100644 --- a/packages/global/snap-tests/command-view-pnpm10/steps.json +++ b/packages/global/snap-tests/command-view-pnpm10/steps.json @@ -3,14 +3,14 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm view --help # should show help", - "vite pm view testnpm2 # should view lodash package information (uses npm view)", - "vite pm view testnpm2 version # should view lodash version field (uses npm view)", - "vite pm view testnpm2@1.0.0 # should view specific version of lodash (uses npm view)", - "vite pm view testnpm2 dist.tarball # should view nested field (uses npm view)", - "vite pm view testnpm2 dependencies # should view dependencies object (uses npm view)", - "vite pm view testnpm2 dist.tarball --json # should view package.dist.tarball info in JSON format (uses npm view)", - "vite pm view testnpm2 version --json # should view field in JSON format (uses npm view)", - "vite pm view testnpm2 -- --loglevel=warn # should support pass through arguments (uses npm view)" + "vp pm view --help # should show help", + "vp pm view testnpm2 # should view lodash package information (uses npm view)", + "vp pm view testnpm2 version # should view lodash version field (uses npm view)", + "vp pm view testnpm2@1.0.0 # should view specific version of lodash (uses npm view)", + "vp pm view testnpm2 dist.tarball # should view nested field (uses npm view)", + "vp pm view testnpm2 dependencies # should view dependencies object (uses npm view)", + "vp pm view testnpm2 dist.tarball --json # should view package.dist.tarball info in JSON format (uses npm view)", + "vp pm view testnpm2 version --json # should view field in JSON format (uses npm view)", + "vp pm view testnpm2 -- --loglevel=warn # should support pass through arguments (uses npm view)" ] } diff --git a/packages/global/snap-tests/command-view-yarn1/snap.txt b/packages/global/snap-tests/command-view-yarn1/snap.txt index c1fd918cd2..5896cadbfd 100644 --- a/packages/global/snap-tests/command-view-yarn1/snap.txt +++ b/packages/global/snap-tests/command-view-yarn1/snap.txt @@ -1,4 +1,4 @@ -> vite pm view testnpm2 # should view testnpm2 package information (uses npm view) +> vp pm view testnpm2 # should view testnpm2 package information (uses npm view) testnpm2@ | ISC | deps: none | versions: 2 @@ -16,5 +16,5 @@ release-1: published over a year ago by fengmk2 -> vite pm view testnpm2 version # should view testnpm2 version field (uses npm view) +> vp pm view testnpm2 version # should view testnpm2 version field (uses npm view) 1.0.1 diff --git a/packages/global/snap-tests/command-view-yarn1/steps.json b/packages/global/snap-tests/command-view-yarn1/steps.json index b74bd60510..a554e4a81d 100644 --- a/packages/global/snap-tests/command-view-yarn1/steps.json +++ b/packages/global/snap-tests/command-view-yarn1/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm view testnpm2 # should view testnpm2 package information (uses npm view)", - "vite pm view testnpm2 version # should view testnpm2 version field (uses npm view)" + "vp pm view testnpm2 # should view testnpm2 package information (uses npm view)", + "vp pm view testnpm2 version # should view testnpm2 version field (uses npm view)" ] } diff --git a/packages/global/snap-tests/command-view-yarn4/snap.txt b/packages/global/snap-tests/command-view-yarn4/snap.txt index c1fd918cd2..5896cadbfd 100644 --- a/packages/global/snap-tests/command-view-yarn4/snap.txt +++ b/packages/global/snap-tests/command-view-yarn4/snap.txt @@ -1,4 +1,4 @@ -> vite pm view testnpm2 # should view testnpm2 package information (uses npm view) +> vp pm view testnpm2 # should view testnpm2 package information (uses npm view) testnpm2@ | ISC | deps: none | versions: 2 @@ -16,5 +16,5 @@ release-1: published over a year ago by fengmk2 -> vite pm view testnpm2 version # should view testnpm2 version field (uses npm view) +> vp pm view testnpm2 version # should view testnpm2 version field (uses npm view) 1.0.1 diff --git a/packages/global/snap-tests/command-view-yarn4/steps.json b/packages/global/snap-tests/command-view-yarn4/steps.json index b74bd60510..a554e4a81d 100644 --- a/packages/global/snap-tests/command-view-yarn4/steps.json +++ b/packages/global/snap-tests/command-view-yarn4/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite pm view testnpm2 # should view testnpm2 package information (uses npm view)", - "vite pm view testnpm2 version # should view testnpm2 version field (uses npm view)" + "vp pm view testnpm2 # should view testnpm2 package information (uses npm view)", + "vp pm view testnpm2 version # should view testnpm2 version field (uses npm view)" ] } diff --git a/packages/global/snap-tests/command-why-npm10-with-workspace/snap.txt b/packages/global/snap-tests/command-why-npm10-with-workspace/snap.txt index 5f46b13e14..e642ebcf04 100644 --- a/packages/global/snap-tests/command-why-npm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-why-npm10-with-workspace/snap.txt @@ -1,8 +1,8 @@ -> vite install +> vp install added 6 packages in ms -> vite why testnpm2 --filter app # should check why in specific workspace using --workspace +> vp why testnpm2 --filter app # should check why in specific workspace using --workspace testnpm2@ node_modules/testnpm2 testnpm2@"1.0.0" from @vite-plus-test/utils@undefined @@ -22,7 +22,7 @@ node_modules/testnpm2 workspace packages/app from the root project testnpm2@"1.0.0" from the root project -> vite why test-vite-plus-package --filter app # should check why dev dependencies in app workspace +> vp why test-vite-plus-package --filter app # should check why dev dependencies in app workspace test-vite-plus-package@ dev node_modules/test-vite-plus-package dev test-vite-plus-package@"1.0.0" from app@undefined @@ -31,7 +31,7 @@ node_modules/test-vite-plus-package node_modules/app workspace packages/app from the root project -> vite why testnpm2 --filter app --json # should support json output with workspace filter +> vp why testnpm2 --filter app --json # should support json output with workspace filter [ { "name": "testnpm2", diff --git a/packages/global/snap-tests/command-why-npm10-with-workspace/steps.json b/packages/global/snap-tests/command-why-npm10-with-workspace/steps.json index 7e16e91634..5f96d774f3 100644 --- a/packages/global/snap-tests/command-why-npm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-why-npm10-with-workspace/steps.json @@ -4,9 +4,9 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install", - "vite why testnpm2 --filter app # should check why in specific workspace using --workspace", - "vite why test-vite-plus-package --filter app # should check why dev dependencies in app workspace", - "vite why testnpm2 --filter app --json # should support json output with workspace filter" + "vp install", + "vp why testnpm2 --filter app # should check why in specific workspace using --workspace", + "vp why test-vite-plus-package --filter app # should check why dev dependencies in app workspace", + "vp why testnpm2 --filter app --json # should support json output with workspace filter" ] } diff --git a/packages/global/snap-tests/command-why-npm10/snap.txt b/packages/global/snap-tests/command-why-npm10/snap.txt index 9a785c7c3a..e26e7990ad 100644 --- a/packages/global/snap-tests/command-why-npm10/snap.txt +++ b/packages/global/snap-tests/command-why-npm10/snap.txt @@ -1,23 +1,23 @@ -> vite install # should install packages first +> vp install # should install packages first added 3 packages in ms -> vite why testnpm2 # should show why package is installed (uses npm explain) +> vp why testnpm2 # should show why package is installed (uses npm explain) testnpm2@ node_modules/testnpm2 testnpm2@"1.0.1" from the root project -> vite explain testnpm2 # should work with explain alias +> vp explain testnpm2 # should work with explain alias testnpm2@ node_modules/testnpm2 testnpm2@"1.0.1" from the root project -> vite why test-vite-plus-package # should show why dev package is installed +> vp why test-vite-plus-package # should show why dev package is installed test-vite-plus-package@ dev node_modules/test-vite-plus-package dev test-vite-plus-package@"1.0.0" from the root project -> vite why testnpm2 --json # should support json output +> vp why testnpm2 --json # should support json output [ { "name": "testnpm2", @@ -43,7 +43,7 @@ node_modules/test-vite-plus-package } ] -> vite why testnpm2 test-vite-plus-package # should support multiple packages +> vp why testnpm2 test-vite-plus-package # should support multiple packages testnpm2@ node_modules/testnpm2 testnpm2@"1.0.1" from the root project @@ -52,31 +52,31 @@ test-vite-plus-package@ dev node_modules/test-vite-plus-package dev test-vite-plus-package@"1.0.0" from the root project -> vite why testnpm2 --long # should warn that --long not supported by npm +> vp why testnpm2 --long # should warn that --long not supported by npm Warning: --long not supported by npm testnpm2@ node_modules/testnpm2 testnpm2@"1.0.1" from the root project -> vite why testnpm2 --parseable # should warn that --parseable not supported by npm +> vp why testnpm2 --parseable # should warn that --parseable not supported by npm Warning: --parseable not supported by npm testnpm2@ node_modules/testnpm2 testnpm2@"1.0.1" from the root project -> vite why testnpm2 -P # should warn that --prod not supported by npm +> vp why testnpm2 -P # should warn that --prod not supported by npm Warning: --prod/--dev not supported by npm testnpm2@ node_modules/testnpm2 testnpm2@"1.0.1" from the root project -> vite why testnpm2 --find-by customFinder # should warn that --find-by not supported by npm +> vp why testnpm2 --find-by customFinder # should warn that --find-by not supported by npm Warning: --find-by not supported by npm testnpm2@ node_modules/testnpm2 testnpm2@"1.0.1" from the root project -> vite why testnpm2 -- --omit=dev # should support pass through arguments +> vp why testnpm2 -- --omit=dev # should support pass through arguments testnpm2@ node_modules/testnpm2 testnpm2@"1.0.1" from the root project diff --git a/packages/global/snap-tests/command-why-npm10/steps.json b/packages/global/snap-tests/command-why-npm10/steps.json index 56bc3fa152..9f1724771b 100644 --- a/packages/global/snap-tests/command-why-npm10/steps.json +++ b/packages/global/snap-tests/command-why-npm10/steps.json @@ -4,16 +4,16 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install # should install packages first", - "vite why testnpm2 # should show why package is installed (uses npm explain)", - "vite explain testnpm2 # should work with explain alias", - "vite why test-vite-plus-package # should show why dev package is installed", - "vite why testnpm2 --json # should support json output", - "vite why testnpm2 test-vite-plus-package # should support multiple packages", - "vite why testnpm2 --long # should warn that --long not supported by npm", - "vite why testnpm2 --parseable # should warn that --parseable not supported by npm", - "vite why testnpm2 -P # should warn that --prod not supported by npm", - "vite why testnpm2 --find-by customFinder # should warn that --find-by not supported by npm", - "vite why testnpm2 -- --omit=dev # should support pass through arguments" + "vp install # should install packages first", + "vp why testnpm2 # should show why package is installed (uses npm explain)", + "vp explain testnpm2 # should work with explain alias", + "vp why test-vite-plus-package # should show why dev package is installed", + "vp why testnpm2 --json # should support json output", + "vp why testnpm2 test-vite-plus-package # should support multiple packages", + "vp why testnpm2 --long # should warn that --long not supported by npm", + "vp why testnpm2 --parseable # should warn that --parseable not supported by npm", + "vp why testnpm2 -P # should warn that --prod not supported by npm", + "vp why testnpm2 --find-by customFinder # should warn that --find-by not supported by npm", + "vp why testnpm2 -- --omit=dev # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-why-pnpm10-with-workspace/snap.txt b/packages/global/snap-tests/command-why-pnpm10-with-workspace/snap.txt index d331ff8779..b584bac92e 100644 --- a/packages/global/snap-tests/command-why-pnpm10-with-workspace/snap.txt +++ b/packages/global/snap-tests/command-why-pnpm10-with-workspace/snap.txt @@ -1,4 +1,4 @@ -> vite install +> vp install Scope: all workspace projects Packages: + + @@ -9,7 +9,7 @@ dependencies: Done in ms using pnpm v -> vite why testnpm2 -w # should check why in workspace root +> vp why testnpm2 -w # should check why in workspace root Legend: production dependency, optional only, dev only command-why-pnpm10-with-workspace@ @@ -17,7 +17,7 @@ command-why-pnpm10-with-workspace@ dependencies: testnpm2 -> vite why testnpm2 --filter app # should check why in specific package +> vp why testnpm2 --filter app # should check why in specific package Legend: production dependency, optional only, dev only app /packages/app @@ -27,7 +27,7 @@ dependencies: └── testnpm2 testnpm2 -> vite why test-vite-plus-package -D --filter app # should check why dev dependencies in app +> vp why test-vite-plus-package -D --filter app # should check why dev dependencies in app Legend: production dependency, optional only, dev only app /packages/app @@ -35,7 +35,7 @@ app /packages/app devDependencies: test-vite-plus-package -> vite why testnpm2 --filter "*" # should check why in all packages +> vp why testnpm2 --filter "*" # should check why in all packages Legend: production dependency, optional only, dev only command-why-pnpm10-with-workspace@ @@ -55,7 +55,7 @@ testnpm2 dependencies: testnpm2 -> vite why testnpm2 -r # should check why recursively +> vp why testnpm2 -r # should check why recursively Legend: production dependency, optional only, dev only command-why-pnpm10-with-workspace@ @@ -75,7 +75,7 @@ testnpm2 dependencies: testnpm2 -> vite why testnpm2 --filter app --json # should support json output with filter +> vp why testnpm2 --filter app --json # should support json output with filter [ { "name": "app", @@ -105,7 +105,7 @@ testnpm2 } ] -> vite why test-vite-plus-install --filter app --depth 1 # should support depth limiting with filter +> vp why test-vite-plus-install --filter app --depth 1 # should support depth limiting with filter Legend: production dependency, optional only, dev only app /packages/app diff --git a/packages/global/snap-tests/command-why-pnpm10-with-workspace/steps.json b/packages/global/snap-tests/command-why-pnpm10-with-workspace/steps.json index ffcf27c85e..1b88cb08c4 100644 --- a/packages/global/snap-tests/command-why-pnpm10-with-workspace/steps.json +++ b/packages/global/snap-tests/command-why-pnpm10-with-workspace/steps.json @@ -4,13 +4,13 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install", - "vite why testnpm2 -w # should check why in workspace root", - "vite why testnpm2 --filter app # should check why in specific package", - "vite why test-vite-plus-package -D --filter app # should check why dev dependencies in app", - "vite why testnpm2 --filter \"*\" # should check why in all packages", - "vite why testnpm2 -r # should check why recursively", - "vite why testnpm2 --filter app --json # should support json output with filter", - "vite why test-vite-plus-install --filter app --depth 1 # should support depth limiting with filter" + "vp install", + "vp why testnpm2 -w # should check why in workspace root", + "vp why testnpm2 --filter app # should check why in specific package", + "vp why test-vite-plus-package -D --filter app # should check why dev dependencies in app", + "vp why testnpm2 --filter \"*\" # should check why in all packages", + "vp why testnpm2 -r # should check why recursively", + "vp why testnpm2 --filter app --json # should support json output with filter", + "vp why test-vite-plus-install --filter app --depth 1 # should support depth limiting with filter" ] } diff --git a/packages/global/snap-tests/command-why-pnpm10/snap.txt b/packages/global/snap-tests/command-why-pnpm10/snap.txt index 185c46a26b..8c8e6baee4 100644 --- a/packages/global/snap-tests/command-why-pnpm10/snap.txt +++ b/packages/global/snap-tests/command-why-pnpm10/snap.txt @@ -1,7 +1,7 @@ -> vite why --help # should show help +> vp why --help # should show help Show why a package is installed -Usage: vite why [OPTIONS] ... [-- ...] +Usage: vp why [OPTIONS] ... [-- ...] Arguments: ... Package(s) to check @@ -9,21 +9,21 @@ Arguments: Options: --json Output in JSON format - --long Show extended information (pnpm-specific) - --parseable Show parseable output (pnpm-specific) + --long Show extended information + --parseable Show parseable output -r, --recursive Check recursively across all workspaces - --filter Filter packages in monorepo (pnpm/npm-specific) - -w, --workspace-root Check in workspace root (pnpm-specific) - -P, --prod Only production dependencies (pnpm-specific) - -D, --dev Only dev dependencies (pnpm-specific) - --depth Limit tree depth (pnpm-specific) - --no-optional Exclude optional dependencies (pnpm-specific) + --filter Filter packages in monorepo + -w, --workspace-root Check in workspace root + -P, --prod Only production dependencies + -D, --dev Only dev dependencies + --depth Limit tree depth + --no-optional Exclude optional dependencies -g, --global Check globally installed packages - --exclude-peers Exclude peer dependencies (pnpm/yarn@2+-specific) - --find-by Use a finder function defined in .pnpmfile.cjs (pnpm-specific) + --exclude-peers Exclude peer dependencies + --find-by Use a finder function defined in .pnpmfile.cjs -h, --help Print help -> vite install # should install packages first +> vp install # should install packages first Packages: + + Progress: resolved , reused , downloaded , added , done @@ -39,7 +39,7 @@ devDependencies: Done in ms using pnpm v -> vite why testnpm2 # should show why package is installed +> vp why testnpm2 # should show why package is installed Legend: production dependency, optional only, dev only command-why-pnpm10@ @@ -47,7 +47,7 @@ command-why-pnpm10@ dependencies: testnpm2 -> vite explain testnpm2 # should work with explain alias +> vp explain testnpm2 # should work with explain alias Legend: production dependency, optional only, dev only command-why-pnpm10@ @@ -55,7 +55,7 @@ command-why-pnpm10@ dependencies: testnpm2 -> vite why test-vite-plus-package # should show why dev package is installed +> vp why test-vite-plus-package # should show why dev package is installed Legend: production dependency, optional only, dev only command-why-pnpm10@ @@ -63,7 +63,7 @@ command-why-pnpm10@ devDependencies: test-vite-plus-package -> vite why testnpm2 test-vite-plus-package # should support multiple packages +> vp why testnpm2 test-vite-plus-package # should support multiple packages Legend: production dependency, optional only, dev only command-why-pnpm10@ @@ -74,7 +74,7 @@ testnpm2 devDependencies: test-vite-plus-package -> vite why testnpm2 --json # should support json output +> vp why testnpm2 --json # should support json output [ { "name": "command-why-pnpm10", @@ -92,7 +92,7 @@ test-vite-plus-package } ] -> vite why testnpm2 --long # should support long output +> vp why testnpm2 --long # should support long output Legend: production dependency, optional only, dev only command-why-pnpm10@ @@ -101,11 +101,11 @@ dependencies: testnpm2 /node_modules/.pnpm/testnpm2@/node_modules/testnpm2 -> vite why testnpm2 --parseable # should support parseable output +> vp why testnpm2 --parseable # should support parseable output /node_modules/.pnpm/testnpm2@/node_modules/testnpm2 -> vite why testnpm2 -P # should support prod dependencies only +> vp why testnpm2 -P # should support prod dependencies only Legend: production dependency, optional only, dev only command-why-pnpm10@ @@ -113,7 +113,7 @@ command-why-pnpm10@ dependencies: testnpm2 -> vite why test-vite-plus-package -D # should support dev dependencies only +> vp why test-vite-plus-package -D # should support dev dependencies only Legend: production dependency, optional only, dev only command-why-pnpm10@ @@ -121,7 +121,7 @@ command-why-pnpm10@ devDependencies: test-vite-plus-package -> vite why testnpm2 --depth 1 # should support depth limiting +> vp why testnpm2 --depth 1 # should support depth limiting Legend: production dependency, optional only, dev only command-why-pnpm10@ @@ -129,11 +129,11 @@ command-why-pnpm10@ dependencies: testnpm2 -> vite why test-vite-plus-package-optional --no-optional # should exclude optional dependencies -[1]> vite why testnpm2 --find-by customFinder # should support find-by option (pnpm-specific) +> vp why test-vite-plus-package-optional --no-optional # should exclude optional dependencies +[1]> vp why testnpm2 --find-by customFinder # should support find-by option (pnpm-specific)  ERR_PNPM_FINDER_NOT_FOUND  No finder with name customFinder is found -> vite why testnpm2 -- --reporter=silent # should support pass through arguments +> vp why testnpm2 -- --reporter=silent # should support pass through arguments Legend: production dependency, optional only, dev only command-why-pnpm10@ diff --git a/packages/global/snap-tests/command-why-pnpm10/steps.json b/packages/global/snap-tests/command-why-pnpm10/steps.json index 6a9f1c18c7..3c495a3760 100644 --- a/packages/global/snap-tests/command-why-pnpm10/steps.json +++ b/packages/global/snap-tests/command-why-pnpm10/steps.json @@ -4,20 +4,20 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite why --help # should show help", - "vite install # should install packages first", - "vite why testnpm2 # should show why package is installed", - "vite explain testnpm2 # should work with explain alias", - "vite why test-vite-plus-package # should show why dev package is installed", - "vite why testnpm2 test-vite-plus-package # should support multiple packages", - "vite why testnpm2 --json # should support json output", - "vite why testnpm2 --long # should support long output", - "vite why testnpm2 --parseable # should support parseable output", - "vite why testnpm2 -P # should support prod dependencies only", - "vite why test-vite-plus-package -D # should support dev dependencies only", - "vite why testnpm2 --depth 1 # should support depth limiting", - "vite why test-vite-plus-package-optional --no-optional # should exclude optional dependencies", - "vite why testnpm2 --find-by customFinder # should support find-by option (pnpm-specific)", - "vite why testnpm2 -- --reporter=silent # should support pass through arguments" + "vp why --help # should show help", + "vp install # should install packages first", + "vp why testnpm2 # should show why package is installed", + "vp explain testnpm2 # should work with explain alias", + "vp why test-vite-plus-package # should show why dev package is installed", + "vp why testnpm2 test-vite-plus-package # should support multiple packages", + "vp why testnpm2 --json # should support json output", + "vp why testnpm2 --long # should support long output", + "vp why testnpm2 --parseable # should support parseable output", + "vp why testnpm2 -P # should support prod dependencies only", + "vp why test-vite-plus-package -D # should support dev dependencies only", + "vp why testnpm2 --depth 1 # should support depth limiting", + "vp why test-vite-plus-package-optional --no-optional # should exclude optional dependencies", + "vp why testnpm2 --find-by customFinder # should support find-by option (pnpm-specific)", + "vp why testnpm2 -- --reporter=silent # should support pass through arguments" ] } diff --git a/packages/global/snap-tests/command-why-yarn4/snap.txt b/packages/global/snap-tests/command-why-yarn4/snap.txt index 56b3727214..4752e3b73c 100644 --- a/packages/global/snap-tests/command-why-yarn4/snap.txt +++ b/packages/global/snap-tests/command-why-yarn4/snap.txt @@ -1,4 +1,4 @@ -> vite install -- --mode=update-lockfile # should install packages first +> vp install -- --mode=update-lockfile # should install packages first ➤ YN0000: · Yarn ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + test-vite-plus-package-optional@npm:1.0.0, test-vite-plus-package@npm:1.0.0, testnpm2@npm:1.0.1 @@ -10,52 +10,52 @@ ➤ YN0000: └ Completed ➤ YN0000: · Done with warnings in ms ms -> vite why testnpm2 # should show why package is installed +> vp why testnpm2 # should show why package is installed └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite explain testnpm2 # should work with explain alias +> vp explain testnpm2 # should work with explain alias └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite why test-vite-plus-package # should show why dev package is installed +> vp why test-vite-plus-package # should show why dev package is installed └─ command-why-yarn4@workspace:. └─ test-vite-plus-package@npm:1.0.0 (via npm:1.0.0) -> vite why testnpm2 -r # should support recursive in yarn@2+ +> vp why testnpm2 -r # should support recursive in yarn@2+ └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite why testnpm2 test-vite-plus-package # should warn about multiple packages and use first +> vp why testnpm2 test-vite-plus-package # should warn about multiple packages and use first Warning: yarn only supports checking one package at a time, using first package └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite why testnpm2 --json # should warn that --json not supported by yarn +> vp why testnpm2 --json # should warn that --json not supported by yarn Warning: --json not supported by yarn └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite why testnpm2 --long # should warn that --long not supported by yarn +> vp why testnpm2 --long # should warn that --long not supported by yarn Warning: --long not supported by yarn └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite why testnpm2 --parseable # should warn that --parseable not supported by yarn +> vp why testnpm2 --parseable # should warn that --parseable not supported by yarn Warning: --parseable not supported by yarn └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite why testnpm2 -P # should warn that --prod not supported by yarn +> vp why testnpm2 -P # should warn that --prod not supported by yarn Warning: --prod/--dev not supported by yarn └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite why testnpm2 --find-by customFinder # should warn that --find-by not supported by yarn +> vp why testnpm2 --find-by customFinder # should warn that --find-by not supported by yarn Warning: --find-by not supported by yarn └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) -> vite why testnpm2 --exclude-peers # should exclude peers by removing --peers flag +> vp why testnpm2 --exclude-peers # should exclude peers by removing --peers flag └─ command-why-yarn4@workspace:. └─ testnpm2@npm:1.0.1 (via npm:1.0.1) diff --git a/packages/global/snap-tests/command-why-yarn4/steps.json b/packages/global/snap-tests/command-why-yarn4/steps.json index 84470c1378..919b51e7fa 100644 --- a/packages/global/snap-tests/command-why-yarn4/steps.json +++ b/packages/global/snap-tests/command-why-yarn4/steps.json @@ -4,17 +4,17 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite install -- --mode=update-lockfile # should install packages first", - "vite why testnpm2 # should show why package is installed", - "vite explain testnpm2 # should work with explain alias", - "vite why test-vite-plus-package # should show why dev package is installed", - "vite why testnpm2 -r # should support recursive in yarn@2+", - "vite why testnpm2 test-vite-plus-package # should warn about multiple packages and use first", - "vite why testnpm2 --json # should warn that --json not supported by yarn", - "vite why testnpm2 --long # should warn that --long not supported by yarn", - "vite why testnpm2 --parseable # should warn that --parseable not supported by yarn", - "vite why testnpm2 -P # should warn that --prod not supported by yarn", - "vite why testnpm2 --find-by customFinder # should warn that --find-by not supported by yarn", - "vite why testnpm2 --exclude-peers # should exclude peers by removing --peers flag" + "vp install -- --mode=update-lockfile # should install packages first", + "vp why testnpm2 # should show why package is installed", + "vp explain testnpm2 # should work with explain alias", + "vp why test-vite-plus-package # should show why dev package is installed", + "vp why testnpm2 -r # should support recursive in yarn@2+", + "vp why testnpm2 test-vite-plus-package # should warn about multiple packages and use first", + "vp why testnpm2 --json # should warn that --json not supported by yarn", + "vp why testnpm2 --long # should warn that --long not supported by yarn", + "vp why testnpm2 --parseable # should warn that --parseable not supported by yarn", + "vp why testnpm2 -P # should warn that --prod not supported by yarn", + "vp why testnpm2 --find-by customFinder # should warn that --find-by not supported by yarn", + "vp why testnpm2 --exclude-peers # should exclude peers by removing --peers flag" ] } diff --git a/packages/global/snap-tests/dev-engines-runtime-pnpm10/package.json b/packages/global/snap-tests/dev-engines-runtime-pnpm10/package.json new file mode 100644 index 0000000000..ecc3be898b --- /dev/null +++ b/packages/global/snap-tests/dev-engines-runtime-pnpm10/package.json @@ -0,0 +1,11 @@ +{ + "name": "dev-engines-runtime-pnpm10", + "version": "1.0.0", + "devEngines": { + "runtime": { + "name": "node", + "version": "22.11.0" + } + }, + "packageManager": "pnpm@10.19.0" +} diff --git a/packages/global/snap-tests/dev-engines-runtime-pnpm10/snap.txt b/packages/global/snap-tests/dev-engines-runtime-pnpm10/snap.txt new file mode 100644 index 0000000000..94234b6e27 --- /dev/null +++ b/packages/global/snap-tests/dev-engines-runtime-pnpm10/snap.txt @@ -0,0 +1,2 @@ +> vp dlx -s print-current-version # should print Node.js version 22.11.0 from devEngines.runtime +v22.11.0 diff --git a/packages/global/snap-tests/dev-engines-runtime-pnpm10/steps.json b/packages/global/snap-tests/dev-engines-runtime-pnpm10/steps.json new file mode 100644 index 0000000000..01b43448f5 --- /dev/null +++ b/packages/global/snap-tests/dev-engines-runtime-pnpm10/steps.json @@ -0,0 +1,8 @@ +{ + "env": { + "VITE_DISABLE_AUTO_INSTALL": "1" + }, + "commands": [ + "vp dlx -s print-current-version # should print Node.js version 22.11.0 from devEngines.runtime" + ] +} diff --git a/packages/global/snap-tests/migration-agent-claude/snap.txt b/packages/global/snap-tests/migration-agent-claude/snap.txt index 5ef375b02f..7f68a4a1ce 100644 --- a/packages/global/snap-tests/migration-agent-claude/snap.txt +++ b/packages/global/snap-tests/migration-agent-claude/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --agent claude --no-interactive # migration with --agent claude should write CLAUDE.md +> vp migrate --agent claude --no-interactive # migration with --agent claude should write CLAUDE.md ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-agent-claude/steps.json b/packages/global/snap-tests/migration-agent-claude/steps.json index 8608869eea..4a544f202c 100644 --- a/packages/global/snap-tests/migration-agent-claude/steps.json +++ b/packages/global/snap-tests/migration-agent-claude/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --agent claude --no-interactive # migration with --agent claude should write CLAUDE.md", + "vp migrate --agent claude --no-interactive # migration with --agent claude should write CLAUDE.md", "cat CLAUDE.md | head -3 # verify CLAUDE.md was created" ] } diff --git a/packages/global/snap-tests/migration-already-vite-plus/snap.txt b/packages/global/snap-tests/migration-already-vite-plus/snap.txt index 268cb2477c..d2269bcbba 100644 --- a/packages/global/snap-tests/migration-already-vite-plus/snap.txt +++ b/packages/global/snap-tests/migration-already-vite-plus/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # should detect existing vite-plus and exit +> vp migrate --no-interactive # should detect existing vite-plus and exit ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ └ This project is already using Vite+! Happy coding! diff --git a/packages/global/snap-tests/migration-already-vite-plus/steps.json b/packages/global/snap-tests/migration-already-vite-plus/steps.json index f66406b2e0..dbc19ed8ec 100644 --- a/packages/global/snap-tests/migration-already-vite-plus/steps.json +++ b/packages/global/snap-tests/migration-already-vite-plus/steps.json @@ -1,3 +1,3 @@ { - "commands": ["vite migrate --no-interactive # should detect existing vite-plus and exit"] + "commands": ["vp migrate --no-interactive # should detect existing vite-plus and exit"] } diff --git a/packages/global/snap-tests/migration-auto-create-vite-config/snap.txt b/packages/global/snap-tests/migration-auto-create-vite-config/snap.txt index 2bf1117e0a..322efc3540 100644 --- a/packages/global/snap-tests/migration-auto-create-vite-config/snap.txt +++ b/packages/global/snap-tests/migration-auto-create-vite-config/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should auto create vite.config.ts and remove oxlintrc and oxfmtrc +> vp migrate --no-interactive # migration should auto create vite.config.ts and remove oxlintrc and oxfmtrc ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-auto-create-vite-config/steps.json b/packages/global/snap-tests/migration-auto-create-vite-config/steps.json index ef6d4a01fc..ecde497a32 100644 --- a/packages/global/snap-tests/migration-auto-create-vite-config/steps.json +++ b/packages/global/snap-tests/migration-auto-create-vite-config/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should auto create vite.config.ts and remove oxlintrc and oxfmtrc", + "vp migrate --no-interactive # migration should auto create vite.config.ts and remove oxlintrc and oxfmtrc", "cat vite.config.ts # check vite.config.ts", "cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed", "cat .oxfmtrc.json && exit 1 || true # check .oxfmtrc.json is removed", diff --git a/packages/global/snap-tests/migration-check/snap.txt b/packages/global/snap-tests/migration-check/snap.txt index 22b9728f72..3206465e48 100644 --- a/packages/global/snap-tests/migration-check/snap.txt +++ b/packages/global/snap-tests/migration-check/snap.txt @@ -1,7 +1,7 @@ -> vite migrate --help # show help +> vp migrate --help # show help VITE+(⚡︎) - The Unified Toolchain for the Web -USAGE: vite migrate [PATH] [OPTIONS] +USAGE: vp migrate [PATH] [OPTIONS] Migrate standalone Vite, Vitest, Oxlint, and Oxfmt projects to unified Vite+. @@ -17,12 +17,12 @@ OPTIONS: EXAMPLES: # Migrate current package - vite migrate + vp migrate # Migrate specific directory - vite migrate my-app + vp migrate my-app # Non-interactive mode - vite migrate --no-interactive + vp migrate --no-interactive diff --git a/packages/global/snap-tests/migration-check/steps.json b/packages/global/snap-tests/migration-check/steps.json index 701c65e16b..825f735a24 100644 --- a/packages/global/snap-tests/migration-check/steps.json +++ b/packages/global/snap-tests/migration-check/steps.json @@ -1,3 +1,3 @@ { - "commands": ["vite migrate --help # show help"] + "commands": ["vp migrate --help # show help"] } diff --git a/packages/global/snap-tests/migration-from-tsdown-json-config/snap.txt b/packages/global/snap-tests/migration-from-tsdown-json-config/snap.txt index 1b22f4d0af..9ea43cfffb 100644 --- a/packages/global/snap-tests/migration-from-tsdown-json-config/snap.txt +++ b/packages/global/snap-tests/migration-from-tsdown-json-config/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should rewrite imports to vite-plus +> vp migrate --no-interactive # migration should rewrite imports to vite-plus ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm @@ -56,7 +56,7 @@ export default defineConfig({ "packageManager": "pnpm@" } -> vite migrate --no-interactive # run migration again to check if it is idempotent +> vp migrate --no-interactive # run migration again to check if it is idempotent ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ └ This project is already using Vite+! Happy coding! diff --git a/packages/global/snap-tests/migration-from-tsdown-json-config/steps.json b/packages/global/snap-tests/migration-from-tsdown-json-config/steps.json index 41c9b5e828..a7d3c4fd7c 100644 --- a/packages/global/snap-tests/migration-from-tsdown-json-config/steps.json +++ b/packages/global/snap-tests/migration-from-tsdown-json-config/steps.json @@ -3,11 +3,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should rewrite imports to vite-plus", + "vp migrate --no-interactive # migration should rewrite imports to vite-plus", "cat tsdown.config.json && exit 1 || true # check tsdown.config.json should be removed", "cat vite.config.ts # check vite.config.ts", "cat package.json # check package.json", - "vite migrate --no-interactive # run migration again to check if it is idempotent", + "vp migrate --no-interactive # run migration again to check if it is idempotent", "cat vite.config.ts # check vite.config.ts", "cat package.json # check package.json" ] diff --git a/packages/global/snap-tests/migration-from-tsdown/snap.txt b/packages/global/snap-tests/migration-from-tsdown/snap.txt index bb366c8509..d18d757b28 100644 --- a/packages/global/snap-tests/migration-from-tsdown/snap.txt +++ b/packages/global/snap-tests/migration-from-tsdown/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should rewrite imports to vite-plus +> vp migrate --no-interactive # migration should rewrite imports to vite-plus ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm @@ -63,7 +63,7 @@ export default defineConfig({ "packageManager": "pnpm@" } -> vite migrate --no-interactive # run migration again to check if it is idempotent +> vp migrate --no-interactive # run migration again to check if it is idempotent ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ └ This project is already using Vite+! Happy coding! diff --git a/packages/global/snap-tests/migration-from-tsdown/steps.json b/packages/global/snap-tests/migration-from-tsdown/steps.json index 6f63a90323..12b3d97676 100644 --- a/packages/global/snap-tests/migration-from-tsdown/steps.json +++ b/packages/global/snap-tests/migration-from-tsdown/steps.json @@ -3,11 +3,11 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should rewrite imports to vite-plus", + "vp migrate --no-interactive # migration should rewrite imports to vite-plus", "cat tsdown.config.ts # check tsdown.config.ts", "cat vite.config.ts # check vite.config.ts", "cat package.json # check package.json", - "vite migrate --no-interactive # run migration again to check if it is idempotent", + "vp migrate --no-interactive # run migration again to check if it is idempotent", "cat tsdown.config.ts # check tsdown.config.ts", "cat vite.config.ts # check vite.config.ts", "cat package.json # check package.json" diff --git a/packages/global/snap-tests/migration-from-vitest-config/snap.txt b/packages/global/snap-tests/migration-from-vitest-config/snap.txt index 5f0734d148..140324f0c4 100644 --- a/packages/global/snap-tests/migration-from-vitest-config/snap.txt +++ b/packages/global/snap-tests/migration-from-vitest-config/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should rewrite imports to vite-plus +> vp migrate --no-interactive # migration should rewrite imports to vite-plus ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-from-vitest-config/steps.json b/packages/global/snap-tests/migration-from-vitest-config/steps.json index ac805a6623..1342707009 100644 --- a/packages/global/snap-tests/migration-from-vitest-config/steps.json +++ b/packages/global/snap-tests/migration-from-vitest-config/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should rewrite imports to vite-plus", + "vp migrate --no-interactive # migration should rewrite imports to vite-plus", "cat vitest.config.ts # check vitest.config.ts", "cat package.json # check package.json" ] diff --git a/packages/global/snap-tests/migration-from-vitest-files/snap.txt b/packages/global/snap-tests/migration-from-vitest-files/snap.txt index ba897d29c3..1316a6bc1c 100644 --- a/packages/global/snap-tests/migration-from-vitest-files/snap.txt +++ b/packages/global/snap-tests/migration-from-vitest-files/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should rewrite imports to vite-plus +> vp migrate --no-interactive # migration should rewrite imports to vite-plus ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-from-vitest-files/steps.json b/packages/global/snap-tests/migration-from-vitest-files/steps.json index 47936ebb27..e823162737 100644 --- a/packages/global/snap-tests/migration-from-vitest-files/steps.json +++ b/packages/global/snap-tests/migration-from-vitest-files/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should rewrite imports to vite-plus", + "vp migrate --no-interactive # migration should rewrite imports to vite-plus", "cat package.json # check package.json", "cat test/hello.ts # check test/hello.ts" ] diff --git a/packages/global/snap-tests/migration-lintstagedrc-json/snap.txt b/packages/global/snap-tests/migration-lintstagedrc-json/snap.txt index de00d20cba..de3fc647b2 100644 --- a/packages/global/snap-tests/migration-lintstagedrc-json/snap.txt +++ b/packages/global/snap-tests/migration-lintstagedrc-json/snap.txt @@ -1,7 +1,7 @@ -> vite migrate -h # migration help message +> vp migrate -h # migration help message VITE+(⚡︎) - The Unified Toolchain for the Web -USAGE: vite migrate [PATH] [OPTIONS] +USAGE: vp migrate [PATH] [OPTIONS] Migrate standalone Vite, Vitest, Oxlint, and Oxfmt projects to unified Vite+. @@ -17,17 +17,17 @@ OPTIONS: EXAMPLES: # Migrate current package - vite migrate + vp migrate # Migrate specific directory - vite migrate my-app + vp migrate my-app # Non-interactive mode - vite migrate --no-interactive + vp migrate --no-interactive -> vite migrate --no-interactive # migration work with lintstagedrc.json +> vp migrate --no-interactive # migration work with lintstagedrc.json ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-lintstagedrc-json/steps.json b/packages/global/snap-tests/migration-lintstagedrc-json/steps.json index a7ffd85e53..21ae3fc2fc 100644 --- a/packages/global/snap-tests/migration-lintstagedrc-json/steps.json +++ b/packages/global/snap-tests/migration-lintstagedrc-json/steps.json @@ -3,8 +3,8 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate -h # migration help message", - "vite migrate --no-interactive # migration work with lintstagedrc.json", + "vp migrate -h # migration help message", + "vp migrate --no-interactive # migration work with lintstagedrc.json", "cat .lintstagedrc.json # check lintstagedrc.json", "cat package.json # check package.json" ] diff --git a/packages/global/snap-tests/migration-lintstagedrc-not-support/snap.txt b/packages/global/snap-tests/migration-lintstagedrc-not-support/snap.txt index b63035d836..b14383e1c8 100644 --- a/packages/global/snap-tests/migration-lintstagedrc-not-support/snap.txt +++ b/packages/global/snap-tests/migration-lintstagedrc-not-support/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should not support non-json format lintstagedrc +> vp migrate --no-interactive # migration should not support non-json format lintstagedrc ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-lintstagedrc-not-support/steps.json b/packages/global/snap-tests/migration-lintstagedrc-not-support/steps.json index cc041952f5..bcc8077a34 100644 --- a/packages/global/snap-tests/migration-lintstagedrc-not-support/steps.json +++ b/packages/global/snap-tests/migration-lintstagedrc-not-support/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should not support non-json format lintstagedrc", + "vp migrate --no-interactive # migration should not support non-json format lintstagedrc", "cat .lintstagedrc # check .lintstagedrc is not updated", "cat .lintstagedrc.yaml # check .lintstagedrc.yaml is not updated", "cat lint-staged.config.mjs # check lint-staged.config.mjs is not updated", diff --git a/packages/global/snap-tests/migration-merge-vite-config-js/snap.txt b/packages/global/snap-tests/migration-merge-vite-config-js/snap.txt index eca14c8f37..0892d162c0 100644 --- a/packages/global/snap-tests/migration-merge-vite-config-js/snap.txt +++ b/packages/global/snap-tests/migration-merge-vite-config-js/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should merge vite.config.js and remove oxlintrc +> vp migrate --no-interactive # migration should merge vite.config.js and remove oxlintrc ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-merge-vite-config-js/steps.json b/packages/global/snap-tests/migration-merge-vite-config-js/steps.json index 095a2ea1e4..924ddf3214 100644 --- a/packages/global/snap-tests/migration-merge-vite-config-js/steps.json +++ b/packages/global/snap-tests/migration-merge-vite-config-js/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should merge vite.config.js and remove oxlintrc", + "vp migrate --no-interactive # migration should merge vite.config.js and remove oxlintrc", "cat vite.config.js # check vite.config.js", "cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed", "cat package.json # check package.json" diff --git a/packages/global/snap-tests/migration-merge-vite-config-ts/snap.txt b/packages/global/snap-tests/migration-merge-vite-config-ts/snap.txt index ac1714334b..2749333984 100644 --- a/packages/global/snap-tests/migration-merge-vite-config-ts/snap.txt +++ b/packages/global/snap-tests/migration-merge-vite-config-ts/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc and oxfmtrc +> vp migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc and oxfmtrc ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-merge-vite-config-ts/steps.json b/packages/global/snap-tests/migration-merge-vite-config-ts/steps.json index ec2b381f28..557279f85d 100644 --- a/packages/global/snap-tests/migration-merge-vite-config-ts/steps.json +++ b/packages/global/snap-tests/migration-merge-vite-config-ts/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc and oxfmtrc", + "vp migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc and oxfmtrc", "cat vite.config.ts # check vite.config.ts", "cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed", "cat .oxfmtrc.json && exit 1 || true # check .oxfmtrc.json is removed", diff --git a/packages/global/snap-tests/migration-monorepo-pnpm-overrides-dependency-selector/snap.txt b/packages/global/snap-tests/migration-monorepo-pnpm-overrides-dependency-selector/snap.txt index be774f7d46..82b7f00bdb 100644 --- a/packages/global/snap-tests/migration-monorepo-pnpm-overrides-dependency-selector/snap.txt +++ b/packages/global/snap-tests/migration-monorepo-pnpm-overrides-dependency-selector/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should merge pnpm overrides with dependency selector +> vp migrate --no-interactive # migration should merge pnpm overrides with dependency selector ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● pnpm@ installing... diff --git a/packages/global/snap-tests/migration-monorepo-pnpm-overrides-dependency-selector/steps.json b/packages/global/snap-tests/migration-monorepo-pnpm-overrides-dependency-selector/steps.json index 46f23d010f..3dfcdd464d 100644 --- a/packages/global/snap-tests/migration-monorepo-pnpm-overrides-dependency-selector/steps.json +++ b/packages/global/snap-tests/migration-monorepo-pnpm-overrides-dependency-selector/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should merge pnpm overrides with dependency selector", + "vp migrate --no-interactive # migration should merge pnpm overrides with dependency selector", "cat vite.config.ts # check vite.config.ts", "cat package.json # check package.json", "cat pnpm-workspace.yaml # check pnpm-workspace.yaml", diff --git a/packages/global/snap-tests/migration-monorepo-pnpm/snap.txt b/packages/global/snap-tests/migration-monorepo-pnpm/snap.txt index 677bdf5b3a..ba21ccc4df 100644 --- a/packages/global/snap-tests/migration-monorepo-pnpm/snap.txt +++ b/packages/global/snap-tests/migration-monorepo-pnpm/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc and oxfmtrc +> vp migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc and oxfmtrc ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● pnpm@ installing... diff --git a/packages/global/snap-tests/migration-monorepo-pnpm/steps.json b/packages/global/snap-tests/migration-monorepo-pnpm/steps.json index de1233e239..d63145d090 100644 --- a/packages/global/snap-tests/migration-monorepo-pnpm/steps.json +++ b/packages/global/snap-tests/migration-monorepo-pnpm/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc and oxfmtrc", + "vp migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc and oxfmtrc", "cat vite.config.ts # check vite.config.ts", "cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed", "cat .oxfmtrc.json && exit 1 || true # check .oxfmtrc.json is removed", diff --git a/packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/snap.txt b/packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/snap.txt index d023abcd2e..13f04e285f 100644 --- a/packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/snap.txt +++ b/packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should check each package's peerDependencies +> vp migrate --no-interactive # migration should check each package's peerDependencies ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● pnpm@latest installing... diff --git a/packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/steps.json b/packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/steps.json index 24d0cf514b..e7b6c2e6c5 100644 --- a/packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/steps.json +++ b/packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should check each package's peerDependencies", + "vp migrate --no-interactive # migration should check each package's peerDependencies", "cat packages/vite-plugin/src/index.ts # vite-plugin has vite in peerDeps: vite NOT rewritten, vitest rewritten", "cat package.json # check root package.json (no peerDependencies)", "cat packages/vite-plugin/package.json # has vite in peerDependencies" diff --git a/packages/global/snap-tests/migration-monorepo-yarn4/snap.txt b/packages/global/snap-tests/migration-monorepo-yarn4/snap.txt index c910575263..bc405d86e6 100644 --- a/packages/global/snap-tests/migration-monorepo-yarn4/snap.txt +++ b/packages/global/snap-tests/migration-monorepo-yarn4/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc +> vp migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● yarn@ installing... diff --git a/packages/global/snap-tests/migration-monorepo-yarn4/steps.json b/packages/global/snap-tests/migration-monorepo-yarn4/steps.json index 094e40fe91..9196fa1106 100644 --- a/packages/global/snap-tests/migration-monorepo-yarn4/steps.json +++ b/packages/global/snap-tests/migration-monorepo-yarn4/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc", + "vp migrate --no-interactive # migration should merge vite.config.ts and remove oxlintrc", "cat vite.config.ts # check vite.config.ts", "cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed", "cat package.json # check package.json", diff --git a/packages/global/snap-tests/migration-no-agent/snap.txt b/packages/global/snap-tests/migration-no-agent/snap.txt index 14685f0e47..9cd76b8290 100644 --- a/packages/global/snap-tests/migration-no-agent/snap.txt +++ b/packages/global/snap-tests/migration-no-agent/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-agent --no-interactive # migration with --no-agent should skip agent instructions +> vp migrate --no-agent --no-interactive # migration with --no-agent should skip agent instructions ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-no-agent/steps.json b/packages/global/snap-tests/migration-no-agent/steps.json index 3b77091809..6c604001cd 100644 --- a/packages/global/snap-tests/migration-no-agent/steps.json +++ b/packages/global/snap-tests/migration-no-agent/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-agent --no-interactive # migration with --no-agent should skip agent instructions", + "vp migrate --no-agent --no-interactive # migration with --no-agent should skip agent instructions", "ls -la | grep -E '(AGENTS|CLAUDE)' || echo 'No agent file created' # verify no agent file was created" ] } diff --git a/packages/global/snap-tests/migration-not-supported-npm8.2/snap.txt b/packages/global/snap-tests/migration-not-supported-npm8.2/snap.txt index d6d65c456d..1652880be9 100644 --- a/packages/global/snap-tests/migration-not-supported-npm8.2/snap.txt +++ b/packages/global/snap-tests/migration-not-supported-npm8.2/snap.txt @@ -1,4 +1,4 @@ -[1]> vite migrate --no-interactive # migration should fail because npm version is not supported +[1]> vp migrate --no-interactive # migration should fail because npm version is not supported ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● npm@ installing... diff --git a/packages/global/snap-tests/migration-not-supported-npm8.2/steps.json b/packages/global/snap-tests/migration-not-supported-npm8.2/steps.json index 1cc6ba48c0..e29c5aed8d 100644 --- a/packages/global/snap-tests/migration-not-supported-npm8.2/steps.json +++ b/packages/global/snap-tests/migration-not-supported-npm8.2/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should fail because npm version is not supported", + "vp migrate --no-interactive # migration should fail because npm version is not supported", "cat package.json # check package.json is not updated" ] } diff --git a/packages/global/snap-tests/migration-not-supported-pnpm9.4/snap.txt b/packages/global/snap-tests/migration-not-supported-pnpm9.4/snap.txt index a7586da42f..d55e068cc2 100644 --- a/packages/global/snap-tests/migration-not-supported-pnpm9.4/snap.txt +++ b/packages/global/snap-tests/migration-not-supported-pnpm9.4/snap.txt @@ -1,4 +1,4 @@ -[1]> vite migrate --no-interactive # migration should fail because pnpm version is not supported +[1]> vp migrate --no-interactive # migration should fail because pnpm version is not supported ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● pnpm@ installing... diff --git a/packages/global/snap-tests/migration-not-supported-pnpm9.4/steps.json b/packages/global/snap-tests/migration-not-supported-pnpm9.4/steps.json index 9bfec5933b..a533e24783 100644 --- a/packages/global/snap-tests/migration-not-supported-pnpm9.4/steps.json +++ b/packages/global/snap-tests/migration-not-supported-pnpm9.4/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should fail because pnpm version is not supported", + "vp migrate --no-interactive # migration should fail because pnpm version is not supported", "cat package.json # check package.json is not updated" ] } diff --git a/packages/global/snap-tests/migration-not-supported-vite6/snap.txt b/packages/global/snap-tests/migration-not-supported-vite6/snap.txt index def1fc4ad1..580c1b7064 100644 --- a/packages/global/snap-tests/migration-not-supported-vite6/snap.txt +++ b/packages/global/snap-tests/migration-not-supported-vite6/snap.txt @@ -1,5 +1,5 @@ -> vite install # install dependencies first -[1]> vite migrate --no-interactive # migration should fail because vite version is not supported +> vp install # install dependencies first +[1]> vp migrate --no-interactive # migration should fail because vite version is not supported ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● pnpm@ installing... diff --git a/packages/global/snap-tests/migration-not-supported-vite6/steps.json b/packages/global/snap-tests/migration-not-supported-vite6/steps.json index 5594b69310..3659b71fd5 100644 --- a/packages/global/snap-tests/migration-not-supported-vite6/steps.json +++ b/packages/global/snap-tests/migration-not-supported-vite6/steps.json @@ -4,10 +4,10 @@ }, "commands": [ { - "command": "vite install # install dependencies first", + "command": "vp install # install dependencies first", "ignoreOutput": true }, - "vite migrate --no-interactive # migration should fail because vite version is not supported", + "vp migrate --no-interactive # migration should fail because vite version is not supported", "cat package.json # check package.json is not updated" ] } diff --git a/packages/global/snap-tests/migration-not-supported-vitest3/snap.txt b/packages/global/snap-tests/migration-not-supported-vitest3/snap.txt index 6418433a65..c49b38eb72 100644 --- a/packages/global/snap-tests/migration-not-supported-vitest3/snap.txt +++ b/packages/global/snap-tests/migration-not-supported-vitest3/snap.txt @@ -1,5 +1,5 @@ -> vite install # install dependencies first -[1]> vite migrate --no-interactive # migration should fail because vitest version is not supported +> vp install # install dependencies first +[1]> vp migrate --no-interactive # migration should fail because vitest version is not supported ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● pnpm@ installing... diff --git a/packages/global/snap-tests/migration-not-supported-vitest3/steps.json b/packages/global/snap-tests/migration-not-supported-vitest3/steps.json index 268b5f2929..3861e3203f 100644 --- a/packages/global/snap-tests/migration-not-supported-vitest3/steps.json +++ b/packages/global/snap-tests/migration-not-supported-vitest3/steps.json @@ -4,10 +4,10 @@ }, "commands": [ { - "command": "vite install # install dependencies first", + "command": "vp install # install dependencies first", "ignoreOutput": true }, - "vite migrate --no-interactive # migration should fail because vitest version is not supported", + "vp migrate --no-interactive # migration should fail because vitest version is not supported", "cat package.json # check package.json is not updated" ] } diff --git a/packages/global/snap-tests/migration-rewrite-declare-module/snap.txt b/packages/global/snap-tests/migration-rewrite-declare-module/snap.txt index ecec3c8fab..b855cbdff8 100644 --- a/packages/global/snap-tests/migration-rewrite-declare-module/snap.txt +++ b/packages/global/snap-tests/migration-rewrite-declare-module/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should rewrite imports to vite-plus +> vp migrate --no-interactive # migration should rewrite imports to vite-plus ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-rewrite-declare-module/steps.json b/packages/global/snap-tests/migration-rewrite-declare-module/steps.json index 17f56957a1..19b9bada8f 100644 --- a/packages/global/snap-tests/migration-rewrite-declare-module/steps.json +++ b/packages/global/snap-tests/migration-rewrite-declare-module/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should rewrite imports to vite-plus", + "vp migrate --no-interactive # migration should rewrite imports to vite-plus", "cat src/index.ts # check src/index.ts", "cat package.json # check package.json" ] diff --git a/packages/global/snap-tests/migration-skip-vite-dependency/snap.txt b/packages/global/snap-tests/migration-skip-vite-dependency/snap.txt index 40a946cca2..69407ed732 100644 --- a/packages/global/snap-tests/migration-skip-vite-dependency/snap.txt +++ b/packages/global/snap-tests/migration-skip-vite-dependency/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should skip rewriting vite imports when vite is in dependencies +> vp migrate --no-interactive # migration should skip rewriting vite imports when vite is in dependencies ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-skip-vite-dependency/steps.json b/packages/global/snap-tests/migration-skip-vite-dependency/steps.json index ab492bedfc..c2f5dc4c1e 100644 --- a/packages/global/snap-tests/migration-skip-vite-dependency/steps.json +++ b/packages/global/snap-tests/migration-skip-vite-dependency/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should skip rewriting vite imports when vite is in dependencies", + "vp migrate --no-interactive # migration should skip rewriting vite imports when vite is in dependencies", "cat src/index.ts # vite imports should NOT be rewritten, vitest imports SHOULD be rewritten", "cat package.json # check package.json" ] diff --git a/packages/global/snap-tests/migration-skip-vite-peer-dependency/snap.txt b/packages/global/snap-tests/migration-skip-vite-peer-dependency/snap.txt index 8a57297f86..d671345f8a 100644 --- a/packages/global/snap-tests/migration-skip-vite-peer-dependency/snap.txt +++ b/packages/global/snap-tests/migration-skip-vite-peer-dependency/snap.txt @@ -1,4 +1,4 @@ -> vite migrate --no-interactive # migration should skip rewriting vite imports when vite is in peerDependencies +> vp migrate --no-interactive # migration should skip rewriting vite imports when vite is in peerDependencies ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-skip-vite-peer-dependency/steps.json b/packages/global/snap-tests/migration-skip-vite-peer-dependency/steps.json index 30720e9c53..d66832e4fa 100644 --- a/packages/global/snap-tests/migration-skip-vite-peer-dependency/steps.json +++ b/packages/global/snap-tests/migration-skip-vite-peer-dependency/steps.json @@ -3,7 +3,7 @@ "VITE_DISABLE_AUTO_INSTALL": "1" }, "commands": [ - "vite migrate --no-interactive # migration should skip rewriting vite imports when vite is in peerDependencies", + "vp migrate --no-interactive # migration should skip rewriting vite imports when vite is in peerDependencies", "cat src/index.ts # vite imports should NOT be rewritten, vitest imports SHOULD be rewritten", "cat package.json # check package.json" ] diff --git a/packages/global/snap-tests/migration-subpath/snap.txt b/packages/global/snap-tests/migration-subpath/snap.txt index b93c50611c..d695bef129 100644 --- a/packages/global/snap-tests/migration-subpath/snap.txt +++ b/packages/global/snap-tests/migration-subpath/snap.txt @@ -1,4 +1,4 @@ -> vite migrate foo --no-interactive # migration work with subpath +> vp migrate foo --no-interactive # migration work with subpath ┌ VITE+(⚡︎) - The Unified Toolchain for the Web │ ● Using default package manager: pnpm diff --git a/packages/global/snap-tests/migration-subpath/steps.json b/packages/global/snap-tests/migration-subpath/steps.json index 64289f0a99..ba2c77b4f1 100644 --- a/packages/global/snap-tests/migration-subpath/steps.json +++ b/packages/global/snap-tests/migration-subpath/steps.json @@ -1,6 +1,6 @@ { "commands": [ - "vite migrate foo --no-interactive # migration work with subpath", + "vp migrate foo --no-interactive # migration work with subpath", "cat foo/package.json # check package.json" ] } diff --git a/packages/global/snap-tests/new-check/snap.txt b/packages/global/snap-tests/new-check/snap.txt index 2b2d279d9d..b3e777e4e4 100644 --- a/packages/global/snap-tests/new-check/snap.txt +++ b/packages/global/snap-tests/new-check/snap.txt @@ -1,12 +1,12 @@ -> vite new --help # show help +> vp new --help # show help VITE+(⚡︎) - The Unified Toolchain for the Web -USAGE: vite new [TEMPLATE] [OPTIONS] [-- TEMPLATE_OPTIONS] +USAGE: vp new [TEMPLATE] [OPTIONS] [-- TEMPLATE_OPTIONS] Use any builtin, local or remote template with Vite+. ARGUMENTS: - TEMPLATE Template name. Run `vite new --list` to see available templates. + TEMPLATE Template name. Run `vp new --list` to see available templates. - Default: vite:monorepo, vite:application, vite:library, vite:generator - Remote: create-vite, @tanstack/create-start, create-next-app, create-nuxt, github:user/repo, https://github.com/user/template-repo, etc. @@ -24,26 +24,26 @@ TEMPLATE OPTIONS: EXAMPLES: # Interactive mode - vite new + vp new # Use existing templates - vite new create-vite - vite new create-next-app - vite new @tanstack/create-start - vite new create-vite -- --template react-ts + vp new create-vite + vp new create-next-app + vp new @tanstack/create-start + vp new create-vite -- --template react-ts # Create Vite+ monorepo, application, library, or generator scaffolds - vite new vite:monorepo - vite new vite:application - vite new vite:library - vite new vite:generator + vp new vite:monorepo + vp new vite:application + vp new vite:library + vp new vite:generator # Use templates from GitHub (via degit) - vite new github:user/repo - vite new https://github.com/user/template-repo + vp new github:user/repo + vp new https://github.com/user/template-repo -> vite new --list # list templates +> vp new --list # list templates VITE+(⚡︎) - The Unified Toolchain for the Web VITE+ BUILT-IN TEMPLATES: @@ -62,22 +62,22 @@ POPULAR TEMPLATES: create-vue Vue application EXAMPLES: - vite new # interactive mode - vite new