fix: build layer (#2769)

This commit is contained in:
Himself65
2023-06-14 18:40:13 +08:00
committed by GitHub
parent ad32ed5dd5
commit 761965240d
2 changed files with 24 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
const { z } = require('zod'); const { z } = require('zod');
const { const {
@@ -104,6 +105,27 @@ module.exports = {
// so stable and canary will not share the same app data // so stable and canary will not share the same app data
packageJson.productName = productName; packageJson.productName = productName;
}, },
prePackage: async () => {
const { rm, cp } = require('node:fs/promises');
const { resolve } = require('node:path');
await rm(
resolve(__dirname, './node_modules/@toeverything/plugin-infra'),
{
recursive: true,
force: true,
}
);
await cp(
resolve(__dirname, '../../packages/plugin-infra'),
resolve(__dirname, './node_modules/@toeverything/plugin-infra'),
{
recursive: true,
force: true,
}
);
},
generateAssets: async (_, platform, arch) => { generateAssets: async (_, platform, arch) => {
if (process.env.SKIP_GENERATE_ASSETS) { if (process.env.SKIP_GENERATE_ASSETS) {
return; return;

View File

@@ -32,10 +32,6 @@ if (releaseVersionEnv && electronPackageJson.version !== releaseVersionEnv) {
} }
// copy web dist files to electron dist // copy web dist files to electron dist
// step 1: clean up
await cleanup();
echo('Clean up done');
if (process.platform === 'win32') { if (process.platform === 'win32') {
$.shell = 'powershell.exe'; $.shell = 'powershell.exe';
$.prefix = ''; $.prefix = '';
@@ -43,7 +39,7 @@ if (process.platform === 'win32') {
cd(repoRootDir); cd(repoRootDir);
// step 2: build web (nextjs) dist // step 1: build web (nextjs) dist
if (!process.env.SKIP_WEB_BUILD) { if (!process.env.SKIP_WEB_BUILD) {
process.env.ENABLE_LEGACY_PROVIDER = 'false'; process.env.ENABLE_LEGACY_PROVIDER = 'false';
await $`yarn nx build @affine/web`; await $`yarn nx build @affine/web`;
@@ -67,7 +63,7 @@ if (!process.env.SKIP_WEB_BUILD) {
await fs.move(affineWebOutDir, publicAffineOutDir, { overwrite: true }); await fs.move(affineWebOutDir, publicAffineOutDir, { overwrite: true });
} }
// step 3: update app-updater.yml content with build type in resources folder // step 2: update app-updater.yml content with build type in resources folder
if (process.env.BUILD_TYPE === 'internal') { if (process.env.BUILD_TYPE === 'internal') {
const appUpdaterYml = path.join(publicDistDir, 'app-update.yml'); const appUpdaterYml = path.join(publicDistDir, 'app-update.yml');
const appUpdaterYmlContent = await fs.readFile(appUpdaterYml, 'utf-8'); const appUpdaterYmlContent = await fs.readFile(appUpdaterYml, 'utf-8');
@@ -77,14 +73,3 @@ if (process.env.BUILD_TYPE === 'internal') {
); );
await fs.writeFile(appUpdaterYml, newAppUpdaterYmlContent); await fs.writeFile(appUpdaterYml, newAppUpdaterYmlContent);
} }
/// --------
/// --------
/// --------
async function cleanup() {
if (!process.env.SKIP_WEB_BUILD) {
await fs.emptyDir(publicAffineOutDir);
}
await fs.remove(path.join(electronRootDir, 'dist'));
await fs.remove(path.join(electronRootDir, 'out'));
}