🐛 Fix pnpm packaging errors and refactor
This commit is contained in:
68
bin/builders/WinBuilder.ts
vendored
68
bin/builders/WinBuilder.ts
vendored
@@ -9,61 +9,35 @@ export default class WinBuilder extends BaseBuilder {
|
||||
|
||||
constructor(options: PakeAppOptions) {
|
||||
super(options);
|
||||
// Store the original targets value for architecture selection
|
||||
this.buildArch = options.targets || 'auto';
|
||||
// Set targets to msi format for Tauri
|
||||
this.buildArch = this.resolveTargetArch(options.targets);
|
||||
this.options.targets = this.buildFormat;
|
||||
}
|
||||
|
||||
getFileName(): string {
|
||||
const { name } = this.options;
|
||||
const language = tauriConfig.bundle.windows.wix.language[0];
|
||||
|
||||
// Determine architecture name based on explicit targets option or auto-detect
|
||||
let targetArch: string;
|
||||
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: { [key: string]: string } = {
|
||||
x64: 'x64',
|
||||
arm64: 'aarch64',
|
||||
};
|
||||
targetArch = archMap[process.arch] || process.arch;
|
||||
}
|
||||
|
||||
const targetArch = this.getArchDisplayName(this.buildArch);
|
||||
return `${name}_${tauriConfig.version}_${targetArch}_${language}`;
|
||||
}
|
||||
|
||||
protected getBuildCommand(packageManager: string = 'pnpm'): string {
|
||||
const baseCommand = this.options.debug
|
||||
? `${packageManager} run build:debug`
|
||||
: `${packageManager} 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}"`;
|
||||
const buildTarget = this.getTauriTarget(this.buildArch, 'win32');
|
||||
|
||||
// Determine build target based on explicit targets option or auto-detect
|
||||
let buildTarget: string;
|
||||
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';
|
||||
if (!buildTarget) {
|
||||
throw new Error(
|
||||
`Unsupported architecture: ${this.buildArch} for Windows`,
|
||||
);
|
||||
}
|
||||
|
||||
fullCommand += ` --target ${buildTarget}`;
|
||||
let fullCommand = this.buildBaseCommand(
|
||||
packageManager,
|
||||
configPath,
|
||||
buildTarget,
|
||||
);
|
||||
|
||||
// Add features
|
||||
const features = ['cli-build'];
|
||||
const features = this.getBuildFeatures();
|
||||
if (features.length > 0) {
|
||||
fullCommand += ` --features ${features.join(',')}`;
|
||||
}
|
||||
@@ -73,21 +47,7 @@ export default class WinBuilder extends BaseBuilder {
|
||||
|
||||
protected getBasePath(): string {
|
||||
const basePath = this.options.debug ? 'debug' : 'release';
|
||||
|
||||
// Determine target based on explicit targets option or auto-detect
|
||||
let target: string;
|
||||
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';
|
||||
}
|
||||
|
||||
const target = this.getTauriTarget(this.buildArch, 'win32');
|
||||
return `src-tauri/target/${target}/${basePath}/bundle/`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user