172 lines
16 KiB
JavaScript
172 lines
16 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
|
|
require("source-map-support/register");
|
|
|
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
|
|
var _path = _interopRequireDefault(require("path"));
|
|
|
|
var _which = _interopRequireDefault(require("which"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
class Maker {
|
|
constructor(configFetcher = {}, providedPlatforms) {
|
|
this.configFetcher = configFetcher;
|
|
this.providedPlatforms = providedPlatforms;
|
|
|
|
_defineProperty(this, "config", void 0);
|
|
|
|
_defineProperty(this, "name", void 0);
|
|
|
|
_defineProperty(this, "defaultPlatforms", void 0);
|
|
|
|
_defineProperty(this, "requiredExternalBinaries", []);
|
|
|
|
_defineProperty(this, "__isElectronForgeMaker", void 0);
|
|
|
|
Object.defineProperty(this, '__isElectronForgeMaker', {
|
|
value: true,
|
|
enumerable: false,
|
|
configurable: false
|
|
});
|
|
}
|
|
|
|
get platforms() {
|
|
if (this.providedPlatforms) return this.providedPlatforms;
|
|
return this.defaultPlatforms;
|
|
} // TODO: Remove this, it is an eye-sore and is a nasty hack to provide forge
|
|
// v5 style functionality in the new API
|
|
|
|
|
|
prepareConfig(targetArch) {
|
|
if (typeof this.configFetcher === 'function') {
|
|
this.config = this.configFetcher(targetArch);
|
|
} else {
|
|
this.config = this.configFetcher;
|
|
}
|
|
}
|
|
/**
|
|
* Makers must implement this method and return true or false indicating whether
|
|
* this maker can be run on the current platform. Normally this is just a process.platform
|
|
* check but it can be a deeper check for dependencies like fake-root or other
|
|
* required external build tools.
|
|
*
|
|
* If the issue is a missing dependency you should log out a HELPFUL error message
|
|
* telling the developer exactly what is missing and if possible how to get it.
|
|
*/
|
|
|
|
|
|
isSupportedOnCurrentPlatform() {
|
|
if (this.isSupportedOnCurrentPlatform === Maker.prototype.isSupportedOnCurrentPlatform) {
|
|
throw new Error(`Maker ${this.name} did not implement the isSupportedOnCurrentPlatform method`);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
/**
|
|
* Makers must implement this method and return an array of absolute paths
|
|
* to the artifacts generated by your maker
|
|
*/
|
|
|
|
|
|
async make(opts) {
|
|
// eslint-disable-line max-len, @typescript-eslint/no-unused-vars
|
|
if (this.make === Maker.prototype.make) {
|
|
throw new Error(`Maker ${this.name} did not implement the make method`);
|
|
}
|
|
|
|
return [];
|
|
}
|
|
/**
|
|
* Helpers
|
|
*/
|
|
|
|
/**
|
|
* Ensures the directory exists and is forced to be empty.
|
|
*
|
|
* I.e. If the directory already exists it is deleted and recreated, this
|
|
* is a destructive operation
|
|
*/
|
|
|
|
|
|
async ensureDirectory(dir) {
|
|
if (await _fsExtra.default.pathExists(dir)) {
|
|
await _fsExtra.default.remove(dir);
|
|
}
|
|
|
|
return _fsExtra.default.mkdirs(dir);
|
|
}
|
|
/**
|
|
* Ensures the path to the file exists and the file does not exist
|
|
*
|
|
* I.e. If the file already exists it is deleted and the path created
|
|
*/
|
|
|
|
|
|
async ensureFile(file) {
|
|
if (await _fsExtra.default.pathExists(file)) {
|
|
await _fsExtra.default.remove(file);
|
|
}
|
|
|
|
await _fsExtra.default.mkdirs(_path.default.dirname(file));
|
|
}
|
|
/**
|
|
* Checks if the specified binaries exist, which are required for the maker to be used.
|
|
*/
|
|
|
|
|
|
externalBinariesExist() {
|
|
return this.requiredExternalBinaries.every(binary => _which.default.sync(binary, {
|
|
nothrow: true
|
|
}) !== null);
|
|
}
|
|
/**
|
|
* Throws an error if any of the binaries don't exist.
|
|
*/
|
|
|
|
|
|
ensureExternalBinariesExist() {
|
|
if (!this.externalBinariesExist()) {
|
|
throw new Error(`Cannot make for ${this.name}, the following external binaries need to be installed: ${this.requiredExternalBinaries.join(', ')}`);
|
|
}
|
|
}
|
|
/**
|
|
* Checks if the given module is installed, used for testing if optional dependencies
|
|
* are installed or not
|
|
*/
|
|
|
|
|
|
isInstalled(module) {
|
|
try {
|
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
require(module);
|
|
|
|
return true;
|
|
} catch (e) {
|
|
// Package doesn't exist -- must not be installable on this platform
|
|
return false;
|
|
}
|
|
}
|
|
/**
|
|
* Normalize the given semver-formatted version to a 4-part dot delimited version number without
|
|
* prerelease information for use in Windows apps.
|
|
*/
|
|
|
|
|
|
normalizeWindowsVersion(version) {
|
|
const noPrerelease = version.replace(/-.*/, '');
|
|
return `${noPrerelease}.0`;
|
|
}
|
|
|
|
}
|
|
|
|
exports.default = Maker;
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9NYWtlci50cyJdLCJuYW1lcyI6WyJNYWtlciIsImNvbnN0cnVjdG9yIiwiY29uZmlnRmV0Y2hlciIsInByb3ZpZGVkUGxhdGZvcm1zIiwiT2JqZWN0IiwiZGVmaW5lUHJvcGVydHkiLCJ2YWx1ZSIsImVudW1lcmFibGUiLCJjb25maWd1cmFibGUiLCJwbGF0Zm9ybXMiLCJkZWZhdWx0UGxhdGZvcm1zIiwicHJlcGFyZUNvbmZpZyIsInRhcmdldEFyY2giLCJjb25maWciLCJpc1N1cHBvcnRlZE9uQ3VycmVudFBsYXRmb3JtIiwicHJvdG90eXBlIiwiRXJyb3IiLCJuYW1lIiwibWFrZSIsIm9wdHMiLCJlbnN1cmVEaXJlY3RvcnkiLCJkaXIiLCJmcyIsInBhdGhFeGlzdHMiLCJyZW1vdmUiLCJta2RpcnMiLCJlbnN1cmVGaWxlIiwiZmlsZSIsInBhdGgiLCJkaXJuYW1lIiwiZXh0ZXJuYWxCaW5hcmllc0V4aXN0IiwicmVxdWlyZWRFeHRlcm5hbEJpbmFyaWVzIiwiZXZlc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