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

electron-winstaller

Package Overview
Dependencies
Maintainers
6
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-winstaller - npm Package Compare versions

Comparing version 2.7.0 to 3.0.0

lib/temp-utils.js

422

lib/index.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,227 +6,315 @@ Object.defineProperty(exports, "__esModule", {

});
exports.createWindowsInstaller = undefined;
exports.convertVersion = convertVersion;
exports.createWindowsInstaller = createWindowsInstaller;
var _bluebird = require('bluebird');
var _lodash = _interopRequireDefault(require("lodash.template"));
let createWindowsInstaller = exports.createWindowsInstaller = (() => {
var _ref = (0, _bluebird.coroutine)(function* (options) {
let useMono = false;
var _spawnPromise = _interopRequireDefault(require("./spawn-promise"));
const monoExe = 'mono';
const wineExe = 'wine';
var _asar = _interopRequireDefault(require("asar"));
if (process.platform !== 'win32') {
useMono = true;
if (!wineExe || !monoExe) {
throw new Error('You must install both Mono and Wine on non-Windows');
}
var _path = _interopRequireDefault(require("path"));
log(`Using Mono: '${monoExe}'`);
log(`Using Wine: '${wineExe}'`);
}
var _tempUtils = require("./temp-utils");
let appDirectory = options.appDirectory,
outputDirectory = options.outputDirectory,
loadingGif = options.loadingGif;
var _fsExtra = _interopRequireDefault(require("fs-extra"));
outputDirectory = _path2.default.resolve(outputDirectory || 'installer');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const vendorPath = _path2.default.join(__dirname, '..', 'vendor');
const vendorUpdate = _path2.default.join(vendorPath, 'Update.exe');
const appUpdate = _path2.default.join(appDirectory, 'Update.exe');
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
yield fsUtils.copy(vendorUpdate, appUpdate);
if (options.setupIcon && options.skipUpdateIcon !== true) {
let cmd = _path2.default.join(vendorPath, 'rcedit.exe');
let args = [appUpdate, '--set-icon', options.setupIcon];
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
if (useMono) {
args.unshift(cmd);
cmd = wineExe;
}
var log = require('debug')('electron-windows-installer:main');
yield (0, _spawnPromise2.default)(cmd, args);
}
function convertVersion(version) {
var parts = version.split('-');
var mainVersion = parts.shift();
const defaultLoadingGif = _path2.default.join(__dirname, '..', 'resources', 'install-spinner.gif');
loadingGif = loadingGif ? _path2.default.resolve(loadingGif) : defaultLoadingGif;
if (parts.length > 0) {
return [mainVersion, parts.join('-').replace(/\./g, '')].join('-');
} else {
return mainVersion;
}
}
let certificateFile = options.certificateFile,
certificatePassword = options.certificatePassword,
remoteReleases = options.remoteReleases,
signWithParams = options.signWithParams,
remoteToken = options.remoteToken;
function createWindowsInstaller(_x) {
return _createWindowsInstaller.apply(this, arguments);
}
function _createWindowsInstaller() {
_createWindowsInstaller = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(options) {
var useMono, monoExe, wineExe, appDirectory, outputDirectory, loadingGif, vendorPath, vendorUpdate, appUpdate, _cmd, _args, defaultLoadingGif, certificateFile, certificatePassword, remoteReleases, signWithParams, remoteToken, metadata, appResources, asarFile, appMetadata, templateData, nuspecContent, nugetOutput, targetNuspecPath, cmd, args, nupkgPath, setupPath, unfixedSetupPath, msiPath, unfixedMsiPath;
const metadata = {
description: '',
iconUrl: 'https://raw.githubusercontent.com/atom/electron/master/atom/browser/resources/win/atom.ico'
};
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
useMono = false;
monoExe = 'mono';
wineExe = 'wine';
if (options.usePackageJson !== false) {
const appResources = _path2.default.join(appDirectory, 'resources');
const asarFile = _path2.default.join(appResources, 'app.asar');
let appMetadata;
if (!(process.platform !== 'win32')) {
_context.next = 9;
break;
}
if (yield fsUtils.fileExists(asarFile)) {
appMetadata = JSON.parse(_asar2.default.extractFile(asarFile, 'package.json'));
} else {
appMetadata = JSON.parse((yield fsUtils.readFile(_path2.default.join(appResources, 'app', 'package.json'), 'utf8')));
}
useMono = true;
Object.assign(metadata, {
exe: `${appMetadata.name}.exe`,
title: appMetadata.productName || appMetadata.name
}, appMetadata);
}
if (!(!wineExe || !monoExe)) {
_context.next = 7;
break;
}
Object.assign(metadata, options);
throw new Error('You must install both Mono and Wine on non-Windows');
if (!metadata.authors) {
if (typeof metadata.author === 'string') {
metadata.authors = metadata.author;
} else {
metadata.authors = (metadata.author || {}).name || '';
}
}
case 7:
log("Using Mono: '".concat(monoExe, "'"));
log("Using Wine: '".concat(wineExe, "'"));
metadata.owners = metadata.owners || metadata.authors;
metadata.version = convertVersion(metadata.version);
metadata.copyright = metadata.copyright || `Copyright © ${new Date().getFullYear()} ${metadata.authors || metadata.owners}`;
case 9:
appDirectory = options.appDirectory, outputDirectory = options.outputDirectory, loadingGif = options.loadingGif;
outputDirectory = _path.default.resolve(outputDirectory || 'installer');
vendorPath = _path.default.join(__dirname, '..', 'vendor');
vendorUpdate = _path.default.join(vendorPath, 'Squirrel.exe');
appUpdate = _path.default.join(appDirectory, 'Squirrel.exe');
_context.next = 16;
return _fsExtra.default.copy(vendorUpdate, appUpdate);
let templateData = yield fsUtils.readFile(_path2.default.join(__dirname, '..', 'template.nuspectemplate'), 'utf8');
if (_path2.default.sep === '/') {
templateData = templateData.replace(/\\/g, '/');
}
const nuspecContent = (0, _lodash2.default)(templateData)(metadata);
case 16:
if (!(options.setupIcon && options.skipUpdateIcon !== true)) {
_context.next = 22;
break;
}
log(`Created NuSpec file:\n${nuspecContent}`);
_cmd = _path.default.join(vendorPath, 'rcedit.exe');
_args = [appUpdate, '--set-icon', options.setupIcon];
const nugetOutput = yield fsUtils.createTempDir('si-');
const targetNuspecPath = _path2.default.join(nugetOutput, metadata.name + '.nuspec');
if (useMono) {
_args.unshift(_cmd);
yield fsUtils.writeFile(targetNuspecPath, nuspecContent);
_cmd = wineExe;
}
let cmd = _path2.default.join(vendorPath, 'nuget.exe');
let args = ['pack', targetNuspecPath, '-BasePath', appDirectory, '-OutputDirectory', nugetOutput, '-NoDefaultExcludes'];
_context.next = 22;
return (0, _spawnPromise.default)(_cmd, _args);
if (useMono) {
args.unshift(cmd);
cmd = monoExe;
}
case 22:
defaultLoadingGif = _path.default.join(__dirname, '..', 'resources', 'install-spinner.gif');
loadingGif = loadingGif ? _path.default.resolve(loadingGif) : defaultLoadingGif;
certificateFile = options.certificateFile, certificatePassword = options.certificatePassword, remoteReleases = options.remoteReleases, signWithParams = options.signWithParams, remoteToken = options.remoteToken;
metadata = {
description: '',
iconUrl: 'https://raw.githubusercontent.com/atom/electron/master/atom/browser/resources/win/atom.ico'
};
// Call NuGet to create our package
log((yield (0, _spawnPromise2.default)(cmd, args)));
const nupkgPath = _path2.default.join(nugetOutput, `${metadata.name}.${metadata.version}.nupkg`);
if (!(options.usePackageJson !== false)) {
_context.next = 39;
break;
}
if (remoteReleases) {
cmd = _path2.default.join(vendorPath, 'SyncReleases.exe');
args = ['-u', remoteReleases, '-r', outputDirectory];
appResources = _path.default.join(appDirectory, 'resources');
asarFile = _path.default.join(appResources, 'app.asar');
_context.next = 31;
return _fsExtra.default.pathExists(asarFile);
if (useMono) {
args.unshift(cmd);
cmd = monoExe;
}
case 31:
if (!_context.sent) {
_context.next = 35;
break;
}
if (remoteToken) {
args.push('-t', remoteToken);
}
appMetadata = JSON.parse(_asar.default.extractFile(asarFile, 'package.json'));
_context.next = 38;
break;
log((yield (0, _spawnPromise2.default)(cmd, args)));
}
case 35:
_context.next = 37;
return _fsExtra.default.readJSON(_path.default.join(appResources, 'app', 'package.json'), 'utf8');
cmd = _path2.default.join(vendorPath, 'Update.com');
args = ['--releasify', nupkgPath, '--releaseDir', outputDirectory, '--loadingGif', loadingGif];
case 37:
appMetadata = _context.sent;
if (useMono) {
args.unshift(_path2.default.join(vendorPath, 'Update-Mono.exe'));
cmd = monoExe;
}
case 38:
Object.assign(metadata, {
exe: "".concat(appMetadata.name, ".exe"),
title: appMetadata.productName || appMetadata.name
}, appMetadata);
if (signWithParams) {
args.push('--signWithParams');
args.push(signWithParams);
} else if (certificateFile && certificatePassword) {
args.push('--signWithParams');
args.push(`/a /f "${_path2.default.resolve(certificateFile)}" /p "${certificatePassword}"`);
}
case 39:
Object.assign(metadata, options);
if (options.setupIcon) {
args.push('--setupIcon');
args.push(_path2.default.resolve(options.setupIcon));
}
if (!metadata.authors) {
if (typeof metadata.author === 'string') {
metadata.authors = metadata.author;
} else {
metadata.authors = (metadata.author || {}).name || '';
}
}
if (options.noMsi) {
args.push('--no-msi');
}
metadata.owners = metadata.owners || metadata.authors;
metadata.version = convertVersion(metadata.version);
metadata.copyright = metadata.copyright || "Copyright \xA9 ".concat(new Date().getFullYear(), " ").concat(metadata.authors || metadata.owners);
_context.next = 46;
return _fsExtra.default.readFile(_path.default.join(__dirname, '..', 'template.nuspectemplate'), 'utf8');
if (options.noDelta) {
args.push('--no-delta');
}
case 46:
templateData = _context.sent;
log((yield (0, _spawnPromise2.default)(cmd, args)));
if (_path.default.sep === '/') {
templateData = templateData.replace(/\\/g, '/');
}
if (options.fixUpPaths !== false) {
log('Fixing up paths');
nuspecContent = (0, _lodash.default)(templateData)(metadata);
log("Created NuSpec file:\n".concat(nuspecContent));
_context.next = 52;
return (0, _tempUtils.createTempDir)('si-');
if (metadata.productName || options.setupExe) {
const setupPath = _path2.default.join(outputDirectory, options.setupExe || `${metadata.productName}Setup.exe`);
const unfixedSetupPath = _path2.default.join(outputDirectory, 'Setup.exe');
log(`Renaming ${unfixedSetupPath} => ${setupPath}`);
yield fsUtils.rename(unfixedSetupPath, setupPath);
}
case 52:
nugetOutput = _context.sent;
targetNuspecPath = _path.default.join(nugetOutput, metadata.name + '.nuspec');
_context.next = 56;
return _fsExtra.default.writeFile(targetNuspecPath, nuspecContent);
if (metadata.productName || options.setupMsi) {
const msiPath = _path2.default.join(outputDirectory, options.setupMsi || `${metadata.productName}Setup.msi`);
const unfixedMsiPath = _path2.default.join(outputDirectory, 'Setup.msi');
if (yield fsUtils.fileExists(unfixedMsiPath)) {
log(`Renaming ${unfixedMsiPath} => ${msiPath}`);
yield fsUtils.rename(unfixedMsiPath, msiPath);
}
}
}
});
case 56:
cmd = _path.default.join(vendorPath, 'nuget.exe');
args = ['pack', targetNuspecPath, '-BasePath', appDirectory, '-OutputDirectory', nugetOutput, '-NoDefaultExcludes'];
return function createWindowsInstaller(_x) {
return _ref.apply(this, arguments);
};
})();
if (useMono) {
args.unshift(cmd);
cmd = monoExe;
} // Call NuGet to create our package
exports.convertVersion = convertVersion;
var _lodash = require('lodash.template');
_context.t0 = log;
_context.next = 62;
return (0, _spawnPromise.default)(cmd, args);
var _lodash2 = _interopRequireDefault(_lodash);
case 62:
_context.t1 = _context.sent;
(0, _context.t0)(_context.t1);
nupkgPath = _path.default.join(nugetOutput, "".concat(metadata.name, ".").concat(metadata.version, ".nupkg"));
var _spawnPromise = require('./spawn-promise');
if (!remoteReleases) {
_context.next = 75;
break;
}
var _spawnPromise2 = _interopRequireDefault(_spawnPromise);
cmd = _path.default.join(vendorPath, 'SyncReleases.exe');
args = ['-u', remoteReleases, '-r', outputDirectory];
var _asar = require('asar');
if (useMono) {
args.unshift(cmd);
cmd = monoExe;
}
var _asar2 = _interopRequireDefault(_asar);
if (remoteToken) {
args.push('-t', remoteToken);
}
var _path = require('path');
_context.t2 = log;
_context.next = 73;
return (0, _spawnPromise.default)(cmd, args);
var _path2 = _interopRequireDefault(_path);
case 73:
_context.t3 = _context.sent;
(0, _context.t2)(_context.t3);
var _fsUtils = require('./fs-utils');
case 75:
cmd = _path.default.join(vendorPath, 'Squirrel.exe');
args = ['--releasify', nupkgPath, '--releaseDir', outputDirectory, '--loadingGif', loadingGif];
var fsUtils = _interopRequireWildcard(_fsUtils);
if (useMono) {
args.unshift(_path.default.join(vendorPath, 'Squirrel-Mono.exe'));
cmd = monoExe;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
if (signWithParams) {
args.push('--signWithParams');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
if (!signWithParams.includes('/f') && !signWithParams.includes('/p') && certificateFile && certificatePassword) {
args.push("".concat(signWithParams, " /a /f \"").concat(_path.default.resolve(certificateFile), "\" /p \"").concat(certificatePassword, "\""));
} else {
args.push(signWithParams);
}
} else if (certificateFile && certificatePassword) {
args.push('--signWithParams');
args.push("/a /f \"".concat(_path.default.resolve(certificateFile), "\" /p \"").concat(certificatePassword, "\""));
}
const log = require('debug')('electron-windows-installer:main');
if (options.setupIcon) {
args.push('--setupIcon');
args.push(_path.default.resolve(options.setupIcon));
}
function convertVersion(version) {
const parts = version.split('-');
const mainVersion = parts.shift();
if (options.noMsi) {
args.push('--no-msi');
}
if (parts.length > 0) {
return [mainVersion, parts.join('-').replace(/\./g, '')].join('-');
} else {
return mainVersion;
}
if (options.noDelta) {
args.push('--no-delta');
}
if (options.frameworkVersion) {
args.push('--framework-version');
args.push(options.frameworkVersion);
}
_context.t4 = log;
_context.next = 86;
return (0, _spawnPromise.default)(cmd, args);
case 86:
_context.t5 = _context.sent;
(0, _context.t4)(_context.t5);
if (!(options.fixUpPaths !== false)) {
_context.next = 105;
break;
}
log('Fixing up paths');
if (!(metadata.productName || options.setupExe)) {
_context.next = 96;
break;
}
setupPath = _path.default.join(outputDirectory, options.setupExe || "".concat(metadata.productName, "Setup.exe"));
unfixedSetupPath = _path.default.join(outputDirectory, 'Setup.exe');
log("Renaming ".concat(unfixedSetupPath, " => ").concat(setupPath));
_context.next = 96;
return _fsExtra.default.rename(unfixedSetupPath, setupPath);
case 96:
if (!(metadata.productName || options.setupMsi)) {
_context.next = 105;
break;
}
msiPath = _path.default.join(outputDirectory, options.setupMsi || "".concat(metadata.productName, "Setup.msi"));
unfixedMsiPath = _path.default.join(outputDirectory, 'Setup.msi');
_context.next = 101;
return _fsExtra.default.pathExists(unfixedMsiPath);
case 101:
if (!_context.sent) {
_context.next = 105;
break;
}
log("Renaming ".concat(unfixedMsiPath, " => ").concat(msiPath));
_context.next = 105;
return _fsExtra.default.rename(unfixedMsiPath, msiPath);
case 105:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _createWindowsInstaller.apply(this, arguments);
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -8,9 +8,5 @@ Object.defineProperty(exports, "__esModule", {

var _child_process = require('child_process');
var _child_process = require("child_process");
var _bluebird = require('bluebird');
const d = require('debug')('electron-windows-installer:spawn');
// Public: Maps a process's output into an {Observable}
var d = require('debug')('electron-windows-installer:spawn'); // Public: Maps a process's output into an {Observable}
//

@@ -23,9 +19,10 @@ // exe - The program to execute

// spawned process
function spawn(exe, params) {
let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
return new Promise(function (resolve, reject) {
var proc = null;
d("Spawning ".concat(exe, " ").concat(params.join(' ')));
return new _bluebird.Promise((resolve, reject) => {
let proc = null;
d(`Spawning ${exe} ${params.join(' ')}`);
if (!opts) {

@@ -35,17 +32,19 @@ proc = (0, _child_process.spawn)(exe, params);

proc = (0, _child_process.spawn)(exe, params, opts);
}
// We need to wait until all three events have happened:
} // We need to wait until all three events have happened:
// * stdout's pipe is closed
// * stderr's pipe is closed
// * We've got an exit code
let rejected = false;
let refCount = 3;
let release = () => {
var rejected = false;
var refCount = 3;
var release = function release() {
if (--refCount <= 0 && !rejected) resolve(stdout);
};
let stdout = '';
let bufHandler = b => {
let chunk = b.toString();
var stdout = '';
var bufHandler = function bufHandler(b) {
var chunk = b.toString();
stdout += chunk;

@@ -58,5 +57,6 @@ };

proc.stderr.once('close', release);
proc.on('error', e => reject(e));
proc.on('close', code => {
proc.on('error', function (e) {
return reject(e);
});
proc.on('close', function (code) {
if (code === 0) {

@@ -66,3 +66,3 @@ release();

rejected = true;
reject(new Error(`Failed with exit code: ${code}\nOutput:\n${stdout}`));
reject(new Error("Failed with exit code: ".concat(code, "\nOutput:\n").concat(stdout)));
}

@@ -69,0 +69,0 @@ });

{
"name": "electron-winstaller",
"version": "2.7.0",
"version": "3.0.0",
"description": "Module to generate Windows installers for Electron apps",

@@ -14,3 +14,3 @@ "main": "./lib/index.js",

"prepublish": "npm run compile",
"lint": "eslint src & eslint spec",
"lint": "eslint src spec",
"test": "npm run lint && ava",

@@ -20,36 +20,29 @@ "tdd": "ava --watch"

"dependencies": {
"asar": "^0.11.0",
"bluebird": "^3.3.4",
"debug": "^2.2.0",
"fs-extra": "^2.1.2",
"asar": "^1.0.0",
"debug": "^4.1.1",
"fs-extra": "^7.0.1",
"lodash.template": "^4.2.2",
"temp": "^0.8.3"
"pify": "^4.0.1",
"temp": "^0.9.0"
},
"devDependencies": {
"ava": "^0.13.0",
"babel-cli": "^6.6.5",
"babel-eslint": "^6.0.2",
"babel-plugin-transform-async-to-module-method": "^6.7.0",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015-node4": "^2.0.3",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.7.2",
"eslint": "^2.4.0"
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.3",
"@babel/plugin-transform-async-to-generator": "^7.2.0",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.3.1",
"@babel/register": "^7.0.0",
"ava": "^1.2.1",
"babel-eslint": "^10.0.1",
"eslint": "^5.14.1"
},
"engines": {
"node": ">=0.4.0"
"node": ">=6.0.0"
},
"babel": {
"presets": [
"stage-0",
"es2015-node4"
"@babel/preset-env"
],
"plugins": [
[
"transform-async-to-module-method",
{
"module": "bluebird",
"method": "coroutine"
}
]
"@babel/plugin-transform-async-to-generator"
]

@@ -63,6 +56,6 @@ },

"require": [
"babel-register"
],
"babel": "inherit"
"@babel/register",
"@babel/polyfill"
]
}
}

@@ -67,2 +67,3 @@ # Electron Installer

| `remoteToken` | No | Authentication token for remote updates |
| `frameworkVersion` | No | Set the required .NET framework version, e.g. `net461` |

@@ -69,0 +70,0 @@ ## Sign your installer or else bad things will happen

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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