🐛 Fix packaging issues under Windows

This commit is contained in:
Tw93
2025-08-26 19:38:02 +08:00
parent 88690b15ea
commit 0e11f7f647
2 changed files with 22 additions and 9 deletions

View File

@@ -9,7 +9,12 @@ export default class WinBuilder extends BaseBuilder {
constructor(options: PakeAppOptions) { constructor(options: PakeAppOptions) {
super(options); super(options);
this.buildArch = this.resolveTargetArch(options.targets); // For Windows, targets can be architecture names or format names
// Filter out non-architecture values
const validArchs = ['x64', 'arm64', 'auto'];
this.buildArch = validArchs.includes(options.targets || '')
? this.resolveTargetArch(options.targets)
: this.resolveTargetArch('auto');
this.options.targets = this.buildFormat; this.options.targets = this.buildFormat;
} }

24
dist/cli.js vendored
View File

@@ -804,22 +804,22 @@ BaseBuilder.ARCH_MAPPINGS = {
darwin: { darwin: {
arm64: 'aarch64-apple-darwin', arm64: 'aarch64-apple-darwin',
x64: 'x86_64-apple-darwin', x64: 'x86_64-apple-darwin',
universal: 'universal-apple-darwin' universal: 'universal-apple-darwin',
}, },
win32: { win32: {
arm64: 'aarch64-pc-windows-msvc', arm64: 'aarch64-pc-windows-msvc',
x64: 'x86_64-pc-windows-msvc' x64: 'x86_64-pc-windows-msvc',
}, },
linux: { linux: {
arm64: 'aarch64-unknown-linux-gnu', arm64: 'aarch64-unknown-linux-gnu',
x64: 'x86_64-unknown-linux-gnu' x64: 'x86_64-unknown-linux-gnu',
} },
}; };
// 架构名称映射(用于文件名生成) // 架构名称映射(用于文件名生成)
BaseBuilder.ARCH_DISPLAY_NAMES = { BaseBuilder.ARCH_DISPLAY_NAMES = {
arm64: 'aarch64', arm64: 'aarch64',
x64: 'x64', x64: 'x64',
universal: 'universal' universal: 'universal',
}; };
class MacBuilder extends BaseBuilder { class MacBuilder extends BaseBuilder {
@@ -829,7 +829,9 @@ class MacBuilder extends BaseBuilder {
// For macOS, targets can be architecture names or format names // For macOS, targets can be architecture names or format names
// Filter out non-architecture values // Filter out non-architecture values
const validArchs = ['intel', 'apple', 'universal', 'auto', 'x64', 'arm64']; const validArchs = ['intel', 'apple', 'universal', 'auto', 'x64', 'arm64'];
this.buildArch = validArchs.includes(options.targets || '') ? options.targets : 'auto'; this.buildArch = validArchs.includes(options.targets || '')
? 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') {
@@ -903,7 +905,12 @@ class WinBuilder extends BaseBuilder {
constructor(options) { constructor(options) {
super(options); super(options);
this.buildFormat = 'msi'; this.buildFormat = 'msi';
this.buildArch = this.resolveTargetArch(options.targets); // For Windows, targets can be architecture names or format names
// Filter out non-architecture values
const validArchs = ['x64', 'arm64', 'auto'];
this.buildArch = validArchs.includes(options.targets || '')
? this.resolveTargetArch(options.targets)
: this.resolveTargetArch('auto');
this.options.targets = this.buildFormat; this.options.targets = this.buildFormat;
} }
getFileName() { getFileName() {
@@ -961,7 +968,8 @@ class LinuxBuilder extends BaseBuilder {
// Auto-detect or default to current architecture // Auto-detect or default to current architecture
const resolvedArch = this.buildArch === 'x64' ? 'amd64' : this.buildArch; const resolvedArch = this.buildArch === 'x64' ? 'amd64' : this.buildArch;
arch = resolvedArch; arch = resolvedArch;
if (resolvedArch === 'arm64' && (targets === 'rpm' || targets === 'appimage')) { if (resolvedArch === 'arm64' &&
(targets === 'rpm' || targets === 'appimage')) {
arch = 'aarch64'; arch = 'aarch64';
} }
} }