fix: cleanup electron build script (#1813)

This commit is contained in:
Peng Xiao
2023-04-04 20:40:07 +08:00
committed by GitHub
parent c023d0a2b8
commit 5bd3aa4a80
5 changed files with 64 additions and 150 deletions
+14
View File
@@ -31,4 +31,18 @@ module.exports = {
},
},
],
hooks: {
generateAssets: async (_, platform, arch) => {
const { $ } = await import('zx');
if (platform === 'darwin' && arch === 'arm64') {
// In GitHub Actions runner, MacOS is always x64
// we need to manually set TARGET to aarch64-apple-darwin
process.env.TARGET = 'aarch64-apple-darwin';
}
// run yarn generate-assets
await $`yarn generate-assets`;
},
},
};
+1 -1
View File
@@ -13,7 +13,7 @@
"scripts": {
"dev": "cross-env NODE_ENV=development node scripts/dev.mjs",
"prod": "cross-env NODE_ENV=production node scripts/dev.mjs",
"before-make": "zx scripts/before-make.mjs",
"generate-assets": "zx scripts/generate-assets.mjs",
"make": "electron-forge make",
"make-macos-arm64": "electron-forge make --platform=darwin --arch=arm64",
"make-macos-x64": "electron-forge make --platform=darwin --arch=x64",
@@ -40,6 +40,17 @@ await fs.move(affineWebOutDir, publicAffineOutDir, { overwrite: true });
await buildLayers();
echo('Build layers done');
// step 3: build octobase-node
let buildOctobaseNode = 'yarn workspace @affine/octobase-node build';
if (process.env.TARGET) {
buildOctobaseNode += ` --target=${process.env.TARGET}`;
}
await $([buildOctobaseNode]);
// step 4: copy octobase-node to electron dist
await fs.ensureDir('./apps/electron/dist/layers/main/');
await $`cp ./packages/octobase-node/octobase.*.node ./apps/electron/dist/layers/main/`;
/// --------
/// --------
/// --------