diff --git a/development/build/index.js b/development/build/index.js index 9c9f75f16..a82d9bbd3 100755 --- a/development/build/index.js +++ b/development/build/index.js @@ -147,6 +147,9 @@ async function defineAndRunBuildTasks() { browserPlatforms, browserVersionMap, buildType, + applyLavaMoat, + shouldIncludeSnow, + entryTask, }); const styleTasks = createStyleTasks({ livereload }); diff --git a/development/build/manifest.js b/development/build/manifest.js index 58817372e..e95690868 100644 --- a/development/build/manifest.js +++ b/development/build/manifest.js @@ -1,14 +1,16 @@ const { promises: fs } = require('fs'); const path = require('path'); -const { mergeWith, cloneDeep } = require('lodash'); +const childProcess = require('child_process'); +const { mergeWith, cloneDeep, capitalize } = require('lodash'); const baseManifest = process.env.ENABLE_MV3 ? require('../../app/manifest/v3/_base.json') : require('../../app/manifest/v2/_base.json'); const { BuildType } = require('../lib/build-type'); -const { TASKS } = require('./constants'); +const { TASKS, ENVIRONMENT } = require('./constants'); const { createTask, composeSeries } = require('./task'); +const { getEnvironment } = require('./utils'); module.exports = createManifestTasks; @@ -16,6 +18,9 @@ function createManifestTasks({ browserPlatforms, browserVersionMap, buildType, + applyLavaMoat, + shouldIncludeSnow, + entryTask, }) { // merge base manifest with per-platform manifests const prepPlatforms = async () => { @@ -38,6 +43,9 @@ function createManifestTasks({ await getBuildModifications(buildType, platform), customArrayMerge, ); + + modifyNameAndDescForNonProd(result); + const dir = path.join('.', 'dist', platform); await fs.mkdir(dir, { recursive: true }); await writeJson(result, path.join(dir, 'manifest.json')); @@ -101,12 +109,39 @@ function createManifestTasks({ ); const manifest = await readJson(manifestPath); transformFn(manifest); + await writeJson(manifest, manifestPath); }), ); }; } + // For non-production builds only, modify the extension's name and description + function modifyNameAndDescForNonProd(manifest) { + const environment = getEnvironment({ buildTarget: entryTask }); + + if (environment === ENVIRONMENT.PRODUCTION) { + return; + } + + const mv3Str = process.env.ENABLE_MV3 ? ' MV3' : ''; + const lavamoatStr = applyLavaMoat ? ' lavamoat' : ''; + const snowStr = shouldIncludeSnow ? ' snow' : ''; + + // Get the first 8 characters of the git revision id + const gitRevisionStr = childProcess + .execSync('git rev-parse HEAD') + .toString() + .trim() + .substring(0, 8); + + manifest.name = `MetaMask ${capitalize( + buildType, + )}${mv3Str}${lavamoatStr}${snowStr}`; + + manifest.description = `${environment} build from git id: ${gitRevisionStr}`; + } + // helper for merging obj value function customArrayMerge(objValue, srcValue) { if (Array.isArray(objValue)) { diff --git a/package.json b/package.json index 6dc22b4da..84251ff08 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "start": "yarn build:dev dev --apply-lavamoat=false --snow=false", "start:lavamoat": "yarn build:dev dev --apply-lavamoat=true", "start:mv3": "ENABLE_MV3=true yarn build:dev dev --apply-lavamoat=false", + "start:flask": "yarn start --build-type flask", "dist": "yarn build dist", "build": "yarn lavamoat:build", "build:dev": "node development/build/index.js",