mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
3de3765425
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075. Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`. By way of example, this build system feature allows us to add fences like this: ```javascript this.store.updateStructure({ ..., GasFeeController: this.gasFeeController, TokenListController: this.tokenListController, ///: BEGIN:ONLY_INCLUDE_IN(beta) PluginController: this.pluginController, ///: END:ONLY_INCLUDE_IN }); ``` Which at build time are transformed to the following if the build type is not `beta`: ```javascript this.store.updateStructure({ ..., GasFeeController: this.gasFeeController, TokenListController: this.tokenListController, }); ``` Co-authored-by: Mark Stacey <markjstacey@gmail.com>
33 lines
789 B
JavaScript
33 lines
789 B
JavaScript
/**
|
|
* @returns {Object} An object with browser as key and next version of beta
|
|
* as the value. E.g. { firefox: '9.6.0.beta0', chrome: '9.6.0.1' }
|
|
*/
|
|
function getNextBetaVersionMap(currentVersion, betaVersion, platforms) {
|
|
const [major, minor] = currentVersion.split('.');
|
|
|
|
return platforms.reduce((platformMap, platform) => {
|
|
platformMap[platform] = [
|
|
// Keeps the current major
|
|
major,
|
|
// Bump the minor version
|
|
Number(minor) + 1,
|
|
// This isn't typically used
|
|
0,
|
|
// The beta number
|
|
`${platform === 'firefox' ? 'beta' : ''}${betaVersion}`,
|
|
].join('.');
|
|
return platformMap;
|
|
}, {});
|
|
}
|
|
|
|
const BuildTypes = {
|
|
beta: 'beta',
|
|
flask: 'flask',
|
|
main: 'main',
|
|
};
|
|
|
|
module.exports = {
|
|
BuildTypes,
|
|
getNextBetaVersionMap,
|
|
};
|