1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.debug7z = exports.debug = exports.archFromString = exports.getArchSuffix = exports.toLinuxArchString = exports.Arch = exports.prepareWindowsExecutableArgs = exports.execWine = exports.isMacOsSierra = exports.subTask = exports.task = exports.warn = exports.log = exports.TmpDir = undefined;
|
7 |
|
8 | var _tempFile;
|
9 |
|
10 | function _load_tempFile() {
|
11 | return _tempFile = require("temp-file");
|
12 | }
|
13 |
|
14 | Object.defineProperty(exports, "TmpDir", {
|
15 | enumerable: true,
|
16 | get: function () {
|
17 | return (_tempFile || _load_tempFile()).TmpDir;
|
18 | }
|
19 | });
|
20 |
|
21 | var _log;
|
22 |
|
23 | function _load_log() {
|
24 | return _log = require("./log");
|
25 | }
|
26 |
|
27 | Object.defineProperty(exports, "log", {
|
28 | enumerable: true,
|
29 | get: function () {
|
30 | return (_log || _load_log()).log;
|
31 | }
|
32 | });
|
33 | Object.defineProperty(exports, "warn", {
|
34 | enumerable: true,
|
35 | get: function () {
|
36 | return (_log || _load_log()).warn;
|
37 | }
|
38 | });
|
39 | Object.defineProperty(exports, "task", {
|
40 | enumerable: true,
|
41 | get: function () {
|
42 | return (_log || _load_log()).task;
|
43 | }
|
44 | });
|
45 | Object.defineProperty(exports, "subTask", {
|
46 | enumerable: true,
|
47 | get: function () {
|
48 | return (_log || _load_log()).subTask;
|
49 | }
|
50 | });
|
51 |
|
52 | var _macosVersion;
|
53 |
|
54 | function _load_macosVersion() {
|
55 | return _macosVersion = require("./macosVersion");
|
56 | }
|
57 |
|
58 | Object.defineProperty(exports, "isMacOsSierra", {
|
59 | enumerable: true,
|
60 | get: function () {
|
61 | return (_macosVersion || _load_macosVersion()).isMacOsSierra;
|
62 | }
|
63 | });
|
64 |
|
65 | var _wine;
|
66 |
|
67 | function _load_wine() {
|
68 | return _wine = require("./wine");
|
69 | }
|
70 |
|
71 | Object.defineProperty(exports, "execWine", {
|
72 | enumerable: true,
|
73 | get: function () {
|
74 | return (_wine || _load_wine()).execWine;
|
75 | }
|
76 | });
|
77 | Object.defineProperty(exports, "prepareWindowsExecutableArgs", {
|
78 | enumerable: true,
|
79 | get: function () {
|
80 | return (_wine || _load_wine()).prepareWindowsExecutableArgs;
|
81 | }
|
82 | });
|
83 |
|
84 | var _arch;
|
85 |
|
86 | function _load_arch() {
|
87 | return _arch = require("./arch");
|
88 | }
|
89 |
|
90 | Object.defineProperty(exports, "Arch", {
|
91 | enumerable: true,
|
92 | get: function () {
|
93 | return (_arch || _load_arch()).Arch;
|
94 | }
|
95 | });
|
96 | Object.defineProperty(exports, "toLinuxArchString", {
|
97 | enumerable: true,
|
98 | get: function () {
|
99 | return (_arch || _load_arch()).toLinuxArchString;
|
100 | }
|
101 | });
|
102 | Object.defineProperty(exports, "getArchSuffix", {
|
103 | enumerable: true,
|
104 | get: function () {
|
105 | return (_arch || _load_arch()).getArchSuffix;
|
106 | }
|
107 | });
|
108 | Object.defineProperty(exports, "archFromString", {
|
109 | enumerable: true,
|
110 | get: function () {
|
111 | return (_arch || _load_arch()).archFromString;
|
112 | }
|
113 | });
|
114 | exports.removePassword = removePassword;
|
115 | exports.exec = exec;
|
116 | exports.doSpawn = doSpawn;
|
117 | exports.spawnAndWrite = spawnAndWrite;
|
118 | exports.spawn = spawn;
|
119 | exports.handleProcess = handleProcess;
|
120 | exports.use = use;
|
121 | exports.debug7zArgs = debug7zArgs;
|
122 | exports.isEmptyOrSpaces = isEmptyOrSpaces;
|
123 | exports.isTokenCharValid = isTokenCharValid;
|
124 | exports.asArray = asArray;
|
125 | exports.getCacheDirectory = getCacheDirectory;
|
126 | exports.smarten = smarten;
|
127 | exports.addValue = addValue;
|
128 | exports.replaceDefault = replaceDefault;
|
129 | exports.getPlatformIconFileName = getPlatformIconFileName;
|
130 | exports.isPullRequest = isPullRequest;
|
131 | exports.safeStringifyJson = safeStringifyJson;
|
132 | exports.isEnvTrue = isEnvTrue;
|
133 |
|
134 | var _bluebirdLst;
|
135 |
|
136 | function _load_bluebirdLst() {
|
137 | return _bluebirdLst = _interopRequireDefault(require("bluebird-lst"));
|
138 | }
|
139 |
|
140 | var _chalk;
|
141 |
|
142 | function _load_chalk() {
|
143 | return _chalk = require("chalk");
|
144 | }
|
145 |
|
146 | var _child_process;
|
147 |
|
148 | function _load_child_process() {
|
149 | return _child_process = require("child_process");
|
150 | }
|
151 |
|
152 | var _crypto;
|
153 |
|
154 | function _load_crypto() {
|
155 | return _crypto = require("crypto");
|
156 | }
|
157 |
|
158 | var _debug2;
|
159 |
|
160 | function _load_debug() {
|
161 | return _debug2 = _interopRequireDefault(require("debug"));
|
162 | }
|
163 |
|
164 | var _os;
|
165 |
|
166 | function _load_os() {
|
167 | return _os = require("os");
|
168 | }
|
169 |
|
170 | var _path = _interopRequireWildcard(require("path"));
|
171 |
|
172 | require("source-map-support/register");
|
173 |
|
174 | 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; } }
|
175 |
|
176 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
177 |
|
178 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
|
179 |
|
180 | const debug = exports.debug = (0, (_debug2 || _load_debug()).default)("electron-builder");
|
181 | const debug7z = exports.debug7z = (0, (_debug2 || _load_debug()).default)("electron-builder:7z");
|
182 | function removePassword(input) {
|
183 | return input.replace(/(-String |-P |pass:| \/p |-pass )([^ ]+)/g, (match, p1, p2) => {
|
184 | return `${p1}${(0, (_crypto || _load_crypto()).createHash)("sha256").update(p2).digest("hex")} (sha256 hash)`;
|
185 | });
|
186 | }
|
187 | function exec(file, args, options) {
|
188 | let isLogOutIfDebug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
189 |
|
190 | if (debug.enabled) {
|
191 | debug(`Executing ${file} ${args == null ? "" : removePassword(args.join(" "))}`);
|
192 | if (options != null && options.env != null) {
|
193 | const diffEnv = Object.assign({}, options.env);
|
194 | for (const name of Object.keys(process.env)) {
|
195 | if (process.env[name] === options.env[name]) {
|
196 | delete diffEnv[name];
|
197 | }
|
198 | }
|
199 | debug(`env: ${safeStringifyJson(diffEnv)}`);
|
200 | }
|
201 | if (options != null && options.cwd != null) {
|
202 | debug(`cwd: ${options.cwd}`);
|
203 | }
|
204 | }
|
205 | return new (_bluebirdLst || _load_bluebirdLst()).default((resolve, reject) => {
|
206 | (0, (_child_process || _load_child_process()).execFile)(file, args, options, (error, stdout, stderr) => {
|
207 | if (error == null) {
|
208 | if (isLogOutIfDebug && debug.enabled) {
|
209 | if (stderr.length !== 0) {
|
210 | debug(stderr);
|
211 | }
|
212 | if (stdout.length !== 0) {
|
213 | debug(stdout);
|
214 | }
|
215 | }
|
216 | resolve(stdout.toString());
|
217 | } else {
|
218 | let message = (0, (_chalk || _load_chalk()).red)(removePassword(`Exit code: ${error.code}. ${error.message}`));
|
219 | if (stdout.length !== 0) {
|
220 | message += `\n${(0, (_chalk || _load_chalk()).yellow)(stdout.toString())}`;
|
221 | }
|
222 | if (stderr.length !== 0) {
|
223 | message += `\n${(0, (_chalk || _load_chalk()).red)(stderr.toString())}`;
|
224 | }
|
225 | reject(new Error(message));
|
226 | }
|
227 | });
|
228 | });
|
229 | }
|
230 | function doSpawn(command, args, options, extraOptions) {
|
231 | if (options == null) {
|
232 | options = {};
|
233 | }
|
234 | const isDebugEnabled = extraOptions == null || extraOptions.isDebugEnabled == null ? debug.enabled : extraOptions.isDebugEnabled;
|
235 | if (options.stdio == null) {
|
236 |
|
237 | options.stdio = [extraOptions != null && extraOptions.isPipeInput ? "pipe" : "ignore", isDebugEnabled ? "inherit" : "pipe", isDebugEnabled ? "inherit" : "pipe"];
|
238 | }
|
239 |
|
240 | if (debug.enabled) {
|
241 | const argsString = args.join(" ");
|
242 | debug(`Spawning ${command} ${command === "docker" ? argsString : removePassword(argsString)}`);
|
243 | if (options != null && options.cwd != null) {
|
244 | debug(`cwd: ${options.cwd}`);
|
245 | }
|
246 | }
|
247 | try {
|
248 | return (0, (_child_process || _load_child_process()).spawn)(command, args, options);
|
249 | } catch (e) {
|
250 | throw new Error(`Cannot spawn ${command}: ${e.stack || e}`);
|
251 | }
|
252 | }
|
253 | function spawnAndWrite(command, args, data, options) {
|
254 | let isDebugEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
255 |
|
256 | const childProcess = doSpawn(command, args, options, { isPipeInput: true, isDebugEnabled });
|
257 | const timeout = setTimeout(() => childProcess.kill(), 4 * 60 * 1000);
|
258 | return new (_bluebirdLst || _load_bluebirdLst()).default((resolve, reject) => {
|
259 | handleProcess("close", childProcess, command, () => {
|
260 | try {
|
261 | clearTimeout(timeout);
|
262 | } finally {
|
263 | resolve();
|
264 | }
|
265 | }, error => {
|
266 | try {
|
267 | clearTimeout(timeout);
|
268 | } finally {
|
269 | reject(error.stack || error.toString());
|
270 | }
|
271 | });
|
272 | childProcess.stdin.end(data);
|
273 | });
|
274 | }
|
275 | function spawn(command, args, options, extraOptions) {
|
276 | return new (_bluebirdLst || _load_bluebirdLst()).default((resolve, reject) => {
|
277 | handleProcess("close", doSpawn(command, args || [], options, extraOptions), command, resolve, reject);
|
278 | });
|
279 | }
|
280 | function handleProcess(event, childProcess, command, resolve, reject) {
|
281 | childProcess.on("error", reject);
|
282 | let out = "";
|
283 | if (!debug.enabled && childProcess.stdout != null) {
|
284 | childProcess.stdout.on("data", data => {
|
285 | out += data;
|
286 | });
|
287 | }
|
288 | let errorOut = "";
|
289 | if (childProcess.stderr != null) {
|
290 | childProcess.stderr.on("data", data => {
|
291 | errorOut += data;
|
292 | });
|
293 | }
|
294 | childProcess.once(event, code => {
|
295 | if (code === 0 && debug.enabled) {
|
296 | debug(`${command} (${childProcess.pid}) exited with exit code 0`);
|
297 | }
|
298 | if (code === 0) {
|
299 | if (resolve != null) {
|
300 | resolve();
|
301 | }
|
302 | } else {
|
303 | function formatOut(text, title) {
|
304 | return text.length === 0 ? "" : `\n${title}:\n${text}`;
|
305 | }
|
306 | reject(new Error(`${command} exited with code ${code}${formatOut(out, "Output")}${formatOut(errorOut, "Error output")}`));
|
307 | }
|
308 | });
|
309 | }
|
310 | function use(value, task) {
|
311 | return value == null ? null : task(value);
|
312 | }
|
313 | function debug7zArgs(command) {
|
314 | const args = [command, "-bd"];
|
315 | if (debug7z.enabled) {
|
316 | args.push("-bb3");
|
317 | } else if (!debug.enabled) {
|
318 | args.push("-bb0");
|
319 | }
|
320 | return args;
|
321 | }
|
322 | function isEmptyOrSpaces(s) {
|
323 | return s == null || s.trim().length === 0;
|
324 | }
|
325 | function isTokenCharValid(token) {
|
326 | return (/^[\w\/=+-]+$/.test(token)
|
327 | );
|
328 | }
|
329 | function asArray(v) {
|
330 | if (v == null) {
|
331 | return [];
|
332 | } else if (Array.isArray(v)) {
|
333 | return v;
|
334 | } else {
|
335 | return [v];
|
336 | }
|
337 | }
|
338 | function getCacheDirectory() {
|
339 | const env = process.env.ELECTRON_BUILDER_CACHE;
|
340 | if (!isEmptyOrSpaces(env)) {
|
341 | return env;
|
342 | }
|
343 | if (process.platform === "darwin") {
|
344 | return _path.join((0, (_os || _load_os()).homedir)(), "Library", "Caches", "electron-builder");
|
345 | }
|
346 | const localappdata = process.env.LOCALAPPDATA;
|
347 | if (process.platform === "win32" && localappdata != null) {
|
348 |
|
349 | if (localappdata.toLowerCase().indexOf("\\windows\\system32\\") !== -1 || (process.env.USERNAME || "").toLowerCase() === "system") {
|
350 | return _path.join((0, (_os || _load_os()).tmpdir)(), "electron-builder-cache");
|
351 | }
|
352 | return _path.join(localappdata, "electron-builder", "cache");
|
353 | }
|
354 | return _path.join((0, (_os || _load_os()).homedir)(), ".cache", "electron-builder");
|
355 | }
|
356 |
|
357 |
|
358 | function smarten(s) {
|
359 |
|
360 | s = s.replace(/(^|[-\u2014\s(\["])'/g, "$1\u2018");
|
361 |
|
362 | s = s.replace(/'/g, "\u2019");
|
363 |
|
364 | s = s.replace(/(^|[-\u2014/\[(\u2018\s])"/g, "$1\u201c");
|
365 |
|
366 | s = s.replace(/"/g, "\u201d");
|
367 | return s;
|
368 | }
|
369 | function addValue(map, key, value) {
|
370 | const list = map.get(key);
|
371 | if (list == null) {
|
372 | map.set(key, [value]);
|
373 | } else if (!(list.indexOf(value) !== -1)) {
|
374 | list.push(value);
|
375 | }
|
376 | }
|
377 | function replaceDefault(inList, defaultList) {
|
378 | if (inList == null) {
|
379 | return defaultList;
|
380 | }
|
381 | const index = inList.indexOf("default");
|
382 | if (index >= 0) {
|
383 | const list = inList.slice(0, index);
|
384 | list.push.apply(list, _toConsumableArray(defaultList));
|
385 | if (index !== inList.length - 1) {
|
386 | list.push.apply(list, _toConsumableArray(inList.slice(index + 1)));
|
387 | }
|
388 | inList = list;
|
389 | }
|
390 | return inList;
|
391 | }
|
392 | function getPlatformIconFileName(value, isMac) {
|
393 | if (value === undefined) {
|
394 | return undefined;
|
395 | }
|
396 | if (value === null) {
|
397 | return null;
|
398 | }
|
399 | if (!(value.indexOf(".") !== -1)) {
|
400 | return `${value}.${isMac ? "icns" : "ico"}`;
|
401 | }
|
402 | return value.replace(isMac ? ".ico" : ".icns", isMac ? ".icns" : ".ico");
|
403 | }
|
404 | function isPullRequest() {
|
405 |
|
406 | function isSet(value) {
|
407 |
|
408 | return value && value !== "false";
|
409 | }
|
410 | return isSet(process.env.TRAVIS_PULL_REQUEST) || isSet(process.env.CI_PULL_REQUEST) || isSet(process.env.CI_PULL_REQUESTS) || isSet(process.env.BITRISE_PULL_REQUEST) || isSet(process.env.APPVEYOR_PULL_REQUEST_NUMBER);
|
411 | }
|
412 | function safeStringifyJson(data, skippedNames) {
|
413 | return JSON.stringify(data, (name, value) => {
|
414 | if (name.endsWith("Password") || name.endsWith("PASSWORD") || name.endsWith("Token") || name.indexOf("password") !== -1 || name.indexOf("token") !== -1 || skippedNames != null && skippedNames.has(name)) {
|
415 | return "<stripped sensitive data>";
|
416 | }
|
417 | return value;
|
418 | }, 2);
|
419 | }
|
420 | function isEnvTrue(value) {
|
421 | if (value != null) {
|
422 | value = value.trim();
|
423 | }
|
424 | return value === "true" || value === "" || value === "1";
|
425 | }
|
426 |
|
\ | No newline at end of file |