From 09a122dd6b9cb877ee96944121a005307011fa09 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Wed, 13 Aug 2025 19:40:00 +0800 Subject: [PATCH] :bug: Fix name compatibility --- CLAUDE.md | 7 ++++--- README.md | 3 +++ bin/README_CN.md | 6 +++--- bin/cli.ts | 9 +-------- bin/options/index.ts | 6 ++++++ 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index d34afeb..3036fde 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -79,9 +79,10 @@ npm run build:mac # macOS universal build ### CLI Tool (`bin/`) -- `bin/cli.ts` - Main entry point -- `bin/builders/` - Platform-specific builders -- `bin/options/` - Configuration processing +- `bin/cli.ts` - Main entry point with Commander.js +- `bin/builders/` - Platform-specific builders (Mac, Windows, Linux) +- `bin/options/` - CLI option processing and validation +- `bin/helpers/merge.ts` - Configuration merging (name setting at line 55) ### Tauri Application (`src-tauri/`) diff --git a/README.md b/README.md index cb50c9f..118913b 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,9 @@ pake url [OPTIONS]... # Feel free to play with Pake! It might take a while to prepare the environment the first time you launch Pake. pake https://weekly.tw93.fun --name Weekly --hide-title-bar +# Also supports names with spaces (cross-platform compatible) +pake https://translate.google.com --name "Google Translate" --hide-title-bar + ``` If you are new to the command line, you can compile packages online with _GitHub Actions_. See the [Tutorial]() for more information. diff --git a/bin/README_CN.md b/bin/README_CN.md index be06920..33e1890 100644 --- a/bin/README_CN.md +++ b/bin/README_CN.md @@ -61,16 +61,16 @@ pake [url] [options] 指定应用程序的名称,如果未指定,系统会提示您输入,建议使用英文单词。 -**注意**: 也支持多个单词,会自动处理不同平台的命名规范: +**注意**: 支持带空格的名称,会自动处理不同平台的命名规范: - **Windows/macOS**: 保持空格和大小写(如 `"Google Translate"`) -- **Linux**: 转换为小写并用连字符连接(如 `"google-translate"`) +- **Linux**: 自动转换为小写并用连字符连接(如 `"google-translate"`) ```shell --name --name MyApp -# 多个单词(如需要): +# 带空格的名称: --name "Google Translate" ``` diff --git a/bin/cli.ts b/bin/cli.ts index cf22877..3b8d86c 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -31,14 +31,7 @@ program // Refer to https://github.com/tj/commander.js#custom-option-processing, turn string array into a string connected with custom connectors. // If the platform is Linux, use `-` as the connector, and convert all characters to lowercase. // For example, Google Translate will become google-translate. - .option('--name ', 'Application name', (value, previous) => { - const platform = process.platform; - const connector = platform === 'linux' ? '-' : ' '; - const name = - previous === undefined ? value : `${previous}${connector}${value}`; - - return platform === 'linux' ? name.toLowerCase() : name; - }) + .option('--name ', 'Application name') .option('--icon ', 'Application icon', DEFAULT.icon) .option( '--width ', diff --git a/bin/options/index.ts b/bin/options/index.ts index 586c660..564ac0c 100644 --- a/bin/options/index.ts +++ b/bin/options/index.ts @@ -36,6 +36,12 @@ export default async function handleOptions( name = namePrompt || defaultName; } + // Handle platform-specific name formatting + if (name && platform === 'linux') { + // Convert to lowercase and replace spaces with dashes for Linux + name = name.toLowerCase().replace(/\s+/g, '-'); + } + if (!isValidName(name, platform)) { const LINUX_NAME_ERROR = `✕ Name should only include lowercase letters, numbers, and dashes (not leading dashes). Examples: com-123-xxx, 123pan, pan123, weread, we-read, 123.`; const DEFAULT_NAME_ERROR = `✕ Name should only include letters, numbers, dashes, and spaces (not leading dashes and spaces). Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read, We Read, 123.`;