1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/development/generate-lavamoat-policies.js
Olaf Tomalka 95c37e1ba3
feat: add yaml feature management (#18125)
* feat: add yaml feature management

Add yaml feature file per build type.
Also add method to parse yaml and set
enabled features env to true. The build
process will then replace any process.env[feature]
that exists on the config by its value

* chore: add example for desktop

* Added initial draft of build features

* [TMP] Sync between computers

* Is able to succesfully build stable extension with snaps feature

* Removing var context from builds.yml

* Add asssets to builds.yml

* Minor bug fixes and removing debug logs

* [WIP] Test changes

* Removed TODOs

* Fix regession bug

Also
* remove debug logs
* merge Variables.set and Variables.setMany with an overload

* Fix build, lint and a bunch of issues

* Update LavaMoat policies

* Re-add desktop build type

* Fix some tests

* Fix desktop build

* Define some env variables used by MV3

* Fix lint

* Fix remove-fenced-code tests

* Fix README typo

* Move new code

* Fix missing asset copy

* Move Jest env setup

* Fix path for test after rebase

* Fix code fences

* Fix fencing and LavaMoat policies

* Fix MMI code-fencing after rebase

* Fix MMI code fencing after merge

* Fix more MMI code fencing

---------

Co-authored-by: cryptotavares <joao.tavares@consensys.net>
Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2023-04-25 16:32:51 +02:00

71 lines
2.1 KiB
JavaScript
Executable File

#!/usr/bin/env node
const concurrently = require('concurrently');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const { loadBuildTypesConfig } = require('./lib/build-type');
const buildTypesConfig = loadBuildTypesConfig();
const stableBuildTypes = Object.keys(buildTypesConfig.buildTypes).filter(
// Skip generating policy for MMI until that build has stabilized
(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.keys(buildTypesConfig.buildTypes),
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!');
}