2018-08-08 18:47:54 +02:00
|
|
|
const gulp = require('gulp');
|
|
|
|
const googleWebFonts = require('gulp-google-webfonts');
|
|
|
|
const del = require('del');
|
2019-02-13 16:06:58 +01:00
|
|
|
const fs = require('fs');
|
2019-09-28 02:59:10 +02:00
|
|
|
const child = require('child_process');
|
2018-08-08 18:47:54 +02:00
|
|
|
|
|
|
|
const paths = {
|
|
|
|
cssDir: './src/css/',
|
2019-02-13 16:06:58 +01:00
|
|
|
node_modules: './node_modules/',
|
2019-09-28 02:59:10 +02:00
|
|
|
dist: './dist/',
|
|
|
|
resources: './resources/',
|
2018-08-08 18:47:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function clean() {
|
|
|
|
return del([paths.cssDir]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function webfonts() {
|
|
|
|
return gulp.src('./webfonts.list')
|
|
|
|
.pipe(googleWebFonts({
|
|
|
|
fontsDir: 'webfonts',
|
|
|
|
cssFilename: 'webfonts.css',
|
|
|
|
format: 'woff',
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest(paths.cssDir));
|
2018-09-12 19:12:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ref: https://github.com/angular/angular/issues/22524
|
|
|
|
function cleanupAotIssue() {
|
|
|
|
return del(['./node_modules/@types/uglify-js/node_modules/source-map/source-map.d.ts']);
|
|
|
|
}
|
2018-08-08 18:47:54 +02:00
|
|
|
|
2019-02-13 16:06:58 +01:00
|
|
|
// ref: https://github.com/t4t5/sweetalert/issues/890
|
|
|
|
function fixSweetAlert(cb) {
|
|
|
|
fs.writeFileSync(paths.node_modules + 'sweetalert/typings/sweetalert.d.ts',
|
|
|
|
'import swal, { SweetAlert } from "./core";export default swal;export as namespace swal;');
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
|
2019-09-28 02:59:10 +02:00
|
|
|
function pkgMas(cb) {
|
|
|
|
const appPath = paths.dist + 'mas/Bitwarden.app';
|
|
|
|
const pkgPath = paths.dist + 'mas/Bitwarden-mas.pkg';
|
2019-09-28 05:18:45 +02:00
|
|
|
const pkgSignedPath = paths.dist + 'mas/Bitwarden-mas-signed.pkg';
|
2019-09-28 02:59:10 +02:00
|
|
|
|
2019-09-28 03:18:57 +02:00
|
|
|
return del([paths.dist + 'mas/Bitwarden*.pkg'])
|
2019-09-28 02:59:10 +02:00
|
|
|
.then(() => {
|
2019-09-30 21:41:16 +02:00
|
|
|
return signMas(cb);
|
2019-09-28 02:59:10 +02:00
|
|
|
}).then(() => {
|
2019-09-28 03:18:57 +02:00
|
|
|
const proc = child.spawn('productbuild', [
|
|
|
|
'--component',
|
|
|
|
appPath,
|
|
|
|
'/Applications',
|
|
|
|
pkgPath]);
|
|
|
|
stdOutProc(proc);
|
|
|
|
return new Promise((resolve) => proc.on('close', resolve));
|
2019-09-28 05:18:45 +02:00
|
|
|
}).then(() => {
|
|
|
|
const proc = child.spawn('productsign', [
|
|
|
|
'--sign',
|
|
|
|
'3rd Party Mac Developer Installer: 8bit Solutions LLC',
|
|
|
|
pkgPath,
|
|
|
|
pkgSignedPath]);
|
|
|
|
stdOutProc(proc);
|
|
|
|
return new Promise((resolve) => proc.on('close', resolve));
|
2019-09-28 02:59:10 +02:00
|
|
|
}).then(() => {
|
|
|
|
return cb;
|
|
|
|
}, () => {
|
|
|
|
return cb;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-09-30 21:41:16 +02:00
|
|
|
function signMas(cb) {
|
|
|
|
return signSafariExt(cb, 'mas');
|
|
|
|
}
|
2019-09-30 15:29:12 +02:00
|
|
|
|
|
|
|
function signMac(cb) {
|
|
|
|
return signSafariExt(cb, 'mac');
|
|
|
|
}
|
|
|
|
|
|
|
|
function signSafariExt(cb, dir) {
|
|
|
|
const appPath = paths.dist + dir + '/Bitwarden.app';
|
|
|
|
const safariAppexPath = appPath + '/Contents/PlugIns/safari.appex';
|
|
|
|
const safariAppexFrameworkPath = safariAppexPath + '/Contents/Frameworks/';
|
|
|
|
const safariEntitlementsPath = paths.resources + 'safari.entitlements';
|
|
|
|
|
|
|
|
const libs = fs.readdirSync(safariAppexFrameworkPath).filter((p) => p.endsWith('.dylib'))
|
|
|
|
.map((p) => safariAppexFrameworkPath + p);
|
2019-09-30 21:41:16 +02:00
|
|
|
const libPromises = [];
|
|
|
|
var args = dir === 'mas' ?
|
|
|
|
[
|
|
|
|
'--verbose',
|
|
|
|
'--force',
|
|
|
|
'--sign',
|
|
|
|
'3rd Party Mac Developer Application: 8bit Solutions LLC',
|
|
|
|
'--entitlements',
|
|
|
|
safariEntitlementsPath
|
|
|
|
] :
|
|
|
|
[
|
|
|
|
'--verbose',
|
|
|
|
'--force',
|
|
|
|
'-o',
|
|
|
|
'runtime',
|
|
|
|
'--sign',
|
|
|
|
'Developer ID Application: 8bit Solutions LLC',
|
|
|
|
'--entitlements',
|
|
|
|
safariEntitlementsPath
|
|
|
|
];
|
|
|
|
libs.forEach((i) => {
|
|
|
|
const proc = child.spawn('codesign', args.concat([i]));
|
2019-09-30 15:29:12 +02:00
|
|
|
stdOutProc(proc);
|
2019-09-30 21:41:16 +02:00
|
|
|
libPromises.push(new Promise((resolve) => proc.on('close', resolve)));
|
|
|
|
libPromises.push(new Promise((resolve) => setTimeout(() => resolve(), 10000)));
|
2019-09-30 15:29:12 +02:00
|
|
|
});
|
2019-09-30 21:41:16 +02:00
|
|
|
return Promise.all(libPromises).then(() => {
|
|
|
|
const proc = child.spawn('codesign', args.concat([safariAppexPath]));
|
|
|
|
stdOutProc(proc);
|
|
|
|
return new Promise((resolve) => proc.on('close', resolve));
|
|
|
|
}).then(() => {
|
2019-09-30 15:29:12 +02:00
|
|
|
return cb;
|
|
|
|
}, () => {
|
|
|
|
return cb;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-09-28 02:59:10 +02:00
|
|
|
function stdOutProc(proc) {
|
|
|
|
proc.stdout.on('data', (data) => console.log(data.toString()));
|
|
|
|
proc.stderr.on('data', (data) => console.error(data.toString()));
|
|
|
|
}
|
|
|
|
|
2018-11-27 18:22:18 +01:00
|
|
|
exports.clean = clean;
|
|
|
|
exports.cleanupAotIssue = cleanupAotIssue;
|
|
|
|
exports.webfonts = gulp.series(clean, webfonts);
|
2019-02-13 16:06:58 +01:00
|
|
|
exports['prebuild:renderer'] = gulp.parallel(webfonts, cleanupAotIssue);
|
|
|
|
exports.fixSweetAlert = fixSweetAlert;
|
2019-09-28 02:59:10 +02:00
|
|
|
exports.pkgMas = pkgMas;
|
2019-09-30 21:41:16 +02:00
|
|
|
exports.signMas = signMas;
|
2019-09-30 15:29:12 +02:00
|
|
|
exports.signMac = signMac;
|
2019-02-13 16:06:58 +01:00
|
|
|
exports.postinstall = fixSweetAlert;
|