+28
-2
@@ -1,6 +1,8 @@
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const {exec} = require('pkg');
|
||||
const {execFileSync} = require('child_process');
|
||||
const esbuild = require('esbuild');
|
||||
const {version: packageVersion} = require('../package.json');
|
||||
|
||||
function normalizeBuildVersion(value) {
|
||||
@@ -14,9 +16,33 @@ async function main() {
|
||||
fs.mkdirSync(distDir, {recursive: true});
|
||||
}
|
||||
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gsa-sea-'));
|
||||
const bundlePath = path.join(tempDir, 'index.cjs');
|
||||
const seaBlobPath = path.join(tempDir, 'sea-prep.blob');
|
||||
const seaConfigPath = path.join(tempDir, 'sea-config.json');
|
||||
const buildVersion = normalizeBuildVersion(process.env.BUILD_VERSION);
|
||||
const outputFile = path.join(distDir, `gSheets-Rate-Assistant-${buildVersion}.exe`);
|
||||
await exec(['.', '--targets', 'latest-win-x64', '--output', outputFile]);
|
||||
|
||||
await esbuild.build({
|
||||
entryPoints: [path.resolve(__dirname, '..', 'index.js')],
|
||||
bundle: true,
|
||||
platform: 'node',
|
||||
format: 'cjs',
|
||||
target: 'node26',
|
||||
outfile: bundlePath,
|
||||
logLevel: 'info',
|
||||
});
|
||||
|
||||
fs.writeFileSync(seaConfigPath, JSON.stringify({
|
||||
main: bundlePath,
|
||||
output: outputFile,
|
||||
mainFormat: 'commonjs',
|
||||
disableExperimentalSEAWarning: true,
|
||||
useCodeCache: false,
|
||||
useSnapshot: false,
|
||||
}, null, 2));
|
||||
|
||||
execFileSync(process.execPath, ['--build-sea', seaConfigPath], {stdio: 'inherit'});
|
||||
}
|
||||
|
||||
main().catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user