🎨 Change npm to pnpm

This commit is contained in:
Tw93
2025-08-26 15:10:06 +08:00
parent f084b2fb75
commit 2b45a1f635
14 changed files with 2324 additions and 3713 deletions

View File

@@ -68,7 +68,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22
cache: "npm" cache: "pnpm"
- name: Install Rust for ubuntu-24.04 - name: Install Rust for ubuntu-24.04
if: inputs.platform == 'ubuntu-24.04' if: inputs.platform == 'ubuntu-24.04'
@@ -109,7 +109,7 @@ jobs:
path: | path: |
node_modules node_modules
~/.npm ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-node- ${{ runner.os }}-node-
@@ -117,7 +117,7 @@ jobs:
shell: bash shell: bash
run: | run: |
echo "Installing latest pake-cli..." echo "Installing latest pake-cli..."
npm install pake-cli@latest --no-package-lock pnpm install pake-cli@latest
# Verify installation # Verify installation
if [ ! -d "node_modules/pake-cli" ]; then if [ ! -d "node_modules/pake-cli" ]; then

View File

@@ -26,10 +26,10 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: "22" node-version: "22"
cache: "npm" cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: npm ci run: pnpm install --frozen-lockfile
- name: Check EditorConfig compliance - name: Check EditorConfig compliance
uses: editorconfig-checker/action-editorconfig-checker@main uses: editorconfig-checker/action-editorconfig-checker@main
@@ -93,7 +93,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22
cache: "npm" cache: "pnpm"
- name: Install Rust (Ubuntu) - name: Install Rust (Ubuntu)
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
@@ -124,13 +124,13 @@ jobs:
version: 1.1 version: 1.1
- name: Install dependencies - name: Install dependencies
run: npm ci run: pnpm install --frozen-lockfile
- name: Build CLI - name: Build CLI
run: npm run cli:build run: pnpm run cli:build
- name: Run CLI Test Suite - name: Run CLI Test Suite
run: npm test run: pnpm test
env: env:
CI: true CI: true
NODE_ENV: test NODE_ENV: test
@@ -161,7 +161,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22
cache: "npm" cache: "pnpm"
- name: Install Rust (Ubuntu) - name: Install Rust (Ubuntu)
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
@@ -198,10 +198,10 @@ jobs:
version: 1.1 version: 1.1
- name: Install dependencies - name: Install dependencies
run: npm ci run: pnpm install --frozen-lockfile
- name: Build CLI - name: Build CLI
run: npm run cli:build run: pnpm run cli:build
- name: Run Release Build Test - name: Run Release Build Test
run: ./tests/release.js run: ./tests/release.js

View File

@@ -76,7 +76,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22
cache: "npm" cache: "pnpm"
- name: Install dependencies (ubuntu only) - name: Install dependencies (ubuntu only)
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
@@ -104,8 +104,8 @@ jobs:
NAME_ZH: ${{ inputs.name_zh }} NAME_ZH: ${{ inputs.name_zh }}
URL: ${{ inputs.url }} URL: ${{ inputs.url }}
run: | run: |
npm ci pnpm install --frozen-lockfile
npm run build:config pnpm run build:config
- name: Add Rust targets for macOS universal build - name: Add Rust targets for macOS universal build
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
@@ -117,7 +117,7 @@ jobs:
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
timeout-minutes: 15 timeout-minutes: 15
run: | run: |
npm run tauri build pnpm run tauri build
mkdir -p output/linux mkdir -p output/linux
mv src-tauri/target/release/bundle/deb/*.deb output/linux/${{inputs.title}}_`arch`.deb mv src-tauri/target/release/bundle/deb/*.deb output/linux/${{inputs.title}}_`arch`.deb
mv src-tauri/target/release/bundle/appimage/*.AppImage output/linux/"${{inputs.title}}"_`arch`.AppImage mv src-tauri/target/release/bundle/appimage/*.AppImage output/linux/"${{inputs.title}}"_`arch`.AppImage
@@ -126,7 +126,7 @@ jobs:
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
timeout-minutes: 20 timeout-minutes: 20
run: | run: |
npm run tauri build -- --target universal-apple-darwin pnpm run tauri build -- --target universal-apple-darwin
mkdir -p output/macos mkdir -p output/macos
mv src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg output/macos/"${{inputs.title}}".dmg mv src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg output/macos/"${{inputs.title}}".dmg
@@ -134,7 +134,7 @@ jobs:
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
timeout-minutes: 15 timeout-minutes: 15
run: | run: |
npm run tauri build -- --target x86_64-pc-windows-msvc pnpm run tauri build -- --target x86_64-pc-windows-msvc
New-Item -Path "output\windows" -ItemType Directory New-Item -Path "output\windows" -ItemType Directory
Move-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\bundle\msi\*.msi" -Destination "output\windows\${{inputs.title}}_x64.msi" Move-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\bundle\msi\*.msi" -Destination "output\windows\${{inputs.title}}_x64.msi"
git checkout -- src-tauri/Cargo.lock git checkout -- src-tauri/Cargo.lock

View File

@@ -40,10 +40,11 @@ RUN --mount=type=cache,target=/var/cache/apt \
# Verify Rust version in builder stage # Verify Rust version in builder stage
RUN rustc --version && echo "Builder stage Rust version verified" RUN rustc --version && echo "Builder stage Rust version verified"
# Install Node.js 22.x # Install Node.js 22.x and pnpm
RUN --mount=type=cache,target=/var/cache/apt \ RUN --mount=type=cache,target=/var/cache/apt \
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get update && apt-get install -y nodejs apt-get update && apt-get install -y nodejs && \
npm install -g pnpm
# Copy project files # Copy project files
COPY . /pake COPY . /pake
@@ -55,9 +56,9 @@ COPY --from=cargo-builder /cargo-cache/git /usr/local/cargo/git
COPY --from=cargo-builder /cargo-cache/registry /usr/local/cargo/registry COPY --from=cargo-builder /cargo-cache/registry /usr/local/cargo/registry
# Install dependencies and build pake-cli # Install dependencies and build pake-cli
RUN --mount=type=cache,target=/root/.npm \ RUN --mount=type=cache,target=/root/.local/share/pnpm \
npm ci && \ pnpm install --frozen-lockfile && \
npm run cli:build pnpm run cli:build
# Set up the entrypoint # Set up the entrypoint
WORKDIR /output WORKDIR /output

3661
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,8 +3,12 @@
"version": "3.2.16", "version": "3.2.16",
"description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。", "description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。",
"engines": { "engines": {
"node": ">=16.0.0" "node": ">=18.0.0",
"pnpm": ">=10.0.0",
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm"
}, },
"packageManager": "pnpm@10.15.0",
"bin": { "bin": {
"pake": "./dist/cli.js" "pake": "./dist/cli.js"
}, },
@@ -29,19 +33,19 @@
"src-tauri" "src-tauri"
], ],
"scripts": { "scripts": {
"start": "npm run dev", "start": "pnpm run dev",
"dev": "npm run tauri dev", "dev": "pnpm run tauri dev",
"build": "npm run tauri build --", "build": "pnpm run tauri build --",
"build:debug": "npm run tauri build -- --debug", "build:debug": "pnpm run tauri build -- --debug",
"build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:mac": "pnpm run tauri build -- --target universal-apple-darwin",
"build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs", "build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs",
"analyze": "cd src-tauri && cargo bloat --release --crates", "analyze": "cd src-tauri && cargo bloat --release --crates",
"tauri": "tauri", "tauri": "tauri",
"cli": "cross-env NODE_ENV=development rollup -c -w", "cli": "cross-env NODE_ENV=development rollup -c -w",
"cli:build": "cross-env NODE_ENV=production rollup -c", "cli:build": "cross-env NODE_ENV=production rollup -c",
"test": "npm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js", "test": "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
"format": "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose", "format": "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
"prepublishOnly": "npm run cli:build" "prepublishOnly": "pnpm run cli:build"
}, },
"type": "module", "type": "module",
"exports": "./dist/cli.js", "exports": "./dist/cli.js",
@@ -80,7 +84,7 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"prettier": "^3.6.2", "prettier": "^3.6.2",
"rollup": "^4.46.3", "rollup": "^4.46.3",
"rollup-plugin-typescript2": "^0.36.0", "@rollup/plugin-typescript": "^12.1.2",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.9.2" "typescript": "^5.9.2"
} }

2266
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

2
pnpm-workspace.yaml Normal file
View File

@@ -0,0 +1,2 @@
onlyBuiltDependencies:
- sharp

3
rollup.config.js vendored
View File

@@ -1,7 +1,7 @@
import path from "path"; import path from "path";
import fs from "fs"; import fs from "fs";
import appRootPath from "app-root-path"; import appRootPath from "app-root-path";
import typescript from "rollup-plugin-typescript2"; import typescript from "@rollup/plugin-typescript";
import alias from "@rollup/plugin-alias"; import alias from "@rollup/plugin-alias";
import commonjs from "@rollup/plugin-commonjs"; import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json"; import json from "@rollup/plugin-json";
@@ -48,7 +48,6 @@ export default {
json(), json(),
typescript({ typescript({
tsconfig: "tsconfig.json", tsconfig: "tsconfig.json",
clean: true, // Clear cache
}), }),
commonjs(), commonjs(),
replace({ replace({

View File

@@ -6,10 +6,10 @@
```bash ```bash
# 完整测试套件(推荐) # 完整测试套件(推荐)
npm test # 运行完整测试套件包含真实构建测试8-12分钟 pnpm test # 运行完整测试套件包含真实构建测试8-12分钟
# 开发时快速测试 # 开发时快速测试
npm test -- --no-build # 跳过构建测试仅验证核心功能30秒 pnpm test -- --no-build # 跳过构建测试仅验证核心功能30秒
``` ```
### 🚀 完整测试套件包含 ### 🚀 完整测试套件包含
@@ -76,7 +76,7 @@ npm test -- --no-build # 跳过构建测试仅验证核心功能30秒
## 故障排除 ## 故障排除
**CLI 文件不存在**:运行 `npm run cli:build` **CLI 文件不存在**:运行 `pnpm run cli:build`
**测试超时**:构建测试需要较长时间完成 **测试超时**:构建测试需要较长时间完成
@@ -95,4 +95,4 @@ node ./tests/release.js
## 开发建议 ## 开发建议
提交代码前建议运行 `npm test` 确保所有平台构建正常。 提交代码前建议运行 `pnpm test` 确保所有平台构建正常。

View File

@@ -31,7 +31,7 @@ export const TEST_URLS = {
// Test assets for different scenarios // Test assets for different scenarios
export const TEST_ASSETS = { export const TEST_ASSETS = {
WEEKLY_ICNS: "https://gw.alipayobjects.com/os/k/fw/weekly.icns", WEEKLY_ICNS: "https://cdn.tw93.fun/pake/weekly.icns",
INVALID_ICON: "https://example.com/nonexistent.icns", INVALID_ICON: "https://example.com/nonexistent.icns",
}; };

View File

@@ -193,7 +193,7 @@ runner.addTest(
async () => { async () => {
try { try {
// Test installing pake-cli@latest (simulates GitHub Actions) // Test installing pake-cli@latest (simulates GitHub Actions)
execSync("npm install pake-cli@latest --no-package-lock", { execSync("pnpm install pake-cli@latest", {
encoding: "utf8", encoding: "utf8",
timeout: 60000, // 1 minute timeout timeout: 60000, // 1 minute timeout
cwd: "/tmp", cwd: "/tmp",
@@ -351,7 +351,7 @@ runner.addTest(
// Test icon URL validation (without actually downloading) // Test icon URL validation (without actually downloading)
const testScript = ` const testScript = `
const validIconUrls = [ const validIconUrls = [
'https://gw.alipayobjects.com/os/k/fw/weekly.icns', 'https://cdn.tw93.fun/pake/weekly.icns',
'https://example.com/icon.png', 'https://example.com/icon.png',
'https://cdn.example.com/assets/app.ico' 'https://cdn.example.com/assets/app.ico'
]; ];
@@ -460,15 +460,15 @@ runner.addTest(
// Simulate MacBuilder multi-arch command generation // Simulate MacBuilder multi-arch command generation
const generateMacBuildCommand = (multiArch, debug, features = ['cli-build']) => { const generateMacBuildCommand = (multiArch, debug, features = ['cli-build']) => {
if (!multiArch) { if (!multiArch) {
const baseCommand = debug ? 'npm run tauri build -- --debug' : 'npm run tauri build --'; const baseCommand = debug ? 'pnpm run tauri build -- --debug' : 'pnpm run tauri build --';
return features.length > 0 ? return features.length > 0 ?
\`\${baseCommand} --features \${features.join(',')}\` : \`\${baseCommand} --features \${features.join(',')}\` :
baseCommand; baseCommand;
} }
const baseCommand = debug const baseCommand = debug
? 'npm run tauri build -- --debug' ? 'pnpm run tauri build -- --debug'
: 'npm run tauri build --'; : 'pnpm run tauri build --';
const configPath = 'src-tauri/.pake/tauri.conf.json'; const configPath = 'src-tauri/.pake/tauri.conf.json';
let fullCommand = \`\${baseCommand} --target universal-apple-darwin -c "\${configPath}"\`; let fullCommand = \`\${baseCommand} --target universal-apple-darwin -c "\${configPath}"\`;
@@ -482,7 +482,7 @@ const generateMacBuildCommand = (multiArch, debug, features = ['cli-build']) =>
// Test different scenarios // Test different scenarios
const tests = [ const tests = [
{ multiArch: false, debug: false, expected: 'npm run tauri build -- --features cli-build' }, { multiArch: false, debug: false, expected: 'pnpm run tauri build -- --features cli-build' },
{ multiArch: true, debug: false, expected: 'universal-apple-darwin' }, { multiArch: true, debug: false, expected: 'universal-apple-darwin' },
{ multiArch: false, debug: true, expected: '--debug' }, { multiArch: false, debug: true, expected: '--debug' },
]; ];
@@ -537,7 +537,7 @@ runner.addTest(
// Check for essential workflow components // Check for essential workflow components
const requiredElements = [ const requiredElements = [
"npm install pake-cli@latest --no-package-lock", // Latest version installation "pnpm install pake-cli@latest", // Latest version installation
"timeout-minutes: 15", // Sufficient timeout "timeout-minutes: 15", // Sufficient timeout
"node ./script/github-action-build.js", // Build script execution "node ./script/github-action-build.js", // Build script execution
"ubuntu-24.04", // Linux support "ubuntu-24.04", // Linux support

View File

@@ -96,7 +96,7 @@ class PakeTestRunner {
// Check if CLI file exists // Check if CLI file exists
if (!fs.existsSync(config.CLI_PATH)) { if (!fs.existsSync(config.CLI_PATH)) {
console.log("❌ CLI file not found. Run: npm run cli:build"); console.log("❌ CLI file not found. Run: pnpm run cli:build");
process.exit(1); process.exit(1);
} }
console.log("✅ CLI file exists"); console.log("✅ CLI file exists");
@@ -328,7 +328,7 @@ class PakeTestRunner {
"pake-cli Package Installation", "pake-cli Package Installation",
async () => { async () => {
try { try {
execSync("npm install pake-cli@latest --no-package-lock", { execSync("pnpm install pake-cli@latest", {
encoding: "utf8", encoding: "utf8",
timeout: 60000, timeout: 60000,
cwd: "/tmp", cwd: "/tmp",
@@ -1209,7 +1209,7 @@ if (args.includes("--help") || args.includes("-h")) {
Usage: npm test [-- options] Usage: npm test [-- options]
Complete Test Suite (Default): Complete Test Suite (Default):
npm test # Run complete test suite with real build (8-12 minutes) pnpm test # Run complete test suite with real build (8-12 minutes)
Test Components: Test Components:
✅ Unit Tests # CLI commands, validation, response time ✅ Unit Tests # CLI commands, validation, response time
@@ -1230,7 +1230,7 @@ Skip Components (if needed):
Examples: Examples:
npm test # Complete test suite (recommended) npm test # Complete test suite (recommended)
npm test -- --e2e # Complete suite + end-to-end tests npm test -- --e2e # Complete suite + end-to-end tests
npm test -- --no-build # Skip real build (faster for development) pnpm test -- --no-build # Skip real build (faster for development)
Environment: Environment:
CI=1 # Enable CI mode CI=1 # Enable CI mode

View File

@@ -63,12 +63,12 @@ class ReleaseBuildTest {
try { try {
// Build config // Build config
this.log("DEBUG", "Configuring app..."); this.log("DEBUG", "Configuring app...");
execSync("npm run build:config", { stdio: "pipe" }); execSync("pnpm run build:config", { stdio: "pipe" });
// Build app // Build app
this.log("DEBUG", "Building app package..."); this.log("DEBUG", "Building app package...");
try { try {
execSync("npm run build:debug", { execSync("pnpm run build:debug", {
stdio: "pipe", stdio: "pipe",
timeout: 120000, // 2 minutes timeout: 120000, // 2 minutes
env: { ...process.env, PAKE_CREATE_APP: "1" }, env: { ...process.env, PAKE_CREATE_APP: "1" },