1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00
metamask-extension/development/build/etc.js
Mark Stacey 345ed9f6f2
Add build type to Sentry environment (#12441)
The build type (i.e. the distribution) is now included in the Sentry
environment during setup, for all builds except the "main" build. This
will allow us to track Flask and beta errors separately from other
errors.

A constant was created for the build types. The equivalent constant in
our build scripts was updated to match it more closely, for
consistency. We can't use the same constant in both places because our
shared constants are in modules that use ES6 exports, and our build
script does not yet support ES6 exports.

The singular `BuildType` was used rather than `BuildTypes` to match our
naming conventions elsewhere for enums. We name them like classes or
types, rather than like a collection.

Relates to #11896
2021-10-25 14:27:30 -02:30

51 lines
1.4 KiB
JavaScript

const { promises: fs } = require('fs');
const gulp = require('gulp');
const gulpZip = require('gulp-zip');
const del = require('del');
const pify = require('pify');
const pump = pify(require('pump'));
const { version } = require('../../package.json');
const { createTask, composeParallel } = require('./task');
const { BuildType } = require('./utils');
module.exports = createEtcTasks;
function createEtcTasks({ browserPlatforms, buildType, livereload }) {
const clean = createTask('clean', async function clean() {
await del(['./dist/*']);
await Promise.all(
browserPlatforms.map(async (platform) => {
await fs.mkdir(`./dist/${platform}`, { recursive: true });
}),
);
});
const reload = createTask('reload', function devReload() {
livereload.listen({ port: 35729 });
});
// zip tasks for distribution
const zip = createTask(
'zip',
composeParallel(
...browserPlatforms.map((platform) => createZipTask(platform, buildType)),
),
);
return { clean, reload, zip };
}
function createZipTask(platform, buildType) {
return async () => {
const path =
buildType === BuildType.main
? `metamask-${platform}-${version}`
: `metamask-${buildType}-${platform}-${version}`;
await pump(
gulp.src(`dist/${platform}/**`),
gulpZip(`${path}.zip`),
gulp.dest('builds'),
);
};
}