Skip to content

Instantly share code, notes, and snippets.

@sondreb
Created January 31, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sondreb/3b30ab3edb8132cb625db8c0bb88cc3a to your computer and use it in GitHub Desktop.
Save sondreb/3b30ab3edb8132cb625db8c0bb88cc3a to your computer and use it in GitHub Desktop.
SFX gulp.js
"use strict";
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License file under the project root for license information.
//-----------------------------------------------------------------------------
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
/// <reference path="./@types/collections.d.ts" />
/// <reference path="./@types/versioninfo.d.ts" />
var gulp = require("gulp");
var gutil = require("gulp-util");
var typescript = require("gulp-typescript");
var gulp_tslint_1 = require("gulp-tslint");
var fs = require("fs");
var util = require("util");
var path = require("path");
var pify = require("pify");
var runSequence = require("run-sequence");
var child_process = require("child_process");
var packager = require("electron-packager");
var semver = require("semver");
var pified_exec = pify(child_process.exec, { multiArgs: true });
String.format = function (format) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (!util.isString(format)) {
throw new Error("format must be a string");
}
if (!util.isArray(args)) {
throw new Error("args must be an array.");
}
if (util.isNullOrUndefined(args)) {
return format;
}
var matchIndex = -1;
return format.replace(/(\{*)(\{(\d*)\})/gi, function (substring, escapeChar, argIdentifier, argIndexStr, offset, str) {
matchIndex++;
if (escapeChar.length > 0) {
return argIdentifier;
}
var argIndex = argIndexStr.length === 0 ? matchIndex : parseInt(argIndexStr);
if (isNaN(argIndex) || argIndex < 0 || argIndex >= args.length) {
throw new Error(String.format("Referenced arg index, '{}',is out of range of the args.", argIndexStr));
}
return args[argIndex];
});
};
var Architecture;
(function (Architecture) {
Architecture["X86"] = "x86";
Architecture["X64"] = "x64";
})(Architecture || (Architecture = {}));
var Platform;
(function (Platform) {
Platform["Windows"] = "windows";
Platform["Linux"] = "linux";
Platform["MacOs"] = "macos";
})(Platform || (Platform = {}));
var License = /** @class */ (function () {
function License(spdxId) {
if (util.isNullOrUndefined(spdxId) || spdxId.trim() === "") {
throw Error("spdxId should not be null/undefined/empty.");
}
this.spdxId = spdxId;
}
return License;
}());
var FileLicense = /** @class */ (function (_super) {
__extends(FileLicense, _super);
function FileLicense(spdxId, licensePath) {
var _this = _super.call(this, spdxId) || this;
if (util.isNullOrUndefined(licensePath) || !fs.existsSync(licensePath)) {
throw Error("licensePath should not be null/undefined and the pointing file should exist.");
}
_this.licensePath = licensePath;
return _this;
}
FileLicense.prototype.getLicenseText = function () {
return fs.readFileSync(this.licensePath, { encoding: "utf8" });
};
return FileLicense;
}(License));
var ReadmeLicense = /** @class */ (function (_super) {
__extends(ReadmeLicense, _super);
function ReadmeLicense() {
return _super !== null && _super.apply(this, arguments) || this;
}
ReadmeLicense.prototype.getLicenseText = function () {
var readmeText = _super.prototype.getLicenseText.call(this);
var licenseIdentifier = "## License";
var licenseIndex = readmeText.indexOf(licenseIdentifier);
if (licenseIndex < 0) {
return null;
}
else {
licenseIndex += licenseIdentifier.length;
}
var licenseEndIndex = readmeText.indexOf("#", licenseIndex);
var nonCharRegex = /\w/g;
for (var index = licenseIndex; index < readmeText.length; index++) {
if (nonCharRegex.test(readmeText[index])) {
licenseIndex = index;
break;
}
}
return readmeText.substring(licenseIndex, licenseEndIndex < 0 ? undefined : licenseEndIndex);
};
return ReadmeLicense;
}(FileLicense));
var packagejson = require("./package.json");
var buildInfos = require("./buildInfos.json");
// buildInfos auto-initializiation
gutil.log("Starting", "buildInfos auto-initializiation", "...");
if (buildInfos.buildNumber === "*") {
gutil.log("Read", "BUILD_BUILDNUMBER", "=", process.env["BUILD_BUILDNUMBER"]);
gutil.log("Read", "packagejson.version", "=", packagejson.version);
buildInfos.buildNumber = process.env["BUILD_BUILDNUMBER"] || packagejson.version;
gutil.log("Initialized", "buildInfos.buildNumber:", "=", buildInfos.buildNumber);
}
if (buildInfos.paths.appDir === "*") {
buildInfos.paths.appDir = path.join(buildInfos.paths.buildDir, "app");
gutil.log("Initialized", "buildInfos.paths.appDir", "=", buildInfos.paths.appDir);
}
if (buildInfos.paths.sfxDir === "*") {
buildInfos.paths.sfxDir = path.join(buildInfos.paths.appDir, "sfx");
gutil.log("Initialized", "buildInfos.paths.sfxDir", "=", buildInfos.paths.sfxDir);
}
gutil.log("Finished", "buildInfos auto-initializiation", ".");
/* Utility functions */
function logExec(cmd, pifyResults) {
var error = pifyResults[0], stdout = pifyResults[1], stderr = pifyResults[2];
gutil.log("Executed:", cmd);
if (util.isString(stdout) && stdout.trim() !== "") {
gutil.log(stdout);
}
if (util.isString(stderr) && stderr.trim() !== "") {
gutil.log(stderr);
}
}
function exec(cmd) {
return pified_exec(cmd, { cwd: path.resolve(buildInfos.paths.appDir) })
.then(function (pifyResults) { return logExec(cmd, pifyResults); });
}
function formGlobs(globs) {
var outputGlobs = [];
outputGlobs.push(String.format("!{}/**/*", buildInfos.paths.publishDir));
outputGlobs.push(String.format("!{}/**/*", buildInfos.paths.buildDir));
outputGlobs.push(String.format("!{}/**/*", "node_modules"));
outputGlobs.push("!**/tsconfig.json", "!**/jsconfig.json", "!**/tslint.json", "!./buildInfos.json");
outputGlobs.push("!**/*.md");
if (util.isString(globs)) {
outputGlobs.push(globs);
}
else if (util.isArray(globs)) {
globs.forEach(function (glob) { return outputGlobs.push(glob); });
}
else {
throw "Unsupported globs: " + typeof globs;
}
return outputGlobs;
}
function ensureDirExists(dirname) {
dirname = path.resolve(dirname);
var dirs = [];
while (!fs.existsSync(dirname)) {
dirs.push(dirname);
dirname = path.dirname(dirname);
}
while (dirs.length > 0) {
fs.mkdirSync(dirs.pop());
}
}
function generateVersionInfo(platform, getPackageInfo) {
if (!util.isFunction(getPackageInfo)) {
throw new Error("getPackageInfo must be supplied.");
}
if (!util.isObject(buildInfos.updateInfos) || !util.isString(buildInfos.updateInfos.baseUrl)) {
throw new Error("buildInfos.updateInfos.baseUrl must be specified.");
}
var channel = "public";
var prerelease = semver.prerelease(buildInfos.buildNumber);
if (util.isArray(prerelease) && prerelease.length > 0) {
channel = prerelease[0];
}
var versionInfo = {
version: buildInfos.buildNumber
};
var baseUrl = String.format("{}/{}/{}", buildInfos.updateInfos.baseUrl, channel, platform);
var buildPackageInfo = null;
if (util.isObject(buildInfos.updateInfos.packageInfos)) {
buildPackageInfo = buildInfos.updateInfos.packageInfos[platform];
}
else if (!util.isNullOrUndefined(buildInfos.updateInfos.packageInfos)) {
throw new Error("Invalid value for parameter: buildInfos.updateInfos.packageInfos");
}
if (util.isString(buildPackageInfo)) {
versionInfo[platform] = buildPackageInfo;
}
else if (util.isNullOrUndefined(buildPackageInfo) || util.isObject(buildPackageInfo)) {
versionInfo[platform] = {};
for (var _i = 0, _a = buildInfos.targets[platform].archs; _i < _a.length; _i++) {
var arch = _a[_i];
if (util.isNullOrUndefined(buildPackageInfo) || util.isNullOrUndefined(buildPackageInfo[arch])) {
versionInfo[platform][arch] = getPackageInfo(baseUrl, arch);
}
else if (util.isString(buildPackageInfo[arch])) {
versionInfo[platform][arch] = String.format(buildPackageInfo[arch], baseUrl, buildInfos.buildNumber, arch);
}
else {
throw new Error(String.format("Invalid value for parameter: buildInfos.updateInfos.packageInfos.{}.{}", platform, arch));
}
}
}
else {
throw new Error(String.format("Invalid value for parameter: buildInfos.updateInfos.packageInfos.{}", platform));
}
var versionInfoPath = path.resolve(path.join(buildInfos.paths.publishDir, String.format("version.{}.json", platform)));
ensureDirExists(path.dirname(versionInfoPath));
fs.writeFileSync(versionInfoPath, JSON.stringify(versionInfo, null, '\t'));
}
function convertToPackagerArch(arch) {
switch (arch) {
case Architecture.X86:
return "ia32";
case Architecture.X64:
return "x64";
default:
throw "unsupported architecture: " + arch;
}
;
}
function toPackagerArch(archs) {
if (!util.isArray(archs)) {
throw "archs has to be an array.";
}
var convertedArchs = [];
archs.forEach(function (arch) { return convertedArchs.push(convertToPackagerArch(arch)); });
return convertedArchs;
}
function toPackagerPlatform(platform) {
switch (platform) {
case Platform.Linux:
return "linux";
case Platform.Windows:
return "win32";
case Platform.MacOs:
return "darwin";
default:
throw "unsupported platform: " + platform;
}
;
}
function generatePackage(platform) {
var packConfig = {
dir: buildInfos.paths.appDir,
appCopyright: buildInfos.copyright,
arch: toPackagerArch(buildInfos.targets[platform].archs),
asar: false,
icon: path.join(buildInfos.paths.appDir, "icons/icon"),
name: platform === Platform.MacOs ? buildInfos.productName : buildInfos.targetExecutableName,
out: buildInfos.paths.buildDir,
overwrite: true,
platform: toPackagerPlatform(platform),
appBundleId: buildInfos.appId,
appCategoryType: buildInfos.appCategory
};
return packager(packConfig);
}
function getLicense(dep) {
if (util.isString(dep.license)) {
return dep.license;
}
var license = buildInfos.licensing.packageLicenses[dep.name];
if (!util.isString(license)) {
throw Error("Cannot determine the license of dep: " + dep.name);
}
return license;
}
function generateDep(depName, depsDir, packageJsonName) {
var licenseFileNamePattern = /.*LICENSE.*/gi;
var readmeFileNamePattern = /README.md/gi;
var depDir = path.resolve(path.join(depsDir, depName));
if (!fs.existsSync(depDir)) {
throw new Error(String.format('Cannot find dependency "{}".'));
}
var depJson = require(path.join(depDir, packageJsonName));
var depLicense = null;
var readmeFileName = null;
for (var _i = 0, _a = fs.readdirSync(depDir); _i < _a.length; _i++) {
var fileName = _a[_i];
if (licenseFileNamePattern.test(fileName)) {
depLicense = new FileLicense(getLicense(depJson), path.join(depDir, fileName));
break;
}
if (readmeFileNamePattern.test(fileName)) {
readmeFileName = fileName;
}
}
if (util.isNull(depLicense) && fs.existsSync(path.join(depDir, readmeFileName))) {
depLicense = new ReadmeLicense(getLicense(depJson), path.join(depDir, readmeFileName));
}
if (util.isNullOrUndefined(depLicense)) {
throw new Error(String.format('Cannot find license file for dependency, "{}".', depName));
}
return {
name: depJson.name,
version: depJson.version,
homepage: depJson.homepage,
license: depLicense
};
}
function generateLicensingDeps(depType, packageFormat, depsDir, deps) {
if (util.isNullOrUndefined(deps)) {
return [];
}
if (!fs.existsSync(depsDir)) {
throw new Error(String.format('depsDir "{}" does not exist.', depsDir));
}
var depNames;
if (util.isArray(deps)) {
depNames = deps;
}
else if (util.isObject(deps)) {
depNames = Object.keys(deps);
}
else {
throw new Error("unknow type of deps: " + typeof deps);
}
var licensingDeps = [];
var packageJsonName;
switch (packageFormat) {
case "bower":
packageJsonName = ".bower.json";
break;
case "npm":
default:
packageJsonName = "package.json";
break;
}
var hasErrors = false;
depNames.forEach(function (depName) {
try {
var dep = generateDep(depName, depsDir, packageJsonName);
dep.depType = depType;
licensingDeps.push(dep);
}
catch (error) {
gutil.log("Failed to generate licensing dep for package:", depName, "Error:", error);
hasErrors = true;
}
});
if (hasErrors) {
throw new Error("There are errors when resolving licensing dependencies.");
}
return licensingDeps;
}
function generateThirdPartyNotice(deps, noticeFilePath) {
if (!util.isArray(deps)) {
throw new Error("deps must be a valid array of ILicensingDependency.");
}
if (!util.isString(noticeFilePath)) {
throw new Error("noticeFilePath must be a valid string.");
}
noticeFilePath = path.resolve(noticeFilePath);
if (fs.existsSync(noticeFilePath)) {
fs.unlinkSync(noticeFilePath);
}
var noticeFd = fs.openSync(path.join(buildInfos.paths.appDir, buildInfos.licensing.thirdPartyNoticesFileName), "w");
try {
gutil.log("Generating third party notices files:", buildInfos.licensing.thirdPartyNoticesFileName, "...");
fs.appendFileSync(noticeFd, "THIRD-PARTY SOFTWARE NOTICES AND INFORMATION\r\n");
fs.appendFileSync(noticeFd, "Do Not Translate or Localize\r\n");
fs.appendFileSync(noticeFd, "\r\n");
fs.appendFileSync(noticeFd, "This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.\r\n");
fs.appendFileSync(noticeFd, "\r\n");
deps.forEach(function (dep, depIndex) {
fs.appendFileSync(noticeFd, String.format("{}.\t{} ({})\r\n", depIndex + 1, dep.name, dep.homepage));
});
for (var _i = 0, deps_1 = deps; _i < deps_1.length; _i++) {
var dep = deps_1[_i];
fs.appendFileSync(noticeFd, "\r\n");
fs.appendFileSync(noticeFd, String.format("{} NOTICES AND INFORMATION BEGIN HERE\r\n", dep.name));
fs.appendFileSync(noticeFd, "=========================================\r\n");
fs.appendFileSync(noticeFd, dep.license.getLicenseText() || String.format("{} License: {}", dep.license.spdxId, dep.homepage));
fs.appendFileSync(noticeFd, "\r\n");
fs.appendFileSync(noticeFd, "=========================================\r\n");
fs.appendFileSync(noticeFd, String.format("END OF {} NOTICES AND INFORMATION\r\n", dep.name));
}
}
finally {
fs.closeSync(noticeFd);
gutil.log("Finished generation of the third party notices files:", buildInfos.licensing.thirdPartyNoticesFileName, ".");
}
}
/* Build tasks */
gulp.task("Build:tslint", function () { return typescript.createProject("tsconfig.json")
.src()
.pipe(gulp_tslint_1["default"]({ formatter: "prose" }))
.pipe(gulp_tslint_1["default"].report({ summarizeFailureOutput: true })); });
gulp.task("Build:ts", ["Build:tslint"], function () {
var tsProject = typescript.createProject("tsconfig.json");
return tsProject.src()
.pipe(tsProject())
.js
.pipe(gulp.dest(buildInfos.paths.appDir));
});
gulp.task("Build:html", function () { return gulp.src(formGlobs("**/*.html"))
.pipe(gulp.dest(buildInfos.paths.appDir)); });
gulp.task("Build:img", function () { return gulp.src(formGlobs(["icons/**/*.*"]))
.pipe(gulp.dest(path.join(buildInfos.paths.appDir, "icons"))); });
gulp.task("Build:json", function () { return gulp.src(formGlobs(["**/*.json"]))
.pipe(gulp.dest(buildInfos.paths.appDir)); });
gulp.task("Build:node_modules", ["Build:json"], function () { return exec("npm install --production"); });
gulp.task("Build:sfx", function () { return gulp.src(["../Sfx/wwwroot/**/*.*"])
.pipe(gulp.dest(buildInfos.paths.sfxDir)); });
gulp.task("Build:licenses", function () { return gulp.src(formGlobs(["LICENSE"]))
.pipe(gulp.dest(buildInfos.paths.appDir)); });
gulp.task("Build:All", ["Build:sfx", "Build:ts", "Build:html", "Build:node_modules", "Build:json", "Build:img", "Build:licenses"]);
/* Pack tasks */
gulp.task("Pack:update-version", function () { return exec(String.format("npm version {} --allow-same-version", buildInfos.buildNumber)); });
gulp.task("Pack:licensing", function () {
var msInternalDeps = [];
var prodDeps = [];
prodDeps = prodDeps.concat(generateLicensingDeps("prod", "npm", path.join(buildInfos.paths.appDir, "node_modules"), packagejson.dependencies));
prodDeps = prodDeps.concat(generateLicensingDeps("prod", "npm", path.join(buildInfos.paths.appDir, "node_modules"), packagejson.optionalDependencies));
if (fs.existsSync("../Sfx/package.json")) {
var sfxPackageJson = require("../Sfx/package.json");
prodDeps = prodDeps.concat(generateLicensingDeps("prod", "npm", "../Sfx/node_modules", sfxPackageJson.dependencies));
prodDeps = prodDeps.concat(generateLicensingDeps("prod", "npm", "../Sfx/node_modules", sfxPackageJson.optionalDependencies));
}
if (fs.existsSync("../Sfx/bower_components")) {
prodDeps = prodDeps.concat(generateLicensingDeps("prod", "bower", "../Sfx/bower_components", fs.readdirSync("../Sfx/bower_components", { encoding: "utf8" })));
}
msInternalDeps = msInternalDeps.concat(generateLicensingDeps("dev", "npm", "./node_modules", packagejson.devDependencies));
generateThirdPartyNotice(prodDeps, path.join(buildInfos.paths.appDir, buildInfos.licensing.thirdPartyNoticesFileName));
});
gulp.task("Pack:prepare", function (callback) { return runSequence("Build:All", ["Pack:update-version", "Pack:licensing"], callback); });
gulp.task("Pack:windows", ["Pack:prepare"], function () { return generatePackage(Platform.Windows); });
gulp.task("Pack:linux", ["Pack:prepare"], function () { return generatePackage(Platform.Linux); });
gulp.task("Pack:darwin", ["Pack:prepare"], function () { return generatePackage(Platform.MacOs); });
/* Tasks for Windows */
gulp.task("Publish:versioninfo-windows", function () { return generateVersionInfo(Platform.Windows, function (baseUrl, arch) { return String.format("{}/setup-{}.{}.msi", baseUrl, buildInfos.buildNumber, arch); }); });
gulp.task("Publish:copy-msi.wxs", function () { return gulp.src(formGlobs(".build/msi.wxs")).pipe(gulp.dest(buildInfos.paths.buildDir)); });
gulp.task("Publish:update-wix-version", ["Publish:copy-msi.wxs"], function () { return fs.writeFileSync("./build/msi.wxs", fs.readFileSync("./build/msi.wxs", { encoding: "utf8" })
.replace("$MSIVERSION$", [semver.major(buildInfos.buildNumber), semver.minor(buildInfos.buildNumber), semver.patch(buildInfos.buildNumber)].join(".")), { encoding: "utf8" }); });
gulp.task("Publish:msi", ["Publish:update-wix-version"], function (gcallback) {
var packDirName = String.format("{}-{}-{}", buildInfos.targetExecutableName, toPackagerPlatform(Platform.Windows), convertToPackagerArch(Architecture.X86));
var packDirPath = path.resolve(path.join(buildInfos.paths.buildDir, packDirName));
var publishDir = path.join(buildInfos.paths.publishDir, Platform.Windows);
var filesWixPath = path.resolve(path.join(buildInfos.paths.buildDir, "files.msi.wxs"));
var wxsobjDir = path.resolve(path.join(buildInfos.paths.buildDir, "wxsobj"));
var heatPath = path.resolve("./.vendor/wix/heat.exe");
var candlePath = path.resolve("./.vendor/wix/candle.exe");
var lightPath = path.resolve("./.vendor/wix/light.exe");
var heatCmd = String.format("\"{}\" dir \"{}\" -ag -srd -cg MainComponentsGroup -dr INSTALLFOLDER -o \"{}\"", heatPath, packDirPath, filesWixPath);
var candleCmd = String.format("\"{}\" -arch x86 -out \"{}\\\\\" \"{}\" \"{}\"", candlePath, wxsobjDir, path.resolve("./build/msi.wxs"), filesWixPath);
var lightCmd = String.format("\"{}\" -b \"{}\" -spdb -out \"{}\" \"{}\" \"{}\"", lightPath, packDirPath, path.resolve(path.join(publishDir, buildInfos.buildNumber ? String.format("setup-{}.x86.msi", buildInfos.buildNumber) : "setup.x86.msi")), path.join(wxsobjDir, "msi.wixobj"), path.join(wxsobjDir, "files.msi.wixobj"));
return exec(heatCmd)
.then(function () { return exec(candleCmd)
.then(function () { return exec(lightCmd); }); });
});
gulp.task("Publish:win32", function (callback) { return runSequence("Pack:windows", ["Publish:versioninfo-windows", "Publish:msi"], callback); });
/* Tasks for Debian-based linux */
function toDebArch(arch) {
switch (arch) {
case Architecture.X86:
return "i386";
case Architecture.X64:
return "amd64";
default:
throw "unsupported architecture: " + arch;
}
;
}
function getDebOptions(arch) {
var packDirName = String.format("{}-{}-{}", buildInfos.targetExecutableName, toPackagerPlatform(Platform.Linux), convertToPackagerArch(arch));
var packDirPath = path.resolve(path.join(buildInfos.paths.buildDir, packDirName));
return {
src: packDirPath,
dest: path.join(buildInfos.paths.publishDir, Platform.Linux),
arch: toDebArch(arch),
name: buildInfos.targetExecutableName,
productName: buildInfos.productName,
genericName: buildInfos.productName,
version: buildInfos.buildNumber,
revision: "0",
section: "utils",
bin: buildInfos.targetExecutableName,
icon: {
'16x16': 'icons/icon16x16.png',
'32x32': 'icons/icon32x32.png',
'48x48': 'icons/icon48x48.png',
'52x52': 'icons/icon52x52.png',
'64x64': 'icons/icon64x64.png',
'96x96': 'icons/icon96x96.png',
'128x128': 'icons/icon128x128.png',
'192x192': 'icons/icon192x192.png',
'256x256': 'icons/icon256x256.png',
'512x512': 'icons/icon512x512.png',
'1024x1024': 'icons/icon1024x1024.png'
},
categories: ["Utility", "Development"]
};
}
gulp.task("Publish:versioninfo-linux", function () { return generateVersionInfo(Platform.Linux, function (baseUrl, arch) { return String.format("{}/{}_{}_{}.deb", baseUrl, buildInfos.targetExecutableName, buildInfos.buildNumber, toDebArch(arch)); }); });
gulp.task("Publish:deb-x86", function (callback) {
var debBuilder = require('electron-installer-debian');
var debOptions = getDebOptions(Architecture.X86);
debBuilder(debOptions, callback);
});
gulp.task("Publish:deb-x64", function (callback) {
var debBuilder = require('electron-installer-debian');
var debOptions = getDebOptions(Architecture.X64);
debBuilder(debOptions, callback);
});
gulp.task("Publish:linux", function (callback) { return runSequence("Pack:linux", ["Publish:versioninfo-linux", "Publish:deb-x86", "Publish:deb-x64"], callback); });
/* Tasks for darwin (macOS) */
function getZipName(arch) {
return String.format("{}-{}-{}.zip", buildInfos.targetExecutableName, buildInfos.buildNumber, arch);
}
gulp.task("Publish:versioninfo-darwin", function () { return generateVersionInfo(Platform.MacOs, function (baseUrl, arch) { return String.format("{}/{}", baseUrl, getZipName(arch)); }); });
gulp.task("Publish:zip-darwin-x64", function (callback) {
if (buildInfos.targets[Platform.MacOs].archs.indexOf(Architecture.X64) < 0) {
gutil.log("Skipping", "zip-darwin-64:", "No x64 architecture specified in buildinfos.");
callback();
return;
}
var macZipper = require('electron-installer-zip');
var packDirName = String.format("{}-{}-{}", buildInfos.productName, toPackagerPlatform(Platform.MacOs), Architecture.X64);
var appDirName = String.format("{}.app", buildInfos.productName);
macZipper({
dir: path.resolve(path.join(buildInfos.paths.buildDir, packDirName, appDirName)),
out: path.resolve(path.join(buildInfos.paths.publishDir, Platform.MacOs, getZipName(Architecture.X64)))
}, function (err, res) { return callback(err); });
});
gulp.task("Publish:darwin", function (callback) { return runSequence("Pack:darwin", ["Publish:versioninfo-darwin", "Publish:zip-darwin-x64"], callback); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment