Supports numeric naming

This commit is contained in:
Tw93
2025-08-11 20:03:33 +08:00
parent 69d606653d
commit a0452a0789
2 changed files with 246 additions and 205 deletions

View File

@@ -37,8 +37,8 @@ export default async function handleOptions(
} }
if (!isValidName(name, platform)) { if (!isValidName(name, platform)) {
const LINUX_NAME_ERROR = `✕ Name should only include lowercase letters, numbers, and dashes (not leading dashes), and must contain at least one lowercase letter or number. Examples: com-123-xxx, 123pan, pan123, weread, we-read.`; 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), and must contain at least one letter or number. Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read, We Read.`; 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.`;
const errorMsg = const errorMsg =
platform === 'linux' ? LINUX_NAME_ERROR : DEFAULT_NAME_ERROR; platform === 'linux' ? LINUX_NAME_ERROR : DEFAULT_NAME_ERROR;
logger.error(errorMsg); logger.error(errorMsg);

447
dist/cli.js vendored
View File

@@ -23,232 +23,233 @@ var name = "pake-cli";
var version$1 = "3.1.2"; var version$1 = "3.1.2";
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。"; var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
var engines = { var engines = {
node: ">=16.0.0" node: ">=16.0.0"
}; };
var bin = { var bin = {
pake: "./cli.js" pake: "./cli.js"
}; };
var repository = { var repository = {
type: "git", type: "git",
url: "https://github.com/tw93/pake.git" url: "https://github.com/tw93/pake.git"
}; };
var author = { var author = {
name: "Tw93", name: "Tw93",
email: "tw93@qq.com" email: "tw93@qq.com"
}; };
var keywords = [ var keywords = [
"pake", "pake",
"pake-cli", "pake-cli",
"rust", "rust",
"tauri", "tauri",
"no-electron", "no-electron",
"productivity" "productivity"
]; ];
var files = [ var files = [
"dist", "dist",
"src-tauri", "src-tauri",
"cli.js" "cli.js"
]; ];
var scripts = { var scripts = {
start: "npm run dev", start: "npm run dev",
dev: "npm run tauri dev", dev: "npm run tauri dev",
build: "npm run tauri build --release", build: "npm run tauri build --release",
"build:debug": "npm run tauri build -- --debug", "build:debug": "npm run tauri build -- --debug",
"build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:mac": "npm run tauri build -- --target universal-apple-darwin",
"build:config": "chmod +x script/app_config.mjs && node script/app_config.mjs", "build:config": "chmod +x script/app_config.mjs && node script/app_config.mjs",
analyze: "cd src-tauri && cargo bloat --release --crates", analyze: "cd src-tauri && cargo bloat --release --crates",
tauri: "tauri", tauri: "tauri",
cli: "rollup -c rollup.config.js --watch", cli: "rollup -c rollup.config.js --watch",
"cli:dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", "cli:dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
"cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js",
prepublishOnly: "npm run cli:build" format: "npx prettier --write . --ignore-unknown && cd src-tauri && cargo fmt --verbose",
prepublishOnly: "npm run cli:build"
}; };
var type = "module"; var type = "module";
var exports = "./dist/pake.js"; var exports = "./dist/pake.js";
var license = "MIT"; var license = "MIT";
var dependencies = { var dependencies = {
"@tauri-apps/api": "^2.2.0", "@tauri-apps/api": "^2.2.0",
"@tauri-apps/cli": "^2.2.5", "@tauri-apps/cli": "^2.2.5",
axios: "^1.7.9", axios: "^1.7.9",
chalk: "^5.4.1", chalk: "^5.4.1",
commander: "^13.1.0", commander: "^13.1.0",
execa: "^9.5.2", execa: "^9.5.2",
"file-type": "^20.0.0", "file-type": "^20.0.0",
"fs-extra": "^11.3.0", "fs-extra": "^11.3.0",
"is-url": "^1.2.4", "is-url": "^1.2.4",
loglevel: "^1.9.2", loglevel: "^1.9.2",
ora: "^8.1.1", ora: "^8.1.1",
prompts: "^2.4.2", prompts: "^2.4.2",
psl: "^1.15.0", psl: "^1.15.0",
"tmp-promise": "^3.0.3", "tmp-promise": "^3.0.3",
"update-notifier": "^7.3.1" "update-notifier": "^7.3.1"
}; };
var devDependencies = { var devDependencies = {
"@rollup/plugin-alias": "^5.1.1", "@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^28.0.2", "@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-json": "^6.1.0", "@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-replace": "^6.0.2", "@rollup/plugin-replace": "^6.0.2",
"@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-terser": "^0.4.4",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/is-url": "^1.2.32", "@types/is-url": "^1.2.32",
"@types/node": "^22.10.8", "@types/node": "^22.10.8",
"@types/page-icon": "^0.3.6", "@types/page-icon": "^0.3.6",
"@types/prompts": "^2.4.9", "@types/prompts": "^2.4.9",
"@types/psl": "^1.1.3", "@types/psl": "^1.1.3",
"@types/tmp": "^0.2.6", "@types/tmp": "^0.2.6",
"@types/update-notifier": "^6.0.8", "@types/update-notifier": "^6.0.8",
"app-root-path": "^3.1.0", "app-root-path": "^3.1.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
rollup: "^4.31.0", rollup: "^4.31.0",
"rollup-plugin-typescript2": "^0.36.0", "rollup-plugin-typescript2": "^0.36.0",
tslib: "^2.8.1", tslib: "^2.8.1",
typescript: "^5.7.3" typescript: "^5.7.3"
}; };
var packageJson = { var packageJson = {
name: name, name: name,
version: version$1, version: version$1,
description: description, description: description,
engines: engines, engines: engines,
bin: bin, bin: bin,
repository: repository, repository: repository,
author: author, author: author,
keywords: keywords, keywords: keywords,
files: files, files: files,
scripts: scripts, scripts: scripts,
type: type, type: type,
exports: exports, exports: exports,
license: license, license: license,
dependencies: dependencies, dependencies: dependencies,
devDependencies: devDependencies devDependencies: devDependencies
}; };
var windows = [ var windows = [
{ {
url: "https://weread.qq.com/", url: "https://weread.qq.com/",
url_type: "web", url_type: "web",
hide_title_bar: true, hide_title_bar: true,
fullscreen: false, fullscreen: false,
width: 1200, width: 1200,
height: 780, height: 780,
resizable: true, resizable: true,
always_on_top: false, always_on_top: false,
dark_mode: false, dark_mode: false,
activation_shortcut: "", activation_shortcut: "",
disabled_web_shortcuts: false, disabled_web_shortcuts: false,
hide_on_close: true hide_on_close: true
} }
]; ];
var user_agent = { var user_agent = {
macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15", macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15",
linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
}; };
var system_tray = { var system_tray = {
macos: false, macos: false,
linux: true, linux: true,
windows: true windows: true
}; };
var system_tray_path = "icons/icon.png"; var system_tray_path = "icons/icon.png";
var inject = [ var inject = [
]; ];
var proxy_url = ""; var proxy_url = "";
var pakeConf = { var pakeConf = {
windows: windows, windows: windows,
user_agent: user_agent, user_agent: user_agent,
system_tray: system_tray, system_tray: system_tray,
system_tray_path: system_tray_path, system_tray_path: system_tray_path,
inject: inject, inject: inject,
proxy_url: proxy_url proxy_url: proxy_url
}; };
var productName$1 = "WeRead"; var productName$1 = "WeRead";
var identifier = "com.pake.weread"; var identifier = "com.pake.weread";
var version = "1.0.0"; var version = "1.0.0";
var app = { var app = {
withGlobalTauri: true, withGlobalTauri: true,
trayIcon: { trayIcon: {
iconPath: "png/weread_512.png", iconPath: "png/weread_512.png",
iconAsTemplate: false, iconAsTemplate: false,
id: "pake-tray" id: "pake-tray"
} }
}; };
var build = { var build = {
frontendDist: "../dist" frontendDist: "../dist"
}; };
var CommonConf = { var CommonConf = {
productName: productName$1, productName: productName$1,
identifier: identifier, identifier: identifier,
version: version, version: version,
app: app, app: app,
build: build build: build
}; };
var bundle$2 = { var bundle$2 = {
icon: [ icon: [
"png/weread_256.ico", "png/weread_256.ico",
"png/weread_32.ico" "png/weread_32.ico"
], ],
active: true, active: true,
resources: [ resources: [
"png/weread_32.ico" "png/weread_32.ico"
], ],
targets: [ targets: [
"msi" "msi"
], ],
windows: { windows: {
digestAlgorithm: "sha256", digestAlgorithm: "sha256",
wix: { wix: {
language: [ language: [
"en-US" "en-US"
], ],
template: "assets/main.wxs" template: "assets/main.wxs"
} }
} }
}; };
var WinConf = { var WinConf = {
bundle: bundle$2 bundle: bundle$2
}; };
var bundle$1 = { var bundle$1 = {
icon: [ icon: [
"icons/weread.icns" "icons/weread.icns"
], ],
active: true, active: true,
macOS: { macOS: {
}, },
targets: [ targets: [
"dmg" "dmg"
] ]
}; };
var MacConf = { var MacConf = {
bundle: bundle$1 bundle: bundle$1
}; };
var productName = "we-read"; var productName = "we-read";
var bundle = { var bundle = {
icon: [ icon: [
"png/weread_512.png" "png/weread_512.png"
], ],
active: true, active: true,
linux: { linux: {
deb: { deb: {
depends: [ depends: [
"curl", "curl",
"wget" "wget"
], ],
files: { files: {
"/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop" "/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"
} }
} }
}, },
targets: [ targets: [
"deb", "deb",
"appimage" "appimage"
] ]
}; };
var LinuxConf = { var LinuxConf = {
productName: productName, productName: productName,
bundle: bundle bundle: bundle
}; };
const platformConfigs = { const platformConfigs = {
@@ -274,7 +275,11 @@ let tauriConfig = {
// Generates an identifier based on the given URL. // Generates an identifier based on the given URL.
function getIdentifier(url) { function getIdentifier(url) {
const postFixHash = crypto.createHash('md5').update(url).digest('hex').substring(0, 6); const postFixHash = crypto
.createHash('md5')
.update(url)
.digest('hex')
.substring(0, 6);
return `com.pake.${postFixHash}`; return `com.pake.${postFixHash}`;
} }
async function promptText(message, initial) { async function promptText(message, initial) {
@@ -316,7 +321,7 @@ async function shellExec(command) {
try { try {
const { exitCode } = await execa(command, { const { exitCode } = await execa(command, {
cwd: npmDirectory, cwd: npmDirectory,
stdio: 'inherit' stdio: 'inherit',
}); });
return exitCode; return exitCode;
} }
@@ -327,19 +332,19 @@ async function shellExec(command) {
const logger = { const logger = {
info(...msg) { info(...msg) {
log.info(...msg.map(m => chalk.white(m))); log.info(...msg.map((m) => chalk.white(m)));
}, },
debug(...msg) { debug(...msg) {
log.debug(...msg); log.debug(...msg);
}, },
error(...msg) { error(...msg) {
log.error(...msg.map(m => chalk.red(m))); log.error(...msg.map((m) => chalk.red(m)));
}, },
warn(...msg) { warn(...msg) {
log.info(...msg.map(m => chalk.yellow(m))); log.info(...msg.map((m) => chalk.yellow(m)));
}, },
success(...msg) { success(...msg) {
log.info(...msg.map(m => chalk.green(m))); log.info(...msg.map((m) => chalk.green(m)));
}, },
}; };
@@ -350,12 +355,12 @@ const ping = async (host) => {
const start = new Date(); const start = new Date();
// Prevent timeouts from affecting user experience. // Prevent timeouts from affecting user experience.
const requestPromise = new Promise((resolve, reject) => { const requestPromise = new Promise((resolve, reject) => {
const req = http.get(`http://${ip.address}`, res => { const req = http.get(`http://${ip.address}`, (res) => {
const delay = new Date().getTime() - start.getTime(); const delay = new Date().getTime() - start.getTime();
res.resume(); res.resume();
resolve(delay); resolve(delay);
}); });
req.on('error', err => { req.on('error', (err) => {
reject(err); reject(err);
}); });
}); });
@@ -417,14 +422,16 @@ function checkRustInstalled() {
} }
async function combineFiles(files, output) { async function combineFiles(files, output) {
const contents = files.map(file => { const contents = files.map((file) => {
const fileContent = fs.readFileSync(file); const fileContent = fs.readFileSync(file);
if (file.endsWith('.css')) { if (file.endsWith('.css')) {
return ("window.addEventListener('DOMContentLoaded', (_event) => { const css = `" + return ("window.addEventListener('DOMContentLoaded', (_event) => { const css = `" +
fileContent + fileContent +
"`; const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); });"); "`; const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); });");
} }
return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent + ' });'; return ("window.addEventListener('DOMContentLoaded', (_event) => { " +
fileContent +
' });');
}); });
fs.writeFileSync(output, contents.join('\n')); fs.writeFileSync(output, contents.join('\n'));
return files; return files;
@@ -472,7 +479,7 @@ async function mergeConfig(url, options, tauriConf) {
// ignore it, because about_pake.html have be erased. // ignore it, because about_pake.html have be erased.
// const filesToCopyBack = ['cli.js', 'about_pake.html']; // const filesToCopyBack = ['cli.js', 'about_pake.html'];
const filesToCopyBack = ['cli.js']; const filesToCopyBack = ['cli.js'];
await Promise.all(filesToCopyBack.map(file => fsExtra.copy(path.join(distBakDir, file), path.join(distDir, file)))); await Promise.all(filesToCopyBack.map((file) => fsExtra.copy(path.join(distBakDir, file), path.join(distDir, file))));
} }
tauriConf.pake.windows[0].url = fileName; tauriConf.pake.windows[0].url = fileName;
tauriConf.pake.windows[0].url_type = 'local'; tauriConf.pake.windows[0].url_type = 'local';
@@ -576,11 +583,11 @@ async function mergeConfig(url, options, tauriConf) {
const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`); const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
// inject js or css files // inject js or css files
if (inject?.length > 0) { if (inject?.length > 0) {
if (!inject.every(item => item.endsWith('.css') || item.endsWith('.js'))) { if (!inject.every((item) => item.endsWith('.css') || item.endsWith('.js'))) {
logger.error('The injected file must be in either CSS or JS format.'); logger.error('The injected file must be in either CSS or JS format.');
return; return;
} }
const files = inject.map(filepath => (path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath))); const files = inject.map((filepath) => path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath));
tauriConf.pake.inject = files; tauriConf.pake.inject = files;
await combineFiles(files, injectFilePath); await combineFiles(files, injectFilePath);
} }
@@ -708,7 +715,9 @@ class MacBuilder extends BaseBuilder {
return `${name}_${tauriConfig.version}_${arch}`; return `${name}_${tauriConfig.version}_${arch}`;
} }
getBuildCommand() { getBuildCommand() {
return this.options.multiArch ? 'npm run build:mac' : super.getBuildCommand(); return this.options.multiArch
? 'npm run build:mac'
: super.getBuildCommand();
} }
getBasePath() { getBasePath() {
return this.options.multiArch return this.options.multiArch
@@ -798,7 +807,7 @@ const DEFAULT_PAKE_OPTIONS = {
targets: 'deb', targets: 'deb',
useLocalFile: false, useLocalFile: false,
systemTrayIcon: '', systemTrayIcon: '',
proxyUrl: "", proxyUrl: '',
debug: false, debug: false,
inject: [], inject: [],
installerLanguage: 'en-US', installerLanguage: 'en-US',
@@ -806,7 +815,9 @@ const DEFAULT_PAKE_OPTIONS = {
}; };
async function checkUpdateTips() { async function checkUpdateTips() {
updateNotifier({ pkg: packageJson, updateCheckInterval: 1000 * 60 }).notify({ isGlobal: true }); updateNotifier({ pkg: packageJson, updateCheckInterval: 1000 * 60 }).notify({
isGlobal: true,
});
} }
async function handleIcon(options) { async function handleIcon(options) {
@@ -831,7 +842,9 @@ async function handleIcon(options) {
async function downloadIcon(iconUrl) { async function downloadIcon(iconUrl) {
const spinner = getSpinner('Downloading icon...'); const spinner = getSpinner('Downloading icon...');
try { try {
const iconResponse = await axios.get(iconUrl, { responseType: 'arraybuffer' }); const iconResponse = await axios.get(iconUrl, {
responseType: 'arraybuffer',
});
const iconData = await iconResponse.data; const iconData = await iconResponse.data;
if (!iconData) { if (!iconData) {
return null; return null;
@@ -926,8 +939,8 @@ async function handleOptions(options, url) {
name = namePrompt || defaultName; name = namePrompt || defaultName;
} }
if (!isValidName(name, platform)) { if (!isValidName(name, platform)) {
const LINUX_NAME_ERROR = `✕ Name should only include lowercase letters, numbers, and dashes (not leading dashes), and must contain at least one lowercase letter or number. Examples: com-123-xxx, 123pan, pan123, weread, we-read.`; 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), and must contain at least one letter or number. Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read, We Read.`; 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.`;
const errorMsg = platform === 'linux' ? LINUX_NAME_ERROR : DEFAULT_NAME_ERROR; const errorMsg = platform === 'linux' ? LINUX_NAME_ERROR : DEFAULT_NAME_ERROR;
logger.error(errorMsg); logger.error(errorMsg);
if (isActions) { if (isActions) {
@@ -974,7 +987,10 @@ ${green('| |_) / _` | |/ / _ \\')}
${green('| __/ (_| | < __/')} ${yellow('https://github.com/tw93/pake')} ${green('| __/ (_| | < __/')} ${yellow('https://github.com/tw93/pake')}
${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with Rust.')} ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with Rust.')}
`; `;
program.addHelpText('beforeAll', logo).usage(`[url] [options]`).showHelpAfterError(); program
.addHelpText('beforeAll', logo)
.usage(`[url] [options]`)
.showHelpAfterError();
program program
.argument('[url]', 'The web URL you want to package', validateUrlInput) .argument('[url]', 'The web URL you want to package', validateUrlInput)
// Refer to https://github.com/tj/commander.js#custom-option-processing, turn string array into a string connected with custom connectors. // Refer to https://github.com/tj/commander.js#custom-option-processing, turn string array into a string connected with custom connectors.
@@ -997,33 +1013,58 @@ program
if (!val) if (!val)
return DEFAULT_PAKE_OPTIONS.inject; return DEFAULT_PAKE_OPTIONS.inject;
// Split by comma and trim whitespace, filter out empty strings // Split by comma and trim whitespace, filter out empty strings
const files = val.split(',') const files = val
.map(item => item.trim()) .split(',')
.filter(item => item.length > 0); .map((item) => item.trim())
.filter((item) => item.length > 0);
// If previous values exist (from multiple --inject options), merge them // If previous values exist (from multiple --inject options), merge them
return previous ? [...previous, ...files] : files; return previous ? [...previous, ...files] : files;
}, DEFAULT_PAKE_OPTIONS.inject) }, DEFAULT_PAKE_OPTIONS.inject)
.option('--debug', 'Debug build and more output', DEFAULT_PAKE_OPTIONS.debug) .option('--debug', 'Debug build and more output', DEFAULT_PAKE_OPTIONS.debug)
.addOption(new Option('--proxy-url <url>', 'Proxy URL for all network requests').default(DEFAULT_PAKE_OPTIONS.proxyUrl).hideHelp()) .addOption(new Option('--proxy-url <url>', 'Proxy URL for all network requests')
.addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT_PAKE_OPTIONS.userAgent).hideHelp()) .default(DEFAULT_PAKE_OPTIONS.proxyUrl)
.addOption(new Option('--targets <string>', 'For Linux, option "deb" or "appimage"').default(DEFAULT_PAKE_OPTIONS.targets).hideHelp()) .hideHelp())
.addOption(new Option('--app-version <string>', 'App version, the same as package.json version').default(DEFAULT_PAKE_OPTIONS.appVersion).hideHelp()) .addOption(new Option('--user-agent <string>', 'Custom user agent')
.addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT_PAKE_OPTIONS.alwaysOnTop).hideHelp()) .default(DEFAULT_PAKE_OPTIONS.userAgent)
.addOption(new Option('--dark-mode', 'Force Mac app to use dark mode').default(DEFAULT_PAKE_OPTIONS.darkMode).hideHelp()) .hideHelp())
.addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts').default(DEFAULT_PAKE_OPTIONS.disabledWebShortcuts).hideHelp()) .addOption(new Option('--targets <string>', 'For Linux, option "deb" or "appimage"')
.addOption(new Option('--activation-shortcut <string>', 'Shortcut key to active App').default(DEFAULT_PAKE_OPTIONS.activationShortcut).hideHelp()) .default(DEFAULT_PAKE_OPTIONS.targets)
.addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT_PAKE_OPTIONS.showSystemTray).hideHelp()) .hideHelp())
.addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT_PAKE_OPTIONS.systemTrayIcon).hideHelp()) .addOption(new Option('--app-version <string>', 'App version, the same as package.json version')
.addOption(new Option('--hide-on-close', 'Hide window on close instead of exiting').default(DEFAULT_PAKE_OPTIONS.hideOnClose).hideHelp()) .default(DEFAULT_PAKE_OPTIONS.appVersion)
.addOption(new Option('--installer-language <string>', 'Installer language').default(DEFAULT_PAKE_OPTIONS.installerLanguage).hideHelp()) .hideHelp())
.addOption(new Option('--always-on-top', 'Always on the top level')
.default(DEFAULT_PAKE_OPTIONS.alwaysOnTop)
.hideHelp())
.addOption(new Option('--dark-mode', 'Force Mac app to use dark mode')
.default(DEFAULT_PAKE_OPTIONS.darkMode)
.hideHelp())
.addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
.default(DEFAULT_PAKE_OPTIONS.disabledWebShortcuts)
.hideHelp())
.addOption(new Option('--activation-shortcut <string>', 'Shortcut key to active App')
.default(DEFAULT_PAKE_OPTIONS.activationShortcut)
.hideHelp())
.addOption(new Option('--show-system-tray', 'Show system tray in app')
.default(DEFAULT_PAKE_OPTIONS.showSystemTray)
.hideHelp())
.addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon')
.default(DEFAULT_PAKE_OPTIONS.systemTrayIcon)
.hideHelp())
.addOption(new Option('--hide-on-close', 'Hide window on close instead of exiting')
.default(DEFAULT_PAKE_OPTIONS.hideOnClose)
.hideHelp())
.addOption(new Option('--installer-language <string>', 'Installer language')
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
.hideHelp())
.version(packageJson.version, '-v, --version', 'Output the current version') .version(packageJson.version, '-v, --version', 'Output the current version')
.action(async (url, options) => { .action(async (url, options) => {
await checkUpdateTips(); await checkUpdateTips();
if (!url) { if (!url) {
program.outputHelp(str => { program.outputHelp((str) => {
return str return str
.split('\n') .split('\n')
.filter(line => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line)) .filter((line) => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line))
.join('\n'); .join('\n');
}); });
process.exit(0); process.exit(0);