generate separate zip for FF with options_ui
This commit is contained in:
parent
8302c50d54
commit
2d21bb1dd6
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -1,8 +1,8 @@
|
|||
.DS_Store
|
||||
pull_locales_login.rb
|
||||
.vscode
|
||||
node_modules/
|
||||
yarn.lock
|
||||
*.zip
|
||||
.DS_Store
|
||||
.eslintcache
|
||||
.transifexrc
|
||||
.vscode
|
||||
desktop.ini
|
||||
node_modules/
|
||||
yarn.lock
|
||||
|
|
49
tools/zip.js
49
tools/zip.js
|
@ -4,10 +4,14 @@
|
|||
const fs = require('fs');
|
||||
const archiver = require('archiver');
|
||||
|
||||
function createZip() {
|
||||
const fileName = 'stylus.zip';
|
||||
function createZip(suffix) {
|
||||
const MANIFEST = 'manifest.json';
|
||||
const fileName = `stylus-${suffix}.zip`;
|
||||
const ignore = [
|
||||
MANIFEST,
|
||||
'.*', // dot files/folders (glob, not regexp)
|
||||
'BUILD.md',
|
||||
'node_modules', // may be a symlink in old node.js
|
||||
'node_modules/**',
|
||||
'tools/**',
|
||||
'package.json',
|
||||
|
@ -16,35 +20,34 @@ function createZip() {
|
|||
'*.zip',
|
||||
'*.map',
|
||||
];
|
||||
|
||||
try {
|
||||
ignore.push(...fs.readFileSync('.gitignore', 'utf8').split(/\r?\n/));
|
||||
} catch (e) {}
|
||||
const mj = JSON.parse(fs.readFileSync(MANIFEST, 'utf8'));
|
||||
if (suffix === 'chrome') {
|
||||
delete mj.applications;
|
||||
} else {
|
||||
delete mj.key;
|
||||
mj.options_ui = {
|
||||
/*
|
||||
* Linking to dashboard, not to options, because this is aimed at users who removed the icon
|
||||
* from the toolbar (they rarely use Stylus) so they visit about:addons instead.
|
||||
*/
|
||||
page: 'manage.html',
|
||||
open_in_tab: true,
|
||||
};
|
||||
}
|
||||
const file = fs.createWriteStream(fileName);
|
||||
const archive = archiver('zip');
|
||||
return new Promise((resolve, reject) => {
|
||||
archive.on('finish', () => {
|
||||
resolve();
|
||||
});
|
||||
archive.on('warning', err => {
|
||||
if (err.code === 'ENOENT') {
|
||||
console.log('\x1b[33m%s\x1b[0m', 'Warning', err.message);
|
||||
} else {
|
||||
reject();
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
archive.on('error', err => {
|
||||
reject();
|
||||
throw err;
|
||||
});
|
||||
|
||||
archive.pipe(file);
|
||||
archive.glob('**', {ignore});
|
||||
archive.finalize();
|
||||
});
|
||||
archive.append(Buffer.from(JSON.stringify(mj, null, 2)), {name: MANIFEST});
|
||||
return archive.finalize();
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await createZip();
|
||||
await Promise.all(['chrome', 'firefox'].map(createZip));
|
||||
console.log('\x1b[32m%s\x1b[0m', 'Stylus zip complete');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
|
Loading…
Reference in New Issue
Block a user