@jsenv/github-release-package 1.2.2 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index.js → main.js} +0 -0
- package/package.json +28 -38
- package/readme.md +1 -24
- package/src/ensureGithubReleaseForPackage.js +64 -68
- package/src/internal/readProjectPackage.js +1 -3
- package/dist/commonjs/main.cjs +0 -1531
- package/dist/commonjs/main.cjs.map +0 -1
- package/src/internal/createGithubRelease.js +0 -52
- package/src/internal/getGithubRelease.js +0 -49
package/dist/commonjs/main.cjs
DELETED
|
@@ -1,1531 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var url$1 = require('url');
|
|
6
|
-
var fs = require('fs');
|
|
7
|
-
var crypto = require('crypto');
|
|
8
|
-
var path = require('path');
|
|
9
|
-
var util = require('util');
|
|
10
|
-
var module$1 = require('module');
|
|
11
|
-
var https = require('https');
|
|
12
|
-
require('net');
|
|
13
|
-
require('http');
|
|
14
|
-
require('stream');
|
|
15
|
-
|
|
16
|
-
const LOG_LEVEL_OFF = "off";
|
|
17
|
-
const LOG_LEVEL_DEBUG = "debug";
|
|
18
|
-
const LOG_LEVEL_INFO = "info";
|
|
19
|
-
const LOG_LEVEL_WARN = "warn";
|
|
20
|
-
const LOG_LEVEL_ERROR = "error";
|
|
21
|
-
|
|
22
|
-
const createLogger = ({
|
|
23
|
-
logLevel = LOG_LEVEL_INFO
|
|
24
|
-
} = {}) => {
|
|
25
|
-
if (logLevel === LOG_LEVEL_DEBUG) {
|
|
26
|
-
return {
|
|
27
|
-
debug,
|
|
28
|
-
info,
|
|
29
|
-
warn,
|
|
30
|
-
error
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (logLevel === LOG_LEVEL_INFO) {
|
|
35
|
-
return {
|
|
36
|
-
debug: debugDisabled,
|
|
37
|
-
info,
|
|
38
|
-
warn,
|
|
39
|
-
error
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (logLevel === LOG_LEVEL_WARN) {
|
|
44
|
-
return {
|
|
45
|
-
debug: debugDisabled,
|
|
46
|
-
info: infoDisabled,
|
|
47
|
-
warn,
|
|
48
|
-
error
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (logLevel === LOG_LEVEL_ERROR) {
|
|
53
|
-
return {
|
|
54
|
-
debug: debugDisabled,
|
|
55
|
-
info: infoDisabled,
|
|
56
|
-
warn: warnDisabled,
|
|
57
|
-
error
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (logLevel === LOG_LEVEL_OFF) {
|
|
62
|
-
return {
|
|
63
|
-
debug: debugDisabled,
|
|
64
|
-
info: infoDisabled,
|
|
65
|
-
warn: warnDisabled,
|
|
66
|
-
error: errorDisabled
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
throw new Error(`unexpected logLevel.
|
|
71
|
-
--- logLevel ---
|
|
72
|
-
${logLevel}
|
|
73
|
-
--- allowed log levels ---
|
|
74
|
-
${LOG_LEVEL_OFF}
|
|
75
|
-
${LOG_LEVEL_ERROR}
|
|
76
|
-
${LOG_LEVEL_WARN}
|
|
77
|
-
${LOG_LEVEL_INFO}
|
|
78
|
-
${LOG_LEVEL_DEBUG}`);
|
|
79
|
-
};
|
|
80
|
-
const debug = console.debug;
|
|
81
|
-
|
|
82
|
-
const debugDisabled = () => {};
|
|
83
|
-
|
|
84
|
-
const info = console.info;
|
|
85
|
-
|
|
86
|
-
const infoDisabled = () => {};
|
|
87
|
-
|
|
88
|
-
const warn = console.warn;
|
|
89
|
-
|
|
90
|
-
const warnDisabled = () => {};
|
|
91
|
-
|
|
92
|
-
const error = console.error;
|
|
93
|
-
|
|
94
|
-
const errorDisabled = () => {};
|
|
95
|
-
|
|
96
|
-
const ensureUrlTrailingSlash = url => {
|
|
97
|
-
return url.endsWith("/") ? url : `${url}/`;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const isFileSystemPath = value => {
|
|
101
|
-
if (typeof value !== "string") {
|
|
102
|
-
throw new TypeError(`isFileSystemPath first arg must be a string, got ${value}`);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (value[0] === "/") return true;
|
|
106
|
-
return startsWithWindowsDriveLetter(value);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const startsWithWindowsDriveLetter = string => {
|
|
110
|
-
const firstChar = string[0];
|
|
111
|
-
if (!/[a-zA-Z]/.test(firstChar)) return false;
|
|
112
|
-
const secondChar = string[1];
|
|
113
|
-
if (secondChar !== ":") return false;
|
|
114
|
-
return true;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const fileSystemPathToUrl = value => {
|
|
118
|
-
if (!isFileSystemPath(value)) {
|
|
119
|
-
throw new Error(`received an invalid value for fileSystemPath: ${value}`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return String(url$1.pathToFileURL(value));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const assertAndNormalizeDirectoryUrl = value => {
|
|
126
|
-
let urlString;
|
|
127
|
-
|
|
128
|
-
if (value instanceof URL) {
|
|
129
|
-
urlString = value.href;
|
|
130
|
-
} else if (typeof value === "string") {
|
|
131
|
-
if (isFileSystemPath(value)) {
|
|
132
|
-
urlString = fileSystemPathToUrl(value);
|
|
133
|
-
} else {
|
|
134
|
-
try {
|
|
135
|
-
urlString = String(new URL(value));
|
|
136
|
-
} catch (e) {
|
|
137
|
-
throw new TypeError(`directoryUrl must be a valid url, received ${value}`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
} else {
|
|
141
|
-
throw new TypeError(`directoryUrl must be a string or an url, received ${value}`);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!urlString.startsWith("file://")) {
|
|
145
|
-
throw new Error(`directoryUrl must starts with file://, received ${value}`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return ensureUrlTrailingSlash(urlString);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const assertAndNormalizeFileUrl = (value, baseUrl) => {
|
|
152
|
-
let urlString;
|
|
153
|
-
|
|
154
|
-
if (value instanceof URL) {
|
|
155
|
-
urlString = value.href;
|
|
156
|
-
} else if (typeof value === "string") {
|
|
157
|
-
if (isFileSystemPath(value)) {
|
|
158
|
-
urlString = fileSystemPathToUrl(value);
|
|
159
|
-
} else {
|
|
160
|
-
try {
|
|
161
|
-
urlString = String(new URL(value, baseUrl));
|
|
162
|
-
} catch (e) {
|
|
163
|
-
throw new TypeError(`fileUrl must be a valid url, received ${value}`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
} else {
|
|
167
|
-
throw new TypeError(`fileUrl must be a string or an url, received ${value}`);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (!urlString.startsWith("file://")) {
|
|
171
|
-
throw new Error(`fileUrl must starts with file://, received ${value}`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return urlString;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const urlToFileSystemPath = fileUrl => {
|
|
178
|
-
if (fileUrl[fileUrl.length - 1] === "/") {
|
|
179
|
-
// remove trailing / so that nodejs path becomes predictable otherwise it logs
|
|
180
|
-
// the trailing slash on linux but does not on windows
|
|
181
|
-
fileUrl = fileUrl.slice(0, -1);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const fileSystemPath = url$1.fileURLToPath(fileUrl);
|
|
185
|
-
return fileSystemPath;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// https://github.com/coderaiser/cloudcmd/issues/63#issuecomment-195478143
|
|
189
|
-
// https://nodejs.org/api/fs.html#fs_file_modes
|
|
190
|
-
// https://github.com/TooTallNate/stat-mode
|
|
191
|
-
// cannot get from fs.constants because they are not available on windows
|
|
192
|
-
const S_IRUSR = 256;
|
|
193
|
-
/* 0000400 read permission, owner */
|
|
194
|
-
|
|
195
|
-
const S_IWUSR = 128;
|
|
196
|
-
/* 0000200 write permission, owner */
|
|
197
|
-
|
|
198
|
-
const S_IXUSR = 64;
|
|
199
|
-
/* 0000100 execute/search permission, owner */
|
|
200
|
-
|
|
201
|
-
const S_IRGRP = 32;
|
|
202
|
-
/* 0000040 read permission, group */
|
|
203
|
-
|
|
204
|
-
const S_IWGRP = 16;
|
|
205
|
-
/* 0000020 write permission, group */
|
|
206
|
-
|
|
207
|
-
const S_IXGRP = 8;
|
|
208
|
-
/* 0000010 execute/search permission, group */
|
|
209
|
-
|
|
210
|
-
const S_IROTH = 4;
|
|
211
|
-
/* 0000004 read permission, others */
|
|
212
|
-
|
|
213
|
-
const S_IWOTH = 2;
|
|
214
|
-
/* 0000002 write permission, others */
|
|
215
|
-
|
|
216
|
-
const S_IXOTH = 1;
|
|
217
|
-
const permissionsToBinaryFlags = ({
|
|
218
|
-
owner,
|
|
219
|
-
group,
|
|
220
|
-
others
|
|
221
|
-
}) => {
|
|
222
|
-
let binaryFlags = 0;
|
|
223
|
-
if (owner.read) binaryFlags |= S_IRUSR;
|
|
224
|
-
if (owner.write) binaryFlags |= S_IWUSR;
|
|
225
|
-
if (owner.execute) binaryFlags |= S_IXUSR;
|
|
226
|
-
if (group.read) binaryFlags |= S_IRGRP;
|
|
227
|
-
if (group.write) binaryFlags |= S_IWGRP;
|
|
228
|
-
if (group.execute) binaryFlags |= S_IXGRP;
|
|
229
|
-
if (others.read) binaryFlags |= S_IROTH;
|
|
230
|
-
if (others.write) binaryFlags |= S_IWOTH;
|
|
231
|
-
if (others.execute) binaryFlags |= S_IXOTH;
|
|
232
|
-
return binaryFlags;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
const writeFileSystemNodePermissions = async (source, permissions) => {
|
|
236
|
-
const sourceUrl = assertAndNormalizeFileUrl(source);
|
|
237
|
-
const sourcePath = urlToFileSystemPath(sourceUrl);
|
|
238
|
-
let binaryFlags;
|
|
239
|
-
|
|
240
|
-
if (typeof permissions === "object") {
|
|
241
|
-
permissions = {
|
|
242
|
-
owner: {
|
|
243
|
-
read: getPermissionOrComputeDefault("read", "owner", permissions),
|
|
244
|
-
write: getPermissionOrComputeDefault("write", "owner", permissions),
|
|
245
|
-
execute: getPermissionOrComputeDefault("execute", "owner", permissions)
|
|
246
|
-
},
|
|
247
|
-
group: {
|
|
248
|
-
read: getPermissionOrComputeDefault("read", "group", permissions),
|
|
249
|
-
write: getPermissionOrComputeDefault("write", "group", permissions),
|
|
250
|
-
execute: getPermissionOrComputeDefault("execute", "group", permissions)
|
|
251
|
-
},
|
|
252
|
-
others: {
|
|
253
|
-
read: getPermissionOrComputeDefault("read", "others", permissions),
|
|
254
|
-
write: getPermissionOrComputeDefault("write", "others", permissions),
|
|
255
|
-
execute: getPermissionOrComputeDefault("execute", "others", permissions)
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
binaryFlags = permissionsToBinaryFlags(permissions);
|
|
259
|
-
} else {
|
|
260
|
-
binaryFlags = permissions;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return chmodNaive(sourcePath, binaryFlags);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const chmodNaive = (fileSystemPath, binaryFlags) => {
|
|
267
|
-
return new Promise((resolve, reject) => {
|
|
268
|
-
fs.chmod(fileSystemPath, binaryFlags, error => {
|
|
269
|
-
if (error) {
|
|
270
|
-
reject(error);
|
|
271
|
-
} else {
|
|
272
|
-
resolve();
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
const actionLevels = {
|
|
279
|
-
read: 0,
|
|
280
|
-
write: 1,
|
|
281
|
-
execute: 2
|
|
282
|
-
};
|
|
283
|
-
const subjectLevels = {
|
|
284
|
-
others: 0,
|
|
285
|
-
group: 1,
|
|
286
|
-
owner: 2
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const getPermissionOrComputeDefault = (action, subject, permissions) => {
|
|
290
|
-
if (subject in permissions) {
|
|
291
|
-
const subjectPermissions = permissions[subject];
|
|
292
|
-
|
|
293
|
-
if (action in subjectPermissions) {
|
|
294
|
-
return subjectPermissions[action];
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const actionLevel = actionLevels[action];
|
|
298
|
-
const actionFallback = Object.keys(actionLevels).find(actionFallbackCandidate => actionLevels[actionFallbackCandidate] > actionLevel && actionFallbackCandidate in subjectPermissions);
|
|
299
|
-
|
|
300
|
-
if (actionFallback) {
|
|
301
|
-
return subjectPermissions[actionFallback];
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const subjectLevel = subjectLevels[subject]; // do we have a subject with a stronger level (group or owner)
|
|
306
|
-
// where we could read the action permission ?
|
|
307
|
-
|
|
308
|
-
const subjectFallback = Object.keys(subjectLevels).find(subjectFallbackCandidate => subjectLevels[subjectFallbackCandidate] > subjectLevel && subjectFallbackCandidate in permissions);
|
|
309
|
-
|
|
310
|
-
if (subjectFallback) {
|
|
311
|
-
const subjectPermissions = permissions[subjectFallback];
|
|
312
|
-
return action in subjectPermissions ? subjectPermissions[action] : getPermissionOrComputeDefault(action, subjectFallback, permissions);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return false;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
const isWindows = process.platform === "win32";
|
|
319
|
-
const readFileSystemNodeStat = async (source, {
|
|
320
|
-
nullIfNotFound = false,
|
|
321
|
-
followLink = true
|
|
322
|
-
} = {}) => {
|
|
323
|
-
if (source.endsWith("/")) source = source.slice(0, -1);
|
|
324
|
-
const sourceUrl = assertAndNormalizeFileUrl(source);
|
|
325
|
-
const sourcePath = urlToFileSystemPath(sourceUrl);
|
|
326
|
-
const handleNotFoundOption = nullIfNotFound ? {
|
|
327
|
-
handleNotFoundError: () => null
|
|
328
|
-
} : {};
|
|
329
|
-
return readStat(sourcePath, {
|
|
330
|
-
followLink,
|
|
331
|
-
...handleNotFoundOption,
|
|
332
|
-
...(isWindows ? {
|
|
333
|
-
// Windows can EPERM on stat
|
|
334
|
-
handlePermissionDeniedError: async error => {
|
|
335
|
-
// unfortunately it means we mutate the permissions
|
|
336
|
-
// without being able to restore them to the previous value
|
|
337
|
-
// (because reading current permission would also throw)
|
|
338
|
-
try {
|
|
339
|
-
await writeFileSystemNodePermissions(sourceUrl, 0o666);
|
|
340
|
-
const stats = await readStat(sourcePath, {
|
|
341
|
-
followLink,
|
|
342
|
-
...handleNotFoundOption,
|
|
343
|
-
// could not fix the permission error, give up and throw original error
|
|
344
|
-
handlePermissionDeniedError: () => {
|
|
345
|
-
throw error;
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
return stats;
|
|
349
|
-
} catch (e) {
|
|
350
|
-
// failed to write permission or readState, throw original error as well
|
|
351
|
-
throw error;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
} : {})
|
|
355
|
-
});
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
const readStat = (sourcePath, {
|
|
359
|
-
followLink,
|
|
360
|
-
handleNotFoundError = null,
|
|
361
|
-
handlePermissionDeniedError = null
|
|
362
|
-
} = {}) => {
|
|
363
|
-
const nodeMethod = followLink ? fs.stat : fs.lstat;
|
|
364
|
-
return new Promise((resolve, reject) => {
|
|
365
|
-
nodeMethod(sourcePath, (error, statsObject) => {
|
|
366
|
-
if (error) {
|
|
367
|
-
if (handlePermissionDeniedError && (error.code === "EPERM" || error.code === "EACCES")) {
|
|
368
|
-
resolve(handlePermissionDeniedError(error));
|
|
369
|
-
} else if (handleNotFoundError && error.code === "ENOENT") {
|
|
370
|
-
resolve(handleNotFoundError(error));
|
|
371
|
-
} else {
|
|
372
|
-
reject(error);
|
|
373
|
-
}
|
|
374
|
-
} else {
|
|
375
|
-
resolve(statsObject);
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
const ETAG_FOR_EMPTY_CONTENT = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|
|
382
|
-
const bufferToEtag = buffer => {
|
|
383
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
384
|
-
throw new TypeError(`buffer expected, got ${buffer}`);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (buffer.length === 0) {
|
|
388
|
-
return ETAG_FOR_EMPTY_CONTENT;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
const hash = crypto.createHash("sha1");
|
|
392
|
-
hash.update(buffer, "utf8");
|
|
393
|
-
const hashBase64String = hash.digest("base64");
|
|
394
|
-
const hashBase64StringSubset = hashBase64String.slice(0, 27);
|
|
395
|
-
const length = buffer.length;
|
|
396
|
-
return `"${length.toString(16)}-${hashBase64StringSubset}"`;
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
const createCancellationToken = () => {
|
|
400
|
-
const register = callback => {
|
|
401
|
-
if (typeof callback !== "function") {
|
|
402
|
-
throw new Error(`callback must be a function, got ${callback}`);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
return {
|
|
406
|
-
callback,
|
|
407
|
-
unregister: () => {}
|
|
408
|
-
};
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
const throwIfRequested = () => undefined;
|
|
412
|
-
|
|
413
|
-
return {
|
|
414
|
-
register,
|
|
415
|
-
cancellationRequested: false,
|
|
416
|
-
throwIfRequested
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
const createOperation = ({
|
|
421
|
-
cancellationToken = createCancellationToken(),
|
|
422
|
-
start,
|
|
423
|
-
...rest
|
|
424
|
-
}) => {
|
|
425
|
-
const unknownArgumentNames = Object.keys(rest);
|
|
426
|
-
|
|
427
|
-
if (unknownArgumentNames.length) {
|
|
428
|
-
throw new Error(`createOperation called with unknown argument names.
|
|
429
|
-
--- unknown argument names ---
|
|
430
|
-
${unknownArgumentNames}
|
|
431
|
-
--- possible argument names ---
|
|
432
|
-
cancellationToken
|
|
433
|
-
start`);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
cancellationToken.throwIfRequested();
|
|
437
|
-
const promise = new Promise(resolve => {
|
|
438
|
-
resolve(start());
|
|
439
|
-
});
|
|
440
|
-
const cancelPromise = new Promise((resolve, reject) => {
|
|
441
|
-
const cancelRegistration = cancellationToken.register(cancelError => {
|
|
442
|
-
cancelRegistration.unregister();
|
|
443
|
-
reject(cancelError);
|
|
444
|
-
});
|
|
445
|
-
promise.then(cancelRegistration.unregister, () => {});
|
|
446
|
-
});
|
|
447
|
-
const operationPromise = Promise.race([promise, cancelPromise]);
|
|
448
|
-
return operationPromise;
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
const createCancelError = reason => {
|
|
452
|
-
const cancelError = new Error(`canceled because ${reason}`);
|
|
453
|
-
cancelError.name = "CANCEL_ERROR";
|
|
454
|
-
cancelError.reason = reason;
|
|
455
|
-
return cancelError;
|
|
456
|
-
};
|
|
457
|
-
const isCancelError = value => {
|
|
458
|
-
return value && typeof value === "object" && value.name === "CANCEL_ERROR";
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
const arrayWithout = (array, item) => {
|
|
462
|
-
const arrayWithoutItem = [];
|
|
463
|
-
let i = 0;
|
|
464
|
-
|
|
465
|
-
while (i < array.length) {
|
|
466
|
-
const value = array[i];
|
|
467
|
-
i++;
|
|
468
|
-
|
|
469
|
-
if (value === item) {
|
|
470
|
-
continue;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
arrayWithoutItem.push(value);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
return arrayWithoutItem;
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
// https://github.com/tc39/proposal-cancellation/tree/master/stage0
|
|
480
|
-
const createCancellationSource = () => {
|
|
481
|
-
let requested = false;
|
|
482
|
-
let cancelError;
|
|
483
|
-
let registrationArray = [];
|
|
484
|
-
|
|
485
|
-
const cancel = reason => {
|
|
486
|
-
if (requested) return;
|
|
487
|
-
requested = true;
|
|
488
|
-
cancelError = createCancelError(reason);
|
|
489
|
-
const registrationArrayCopy = registrationArray.slice();
|
|
490
|
-
registrationArray.length = 0;
|
|
491
|
-
registrationArrayCopy.forEach(registration => {
|
|
492
|
-
registration.callback(cancelError); // const removedDuringCall = registrationArray.indexOf(registration) === -1
|
|
493
|
-
});
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
const register = callback => {
|
|
497
|
-
if (typeof callback !== "function") {
|
|
498
|
-
throw new Error(`callback must be a function, got ${callback}`);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
const existingRegistration = registrationArray.find(registration => {
|
|
502
|
-
return registration.callback === callback;
|
|
503
|
-
}); // don't register twice
|
|
504
|
-
|
|
505
|
-
if (existingRegistration) {
|
|
506
|
-
return existingRegistration;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
const registration = {
|
|
510
|
-
callback,
|
|
511
|
-
unregister: () => {
|
|
512
|
-
registrationArray = arrayWithout(registrationArray, registration);
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
registrationArray = [registration, ...registrationArray];
|
|
516
|
-
return registration;
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
const throwIfRequested = () => {
|
|
520
|
-
if (requested) {
|
|
521
|
-
throw cancelError;
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
return {
|
|
526
|
-
token: {
|
|
527
|
-
register,
|
|
528
|
-
|
|
529
|
-
get cancellationRequested() {
|
|
530
|
-
return requested;
|
|
531
|
-
},
|
|
532
|
-
|
|
533
|
-
throwIfRequested
|
|
534
|
-
},
|
|
535
|
-
cancel
|
|
536
|
-
};
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
const catchCancellation = asyncFn => {
|
|
540
|
-
return asyncFn().catch(error => {
|
|
541
|
-
if (isCancelError(error)) {
|
|
542
|
-
// it means consume of the function will resolve with a cancelError
|
|
543
|
-
// but when you cancel it means you're not interested in the result anymore
|
|
544
|
-
// thanks to this it avoid unhandledRejection
|
|
545
|
-
return error;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
throw error;
|
|
549
|
-
});
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
const readDirectory = async (url, {
|
|
553
|
-
emfileMaxWait = 1000
|
|
554
|
-
} = {}) => {
|
|
555
|
-
const directoryUrl = assertAndNormalizeDirectoryUrl(url);
|
|
556
|
-
const directoryPath = urlToFileSystemPath(directoryUrl);
|
|
557
|
-
const startMs = Date.now();
|
|
558
|
-
let attemptCount = 0;
|
|
559
|
-
|
|
560
|
-
const attempt = () => {
|
|
561
|
-
return readdirNaive(directoryPath, {
|
|
562
|
-
handleTooManyFilesOpenedError: async error => {
|
|
563
|
-
attemptCount++;
|
|
564
|
-
const nowMs = Date.now();
|
|
565
|
-
const timeSpentWaiting = nowMs - startMs;
|
|
566
|
-
|
|
567
|
-
if (timeSpentWaiting > emfileMaxWait) {
|
|
568
|
-
throw error;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
return new Promise(resolve => {
|
|
572
|
-
setTimeout(() => {
|
|
573
|
-
resolve(attempt());
|
|
574
|
-
}, attemptCount);
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
return attempt();
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
const readdirNaive = (directoryPath, {
|
|
584
|
-
handleTooManyFilesOpenedError = null
|
|
585
|
-
} = {}) => {
|
|
586
|
-
return new Promise((resolve, reject) => {
|
|
587
|
-
fs.readdir(directoryPath, (error, names) => {
|
|
588
|
-
if (error) {
|
|
589
|
-
// https://nodejs.org/dist/latest-v13.x/docs/api/errors.html#errors_common_system_errors
|
|
590
|
-
if (handleTooManyFilesOpenedError && (error.code === "EMFILE" || error.code === "ENFILE")) {
|
|
591
|
-
resolve(handleTooManyFilesOpenedError(error));
|
|
592
|
-
} else {
|
|
593
|
-
reject(error);
|
|
594
|
-
}
|
|
595
|
-
} else {
|
|
596
|
-
resolve(names);
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
});
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
const resolveUrl = (specifier, baseUrl) => {
|
|
603
|
-
if (typeof baseUrl === "undefined") {
|
|
604
|
-
throw new TypeError(`baseUrl missing to resolve ${specifier}`);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
return String(new URL(specifier, baseUrl));
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
const isWindows$1 = process.platform === "win32";
|
|
611
|
-
const baseUrlFallback = fileSystemPathToUrl(process.cwd());
|
|
612
|
-
|
|
613
|
-
const isWindows$2 = process.platform === "win32";
|
|
614
|
-
|
|
615
|
-
const addCallback = callback => {
|
|
616
|
-
const triggerHangUpOrDeath = () => callback(); // SIGHUP http://man7.org/linux/man-pages/man7/signal.7.html
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
process.once("SIGUP", triggerHangUpOrDeath);
|
|
620
|
-
return () => {
|
|
621
|
-
process.removeListener("SIGUP", triggerHangUpOrDeath);
|
|
622
|
-
};
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
const SIGUPSignal = {
|
|
626
|
-
addCallback
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
const addCallback$1 = callback => {
|
|
630
|
-
// SIGINT is CTRL+C from keyboard also refered as keyboard interruption
|
|
631
|
-
// http://man7.org/linux/man-pages/man7/signal.7.html
|
|
632
|
-
// may also be sent by vscode https://github.com/Microsoft/vscode-node-debug/issues/1#issuecomment-405185642
|
|
633
|
-
process.once("SIGINT", callback);
|
|
634
|
-
return () => {
|
|
635
|
-
process.removeListener("SIGINT", callback);
|
|
636
|
-
};
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
const SIGINTSignal = {
|
|
640
|
-
addCallback: addCallback$1
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
const addCallback$2 = callback => {
|
|
644
|
-
if (process.platform === "win32") {
|
|
645
|
-
console.warn(`SIGTERM is not supported on windows`);
|
|
646
|
-
return () => {};
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
const triggerTermination = () => callback(); // SIGTERM http://man7.org/linux/man-pages/man7/signal.7.html
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
process.once("SIGTERM", triggerTermination);
|
|
653
|
-
return () => {
|
|
654
|
-
process.removeListener("SIGTERM", triggerTermination);
|
|
655
|
-
};
|
|
656
|
-
};
|
|
657
|
-
|
|
658
|
-
const SIGTERMSignal = {
|
|
659
|
-
addCallback: addCallback$2
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
let beforeExitCallbackArray = [];
|
|
663
|
-
let uninstall;
|
|
664
|
-
|
|
665
|
-
const addCallback$3 = callback => {
|
|
666
|
-
if (beforeExitCallbackArray.length === 0) uninstall = install();
|
|
667
|
-
beforeExitCallbackArray = [...beforeExitCallbackArray, callback];
|
|
668
|
-
return () => {
|
|
669
|
-
if (beforeExitCallbackArray.length === 0) return;
|
|
670
|
-
beforeExitCallbackArray = beforeExitCallbackArray.filter(beforeExitCallback => beforeExitCallback !== callback);
|
|
671
|
-
if (beforeExitCallbackArray.length === 0) uninstall();
|
|
672
|
-
};
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
const install = () => {
|
|
676
|
-
const onBeforeExit = () => {
|
|
677
|
-
return beforeExitCallbackArray.reduce(async (previous, callback) => {
|
|
678
|
-
await previous;
|
|
679
|
-
return callback();
|
|
680
|
-
}, Promise.resolve());
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
process.once("beforeExit", onBeforeExit);
|
|
684
|
-
return () => {
|
|
685
|
-
process.removeListener("beforeExit", onBeforeExit);
|
|
686
|
-
};
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
const beforeExitSignal = {
|
|
690
|
-
addCallback: addCallback$3
|
|
691
|
-
};
|
|
692
|
-
|
|
693
|
-
const addCallback$4 = (callback, {
|
|
694
|
-
collectExceptions = false
|
|
695
|
-
} = {}) => {
|
|
696
|
-
if (!collectExceptions) {
|
|
697
|
-
const exitCallback = () => {
|
|
698
|
-
callback();
|
|
699
|
-
};
|
|
700
|
-
|
|
701
|
-
process.on("exit", exitCallback);
|
|
702
|
-
return () => {
|
|
703
|
-
process.removeListener("exit", exitCallback);
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
const {
|
|
708
|
-
getExceptions,
|
|
709
|
-
stop
|
|
710
|
-
} = trackExceptions();
|
|
711
|
-
|
|
712
|
-
const exitCallback = () => {
|
|
713
|
-
process.removeListener("exit", exitCallback);
|
|
714
|
-
stop();
|
|
715
|
-
callback({
|
|
716
|
-
exceptionArray: getExceptions().map(({
|
|
717
|
-
exception,
|
|
718
|
-
origin
|
|
719
|
-
}) => {
|
|
720
|
-
return {
|
|
721
|
-
exception,
|
|
722
|
-
origin
|
|
723
|
-
};
|
|
724
|
-
})
|
|
725
|
-
});
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
process.on("exit", exitCallback);
|
|
729
|
-
return () => {
|
|
730
|
-
process.removeListener("exit", exitCallback);
|
|
731
|
-
};
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
const trackExceptions = () => {
|
|
735
|
-
let exceptionArray = [];
|
|
736
|
-
|
|
737
|
-
const unhandledRejectionCallback = (unhandledRejection, promise) => {
|
|
738
|
-
exceptionArray = [...exceptionArray, {
|
|
739
|
-
origin: "unhandledRejection",
|
|
740
|
-
exception: unhandledRejection,
|
|
741
|
-
promise
|
|
742
|
-
}];
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
const rejectionHandledCallback = promise => {
|
|
746
|
-
exceptionArray = exceptionArray.filter(exceptionArray => exceptionArray.promise !== promise);
|
|
747
|
-
};
|
|
748
|
-
|
|
749
|
-
const uncaughtExceptionCallback = (uncaughtException, origin) => {
|
|
750
|
-
// since node 12.4 https://nodejs.org/docs/latest-v12.x/api/process.html#process_event_uncaughtexception
|
|
751
|
-
if (origin === "unhandledRejection") return;
|
|
752
|
-
exceptionArray = [...exceptionArray, {
|
|
753
|
-
origin: "uncaughtException",
|
|
754
|
-
exception: uncaughtException
|
|
755
|
-
}];
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
process.on("unhandledRejection", unhandledRejectionCallback);
|
|
759
|
-
process.on("rejectionHandled", rejectionHandledCallback);
|
|
760
|
-
process.on("uncaughtException", uncaughtExceptionCallback);
|
|
761
|
-
return {
|
|
762
|
-
getExceptions: () => exceptionArray,
|
|
763
|
-
stop: () => {
|
|
764
|
-
process.removeListener("unhandledRejection", unhandledRejectionCallback);
|
|
765
|
-
process.removeListener("rejectionHandled", rejectionHandledCallback);
|
|
766
|
-
process.removeListener("uncaughtException", uncaughtExceptionCallback);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
const exitSignal = {
|
|
772
|
-
addCallback: addCallback$4
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
const addCallback$5 = callback => {
|
|
776
|
-
return eventRace({
|
|
777
|
-
SIGHUP: {
|
|
778
|
-
register: SIGUPSignal.addCallback,
|
|
779
|
-
callback: () => callback("SIGHUP")
|
|
780
|
-
},
|
|
781
|
-
SIGINT: {
|
|
782
|
-
register: SIGINTSignal.addCallback,
|
|
783
|
-
callback: () => callback("SIGINT")
|
|
784
|
-
},
|
|
785
|
-
...(process.platform === "win32" ? {} : {
|
|
786
|
-
SIGTERM: {
|
|
787
|
-
register: SIGTERMSignal.addCallback,
|
|
788
|
-
callback: () => callback("SIGTERM")
|
|
789
|
-
}
|
|
790
|
-
}),
|
|
791
|
-
beforeExit: {
|
|
792
|
-
register: beforeExitSignal.addCallback,
|
|
793
|
-
callback: () => callback("beforeExit")
|
|
794
|
-
},
|
|
795
|
-
exit: {
|
|
796
|
-
register: exitSignal.addCallback,
|
|
797
|
-
callback: () => callback("exit")
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
const eventRace = eventMap => {
|
|
803
|
-
const unregisterMap = {};
|
|
804
|
-
|
|
805
|
-
const unregisterAll = reason => {
|
|
806
|
-
return Object.keys(unregisterMap).map(name => unregisterMap[name](reason));
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
Object.keys(eventMap).forEach(name => {
|
|
810
|
-
const {
|
|
811
|
-
register,
|
|
812
|
-
callback
|
|
813
|
-
} = eventMap[name];
|
|
814
|
-
unregisterMap[name] = register((...args) => {
|
|
815
|
-
unregisterAll();
|
|
816
|
-
callback(...args);
|
|
817
|
-
});
|
|
818
|
-
});
|
|
819
|
-
return unregisterAll;
|
|
820
|
-
};
|
|
821
|
-
|
|
822
|
-
const teardownSignal = {
|
|
823
|
-
addCallback: addCallback$5
|
|
824
|
-
};
|
|
825
|
-
|
|
826
|
-
const createCancellationTokenForProcess = () => {
|
|
827
|
-
const teardownCancelSource = createCancellationSource();
|
|
828
|
-
teardownSignal.addCallback(reason => teardownCancelSource.cancel(`process ${reason}`));
|
|
829
|
-
return teardownCancelSource.token;
|
|
830
|
-
};
|
|
831
|
-
|
|
832
|
-
const readFilePromisified = util.promisify(fs.readFile);
|
|
833
|
-
const readFile = async value => {
|
|
834
|
-
const fileUrl = assertAndNormalizeFileUrl(value);
|
|
835
|
-
const filePath = urlToFileSystemPath(fileUrl);
|
|
836
|
-
const buffer = await readFilePromisified(filePath);
|
|
837
|
-
return buffer.toString();
|
|
838
|
-
};
|
|
839
|
-
|
|
840
|
-
const isWindows$3 = process.platform === "win32";
|
|
841
|
-
|
|
842
|
-
/* eslint-disable import/max-dependencies */
|
|
843
|
-
const isLinux = process.platform === "linux"; // linux does not support recursive option
|
|
844
|
-
|
|
845
|
-
const readProjectPackage = async ({
|
|
846
|
-
projectDirectoryUrl
|
|
847
|
-
}) => {
|
|
848
|
-
const packageFileUrl = resolveUrl("./package.json", projectDirectoryUrl);
|
|
849
|
-
let packageInProject;
|
|
850
|
-
|
|
851
|
-
try {
|
|
852
|
-
const packageString = await readFile(packageFileUrl);
|
|
853
|
-
|
|
854
|
-
try {
|
|
855
|
-
packageInProject = JSON.parse(packageString);
|
|
856
|
-
} catch (e) {
|
|
857
|
-
if (e.name === "SyntaxError") {
|
|
858
|
-
throw new Error(`syntax error while parsing project package.json
|
|
859
|
-
--- syntax error stack ---
|
|
860
|
-
${e.stack}
|
|
861
|
-
--- package.json path ---
|
|
862
|
-
${urlToFileSystemPath(packageFileUrl)}`);
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
throw e;
|
|
866
|
-
}
|
|
867
|
-
} catch (e) {
|
|
868
|
-
if (e.code === "ENOENT") {
|
|
869
|
-
throw new Error(`cannot find project package.json
|
|
870
|
-
--- package.json path ---
|
|
871
|
-
${urlToFileSystemPath(packageFileUrl)}`);
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
throw e;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
return packageInProject;
|
|
878
|
-
};
|
|
879
|
-
|
|
880
|
-
const convertFileSystemErrorToResponseProperties = error => {
|
|
881
|
-
// https://iojs.org/api/errors.html#errors_eacces_permission_denied
|
|
882
|
-
if (isErrorWithCode(error, "EACCES")) {
|
|
883
|
-
return {
|
|
884
|
-
status: 403,
|
|
885
|
-
statusText: "no permission to read file"
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
if (isErrorWithCode(error, "EPERM")) {
|
|
890
|
-
return {
|
|
891
|
-
status: 403,
|
|
892
|
-
statusText: "no permission to read file"
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
if (isErrorWithCode(error, "ENOENT")) {
|
|
897
|
-
return {
|
|
898
|
-
status: 404,
|
|
899
|
-
statusText: "file not found"
|
|
900
|
-
};
|
|
901
|
-
} // file access may be temporarily blocked
|
|
902
|
-
// (by an antivirus scanning it because recently modified for instance)
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (isErrorWithCode(error, "EBUSY")) {
|
|
906
|
-
return {
|
|
907
|
-
status: 503,
|
|
908
|
-
statusText: "file is busy",
|
|
909
|
-
headers: {
|
|
910
|
-
"retry-after": 0.01 // retry in 10ms
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
} // emfile means there is too many files currently opened
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
if (isErrorWithCode(error, "EMFILE")) {
|
|
918
|
-
return {
|
|
919
|
-
status: 503,
|
|
920
|
-
statusText: "too many file opened",
|
|
921
|
-
headers: {
|
|
922
|
-
"retry-after": 0.1 // retry in 100ms
|
|
923
|
-
|
|
924
|
-
}
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
if (isErrorWithCode(error, "EISDIR")) {
|
|
929
|
-
return {
|
|
930
|
-
status: 500,
|
|
931
|
-
statusText: "Unexpected directory operation"
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
return Promise.reject(error);
|
|
936
|
-
};
|
|
937
|
-
|
|
938
|
-
const isErrorWithCode = (error, code) => {
|
|
939
|
-
return typeof error === "object" && error.code === code;
|
|
940
|
-
};
|
|
941
|
-
|
|
942
|
-
if ("observable" in Symbol === false) {
|
|
943
|
-
Symbol.observable = Symbol.for("observable");
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
/* global require, __filename */
|
|
947
|
-
const nodeRequire = require;
|
|
948
|
-
const filenameContainsBackSlashes = __filename.indexOf("\\") > -1;
|
|
949
|
-
const url = filenameContainsBackSlashes ? `file:///${__filename.replace(/\\/g, "/")}` : `file://${__filename}`;
|
|
950
|
-
|
|
951
|
-
const jsenvContentTypeMap = {
|
|
952
|
-
"application/javascript": {
|
|
953
|
-
extensions: ["js", "cjs", "mjs", "ts", "jsx"]
|
|
954
|
-
},
|
|
955
|
-
"application/json": {
|
|
956
|
-
extensions: ["json"]
|
|
957
|
-
},
|
|
958
|
-
"application/octet-stream": {},
|
|
959
|
-
"application/pdf": {
|
|
960
|
-
extensions: ["pdf"]
|
|
961
|
-
},
|
|
962
|
-
"application/xml": {
|
|
963
|
-
extensions: ["xml"]
|
|
964
|
-
},
|
|
965
|
-
"application/x-gzip": {
|
|
966
|
-
extensions: ["gz"]
|
|
967
|
-
},
|
|
968
|
-
"application/wasm": {
|
|
969
|
-
extensions: ["wasm"]
|
|
970
|
-
},
|
|
971
|
-
"application/zip": {
|
|
972
|
-
extensions: ["zip"]
|
|
973
|
-
},
|
|
974
|
-
"audio/basic": {
|
|
975
|
-
extensions: ["au", "snd"]
|
|
976
|
-
},
|
|
977
|
-
"audio/mpeg": {
|
|
978
|
-
extensions: ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"]
|
|
979
|
-
},
|
|
980
|
-
"audio/midi": {
|
|
981
|
-
extensions: ["midi", "mid", "kar", "rmi"]
|
|
982
|
-
},
|
|
983
|
-
"audio/mp4": {
|
|
984
|
-
extensions: ["m4a", "mp4a"]
|
|
985
|
-
},
|
|
986
|
-
"audio/ogg": {
|
|
987
|
-
extensions: ["oga", "ogg", "spx"]
|
|
988
|
-
},
|
|
989
|
-
"audio/webm": {
|
|
990
|
-
extensions: ["weba"]
|
|
991
|
-
},
|
|
992
|
-
"audio/x-wav": {
|
|
993
|
-
extensions: ["wav"]
|
|
994
|
-
},
|
|
995
|
-
"font/ttf": {
|
|
996
|
-
extensions: ["ttf"]
|
|
997
|
-
},
|
|
998
|
-
"font/woff": {
|
|
999
|
-
extensions: ["woff"]
|
|
1000
|
-
},
|
|
1001
|
-
"font/woff2": {
|
|
1002
|
-
extensions: ["woff2"]
|
|
1003
|
-
},
|
|
1004
|
-
"image/png": {
|
|
1005
|
-
extensions: ["png"]
|
|
1006
|
-
},
|
|
1007
|
-
"image/gif": {
|
|
1008
|
-
extensions: ["gif"]
|
|
1009
|
-
},
|
|
1010
|
-
"image/jpeg": {
|
|
1011
|
-
extensions: ["jpg"]
|
|
1012
|
-
},
|
|
1013
|
-
"image/svg+xml": {
|
|
1014
|
-
extensions: ["svg", "svgz"]
|
|
1015
|
-
},
|
|
1016
|
-
"text/plain": {
|
|
1017
|
-
extensions: ["txt"]
|
|
1018
|
-
},
|
|
1019
|
-
"text/html": {
|
|
1020
|
-
extensions: ["html"]
|
|
1021
|
-
},
|
|
1022
|
-
"text/css": {
|
|
1023
|
-
extensions: ["css"]
|
|
1024
|
-
},
|
|
1025
|
-
"text/cache-manifest": {
|
|
1026
|
-
extensions: ["appcache"]
|
|
1027
|
-
},
|
|
1028
|
-
"video/mp4": {
|
|
1029
|
-
extensions: ["mp4", "mp4v", "mpg4"]
|
|
1030
|
-
},
|
|
1031
|
-
"video/mpeg": {
|
|
1032
|
-
extensions: ["mpeg", "mpg", "mpe", "m1v", "m2v"]
|
|
1033
|
-
},
|
|
1034
|
-
"video/ogg": {
|
|
1035
|
-
extensions: ["ogv"]
|
|
1036
|
-
},
|
|
1037
|
-
"video/webm": {
|
|
1038
|
-
extensions: ["webm"]
|
|
1039
|
-
}
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
// https://github.com/jshttp/mime-db/blob/master/src/apache-types.json
|
|
1043
|
-
const urlToContentType = (url, contentTypeMap = jsenvContentTypeMap, contentTypeDefault = "application/octet-stream") => {
|
|
1044
|
-
if (typeof contentTypeMap !== "object") {
|
|
1045
|
-
throw new TypeError(`contentTypeMap must be an object, got ${contentTypeMap}`);
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
const pathname = new URL(url).pathname;
|
|
1049
|
-
const extensionWithDot = path.extname(pathname);
|
|
1050
|
-
|
|
1051
|
-
if (!extensionWithDot || extensionWithDot === ".") {
|
|
1052
|
-
return contentTypeDefault;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
const extension = extensionWithDot.slice(1);
|
|
1056
|
-
const availableContentTypes = Object.keys(contentTypeMap);
|
|
1057
|
-
const contentTypeForExtension = availableContentTypes.find(contentTypeName => {
|
|
1058
|
-
const contentType = contentTypeMap[contentTypeName];
|
|
1059
|
-
return contentType.extensions && contentType.extensions.indexOf(extension) > -1;
|
|
1060
|
-
});
|
|
1061
|
-
return contentTypeForExtension || contentTypeDefault;
|
|
1062
|
-
};
|
|
1063
|
-
|
|
1064
|
-
const {
|
|
1065
|
-
readFile: readFile$1
|
|
1066
|
-
} = fs.promises;
|
|
1067
|
-
const serveFile = async (source, {
|
|
1068
|
-
cancellationToken = createCancellationToken(),
|
|
1069
|
-
method = "GET",
|
|
1070
|
-
headers = {},
|
|
1071
|
-
canReadDirectory = false,
|
|
1072
|
-
cacheStrategy = "etag",
|
|
1073
|
-
contentTypeMap = jsenvContentTypeMap
|
|
1074
|
-
} = {}) => {
|
|
1075
|
-
if (method !== "GET" && method !== "HEAD") {
|
|
1076
|
-
return {
|
|
1077
|
-
status: 501
|
|
1078
|
-
};
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
const sourceUrl = assertAndNormalizeFileUrl(source);
|
|
1082
|
-
const clientCacheDisabled = headers["cache-control"] === "no-cache";
|
|
1083
|
-
|
|
1084
|
-
try {
|
|
1085
|
-
const cacheWithMtime = !clientCacheDisabled && cacheStrategy === "mtime";
|
|
1086
|
-
const cacheWithETag = !clientCacheDisabled && cacheStrategy === "etag";
|
|
1087
|
-
const cachedDisabled = clientCacheDisabled || cacheStrategy === "none";
|
|
1088
|
-
const sourceStat = await createOperation({
|
|
1089
|
-
cancellationToken,
|
|
1090
|
-
start: () => readFileSystemNodeStat(sourceUrl)
|
|
1091
|
-
});
|
|
1092
|
-
|
|
1093
|
-
if (sourceStat.isDirectory()) {
|
|
1094
|
-
if (canReadDirectory === false) {
|
|
1095
|
-
return {
|
|
1096
|
-
status: 403,
|
|
1097
|
-
statusText: "not allowed to read directory",
|
|
1098
|
-
headers: { ...(cachedDisabled ? {
|
|
1099
|
-
"cache-control": "no-store"
|
|
1100
|
-
} : {})
|
|
1101
|
-
}
|
|
1102
|
-
};
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
const directoryContentArray = await createOperation({
|
|
1106
|
-
cancellationToken,
|
|
1107
|
-
start: () => readDirectory(sourceUrl)
|
|
1108
|
-
});
|
|
1109
|
-
const directoryContentJson = JSON.stringify(directoryContentArray);
|
|
1110
|
-
return {
|
|
1111
|
-
status: 200,
|
|
1112
|
-
headers: { ...(cachedDisabled ? {
|
|
1113
|
-
"cache-control": "no-store"
|
|
1114
|
-
} : {}),
|
|
1115
|
-
"content-type": "application/json",
|
|
1116
|
-
"content-length": directoryContentJson.length
|
|
1117
|
-
},
|
|
1118
|
-
body: directoryContentJson
|
|
1119
|
-
};
|
|
1120
|
-
} // not a file, give up
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
if (!sourceStat.isFile()) {
|
|
1124
|
-
return {
|
|
1125
|
-
status: 404,
|
|
1126
|
-
headers: { ...(cachedDisabled ? {
|
|
1127
|
-
"cache-control": "no-store"
|
|
1128
|
-
} : {})
|
|
1129
|
-
}
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
if (cacheWithETag) {
|
|
1134
|
-
const fileContentAsBuffer = await createOperation({
|
|
1135
|
-
cancellationToken,
|
|
1136
|
-
start: () => readFile$1(urlToFileSystemPath(sourceUrl))
|
|
1137
|
-
});
|
|
1138
|
-
const fileContentEtag = bufferToEtag(fileContentAsBuffer);
|
|
1139
|
-
|
|
1140
|
-
if ("if-none-match" in headers && headers["if-none-match"] === fileContentEtag) {
|
|
1141
|
-
return {
|
|
1142
|
-
status: 304,
|
|
1143
|
-
headers: { ...(cachedDisabled ? {
|
|
1144
|
-
"cache-control": "no-store"
|
|
1145
|
-
} : {})
|
|
1146
|
-
}
|
|
1147
|
-
};
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
return {
|
|
1151
|
-
status: 200,
|
|
1152
|
-
headers: { ...(cachedDisabled ? {
|
|
1153
|
-
"cache-control": "no-store"
|
|
1154
|
-
} : {}),
|
|
1155
|
-
"content-length": sourceStat.size,
|
|
1156
|
-
"content-type": urlToContentType(sourceUrl, contentTypeMap),
|
|
1157
|
-
"etag": fileContentEtag
|
|
1158
|
-
},
|
|
1159
|
-
body: fileContentAsBuffer
|
|
1160
|
-
};
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
if (cacheWithMtime && "if-modified-since" in headers) {
|
|
1164
|
-
let cachedModificationDate;
|
|
1165
|
-
|
|
1166
|
-
try {
|
|
1167
|
-
cachedModificationDate = new Date(headers["if-modified-since"]);
|
|
1168
|
-
} catch (e) {
|
|
1169
|
-
return {
|
|
1170
|
-
status: 400,
|
|
1171
|
-
statusText: "if-modified-since header is not a valid date"
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
const actualModificationDate = dateToSecondsPrecision(sourceStat.mtime);
|
|
1176
|
-
|
|
1177
|
-
if (Number(cachedModificationDate) >= Number(actualModificationDate)) {
|
|
1178
|
-
return {
|
|
1179
|
-
status: 304
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
return {
|
|
1185
|
-
status: 200,
|
|
1186
|
-
headers: { ...(cachedDisabled ? {
|
|
1187
|
-
"cache-control": "no-store"
|
|
1188
|
-
} : {}),
|
|
1189
|
-
...(cacheWithMtime ? {
|
|
1190
|
-
"last-modified": dateToUTCString(sourceStat.mtime)
|
|
1191
|
-
} : {}),
|
|
1192
|
-
"content-length": sourceStat.size,
|
|
1193
|
-
"content-type": urlToContentType(sourceUrl, contentTypeMap)
|
|
1194
|
-
},
|
|
1195
|
-
body: fs.createReadStream(urlToFileSystemPath(sourceUrl))
|
|
1196
|
-
};
|
|
1197
|
-
} catch (e) {
|
|
1198
|
-
return convertFileSystemErrorToResponseProperties(e);
|
|
1199
|
-
}
|
|
1200
|
-
}; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString
|
|
1201
|
-
|
|
1202
|
-
const dateToUTCString = date => date.toUTCString();
|
|
1203
|
-
|
|
1204
|
-
const dateToSecondsPrecision = date => {
|
|
1205
|
-
const dateWithSecondsPrecision = new Date(date);
|
|
1206
|
-
dateWithSecondsPrecision.setMilliseconds(0);
|
|
1207
|
-
return dateWithSecondsPrecision;
|
|
1208
|
-
};
|
|
1209
|
-
|
|
1210
|
-
const require$1 = module$1.createRequire(url);
|
|
1211
|
-
|
|
1212
|
-
const nodeFetch = require$1("node-fetch");
|
|
1213
|
-
|
|
1214
|
-
const AbortController = require$1("abort-controller");
|
|
1215
|
-
|
|
1216
|
-
const {
|
|
1217
|
-
Response
|
|
1218
|
-
} = nodeFetch;
|
|
1219
|
-
const fetchUrl = async (url, {
|
|
1220
|
-
cancellationToken = createCancellationToken(),
|
|
1221
|
-
simplified = false,
|
|
1222
|
-
ignoreHttpsError = false,
|
|
1223
|
-
canReadDirectory,
|
|
1224
|
-
contentTypeMap,
|
|
1225
|
-
cacheStrategy,
|
|
1226
|
-
...options
|
|
1227
|
-
} = {}) => {
|
|
1228
|
-
try {
|
|
1229
|
-
url = String(new URL(url));
|
|
1230
|
-
} catch (e) {
|
|
1231
|
-
throw new Error(`fetchUrl first argument must be an absolute url, received ${url}`);
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
if (url.startsWith("file://")) {
|
|
1235
|
-
const {
|
|
1236
|
-
status,
|
|
1237
|
-
statusText,
|
|
1238
|
-
headers,
|
|
1239
|
-
body
|
|
1240
|
-
} = await serveFile(url, {
|
|
1241
|
-
cancellationToken,
|
|
1242
|
-
cacheStrategy,
|
|
1243
|
-
canReadDirectory,
|
|
1244
|
-
contentTypeMap,
|
|
1245
|
-
...options
|
|
1246
|
-
});
|
|
1247
|
-
const response = new Response(typeof body === "string" ? Buffer.from(body) : body, {
|
|
1248
|
-
url,
|
|
1249
|
-
status,
|
|
1250
|
-
statusText,
|
|
1251
|
-
headers
|
|
1252
|
-
});
|
|
1253
|
-
return simplified ? standardResponseToSimplifiedResponse(response) : response;
|
|
1254
|
-
} // cancellation might be requested early, abortController does not support that
|
|
1255
|
-
// so we have to throw if requested right away
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
cancellationToken.throwIfRequested(); // https://github.com/bitinn/node-fetch#request-cancellation-with-abortsignal
|
|
1259
|
-
|
|
1260
|
-
const abortController = new AbortController();
|
|
1261
|
-
let cancelError;
|
|
1262
|
-
cancellationToken.register(reason => {
|
|
1263
|
-
cancelError = reason;
|
|
1264
|
-
abortController.abort(reason);
|
|
1265
|
-
});
|
|
1266
|
-
let response;
|
|
1267
|
-
|
|
1268
|
-
try {
|
|
1269
|
-
response = await nodeFetch(url, {
|
|
1270
|
-
signal: abortController.signal,
|
|
1271
|
-
...(ignoreHttpsError && url.startsWith("https") ? {
|
|
1272
|
-
agent: new https.Agent({
|
|
1273
|
-
rejectUnauthorized: false
|
|
1274
|
-
})
|
|
1275
|
-
} : {}),
|
|
1276
|
-
...options
|
|
1277
|
-
});
|
|
1278
|
-
} catch (e) {
|
|
1279
|
-
if (cancelError && e.name === "AbortError") {
|
|
1280
|
-
throw cancelError;
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
throw e;
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
return simplified ? standardResponseToSimplifiedResponse(response) : response;
|
|
1287
|
-
};
|
|
1288
|
-
|
|
1289
|
-
const standardResponseToSimplifiedResponse = async response => {
|
|
1290
|
-
const text = await response.text();
|
|
1291
|
-
return {
|
|
1292
|
-
url: response.url,
|
|
1293
|
-
status: response.status,
|
|
1294
|
-
statusText: response.statusText,
|
|
1295
|
-
headers: responseToHeaders(response),
|
|
1296
|
-
body: text
|
|
1297
|
-
};
|
|
1298
|
-
};
|
|
1299
|
-
|
|
1300
|
-
const responseToHeaders = response => {
|
|
1301
|
-
const headers = {};
|
|
1302
|
-
response.headers.forEach((value, name) => {
|
|
1303
|
-
headers[name] = value;
|
|
1304
|
-
});
|
|
1305
|
-
return headers;
|
|
1306
|
-
};
|
|
1307
|
-
|
|
1308
|
-
const require$2 = module$1.createRequire(url);
|
|
1309
|
-
|
|
1310
|
-
const killPort = require$2("kill-port");
|
|
1311
|
-
|
|
1312
|
-
// https://developer.github.com/v3/git/refs/#get-a-single-reference
|
|
1313
|
-
const getGithubRelease = async ({
|
|
1314
|
-
githubToken,
|
|
1315
|
-
githubRepositoryOwner,
|
|
1316
|
-
githubRepositoryName,
|
|
1317
|
-
githubReleaseName
|
|
1318
|
-
}) => {
|
|
1319
|
-
const requestUrl = `https://api.github.com/repos/${githubRepositoryOwner}/${githubRepositoryName}/git/ref/tags/${githubReleaseName}`;
|
|
1320
|
-
const response = await fetchUrl(requestUrl, {
|
|
1321
|
-
headers: {
|
|
1322
|
-
authorization: `token ${githubToken}`
|
|
1323
|
-
},
|
|
1324
|
-
method: "GET"
|
|
1325
|
-
});
|
|
1326
|
-
const responseStatus = response.status;
|
|
1327
|
-
|
|
1328
|
-
if (responseStatus === 404) {
|
|
1329
|
-
return null;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
if (responseStatus !== 200) {
|
|
1333
|
-
throw new Error(writeUnexpectedResponseStatus({
|
|
1334
|
-
requestUrl,
|
|
1335
|
-
responseStatus,
|
|
1336
|
-
responseText: await response.text()
|
|
1337
|
-
}));
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
const responseJson = await response.json();
|
|
1341
|
-
return responseJson;
|
|
1342
|
-
};
|
|
1343
|
-
|
|
1344
|
-
const writeUnexpectedResponseStatus = ({
|
|
1345
|
-
requestUrl,
|
|
1346
|
-
responseStatus,
|
|
1347
|
-
responseText
|
|
1348
|
-
}) => `github api response status should be 200.
|
|
1349
|
-
--- request url ----
|
|
1350
|
-
${requestUrl}
|
|
1351
|
-
--- response status ---
|
|
1352
|
-
${responseStatus}
|
|
1353
|
-
--- response text ---
|
|
1354
|
-
${responseText}`;
|
|
1355
|
-
|
|
1356
|
-
// https://developer.github.com/v3/git/tags/
|
|
1357
|
-
const createGithubRelease = async ({
|
|
1358
|
-
githubToken,
|
|
1359
|
-
githubRepositoryOwner,
|
|
1360
|
-
githubRepositoryName,
|
|
1361
|
-
githubSha,
|
|
1362
|
-
githubReleaseName
|
|
1363
|
-
}) => {
|
|
1364
|
-
const requestUrl = `https://api.github.com/repos/${githubRepositoryOwner}/${githubRepositoryName}/git/refs`;
|
|
1365
|
-
const body = JSON.stringify({
|
|
1366
|
-
ref: `refs/tags/${githubReleaseName}`,
|
|
1367
|
-
sha: githubSha
|
|
1368
|
-
});
|
|
1369
|
-
const response = await fetchUrl(requestUrl, {
|
|
1370
|
-
headers: {
|
|
1371
|
-
"authorization": `token ${githubToken}`,
|
|
1372
|
-
"content-length": Buffer.byteLength(body)
|
|
1373
|
-
},
|
|
1374
|
-
method: "POST",
|
|
1375
|
-
body
|
|
1376
|
-
});
|
|
1377
|
-
const responseStatus = response.status;
|
|
1378
|
-
|
|
1379
|
-
if (responseStatus !== 201) {
|
|
1380
|
-
throw new Error(writeUnexpectedResponseStatus$1({
|
|
1381
|
-
requestUrl,
|
|
1382
|
-
responseStatus,
|
|
1383
|
-
responseText: await response.text()
|
|
1384
|
-
}));
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
const responseJson = await response.json();
|
|
1388
|
-
return responseJson;
|
|
1389
|
-
};
|
|
1390
|
-
|
|
1391
|
-
const writeUnexpectedResponseStatus$1 = ({
|
|
1392
|
-
requestUrl,
|
|
1393
|
-
responseStatus,
|
|
1394
|
-
responseText
|
|
1395
|
-
}) => `github api response status should be 201.
|
|
1396
|
-
--- request url ----
|
|
1397
|
-
${requestUrl}
|
|
1398
|
-
--- response status ---
|
|
1399
|
-
${responseStatus}
|
|
1400
|
-
--- response text ---
|
|
1401
|
-
${responseText}`;
|
|
1402
|
-
|
|
1403
|
-
const ensureGithubReleaseForPackage = async ({
|
|
1404
|
-
cancellationToken = createCancellationTokenForProcess(),
|
|
1405
|
-
logLevel,
|
|
1406
|
-
projectDirectoryUrl,
|
|
1407
|
-
updateProcessExitCode = true
|
|
1408
|
-
}) => {
|
|
1409
|
-
return catchCancellation(async () => {
|
|
1410
|
-
const logger = createLogger({
|
|
1411
|
-
logLevel
|
|
1412
|
-
});
|
|
1413
|
-
logger.debug(`autoReleaseOnGithub(${JSON.stringify({
|
|
1414
|
-
projectDirectoryUrl,
|
|
1415
|
-
logLevel
|
|
1416
|
-
}, null, " ")})`);
|
|
1417
|
-
projectDirectoryUrl = assertAndNormalizeDirectoryUrl(projectDirectoryUrl);
|
|
1418
|
-
const {
|
|
1419
|
-
githubToken,
|
|
1420
|
-
githubRepositoryOwner,
|
|
1421
|
-
githubRepositoryName,
|
|
1422
|
-
githubSha
|
|
1423
|
-
} = getOptionsFromGithubAction();
|
|
1424
|
-
logger.debug(`reading project package.json`);
|
|
1425
|
-
const {
|
|
1426
|
-
packageVersion
|
|
1427
|
-
} = await getOptionsFromProjectPackage({
|
|
1428
|
-
projectDirectoryUrl
|
|
1429
|
-
});
|
|
1430
|
-
cancellationToken.throwIfRequested();
|
|
1431
|
-
logger.debug(`${packageVersion} found in package.json`);
|
|
1432
|
-
logger.debug(`search release for ${packageVersion} on github`);
|
|
1433
|
-
const githubReleaseName = `v${packageVersion}`;
|
|
1434
|
-
const existingRelease = await getGithubRelease({
|
|
1435
|
-
githubToken,
|
|
1436
|
-
githubRepositoryOwner,
|
|
1437
|
-
githubRepositoryName,
|
|
1438
|
-
githubReleaseName
|
|
1439
|
-
});
|
|
1440
|
-
cancellationToken.throwIfRequested();
|
|
1441
|
-
|
|
1442
|
-
if (existingRelease) {
|
|
1443
|
-
logger.info(`${packageVersion} already released at ${generateReleaseUrl({
|
|
1444
|
-
githubRepositoryOwner,
|
|
1445
|
-
githubRepositoryName,
|
|
1446
|
-
githubReleaseName
|
|
1447
|
-
})}`);
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
logger.info(`creating release for ${packageVersion}`);
|
|
1452
|
-
await createGithubRelease({
|
|
1453
|
-
githubToken,
|
|
1454
|
-
githubRepositoryOwner,
|
|
1455
|
-
githubRepositoryName,
|
|
1456
|
-
githubSha,
|
|
1457
|
-
githubReleaseName
|
|
1458
|
-
});
|
|
1459
|
-
logger.info(`release created at ${generateReleaseUrl({
|
|
1460
|
-
githubRepositoryOwner,
|
|
1461
|
-
githubRepositoryName,
|
|
1462
|
-
githubReleaseName
|
|
1463
|
-
})}`);
|
|
1464
|
-
}).catch(e => {
|
|
1465
|
-
if (updateProcessExitCode) {
|
|
1466
|
-
process.exitCode = 1;
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
throw e;
|
|
1470
|
-
});
|
|
1471
|
-
};
|
|
1472
|
-
|
|
1473
|
-
const generateReleaseUrl = ({
|
|
1474
|
-
githubRepositoryOwner,
|
|
1475
|
-
githubRepositoryName,
|
|
1476
|
-
githubReleaseName
|
|
1477
|
-
}) => {
|
|
1478
|
-
return `https://github.com/${githubRepositoryOwner}/${githubRepositoryName}/releases/tag/${githubReleaseName}`;
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
|
-
const getOptionsFromGithubAction = () => {
|
|
1482
|
-
const eventName = process.env.GITHUB_EVENT_NAME;
|
|
1483
|
-
|
|
1484
|
-
if (!eventName) {
|
|
1485
|
-
throw new Error(`missing process.env.GITHUB_EVENT_NAME, we are not in a github action`);
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
if (eventName !== "push") {
|
|
1489
|
-
throw new Error(`getOptionsFromGithubAction must be called only in a push action`);
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
const githubRepository = process.env.GITHUB_REPOSITORY;
|
|
1493
|
-
|
|
1494
|
-
if (!githubRepository) {
|
|
1495
|
-
throw new Error(`missing process.env.GITHUB_REPOSITORY`);
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
const [githubRepositoryOwner, githubRepositoryName] = githubRepository.split("/");
|
|
1499
|
-
const githubToken = process.env.GITHUB_TOKEN;
|
|
1500
|
-
|
|
1501
|
-
if (!githubToken) {
|
|
1502
|
-
throw new Error(`missing process.env.GITHUB_TOKEN`);
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
const githubSha = process.env.GITHUB_SHA;
|
|
1506
|
-
|
|
1507
|
-
if (!githubSha) {
|
|
1508
|
-
throw new Error(`missing process.env.GITHUB_SHA`);
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
return {
|
|
1512
|
-
githubRepositoryOwner,
|
|
1513
|
-
githubRepositoryName,
|
|
1514
|
-
githubToken,
|
|
1515
|
-
githubSha
|
|
1516
|
-
};
|
|
1517
|
-
};
|
|
1518
|
-
|
|
1519
|
-
const getOptionsFromProjectPackage = async ({
|
|
1520
|
-
projectDirectoryUrl
|
|
1521
|
-
}) => {
|
|
1522
|
-
const projectPackage = await readProjectPackage({
|
|
1523
|
-
projectDirectoryUrl
|
|
1524
|
-
});
|
|
1525
|
-
return {
|
|
1526
|
-
packageVersion: projectPackage.version
|
|
1527
|
-
};
|
|
1528
|
-
};
|
|
1529
|
-
|
|
1530
|
-
exports.ensureGithubReleaseForPackage = ensureGithubReleaseForPackage;
|
|
1531
|
-
//# sourceMappingURL=main.cjs.map
|