tools/sign.js

This commit is contained in:
ccd0 2016-04-10 03:42:30 -07:00
parent 39f4e05520
commit 1ad999e12e
2 changed files with 19 additions and 15 deletions

View File

@ -1,5 +1,4 @@
path = require 'path'
crx = require 'crx'
module.exports = (grunt) ->
grunt.util.linefeed = '\n'
@ -113,6 +112,8 @@ module.exports = (grunt) ->
""".split('\n').join('&&')
install:
command: 'node tools/install.js'
sign:
command: (channel='') -> "node tools/sign.js #{channel}"
'copy-builds':
command: '<%= builds.map(file => `node tools/cp.js testbuilds/${file} builds/${file}`).join("&&") %>'
markdown:
@ -215,21 +216,10 @@ module.exports = (grunt) ->
'shell:copy-zip'
]
grunt.registerTask 'sign-channel', 'Sign CRX package', (channel='') ->
done = @async()
pkg = grunt.config 'pkg'
privateKey = grunt.file.read "../#{pkg.meta.path}.keys/#{pkg.name}.pem"
archive = grunt.file.read "testbuilds/#{pkg.name}#{channel}.crx.zip", {encoding: null}
extension = new crx {privateKey, loaded: true}
extension.pack(archive).then((data) ->
grunt.file.write "testbuilds/#{pkg.name}#{channel}.crx", data
done()
).catch(done)
grunt.registerTask 'sign', [
'sign-channel'
'sign-channel:-beta'
'sign-channel:-noupdate'
'shell:sign'
'shell:sign:-beta'
'shell:sign:-noupdate'
]
grunt.registerTask 'build-userscript', [

14
tools/sign.js Normal file
View File

@ -0,0 +1,14 @@
fs = require('fs');
crx = require('crx');
var pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
var channel = process.argv[2] || '';
var privateKey = fs.readFileSync(`../${pkg.meta.path}.keys/${pkg.name}.pem`)
var archive = fs.readFileSync(`testbuilds/${pkg.name}${channel}.crx.zip`);
var extension = new crx({privateKey, loaded: true});
extension.pack(archive).then((data) =>
fs.writeFileSync(`testbuilds/${pkg.name}${channel}.crx`, data)
).catch(function(err) {
process.exit(1);
});