Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-release

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-release - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

gulpfile.js

37

cli.js
#!/usr/bin/env node
'use strict'
const Publish = require('./index')
const meow = require('meow')
const cli = meow({
help: [
'Usage',
' $ electron-release',
'Options',
' --app [Required] The path to the .app to compress and upload.',
' --token [Required] Github token to be able to publish the relase.',
' --tag The git tag connected to the release, needs to be semver. Defaults to version in package.json',
' --repo The github repo in the following format: "username/reponame". Defaults to repository.url in package.json',
' --name The name of the relase. Defaults to --tag',
' --output The .zip output folder. Defaults to same folder as .app'
]
})
var publish = new Publish(cli.flags)
'use strict';
var Publish = require('./index');
var meow = require('meow');
var cli = meow({
help: ['Usage', ' $ electron-release', 'Options', ' --app [Required] The path to the .app to compress and upload.', ' --token [Required] Github token to be able to publish the relase.', ' --tag The git tag connected to the release, needs to be semver. Defaults to version in package.json', ' --repo The github repo in the following format: "username/reponame". Defaults to repository.url in package.json', ' --name The name of the relase. Defaults to --tag', ' --output The .zip output folder. Defaults to same folder as .app']
});
publish.compress()
.then(function () {
return publish.release()
})
.then(function () {
return publish.updateUrl()
})
var publish = new Publish(cli.flags);
publish.compress().then(function () {
return publish.release();
}).then(function () {
return publish.updateUrl();
});

@@ -1,93 +0,116 @@

'use strict'
const exec = require('child_process').exec
const publishRelease = require('publish-release')
const got = require('got')
const Promise = require('bluebird')
const loadJsonFile = require('load-json-file')
const writeJsonFile = require('write-json-file')
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
class Publish {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
constructor (opts) {
this.opts = (opts) ? opts : {}
if (!opts.repo) opts.repo = this._getRepo()
if (!opts.tag) opts.tag = this._getTag()
if (!opts.name) opts.name = opts.tag
if (!opts.output) opts.output = opts.app + '.zip'
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var exec = require('child_process').exec;
var publishRelease = require('publish-release');
var got = require('got');
var Promise = require('bluebird');
var loadJsonFile = require('load-json-file');
var writeJsonFile = require('write-json-file');
var Publish = (function () {
function Publish(opts) {
_classCallCheck(this, Publish);
this.opts = opts ? opts : {};
if (!opts.repo) opts.repo = this._getRepo();
if (!opts.tag) opts.tag = this._getTag();
if (!opts.name) opts.name = opts.tag;
if (!opts.output) opts.output = opts.app + '.zip';
if (!opts.tag || !opts.repo || !opts.app || !opts.token) {
console.log('Missing required options.')
process.exit()
console.log('Missing required options.');
process.exit();
}
this._releaseUrl = null
this._releaseUrl = null;
}
// Zip compress .app
compress () {
let self = this
return new Promise(function (resolve, reject) {
let cmd = 'ditto -c -k --sequesterRsrc --keepParent ' + self.opts.app + ' ' + self.opts.output
exec(cmd, function (err) {
if (!err) {
resolve()
}
})
})
}
_createClass(Publish, [{
key: 'compress',
value: function compress() {
var self = this;
// Create new release with zip as asset.
release () {
let self = this
return new Promise(function (resolve, reject) {
var cmd = 'ditto -c -k --sequesterRsrc --keepParent ' + self.opts.app + ' ' + self.opts.output;
exec(cmd, function (err) {
if (!err) {
resolve();
}
});
});
}
return new Promise(function (resolve, reject) {
publishRelease({
token: self.opts.token,
owner: self.opts.repo.split('/')[0],
repo: self.opts.repo.split('/')[1],
tag: self.opts.tag,
name: self.opts.name,
assets: [self.opts.output]
}, function (err, release) {
if (!err) {
got(release.assets_url).then(function (res) {
var jsonBody = JSON.parse(res.body)
self._releaseUrl = jsonBody[0].browser_download_url
resolve()
})
}
})
})
}
// Create new release with zip as asset.
}, {
key: 'release',
value: function release() {
var self = this;
// Update auto_update.json file with latest url.
updateUrl () {
let self = this
return new Promise(function (resolve) {
loadJsonFile('./auto_updater.json').then(function (content) {
content.url = self._releaseUrl
writeJsonFile('./auto_updater.json', content).then(function () {
resolve()
})
})
})
}
return new Promise(function (resolve, reject) {
publishRelease({
token: self.opts.token,
owner: self.opts.repo.split('/')[0],
repo: self.opts.repo.split('/')[1],
tag: self.opts.tag,
name: self.opts.name,
assets: [self.opts.output]
}, function (err, release) {
if (!err) {
got(release.assets_url).then(function (res) {
var jsonBody = JSON.parse(res.body);
self._releaseUrl = jsonBody[0].browser_download_url;
resolve();
});
}
});
});
}
// Get repo from package.json
_getRepo () {
let pkg = loadJsonFile.sync('./package.json')
let url = pkg.repository.url.split('/')
return url[3] + '/' + url[4].replace(/\.[^/.]+$/, '')
}
// Update auto_update.json file with latest url.
}, {
key: 'updateUrl',
value: function updateUrl() {
var self = this;
return new Promise(function (resolve) {
loadJsonFile('./auto_updater.json').then(function (content) {
content.url = self._releaseUrl;
writeJsonFile('./auto_updater.json', content).then(function () {
resolve();
});
});
});
}
// Get tag (version) from package.json
_getTag () {
let pkg = loadJsonFile.sync('./package.json')
let version = pkg.version
return 'v' + version
}
// Get repo from package.json
}, {
key: '_getRepo',
value: function _getRepo() {
var pkg = loadJsonFile.sync('./package.json');
var url = pkg.repository.url.split('/');
return url[3] + '/' + url[4].replace(/\.[^/.]+$/, '');
}
}
// Get tag (version) from package.json
}, {
key: '_getTag',
value: function _getTag() {
var pkg = loadJsonFile.sync('./package.json');
var version = pkg.version;
return 'v' + version;
}
}]);
module.exports = Publish
return Publish;
})();
exports['default'] = Publish;
module.exports = exports['default'];
{
"name": "electron-release",
"version": "2.0.4",
"version": "2.0.5",
"description": "Publish a new release of your app to Github.",

@@ -23,2 +23,4 @@ "main": "index.js",

"devDependencies": {
"gulp": "^3.9.0",
"gulp-babel": "^5.2.1",
"standard": "^5.2.2"

@@ -25,0 +27,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc