🐛 update actions work

This commit is contained in:
Tw93
2025-08-14 11:52:37 +08:00
parent 81eae9627a
commit 7b74b7fc15
5 changed files with 22 additions and 7 deletions

View File

@@ -149,7 +149,11 @@ jobs:
shell: bash shell: bash
run: | run: |
echo "Testing CLI integration with weekly.tw93.fun..." 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)" echo "Integration test completed (expected to timeout)"
summary: summary:

View File

@@ -58,15 +58,19 @@ export default abstract class BaseBuilder {
? ' --registry=https://registry.npmmirror.com' ? ' --registry=https://registry.npmmirror.com'
: ''; : '';
// Windows环境下需要更长的超时时间
const timeout = process.platform === 'win32' ? 600000 : 300000;
if (isChina) { if (isChina) {
logger.info('✺ Located in China, using npm/rsProxy CN mirror.'); logger.info('✺ Located in China, using npm/rsProxy CN mirror.');
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml'); const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
await fsExtra.copy(projectCnConf, projectConf); await fsExtra.copy(projectCnConf, projectConf);
await shellExec( await shellExec(
`cd "${npmDirectory}" && ${packageManager} install${registryOption}`, `cd "${npmDirectory}" && ${packageManager} install${registryOption}`,
timeout,
); );
} else { } else {
await shellExec(`cd "${npmDirectory}" && ${packageManager} install`); await shellExec(`cd "${npmDirectory}" && ${packageManager} install`, timeout);
} }
spinner.succeed(chalk.green('Package installed!')); spinner.succeed(chalk.green('Package installed!'));
if (!tauriTargetPathExists) { if (!tauriTargetPathExists) {

10
bin/utils/shell.ts vendored
View File

@@ -1,17 +1,25 @@
import { execa } from 'execa'; import { execa } from 'execa';
import { npmDirectory } from './dir'; import { npmDirectory } from './dir';
export async function shellExec(command: string) { export async function shellExec(command: string, timeout: number = 300000) {
try { try {
const { exitCode } = await execa(command, { const { exitCode } = await execa(command, {
cwd: npmDirectory, cwd: npmDirectory,
stdio: 'inherit', stdio: 'inherit',
shell: true, shell: true,
timeout,
}); });
return exitCode; return exitCode;
} catch (error: any) { } catch (error: any) {
const exitCode = error.exitCode ?? 'unknown'; const exitCode = error.exitCode ?? 'unknown';
const errorMessage = error.message || 'Unknown error occurred'; 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( throw new Error(
`Error occurred while executing command "${command}". Exit code: ${exitCode}. Details: ${errorMessage}`, `Error occurred while executing command "${command}". Exit code: ${exitCode}. Details: ${errorMessage}`,
); );

4
dist/cli.js vendored
View File

@@ -647,7 +647,9 @@ class BaseBuilder {
await fsExtra.ensureDir(rustProjectDir); await fsExtra.ensureDir(rustProjectDir);
// For global CLI installation, always use npm // For global CLI installation, always use npm
const packageManager = 'npm'; const packageManager = 'npm';
const registryOption = isChina ? ' --registry=https://registry.npmmirror.com' : ''; const registryOption = isChina
? ' --registry=https://registry.npmmirror.com'
: '';
if (isChina) { if (isChina) {
logger.info('✺ Located in China, using npm/rsProxy CN mirror.'); logger.info('✺ Located in China, using npm/rsProxy CN mirror.');
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml'); const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');

View File

@@ -6,9 +6,6 @@ use tauri::{App, Config, Url, WebviewUrl, WebviewWindow, WebviewWindowBuilder};
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
use tauri::{Theme, TitleBarStyle}; use tauri::{Theme, TitleBarStyle};
#[cfg(target_os = "windows")]
use tauri::Theme;
pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) -> WebviewWindow { pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) -> WebviewWindow {
let package_name = tauri_config.clone().product_name.unwrap(); let package_name = tauri_config.clone().product_name.unwrap();
let _data_dir = get_data_dir(app.handle(), package_name); let _data_dir = get_data_dir(app.handle(), package_name);