Skip to content

Commit 72e914d

Browse files
fengmk2claude
andcommitted
feat(pm): add vite install command with package manager support
Implements a comprehensive package manager installation system that automatically detects and downloads the appropriate package manager (npm, yarn, pnpm) based on lockfiles, configuration files, and package.json settings. Key features: - Automatic package manager detection from multiple sources - Support for pnpm, yarn (including v2+), and npm - Intelligent version resolution with semver support - Automatic shim generation for cross-platform compatibility - HTTP client with automatic retry support using backon - Workspace root and package root detection utilities - Path filtering for cache optimization using gitignore-style patterns - Comprehensive test coverage with mocked HTTP requests Detection priority order: 1. packageManager field in package.json 2. pnpm-workspace.yaml 3. Lock files (pnpm-lock.yaml, yarn.lock, package-lock.json) 4. Config files (pnpmfile.cjs, yarn.config.cjs, .yarnrc.yml) The implementation ensures consistent package manager usage across the monorepo and automatically updates the packageManager field when detecting from other sources. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8c1c5c1 commit 72e914d

20 files changed

Lines changed: 4272 additions & 35 deletions

File tree

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,60 @@ jobs:
115115
vite-plus lint -h
116116
vite-plus test -h
117117
vite-plus build -h
118+
119+
e2e-test:
120+
name: E2E test
121+
runs-on: blaze/macos-latest
122+
steps:
123+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
124+
125+
- name: Setup Rust
126+
uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
127+
env:
128+
CARGO_INCREMENTAL: "1"
129+
130+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
131+
132+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
133+
with:
134+
node-version-file: .node-version
135+
cache: "pnpm"
136+
137+
- name: Install dependencies
138+
run: pnpm install
139+
140+
- name: Build vt
141+
run: cargo build --bin vt --release
142+
143+
- name: Run vt install
144+
run: |
145+
export PATH=$PWD/target/release:$PATH
146+
147+
# Test vt install on various repositories with different package managers
148+
repos=(
149+
# pnpm workspace
150+
"vitejs/vite:vite"
151+
"pnpm/pnpm:pnpm"
152+
# yarn workspace
153+
"napi-rs/napi-rs:napi-rs"
154+
"toeverything/AFFiNE:AFFiNE"
155+
# npm workspace
156+
"npm/cli:npm"
157+
"redhat-developer/vscode-extension-tester:vscode-extension-tester"
158+
)
159+
160+
for repo_info in "${repos[@]}"; do
161+
IFS=':' read -r repo dir_name <<< "$repo_info"
162+
echo "Testing vt install on $repo..."
163+
# remove the directory if it exists
164+
if [ -d "/tmp/$dir_name" ]; then
165+
rm -rf "/tmp/$dir_name"
166+
fi
167+
git clone --depth 1 "https://github.com/$repo.git" "/tmp/$dir_name"
168+
cd "/tmp/$dir_name"
169+
vt install
170+
# run again to show install cache increase by time
171+
time vt install
172+
echo "✓ Successfully installed dependencies for $repo"
173+
echo ""
174+
done

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
node_modules
33
dist
44
.claude/settings.local.json
5-
*.tsbuildinfo
5+
*.tsbuildinfo
6+
.DS_Store

0 commit comments

Comments
 (0)