Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
refactor: extract CLI program definition to a helper and improve rust error handling and app name defaults.
Tw9329815e710ea8
diff --git a/bin/builders/BaseBuilder.ts b/bin/builders/BaseBuilder.tsindex ef68da9a..77d7cb0b 100644--- a/bin/builders/BaseBuilder.ts+++ b/bin/builders/BaseBuilder.ts@@ -141,9 +141,13 @@ export default abstract class BaseBuilder {);}spinner.succeed(chalk.green('Package installed!'));- } catch (error: any) {+ } catch (error: unknown) {// If installation times out and we haven't tried the mirror yet, retry with mirror- if (error.message?.includes('timed out') && !usedMirror) {+ if (+ error instanceof Error &&+ error.message.includes('timed out') &&+ !usedMirror+ ) {spinner.fail(chalk.yellow('Installation timed out, retrying with CN mirror...'),);@@ -187,11 +191,29 @@ export default abstract class BaseBuilder {}async start(url: string) {+ logger.info('Pake dev server starting...');await mergeConfig(url, this.options, tauriConfig);++ const packageManager = await this.detectPackageManager();+ const configPath = path.join(+ npmDirectory,+ 'src-tauri',+ '.pake',+ 'tauri.conf.json',+ );++ const features = this.getBuildFeatures();+ const featureArgs =+ features.length > 0 ? `--features ${features.join(',')}` : '';++ const argSeparator = packageManager === 'npm' ? ' --' : '';+ const command = `cd "${npmDirectory}" && ${packageManager} run tauri${argSeparator} dev --config "${configPath}" ${featureArgs}`;++ await shellExec(command);}async buildAndCopy(url: string, target: string) {- const { name } = this.options;+ const { name = 'pake-app' } = this.options;await mergeConfig(url, this.options, tauriConfig);// Detect available package managerdiff --git a/bin/builders/LinuxBuilder.ts b/bin/builders/LinuxBuilder.tsindex 3efb64ae..07d14843 100644--- a/bin/builders/LinuxBuilder.ts+++ b/bin/builders/LinuxBuilder.ts@@ -23,7 +23,7 @@ export default class LinuxBuilder extends BaseBuilder {}getFileName() {- const { name, targets } = this.options;+ const { name = 'pake-app', targets } = this.options;const version = tauriConfig.version;let arch: string;@@ -64,7 +64,7 @@ export default class LinuxBuilder extends BaseBuilder {const buildTarget =this.buildArch === 'arm64'- ? this.getTauriTarget(this.buildArch, 'linux')+ ? (this.getTauriTarget(this.buildArch, 'linux') ?? undefined): undefined;let fullCommand = this.buildBaseCommand(diff --git a/bin/builders/MacBuilder.ts b/bin/builders/MacBuilder.tsindex f097ff12..29fa8cd7 100644--- a/bin/builders/MacBuilder.ts+++ b/bin/builders/MacBuilder.ts@@ -25,7 +25,7 @@ export default class MacBuilder extends BaseBuilder {}getFileName(): string {- const { name } = this.options;+ const { name = 'pake-app' } = this.options;if (this.buildFormat === 'app') {return name;diff --git a/bin/cli.ts b/bin/cli.tsindex 69eff1d6..0323b98e 100644--- a/bin/cli.ts+++ b/bin/cli.ts@@ -1,267 +1,34 @@-import chalk from 'chalk';-import { program, Option } from 'commander';import log from 'loglevel';-import packageJson from '../package.json';import BuilderProvider from './builders/BuilderProvider';-import {- DEFAULT_PAKE_OPTIONS as DEFAULT,- DEFAULT_PAKE_OPTIONS,-} from './defaults';import { checkUpdateTips } from './helpers/updater';import handleInputOptions from './options/index';-+import { getCliProgram } from './helpers/cli-program';import { PakeCliOptions } from './types';-import { validateNumberInput, validateUrlInput } from './utils/validate';--const { green, yellow } = chalk;-const logo = `${chalk.green(' ____ _')}-${green('| _ \\ __ _| | _____')}-${green('| |_) / _` | |/ / _ \\')}-${green('| __/ (_| | < __/')} ${yellow('https://github.com/tw93/pake')}-${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with Rust.')}-`;--program- .addHelpText('beforeAll', logo)- .usage(`[url] [options]`)- .showHelpAfterError();-program- .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.- // 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 <string>', 'Application name')- .option('--icon <string>', 'Application icon', DEFAULT.icon)- .option(- '--width <number>',- 'Window width',- validateNumberInput,- DEFAULT.width,- )- .option(- '--height <number>',- 'Window height',- validateNumberInput,- DEFAULT.height,- )- .option('--use-local-file', 'Use local file packaging', DEFAULT.useLocalFile)- .option('--fullscreen', 'Start in full screen', DEFAULT.fullscreen)- .option('--hide-title-bar', 'For Mac, hide title bar', DEFAULT.hideTitleBar)- .option('--multi-arch', 'For Mac, both Intel and M1', DEFAULT.multiArch)- .option(- '--inject <files>',- 'Inject local CSS/JS files into the page',- (val, previous) => {- if (!val) return DEFAULT.inject;+const program = getCliProgram();- // Split by comma and trim whitespace, filter out empty strings- const files = val- .split(',')- .map((item) => item.trim())- .filter((item) => item.length > 0);+program.action(async (url: string, options: PakeCliOptions) => {+ await checkUpdateTips();- // If previous values exist (from multiple --inject options), merge them- return previous ? [...previous, ...files] : files;- },- DEFAULT.inject,- )- .option('--debug', 'Debug build and more output', DEFAULT.debug)- .addOption(- new Option(- '--proxy-url <url>',- 'Proxy URL for all network requests (http://, https://, socks5://)',- )- .default(DEFAULT_PAKE_OPTIONS.proxyUrl)- .hideHelp(),- )- .addOption(- new Option('--user-agent <string>', 'Custom user agent')- .default(DEFAULT.userAgent)- .hideHelp(),- )- .addOption(- new Option(- '--targets <string>',- 'Build target format for your system',- ).default(DEFAULT.targets),- )- .addOption(- new Option(- '--app-version <string>',- 'App version, the same as package.json version',- )- .default(DEFAULT.appVersion)- .hideHelp(),- )- .addOption(- new Option('--always-on-top', 'Always on the top level')- .default(DEFAULT.alwaysOnTop)- .hideHelp(),- )- .addOption(- new Option('--maximize', 'Start window maximized')- .default(DEFAULT.maximize)- .hideHelp(),- )- .addOption(- new Option('--dark-mode', 'Force Mac app to use dark mode')- .default(DEFAULT.darkMode)- .hideHelp(),- )- .addOption(- new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')- .default(DEFAULT.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.showSystemTray)- .hideHelp(),- )- .addOption(- new Option('--system-tray-icon <string>', 'Custom system tray icon')- .default(DEFAULT.systemTrayIcon)- .hideHelp(),- )- .addOption(- new Option(- '--hide-on-close [boolean]',- 'Hide window on close instead of exiting (default: true for macOS, false for others)',- )- .default(DEFAULT.hideOnClose)- .argParser((value) => {- if (value === undefined) return true; // --hide-on-close without value- if (value === 'true') return true;- if (value === 'false') return false;- throw new Error('--hide-on-close must be true or false');- })- .hideHelp(),- )- .addOption(new Option('--title <string>', 'Window title').hideHelp())- .addOption(- new Option('--incognito', 'Launch app in incognito/private mode')- .default(DEFAULT.incognito)- .hideHelp(),- )- .addOption(- new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')- .default(DEFAULT.wasm)- .hideHelp(),- )- .addOption(- new Option('--enable-drag-drop', 'Enable drag and drop functionality')- .default(DEFAULT.enableDragDrop)- .hideHelp(),- )- .addOption(- new Option('--keep-binary', 'Keep raw binary file alongside installer')- .default(DEFAULT.keepBinary)- .hideHelp(),- )- .addOption(- new Option('--multi-instance', 'Allow multiple app instances')- .default(DEFAULT.multiInstance)- .hideHelp(),- )- .addOption(- new Option('--start-to-tray', 'Start app minimized to tray')- .default(DEFAULT.startToTray)- .hideHelp(),- )- .addOption(- new Option(- '--force-internal-navigation',- 'Keep every link inside the Pake window instead of opening external handlers',- )- .default(DEFAULT.forceInternalNavigation)- .hideHelp(),- )- .addOption(- new Option('--installer-language <string>', 'Installer language')- .default(DEFAULT.installerLanguage)- .hideHelp(),- )- .addOption(- new Option('--zoom <number>', 'Initial page zoom level (50-200)')- .default(DEFAULT.zoom)- .argParser((value) => {- const zoom = parseInt(value);- if (isNaN(zoom) || zoom < 50 || zoom > 200) {- throw new Error('--zoom must be a number between 50 and 200');- }- return zoom;- })- .hideHelp(),- )- .addOption(- new Option('--min-width <number>', 'Minimum window width')- .default(DEFAULT.minWidth)- .argParser(validateNumberInput)- .hideHelp(),- )- .addOption(- new Option('--min-height <number>', 'Minimum window height')- .default(DEFAULT.minHeight)- .argParser(validateNumberInput)- .hideHelp(),- )- .addOption(- new Option(- '--ignore-certificate-errors',- 'Ignore certificate errors (for self-signed certificates)',- )- .default(DEFAULT.ignoreCertificateErrors)- .hideHelp(),- )- .addOption(- new Option(- '--iterative-build',- 'Turn on rapid build mode (app only, no dmg/deb/msi), good for debugging',- )- .default(DEFAULT.iterativeBuild)- .hideHelp(),- )- .version(packageJson.version, '-v, --version')- .configureHelp({- sortSubcommands: true,- optionTerm: (option) => {- if (option.flags === '-v, --version' || option.flags === '-h, --help')- return '';- return option.flags;- },- optionDescription: (option) => {- if (option.flags === '-v, --version' || option.flags === '-h, --help')- return '';- return option.description;- },- })- .action(async (url: string, options: PakeCliOptions) => {- await checkUpdateTips();+ if (!url) {+ program.help({+ error: false,+ });+ return;+ }- if (!url) {- program.help({- error: false,- });- return;- }+ log.setDefaultLevel('info');+ log.setLevel('info');+ if (options.debug) {+ log.setLevel('debug');+ }- log.setDefaultLevel('info');- log.setLevel('info');- if (options.debug) {- log.setLevel('debug');- }+ const appOptions = await handleInputOptions(options, url);- const appOptions = await handleInputOptions(options, url);-- const builder = BuilderProvider.create(appOptions);- await builder.prepare();- await builder.build(url);- });+ const builder = BuilderProvider.create(appOptions);+ await builder.prepare();+ await builder.build(url);+});program.parse();+diff --git a/bin/dev.ts b/bin/dev.tsindex 09224db5..7dca5704 100644--- a/bin/dev.ts+++ b/bin/dev.ts@@ -1,20 +1,21 @@import log from 'loglevel';-import { DEFAULT_DEV_PAKE_OPTIONS } from './defaults';+import { PakeCliOptions } from './types';import handleInputOptions from './options/index';import BuilderProvider from './builders/BuilderProvider';+import { getCliProgram } from './helpers/cli-program';-async function startBuild() {+const program = getCliProgram();++program.action(async (url: string, options: PakeCliOptions) => {log.setDefaultLevel('debug');- const appOptions = await handleInputOptions(- DEFAULT_DEV_PAKE_OPTIONS,- DEFAULT_DEV_PAKE_OPTIONS.url,- );+ const appOptions = await handleInputOptions(options, url);log.debug('PakeAppOptions', appOptions);const builder = BuilderProvider.create(appOptions);await builder.prepare();- await builder.start(DEFAULT_DEV_PAKE_OPTIONS.url);-}+ await builder.start(url);+});++program.parse();-startBuild();diff --git a/bin/helpers/cli-program.ts b/bin/helpers/cli-program.tsnew file mode 100644index 00000000..40b3aa48--- /dev/null+++ b/bin/helpers/cli-program.ts@@ -0,0 +1,235 @@++import chalk from 'chalk';+import { program, Option } from 'commander';+import packageJson from '../../package.json';+import {+ DEFAULT_PAKE_OPTIONS as DEFAULT,+ DEFAULT_PAKE_OPTIONS,+} from '../defaults';+import { validateNumberInput, validateUrlInput } from '../utils/validate';++export function getCliProgram() {+ const { green, yellow } = chalk;+ const logo = `${chalk.green(' ____ _')}+${green('| _ \\ __ _| | _____')}+${green('| |_) / _` | |/ / _ \\')}+${green('| __/ (_| | < __/')} ${yellow('https://github.com/tw93/pake')}+${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with Rust.')}+`;++ return program+ .addHelpText('beforeAll', logo)+ .usage(`[url] [options]`)+ .showHelpAfterError()+ .argument('[url]', 'The web URL you want to package', validateUrlInput)+ .option('--name <string>', 'Application name')+ .option('--icon <string>', 'Application icon', DEFAULT.icon)+ .option(+ '--width <number>',+ 'Window width',+ validateNumberInput,+ DEFAULT.width,+ )+ .option(+ '--height <number>',+ 'Window height',+ validateNumberInput,+ DEFAULT.height,+ )+ .option('--use-local-file', 'Use local file packaging', DEFAULT.useLocalFile)+ .option('--fullscreen', 'Start in full screen', DEFAULT.fullscreen)+ .option('--hide-title-bar', 'For Mac, hide title bar', DEFAULT.hideTitleBar)+ .option('--multi-arch', 'For Mac, both Intel and M1', DEFAULT.multiArch)+ .option(+ '--inject <files>',+ 'Inject local CSS/JS files into the page',+ (val, previous) => {+ if (!val) return DEFAULT.inject;++ // Split by comma and trim whitespace, filter out empty strings+ const files = val+ .split(',')+ .map((item) => item.trim())+ .filter((item) => item.length > 0);++ // If previous values exist (from multiple --inject options), merge them+ return previous ? [...previous, ...files] : files;+ },+ DEFAULT.inject,+ )+ .option('--debug', 'Debug build and more output', DEFAULT.debug)+ .addOption(+ new Option(+ '--proxy-url <url>',+ 'Proxy URL for all network requests (http://, https://, socks5://)',+ )+ .default(DEFAULT_PAKE_OPTIONS.proxyUrl)+ .hideHelp(),+ )+ .addOption(+ new Option('--user-agent <string>', 'Custom user agent')+ .default(DEFAULT.userAgent)+ .hideHelp(),+ )+ .addOption(+ new Option(+ '--targets <string>',+ 'Build target format for your system',+ ).default(DEFAULT.targets),+ )+ .addOption(+ new Option(+ '--app-version <string>',+ 'App version, the same as package.json version',+ )+ .default(DEFAULT.appVersion)+ .hideHelp(),+ )+ .addOption(+ new Option('--always-on-top', 'Always on the top level')+ .default(DEFAULT.alwaysOnTop)+ .hideHelp(),+ )+ .addOption(+ new Option('--maximize', 'Start window maximized')+ .default(DEFAULT.maximize)+ .hideHelp(),+ )+ .addOption(+ new Option('--dark-mode', 'Force Mac app to use dark mode')+ .default(DEFAULT.darkMode)+ .hideHelp(),+ )+ .addOption(+ new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')+ .default(DEFAULT.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.showSystemTray)+ .hideHelp(),+ )+ .addOption(+ new Option('--system-tray-icon <string>', 'Custom system tray icon')+ .default(DEFAULT.systemTrayIcon)+ .hideHelp(),+ )+ .addOption(+ new Option(+ '--hide-on-close [boolean]',+ 'Hide window on close instead of exiting (default: true for macOS, false for others)',+ )+ .default(DEFAULT.hideOnClose)+ .argParser((value) => {+ if (value === undefined) return true; // --hide-on-close without value+ if (value === 'true') return true;+ if (value === 'false') return false;+ throw new Error('--hide-on-close must be true or false');+ })+ .hideHelp(),+ )+ .addOption(new Option('--title <string>', 'Window title').hideHelp())+ .addOption(+ new Option('--incognito', 'Launch app in incognito/private mode')+ .default(DEFAULT.incognito)+ .hideHelp(),+ )+ .addOption(+ new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')+ .default(DEFAULT.wasm)+ .hideHelp(),+ )+ .addOption(+ new Option('--enable-drag-drop', 'Enable drag and drop functionality')+ .default(DEFAULT.enableDragDrop)+ .hideHelp(),+ )+ .addOption(+ new Option('--keep-binary', 'Keep raw binary file alongside installer')+ .default(DEFAULT.keepBinary)+ .hideHelp(),+ )+ .addOption(+ new Option('--multi-instance', 'Allow multiple app instances')+ .default(DEFAULT.multiInstance)+ .hideHelp(),+ )+ .addOption(+ new Option('--start-to-tray', 'Start app minimized to tray')+ .default(DEFAULT.startToTray)+ .hideHelp(),+ )+ .addOption(+ new Option(+ '--force-internal-navigation',+ 'Keep every link inside the Pake window instead of opening external handlers',+ )+ .default(DEFAULT.forceInternalNavigation)+ .hideHelp(),+ )+ .addOption(+ new Option('--installer-language <string>', 'Installer language')+ .default(DEFAULT.installerLanguage)+ .hideHelp(),+ )+ .addOption(+ new Option('--zoom <number>', 'Initial page zoom level (50-200)')+ .default(DEFAULT.zoom)+ .argParser((value) => {+ const zoom = parseInt(value);+ if (isNaN(zoom) || zoom < 50 || zoom > 200) {+ throw new Error('--zoom must be a number between 50 and 200');+ }+ return zoom;+ })+ .hideHelp(),+ )+ .addOption(+ new Option('--min-width <number>', 'Minimum window width')+ .default(DEFAULT.minWidth)+ .argParser(validateNumberInput)+ .hideHelp(),+ )+ .addOption(+ new Option('--min-height <number>', 'Minimum window height')+ .default(DEFAULT.minHeight)+ .argParser(validateNumberInput)+ .hideHelp(),+ )+ .addOption(+ new Option(+ '--ignore-certificate-errors',+ 'Ignore certificate errors (for self-signed certificates)',+ )+ .default(DEFAULT.ignoreCertificateErrors)+ .hideHelp(),+ )+ .addOption(+ new Option(+ '--iterative-build',+ 'Turn on rapid build mode (app only, no dmg/deb/msi), good for debugging',+ )+ .default(DEFAULT.iterativeBuild)+ .hideHelp(),+ )+ .version(packageJson.version, '-v, --version')+ .configureHelp({+ sortSubcommands: true,+ optionTerm: (option) => {+ if (option.flags === '-v, --version' || option.flags === '-h, --help')+ return '';+ return option.flags;+ },+ optionDescription: (option) => {+ if (option.flags === '-v, --version' || option.flags === '-h, --help')+ return '';+ return option.description;+ },+ });+}diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.tsindex b11c66c7..e484eda0 100644--- a/bin/helpers/merge.ts+++ b/bin/helpers/merge.ts@@ -54,7 +54,7 @@ export async function mergeConfig(systemTrayIcon,useLocalFile,identifier,- name,+ name = 'pake-app',resizable = true,inject,proxyUrl,diff --git a/bin/helpers/rust.ts b/bin/helpers/rust.tsindex dde4d201..946408c8 100644--- a/bin/helpers/rust.ts+++ b/bin/helpers/rust.ts@@ -88,7 +88,11 @@ export async function installRust() {ensureRustEnv();} catch (error) {spinner.fail(chalk.red('✕ Rust installation failed!'));- console.error(error.message);+ if (error instanceof Error) {+ console.error(error.message);+ } else {+ console.error(error);+ }process.exit(1);}}diff --git a/bin/options/icon.ts b/bin/options/icon.tsindex 86db327b..d54fa3c1 100644--- a/bin/options/icon.ts+++ b/bin/options/icon.ts@@ -10,7 +10,7 @@ import sharp from 'sharp';import logger from './logger';import { getSpinner } from '@/utils/info';import { npmDirectory } from '@/utils/dir';-import { IS_LINUX, IS_WIN } from '@/utils/platform';+import { IS_LINUX, IS_WIN, IS_MAC } from '@/utils/platform';import { PakeAppOptions } from '@/types';type PlatformIconConfig = {@@ -106,7 +106,63 @@ async function preprocessIcon(inputPath: string): Promise<string> {return outputPath;} catch (error) {- logger.warn(`Failed to add background to icon: ${error.message}`);+ if (error instanceof Error) {+ logger.warn(`Failed to add background to icon: ${error.message}`);+ }+ return inputPath;+ }+}++/**+ * Applies macOS squircle mask to icon+ */+async function applyMacOSMask(inputPath: string): Promise<string> {+ try {+ const { path: tempDir } = await dir();+ const outputPath = path.join(tempDir, 'icon-macos-rounded.png');++ // 1. Create a 1024x1024 rounded rect mask+ // rx="224" is closer to the smooth Apple squircle look for 1024px+ const mask = Buffer.from(+ '<svg width="1024" height="1024"><rect x="0" y="0" width="1024" height="1024" rx="224" ry="224" fill="white"/></svg>',+ );++ // 2. Load input, resize to 1024, apply mask+ const maskedBuffer = await sharp(inputPath)+ .resize(1024, 1024, {+ fit: 'contain',+ background: { r: 0, g: 0, b: 0, alpha: 0 },+ })+ .composite([+ {+ input: mask,+ blend: 'dest-in',+ },+ ])+ .png()+ .toBuffer();++ // 3. Resize to 840x840 (~18% padding) to solve "too big" visual issue+ // Native MacOS icons often leave some breathing room+ await sharp(maskedBuffer)+ .resize(840, 840, {+ fit: 'contain',+ background: { r: 0, g: 0, b: 0, alpha: 0 },+ })+ .extend({+ top: 92,+ bottom: 92,+ left: 92,+ right: 92,+ background: { r: 0, g: 0, b: 0, alpha: 0 },+ })+ .toFile(outputPath);++ return outputPath;+ } catch (error) {+ if (error instanceof Error) {+ logger.warn(`Failed to apply macOS mask: ${error.message}`);+ }return inputPath;}}@@ -164,7 +220,8 @@ async function convertIconFormat(}// macOS- await icongen(processedInputPath, platformOutputDir, {+ const macIconPath = await applyMacOSMask(processedInputPath);+ await icongen(macIconPath, platformOutputDir, {report: false,icns: { name: iconName, sizes: PLATFORM_CONFIG.macos.sizes },});@@ -174,7 +231,9 @@ async function convertIconFormat();return (await fsExtra.pathExists(outputPath)) ? outputPath : null;} catch (error) {- logger.warn(`Icon format conversion failed: ${error.message}`);+ if (error instanceof Error) {+ logger.warn(`Icon format conversion failed: ${error.message}`);+ }return null;}}@@ -356,21 +415,19 @@ async function tryGetFavicon();return finalPath;}- } catch (error) {- logger.debug(`Icon service ${serviceUrl} failed: ${error.message}`);+ } catch (error: unknown) {+ if (error instanceof Error) {+ logger.debug(`Icon service ${serviceUrl} failed: ${error.message}`);+ }- // Platform-specific error handling- if ((IS_LINUX || IS_WIN) && error.code === 'ENOTFOUND') {- logger.debug(- `DNS resolution failed for ${serviceUrl}, trying next service...`,- );+ // Network error handling+ if ((IS_LINUX || IS_WIN) && (error as any).code === 'ENOTFOUND') {+ return null;}- // Windows-specific icon conversion errors- if (IS_WIN && error.message.includes('icongen')) {- logger.debug(- `Windows icon conversion failed for ${serviceUrl}, trying next service...`,- );+ // Icon generation error on Windows+ if (IS_WIN && error instanceof Error && error.message.includes('icongen')) {+ return null;}continue;@@ -380,7 +437,9 @@ async function tryGetFavicon(spinner.warn(`No favicon found for ${domain}. Using default.`);return null;} catch (error) {- logger.warn(`Failed to fetch favicon: ${error.message}`);+ if (error instanceof Error) {+ logger.warn(`Failed to fetch favicon: ${error.message}`);+ }return null;}}@@ -411,9 +470,9 @@ export async function downloadIcon(}return await saveIconFile(iconData, fileDetails.ext);- } catch (error) {- if (showSpinner && !(error.response?.status === 404)) {- throw error;+ } catch (error: unknown) {+ if (showSpinner && !((error as any).response?.status === 404)) {+ logger.error('Icon download failed!', error);}return null;}diff --git a/bin/options/index.ts b/bin/options/index.tsindex c0a2a521..cb90c772 100644--- a/bin/options/index.ts+++ b/bin/options/index.ts@@ -41,7 +41,7 @@ export default async function handleOptions(name = generateLinuxPackageName(name);}- if (!isValidName(name, platform)) {+ if (name && !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.`;const errorMsg =@@ -62,7 +62,7 @@ export default async function handleOptions(};const iconPath = await handleIcon(appOptions, url);- appOptions.icon = iconPath || undefined;+ appOptions.icon = iconPath || '';return appOptions;}diff --git a/bin/utils/validate.ts b/bin/utils/validate.tsindex e55b9bd5..2ef83f0c 100644--- a/bin/utils/validate.ts+++ b/bin/utils/validate.ts@@ -17,7 +17,10 @@ export function validateUrlInput(url: string) {try {return normalizeUrl(url);} catch (error) {- throw new InvalidArgumentError(error.message);+ if (error instanceof Error) {+ throw new InvalidArgumentError(error.message);+ }+ throw error;}}