✨ Support test packaging process
This commit is contained in:
45
bin/builders/BaseBuilder.ts
vendored
45
bin/builders/BaseBuilder.ts
vendored
@@ -118,8 +118,44 @@ export default abstract class BaseBuilder {
|
||||
abstract getFileName(): string;
|
||||
|
||||
protected getBuildCommand(): string {
|
||||
// the debug option should support `--debug` and `--release`
|
||||
return this.options.debug ? 'npm run build:debug' : 'npm run build';
|
||||
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(
|
||||
npmDirectory,
|
||||
'src-tauri',
|
||||
'.pake',
|
||||
'tauri.conf.json',
|
||||
);
|
||||
let fullCommand = `${baseCommand} -- -c "${configPath}"`;
|
||||
|
||||
// For macOS, use app bundles by default unless DMG is explicitly requested
|
||||
if (IS_MAC && this.options.targets === 'app') {
|
||||
fullCommand += ' --bundles app';
|
||||
}
|
||||
|
||||
// Add macos-proxy feature for modern macOS (Darwin 23+ = macOS 14+)
|
||||
if (IS_MAC) {
|
||||
const macOSVersion = this.getMacOSMajorVersion();
|
||||
if (macOSVersion >= 23) {
|
||||
fullCommand += ' --features macos-proxy';
|
||||
}
|
||||
}
|
||||
|
||||
return fullCommand;
|
||||
}
|
||||
|
||||
private getMacOSMajorVersion(): number {
|
||||
try {
|
||||
const os = require('os');
|
||||
const release = os.release();
|
||||
const majorVersion = parseInt(release.split('.')[0], 10);
|
||||
return majorVersion;
|
||||
} catch (error) {
|
||||
return 0; // Disable proxy feature if version detection fails
|
||||
}
|
||||
}
|
||||
|
||||
protected getBasePath(): string {
|
||||
@@ -132,10 +168,13 @@ export default abstract class BaseBuilder {
|
||||
fileName: string,
|
||||
fileType: string,
|
||||
): string {
|
||||
// For app bundles on macOS, the directory is 'macos', not 'app'
|
||||
const bundleDir =
|
||||
fileType.toLowerCase() === 'app' ? 'macos' : fileType.toLowerCase();
|
||||
return path.join(
|
||||
npmDirectory,
|
||||
this.getBasePath(),
|
||||
fileType.toLowerCase(),
|
||||
bundleDir,
|
||||
`${fileName}.${fileType}`,
|
||||
);
|
||||
}
|
||||
|
||||
15
bin/builders/MacBuilder.ts
vendored
15
bin/builders/MacBuilder.ts
vendored
@@ -5,11 +5,24 @@ import BaseBuilder from './BaseBuilder';
|
||||
export default class MacBuilder extends BaseBuilder {
|
||||
constructor(options: PakeAppOptions) {
|
||||
super(options);
|
||||
this.options.targets = 'dmg';
|
||||
// Use DMG by default for distribution
|
||||
// Only create app bundles for testing to avoid user interaction
|
||||
if (process.env.PAKE_CREATE_APP === '1') {
|
||||
this.options.targets = 'app';
|
||||
} else {
|
||||
this.options.targets = 'dmg';
|
||||
}
|
||||
}
|
||||
|
||||
getFileName(): string {
|
||||
const { name } = this.options;
|
||||
|
||||
// For app bundles, use simple name without version/arch
|
||||
if (this.options.targets === 'app') {
|
||||
return name;
|
||||
}
|
||||
|
||||
// For DMG files, use versioned filename
|
||||
let arch: string;
|
||||
if (this.options.multiArch) {
|
||||
arch = 'universal';
|
||||
|
||||
Reference in New Issue
Block a user