electron-installer-squirrel-windows = function (opts, done) { debug('generating squirrel-windows installer for', JSON.stringify(opts, null, 2)); var app = new Model(opts, function(err) { if (err) return done(err); series([ checkForExisting.bind(null, app), createTempDirectory.bind(null, app), createNugetPkg.bind(null, app), syncReleases.bind(null, app), createSetupExe.bind(null, app) ], done); }); }
n/a
model = function () { return parent.apply(this, arguments); }
n/a
model = function () { return parent.apply(this, arguments); }
n/a
function extend(protoProps) {
/*jshint validthis:true*/
var parent = this;
var child;
// The constructor function for the new subclass is either defined by you
// (the "constructor" property in your `extend` definition), or defaulted
// by us to simply call the parent's constructor.
if (protoProps && protoProps.hasOwnProperty('constructor')) {
child = protoProps.constructor;
} else {
child = function () {
return parent.apply(this, arguments);
};
}
// Add static properties to the constructor function from parent
assign(child, parent);
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
var Surrogate = function () { this.constructor = child; };
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate();
// set prototype level objects
child.prototype._derived = assign({}, parent.prototype._derived);
child.prototype._deps = assign({}, parent.prototype._deps);
child.prototype._definition = assign({}, parent.prototype._definition);
child.prototype._collections = assign({}, parent.prototype._collections);
child.prototype._children = assign({}, parent.prototype._children);
child.prototype._dataTypes = assign({}, parent.prototype._dataTypes || dataTypes);
// Mix in all prototype properties to the subclass if supplied.
if (protoProps) {
var omitFromExtend = [
'dataTypes', 'props', 'session', 'derived', 'collections', 'children'
];
for(var i = 0; i < arguments.length; i++) {
var def = arguments[i];
if (def.dataTypes) {
forOwn(def.dataTypes, function (def, name) {
child.prototype._dataTypes[name] = def;
});
}
if (def.props) {
forOwn(def.props, function (def, name) {
createPropertyDefinition(child.prototype, name, def);
});
}
if (def.session) {
forOwn(def.session, function (def, name) {
createPropertyDefinition(child.prototype, name, def, true);
});
}
if (def.derived) {
forOwn(def.derived, function (def, name) {
createDerivedProperty(child.prototype, name, def);
});
}
if (def.collections) {
forOwn(def.collections, function (constructor, name) {
child.prototype._collections[name] = constructor;
});
}
if (def.children) {
forOwn(def.children, function (constructor, name) {
child.prototype._children[name] = constructor;
});
}
assign(child.prototype, omit(def, omitFromExtend));
}
}
// Set a convenience property in case the parent's prototype is needed
// later.
child.__super__ = parent.prototype;
return child;
}
...
var titlecase = require('titlecase');
var defaults = require('./defaults');
var format = require('util').format;
var createSyncErrback = require('./create-sync-errback');
// @todo (imlucas): move this to `electron-installer-model`
var App = Model.extend({
props: {
name: 'string',
version: 'string',
description: 'string',
copyright: 'string',
// Path to the app.
path: 'string',
...
constructor = function () { return parent.apply(this, arguments); }
n/a
initialize = function (opts, fn) { if (typeof opts === 'string') { opts = { path: opts }; } if (!fn) return; if (!opts.path) { process.nextTick(function() { fn(new TypeError('Missing required `path` param.')); }); return; } if (!opts.out) { opts.out = path.resolve(opts.path, '..'); } this.on('sync', function(model) { debug('loaded model', JSON.stringify(model.toJSON(), null, 2)); fn(null, model); }); this.on('error', function(model, err) { debug('error fetching model', err); fn(err); }); debug('fetching app model'); this.fetch(opts); }
n/a
loadPackageJson = function (done) { if (!this.asar) { return this.loadPackageJsonFromResources(done); } fs.exists(this.asar, function(exists) { if (exists) { done(null, JSON.parse(asar.extractFile(this.asar, 'package.json'))); } else { this.loadPackageJsonFromResources(done); } }.bind(this)); }
...
var done = createSyncErrback(method, model, options);
var overrides = clone(options);
delete overrides.parse;
delete overrides.path;
debug('sync called w/ overrides', JSON.stringify(overrides, null, 2));
this.loadPackageJson(function(err, data) {
if (err) {
debug('error loading package json', err);
return done(err);
}
var res = assign(data, overrides);
done(null, res);
});
...
loadPackageJsonFromResources = function (done) { var src = path.join(this.resources, 'app', 'package.json'); fs.readFile(src, function(err, buf) { if (err) return done(err); done(null, JSON.parse(buf)); }); }
...
if (err) return done(err);
done(null, JSON.parse(buf));
});
},
loadPackageJson: function(done) {
if (!this.asar) {
return this.loadPackageJsonFromResources(done);
}
fs.exists(this.asar, function(exists) {
if (exists) {
done(null, JSON.parse(asar.extractFile(this.asar, 'package.json')));
} else {
this.loadPackageJsonFromResources(done);
}
...
parse = function (resp) { resp.name_original = resp.name; resp.name = titlecase(resp.name.replace(/-/g, ' ')).replace(/ /, ''); resp.product_name = resp.product_name || resp.productName || resp.name; resp.icon_url = resp.icon_url || resp.iconUrl; if (!resp.authors) { resp.authors = resp.author ? resp.author.name : ''; } if (!resp.exe) { resp.exe = format('%s.exe', resp.name); } resp.loading_gif = resp.loading_gif || resp.loadingGif; if (!resp.loading_gif) { resp.loading_gif = defaults.LOADING_GIF; } if (!resp.owners) { resp.owners = resp.authors; } if (!resp.title) { resp.title = resp.product_name; } resp.icon_url = resp.icon_url || resp.iconUrl; if (!resp.icon_url) { resp.icon_url = defaults.ICON_URL; } if (!resp.copyright) { resp.copyright = format('%s %s', new Date().getFullYear(), resp.owners); } if (!resp.setup_filename) { resp.setup_filename = format('%sSetup.exe', resp.name); } if (!resp.nuget_id) { resp.nuget_id = resp.name; } resp.version = resp.version.replace(/-.*$/, ''); return resp; }
...
fn(model, resp, options);
}
model.trigger('error', model, resp, options);
};
var success = options.success;
options.success = function(resp) {
if (!model.set(model.parse(resp, options), options)) return false;
if (success) {
success(model, resp, options);
}
};
return function(err, resp) {
if (err) {
options.error(err);
...
serialize = function () { var res = this.getAttributes({ props: true, derived: true }, true); each(this._children, function(value, key) { res[key] = this[key].serialize(); }, this); each(this._collections, function(value, key) { res[key] = this[key].serialize(); }, this); return res; }
...
},
serialize: function() {
var res = this.getAttributes({
props: true,
derived: true
}, true);
each(this._children, function(value, key) {
res[key] = this[key].serialize();
}, this);
each(this._collections, function(value, key) {
res[key] = this[key].serialize();
}, this);
return res;
}
});
...
sync = function (method, model, options) { this.path = options.path; this.out = options.out; var done = createSyncErrback(method, model, options); var overrides = clone(options); delete overrides.parse; delete overrides.path; debug('sync called w/ overrides', JSON.stringify(overrides, null, 2)); this.loadPackageJson(function(err, data) { if (err) { debug('error loading package json', err); return done(err); } var res = assign(data, overrides); done(null, res); }); }
n/a