aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json2
-rwxr-xr-xscript/package39
-rwxr-xr-xscript/package.sh21
3 files changed, 40 insertions, 22 deletions
diff --git a/package.json b/package.json
index b3b44b1..68b2e0c 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"scripts": {
"start": "webpack --mode development -w --debug --devtool inline-source-map",
"build": "NODE_ENV=production webpack --mode production --progress --display-error-details",
- "package": "npm run build && script/package.sh",
+ "package": "npm run build && script/package",
"lint": "eslint --ext .jsx,.js src",
"test": "karma start",
"test:e2e": "mocha --timeout 8000 e2e"
diff --git a/script/package b/script/package
new file mode 100755
index 0000000..07f8bdf
--- /dev/null
+++ b/script/package
@@ -0,0 +1,39 @@
+#!/usr/bin/env node
+
+const fs = require('fs');
+const path = require('path');
+const manifest = require('../manifest');
+const JSZip = require('jszip');
+
+const resources = () => {
+ return [
+ 'manifest.json',
+ 'resources/disabled_32x32.png',
+ 'resources/enabled_32x32.png',
+ manifest.options_ui.page,
+ 'build/settings.js',
+ ].concat(
+ Object.values(manifest.icons),
+ manifest.background.scripts,
+ manifest.content_scripts.map(cs => cs.js).reduce((a1, a2) => a1.concat(a2), []),
+ manifest.web_accessible_resources,
+ ).sort();
+};
+
+const output = `vim-vixen-${manifest.version}.zip`
+
+let basedir = path.join(__dirname, '..');
+let zip = new JSZip();
+
+for (let r of resources()) {
+ console.log(` adding: ${r}`)
+ let data = fs.readFileSync(path.join(basedir, r));
+ zip.file(r, data);
+}
+
+zip
+ .generateNodeStream({ type: 'nodebuffer', streamFiles: true })
+ .pipe(fs.createWriteStream(output))
+ .on('finish', function () {
+ console.log(`${output} created`);
+ });
diff --git a/script/package.sh b/script/package.sh
deleted file mode 100755
index f3da914..0000000
--- a/script/package.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-MANIFEST="manifest.json"
-
-version=$(jq -r '.version' $MANIFEST)
-
-icons=$(jq -r '.icons[]' $MANIFEST)
-toolbar_icons="resources/disabled_32x32.png resources/enabled_32x32.png"
-content_scripts=$(jq -r '.content_scripts[].js[]' $MANIFEST)
-background_scripts=$(jq -r '.background.scripts[]' $MANIFEST)
-web_accessible_resources=$(jq -r '.web_accessible_resources[]' $MANIFEST)
-options_ui=$(jq -r '.options_ui.page' $MANIFEST)
-options_scripts=""
-for html in $options_ui; do
- scripts=$(grep -Po "(?<=src=['\"])[^'\"]*" "$html")
- for js in $scripts; do
- options_scripts="$options_scripts $(dirname $html)/$js"
- done
-done
-
-zip ${version}.zip $MANIFEST $icons $toolbar_icons $content_scripts $background_scripts $web_accessible_resources $options_ui $options_scripts