gulp.task('crx', ['build-scripts'], function() { crx.load(path.join(__dirname, 'build')) .then(function() { return crx.pack().then(function(crxBuffer){ fs.writeFile(path.join(__dirname, packageInfo.name + ".crx"), crxBuffer) }) }); })
}).then(function() { //create Chrome Zip crx.load(path.join(__dirname, 'extensions', 'Chrome')) .then(function() { return crx.loadContents(); }) .then(function(archiveBuffer) { fs.writeFile(path.join(__dirname, 'extensions', 'Chrome.zip'), archiveBuffer); console.log('[Extension Pack]', 'Chrome Zip Written'); return crx.pack(archiveBuffer); }); });
function(cb) { try { crx = new ChromeExtension({privateKey: privateKey}); crx.load(tempDir) .then(function() { cb(null, crx); }) .catch(function(reason) { cb(reason); }); } catch (ex) { cb(ex); } },
exports.pack = function ({dir, key, out}) { const crx = new Crx({ privateKey: fs.readFileSync(key) }); return crx.load(path.resolve(dir)) .then(crx => crx.pack()) .then(crxBuffer => { fs.writeFileSync(out, crxBuffer); console.log(`crx: packed ${dir} --> ${out}`); }) .catch(e => { console.log(e); process.exit(1); }) };
gulp.task('build', ['copy', 'scss', 'webpack'], function (callback) { var crx = new ChromeExtension({ privateKey: fs.readFileSync("./src.pem") }); crx.load('./build').then(function(){ return crx.loadContents(); }).then(function(archiveBuffer){ fs.writeFile('./build/Github-Stars-Categorizer.zip', archiveBuffer); return crx.pack(archiveBuffer); }).then(function(crxBuffer){ fs.writeFile('./build/Github-Stars-Categorizer.crx', crxBuffer); }).then(callback); });
function generateCrx (pemKey) { var crx = new ChromeExtension({ codebase: `${app.crxRemoteHost}/${app.crxRemoteDirectory}/crx/${app.crxFileName}`, privateKey: pemKey }) console.log('[crx] generating files') return crx.load(join(process.cwd(), 'dist')) .then(function () { return crx.pack().then(function (crxBuffer) { var updateXML = crx.generateUpdateXML() mkdirp.sync(join(process.cwd(), 'bin/crx')) fs.writeFileSync(join(process.cwd(), 'bin/update.xml'), updateXML) fs.writeFileSync(join(process.cwd(), 'bin/crx/', app.crxFileName), crxBuffer) console.log(`[crx] written file: ${app.crxFileName}`) }) }) }
/* eslint import/no-unresolved: 0 */ const name = require('../build/manifest.json').name; const argv = require('minimist')(process.argv.slice(2)); const keyPath = argv.key || 'key.pem'; const existsKey = fs.existsSync(keyPath); const crx = new ChromeExtension({ appId: argv['app-id'], codebase: argv.codebase, privateKey: existsKey ? fs.readFileSync(keyPath) : null }); console.log("\ncrx:", crx); console.log("existsKey:", existsKey); console.log("argv:", argv); crx.load('build') .then(() => crx.loadContents()) .then(archiveBuffer => { fs.writeFile(`${name}.zip`, archiveBuffer); console.log("1", existsKey, argv.codebase) if (!argv.codebase || !existsKey) return; console.log("2") crx.pack(archiveBuffer).then(crxBuffer => { const updateXML = crx.generateUpdateXML(); fs.writeFile('update.xml', updateXML); fs.writeFile(`${name}.crx`, crxBuffer); }); });
var fs = require('fs'); var Extension = require('crx'); var path = require('path'); var crx = new Extension({ privateKey: fs.readFileSync(path.join(__dirname, 'extensions', 'key.pem')) }); var p3Release = path.join(__dirname, 'bin', 'release', 'plugCubed.extension.js'); //Writes plug³ release files to the extension folders. fs.createReadStream(p3Release).pipe(fs.createWriteStream(path.join(__dirname, 'extensions', 'Opera', 'plugCubed.js'))); fs.createReadStream(p3Release).pipe(fs.createWriteStream(path.join(__dirname, 'extensions', 'Chrome', 'plugCubed.js'))); fs.createReadStream(p3Release).pipe(fs.createWriteStream(path.join(__dirname, 'extensions', 'Firefox', 'data', 'plugCubed.js'))); //create Opera CRX crx.load(path.join(__dirname, 'extensions', 'Opera')) .then(function() { return crx.pack().then(function(crxBuffer) { fs.writeFile(path.join(__dirname, 'extensions', 'Opera.crx'), crxBuffer); console.log('[Extension Pack]', 'Opera CRX written'); }).then(function() { //create Chrome Zip crx.load(path.join(__dirname, 'extensions', 'Chrome')) .then(function() { return crx.loadContents(); }) .then(function(archiveBuffer) { fs.writeFile(path.join(__dirname, 'extensions', 'Chrome.zip'), archiveBuffer); console.log('[Extension Pack]', 'Chrome Zip Written'); return crx.pack(archiveBuffer); }); });