From a43908e133f984c8fb9100984ffc1dd0b82fda4b Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 10 Apr 2016 02:42:32 -0700 Subject: [PATCH] tools/cp.js --- Gruntfile.coffee | 36 ++++++++++++++++-------------------- npm-shrinkwrap.json | 26 ++++++++++++++++++++++++++ package.json | 1 + tools/cp.js | 3 +++ 4 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 tools/cp.js diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 0ef508fd9..768f4bbb4 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -58,25 +58,16 @@ module.exports = (grunt) -> 'src/General/Main.coffee' ] + icons: ['icon128.png', 'icon16.png', 'icon48.png'] + + builds: + ("4chan-X#{c}.crx updates#{c}.xml 4chan-X#{c}.user.js 4chan-X#{c}.meta.js" for c in ['', '-beta']).join(' ').split(' ').concat [ + '4chan-X-noupdate.crx', '4chan-X-noupdate.user.js', '4chan-X.zip' + ] + copy: - crx: - src: ['src/meta/*.png', 'tmp/eventPage.js'] - dest: 'testbuilds/crx<%= pkg.channel %>/' - expand: true - flatten: true - zip: - src: 'testbuilds/<%= pkg.name %>-noupdate.crx.zip' - dest: 'testbuilds/<%= pkg.name %>.zip' - builds: - cwd: 'testbuilds/' - src: ['*.js', '*.crx', '*.xml', '<%= pkg.name %>.zip', '!*-noupdate.xml', '!*-noupdate.meta.js'] - dest: 'builds/' - expand: true install: files: if grunt.file.exists('install.json') then grunt.file.readJSON('install.json') else [] - web: - src: '../<%= pkg.meta.path %>/test.html' - dest: 'index.html' concurrent: build: [ @@ -106,7 +97,11 @@ module.exports = (grunt) -> <%= BIN %>coffee tools/templates.coffee src/meta/updates.xml testbuilds/updates<%= pkg.channel %>.xml type=crx channel=<%= pkg.channel %> <%= BIN %>coffee tools/templates.coffee src/meta/manifest.json testbuilds/crx<%= pkg.channel %>/manifest.json type=crx channel=<%= pkg.channel %> node tools/cat.js src/meta/botproc.js LICENSE src/meta/usestrict.js tmp/script-crx.js testbuilds/crx<%= pkg.channel %>/script.js + <%= icons.map(file => `node tools/cp.js src/meta/${file} testbuilds/crx${pkg.channel}/${file}`).join('&&') %> + node tools/cp.js tmp/eventPage.js testbuilds/crx<%= pkg.channel %>/eventPage.js """.split('\n').join('&&') + 'copy-zip': + command: 'node tools/cp.js testbuilds/<%= pkg.name %>-noupdate.crx.zip testbuilds/<%= pkg.name %>.zip' userscript: command: """ <%= BIN %>coffee tools/templates.coffee tmp/script.coffee tmp/script-userscript.coffee type=userscript tests_enabled=<%= pkg.tests_enabled || "" %> @@ -118,6 +113,8 @@ module.exports = (grunt) -> <%= BIN %>coffee tools/templates.coffee src/meta/metadata.js testbuilds/<%= pkg.name %><%= pkg.channel %>.meta.js type=userscript channel=<%= pkg.channel %> node tools/cat.js src/meta/botproc.js testbuilds/<%= pkg.name %><%= pkg.channel %>.meta.js LICENSE src/meta/usestrict.js tmp/script-userscript.js testbuilds/<%= pkg.name %><%= pkg.channel %>.user.js """.split('\n').join('&&') + 'copy-builds': + command: '<%= builds.map(file => `node tools/cp.js testbuilds/${file} builds/${file}`).join("&&") %>' markdown: command: 'node tools/markdown.js' commit: @@ -153,6 +150,7 @@ module.exports = (grunt) -> """.split('\n').join('&&') web: command: """ + node ../<%= pkg.meta.path %>/tools/cp.js ../<%= pkg.meta.path %>/test.html index.html git merge --no-commit -s ours master git checkout master README.md web.css img git commit -am "Update web page." @@ -216,7 +214,6 @@ module.exports = (grunt) -> grunt.registerTask 'build-crx-channel', [ 'shell:crx-channel' - 'copy:crx' 'zip-crx' ] @@ -228,7 +225,7 @@ module.exports = (grunt) -> 'build-crx-channel' 'set-channel:-noupdate' 'build-crx-channel' - 'copy:zip' + 'shell:copy-zip' ] grunt.registerTask 'zip-crx', 'Pack CRX contents in ZIP file', -> @@ -281,7 +278,7 @@ module.exports = (grunt) -> grunt.registerTask 'full', [ 'build' 'sign' - 'copy:builds' + 'shell:copy-builds' ] grunt.registerTask 'tag', 'Tag a new release', (version) -> @@ -330,7 +327,6 @@ module.exports = (grunt) -> grunt.registerTask 'web', [ 'shell:markdown' 'pushd' - 'copy:web' 'shell:web' 'popd' ] diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 185bb20f2..90147eaa0 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -197,6 +197,32 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.5.0.tgz" }, + "fs-extra": { + "version": "0.26.7", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", + "dependencies": { + "graceful-fs": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.3.tgz" + }, + "jsonfile": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.2.3.tgz" + }, + "klaw": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.1.3.tgz" + }, + "path-is-absolute": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" + }, + "rimraf": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.2.tgz" + } + } + }, "glob": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.3.tgz", diff --git a/package.json b/package.json index 50de38aa7..36d86d74c 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "coffee-script": "1.9.3", "crx": "^3.0.3", "font-awesome": "4.5.0", + "fs-extra": "^0.26.7", "glob": "^7.0.3", "grunt": "^1.0.1", "grunt-concurrent": "^2.3.0", diff --git a/tools/cp.js b/tools/cp.js new file mode 100644 index 000000000..fc751e2b8 --- /dev/null +++ b/tools/cp.js @@ -0,0 +1,3 @@ +var fs = require('fs-extra'); + +fs.copySync(process.argv[2], process.argv[3]);