From 7b74b7fc153ea77fc2f189ae16fcec891aadf555 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Thu, 14 Aug 2025 11:52:37 +0800 Subject: [PATCH] :bug: update actions work --- .github/workflows/quality-and-test.yml | 6 +++++- bin/builders/BaseBuilder.ts | 6 +++++- bin/utils/shell.ts | 10 +++++++++- dist/cli.js | 4 +++- src-tauri/src/app/window.rs | 3 --- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/quality-and-test.yml b/.github/workflows/quality-and-test.yml index b0dcf59..b350d04 100644 --- a/.github/workflows/quality-and-test.yml +++ b/.github/workflows/quality-and-test.yml @@ -149,7 +149,11 @@ jobs: shell: bash run: | echo "Testing CLI integration with weekly.tw93.fun..." - timeout 30s node dist/cli.js https://weekly.tw93.fun --name "CITestWeekly" --debug || true + if [[ "$RUNNER_OS" == "Windows" ]]; then + timeout 120s node dist/cli.js https://weekly.tw93.fun --name "CITestWeekly" --debug || true + else + timeout 30s node dist/cli.js https://weekly.tw93.fun --name "CITestWeekly" --debug || true + fi echo "Integration test completed (expected to timeout)" summary: diff --git a/bin/builders/BaseBuilder.ts b/bin/builders/BaseBuilder.ts index eb4a21d..024e563 100644 --- a/bin/builders/BaseBuilder.ts +++ b/bin/builders/BaseBuilder.ts @@ -58,15 +58,19 @@ export default abstract class BaseBuilder { ? ' --registry=https://registry.npmmirror.com' : ''; + // Windows环境下需要更长的超时时间 + const timeout = process.platform === 'win32' ? 600000 : 300000; + if (isChina) { logger.info('✺ Located in China, using npm/rsProxy CN mirror.'); const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml'); await fsExtra.copy(projectCnConf, projectConf); await shellExec( `cd "${npmDirectory}" && ${packageManager} install${registryOption}`, + timeout, ); } else { - await shellExec(`cd "${npmDirectory}" && ${packageManager} install`); + await shellExec(`cd "${npmDirectory}" && ${packageManager} install`, timeout); } spinner.succeed(chalk.green('Package installed!')); if (!tauriTargetPathExists) { diff --git a/bin/utils/shell.ts b/bin/utils/shell.ts index f2a9bc0..3eda775 100644 --- a/bin/utils/shell.ts +++ b/bin/utils/shell.ts @@ -1,17 +1,25 @@ import { execa } from 'execa'; import { npmDirectory } from './dir'; -export async function shellExec(command: string) { +export async function shellExec(command: string, timeout: number = 300000) { try { const { exitCode } = await execa(command, { cwd: npmDirectory, stdio: 'inherit', shell: true, + timeout, }); return exitCode; } catch (error: any) { const exitCode = error.exitCode ?? 'unknown'; const errorMessage = error.message || 'Unknown error occurred'; + + if (error.timedOut) { + throw new Error( + `Command timed out after ${timeout}ms: "${command}". Try increasing timeout or check network connectivity.`, + ); + } + throw new Error( `Error occurred while executing command "${command}". Exit code: ${exitCode}. Details: ${errorMessage}`, ); diff --git a/dist/cli.js b/dist/cli.js index 244816b..15fc7d4 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -647,7 +647,9 @@ class BaseBuilder { await fsExtra.ensureDir(rustProjectDir); // For global CLI installation, always use npm const packageManager = 'npm'; - const registryOption = isChina ? ' --registry=https://registry.npmmirror.com' : ''; + const registryOption = isChina + ? ' --registry=https://registry.npmmirror.com' + : ''; if (isChina) { logger.info('✺ Located in China, using npm/rsProxy CN mirror.'); const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml'); diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs index be5f686..ff464a4 100644 --- a/src-tauri/src/app/window.rs +++ b/src-tauri/src/app/window.rs @@ -6,9 +6,6 @@ use tauri::{App, Config, Url, WebviewUrl, WebviewWindow, WebviewWindowBuilder}; #[cfg(target_os = "macos")] use tauri::{Theme, TitleBarStyle}; -#[cfg(target_os = "windows")] -use tauri::Theme; - pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) -> WebviewWindow { let package_name = tauri_config.clone().product_name.unwrap(); let _data_dir = get_data_dir(app.handle(), package_name);