1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.tmpDirCounter = exports.debug7z = exports.debug = exports.Lazy = exports.subTask = exports.task = exports.warn = exports.log = exports.TmpDir = undefined;
|
7 |
|
8 | var _tmp;
|
9 |
|
10 | function _load_tmp() {
|
11 | return _tmp = require("./tmp");
|
12 | }
|
13 |
|
14 | Object.defineProperty(exports, "TmpDir", {
|
15 | enumerable: true,
|
16 | get: function () {
|
17 | return (_tmp || _load_tmp()).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 _electronBuilderHttp;
|
53 |
|
54 | function _load_electronBuilderHttp() {
|
55 | return _electronBuilderHttp = require("electron-builder-http");
|
56 | }
|
57 |
|
58 | Object.defineProperty(exports, "Lazy", {
|
59 | enumerable: true,
|
60 | get: function () {
|
61 | return (_electronBuilderHttp || _load_electronBuilderHttp()).Lazy;
|
62 | }
|
63 | });
|
64 | exports.removePassword = removePassword;
|
65 | exports.exec = exec;
|
66 | exports.doSpawn = doSpawn;
|
67 | exports.spawn = spawn;
|
68 | exports.handleProcess = handleProcess;
|
69 | exports.use = use;
|
70 | exports.debug7zArgs = debug7zArgs;
|
71 | exports.getTempName = getTempName;
|
72 | exports.isEmptyOrSpaces = isEmptyOrSpaces;
|
73 | exports.isTokenCharValid = isTokenCharValid;
|
74 | exports.asArray = asArray;
|
75 | exports.getCacheDirectory = getCacheDirectory;
|
76 | exports.smarten = smarten;
|
77 | exports.addValue = addValue;
|
78 | exports.replaceDefault = replaceDefault;
|
79 | exports.getPlatformIconFileName = getPlatformIconFileName;
|
80 | exports.isPullRequest = isPullRequest;
|
81 | exports.safeStringifyJson = safeStringifyJson;
|
82 |
|
83 | var _bluebirdLst;
|
84 |
|
85 | function _load_bluebirdLst() {
|
86 | return _bluebirdLst = _interopRequireDefault(require("bluebird-lst"));
|
87 | }
|
88 |
|
89 | var _chalk;
|
90 |
|
91 | function _load_chalk() {
|
92 | return _chalk = require("chalk");
|
93 | }
|
94 |
|
95 | var _child_process;
|
96 |
|
97 | function _load_child_process() {
|
98 | return _child_process = require("child_process");
|
99 | }
|
100 |
|
101 | var _crypto;
|
102 |
|
103 | function _load_crypto() {
|
104 | return _crypto = require("crypto");
|
105 | }
|
106 |
|
107 | var _debug2;
|
108 |
|
109 | function _load_debug() {
|
110 | return _debug2 = _interopRequireDefault(require("debug"));
|
111 | }
|
112 |
|
113 | var _os;
|
114 |
|
115 | function _load_os() {
|
116 | return _os = require("os");
|
117 | }
|
118 |
|
119 | var _path = _interopRequireWildcard(require("path"));
|
120 |
|
121 | require("source-map-support/register");
|
122 |
|
123 | 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; } }
|
124 |
|
125 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
126 |
|
127 | 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); } }
|
128 |
|
129 | const debug = exports.debug = (0, (_debug2 || _load_debug()).default)("electron-builder");
|
130 | const debug7z = exports.debug7z = (0, (_debug2 || _load_debug()).default)("electron-builder:7z");
|
131 | function removePassword(input) {
|
132 | return input.replace(/(-String |-P |pass:| \/p |-pass )([^ ]+)/g, (match, p1, p2) => {
|
133 | return `${p1}${(0, (_crypto || _load_crypto()).createHash)("sha256").update(p2).digest("hex")} (sha256 hash)`;
|
134 | });
|
135 | }
|
136 | function exec(file, args, options) {
|
137 | let isLogOutIfDebug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
138 |
|
139 | if (debug.enabled) {
|
140 | debug(`Executing ${file} ${args == null ? "" : removePassword(args.join(" "))}`);
|
141 | }
|
142 | return new (_bluebirdLst || _load_bluebirdLst()).default((resolve, reject) => {
|
143 | (0, (_child_process || _load_child_process()).execFile)(file, args, options, (error, stdout, stderr) => {
|
144 | if (error == null) {
|
145 | if (isLogOutIfDebug && debug.enabled) {
|
146 | if (stderr.length !== 0) {
|
147 | debug(stderr);
|
148 | }
|
149 | if (stdout.length !== 0) {
|
150 | debug(stdout);
|
151 | }
|
152 | }
|
153 | resolve(stdout);
|
154 | } else {
|
155 | let message = (0, (_chalk || _load_chalk()).red)(removePassword(`Exit code: ${error.code}. ${error.message}`));
|
156 | if (stdout.length !== 0) {
|
157 | message += `\n${(0, (_chalk || _load_chalk()).yellow)(stdout)}`;
|
158 | }
|
159 | if (stderr.length !== 0) {
|
160 | message += `\n${(0, (_chalk || _load_chalk()).red)(stderr)}`;
|
161 | }
|
162 | reject(new Error(message));
|
163 | }
|
164 | });
|
165 | });
|
166 | }
|
167 | function doSpawn(command, args, options, extraOptions) {
|
168 | if (options == null) {
|
169 | options = {};
|
170 | }
|
171 | const isDebugEnabled = extraOptions == null || extraOptions.isDebugEnabled == null ? debug.enabled : extraOptions.isDebugEnabled;
|
172 | if (options.stdio == null) {
|
173 |
|
174 | options.stdio = [extraOptions != null && extraOptions.isPipeInput ? "pipe" : "ignore", isDebugEnabled ? "inherit" : "pipe", isDebugEnabled ? "inherit" : "pipe"];
|
175 | }
|
176 |
|
177 | if (debug.enabled) {
|
178 | const argsString = args.join(" ");
|
179 | debug(`Spawning ${command} ${command === "docker" ? argsString : removePassword(argsString)}`);
|
180 | }
|
181 | try {
|
182 | return (0, (_child_process || _load_child_process()).spawn)(command, args, options);
|
183 | } catch (e) {
|
184 | throw new Error(`Cannot spawn ${command}: ${e.stack || e}`);
|
185 | }
|
186 | }
|
187 | function spawn(command, args, options, extraOptions) {
|
188 | return new (_bluebirdLst || _load_bluebirdLst()).default((resolve, reject) => {
|
189 | handleProcess("close", doSpawn(command, args || [], options, extraOptions), command, resolve, reject);
|
190 | });
|
191 | }
|
192 | function handleProcess(event, childProcess, command, resolve, reject) {
|
193 | childProcess.on("error", reject);
|
194 | let out = "";
|
195 | if (!debug.enabled && childProcess.stdout != null) {
|
196 | childProcess.stdout.on("data", data => {
|
197 | out += data;
|
198 | });
|
199 | }
|
200 | let errorOut = "";
|
201 | if (childProcess.stderr != null) {
|
202 | childProcess.stderr.on("data", data => {
|
203 | errorOut += data;
|
204 | });
|
205 | }
|
206 | childProcess.once(event, code => {
|
207 | if (code === 0 && debug.enabled) {
|
208 | debug(`${command} (${childProcess.pid}) exited with exit code 0`);
|
209 | }
|
210 | if (code === 0) {
|
211 | if (resolve != null) {
|
212 | resolve();
|
213 | }
|
214 | } else {
|
215 | function formatOut(text, title) {
|
216 | return text.length === 0 ? "" : `\n${title}:\n${text}`;
|
217 | }
|
218 | reject(new Error(`${command} exited with code ${code}${formatOut(out, "Output")}${formatOut(errorOut, "Error output")}`));
|
219 | }
|
220 | });
|
221 | }
|
222 | function use(value, task) {
|
223 | return value == null ? null : task(value);
|
224 | }
|
225 | function debug7zArgs(command) {
|
226 | const args = [command, "-bd"];
|
227 | if (debug7z.enabled) {
|
228 | args.push("-bb3");
|
229 | } else if (!debug.enabled) {
|
230 | args.push("-bb0");
|
231 | }
|
232 | return args;
|
233 | }
|
234 | let tmpDirCounter = exports.tmpDirCounter = 0;
|
235 |
|
236 | const tempDirPrefix = `${process.pid.toString(16)}-${Date.now().toString(16)}`;
|
237 | function getTempName(prefix) {
|
238 | return `${prefix == null ? "" : `${prefix}-`}${tempDirPrefix}-${(exports.tmpDirCounter = tmpDirCounter += 1, tmpDirCounter - 1).toString(16)}`;
|
239 | }
|
240 | function isEmptyOrSpaces(s) {
|
241 | return s == null || s.trim().length === 0;
|
242 | }
|
243 | function isTokenCharValid(token) {
|
244 | return (/^[\w\/=+-]+$/.test(token)
|
245 | );
|
246 | }
|
247 | function asArray(v) {
|
248 | if (v == null) {
|
249 | return [];
|
250 | } else if (Array.isArray(v)) {
|
251 | return v;
|
252 | } else {
|
253 | return [v];
|
254 | }
|
255 | }
|
256 | function getCacheDirectory() {
|
257 | const env = process.env.ELECTRON_BUILDER_CACHE;
|
258 | if (!isEmptyOrSpaces(env)) {
|
259 | return env;
|
260 | }
|
261 | if (process.platform === "darwin") {
|
262 | return _path.join((0, (_os || _load_os()).homedir)(), "Library", "Caches", "electron-builder");
|
263 | }
|
264 | const localappdata = process.env.LOCALAPPDATA;
|
265 | if (process.platform === "win32" && localappdata != null) {
|
266 |
|
267 | if (localappdata.toLowerCase().indexOf("\\windows\\system32\\") !== -1 || (process.env.USERNAME || "").toLowerCase() === "system") {
|
268 | return _path.join((0, (_os || _load_os()).tmpdir)(), "electron-builder-cache");
|
269 | }
|
270 | return _path.join(localappdata, "electron-builder", "cache");
|
271 | }
|
272 | return _path.join((0, (_os || _load_os()).homedir)(), ".cache", "electron-builder");
|
273 | }
|
274 |
|
275 |
|
276 | function smarten(s) {
|
277 |
|
278 | s = s.replace(/(^|[-\u2014\s(\["])'/g, "$1\u2018");
|
279 |
|
280 | s = s.replace(/'/g, "\u2019");
|
281 |
|
282 | s = s.replace(/(^|[-\u2014/\[(\u2018\s])"/g, "$1\u201c");
|
283 |
|
284 | s = s.replace(/"/g, "\u201d");
|
285 | return s;
|
286 | }
|
287 | function addValue(map, key, value) {
|
288 | const list = map.get(key);
|
289 | if (list == null) {
|
290 | map.set(key, [value]);
|
291 | } else if (!(list.indexOf(value) !== -1)) {
|
292 | list.push(value);
|
293 | }
|
294 | }
|
295 | function replaceDefault(inList, defaultList) {
|
296 | if (inList == null) {
|
297 | return defaultList;
|
298 | }
|
299 | const index = inList.indexOf("default");
|
300 | if (index >= 0) {
|
301 | const list = inList.slice(0, index);
|
302 | list.push.apply(list, _toConsumableArray(defaultList));
|
303 | if (index !== inList.length - 1) {
|
304 | list.push.apply(list, _toConsumableArray(inList.slice(index + 1)));
|
305 | }
|
306 | inList = list;
|
307 | }
|
308 | return inList;
|
309 | }
|
310 | function getPlatformIconFileName(value, isMac) {
|
311 | if (value === undefined) {
|
312 | return undefined;
|
313 | }
|
314 | if (value === null) {
|
315 | return null;
|
316 | }
|
317 | if (!(value.indexOf(".") !== -1)) {
|
318 | return `${value}.${isMac ? "icns" : "ico"}`;
|
319 | }
|
320 | return value.replace(isMac ? ".ico" : ".icns", isMac ? ".icns" : ".ico");
|
321 | }
|
322 | function isPullRequest() {
|
323 |
|
324 | function isSet(value) {
|
325 |
|
326 | return value && value !== "false";
|
327 | }
|
328 | 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);
|
329 | }
|
330 | function safeStringifyJson(data, skippedNames) {
|
331 | return JSON.stringify(data, (name, value) => {
|
332 | if (name.endsWith("Password") || name.endsWith("Token") || name.indexOf("password") !== -1 || name.indexOf("token") !== -1 || skippedNames != null && skippedNames.has(name)) {
|
333 | return "<stripped sensitive data>";
|
334 | }
|
335 | return value;
|
336 | }, 2);
|
337 | }
|
338 |
|
\ | No newline at end of file |