Add platform-specific build type manifest modifications (#12638)

The build system now supports platform-specific modifications to the
manifest for each build type. The need to customize the `id` on Firefox
motivated this change.

To support this, a new directory was made in each build type directory
for manifest changes. The images currently in this directory were moved
into an `images` subdirectory.

This new `manifest` directory can include each manifest file currently
in `app/manifest`. The `_base.json` file is assumed to exist, but the
platform manifest modifications are optional.
feature/default_network_editable
Mark Stacey 3 years ago committed by GitHub
parent 3f9ec40107
commit faebdd0ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 0
      app/build-types/beta/images/beta-mascot.json
  2. 0
      app/build-types/beta/images/icon-128.png
  3. 0
      app/build-types/beta/images/icon-16.png
  4. 0
      app/build-types/beta/images/icon-19.png
  5. 0
      app/build-types/beta/images/icon-32.png
  6. 0
      app/build-types/beta/images/icon-38.png
  7. 0
      app/build-types/beta/images/icon-48.png
  8. 0
      app/build-types/beta/images/icon-512.png
  9. 0
      app/build-types/beta/images/icon-64.png
  10. 0
      app/build-types/beta/images/info-logo.png
  11. 0
      app/build-types/beta/images/logo/metamask-fox.svg
  12. 0
      app/build-types/beta/images/logo/metamask-logo-horizontal-dark.svg
  13. 0
      app/build-types/beta/images/logo/metamask-logo-horizontal.svg
  14. 0
      app/build-types/beta/manifest/_base.json
  15. 7
      app/build-types/beta/manifest/firefox.json
  16. 0
      app/build-types/flask/images/flask-mascot.json
  17. 0
      app/build-types/flask/images/icon-128.png
  18. 0
      app/build-types/flask/images/icon-16.png
  19. 0
      app/build-types/flask/images/icon-19.png
  20. 0
      app/build-types/flask/images/icon-32.png
  21. 0
      app/build-types/flask/images/icon-38.png
  22. 0
      app/build-types/flask/images/icon-48.png
  23. 0
      app/build-types/flask/images/icon-512.png
  24. 0
      app/build-types/flask/images/icon-64.png
  25. 0
      app/build-types/flask/images/logo/metamask-fox.svg
  26. 0
      app/build-types/flask/images/logo/metamask-logo-horizontal-dark.svg
  27. 0
      app/build-types/flask/images/logo/metamask-logo-horizontal.svg
  28. 0
      app/build-types/flask/manifest/_base.json
  29. 7
      app/build-types/flask/manifest/firefox.json
  30. 57
      development/build/manifest.js
  31. 4
      development/build/static.js
  32. 4
      ui/helpers/utils/build-types.js

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 847 B

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 172 KiB

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

@ -0,0 +1,7 @@
{
"applications": {
"gecko": {
"id": "webextension-beta@metamask.io"
}
}
}

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 211 KiB

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

@ -0,0 +1,7 @@
{
"applications": {
"gecko": {
"id": "webextension-flask@metamask.io"
}
}
}

@ -3,8 +3,6 @@ const path = require('path');
const { merge, cloneDeep } = require('lodash');
const baseManifest = require('../../app/manifest/_base.json');
const betaManifestModifications = require('../../app/manifest/_beta_modifications.json');
const flaskManifestModifications = require('../../app/manifest/_flask_modifications.json');
const { createTask, composeSeries } = require('./task');
const { BuildType } = require('./utils');
@ -34,7 +32,7 @@ function createManifestTasks({
cloneDeep(baseManifest),
platformModifications,
browserVersionMap[platform],
getBuildModifications(buildType),
await getBuildModifications(buildType, platform),
);
const dir = path.join('.', 'dist', platform);
await fs.mkdir(dir, { recursive: true });
@ -113,12 +111,53 @@ async function writeJson(obj, file) {
return fs.writeFile(file, JSON.stringify(obj, null, 2));
}
function getBuildModifications(buildType) {
const buildModifications = {};
if (buildType === BuildType.beta) {
Object.assign(buildModifications, betaManifestModifications);
} else if (buildType === BuildType.flask) {
Object.assign(buildModifications, flaskManifestModifications);
/**
* Get manifest modifications for the given build type, including modifications specific to the
* given platform.
*
* @param {BuildType} buildType - The build type.
* @param {string} platform - The platform (i.e. the browser).
* @returns {Object} The build modificantions for the given build type and platform.
*/
async function getBuildModifications(buildType, platform) {
if (!Object.values(BuildType).includes(buildType)) {
throw new Error(`Invalid build type: ${buildType}`);
} else if (buildType === BuildType.main) {
return {};
}
const builtTypeManifestDirectoryPath = path.resolve(
__dirname,
'..',
'..',
'app',
'build-types',
buildType,
'manifest',
);
const baseBuildTypeModificationsPath = path.join(
builtTypeManifestDirectoryPath,
'_base.json',
);
const buildModifications = await readJson(baseBuildTypeModificationsPath);
const platformBuildTypeModificationsPath = path.join(
builtTypeManifestDirectoryPath,
`${platform}.json`,
);
try {
const platformBuildTypeModifications = await readJson(
platformBuildTypeModificationsPath,
);
Object.assign(buildModifications, platformBuildTypeModifications);
} catch (error) {
// Suppress 'ENOENT' error because it indicates there are no platform-specific manifest
// modifications for this build type.
if (error.code !== 'ENOENT') {
throw error;
}
}
return buildModifications;
}

@ -23,13 +23,13 @@ module.exports = function createStaticAssetTasks({
const additionalBuildTargets = {
[BuildType.beta]: [
{
src: './app/build-types/beta/',
src: './app/build-types/beta/images/',
dest: `images`,
},
],
[BuildType.flask]: [
{
src: './app/build-types/flask/',
src: './app/build-types/flask/images/',
dest: `images`,
},
],

@ -1,8 +1,8 @@
///: BEGIN:ONLY_INCLUDE_IN(beta)
import betaJson from '../../../app/build-types/beta/beta-mascot.json';
import betaJson from '../../../app/build-types/beta/images/beta-mascot.json';
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(flask)
import flaskJson from '../../../app/build-types/flask/flask-mascot.json';
import flaskJson from '../../../app/build-types/flask/images/flask-mascot.json';
///: END:ONLY_INCLUDE_IN
const assetList = {

Loading…
Cancel
Save