🐛 Fix duplicate emoji in icon processing prompt

This commit is contained in:
Tw93
2025-08-22 23:54:16 +08:00
parent 3868e993ce
commit bda4376594
3 changed files with 185 additions and 21 deletions

2
bin/options/icon.ts vendored
View File

@@ -281,7 +281,7 @@ async function tryGetFavicon(
} }
} }
spinner.warn(`No favicon found for ${domain}. Using default.`); spinner.warn(`No favicon found for ${domain}. Using default.`);
return null; return null;
} catch (error) { } catch (error) {
logger.warn(`Failed to fetch favicon: ${error.message}`); logger.warn(`Failed to fetch favicon: ${error.message}`);

200
dist/cli.js vendored
View File

@@ -709,33 +709,46 @@ class BaseBuilder {
class MacBuilder extends BaseBuilder { class MacBuilder extends BaseBuilder {
constructor(options) { constructor(options) {
super(options); super(options);
// Store the original targets value for architecture selection
this.buildArch = options.targets || 'auto';
// Use DMG by default for distribution // Use DMG by default for distribution
// Only create app bundles for testing to avoid user interaction // Only create app bundles for testing to avoid user interaction
if (process.env.PAKE_CREATE_APP === '1') { if (process.env.PAKE_CREATE_APP === '1') {
this.options.targets = 'app'; this.buildFormat = 'app';
} }
else { else {
this.options.targets = 'dmg'; this.buildFormat = 'dmg';
} }
// Set targets to format for Tauri
this.options.targets = this.buildFormat;
} }
getFileName() { getFileName() {
const { name } = this.options; const { name } = this.options;
// For app bundles, use simple name without version/arch // For app bundles, use simple name without version/arch
if (this.options.targets === 'app') { if (this.buildFormat === 'app') {
return name; return name;
} }
// For DMG files, use versioned filename // For DMG files, use versioned filename
let arch; let arch;
if (this.options.multiArch) { if (this.buildArch === 'universal' || this.options.multiArch) {
arch = 'universal'; arch = 'universal';
} }
else if (this.buildArch === 'apple') {
arch = 'aarch64';
}
else if (this.buildArch === 'intel') {
arch = 'x64';
}
else { else {
// Auto-detect based on current architecture
arch = process.arch === 'arm64' ? 'aarch64' : process.arch; arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
} }
return `${name}_${tauriConfig.version}_${arch}`; return `${name}_${tauriConfig.version}_${arch}`;
} }
getBuildCommand() { getBuildCommand() {
if (this.options.multiArch) { // Determine if we need universal build
const needsUniversal = this.buildArch === 'universal' || this.options.multiArch;
if (needsUniversal) {
const baseCommand = this.options.debug const baseCommand = this.options.debug
? 'npm run tauri build -- --debug' ? 'npm run tauri build -- --debug'
: 'npm run tauri build --'; : 'npm run tauri build --';
@@ -754,38 +767,165 @@ class MacBuilder extends BaseBuilder {
} }
return fullCommand; return fullCommand;
} }
else if (this.buildArch === 'apple') {
// Build for Apple Silicon only
const baseCommand = this.options.debug
? 'npm run tauri build -- --debug'
: 'npm run tauri build --';
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
let fullCommand = `${baseCommand} --target aarch64-apple-darwin -c "${configPath}"`;
// Add features
const features = ['cli-build'];
const macOSVersion = this.getMacOSMajorVersion();
if (macOSVersion >= 23) {
features.push('macos-proxy');
}
if (features.length > 0) {
fullCommand += ` --features ${features.join(',')}`;
}
return fullCommand;
}
else if (this.buildArch === 'intel') {
// Build for Intel only
const baseCommand = this.options.debug
? 'npm run tauri build -- --debug'
: 'npm run tauri build --';
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
let fullCommand = `${baseCommand} --target x86_64-apple-darwin -c "${configPath}"`;
// Add features
const features = ['cli-build'];
const macOSVersion = this.getMacOSMajorVersion();
if (macOSVersion >= 23) {
features.push('macos-proxy');
}
if (features.length > 0) {
fullCommand += ` --features ${features.join(',')}`;
}
return fullCommand;
}
return super.getBuildCommand(); return super.getBuildCommand();
} }
getBasePath() { getBasePath() {
return this.options.multiArch const needsUniversal = this.buildArch === 'universal' || this.options.multiArch;
? 'src-tauri/target/universal-apple-darwin/release/bundle' const basePath = this.options.debug ? 'debug' : 'release';
: super.getBasePath(); if (needsUniversal) {
return `src-tauri/target/universal-apple-darwin/${basePath}/bundle`;
}
else if (this.buildArch === 'apple') {
return `src-tauri/target/aarch64-apple-darwin/${basePath}/bundle`;
}
else if (this.buildArch === 'intel') {
return `src-tauri/target/x86_64-apple-darwin/${basePath}/bundle`;
}
return super.getBasePath();
} }
} }
class WinBuilder extends BaseBuilder { class WinBuilder extends BaseBuilder {
constructor(options) { constructor(options) {
super(options); super(options);
this.options.targets = 'msi'; this.buildFormat = 'msi';
// Store the original targets value for architecture selection
this.buildArch = options.targets || 'auto';
// Set targets to msi format for Tauri
this.options.targets = this.buildFormat;
} }
getFileName() { getFileName() {
const { name } = this.options; const { name } = this.options;
const { arch } = process;
const language = tauriConfig.bundle.windows.wix.language[0]; const language = tauriConfig.bundle.windows.wix.language[0];
return `${name}_${tauriConfig.version}_${arch}_${language}`; // Determine architecture name based on explicit targets option or auto-detect
let targetArch;
if (this.buildArch === 'arm64') {
targetArch = 'aarch64';
}
else if (this.buildArch === 'x64') {
targetArch = 'x64';
}
else {
// Auto-detect based on current architecture if no explicit target
const archMap = {
'x64': 'x64',
'arm64': 'aarch64',
};
targetArch = archMap[process.arch] || process.arch;
}
return `${name}_${tauriConfig.version}_${targetArch}_${language}`;
}
getBuildCommand() {
const baseCommand = this.options.debug
? 'npm run build:debug'
: 'npm run build';
// Use temporary config directory to avoid modifying source files
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
let fullCommand = `${baseCommand} -- -c "${configPath}"`;
// Determine build target based on explicit targets option or auto-detect
let buildTarget;
if (this.buildArch === 'arm64') {
buildTarget = 'aarch64-pc-windows-msvc';
}
else if (this.buildArch === 'x64') {
buildTarget = 'x86_64-pc-windows-msvc';
}
else {
// Auto-detect based on current architecture if no explicit target
buildTarget = process.arch === 'arm64' ? 'aarch64-pc-windows-msvc' : 'x86_64-pc-windows-msvc';
}
fullCommand += ` --target ${buildTarget}`;
// Add features
const features = ['cli-build'];
if (features.length > 0) {
fullCommand += ` --features ${features.join(',')}`;
}
return fullCommand;
}
getBasePath() {
const basePath = this.options.debug ? 'debug' : 'release';
// Determine target based on explicit targets option or auto-detect
let target;
if (this.buildArch === 'arm64') {
target = 'aarch64-pc-windows-msvc';
}
else if (this.buildArch === 'x64') {
target = 'x86_64-pc-windows-msvc';
}
else {
// Auto-detect based on current architecture if no explicit target
target = process.arch === 'arm64' ? 'aarch64-pc-windows-msvc' : 'x86_64-pc-windows-msvc';
}
return `src-tauri/target/${target}/${basePath}/bundle/`;
} }
} }
class LinuxBuilder extends BaseBuilder { class LinuxBuilder extends BaseBuilder {
constructor(options) { constructor(options) {
super(options); super(options);
// Parse target format and architecture
const target = options.targets || 'deb';
if (target.includes('-arm64')) {
this.buildFormat = target.replace('-arm64', '');
this.buildArch = 'arm64';
}
else {
this.buildFormat = target;
this.buildArch = 'auto';
}
// Set targets to format for Tauri
this.options.targets = this.buildFormat;
} }
getFileName() { getFileName() {
const { name, targets } = this.options; const { name, targets } = this.options;
const version = tauriConfig.version; const version = tauriConfig.version;
let arch = process.arch === 'x64' ? 'amd64' : process.arch; // Determine architecture based on explicit target or auto-detect
if (arch === 'arm64' && (targets === 'rpm' || targets === 'appimage')) { let arch;
arch = 'aarch64'; if (this.buildArch === 'arm64') {
arch = targets === 'rpm' || targets === 'appimage' ? 'aarch64' : 'arm64';
}
else {
// Auto-detect or default to current architecture
arch = process.arch === 'x64' ? 'amd64' : process.arch;
if (arch === 'arm64' && (targets === 'rpm' || targets === 'appimage')) {
arch = 'aarch64';
}
} }
// The RPM format uses different separators and version number formats // The RPM format uses different separators and version number formats
if (targets === 'rpm') { if (targets === 'rpm') {
@@ -802,6 +942,31 @@ class LinuxBuilder extends BaseBuilder {
} }
} }
} }
getBuildCommand() {
const baseCommand = this.options.debug
? 'npm run build:debug'
: 'npm run build';
// Use temporary config directory to avoid modifying source files
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
let fullCommand = `${baseCommand} -- -c "${configPath}"`;
// Add ARM64 target if explicitly specified
if (this.buildArch === 'arm64') {
fullCommand += ' --target aarch64-unknown-linux-gnu';
}
// Add features
const features = ['cli-build'];
if (features.length > 0) {
fullCommand += ` --features ${features.join(',')}`;
}
return fullCommand;
}
getBasePath() {
const basePath = this.options.debug ? 'debug' : 'release';
if (this.buildArch === 'arm64') {
return `src-tauri/target/aarch64-unknown-linux-gnu/${basePath}/bundle/`;
}
return super.getBasePath();
}
getFileType(target) { getFileType(target) {
if (target === 'appimage') { if (target === 'appimage') {
return 'AppImage'; return 'AppImage';
@@ -1068,7 +1233,7 @@ async function tryGetFavicon(url, appName) {
continue; continue;
} }
} }
spinner.warn(`No favicon found for ${domain}. Using default.`); spinner.warn(`No favicon found for ${domain}. Using default.`);
return null; return null;
} }
catch (error) { catch (error) {
@@ -1271,9 +1436,8 @@ program
.addOption(new Option('--user-agent <string>', 'Custom user agent') .addOption(new Option('--user-agent <string>', 'Custom user agent')
.default(DEFAULT_PAKE_OPTIONS.userAgent) .default(DEFAULT_PAKE_OPTIONS.userAgent)
.hideHelp()) .hideHelp())
.addOption(new Option('--targets <string>', 'For Linux, option "deb" or "appimage"') .addOption(new Option('--targets <string>', 'Build target: Linux: "deb", "appimage", "deb-arm64", "appimage-arm64"; Windows: "x64", "arm64"; macOS: "intel", "apple", "universal"')
.default(DEFAULT_PAKE_OPTIONS.targets) .default(DEFAULT_PAKE_OPTIONS.targets))
.hideHelp())
.addOption(new Option('--app-version <string>', 'App version, the same as package.json version') .addOption(new Option('--app-version <string>', 'App version, the same as package.json version')
.default(DEFAULT_PAKE_OPTIONS.appVersion) .default(DEFAULT_PAKE_OPTIONS.appVersion)
.hideHelp()) .hideHelp())

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "pake-cli", "name": "pake-cli",
"version": "3.2.12", "version": "3.2.15",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "pake-cli", "name": "pake-cli",
"version": "3.2.12", "version": "3.2.15",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@tauri-apps/api": "^2.8.0", "@tauri-apps/api": "^2.8.0",