🎨 format code

This commit is contained in:
Tw93
2025-08-14 11:20:15 +08:00
parent 7adeb91ae9
commit 256cdc77ee
12 changed files with 745 additions and 639 deletions

View File

@@ -1,55 +1,55 @@
/**
* Test Configuration for Pake CLI
*
*
* This file contains test configuration and utilities
* shared across different test files.
*/
import path from 'path';
import { fileURLToPath } from 'url';
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export const PROJECT_ROOT = path.dirname(__dirname);
export const CLI_PATH = path.join(PROJECT_ROOT, 'dist/cli.js');
export const CLI_PATH = path.join(PROJECT_ROOT, "dist/cli.js");
// Test timeouts (in milliseconds)
export const TIMEOUTS = {
QUICK: 3000, // For version, help commands
MEDIUM: 10000, // For validation tests
LONG: 300000, // For build tests (5 minutes)
QUICK: 3000, // For version, help commands
MEDIUM: 10000, // For validation tests
LONG: 300000, // For build tests (5 minutes)
};
// Test URLs for different scenarios
export const TEST_URLS = {
WEEKLY: 'https://weekly.tw93.fun',
VALID: 'https://example.com',
GITHUB: 'https://github.com',
GOOGLE: 'https://www.google.com',
INVALID: 'not://a/valid[url]',
LOCAL: './test-file.html'
WEEKLY: "https://weekly.tw93.fun",
VALID: "https://example.com",
GITHUB: "https://github.com",
GOOGLE: "https://www.google.com",
INVALID: "not://a/valid[url]",
LOCAL: "./test-file.html",
};
// Test assets for different scenarios
export const TEST_ASSETS = {
WEEKLY_ICNS: 'https://gw.alipayobjects.com/os/k/fw/weekly.icns',
INVALID_ICON: 'https://example.com/nonexistent.icns'
WEEKLY_ICNS: "https://gw.alipayobjects.com/os/k/fw/weekly.icns",
INVALID_ICON: "https://example.com/nonexistent.icns",
};
// Test app names
export const TEST_NAMES = {
WEEKLY: 'Weekly',
BASIC: 'TestApp',
DEBUG: 'DebugApp',
FULL: 'FullscreenApp',
GOOGLE_TRANSLATE: 'Google Translate',
MAC: 'MacApp'
WEEKLY: "Weekly",
BASIC: "TestApp",
DEBUG: "DebugApp",
FULL: "FullscreenApp",
GOOGLE_TRANSLATE: "Google Translate",
MAC: "MacApp",
};
// Expected file extensions by platform
export const PLATFORM_EXTENSIONS = {
darwin: 'dmg',
win32: 'msi',
linux: 'deb'
darwin: "dmg",
win32: "msi",
linux: "deb",
};
// Helper functions
@@ -57,16 +57,16 @@ export const testHelpers = {
/**
* Clean test name for filesystem
*/
sanitizeName: (name) => name.replace(/[^a-zA-Z0-9]/g, ''),
sanitizeName: (name) => name.replace(/[^a-zA-Z0-9]/g, ""),
/**
* Get expected output file for current platform
*/
getExpectedOutput: (appName) => {
const ext = PLATFORM_EXTENSIONS[process.platform] || 'bin';
const ext = PLATFORM_EXTENSIONS[process.platform] || "bin";
return `${appName}.${ext}`;
},
/**
* Create test command with common options
*/
@@ -75,14 +75,14 @@ export const testHelpers = {
const optionsStr = Object.entries(options)
.map(([key, value]) => {
if (value === true) return `--${key}`;
if (value === false) return '';
if (value === false) return "";
return `--${key} "${value}"`;
})
.filter(Boolean)
.join(' ');
.join(" ");
return `${baseCmd} ${optionsStr}`.trim();
}
},
};
export default {
@@ -92,5 +92,5 @@ export default {
TEST_URLS,
TEST_NAMES,
PLATFORM_EXTENSIONS,
testHelpers
};
testHelpers,
};