cache-extensions 1.1.1 → 1.7.0

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.
Files changed (72) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +154 -133
  3. package/lib/cache.d.ts +2 -0
  4. package/lib/cache.js +59 -0
  5. package/lib/cache.js.map +1 -0
  6. package/lib/utils.d.ts +3 -0
  7. package/lib/utils.js +44 -0
  8. package/lib/utils.js.map +1 -0
  9. package/package.json +66 -54
  10. package/src/cache.ts +44 -11
  11. package/src/lists/bionic-libs +768 -737
  12. package/src/lists/darwin-deps +1 -0
  13. package/src/lists/darwin-extensions +18 -0
  14. package/src/lists/focal-libs +788 -753
  15. package/src/lists/linux-deps +4 -0
  16. package/src/scripts/cache.sh +124 -0
  17. package/src/scripts/darwin.sh +189 -0
  18. package/src/scripts/linux.sh +117 -0
  19. package/src/utils.ts +30 -23
  20. package/.eslintrc.json +0 -23
  21. package/.github/CODE_OF_CONDUCT.md +0 -76
  22. package/.github/CONTRIBUTING.md +0 -63
  23. package/.github/FUNDING.yml +0 -5
  24. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
  25. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  26. package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
  27. package/.github/workflows/workflow.yml +0 -31
  28. package/.idea/cache-extensions.iml +0 -8
  29. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  30. package/.idea/misc.xml +0 -6
  31. package/.idea/modules.xml +0 -8
  32. package/.idea/vcs.xml +0 -6
  33. package/.idea/workspace.xml +0 -217
  34. package/.prettierrc.json +0 -12
  35. package/__tests__/cache.test.ts +0 -60
  36. package/__tests__/utils.test.ts +0 -25
  37. package/action.yml +0 -19
  38. package/dist/index.js +0 -1701
  39. package/jest.config.js +0 -12
  40. package/src/extensions.sh +0 -96
  41. package/src/lists/bionic-php5.3-extensions +0 -68
  42. package/src/lists/bionic-php5.4-extensions +0 -72
  43. package/src/lists/bionic-php5.5-extensions +0 -72
  44. package/src/lists/bionic-php5.6-extensions +0 -66
  45. package/src/lists/bionic-php7.0-extensions +0 -63
  46. package/src/lists/bionic-php7.1-extensions +0 -90
  47. package/src/lists/bionic-php7.2-extensions +0 -90
  48. package/src/lists/bionic-php7.3-extensions +0 -90
  49. package/src/lists/bionic-php7.4-extensions +0 -88
  50. package/src/lists/bionic-php8.0-extensions +0 -69
  51. package/src/lists/focal-php5.3-extensions +0 -64
  52. package/src/lists/focal-php5.4-extensions +0 -71
  53. package/src/lists/focal-php5.5-extensions +0 -71
  54. package/src/lists/focal-php5.6-extensions +0 -65
  55. package/src/lists/focal-php7.0-extensions +0 -62
  56. package/src/lists/focal-php7.1-extensions +0 -62
  57. package/src/lists/focal-php7.2-extensions +0 -63
  58. package/src/lists/focal-php7.3-extensions +0 -63
  59. package/src/lists/focal-php7.4-extensions +0 -54
  60. package/src/lists/focal-php8.0-extensions +0 -68
  61. package/src/lists/xenial-libs +0 -728
  62. package/src/lists/xenial-php5.3-extensions +0 -67
  63. package/src/lists/xenial-php5.4-extensions +0 -71
  64. package/src/lists/xenial-php5.5-extensions +0 -71
  65. package/src/lists/xenial-php5.6-extensions +0 -95
  66. package/src/lists/xenial-php7.0-extensions +0 -90
  67. package/src/lists/xenial-php7.1-extensions +0 -90
  68. package/src/lists/xenial-php7.2-extensions +0 -90
  69. package/src/lists/xenial-php7.3-extensions +0 -90
  70. package/src/lists/xenial-php7.4-extensions +0 -88
  71. package/src/lists/xenial-php8.0-extensions +0 -69
  72. package/tsconfig.json +0 -63
package/dist/index.js DELETED
@@ -1,1701 +0,0 @@
1
- module.exports =
2
- /******/ (function(modules, runtime) { // webpackBootstrap
3
- /******/ "use strict";
4
- /******/ // The module cache
5
- /******/ var installedModules = {};
6
- /******/
7
- /******/ // The require function
8
- /******/ function __webpack_require__(moduleId) {
9
- /******/
10
- /******/ // Check if module is in cache
11
- /******/ if(installedModules[moduleId]) {
12
- /******/ return installedModules[moduleId].exports;
13
- /******/ }
14
- /******/ // Create a new module (and put it into the cache)
15
- /******/ var module = installedModules[moduleId] = {
16
- /******/ i: moduleId,
17
- /******/ l: false,
18
- /******/ exports: {}
19
- /******/ };
20
- /******/
21
- /******/ // Execute the module function
22
- /******/ var threw = true;
23
- /******/ try {
24
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25
- /******/ threw = false;
26
- /******/ } finally {
27
- /******/ if(threw) delete installedModules[moduleId];
28
- /******/ }
29
- /******/
30
- /******/ // Flag the module as loaded
31
- /******/ module.l = true;
32
- /******/
33
- /******/ // Return the exports of the module
34
- /******/ return module.exports;
35
- /******/ }
36
- /******/
37
- /******/
38
- /******/ __webpack_require__.ab = __dirname + "/";
39
- /******/
40
- /******/ // the startup function
41
- /******/ function startup() {
42
- /******/ // Load entry module and return exports
43
- /******/ return __webpack_require__(722);
44
- /******/ };
45
- /******/
46
- /******/ // run startup
47
- /******/ return startup();
48
- /******/ })
49
- /************************************************************************/
50
- /******/ ({
51
-
52
- /***/ 1:
53
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
54
-
55
- "use strict";
56
-
57
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
58
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
59
- return new (P || (P = Promise))(function (resolve, reject) {
60
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
61
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
62
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
63
- step((generator = generator.apply(thisArg, _arguments || [])).next());
64
- });
65
- };
66
- Object.defineProperty(exports, "__esModule", { value: true });
67
- const childProcess = __webpack_require__(129);
68
- const path = __webpack_require__(622);
69
- const util_1 = __webpack_require__(669);
70
- const ioUtil = __webpack_require__(672);
71
- const exec = util_1.promisify(childProcess.exec);
72
- /**
73
- * Copies a file or folder.
74
- * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
75
- *
76
- * @param source source path
77
- * @param dest destination path
78
- * @param options optional. See CopyOptions.
79
- */
80
- function cp(source, dest, options = {}) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- const { force, recursive } = readCopyOptions(options);
83
- const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
84
- // Dest is an existing file, but not forcing
85
- if (destStat && destStat.isFile() && !force) {
86
- return;
87
- }
88
- // If dest is an existing directory, should copy inside.
89
- const newDest = destStat && destStat.isDirectory()
90
- ? path.join(dest, path.basename(source))
91
- : dest;
92
- if (!(yield ioUtil.exists(source))) {
93
- throw new Error(`no such file or directory: ${source}`);
94
- }
95
- const sourceStat = yield ioUtil.stat(source);
96
- if (sourceStat.isDirectory()) {
97
- if (!recursive) {
98
- throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
99
- }
100
- else {
101
- yield cpDirRecursive(source, newDest, 0, force);
102
- }
103
- }
104
- else {
105
- if (path.relative(source, newDest) === '') {
106
- // a file cannot be copied to itself
107
- throw new Error(`'${newDest}' and '${source}' are the same file`);
108
- }
109
- yield copyFile(source, newDest, force);
110
- }
111
- });
112
- }
113
- exports.cp = cp;
114
- /**
115
- * Moves a path.
116
- *
117
- * @param source source path
118
- * @param dest destination path
119
- * @param options optional. See MoveOptions.
120
- */
121
- function mv(source, dest, options = {}) {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- if (yield ioUtil.exists(dest)) {
124
- let destExists = true;
125
- if (yield ioUtil.isDirectory(dest)) {
126
- // If dest is directory copy src into dest
127
- dest = path.join(dest, path.basename(source));
128
- destExists = yield ioUtil.exists(dest);
129
- }
130
- if (destExists) {
131
- if (options.force == null || options.force) {
132
- yield rmRF(dest);
133
- }
134
- else {
135
- throw new Error('Destination already exists');
136
- }
137
- }
138
- }
139
- yield mkdirP(path.dirname(dest));
140
- yield ioUtil.rename(source, dest);
141
- });
142
- }
143
- exports.mv = mv;
144
- /**
145
- * Remove a path recursively with force
146
- *
147
- * @param inputPath path to remove
148
- */
149
- function rmRF(inputPath) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- if (ioUtil.IS_WINDOWS) {
152
- // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
153
- // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
154
- try {
155
- if (yield ioUtil.isDirectory(inputPath, true)) {
156
- yield exec(`rd /s /q "${inputPath}"`);
157
- }
158
- else {
159
- yield exec(`del /f /a "${inputPath}"`);
160
- }
161
- }
162
- catch (err) {
163
- // if you try to delete a file that doesn't exist, desired result is achieved
164
- // other errors are valid
165
- if (err.code !== 'ENOENT')
166
- throw err;
167
- }
168
- // Shelling out fails to remove a symlink folder with missing source, this unlink catches that
169
- try {
170
- yield ioUtil.unlink(inputPath);
171
- }
172
- catch (err) {
173
- // if you try to delete a file that doesn't exist, desired result is achieved
174
- // other errors are valid
175
- if (err.code !== 'ENOENT')
176
- throw err;
177
- }
178
- }
179
- else {
180
- let isDir = false;
181
- try {
182
- isDir = yield ioUtil.isDirectory(inputPath);
183
- }
184
- catch (err) {
185
- // if you try to delete a file that doesn't exist, desired result is achieved
186
- // other errors are valid
187
- if (err.code !== 'ENOENT')
188
- throw err;
189
- return;
190
- }
191
- if (isDir) {
192
- yield exec(`rm -rf "${inputPath}"`);
193
- }
194
- else {
195
- yield ioUtil.unlink(inputPath);
196
- }
197
- }
198
- });
199
- }
200
- exports.rmRF = rmRF;
201
- /**
202
- * Make a directory. Creates the full path with folders in between
203
- * Will throw if it fails
204
- *
205
- * @param fsPath path to create
206
- * @returns Promise<void>
207
- */
208
- function mkdirP(fsPath) {
209
- return __awaiter(this, void 0, void 0, function* () {
210
- yield ioUtil.mkdirP(fsPath);
211
- });
212
- }
213
- exports.mkdirP = mkdirP;
214
- /**
215
- * Returns path of a tool had the tool actually been invoked. Resolves via paths.
216
- * If you check and the tool does not exist, it will throw.
217
- *
218
- * @param tool name of the tool
219
- * @param check whether to check if tool exists
220
- * @returns Promise<string> path to tool
221
- */
222
- function which(tool, check) {
223
- return __awaiter(this, void 0, void 0, function* () {
224
- if (!tool) {
225
- throw new Error("parameter 'tool' is required");
226
- }
227
- // recursive when check=true
228
- if (check) {
229
- const result = yield which(tool, false);
230
- if (!result) {
231
- if (ioUtil.IS_WINDOWS) {
232
- throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
233
- }
234
- else {
235
- throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
236
- }
237
- }
238
- }
239
- try {
240
- // build the list of extensions to try
241
- const extensions = [];
242
- if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
243
- for (const extension of process.env.PATHEXT.split(path.delimiter)) {
244
- if (extension) {
245
- extensions.push(extension);
246
- }
247
- }
248
- }
249
- // if it's rooted, return it if exists. otherwise return empty.
250
- if (ioUtil.isRooted(tool)) {
251
- const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
252
- if (filePath) {
253
- return filePath;
254
- }
255
- return '';
256
- }
257
- // if any path separators, return empty
258
- if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
259
- return '';
260
- }
261
- // build the list of directories
262
- //
263
- // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
264
- // it feels like we should not do this. Checking the current directory seems like more of a use
265
- // case of a shell, and the which() function exposed by the toolkit should strive for consistency
266
- // across platforms.
267
- const directories = [];
268
- if (process.env.PATH) {
269
- for (const p of process.env.PATH.split(path.delimiter)) {
270
- if (p) {
271
- directories.push(p);
272
- }
273
- }
274
- }
275
- // return the first match
276
- for (const directory of directories) {
277
- const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
278
- if (filePath) {
279
- return filePath;
280
- }
281
- }
282
- return '';
283
- }
284
- catch (err) {
285
- throw new Error(`which failed with message ${err.message}`);
286
- }
287
- });
288
- }
289
- exports.which = which;
290
- function readCopyOptions(options) {
291
- const force = options.force == null ? true : options.force;
292
- const recursive = Boolean(options.recursive);
293
- return { force, recursive };
294
- }
295
- function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
296
- return __awaiter(this, void 0, void 0, function* () {
297
- // Ensure there is not a run away recursive copy
298
- if (currentDepth >= 255)
299
- return;
300
- currentDepth++;
301
- yield mkdirP(destDir);
302
- const files = yield ioUtil.readdir(sourceDir);
303
- for (const fileName of files) {
304
- const srcFile = `${sourceDir}/${fileName}`;
305
- const destFile = `${destDir}/${fileName}`;
306
- const srcFileStat = yield ioUtil.lstat(srcFile);
307
- if (srcFileStat.isDirectory()) {
308
- // Recurse
309
- yield cpDirRecursive(srcFile, destFile, currentDepth, force);
310
- }
311
- else {
312
- yield copyFile(srcFile, destFile, force);
313
- }
314
- }
315
- // Change the mode for the newly created directory
316
- yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
317
- });
318
- }
319
- // Buffered file copy
320
- function copyFile(srcFile, destFile, force) {
321
- return __awaiter(this, void 0, void 0, function* () {
322
- if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
323
- // unlink/re-link it
324
- try {
325
- yield ioUtil.lstat(destFile);
326
- yield ioUtil.unlink(destFile);
327
- }
328
- catch (e) {
329
- // Try to override file permission
330
- if (e.code === 'EPERM') {
331
- yield ioUtil.chmod(destFile, '0666');
332
- yield ioUtil.unlink(destFile);
333
- }
334
- // other errors = it doesn't exist, no work to do
335
- }
336
- // Copy over symlink
337
- const symlinkFull = yield ioUtil.readlink(srcFile);
338
- yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null);
339
- }
340
- else if (!(yield ioUtil.exists(destFile)) || force) {
341
- yield ioUtil.copyFile(srcFile, destFile);
342
- }
343
- });
344
- }
345
- //# sourceMappingURL=io.js.map
346
-
347
- /***/ }),
348
-
349
- /***/ 9:
350
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
351
-
352
- "use strict";
353
-
354
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
355
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
356
- return new (P || (P = Promise))(function (resolve, reject) {
357
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
358
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
359
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
360
- step((generator = generator.apply(thisArg, _arguments || [])).next());
361
- });
362
- };
363
- var __importStar = (this && this.__importStar) || function (mod) {
364
- if (mod && mod.__esModule) return mod;
365
- var result = {};
366
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
367
- result["default"] = mod;
368
- return result;
369
- };
370
- Object.defineProperty(exports, "__esModule", { value: true });
371
- const os = __importStar(__webpack_require__(87));
372
- const events = __importStar(__webpack_require__(614));
373
- const child = __importStar(__webpack_require__(129));
374
- const path = __importStar(__webpack_require__(622));
375
- const io = __importStar(__webpack_require__(1));
376
- const ioUtil = __importStar(__webpack_require__(672));
377
- /* eslint-disable @typescript-eslint/unbound-method */
378
- const IS_WINDOWS = process.platform === 'win32';
379
- /*
380
- * Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way.
381
- */
382
- class ToolRunner extends events.EventEmitter {
383
- constructor(toolPath, args, options) {
384
- super();
385
- if (!toolPath) {
386
- throw new Error("Parameter 'toolPath' cannot be null or empty.");
387
- }
388
- this.toolPath = toolPath;
389
- this.args = args || [];
390
- this.options = options || {};
391
- }
392
- _debug(message) {
393
- if (this.options.listeners && this.options.listeners.debug) {
394
- this.options.listeners.debug(message);
395
- }
396
- }
397
- _getCommandString(options, noPrefix) {
398
- const toolPath = this._getSpawnFileName();
399
- const args = this._getSpawnArgs(options);
400
- let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool
401
- if (IS_WINDOWS) {
402
- // Windows + cmd file
403
- if (this._isCmdFile()) {
404
- cmd += toolPath;
405
- for (const a of args) {
406
- cmd += ` ${a}`;
407
- }
408
- }
409
- // Windows + verbatim
410
- else if (options.windowsVerbatimArguments) {
411
- cmd += `"${toolPath}"`;
412
- for (const a of args) {
413
- cmd += ` ${a}`;
414
- }
415
- }
416
- // Windows (regular)
417
- else {
418
- cmd += this._windowsQuoteCmdArg(toolPath);
419
- for (const a of args) {
420
- cmd += ` ${this._windowsQuoteCmdArg(a)}`;
421
- }
422
- }
423
- }
424
- else {
425
- // OSX/Linux - this can likely be improved with some form of quoting.
426
- // creating processes on Unix is fundamentally different than Windows.
427
- // on Unix, execvp() takes an arg array.
428
- cmd += toolPath;
429
- for (const a of args) {
430
- cmd += ` ${a}`;
431
- }
432
- }
433
- return cmd;
434
- }
435
- _processLineBuffer(data, strBuffer, onLine) {
436
- try {
437
- let s = strBuffer + data.toString();
438
- let n = s.indexOf(os.EOL);
439
- while (n > -1) {
440
- const line = s.substring(0, n);
441
- onLine(line);
442
- // the rest of the string ...
443
- s = s.substring(n + os.EOL.length);
444
- n = s.indexOf(os.EOL);
445
- }
446
- strBuffer = s;
447
- }
448
- catch (err) {
449
- // streaming lines to console is best effort. Don't fail a build.
450
- this._debug(`error processing line. Failed with error ${err}`);
451
- }
452
- }
453
- _getSpawnFileName() {
454
- if (IS_WINDOWS) {
455
- if (this._isCmdFile()) {
456
- return process.env['COMSPEC'] || 'cmd.exe';
457
- }
458
- }
459
- return this.toolPath;
460
- }
461
- _getSpawnArgs(options) {
462
- if (IS_WINDOWS) {
463
- if (this._isCmdFile()) {
464
- let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
465
- for (const a of this.args) {
466
- argline += ' ';
467
- argline += options.windowsVerbatimArguments
468
- ? a
469
- : this._windowsQuoteCmdArg(a);
470
- }
471
- argline += '"';
472
- return [argline];
473
- }
474
- }
475
- return this.args;
476
- }
477
- _endsWith(str, end) {
478
- return str.endsWith(end);
479
- }
480
- _isCmdFile() {
481
- const upperToolPath = this.toolPath.toUpperCase();
482
- return (this._endsWith(upperToolPath, '.CMD') ||
483
- this._endsWith(upperToolPath, '.BAT'));
484
- }
485
- _windowsQuoteCmdArg(arg) {
486
- // for .exe, apply the normal quoting rules that libuv applies
487
- if (!this._isCmdFile()) {
488
- return this._uvQuoteCmdArg(arg);
489
- }
490
- // otherwise apply quoting rules specific to the cmd.exe command line parser.
491
- // the libuv rules are generic and are not designed specifically for cmd.exe
492
- // command line parser.
493
- //
494
- // for a detailed description of the cmd.exe command line parser, refer to
495
- // http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
496
- // need quotes for empty arg
497
- if (!arg) {
498
- return '""';
499
- }
500
- // determine whether the arg needs to be quoted
501
- const cmdSpecialChars = [
502
- ' ',
503
- '\t',
504
- '&',
505
- '(',
506
- ')',
507
- '[',
508
- ']',
509
- '{',
510
- '}',
511
- '^',
512
- '=',
513
- ';',
514
- '!',
515
- "'",
516
- '+',
517
- ',',
518
- '`',
519
- '~',
520
- '|',
521
- '<',
522
- '>',
523
- '"'
524
- ];
525
- let needsQuotes = false;
526
- for (const char of arg) {
527
- if (cmdSpecialChars.some(x => x === char)) {
528
- needsQuotes = true;
529
- break;
530
- }
531
- }
532
- // short-circuit if quotes not needed
533
- if (!needsQuotes) {
534
- return arg;
535
- }
536
- // the following quoting rules are very similar to the rules that by libuv applies.
537
- //
538
- // 1) wrap the string in quotes
539
- //
540
- // 2) double-up quotes - i.e. " => ""
541
- //
542
- // this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
543
- // doesn't work well with a cmd.exe command line.
544
- //
545
- // note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
546
- // for example, the command line:
547
- // foo.exe "myarg:""my val"""
548
- // is parsed by a .NET console app into an arg array:
549
- // [ "myarg:\"my val\"" ]
550
- // which is the same end result when applying libuv quoting rules. although the actual
551
- // command line from libuv quoting rules would look like:
552
- // foo.exe "myarg:\"my val\""
553
- //
554
- // 3) double-up slashes that precede a quote,
555
- // e.g. hello \world => "hello \world"
556
- // hello\"world => "hello\\""world"
557
- // hello\\"world => "hello\\\\""world"
558
- // hello world\ => "hello world\\"
559
- //
560
- // technically this is not required for a cmd.exe command line, or the batch argument parser.
561
- // the reasons for including this as a .cmd quoting rule are:
562
- //
563
- // a) this is optimized for the scenario where the argument is passed from the .cmd file to an
564
- // external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
565
- //
566
- // b) it's what we've been doing previously (by deferring to node default behavior) and we
567
- // haven't heard any complaints about that aspect.
568
- //
569
- // note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
570
- // escaped when used on the command line directly - even though within a .cmd file % can be escaped
571
- // by using %%.
572
- //
573
- // the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
574
- // the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
575
- //
576
- // one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
577
- // often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
578
- // variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
579
- // to an external program.
580
- //
581
- // an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
582
- // % can be escaped within a .cmd file.
583
- let reverse = '"';
584
- let quoteHit = true;
585
- for (let i = arg.length; i > 0; i--) {
586
- // walk the string in reverse
587
- reverse += arg[i - 1];
588
- if (quoteHit && arg[i - 1] === '\\') {
589
- reverse += '\\'; // double the slash
590
- }
591
- else if (arg[i - 1] === '"') {
592
- quoteHit = true;
593
- reverse += '"'; // double the quote
594
- }
595
- else {
596
- quoteHit = false;
597
- }
598
- }
599
- reverse += '"';
600
- return reverse
601
- .split('')
602
- .reverse()
603
- .join('');
604
- }
605
- _uvQuoteCmdArg(arg) {
606
- // Tool runner wraps child_process.spawn() and needs to apply the same quoting as
607
- // Node in certain cases where the undocumented spawn option windowsVerbatimArguments
608
- // is used.
609
- //
610
- // Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
611
- // see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
612
- // pasting copyright notice from Node within this function:
613
- //
614
- // Copyright Joyent, Inc. and other Node contributors. All rights reserved.
615
- //
616
- // Permission is hereby granted, free of charge, to any person obtaining a copy
617
- // of this software and associated documentation files (the "Software"), to
618
- // deal in the Software without restriction, including without limitation the
619
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
620
- // sell copies of the Software, and to permit persons to whom the Software is
621
- // furnished to do so, subject to the following conditions:
622
- //
623
- // The above copyright notice and this permission notice shall be included in
624
- // all copies or substantial portions of the Software.
625
- //
626
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
627
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
628
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
629
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
630
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
631
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
632
- // IN THE SOFTWARE.
633
- if (!arg) {
634
- // Need double quotation for empty argument
635
- return '""';
636
- }
637
- if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) {
638
- // No quotation needed
639
- return arg;
640
- }
641
- if (!arg.includes('"') && !arg.includes('\\')) {
642
- // No embedded double quotes or backslashes, so I can just wrap
643
- // quote marks around the whole thing.
644
- return `"${arg}"`;
645
- }
646
- // Expected input/output:
647
- // input : hello"world
648
- // output: "hello\"world"
649
- // input : hello""world
650
- // output: "hello\"\"world"
651
- // input : hello\world
652
- // output: hello\world
653
- // input : hello\\world
654
- // output: hello\\world
655
- // input : hello\"world
656
- // output: "hello\\\"world"
657
- // input : hello\\"world
658
- // output: "hello\\\\\"world"
659
- // input : hello world\
660
- // output: "hello world\\" - note the comment in libuv actually reads "hello world\"
661
- // but it appears the comment is wrong, it should be "hello world\\"
662
- let reverse = '"';
663
- let quoteHit = true;
664
- for (let i = arg.length; i > 0; i--) {
665
- // walk the string in reverse
666
- reverse += arg[i - 1];
667
- if (quoteHit && arg[i - 1] === '\\') {
668
- reverse += '\\';
669
- }
670
- else if (arg[i - 1] === '"') {
671
- quoteHit = true;
672
- reverse += '\\';
673
- }
674
- else {
675
- quoteHit = false;
676
- }
677
- }
678
- reverse += '"';
679
- return reverse
680
- .split('')
681
- .reverse()
682
- .join('');
683
- }
684
- _cloneExecOptions(options) {
685
- options = options || {};
686
- const result = {
687
- cwd: options.cwd || process.cwd(),
688
- env: options.env || process.env,
689
- silent: options.silent || false,
690
- windowsVerbatimArguments: options.windowsVerbatimArguments || false,
691
- failOnStdErr: options.failOnStdErr || false,
692
- ignoreReturnCode: options.ignoreReturnCode || false,
693
- delay: options.delay || 10000
694
- };
695
- result.outStream = options.outStream || process.stdout;
696
- result.errStream = options.errStream || process.stderr;
697
- return result;
698
- }
699
- _getSpawnOptions(options, toolPath) {
700
- options = options || {};
701
- const result = {};
702
- result.cwd = options.cwd;
703
- result.env = options.env;
704
- result['windowsVerbatimArguments'] =
705
- options.windowsVerbatimArguments || this._isCmdFile();
706
- if (options.windowsVerbatimArguments) {
707
- result.argv0 = `"${toolPath}"`;
708
- }
709
- return result;
710
- }
711
- /**
712
- * Exec a tool.
713
- * Output will be streamed to the live console.
714
- * Returns promise with return code
715
- *
716
- * @param tool path to tool to exec
717
- * @param options optional exec options. See ExecOptions
718
- * @returns number
719
- */
720
- exec() {
721
- return __awaiter(this, void 0, void 0, function* () {
722
- // root the tool path if it is unrooted and contains relative pathing
723
- if (!ioUtil.isRooted(this.toolPath) &&
724
- (this.toolPath.includes('/') ||
725
- (IS_WINDOWS && this.toolPath.includes('\\')))) {
726
- // prefer options.cwd if it is specified, however options.cwd may also need to be rooted
727
- this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
728
- }
729
- // if the tool is only a file name, then resolve it from the PATH
730
- // otherwise verify it exists (add extension on Windows if necessary)
731
- this.toolPath = yield io.which(this.toolPath, true);
732
- return new Promise((resolve, reject) => {
733
- this._debug(`exec tool: ${this.toolPath}`);
734
- this._debug('arguments:');
735
- for (const arg of this.args) {
736
- this._debug(` ${arg}`);
737
- }
738
- const optionsNonNull = this._cloneExecOptions(this.options);
739
- if (!optionsNonNull.silent && optionsNonNull.outStream) {
740
- optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
741
- }
742
- const state = new ExecState(optionsNonNull, this.toolPath);
743
- state.on('debug', (message) => {
744
- this._debug(message);
745
- });
746
- const fileName = this._getSpawnFileName();
747
- const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
748
- const stdbuffer = '';
749
- if (cp.stdout) {
750
- cp.stdout.on('data', (data) => {
751
- if (this.options.listeners && this.options.listeners.stdout) {
752
- this.options.listeners.stdout(data);
753
- }
754
- if (!optionsNonNull.silent && optionsNonNull.outStream) {
755
- optionsNonNull.outStream.write(data);
756
- }
757
- this._processLineBuffer(data, stdbuffer, (line) => {
758
- if (this.options.listeners && this.options.listeners.stdline) {
759
- this.options.listeners.stdline(line);
760
- }
761
- });
762
- });
763
- }
764
- const errbuffer = '';
765
- if (cp.stderr) {
766
- cp.stderr.on('data', (data) => {
767
- state.processStderr = true;
768
- if (this.options.listeners && this.options.listeners.stderr) {
769
- this.options.listeners.stderr(data);
770
- }
771
- if (!optionsNonNull.silent &&
772
- optionsNonNull.errStream &&
773
- optionsNonNull.outStream) {
774
- const s = optionsNonNull.failOnStdErr
775
- ? optionsNonNull.errStream
776
- : optionsNonNull.outStream;
777
- s.write(data);
778
- }
779
- this._processLineBuffer(data, errbuffer, (line) => {
780
- if (this.options.listeners && this.options.listeners.errline) {
781
- this.options.listeners.errline(line);
782
- }
783
- });
784
- });
785
- }
786
- cp.on('error', (err) => {
787
- state.processError = err.message;
788
- state.processExited = true;
789
- state.processClosed = true;
790
- state.CheckComplete();
791
- });
792
- cp.on('exit', (code) => {
793
- state.processExitCode = code;
794
- state.processExited = true;
795
- this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
796
- state.CheckComplete();
797
- });
798
- cp.on('close', (code) => {
799
- state.processExitCode = code;
800
- state.processExited = true;
801
- state.processClosed = true;
802
- this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
803
- state.CheckComplete();
804
- });
805
- state.on('done', (error, exitCode) => {
806
- if (stdbuffer.length > 0) {
807
- this.emit('stdline', stdbuffer);
808
- }
809
- if (errbuffer.length > 0) {
810
- this.emit('errline', errbuffer);
811
- }
812
- cp.removeAllListeners();
813
- if (error) {
814
- reject(error);
815
- }
816
- else {
817
- resolve(exitCode);
818
- }
819
- });
820
- if (this.options.input) {
821
- if (!cp.stdin) {
822
- throw new Error('child process missing stdin');
823
- }
824
- cp.stdin.end(this.options.input);
825
- }
826
- });
827
- });
828
- }
829
- }
830
- exports.ToolRunner = ToolRunner;
831
- /**
832
- * Convert an arg string to an array of args. Handles escaping
833
- *
834
- * @param argString string of arguments
835
- * @returns string[] array of arguments
836
- */
837
- function argStringToArray(argString) {
838
- const args = [];
839
- let inQuotes = false;
840
- let escaped = false;
841
- let arg = '';
842
- function append(c) {
843
- // we only escape double quotes.
844
- if (escaped && c !== '"') {
845
- arg += '\\';
846
- }
847
- arg += c;
848
- escaped = false;
849
- }
850
- for (let i = 0; i < argString.length; i++) {
851
- const c = argString.charAt(i);
852
- if (c === '"') {
853
- if (!escaped) {
854
- inQuotes = !inQuotes;
855
- }
856
- else {
857
- append(c);
858
- }
859
- continue;
860
- }
861
- if (c === '\\' && escaped) {
862
- append(c);
863
- continue;
864
- }
865
- if (c === '\\' && inQuotes) {
866
- escaped = true;
867
- continue;
868
- }
869
- if (c === ' ' && !inQuotes) {
870
- if (arg.length > 0) {
871
- args.push(arg);
872
- arg = '';
873
- }
874
- continue;
875
- }
876
- append(c);
877
- }
878
- if (arg.length > 0) {
879
- args.push(arg.trim());
880
- }
881
- return args;
882
- }
883
- exports.argStringToArray = argStringToArray;
884
- class ExecState extends events.EventEmitter {
885
- constructor(options, toolPath) {
886
- super();
887
- this.processClosed = false; // tracks whether the process has exited and stdio is closed
888
- this.processError = '';
889
- this.processExitCode = 0;
890
- this.processExited = false; // tracks whether the process has exited
891
- this.processStderr = false; // tracks whether stderr was written to
892
- this.delay = 10000; // 10 seconds
893
- this.done = false;
894
- this.timeout = null;
895
- if (!toolPath) {
896
- throw new Error('toolPath must not be empty');
897
- }
898
- this.options = options;
899
- this.toolPath = toolPath;
900
- if (options.delay) {
901
- this.delay = options.delay;
902
- }
903
- }
904
- CheckComplete() {
905
- if (this.done) {
906
- return;
907
- }
908
- if (this.processClosed) {
909
- this._setResult();
910
- }
911
- else if (this.processExited) {
912
- this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
913
- }
914
- }
915
- _debug(message) {
916
- this.emit('debug', message);
917
- }
918
- _setResult() {
919
- // determine whether there is an error
920
- let error;
921
- if (this.processExited) {
922
- if (this.processError) {
923
- error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
924
- }
925
- else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
926
- error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
927
- }
928
- else if (this.processStderr && this.options.failOnStdErr) {
929
- error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
930
- }
931
- }
932
- // clear the timeout
933
- if (this.timeout) {
934
- clearTimeout(this.timeout);
935
- this.timeout = null;
936
- }
937
- this.done = true;
938
- this.emit('done', error, this.processExitCode);
939
- }
940
- static HandleTimeout(state) {
941
- if (state.done) {
942
- return;
943
- }
944
- if (!state.processClosed && state.processExited) {
945
- const message = `The STDIO streams did not close within ${state.delay /
946
- 1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
947
- state._debug(message);
948
- }
949
- state._setResult();
950
- }
951
- }
952
- //# sourceMappingURL=toolrunner.js.map
953
-
954
- /***/ }),
955
-
956
- /***/ 87:
957
- /***/ (function(module) {
958
-
959
- module.exports = require("os");
960
-
961
- /***/ }),
962
-
963
- /***/ 129:
964
- /***/ (function(module) {
965
-
966
- module.exports = require("child_process");
967
-
968
- /***/ }),
969
-
970
- /***/ 163:
971
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
972
-
973
- "use strict";
974
-
975
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
976
- if (k2 === undefined) k2 = k;
977
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
978
- }) : (function(o, m, k, k2) {
979
- if (k2 === undefined) k2 = k;
980
- o[k2] = m[k];
981
- }));
982
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
983
- Object.defineProperty(o, "default", { enumerable: true, value: v });
984
- }) : function(o, v) {
985
- o["default"] = v;
986
- });
987
- var __importStar = (this && this.__importStar) || function (mod) {
988
- if (mod && mod.__esModule) return mod;
989
- var result = {};
990
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
991
- __setModuleDefault(result, mod);
992
- return result;
993
- };
994
- Object.defineProperty(exports, "__esModule", { value: true });
995
- exports.filterExtensions = exports.getInput = void 0;
996
- const core = __importStar(__webpack_require__(470));
997
- /**
998
- * Function to get inputs from both with and env annotations.
999
- *
1000
- * @param name
1001
- * @param mandatory
1002
- */
1003
- async function getInput(name, mandatory) {
1004
- const input = process.env[name];
1005
- switch (input) {
1006
- case '':
1007
- case undefined:
1008
- return core.getInput(name, { required: mandatory });
1009
- default:
1010
- return input;
1011
- }
1012
- }
1013
- exports.getInput = getInput;
1014
- /**
1015
- * Function to filter extensions
1016
- *
1017
- * @param extension_csv
1018
- */
1019
- async function filterExtensions(extension_csv) {
1020
- return extension_csv
1021
- .split(',')
1022
- .filter(extension => {
1023
- return extension.trim()[0] != ':';
1024
- })
1025
- .join(',');
1026
- }
1027
- exports.filterExtensions = filterExtensions;
1028
-
1029
-
1030
- /***/ }),
1031
-
1032
- /***/ 357:
1033
- /***/ (function(module) {
1034
-
1035
- module.exports = require("assert");
1036
-
1037
- /***/ }),
1038
-
1039
- /***/ 431:
1040
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
1041
-
1042
- "use strict";
1043
-
1044
- var __importStar = (this && this.__importStar) || function (mod) {
1045
- if (mod && mod.__esModule) return mod;
1046
- var result = {};
1047
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1048
- result["default"] = mod;
1049
- return result;
1050
- };
1051
- Object.defineProperty(exports, "__esModule", { value: true });
1052
- const os = __importStar(__webpack_require__(87));
1053
- /**
1054
- * Commands
1055
- *
1056
- * Command Format:
1057
- * ::name key=value,key=value::message
1058
- *
1059
- * Examples:
1060
- * ::warning::This is the message
1061
- * ::set-env name=MY_VAR::some value
1062
- */
1063
- function issueCommand(command, properties, message) {
1064
- const cmd = new Command(command, properties, message);
1065
- process.stdout.write(cmd.toString() + os.EOL);
1066
- }
1067
- exports.issueCommand = issueCommand;
1068
- function issue(name, message = '') {
1069
- issueCommand(name, {}, message);
1070
- }
1071
- exports.issue = issue;
1072
- const CMD_STRING = '::';
1073
- class Command {
1074
- constructor(command, properties, message) {
1075
- if (!command) {
1076
- command = 'missing.command';
1077
- }
1078
- this.command = command;
1079
- this.properties = properties;
1080
- this.message = message;
1081
- }
1082
- toString() {
1083
- let cmdStr = CMD_STRING + this.command;
1084
- if (this.properties && Object.keys(this.properties).length > 0) {
1085
- cmdStr += ' ';
1086
- let first = true;
1087
- for (const key in this.properties) {
1088
- if (this.properties.hasOwnProperty(key)) {
1089
- const val = this.properties[key];
1090
- if (val) {
1091
- if (first) {
1092
- first = false;
1093
- }
1094
- else {
1095
- cmdStr += ',';
1096
- }
1097
- cmdStr += `${key}=${escapeProperty(val)}`;
1098
- }
1099
- }
1100
- }
1101
- }
1102
- cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
1103
- return cmdStr;
1104
- }
1105
- }
1106
- /**
1107
- * Sanitizes an input into a string so it can be passed into issueCommand safely
1108
- * @param input input to sanitize into a string
1109
- */
1110
- function toCommandValue(input) {
1111
- if (input === null || input === undefined) {
1112
- return '';
1113
- }
1114
- else if (typeof input === 'string' || input instanceof String) {
1115
- return input;
1116
- }
1117
- return JSON.stringify(input);
1118
- }
1119
- exports.toCommandValue = toCommandValue;
1120
- function escapeData(s) {
1121
- return toCommandValue(s)
1122
- .replace(/%/g, '%25')
1123
- .replace(/\r/g, '%0D')
1124
- .replace(/\n/g, '%0A');
1125
- }
1126
- function escapeProperty(s) {
1127
- return toCommandValue(s)
1128
- .replace(/%/g, '%25')
1129
- .replace(/\r/g, '%0D')
1130
- .replace(/\n/g, '%0A')
1131
- .replace(/:/g, '%3A')
1132
- .replace(/,/g, '%2C');
1133
- }
1134
- //# sourceMappingURL=command.js.map
1135
-
1136
- /***/ }),
1137
-
1138
- /***/ 470:
1139
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
1140
-
1141
- "use strict";
1142
-
1143
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1144
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1145
- return new (P || (P = Promise))(function (resolve, reject) {
1146
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1147
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1148
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1149
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1150
- });
1151
- };
1152
- var __importStar = (this && this.__importStar) || function (mod) {
1153
- if (mod && mod.__esModule) return mod;
1154
- var result = {};
1155
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1156
- result["default"] = mod;
1157
- return result;
1158
- };
1159
- Object.defineProperty(exports, "__esModule", { value: true });
1160
- const command_1 = __webpack_require__(431);
1161
- const os = __importStar(__webpack_require__(87));
1162
- const path = __importStar(__webpack_require__(622));
1163
- /**
1164
- * The code to exit an action
1165
- */
1166
- var ExitCode;
1167
- (function (ExitCode) {
1168
- /**
1169
- * A code indicating that the action was successful
1170
- */
1171
- ExitCode[ExitCode["Success"] = 0] = "Success";
1172
- /**
1173
- * A code indicating that the action was a failure
1174
- */
1175
- ExitCode[ExitCode["Failure"] = 1] = "Failure";
1176
- })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
1177
- //-----------------------------------------------------------------------
1178
- // Variables
1179
- //-----------------------------------------------------------------------
1180
- /**
1181
- * Sets env variable for this action and future actions in the job
1182
- * @param name the name of the variable to set
1183
- * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
1184
- */
1185
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1186
- function exportVariable(name, val) {
1187
- const convertedVal = command_1.toCommandValue(val);
1188
- process.env[name] = convertedVal;
1189
- command_1.issueCommand('set-env', { name }, convertedVal);
1190
- }
1191
- exports.exportVariable = exportVariable;
1192
- /**
1193
- * Registers a secret which will get masked from logs
1194
- * @param secret value of the secret
1195
- */
1196
- function setSecret(secret) {
1197
- command_1.issueCommand('add-mask', {}, secret);
1198
- }
1199
- exports.setSecret = setSecret;
1200
- /**
1201
- * Prepends inputPath to the PATH (for this action and future actions)
1202
- * @param inputPath
1203
- */
1204
- function addPath(inputPath) {
1205
- command_1.issueCommand('add-path', {}, inputPath);
1206
- process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
1207
- }
1208
- exports.addPath = addPath;
1209
- /**
1210
- * Gets the value of an input. The value is also trimmed.
1211
- *
1212
- * @param name name of the input to get
1213
- * @param options optional. See InputOptions.
1214
- * @returns string
1215
- */
1216
- function getInput(name, options) {
1217
- const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
1218
- if (options && options.required && !val) {
1219
- throw new Error(`Input required and not supplied: ${name}`);
1220
- }
1221
- return val.trim();
1222
- }
1223
- exports.getInput = getInput;
1224
- /**
1225
- * Sets the value of an output.
1226
- *
1227
- * @param name name of the output to set
1228
- * @param value value to store. Non-string values will be converted to a string via JSON.stringify
1229
- */
1230
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1231
- function setOutput(name, value) {
1232
- command_1.issueCommand('set-output', { name }, value);
1233
- }
1234
- exports.setOutput = setOutput;
1235
- /**
1236
- * Enables or disables the echoing of commands into stdout for the rest of the step.
1237
- * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
1238
- *
1239
- */
1240
- function setCommandEcho(enabled) {
1241
- command_1.issue('echo', enabled ? 'on' : 'off');
1242
- }
1243
- exports.setCommandEcho = setCommandEcho;
1244
- //-----------------------------------------------------------------------
1245
- // Results
1246
- //-----------------------------------------------------------------------
1247
- /**
1248
- * Sets the action status to failed.
1249
- * When the action exits it will be with an exit code of 1
1250
- * @param message add error issue message
1251
- */
1252
- function setFailed(message) {
1253
- process.exitCode = ExitCode.Failure;
1254
- error(message);
1255
- }
1256
- exports.setFailed = setFailed;
1257
- //-----------------------------------------------------------------------
1258
- // Logging Commands
1259
- //-----------------------------------------------------------------------
1260
- /**
1261
- * Gets whether Actions Step Debug is on or not
1262
- */
1263
- function isDebug() {
1264
- return process.env['RUNNER_DEBUG'] === '1';
1265
- }
1266
- exports.isDebug = isDebug;
1267
- /**
1268
- * Writes debug message to user log
1269
- * @param message debug message
1270
- */
1271
- function debug(message) {
1272
- command_1.issueCommand('debug', {}, message);
1273
- }
1274
- exports.debug = debug;
1275
- /**
1276
- * Adds an error issue
1277
- * @param message error issue message. Errors will be converted to string via toString()
1278
- */
1279
- function error(message) {
1280
- command_1.issue('error', message instanceof Error ? message.toString() : message);
1281
- }
1282
- exports.error = error;
1283
- /**
1284
- * Adds an warning issue
1285
- * @param message warning issue message. Errors will be converted to string via toString()
1286
- */
1287
- function warning(message) {
1288
- command_1.issue('warning', message instanceof Error ? message.toString() : message);
1289
- }
1290
- exports.warning = warning;
1291
- /**
1292
- * Writes info to log with console.log.
1293
- * @param message info message
1294
- */
1295
- function info(message) {
1296
- process.stdout.write(message + os.EOL);
1297
- }
1298
- exports.info = info;
1299
- /**
1300
- * Begin an output group.
1301
- *
1302
- * Output until the next `groupEnd` will be foldable in this group
1303
- *
1304
- * @param name The name of the output group
1305
- */
1306
- function startGroup(name) {
1307
- command_1.issue('group', name);
1308
- }
1309
- exports.startGroup = startGroup;
1310
- /**
1311
- * End an output group.
1312
- */
1313
- function endGroup() {
1314
- command_1.issue('endgroup');
1315
- }
1316
- exports.endGroup = endGroup;
1317
- /**
1318
- * Wrap an asynchronous function call in a group.
1319
- *
1320
- * Returns the same type as the function itself.
1321
- *
1322
- * @param name The name of the group
1323
- * @param fn The function to wrap in the group
1324
- */
1325
- function group(name, fn) {
1326
- return __awaiter(this, void 0, void 0, function* () {
1327
- startGroup(name);
1328
- let result;
1329
- try {
1330
- result = yield fn();
1331
- }
1332
- finally {
1333
- endGroup();
1334
- }
1335
- return result;
1336
- });
1337
- }
1338
- exports.group = group;
1339
- //-----------------------------------------------------------------------
1340
- // Wrapper action state
1341
- //-----------------------------------------------------------------------
1342
- /**
1343
- * Saves state for current action, the state can only be retrieved by this action's post job execution.
1344
- *
1345
- * @param name name of the state to store
1346
- * @param value value to store. Non-string values will be converted to a string via JSON.stringify
1347
- */
1348
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1349
- function saveState(name, value) {
1350
- command_1.issueCommand('save-state', { name }, value);
1351
- }
1352
- exports.saveState = saveState;
1353
- /**
1354
- * Gets the value of an state set by this action's main execution.
1355
- *
1356
- * @param name name of the state to get
1357
- * @returns string
1358
- */
1359
- function getState(name) {
1360
- return process.env[`STATE_${name}`] || '';
1361
- }
1362
- exports.getState = getState;
1363
- //# sourceMappingURL=core.js.map
1364
-
1365
- /***/ }),
1366
-
1367
- /***/ 614:
1368
- /***/ (function(module) {
1369
-
1370
- module.exports = require("events");
1371
-
1372
- /***/ }),
1373
-
1374
- /***/ 622:
1375
- /***/ (function(module) {
1376
-
1377
- module.exports = require("path");
1378
-
1379
- /***/ }),
1380
-
1381
- /***/ 669:
1382
- /***/ (function(module) {
1383
-
1384
- module.exports = require("util");
1385
-
1386
- /***/ }),
1387
-
1388
- /***/ 672:
1389
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
1390
-
1391
- "use strict";
1392
-
1393
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1394
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1395
- return new (P || (P = Promise))(function (resolve, reject) {
1396
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1397
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1398
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1399
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1400
- });
1401
- };
1402
- var _a;
1403
- Object.defineProperty(exports, "__esModule", { value: true });
1404
- const assert_1 = __webpack_require__(357);
1405
- const fs = __webpack_require__(747);
1406
- const path = __webpack_require__(622);
1407
- _a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
1408
- exports.IS_WINDOWS = process.platform === 'win32';
1409
- function exists(fsPath) {
1410
- return __awaiter(this, void 0, void 0, function* () {
1411
- try {
1412
- yield exports.stat(fsPath);
1413
- }
1414
- catch (err) {
1415
- if (err.code === 'ENOENT') {
1416
- return false;
1417
- }
1418
- throw err;
1419
- }
1420
- return true;
1421
- });
1422
- }
1423
- exports.exists = exists;
1424
- function isDirectory(fsPath, useStat = false) {
1425
- return __awaiter(this, void 0, void 0, function* () {
1426
- const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
1427
- return stats.isDirectory();
1428
- });
1429
- }
1430
- exports.isDirectory = isDirectory;
1431
- /**
1432
- * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
1433
- * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
1434
- */
1435
- function isRooted(p) {
1436
- p = normalizeSeparators(p);
1437
- if (!p) {
1438
- throw new Error('isRooted() parameter "p" cannot be empty');
1439
- }
1440
- if (exports.IS_WINDOWS) {
1441
- return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
1442
- ); // e.g. C: or C:\hello
1443
- }
1444
- return p.startsWith('/');
1445
- }
1446
- exports.isRooted = isRooted;
1447
- /**
1448
- * Recursively create a directory at `fsPath`.
1449
- *
1450
- * This implementation is optimistic, meaning it attempts to create the full
1451
- * path first, and backs up the path stack from there.
1452
- *
1453
- * @param fsPath The path to create
1454
- * @param maxDepth The maximum recursion depth
1455
- * @param depth The current recursion depth
1456
- */
1457
- function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
1458
- return __awaiter(this, void 0, void 0, function* () {
1459
- assert_1.ok(fsPath, 'a path argument must be provided');
1460
- fsPath = path.resolve(fsPath);
1461
- if (depth >= maxDepth)
1462
- return exports.mkdir(fsPath);
1463
- try {
1464
- yield exports.mkdir(fsPath);
1465
- return;
1466
- }
1467
- catch (err) {
1468
- switch (err.code) {
1469
- case 'ENOENT': {
1470
- yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
1471
- yield exports.mkdir(fsPath);
1472
- return;
1473
- }
1474
- default: {
1475
- let stats;
1476
- try {
1477
- stats = yield exports.stat(fsPath);
1478
- }
1479
- catch (err2) {
1480
- throw err;
1481
- }
1482
- if (!stats.isDirectory())
1483
- throw err;
1484
- }
1485
- }
1486
- }
1487
- });
1488
- }
1489
- exports.mkdirP = mkdirP;
1490
- /**
1491
- * Best effort attempt to determine whether a file exists and is executable.
1492
- * @param filePath file path to check
1493
- * @param extensions additional file extensions to try
1494
- * @return if file exists and is executable, returns the file path. otherwise empty string.
1495
- */
1496
- function tryGetExecutablePath(filePath, extensions) {
1497
- return __awaiter(this, void 0, void 0, function* () {
1498
- let stats = undefined;
1499
- try {
1500
- // test file exists
1501
- stats = yield exports.stat(filePath);
1502
- }
1503
- catch (err) {
1504
- if (err.code !== 'ENOENT') {
1505
- // eslint-disable-next-line no-console
1506
- console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
1507
- }
1508
- }
1509
- if (stats && stats.isFile()) {
1510
- if (exports.IS_WINDOWS) {
1511
- // on Windows, test for valid extension
1512
- const upperExt = path.extname(filePath).toUpperCase();
1513
- if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
1514
- return filePath;
1515
- }
1516
- }
1517
- else {
1518
- if (isUnixExecutable(stats)) {
1519
- return filePath;
1520
- }
1521
- }
1522
- }
1523
- // try each extension
1524
- const originalFilePath = filePath;
1525
- for (const extension of extensions) {
1526
- filePath = originalFilePath + extension;
1527
- stats = undefined;
1528
- try {
1529
- stats = yield exports.stat(filePath);
1530
- }
1531
- catch (err) {
1532
- if (err.code !== 'ENOENT') {
1533
- // eslint-disable-next-line no-console
1534
- console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
1535
- }
1536
- }
1537
- if (stats && stats.isFile()) {
1538
- if (exports.IS_WINDOWS) {
1539
- // preserve the case of the actual file (since an extension was appended)
1540
- try {
1541
- const directory = path.dirname(filePath);
1542
- const upperName = path.basename(filePath).toUpperCase();
1543
- for (const actualName of yield exports.readdir(directory)) {
1544
- if (upperName === actualName.toUpperCase()) {
1545
- filePath = path.join(directory, actualName);
1546
- break;
1547
- }
1548
- }
1549
- }
1550
- catch (err) {
1551
- // eslint-disable-next-line no-console
1552
- console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
1553
- }
1554
- return filePath;
1555
- }
1556
- else {
1557
- if (isUnixExecutable(stats)) {
1558
- return filePath;
1559
- }
1560
- }
1561
- }
1562
- }
1563
- return '';
1564
- });
1565
- }
1566
- exports.tryGetExecutablePath = tryGetExecutablePath;
1567
- function normalizeSeparators(p) {
1568
- p = p || '';
1569
- if (exports.IS_WINDOWS) {
1570
- // convert slashes on Windows
1571
- p = p.replace(/\//g, '\\');
1572
- // remove redundant slashes
1573
- return p.replace(/\\\\+/g, '\\');
1574
- }
1575
- // remove redundant slashes
1576
- return p.replace(/\/\/+/g, '/');
1577
- }
1578
- // on Mac/Linux, test the execute bit
1579
- // R W X R W X R W X
1580
- // 256 128 64 32 16 8 4 2 1
1581
- function isUnixExecutable(stats) {
1582
- return ((stats.mode & 1) > 0 ||
1583
- ((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
1584
- ((stats.mode & 64) > 0 && stats.uid === process.getuid()));
1585
- }
1586
- //# sourceMappingURL=io-util.js.map
1587
-
1588
- /***/ }),
1589
-
1590
- /***/ 722:
1591
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
1592
-
1593
- "use strict";
1594
-
1595
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1596
- if (k2 === undefined) k2 = k;
1597
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1598
- }) : (function(o, m, k, k2) {
1599
- if (k2 === undefined) k2 = k;
1600
- o[k2] = m[k];
1601
- }));
1602
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1603
- Object.defineProperty(o, "default", { enumerable: true, value: v });
1604
- }) : function(o, v) {
1605
- o["default"] = v;
1606
- });
1607
- var __importStar = (this && this.__importStar) || function (mod) {
1608
- if (mod && mod.__esModule) return mod;
1609
- var result = {};
1610
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1611
- __setModuleDefault(result, mod);
1612
- return result;
1613
- };
1614
- Object.defineProperty(exports, "__esModule", { value: true });
1615
- exports.run = void 0;
1616
- const exec_1 = __webpack_require__(986);
1617
- const core = __importStar(__webpack_require__(470));
1618
- const path = __importStar(__webpack_require__(622));
1619
- const utils = __importStar(__webpack_require__(163));
1620
- /**
1621
- * Run the script
1622
- */
1623
- async function run() {
1624
- try {
1625
- let version = await utils.getInput('php-version', true);
1626
- version = version.length > 1 ? version.slice(0, 3) : version + '.0';
1627
- const extensions = await utils.filterExtensions(await utils.getInput('extensions', true));
1628
- const key = await utils.getInput('key', true);
1629
- const script_path = path.join(__dirname, '../src/extensions.sh');
1630
- await exec_1.exec('bash ' + script_path + ' "' + extensions + '" ' + key + ' ' + version);
1631
- }
1632
- catch (error) {
1633
- core.setFailed(error.message);
1634
- }
1635
- }
1636
- exports.run = run;
1637
- // call the run function
1638
- run();
1639
-
1640
-
1641
- /***/ }),
1642
-
1643
- /***/ 747:
1644
- /***/ (function(module) {
1645
-
1646
- module.exports = require("fs");
1647
-
1648
- /***/ }),
1649
-
1650
- /***/ 986:
1651
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
1652
-
1653
- "use strict";
1654
-
1655
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1656
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1657
- return new (P || (P = Promise))(function (resolve, reject) {
1658
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1659
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1660
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1661
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1662
- });
1663
- };
1664
- var __importStar = (this && this.__importStar) || function (mod) {
1665
- if (mod && mod.__esModule) return mod;
1666
- var result = {};
1667
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1668
- result["default"] = mod;
1669
- return result;
1670
- };
1671
- Object.defineProperty(exports, "__esModule", { value: true });
1672
- const tr = __importStar(__webpack_require__(9));
1673
- /**
1674
- * Exec a command.
1675
- * Output will be streamed to the live console.
1676
- * Returns promise with return code
1677
- *
1678
- * @param commandLine command to execute (can include additional args). Must be correctly escaped.
1679
- * @param args optional arguments for tool. Escaping is handled by the lib.
1680
- * @param options optional exec options. See ExecOptions
1681
- * @returns Promise<number> exit code
1682
- */
1683
- function exec(commandLine, args, options) {
1684
- return __awaiter(this, void 0, void 0, function* () {
1685
- const commandArgs = tr.argStringToArray(commandLine);
1686
- if (commandArgs.length === 0) {
1687
- throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
1688
- }
1689
- // Path to tool to execute should be first arg
1690
- const toolPath = commandArgs[0];
1691
- args = commandArgs.slice(1).concat(args || []);
1692
- const runner = new tr.ToolRunner(toolPath, args, options);
1693
- return runner.exec();
1694
- });
1695
- }
1696
- exports.exec = exec;
1697
- //# sourceMappingURL=exec.js.map
1698
-
1699
- /***/ })
1700
-
1701
- /******/ });