Skip to content

Commit 9a74c99

Browse files
authored
[LavaMoat] improve policy generation performance in dev workflow (#16338)
* npm scripts - rename lavamoat:background to lavamoat:webapp * lavamoat - generate webapp policy - add devMode flag to run in node for speed * lavamoat - generate webapp policy - dont lint fences * lint fix
1 parent d837250 commit 9a74c99

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

development/generate-lavamoat-policies.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ start().catch((error) => {
1111

1212
async function start() {
1313
const {
14-
argv: { buildTypes, parallel },
14+
argv: { buildTypes, parallel, devMode },
1515
} = yargs(hideBin(process.argv)).usage(
1616
'$0 [options]',
1717
'Generate the LavaMoat policy file for one more more build types.',
@@ -31,13 +31,22 @@ async function start() {
3131
description: 'Whether to generate policies in parallel.',
3232
type: 'boolean',
3333
})
34+
.option('devMode', {
35+
alias: ['d'],
36+
default: false,
37+
demandOption: true,
38+
description:
39+
'Whether to run the process under lavamoat (devMode=false) or node (devMode=true)',
40+
type: 'boolean',
41+
})
3442
.strict(),
3543
);
3644

45+
const buildCommand = devMode ? 'build:dev' : 'build';
3746
await concurrently(
3847
(Array.isArray(buildTypes) ? buildTypes : [buildTypes]).map(
3948
(buildType) => ({
40-
command: `yarn build scripts:dist --policy-only --build-type=${buildType}`,
49+
command: `yarn ${buildCommand} scripts:dist --policy-only --lint-fence-files=false --build-type=${buildType}`,
4150
env: {
4251
WRITE_AUTO_POLICY: 1,
4352
},

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
"lavamoat:build": "lavamoat development/build/index.js --policy lavamoat/build-system/policy.json --policyOverride lavamoat/build-system/policy-override.json",
7474
"lavamoat:build:auto": "yarn lavamoat:build --writeAutoPolicy",
7575
"lavamoat:debug:build": "yarn lavamoat:build --writeAutoPolicyDebug --policydebug lavamoat/build-system/policy-debug.json",
76-
"lavamoat:background:auto": "node ./development/generate-lavamoat-policies.js",
77-
"lavamoat:background:auto:ci": "node ./development/generate-lavamoat-policies.js --parallel=false",
78-
"lavamoat:auto": "yarn lavamoat:build:auto && yarn lavamoat:background:auto",
79-
"lavamoat:auto:ci": "yarn lavamoat:build:auto && yarn lavamoat:background:auto:ci",
76+
"lavamoat:webapp:auto": "node ./development/generate-lavamoat-policies.js --devMode=true",
77+
"lavamoat:webapp:auto:ci": "node ./development/generate-lavamoat-policies.js --parallel=false",
78+
"lavamoat:auto": "yarn lavamoat:build:auto && yarn lavamoat:webapp:auto",
79+
"lavamoat:auto:ci": "yarn lavamoat:build:auto && yarn lavamoat:webapp:auto:ci",
8080
"ts-migration:enumerate": "ts-node development/ts-migration-dashboard/scripts/write-list-of-files-to-convert.ts",
8181
"ts-migration:dashboard:watch": "ts-node development/ts-migration-dashboard/scripts/build.ts --watch",
8282
"ts-migration:dashboard:build": "ts-node development/ts-migration-dashboard/scripts/build.ts",

0 commit comments

Comments
 (0)