diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-04-27 13:33:20 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-27 13:33:20 +0900 |
commit | 8b8f9fb1e6987044071f5ca8117fa360881e5b83 (patch) | |
tree | ffe604817b6a9195863433df42316e95a1931401 | |
parent | b67129de6ad450ea128b18748edf40cdbfc858fc (diff) | |
parent | 5dd5bbbd3c3f1cda588242714d66d0f454199bf7 (diff) |
Merge pull request #572 from ueokande/jszip
Use JSZIP
-rw-r--r-- | package-lock.json | 88 | ||||
-rw-r--r-- | package.json | 3 | ||||
-rwxr-xr-x | script/package | 39 | ||||
-rwxr-xr-x | script/package.sh | 21 |
4 files changed, 65 insertions, 86 deletions
diff --git a/package-lock.json b/package-lock.json index 53eb21d..7d9d7ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -930,7 +930,7 @@ }, "babel-plugin-syntax-jsx": { "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz", + "resolved": "http://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz", "integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=", "dev": true }, @@ -3969,8 +3969,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3991,14 +3990,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4013,20 +4010,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -4143,8 +4137,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -4156,7 +4149,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4171,7 +4163,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4179,14 +4170,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4205,7 +4194,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4286,8 +4274,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -4299,7 +4286,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4385,8 +4371,7 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -4422,7 +4407,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4442,7 +4426,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4486,14 +4469,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -4640,7 +4621,6 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, - "optional": true, "requires": { "is-glob": "^2.0.0" } @@ -5482,8 +5462,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true, - "optional": true + "dev": true }, "is-finite": { "version": "1.0.2", @@ -5505,7 +5484,6 @@ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, - "optional": true, "requires": { "is-extglob": "^1.0.0" } @@ -6854,11 +6832,11 @@ } }, "lanthan": { - "version": "git+https://github.com/ueokande/lanthan.git#a6795eb90006b11e65d436becda339258c00643c", + "version": "git+https://github.com/ueokande/lanthan.git#fb7f641846369de5bac7762f19186d23248f0d53", "from": "git+https://github.com/ueokande/lanthan.git#master", "dev": true, "requires": { - "commander": "^2.19.0", + "commander": "^2.20.0", "express": "^4.16.4", "jszip": "^3.2.1", "request": "^2.88.0", @@ -8207,7 +8185,6 @@ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, - "optional": true, "requires": { "remove-trailing-separator": "^1.0.1" } @@ -11739,8 +11716,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -11768,7 +11744,6 @@ "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -11783,8 +11758,7 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", @@ -11795,8 +11769,7 @@ "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -11913,8 +11886,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -11926,7 +11898,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -11941,7 +11912,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -11949,14 +11919,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -11975,7 +11943,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -12056,8 +12023,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -12069,7 +12035,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -12155,8 +12120,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -12192,7 +12156,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -12212,7 +12175,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -12256,14 +12218,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/package.json b/package.json index bbceb2f..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" @@ -30,6 +30,7 @@ "eslint": "^5.15.1", "eslint-plugin-react": "^7.12.4", "html-webpack-plugin": "^3.2.0", + "jszip": "^3.2.1", "karma": "^4.0.1", "karma-firefox-launcher": "^1.1.0", "karma-html2js-preprocessor": "^1.1.0", 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 |