Skip to content

Commit

Permalink
update build script to persist manifest changes made by the developme…
Browse files Browse the repository at this point in the history
…nt client (e.g., change user-agent)
  • Loading branch information
ronny1982 committed Oct 7, 2023
1 parent df1e6f4 commit 4dc581e
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions app/nw/scripts/build-app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,36 @@ import path from 'path';
import fs from 'fs-extra';
import { purge, run } from './tools.mjs';

const dirBuild = path.resolve('build');
const pkgFile = 'package.json';
const pkgConfig = await fs.readJSON(pkgFile);
const dirBuild = path.resolve('build');

async function createApplicationManifest() {
const manifest = {
name: pkgConfig.name,
//type: 'commonjs',
main: pkgConfig.main,
//'node-main': pkgConfig.main,
url: pkgConfig.url,
'node-remote': [
'http://localhost/*',
'https://haruneko.pages.dev/*'
],
/*
webkit: {
plugin: true,
'page-cache': false
},
*/
'user-agent': null,
dependencies: pkgConfig.dependencies
};
const file = path.resolve(dirBuild, pkgFile);
await fs.writeJSON(file, manifest, { spaces: 4 });
}
const targetFile = path.resolve(dirBuild, pkgFile);
let targetConfig = {};
try {
targetConfig = await fs.readJSON(targetFile);
} catch { /* IGNORE */ }

await purge(dirBuild);
await createApplicationManifest();

const manifest = {
name: pkgConfig.name,
//type: 'commonjs',
main: pkgConfig.main,
//'node-main': pkgConfig.main,
url: pkgConfig.url,
'node-remote': [
'http://localhost/*',
'https://haruneko.pages.dev/*'
],
/*
webkit: {
plugin: true,
'page-cache': false
},
*/
'user-agent': targetConfig['user-agent'] || null,
dependencies: pkgConfig.dependencies
};

await fs.writeJSON(targetFile, manifest, { spaces: 4 });
await run('npm install --only=production', dirBuild);

0 comments on commit 4dc581e

Please sign in to comment.