🐛 Fix packaging issues under Windows

This commit is contained in:
Tw93
2025-08-26 21:09:46 +08:00
parent b9cffc37b1
commit 21c83143a0
4 changed files with 26 additions and 17 deletions

View File

@@ -255,7 +255,7 @@ export default abstract class BaseBuilder {
? `${packageManager} run build:debug` ? `${packageManager} run build:debug`
: `${packageManager} run build`; : `${packageManager} run build`;
const argSeparator = packageManager === 'npm' ? ' --' : ''; const argSeparator = ' --'; // Both npm and pnpm need -- to pass args to scripts
let fullCommand = `${baseCommand}${argSeparator} -c "${configPath}"`; let fullCommand = `${baseCommand}${argSeparator} -c "${configPath}"`;
if (target) { if (target) {
@@ -283,6 +283,10 @@ export default abstract class BaseBuilder {
} }
protected getBuildCommand(packageManager: string = 'pnpm'): string { 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 // Use temporary config directory to avoid modifying source files
const configPath = path.join( const configPath = path.join(
npmDirectory, npmDirectory,
@@ -290,8 +294,7 @@ export default abstract class BaseBuilder {
'.pake', '.pake',
'tauri.conf.json', 'tauri.conf.json',
); );
let fullCommand = `${baseCommand} -- -c "${configPath}"`;
let fullCommand = this.buildBaseCommand(packageManager, configPath);
// For macOS, use app bundles by default unless DMG is explicitly requested // For macOS, use app bundles by default unless DMG is explicitly requested
if (IS_MAC && this.options.targets === 'app') { if (IS_MAC && this.options.targets === 'app') {

View File

@@ -26,6 +26,10 @@ export default class WinBuilder extends BaseBuilder {
} }
protected getBuildCommand(packageManager: string = 'pnpm'): string { protected getBuildCommand(packageManager: string = 'pnpm'): string {
const baseCommand = this.options.debug
? `${packageManager} run build:debug`
: `${packageManager} run build`;
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json'); const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
const buildTarget = this.getTauriTarget(this.buildArch, 'win32'); const buildTarget = this.getTauriTarget(this.buildArch, 'win32');
@@ -35,11 +39,7 @@ export default class WinBuilder extends BaseBuilder {
); );
} }
let fullCommand = this.buildBaseCommand( let fullCommand = `${baseCommand} -- -c "${configPath}" --target ${buildTarget}`;
packageManager,
configPath,
buildTarget,
);
// Add features // Add features
const features = this.getBuildFeatures(); const features = this.getBuildFeatures();

18
dist/cli.js vendored
View File

@@ -54,9 +54,9 @@ var files = [
var scripts = { var scripts = {
start: "pnpm run dev", start: "pnpm run dev",
dev: "pnpm run tauri dev", dev: "pnpm run tauri dev",
build: "tauri build", build: "pnpm run tauri build --",
"build:debug": "tauri build --debug", "build:debug": "pnpm run tauri build -- --debug",
"build:mac": "tauri build --target universal-apple-darwin", "build:mac": "pnpm run tauri build -- --target universal-apple-darwin",
"build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs", "build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs",
analyze: "cd src-tauri && cargo bloat --release --crates", analyze: "cd src-tauri && cargo bloat --release --crates",
tauri: "tauri", tauri: "tauri",
@@ -742,7 +742,7 @@ class BaseBuilder {
const baseCommand = this.options.debug const baseCommand = this.options.debug
? `${packageManager} run build:debug` ? `${packageManager} run build:debug`
: `${packageManager} run build`; : `${packageManager} run build`;
const argSeparator = packageManager === 'npm' ? ' --' : ''; const argSeparator = ' --'; // Both npm and pnpm need -- to pass args to scripts
let fullCommand = `${baseCommand}${argSeparator} -c "${configPath}"`; let fullCommand = `${baseCommand}${argSeparator} -c "${configPath}"`;
if (target) { if (target) {
fullCommand += ` --target ${target}`; fullCommand += ` --target ${target}`;
@@ -764,9 +764,12 @@ class BaseBuilder {
return features; return features;
} }
getBuildCommand(packageManager = 'pnpm') { getBuildCommand(packageManager = 'pnpm') {
const baseCommand = this.options.debug
? `${packageManager} run build:debug`
: `${packageManager} run build`;
// Use temporary config directory to avoid modifying source files // Use temporary config directory to avoid modifying source files
const configPath = path.join(npmDirectory, 'src-tauri', '.pake', 'tauri.conf.json'); const configPath = path.join(npmDirectory, 'src-tauri', '.pake', 'tauri.conf.json');
let fullCommand = this.buildBaseCommand(packageManager, configPath); let fullCommand = `${baseCommand} -- -c "${configPath}"`;
// For macOS, use app bundles by default unless DMG is explicitly requested // For macOS, use app bundles by default unless DMG is explicitly requested
if (IS_MAC && this.options.targets === 'app') { if (IS_MAC && this.options.targets === 'app') {
fullCommand += ' --bundles app'; fullCommand += ' --bundles app';
@@ -921,12 +924,15 @@ class WinBuilder extends BaseBuilder {
return `${name}_${tauriConfig.version}_${targetArch}_${language}`; return `${name}_${tauriConfig.version}_${targetArch}_${language}`;
} }
getBuildCommand(packageManager = 'pnpm') { getBuildCommand(packageManager = 'pnpm') {
const baseCommand = this.options.debug
? `${packageManager} run build:debug`
: `${packageManager} run build`;
const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json'); const configPath = path.join('src-tauri', '.pake', 'tauri.conf.json');
const buildTarget = this.getTauriTarget(this.buildArch, 'win32'); const buildTarget = this.getTauriTarget(this.buildArch, 'win32');
if (!buildTarget) { if (!buildTarget) {
throw new Error(`Unsupported architecture: ${this.buildArch} for Windows`); throw new Error(`Unsupported architecture: ${this.buildArch} for Windows`);
} }
let fullCommand = this.buildBaseCommand(packageManager, configPath, buildTarget); let fullCommand = `${baseCommand} -- -c "${configPath}" --target ${buildTarget}`;
// Add features // Add features
const features = this.getBuildFeatures(); const features = this.getBuildFeatures();
if (features.length > 0) { if (features.length > 0) {

View File

@@ -32,9 +32,9 @@
"scripts": { "scripts": {
"start": "pnpm run dev", "start": "pnpm run dev",
"dev": "pnpm run tauri dev", "dev": "pnpm run tauri dev",
"build": "tauri build", "build": "pnpm run tauri build --",
"build:debug": "tauri build --debug", "build:debug": "pnpm run tauri build -- --debug",
"build:mac": "tauri build --target universal-apple-darwin", "build:mac": "pnpm run tauri build -- --target universal-apple-darwin",
"build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs", "build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs",
"analyze": "cd src-tauri && cargo bloat --release --crates", "analyze": "cd src-tauri && cargo bloat --release --crates",
"tauri": "tauri", "tauri": "tauri",