1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Replace isBeta with buildType (#12231)

This is a refactor to replace the `isBeta` boolean with `buildType`
throughout the build system. This will allow us to modify the behaviour
of each step of the build process for Flask as well.

This should result in no functional changes.
This commit is contained in:
Mark Stacey 2021-09-28 13:43:26 -02:30 committed by GitHub
parent 92b075581c
commit 3f577700c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 12 deletions

View File

@ -7,13 +7,14 @@ const pump = pify(require('pump'));
const { version } = require('../../package.json'); const { version } = require('../../package.json');
const { createTask, composeParallel } = require('./task'); const { createTask, composeParallel } = require('./task');
const { BuildTypes } = require('./utils');
module.exports = createEtcTasks; module.exports = createEtcTasks;
function createEtcTasks({ function createEtcTasks({
betaVersionsMap, betaVersionsMap,
browserPlatforms, browserPlatforms,
isBeta, buildType,
livereload, livereload,
}) { }) {
const clean = createTask('clean', async function clean() { const clean = createTask('clean', async function clean() {
@ -34,7 +35,10 @@ function createEtcTasks({
'zip', 'zip',
composeParallel( composeParallel(
...browserPlatforms.map((platform) => ...browserPlatforms.map((platform) =>
createZipTask(platform, isBeta ? betaVersionsMap[platform] : undefined), createZipTask(
platform,
buildType === BuildTypes.beta ? betaVersionsMap[platform] : undefined,
),
), ),
), ),
); );

View File

@ -37,7 +37,6 @@ function defineAndRunBuildTasks() {
betaVersion, betaVersion,
buildType, buildType,
entryTask, entryTask,
isBeta,
isLavaMoat, isLavaMoat,
shouldIncludeLockdown, shouldIncludeLockdown,
shouldLintFenceFiles, shouldLintFenceFiles,
@ -47,7 +46,7 @@ function defineAndRunBuildTasks() {
const browserPlatforms = ['firefox', 'chrome', 'brave', 'opera']; const browserPlatforms = ['firefox', 'chrome', 'brave', 'opera'];
let betaVersionsMap; let betaVersionsMap;
if (isBeta) { if (buildType === BuildTypes.beta) {
betaVersionsMap = getNextBetaVersionMap( betaVersionsMap = getNextBetaVersionMap(
version, version,
betaVersion, betaVersion,
@ -59,13 +58,13 @@ function defineAndRunBuildTasks() {
livereload, livereload,
browserPlatforms, browserPlatforms,
shouldIncludeLockdown, shouldIncludeLockdown,
isBeta, buildType,
}); });
const manifestTasks = createManifestTasks({ const manifestTasks = createManifestTasks({
browserPlatforms, browserPlatforms,
betaVersionsMap, betaVersionsMap,
isBeta, buildType,
}); });
const styleTasks = createStyleTasks({ livereload }); const styleTasks = createStyleTasks({ livereload });
@ -82,7 +81,7 @@ function defineAndRunBuildTasks() {
livereload, livereload,
browserPlatforms, browserPlatforms,
betaVersionsMap, betaVersionsMap,
isBeta, buildType,
}); });
// build for development (livereload) // build for development (livereload)
@ -201,7 +200,6 @@ function parseArgv() {
betaVersion: String(betaVersion), betaVersion: String(betaVersion),
buildType, buildType,
entryTask, entryTask,
isBeta: argv[NamedArgs.BuildType] === BuildTypes.beta,
isLavaMoat: process.argv[0].includes('lavamoat'), isLavaMoat: process.argv[0].includes('lavamoat'),
shouldIncludeLockdown: argv[NamedArgs.OmitLockdown], shouldIncludeLockdown: argv[NamedArgs.OmitLockdown],
shouldLintFenceFiles, shouldLintFenceFiles,

View File

@ -7,10 +7,11 @@ const { version } = require('../../package.json');
const betaManifestModifications = require('../../app/manifest/_beta_modifications.json'); const betaManifestModifications = require('../../app/manifest/_beta_modifications.json');
const { createTask, composeSeries } = require('./task'); const { createTask, composeSeries } = require('./task');
const { BuildTypes } = require('./utils');
module.exports = createManifestTasks; module.exports = createManifestTasks;
function createManifestTasks({ betaVersionsMap, browserPlatforms, isBeta }) { function createManifestTasks({ betaVersionsMap, browserPlatforms, buildType }) {
// merge base manifest with per-platform manifests // merge base manifest with per-platform manifests
const prepPlatforms = async () => { const prepPlatforms = async () => {
return Promise.all( return Promise.all(
@ -28,7 +29,7 @@ function createManifestTasks({ betaVersionsMap, browserPlatforms, isBeta }) {
const result = merge( const result = merge(
cloneDeep(baseManifest), cloneDeep(baseManifest),
platformModifications, platformModifications,
isBeta buildType === BuildTypes.beta
? getBetaModifications(platform, betaVersionsMap) ? getBetaModifications(platform, betaVersionsMap)
: { version }, : { version },
); );

View File

@ -6,6 +6,7 @@ const glob = require('fast-glob');
const locales = require('../../app/_locales/index.json'); const locales = require('../../app/_locales/index.json');
const { createTask, composeSeries } = require('./task'); const { createTask, composeSeries } = require('./task');
const { BuildTypes } = require('./utils');
const EMPTY_JS_FILE = './development/empty.js'; const EMPTY_JS_FILE = './development/empty.js';
@ -13,7 +14,7 @@ module.exports = function createStaticAssetTasks({
livereload, livereload,
browserPlatforms, browserPlatforms,
shouldIncludeLockdown = true, shouldIncludeLockdown = true,
isBeta, buildType,
}) { }) {
const [copyTargetsProd, copyTargetsDev] = getCopyTargets( const [copyTargetsProd, copyTargetsDev] = getCopyTargets(
shouldIncludeLockdown, shouldIncludeLockdown,
@ -27,7 +28,8 @@ module.exports = function createStaticAssetTasks({
}, },
]; ];
const targets = isBeta ? copyTargetsBeta : copyTargetsProd; const targets =
buildType === BuildTypes.beta ? copyTargetsBeta : copyTargetsProd;
const prod = createTask( const prod = createTask(
'static:prod', 'static:prod',