generate separate zip for FF with options_ui

This commit is contained in:
tophf 2022-08-05 18:35:16 +03:00
parent 8302c50d54
commit 2d21bb1dd6
2 changed files with 33 additions and 30 deletions

10
.gitignore vendored
View File

@ -1,8 +1,8 @@
.DS_Store
pull_locales_login.rb
.vscode
node_modules/
yarn.lock
*.zip *.zip
.DS_Store
.eslintcache .eslintcache
.transifexrc .transifexrc
.vscode
desktop.ini
node_modules/
yarn.lock

View File

@ -4,10 +4,14 @@
const fs = require('fs'); const fs = require('fs');
const archiver = require('archiver'); const archiver = require('archiver');
function createZip() { function createZip(suffix) {
const fileName = 'stylus.zip'; const MANIFEST = 'manifest.json';
const fileName = `stylus-${suffix}.zip`;
const ignore = [ const ignore = [
MANIFEST,
'.*', // dot files/folders (glob, not regexp) '.*', // dot files/folders (glob, not regexp)
'BUILD.md',
'node_modules', // may be a symlink in old node.js
'node_modules/**', 'node_modules/**',
'tools/**', 'tools/**',
'package.json', 'package.json',
@ -16,35 +20,34 @@ function createZip() {
'*.zip', '*.zip',
'*.map', '*.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 file = fs.createWriteStream(fileName);
const archive = archiver('zip'); const archive = archiver('zip');
return new Promise((resolve, reject) => { archive.pipe(file);
archive.on('finish', () => { archive.glob('**', {ignore});
resolve(); archive.append(Buffer.from(JSON.stringify(mj, null, 2)), {name: MANIFEST});
}); return archive.finalize();
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();
});
} }
(async () => { (async () => {
try { try {
await createZip(); await Promise.all(['chrome', 'firefox'].map(createZip));
console.log('\x1b[32m%s\x1b[0m', 'Stylus zip complete'); console.log('\x1b[32m%s\x1b[0m', 'Stylus zip complete');
} catch (err) { } catch (err) {
console.error(err); console.error(err);