1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/development/generate-lavamoat-policies.js
Mark Stacey 18a304199c
Skip generating LavaMoat policy for MMI (#18416)
The MMI build type is still a work in progress, and should not be
expected to build successfully yet, so we haven't committed a LavaMoat
policy to the repository for it yet. The policy update script has been
updated to skip MMI by default for now; we can include it after that
build has reached a point where we are confident it will build
successfully.
2023-04-03 12:42:24 -02:30

69 lines
2.0 KiB
JavaScript
Executable File

#!/usr/bin/env node
const concurrently = require('concurrently');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const { BuildType } = require('./lib/build-type');
const stableBuildTypes = Object.values(BuildType).filter(
// Skip generating policy for MMI until that build has stabilized
(buildType) => buildType !== BuildType.mmi,
);
start().catch((error) => {
console.error('Policy generation failed.', error);
process.exitCode = 1;
});
async function start() {
const {
argv: { buildTypes, parallel, devMode },
} = yargs(hideBin(process.argv)).usage(
'$0 [options]',
'Generate the LavaMoat policy file for one more more build types.',
(yargsInstance) =>
yargsInstance
.option('build-types', {
alias: ['t'],
choices: Object.values(BuildType),
default: stableBuildTypes,
demandOption: true,
description: 'The build type(s) to generate policy files for.',
})
.option('parallel', {
alias: ['p'],
default: true,
demandOption: true,
description: 'Whether to generate policies in parallel.',
type: 'boolean',
})
.option('devMode', {
alias: ['d'],
default: false,
demandOption: true,
description:
'Whether to run the process under lavamoat (devMode=false) or node (devMode=true)',
type: 'boolean',
})
.strict(),
);
const buildCommand = devMode ? 'build:dev' : 'build';
await concurrently(
(Array.isArray(buildTypes) ? buildTypes : [buildTypes]).map(
(buildType) => ({
command: `yarn ${buildCommand} scripts:dist --policy-only --lint-fence-files=false --build-type=${buildType}`,
env: {
WRITE_AUTO_POLICY: 1,
},
name: buildType,
}),
),
{
killOthers: true,
maxProcesses: parallel ? buildTypes.length : 1,
},
);
console.log('Policy file(s) successfully generated!');
}