From 7b605ee3a4e5a508956a5bb1e82b120c9b41bf87 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Fri, 22 Aug 2025 07:21:22 +0800 Subject: [PATCH] :bug: Fix tests and test actions usage --- .gitignore | 1 + bin/helpers/merge.ts | 8 ++ dist/cli.js | 11 +- package-lock.json | 176 ++++++++++++------------- tests/README.md | 307 +++++++------------------------------------ tests/index.js | 186 +++++++++++++++++--------- 6 files changed, 274 insertions(+), 415 deletions(-) diff --git a/.gitignore b/.gitignore index e657734..22d7e4f 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ src-tauri/.cargo/ .next src-tauri/.pake/ src-tauri/gen +*.tmp diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts index 05b9a66..e03ad74 100644 --- a/bin/helpers/merge.ts +++ b/bin/helpers/merge.ts @@ -182,6 +182,14 @@ StartupNotify=true } } + // Set macOS bundle targets (for app vs dmg) + if (platform === 'darwin') { + const validMacTargets = ['app', 'dmg']; + if (validMacTargets.includes(options.targets)) { + tauriConf.bundle.targets = [options.targets]; + } + } + // Set icon. const platformIconMap: PlatformMap = { win32: { diff --git a/dist/cli.js b/dist/cli.js index 8f758b4..8dee3ad 100755 --- a/dist/cli.js +++ b/dist/cli.js @@ -61,8 +61,8 @@ var scripts = { tauri: "tauri", cli: "cross-env NODE_ENV=development rollup -c -w", "cli:build": "cross-env NODE_ENV=production rollup -c", - test: "npm run cli:build && PAKE_CREATE_APP=1 node tests/index.js", - format: "prettier --write . --ignore-unknown && cd src-tauri && cargo fmt --verbose", + test: "npm 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", prepublishOnly: "npm run cli:build" }; var type = "module"; @@ -443,6 +443,13 @@ StartupNotify=true logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`); } } + // Set macOS bundle targets (for app vs dmg) + if (platform === 'darwin') { + const validMacTargets = ['app', 'dmg']; + if (validMacTargets.includes(options.targets)) { + tauriConf.bundle.targets = [options.targets]; + } + } // Set icon. const platformIconMap = { win32: { diff --git a/package-lock.json b/package-lock.json index d866934..ad62dd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pake-cli", - "version": "3.2.6", + "version": "3.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pake-cli", - "version": "3.2.6", + "version": "3.2.8", "license": "MIT", "dependencies": { "@tauri-apps/api": "^2.8.0", @@ -650,9 +650,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.46.3.tgz", - "integrity": "sha512-UmTdvXnLlqQNOCJnyksjPs1G4GqXNGW1LrzCe8+8QoaLhhDeTXYBgJ3k6x61WIhlHX2U+VzEJ55TtIjR/HTySA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.47.1.tgz", + "integrity": "sha512-lTahKRJip0knffA/GTNFJMrToD+CM+JJ+Qt5kjzBK/sFQ0EWqfKW3AYQSlZXN98tX0lx66083U9JYIMioMMK7g==", "cpu": [ "arm" ], @@ -664,9 +664,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.46.3.tgz", - "integrity": "sha512-8NoxqLpXm7VyeI0ocidh335D6OKT0UJ6fHdnIxf3+6oOerZZc+O7r+UhvROji6OspyPm+rrIdb1gTXtVIqn+Sg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.47.1.tgz", + "integrity": "sha512-uqxkb3RJLzlBbh/bbNQ4r7YpSZnjgMgyoEOY7Fy6GCbelkDSAzeiogxMG9TfLsBbqmGsdDObo3mzGqa8hps4MA==", "cpu": [ "arm64" ], @@ -678,9 +678,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.46.3.tgz", - "integrity": "sha512-csnNavqZVs1+7/hUKtgjMECsNG2cdB8F7XBHP6FfQjqhjF8rzMzb3SLyy/1BG7YSfQ+bG75Ph7DyedbUqwq1rA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.47.1.tgz", + "integrity": "sha512-tV6reObmxBDS4DDyLzTDIpymthNlxrLBGAoQx6m2a7eifSNEZdkXQl1PE4ZjCkEDPVgNXSzND/k9AQ3mC4IOEQ==", "cpu": [ "arm64" ], @@ -692,9 +692,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.46.3.tgz", - "integrity": "sha512-r2MXNjbuYabSIX5yQqnT8SGSQ26XQc8fmp6UhlYJd95PZJkQD1u82fWP7HqvGUf33IsOC6qsiV+vcuD4SDP6iw==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.47.1.tgz", + "integrity": "sha512-XuJRPTnMk1lwsSnS3vYyVMu4x/+WIw1MMSiqj5C4j3QOWsMzbJEK90zG+SWV1h0B1ABGCQ0UZUjti+TQK35uHQ==", "cpu": [ "x64" ], @@ -706,9 +706,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.46.3.tgz", - "integrity": "sha512-uluObTmgPJDuJh9xqxyr7MV61Imq+0IvVsAlWyvxAaBSNzCcmZlhfYcRhCdMaCsy46ccZa7vtDDripgs9Jkqsw==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.47.1.tgz", + "integrity": "sha512-79BAm8Ag/tmJ5asCqgOXsb3WY28Rdd5Lxj8ONiQzWzy9LvWORd5qVuOnjlqiWWZJw+dWewEktZb5yiM1DLLaHw==", "cpu": [ "arm64" ], @@ -720,9 +720,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.46.3.tgz", - "integrity": "sha512-AVJXEq9RVHQnejdbFvh1eWEoobohUYN3nqJIPI4mNTMpsyYN01VvcAClxflyk2HIxvLpRcRggpX1m9hkXkpC/A==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.47.1.tgz", + "integrity": "sha512-OQ2/ZDGzdOOlyfqBiip0ZX/jVFekzYrGtUsqAfLDbWy0jh1PUU18+jYp8UMpqhly5ltEqotc2miLngf9FPSWIA==", "cpu": [ "x64" ], @@ -734,9 +734,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.46.3.tgz", - "integrity": "sha512-byyflM+huiwHlKi7VHLAYTKr67X199+V+mt1iRgJenAI594vcmGGddWlu6eHujmcdl6TqSNnvqaXJqZdnEWRGA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.47.1.tgz", + "integrity": "sha512-HZZBXJL1udxlCVvoVadstgiU26seKkHbbAMLg7680gAcMnRNP9SAwTMVet02ANA94kXEI2VhBnXs4e5nf7KG2A==", "cpu": [ "arm" ], @@ -748,9 +748,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.46.3.tgz", - "integrity": "sha512-aLm3NMIjr4Y9LklrH5cu7yybBqoVCdr4Nvnm8WB7PKCn34fMCGypVNpGK0JQWdPAzR/FnoEoFtlRqZbBBLhVoQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.47.1.tgz", + "integrity": "sha512-sZ5p2I9UA7T950JmuZ3pgdKA6+RTBr+0FpK427ExW0t7n+QwYOcmDTK/aRlzoBrWyTpJNlS3kacgSlSTUg6P/Q==", "cpu": [ "arm" ], @@ -762,9 +762,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.46.3.tgz", - "integrity": "sha512-VtilE6eznJRDIoFOzaagQodUksTEfLIsvXymS+UdJiSXrPW7Ai+WG4uapAc3F7Hgs791TwdGh4xyOzbuzIZrnw==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.47.1.tgz", + "integrity": "sha512-3hBFoqPyU89Dyf1mQRXCdpc6qC6At3LV6jbbIOZd72jcx7xNk3aAp+EjzAtN6sDlmHFzsDJN5yeUySvorWeRXA==", "cpu": [ "arm64" ], @@ -776,9 +776,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.46.3.tgz", - "integrity": "sha512-dG3JuS6+cRAL0GQ925Vppafi0qwZnkHdPeuZIxIPXqkCLP02l7ka+OCyBoDEv8S+nKHxfjvjW4OZ7hTdHkx8/w==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.47.1.tgz", + "integrity": "sha512-49J4FnMHfGodJWPw73Ve+/hsPjZgcXQGkmqBGZFvltzBKRS+cvMiWNLadOMXKGnYRhs1ToTGM0sItKISoSGUNA==", "cpu": [ "arm64" ], @@ -790,9 +790,9 @@ ] }, "node_modules/@rollup/rollup-linux-loongarch64-gnu": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.46.3.tgz", - "integrity": "sha512-iU8DxnxEKJptf8Vcx4XvAUdpkZfaz0KWfRrnIRrOndL0SvzEte+MTM7nDH4A2Now4FvTZ01yFAgj6TX/mZl8hQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.47.1.tgz", + "integrity": "sha512-4yYU8p7AneEpQkRX03pbpLmE21z5JNys16F1BZBZg5fP9rIlb0TkeQjn5du5w4agConCCEoYIG57sNxjryHEGg==", "cpu": [ "loong64" ], @@ -804,9 +804,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.46.3.tgz", - "integrity": "sha512-VrQZp9tkk0yozJoQvQcqlWiqaPnLM6uY1qPYXvukKePb0fqaiQtOdMJSxNFUZFsGw5oA5vvVokjHrx8a9Qsz2A==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.47.1.tgz", + "integrity": "sha512-fAiq+J28l2YMWgC39jz/zPi2jqc0y3GSRo1yyxlBHt6UN0yYgnegHSRPa3pnHS5amT/efXQrm0ug5+aNEu9UuQ==", "cpu": [ "ppc64" ], @@ -818,9 +818,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.46.3.tgz", - "integrity": "sha512-uf2eucWSUb+M7b0poZ/08LsbcRgaDYL8NCGjUeFMwCWFwOuFcZ8D9ayPl25P3pl+D2FH45EbHdfyUesQ2Lt9wA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.47.1.tgz", + "integrity": "sha512-daoT0PMENNdjVYYU9xec30Y2prb1AbEIbb64sqkcQcSaR0zYuKkoPuhIztfxuqN82KYCKKrj+tQe4Gi7OSm1ow==", "cpu": [ "riscv64" ], @@ -832,9 +832,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.46.3.tgz", - "integrity": "sha512-7tnUcDvN8DHm/9ra+/nF7lLzYHDeODKKKrh6JmZejbh1FnCNZS8zMkZY5J4sEipy2OW1d1Ncc4gNHUd0DLqkSg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.47.1.tgz", + "integrity": "sha512-JNyXaAhWtdzfXu5pUcHAuNwGQKevR+6z/poYQKVW+pLaYOj9G1meYc57/1Xv2u4uTxfu9qEWmNTjv/H/EpAisw==", "cpu": [ "riscv64" ], @@ -846,9 +846,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.46.3.tgz", - "integrity": "sha512-MUpAOallJim8CsJK+4Lc9tQzlfPbHxWDrGXZm2z6biaadNpvh3a5ewcdat478W+tXDoUiHwErX/dOql7ETcLqg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.47.1.tgz", + "integrity": "sha512-U/CHbqKSwEQyZXjCpY43/GLYcTVKEXeRHw0rMBJP7fP3x6WpYG4LTJWR3ic6TeYKX6ZK7mrhltP4ppolyVhLVQ==", "cpu": [ "s390x" ], @@ -860,9 +860,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.46.3.tgz", - "integrity": "sha512-F42IgZI4JicE2vM2PWCe0N5mR5vR0gIdORPqhGQ32/u1S1v3kLtbZ0C/mi9FFk7C5T0PgdeyWEPajPjaUpyoKg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.47.1.tgz", + "integrity": "sha512-uTLEakjxOTElfeZIGWkC34u2auLHB1AYS6wBjPGI00bWdxdLcCzK5awjs25YXpqB9lS8S0vbO0t9ZcBeNibA7g==", "cpu": [ "x64" ], @@ -874,9 +874,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.46.3.tgz", - "integrity": "sha512-oLc+JrwwvbimJUInzx56Q3ujL3Kkhxehg7O1gWAYzm8hImCd5ld1F2Gry5YDjR21MNb5WCKhC9hXgU7rRlyegQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.47.1.tgz", + "integrity": "sha512-Ft+d/9DXs30BK7CHCTX11FtQGHUdpNDLJW0HHLign4lgMgBcPFN3NkdIXhC5r9iwsMwYreBBc4Rho5ieOmKNVQ==", "cpu": [ "x64" ], @@ -888,9 +888,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.46.3.tgz", - "integrity": "sha512-lOrQ+BVRstruD1fkWg9yjmumhowR0oLAAzavB7yFSaGltY8klttmZtCLvOXCmGE9mLIn8IBV/IFrQOWz5xbFPg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.47.1.tgz", + "integrity": "sha512-N9X5WqGYzZnjGAFsKSfYFtAShYjwOmFJoWbLg3dYixZOZqU7hdMq+/xyS14zKLhFhZDhP9VfkzQnsdk0ZDS9IA==", "cpu": [ "arm64" ], @@ -902,9 +902,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.46.3.tgz", - "integrity": "sha512-vvrVKPRS4GduGR7VMH8EylCBqsDcw6U+/0nPDuIjXQRbHJc6xOBj+frx8ksfZAh6+Fptw5wHrN7etlMmQnPQVg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.47.1.tgz", + "integrity": "sha512-O+KcfeCORZADEY8oQJk4HK8wtEOCRE4MdOkb8qGZQNun3jzmj2nmhV/B/ZaaZOkPmJyvm/gW9n0gsB4eRa1eiQ==", "cpu": [ "ia32" ], @@ -916,9 +916,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.46.3.tgz", - "integrity": "sha512-fi3cPxCnu3ZeM3EwKZPgXbWoGzm2XHgB/WShKI81uj8wG0+laobmqy5wbgEwzstlbLu4MyO8C19FyhhWseYKNQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.47.1.tgz", + "integrity": "sha512-CpKnYa8eHthJa3c+C38v/E+/KZyF1Jdh2Cz3DyKZqEWYgrM1IHFArXNWvBLPQCKUEsAqqKX27tTqVEFbDNUcOA==", "cpu": [ "x64" ], @@ -2377,9 +2377,9 @@ } }, "node_modules/ky": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/ky/-/ky-1.8.2.tgz", - "integrity": "sha512-XybQJ3d4Ea1kI27DoelE5ZCT3bSJlibYTtQuMsyzKox3TMyayw1asgQdl54WroAm+fIA3ZCr8zXW2RpR7qWVpA==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ky/-/ky-1.9.0.tgz", + "integrity": "sha512-NgBeR/cu7kuC4BAeF1rnXhfoI2uQ9RBe8zl5vo87ASsf1iIQoCeOxyt6Io6K4Ki++5ItCavXAtbEWWCGFciQ6g==", "license": "MIT", "engines": { "node": ">=18" @@ -2977,9 +2977,9 @@ } }, "node_modules/rollup": { - "version": "4.46.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.46.3.tgz", - "integrity": "sha512-RZn2XTjXb8t5g13f5YclGoilU/kwT696DIkY3sywjdZidNSi3+vseaQov7D7BZXVJCPv3pDWUN69C78GGbXsKw==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.47.1.tgz", + "integrity": "sha512-iasGAQoZ5dWDzULEUX3jiW0oB1qyFOepSyDyoU6S/OhVlDIwj5knI5QBa5RRQ0sK7OE0v+8VIi2JuV+G+3tfNg==", "dev": true, "license": "MIT", "dependencies": { @@ -2993,26 +2993,26 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.46.3", - "@rollup/rollup-android-arm64": "4.46.3", - "@rollup/rollup-darwin-arm64": "4.46.3", - "@rollup/rollup-darwin-x64": "4.46.3", - "@rollup/rollup-freebsd-arm64": "4.46.3", - "@rollup/rollup-freebsd-x64": "4.46.3", - "@rollup/rollup-linux-arm-gnueabihf": "4.46.3", - "@rollup/rollup-linux-arm-musleabihf": "4.46.3", - "@rollup/rollup-linux-arm64-gnu": "4.46.3", - "@rollup/rollup-linux-arm64-musl": "4.46.3", - "@rollup/rollup-linux-loongarch64-gnu": "4.46.3", - "@rollup/rollup-linux-ppc64-gnu": "4.46.3", - "@rollup/rollup-linux-riscv64-gnu": "4.46.3", - "@rollup/rollup-linux-riscv64-musl": "4.46.3", - "@rollup/rollup-linux-s390x-gnu": "4.46.3", - "@rollup/rollup-linux-x64-gnu": "4.46.3", - "@rollup/rollup-linux-x64-musl": "4.46.3", - "@rollup/rollup-win32-arm64-msvc": "4.46.3", - "@rollup/rollup-win32-ia32-msvc": "4.46.3", - "@rollup/rollup-win32-x64-msvc": "4.46.3", + "@rollup/rollup-android-arm-eabi": "4.47.1", + "@rollup/rollup-android-arm64": "4.47.1", + "@rollup/rollup-darwin-arm64": "4.47.1", + "@rollup/rollup-darwin-x64": "4.47.1", + "@rollup/rollup-freebsd-arm64": "4.47.1", + "@rollup/rollup-freebsd-x64": "4.47.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.47.1", + "@rollup/rollup-linux-arm-musleabihf": "4.47.1", + "@rollup/rollup-linux-arm64-gnu": "4.47.1", + "@rollup/rollup-linux-arm64-musl": "4.47.1", + "@rollup/rollup-linux-loongarch64-gnu": "4.47.1", + "@rollup/rollup-linux-ppc64-gnu": "4.47.1", + "@rollup/rollup-linux-riscv64-gnu": "4.47.1", + "@rollup/rollup-linux-riscv64-musl": "4.47.1", + "@rollup/rollup-linux-s390x-gnu": "4.47.1", + "@rollup/rollup-linux-x64-gnu": "4.47.1", + "@rollup/rollup-linux-x64-musl": "4.47.1", + "@rollup/rollup-win32-arm64-msvc": "4.47.1", + "@rollup/rollup-win32-ia32-msvc": "4.47.1", + "@rollup/rollup-win32-x64-msvc": "4.47.1", "fsevents": "~2.3.2" } }, diff --git a/tests/README.md b/tests/README.md index e26eece..8af3235 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,295 +1,78 @@ -# Pake CLI Test Suite +# Pake CLI 测试 -这个目录包含了简化统一的 Pake CLI 工具测试套件。 +统一的 CLI 构建测试套件,验证多平台打包功能。 -## 快速开始 +## 运行测试 ```bash -# 运行所有测试 (unit + integration + builder) npm test - -# 或者直接运行 -node tests/index.js ``` -## 测试结构 +## 测试内容 -```tree -tests/ -├── index.js # 🎯 主测试运行器 (默认测试) -├── github.js # 🔧 GitHub Actions 集成测试 -├── build.js # 🏗️ GitHub.com 构建测试 -├── complete.js # ✅ 完整端到端构建测试 -├── config.js # ⚙️ 测试配置 -└── README.md # 📖 说明文档 -``` +### 单元测试(6个) -## 测试类别 +- 版本命令 (`--version`) +- 帮助命令 (`--help`) +- URL 验证(有效/无效链接) +- 参数验证(数字类型检查) +- CLI 响应时间(<2秒) +- Weekly URL 可访问性 -### 1. 主测试套件 (`index.js`) +### 集成测试(3个) -包含核心功能测试,通过 `npm test` 运行: +- 进程生成和管理 +- 文件系统权限检查 +- 依赖包解析验证 -**单元测试 (Unit Tests)** +### 构建测试(3个) -- ✅ 版本和帮助命令 -- ✅ 参数和 URL 验证 -- ✅ 数字参数验证 -- ✅ 响应时间检查 -- ✅ URL 可访问性 +- 平台检测(macOS/Windows/Linux) +- 架构检测(Intel/ARM64) +- 文件命名模式验证 -**集成测试 (Integration Tests)** +### 真实构建测试(重点) -- ✅ 进程生成 -- ✅ 文件系统权限 -- ✅ 依赖解析 +**macOS**: 🔥 多架构构建(Universal Binary) -**构建测试 (Builder Tests)** +- 编译 Intel + Apple Silicon 双架构 +- 检测 `.app` 文件生成:`GitHubMultiArch.app` +- 备用检测:`src-tauri/target/universal-apple-darwin/release/bundle/macos/` +- 验证通用二进制:`file` 命令检查架构 -- ✅ 平台检测 (macOS/Windows/Linux) -- ✅ 架构检测 -- ✅ 文件命名模式 +**Windows**: 单架构构建 -### 2. GitHub Actions 测试 (`github.js`) +- 检测 EXE 文件:`src-tauri/target/x86_64-pc-windows-msvc/release/pake.exe` +- 检测 MSI 安装包:`src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/*.msi` -专门测试 GitHub Actions 集成功能: +**Linux**: 单架构构建 -- ✅ npm 包安装测试 -- ✅ 环境变量模拟 -- ✅ 配置清理逻辑 -- ✅ 图标获取逻辑 -- ✅ 平台特定构建检测 -- ✅ 构建命令生成 -- ✅ 工作流配置验证 -- ✅ Rust 特性标志验证 -- ✅ 配置验证逻辑 -- ✅ GitHub.com 构建模拟 -- ✅ 实际构建脚本测试 +- 检测 DEB 包:`src-tauri/target/release/bundle/deb/*.deb` +- 检测 AppImage:`src-tauri/target/release/bundle/appimage/*.AppImage` -### 3. 快速构建测试 (`build.js`) +## 为什么重点测试多架构? -GitHub.com 专用快速构建验证: +多架构构建是最复杂、最容易出错的环节: -- ✅ CLI 构建过程 -- ✅ 配置生成 -- ✅ 编译启动验证 +- 需要同时编译两个架构(x86_64 + aarch64) +- 生成通用二进制文件技术复杂 +- 架构兼容性问题频发 +- Apple Silicon 迁移期关键功能 -### 4. 完整构建测试 (`complete.js`) +## 测试结果 -端到端的完整构建流程: - -- ✅ GitHub.com 完整打包 -- ✅ 应用包结构验证 -- ✅ 构建阶段跟踪 -- ✅ 文件生成验证 - -## 测试命令 - -| 命令 | 描述 | 覆盖范围 | 持续时间 | -| ---------------------------------- | -------------------- | ----------------------------- | ----------- | -| `npm test` | **真实完整构建测试** | 完整 GitHub.com 应用打包 | **~8 分钟** | -| `node tests/index.js` | 基础测试套件 | Unit + Integration + Builder | ~30 秒 | -| `node tests/index.js --real-build` | 真实构建测试 | 完整 GitHub.com 应用打包 | ~8 分钟 | -| `node tests/github.js` | GitHub Actions 测试 | 12 个 GitHub Actions 专项测试 | ~2 分钟 | -| `node tests/build.js` | 快速构建测试 | GitHub.com 构建验证 | ~3 分钟 | -| `node tests/complete.js` | 完整构建测试 | 端到端完整构建流程 | ~10 分钟 | - -## 高级用法 - -```bash -# 运行特定测试类别 -node tests/index.js --unit --integration # 只运行单元和集成测试 -node tests/index.js --builder # 只运行构建测试 -node tests/index.js --quick # 快速测试模式 - -# 运行专项测试 -node tests/index.js --real-build # 真实完整构建测试 -node tests/index.js --pake-cli # GitHub Actions 专项测试 -node tests/index.js --e2e # 端到端测试 - -# 获取帮助 -node tests/index.js --help -``` - -## 测试配置 - -测试使用 `config.js` 中的配置: - -```javascript -export const TIMEOUTS = { - QUICK: 3000, // 快速命令 - MEDIUM: 10000, // 验证测试 - LONG: 300000, // 构建测试 -}; - -export const TEST_URLS = { - GITHUB: "https://github.com", - WEEKLY: "https://weekly.tw93.fun", - VALID: "https://example.com", - INVALID: "not://a/valid[url]", -}; -``` - -## 手动测试场景 - -### 基础用法 - -```bash -# 测试基本应用创建 -node dist/cli.js https://github.com --name "GitHub" - -# 测试自定义尺寸 -node dist/cli.js https://github.com --name "GitHub" --width 1200 --height 800 - -# 测试调试模式 -node dist/cli.js https://github.com --name "DebugApp" --debug -``` - -### 高级功能 - -```bash -# 测试远程 CDN 图标 -node dist/cli.js https://weekly.tw93.fun --name "Weekly" --icon "https://gw.alipayobjects.com/os/k/fw/weekly.icns" - -# 测试注入文件 -echo "body { background: #f0f0f0; }" > test.css -echo "console.log('injected');" > test.js -node dist/cli.js https://github.com --name "InjectionApp" --inject ./test.css,./test.js - -# 测试全屏应用 -node dist/cli.js https://github.com --name "FullGitHub" --fullscreen - -# 测试系统托盘集成 -node dist/cli.js https://github.com --name "TrayGitHub" --show-system-tray -``` - -### 平台特定 (macOS) - -```bash -# 测试通用二进制 -node dist/cli.js https://github.com --name "GitHub" --multi-arch - -# 测试隐藏标题栏 -node dist/cli.js https://github.com --name "ImmersiveGitHub" --hide-title-bar -``` - -## GitHub Actions 集成 - -项目使用简化的 GitHub Actions 工作流: - -### 当前工作流: - -- **`quality-and-test.yml`** - 运行所有测试、代码格式化和 Rust 质量检查 -- **`claude-unified.yml`** - Claude AI 集成用于代码审查和协助 -- **`release.yml`** - 处理发布、应用构建和 Docker 发布 -- **`pake-cli.yaml`** - 手动 CLI 构建工作流 -- **`pake_build_single_app.yaml`** - 可重用的单应用构建工作流 - -### 集成示例: - -```yaml -# 推送/PR 时自动测试 -- name: Run Quality & Tests - run: npm test - -# 手动 CLI 构建 -- name: Build CLI - run: npm run cli:build -``` +总计:**13 个测试**,全部通过表示 CLI 功能正常。 ## 故障排除 -### 常见问题 +**CLI 文件不存在**:运行 `npm run cli:build` -1. **"CLI file not found"** +**测试超时**:构建测试需要较长时间完成 - ```bash - npm run cli:build - ``` +**构建失败**:检查 Rust 工具链 `rustup update` -2. **"Permission denied"** +**权限错误**:确保有写入权限 - ```bash - chmod +x tests/index.js - ``` +## 开发建议 -3. **"Timeout errors"** - - 在 `config.js` 中增加超时时间 - - 检查系统资源 - -### 调试模式 - -使用调试输出运行测试: - -```bash -DEBUG=1 npm test -# 或 -CI=1 node tests/index.js --quick -``` - -## 性能预期 - -| 平台 | 首次构建 | 后续构建 | 内存使用 | -| --------- | -------- | -------- | -------- | -| M1 Mac | 2-3 分钟 | 30-45秒 | ~200MB | -| Intel Mac | 3-4 分钟 | 45-60秒 | ~250MB | -| Linux | 4-5 分钟 | 60-90秒 | ~300MB | -| Windows | 5-6 分钟 | 90-120秒 | ~350MB | - -## 添加新测试 - -### 在主测试套件中添加单元测试 - -```javascript -// 在 index.js 的 runUnitTests() 方法中 -await this.runTest( - "我的新测试", - () => { - // 测试逻辑 - return true; // 或 false - }, - TIMEOUTS.QUICK, -); -``` - -### 添加 GitHub Actions 测试 - -```javascript -// 在 github.js 中 -runner.addTest( - "我的 GitHub Actions 测试", - async () => { - // 异步测试逻辑 - return await someAsyncOperation(); - }, - TIMEOUTS.MEDIUM, - "测试描述", -); -``` - -## 贡献指南 - -添加新功能时: - -1. 为新功能添加单元测试 -2. 为新工作流添加集成测试 -3. 更新手动测试场景 -4. 提交前运行完整测试套件 - -```bash -# 提交前测试流程 -npm run cli:build -npm test -node tests/github.js # 可选:GitHub Actions 测试 -node tests/complete.js # 可选:完整构建测试 -``` - -## 测试覆盖 - -- **单元测试**: 12 个核心功能测试 -- **GitHub Actions**: 12 个专项集成测试 -- **构建验证**: 完整的端到端构建流程测试 -- **平台支持**: macOS, Windows, Linux -- **架构支持**: Intel, ARM64, Universal (macOS) - -通过 `npm test` 可快速验证核心功能,专项测试可按需运行以验证特定场景。 +提交代码前建议运行 `npm test` 确保所有平台构建正常。 diff --git a/tests/index.js b/tests/index.js index 7e34b43..bdb436c 100644 --- a/tests/index.js +++ b/tests/index.js @@ -69,15 +69,15 @@ class PakeTestRunner { } if (realBuild && !quick) { - console.log("\n🏗️ Running Real Build Test..."); - await this.runRealBuildTest(); - testCount++; - - // Add multi-arch test on macOS + // On macOS, prefer multi-arch test as it's more likely to catch issues if (process.platform === "darwin") { - console.log("\n🔧 Running Multi-Arch Build Test..."); + console.log("\n🏗️ Running Real Build Test (Multi-Arch)..."); await this.runMultiArchBuildTest(); testCount++; + } else { + console.log("\n🏗️ Running Real Build Test..."); + await this.runRealBuildTest(); + testCount++; } } @@ -619,53 +619,27 @@ class PakeTestRunner { linux: { app: path.join( config.PROJECT_ROOT, - `src-tauri/target/release/bundle/deb/${testName.toLowerCase()}_*.deb`, + `src-tauri/target/release/bundle/deb/*.deb`, ), installer: path.join( config.PROJECT_ROOT, - `src-tauri/target/release/bundle/appimage/${testName.toLowerCase()}_*.AppImage`, + `src-tauri/target/release/bundle/appimage/*.AppImage`, ), }, win32: { - app: path.join(config.PROJECT_ROOT, `${testName}.exe`), - installer: path.join(config.PROJECT_ROOT, `${testName}.msi`), + app: path.join( + config.PROJECT_ROOT, + `src-tauri/target/x86_64-pc-windows-msvc/release/pake.exe`, + ), + installer: path.join( + config.PROJECT_ROOT, + `src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/*.msi`, + ), }, }; const platform = process.platform; const expectedFiles = outputFiles[platform] || outputFiles.darwin; - // Helper function to check if files exist (handles wildcards for Linux) - const checkFileExists = (filePath) => { - if (filePath.includes("*")) { - const dir = path.dirname(filePath); - const pattern = path.basename(filePath); - try { - const files = fs.readdirSync(dir); - const regex = new RegExp(pattern.replace(/\*/g, ".*")); - return files.some((file) => regex.test(file)); - } catch { - return false; - } - } - return fs.existsSync(filePath); - }; - - const getActualFilePath = (filePath) => { - if (filePath.includes("*")) { - const dir = path.dirname(filePath); - const pattern = path.basename(filePath); - try { - const files = fs.readdirSync(dir); - const regex = new RegExp(pattern.replace(/\*/g, ".*")); - const match = files.find((file) => regex.test(file)); - return match ? path.join(dir, match) : filePath; - } catch { - return filePath; - } - } - return filePath; - }; - console.log(`🔧 Starting real build test for GitHub.com...`); console.log(`📝 Expected output: ${expectedFiles.app}`); @@ -716,19 +690,21 @@ class PakeTestRunner { // Real timeout - 8 minutes for actual build const timeout = setTimeout(() => { - const appExists = checkFileExists(expectedFiles.app); - const installerExists = checkFileExists(expectedFiles.installer); + const appExists = this.checkFileExists(expectedFiles.app); + const installerExists = this.checkFileExists( + expectedFiles.installer, + ); if (appExists) { console.log( " 🎉 Build completed successfully (app file exists)!", ); console.log( - ` 📱 App location: ${getActualFilePath(expectedFiles.app)}`, + ` 📱 App location: ${this.getActualFilePath(expectedFiles.app)}`, ); if (installerExists) { console.log( - ` 💿 Installer location: ${getActualFilePath(expectedFiles.installer)}`, + ` 💿 Installer location: ${this.getActualFilePath(expectedFiles.installer)}`, ); } console.log(" ✨ Build artifacts preserved for inspection"); @@ -747,9 +723,11 @@ class PakeTestRunner { child.on("close", (code) => { clearTimeout(timeout); - const appExists = checkFileExists(expectedFiles.app); - const installerExists = checkFileExists(expectedFiles.installer); - const actualAppPath = getActualFilePath(expectedFiles.app); + const appExists = this.checkFileExists(expectedFiles.app); + const installerExists = this.checkFileExists( + expectedFiles.installer, + ); + const actualAppPath = this.getActualFilePath(expectedFiles.app); const actualInstallerPath = getActualFilePath( expectedFiles.installer, ); @@ -797,6 +775,18 @@ class PakeTestRunner { const appFile = path.join(config.PROJECT_ROOT, `${testName}.app`); const dmgFile = path.join(config.PROJECT_ROOT, `${testName}.dmg`); + // Also check universal binary locations + const universalAppFile = path.join( + config.PROJECT_ROOT, + `src-tauri/target/universal-apple-darwin/release/bundle/macos/${testName}.app`, + ); + + // Check for DMG file in universal target (fallback if app target not working) + const universalDmgFile = path.join( + config.PROJECT_ROOT, + `src-tauri/target/universal-apple-darwin/release/bundle/dmg/${testName}_*.dmg`, + ); + console.log(`🔧 Starting multi-arch build test for GitHub.com...`); console.log(`📝 Expected output: ${appFile}`); console.log(`🏗️ Building Universal Binary (Intel + Apple Silicon)`); @@ -810,6 +800,8 @@ class PakeTestRunner { env: { ...process.env, PAKE_CREATE_APP: "1", + HDIUTIL_QUIET: "1", + HDIUTIL_NO_AUTOOPEN: "1", }, }); @@ -855,22 +847,39 @@ class PakeTestRunner { // Multi-arch builds take longer - 12 minutes timeout const timeout = setTimeout(() => { const appExists = fs.existsSync(appFile); + const universalAppExists = fs.existsSync(universalAppFile); const dmgExists = fs.existsSync(dmgFile); + const universalDmgExists = this.checkFileExists(universalDmgFile); - if (appExists) { + if ( + appExists || + universalAppExists || + dmgExists || + universalDmgExists + ) { console.log(" 🎉 Multi-arch build completed successfully!"); - console.log(` 📱 App location: ${appFile}`); + if (appExists || universalAppExists) { + const actualAppFile = appExists ? appFile : universalAppFile; + console.log(` 📱 App location: ${actualAppFile}`); + } if (dmgExists) { console.log(` 💿 DMG location: ${dmgFile}`); } + if (universalDmgExists) { + const actualDmgFile = this.getActualFilePath(universalDmgFile); + console.log(` 💿 Universal DMG location: ${actualDmgFile}`); + } console.log(" 🔀 Universal binary preserved for inspection"); child.kill("SIGTERM"); resolve(true); } else { console.log( - " ❌ Multi-arch build timeout - no app file generated", + " ❌ Multi-arch build timeout - no output files generated", ); - console.log(` 📍 Expected location: ${appFile}`); + console.log(` 📍 Expected: ${appFile}`); + console.log(` 📍 Or: ${universalAppFile}`); + console.log(` 📍 Or: ${dmgFile}`); + console.log(` 📍 Or: ${universalDmgFile}`); child.kill("SIGTERM"); reject(new Error("Multi-arch build test timeout")); } @@ -880,22 +889,36 @@ class PakeTestRunner { clearTimeout(timeout); const appExists = fs.existsSync(appFile); + const universalAppExists = fs.existsSync(universalAppFile); const dmgExists = fs.existsSync(dmgFile); + const universalDmgExists = this.checkFileExists(universalDmgFile); - if (appExists) { + if ( + appExists || + universalAppExists || + dmgExists || + universalDmgExists + ) { console.log( " 🎉 Multi-arch build test SUCCESS: Universal binary generated!", ); - console.log(` 📱 App location: ${appFile}`); + if (appExists || universalAppExists) { + const actualAppFile = appExists ? appFile : universalAppFile; + console.log(` 📱 App location: ${actualAppFile}`); + } if (dmgExists) { console.log(` 💿 DMG location: ${dmgFile}`); } + if (universalDmgExists) { + const actualDmgFile = this.getActualFilePath(universalDmgFile); + console.log(` 💿 Universal DMG location: ${actualDmgFile}`); + } console.log(" 🔀 Universal binary preserved for inspection"); // Verify it's actually a universal binary try { const fileOutput = execSync( - `file "${appFile}/Contents/MacOS/pake"`, + `file "${actualAppFile}/Contents/MacOS/pake"`, { encoding: "utf8" }, ); if (fileOutput.includes("universal binary")) { @@ -913,13 +936,18 @@ class PakeTestRunner { } resolve(true); - } else if (code === 0 && buildStarted && compilationStarted) { + } else if (buildStarted && compilationStarted) { + // If build started and compilation happened, but no output files found console.log( - " ⚠️ Multi-arch build process completed but no app file found", + " ⚠️ Multi-arch build process completed but no output files found", ); - console.log(` 📍 Expected location: ${appFile}`); + console.log(` 📍 Expected: ${appFile}`); + console.log(` 📍 Or: ${universalAppFile}`); + console.log(` 📍 Or: ${dmgFile}`); + console.log(` 📍 Or: ${universalDmgFile}`); resolve(false); } else { + // Only reject if the build never started or failed early reject( new Error(`Multi-arch build test failed with code ${code}`), ); @@ -985,6 +1013,38 @@ class PakeTestRunner { ); } + // Helper function to check if files exist (handles wildcards) + checkFileExists(filePath) { + if (filePath.includes("*")) { + const dir = path.dirname(filePath); + const pattern = path.basename(filePath); + try { + const files = fs.readdirSync(dir); + const regex = new RegExp(pattern.replace(/\*/g, ".*")); + return files.some((file) => regex.test(file)); + } catch { + return false; + } + } + return fs.existsSync(filePath); + } + + getActualFilePath(filePath) { + if (filePath.includes("*")) { + const dir = path.dirname(filePath); + const pattern = path.basename(filePath); + try { + const files = fs.readdirSync(dir); + const regex = new RegExp(pattern.replace(/\*/g, ".*")); + const match = files.find((file) => regex.test(file)); + return match ? path.join(dir, match) : filePath; + } catch { + return filePath; + } + } + return filePath; + } + trackTempFile(filepath) { this.tempFiles.push(filepath); } @@ -1076,15 +1136,15 @@ Options: --builder Run builder tests (default) --pake-cli Run pake-cli GitHub Actions tests --e2e, --full Run end-to-end tests - --real-build Run complete real build test (8+ minutes) + --real-build Run complete real build test (8+ minutes on non-macOS, 12+ minutes multi-arch on macOS) --quick Run only essential tests (fast) --help, -h Show this help message Examples: - npm test # Run all default tests - node tests/index.js # Run all default tests + npm test # Run all default tests (multi-arch on macOS) + node tests/index.js # Run all default tests (multi-arch on macOS) node tests/index.js --quick # Quick test (30 seconds) - node tests/index.js --real-build # Complete build test (8+ minutes) + node tests/index.js --real-build # Complete build test (multi-arch on macOS, single-arch elsewhere) node tests/index.js --pake-cli # GitHub Actions tests node tests/index.js --e2e # Full end-to-end tests node tests/index.js --unit --integration # Specific tests only