From 4685d3fb67df108ec16f682285bb36f92d1268a4 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Wed, 20 Aug 2025 16:11:58 +0800 Subject: [PATCH] :bug: Fix the problem of packaging bash under Windows --- .github/workflows/pake-cli.yaml | 1 + dist/cli.js | 4 +- package.json | 2 +- script/build_with_pake_cli.js | 86 ++++++++++++++++----------------- 4 files changed, 45 insertions(+), 48 deletions(-) diff --git a/.github/workflows/pake-cli.yaml b/.github/workflows/pake-cli.yaml index 4210446..e9ee51b 100644 --- a/.github/workflows/pake-cli.yaml +++ b/.github/workflows/pake-cli.yaml @@ -121,6 +121,7 @@ jobs: key: ${{ runner.os }}-pake-cli-${{ hashFiles('**/package.json') }} - name: Install pake-cli and script dependencies + shell: bash run: | if [ ! -d "node_modules/pake-cli" ]; then echo "Installing pake-cli..." diff --git a/dist/cli.js b/dist/cli.js index f998f06..272c3f7 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -22,7 +22,7 @@ import sharp from 'sharp'; import * as psl from 'psl'; var name = "pake-cli"; -var version$1 = "3.2.1"; +var version$1 = "3.2.2"; var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。"; var engines = { node: ">=16.0.0" @@ -662,7 +662,7 @@ class BaseBuilder { return process.platform === 'win32' ? 600000 : 300000; } getBuildTimeout() { - return 300000; // 5 minutes for build process + return 900000; // 15 minutes for all builds } async prepare() { const tauriSrcPath = path.join(npmDirectory, 'src-tauri'); diff --git a/package.json b/package.json index e4191b7..0caf476 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pake-cli", - "version": "3.2.1", + "version": "3.2.2", "description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。", "engines": { "node": ">=16.0.0" diff --git a/script/build_with_pake_cli.js b/script/build_with_pake_cli.js index 0c925b3..924a0c0 100644 --- a/script/build_with_pake_cli.js +++ b/script/build_with_pake_cli.js @@ -21,45 +21,6 @@ const logConfiguration = () => { console.log("===========================\n"); }; -// Build parameters construction -const buildParameters = () => { - const params = [ - "dist/cli.js", - process.env.URL, - "--name", - process.env.NAME, - "--height", - process.env.HEIGHT, - "--width", - process.env.WIDTH, - ]; - - if (process.env.HIDE_TITLE_BAR === "true" && process.platform === "darwin") { - params.push("--hide-title-bar"); - } - - if (process.env.FULLSCREEN === "true") { - params.push("--fullscreen"); - } - - if (process.env.MULTI_ARCH === "true" && process.platform === "darwin") { - // We'll handle rustup separately since it's a different command - params.push("--multi-arch"); - } - - if (process.env.TARGETS && process.platform === "linux") { - params.push("--targets", process.env.TARGETS); - } - - if (process.platform === "win32" || process.platform === "linux") { - params.push("--show-system-tray"); - } - - return params; -}; - -// Icon will be handled directly by CLI - // Main execution const main = async () => { try { @@ -68,9 +29,40 @@ const main = async () => { const cliPath = path.join(process.cwd(), "node_modules/pake-cli"); process.chdir(cliPath); - let params = buildParameters(); + // Build CLI parameters + let params = [ + "dist/cli.js", + process.env.URL, + "--name", + process.env.NAME, + "--height", + process.env.HEIGHT, + "--width", + process.env.WIDTH, + ]; - // Multi-arch target is now handled in GitHub Actions workflow + if ( + process.env.HIDE_TITLE_BAR === "true" && + process.platform === "darwin" + ) { + params.push("--hide-title-bar"); + } + + if (process.env.FULLSCREEN === "true") { + params.push("--fullscreen"); + } + + if (process.env.MULTI_ARCH === "true" && process.platform === "darwin") { + params.push("--multi-arch"); + } + + if (process.env.TARGETS && process.platform === "linux") { + params.push("--targets", process.env.TARGETS); + } + + if (process.platform === "win32" || process.platform === "linux") { + params.push("--show-system-tray"); + } // Add icon parameter if provided - CLI will handle download and conversion if (process.env.ICON && process.env.ICON !== "") { @@ -84,8 +76,9 @@ const main = async () => { console.log("Pake parameters:", params.join(" ")); console.log("Compiling...."); - // Execute the CLI command - await execa("node", params, { stdio: "inherit" }); + // Execute the CLI command with extended timeout + const timeout = 900000; // 15 minutes for all builds + await execa("node", params, { stdio: "inherit", timeout }); // Create output directory if it doesn't exist if (!fs.existsSync("output")) { @@ -117,7 +110,8 @@ const main = async () => { for (const file of bundleFiles) { const srcPath = path.join(buildPath, file); const destPath = path.join("output", path.basename(file)); - await execa("cp", [srcPath, destPath]); + // Use fs.copyFileSync for cross-platform compatibility + fs.copyFileSync(srcPath, destPath); } break; // Found files, no need to check other paths } @@ -129,7 +123,9 @@ const main = async () => { let foundFiles = false; for (const file of files) { if (namePattern.test(file)) { - await execa("mv", [file, path.join("output", file)]); + // Use fs for cross-platform file operations + const destPath = path.join("output", file); + fs.renameSync(file, destPath); foundFiles = true; } }