pkg mas gulp task

This commit is contained in:
Kyle Spearrin 2019-09-27 20:59:10 -04:00
parent fc2761cfca
commit 5268b1be0b
1 changed files with 59 additions and 0 deletions

View File

@ -2,10 +2,13 @@ const gulp = require('gulp');
const googleWebFonts = require('gulp-google-webfonts');
const del = require('del');
const fs = require('fs');
const child = require('child_process');
const paths = {
cssDir: './src/css/',
node_modules: './node_modules/',
dist: './dist/',
resources: './resources/',
};
function clean() {
@ -34,9 +37,65 @@ function fixSweetAlert(cb) {
cb();
}
function pkgMas(cb) {
const appPath = paths.dist + 'mas/Bitwarden.app';
const pkgPath = paths.dist + 'mas/Bitwarden-mas.pkg';
const safariAppexPath = appPath + '/Contents/PlugIns/safari.appex';
const safariAppexFrameworkPath = safariAppexPath + '/Contents/Frameworks/';
const safariEntitlementsPath = paths.resources + 'safari.entitlements';
return del([paths.dist + 'Bitwarden*.pkg'])
.then(() => {
const libs = fs.readdirSync(safariAppexFrameworkPath).filter((p) => p.endsWith('.dylib'))
.map((p) => builtAppexFrameworkPath + p);
const allItems = libs.concat([safariAppexPath]);
const promises = [];
allItems.forEach((i) => {
const proc = child.spawn('codesign', [
'--verbose',
'--force',
'-o',
'runtime',
'--sign',
'3rd Party Mac Developer Application: 8bit Solutions LLC',
'--entitlements',
safariEntitlementsPath,
i]);
stdOutProc(proc);
promises.push(new Promise((resolve) => proc.on('close', resolve)));
});
return Promise.all(promises);
}).then(() => {
const libs = fs.readdirSync(safariAppexFrameworkPath).filter((p) => p.endsWith('.dylib'))
.map((p) => builtAppexFrameworkPath + p);
const allItems = libs.concat([safariAppexPath]);
const promises = [];
allItems.forEach((i) => {
const proc = child.spawn('productbuild', [
'--component',
appPath,
'/Applications',
pkgPath]);
stdOutProc(proc);
promises.push(new Promise((resolve) => proc.on('close', resolve)));
});
return Promise.all(promises);
}).then(() => {
return cb;
}, () => {
return cb;
});
}
function stdOutProc(proc) {
proc.stdout.on('data', (data) => console.log(data.toString()));
proc.stderr.on('data', (data) => console.error(data.toString()));
}
exports.clean = clean;
exports.cleanupAotIssue = cleanupAotIssue;
exports.webfonts = gulp.series(clean, webfonts);
exports['prebuild:renderer'] = gulp.parallel(webfonts, cleanupAotIssue);
exports.fixSweetAlert = fixSweetAlert;
exports.pkgMas = pkgMas;
exports.postinstall = fixSweetAlert;