Add husky setup

5f61b21 · Jonathan Clem · 2020-05-14 19:19

8 files +3520 -0

Files changed

added dist/.github/elixir.json
+31 −0
@@ -0,0 +1,31 @@
1 +{
2 + "problemMatcher": [
3 + {
4 + "owner": "elixir",
5 + "pattern": [
6 + {
7 + "regexp": "^(\\*\\* \\(.*\\) )?((.:)?[^:]*):(\\d+)(:(\\d+))?: (.*)$",
8 + "file": 2,
9 + "line": 4,
10 + "column": 6,
11 + "message": 7
12 + }
13 + ]
14 + },
15 + {
16 + "owner": "elixir-warning",
17 + "pattern": [
18 + {
19 + "regexp": "^(warning: (.*))$",
20 + "message": 2
21 + },
22 + {
23 + "regexp": "^( )((.:)?[^:]*):(\\d+)(:(\\d+))?$",
24 + "file": 2,
25 + "line": 4,
26 + "column": 6
27 + }
28 + ]
29 + }
30 + ]
31 +}
added dist/.github/workflows/licensed.yml
+19 −0
@@ -0,0 +1,19 @@
1 +name: Licensed
2 +
3 +on:
4 + push: {branches: master}
5 + pull_request: {branches: master}
6 + repository_dispatch:
7 +
8 +jobs:
9 + test:
10 + runs-on: ubuntu-latest
11 + name: Check licenses
12 + steps:
13 + - uses: actions/checkout@v1.0.0
14 + - run: |-
15 + cd /tmp
16 + curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.3.2/licensed-2.3.2-linux-x64.tar.gz
17 + sudo tar -xzf licensed.tar.gz
18 + sudo mv licensed /usr/local/bin/licensed
19 + - run: licensed status
added dist/.github/workflows/test.yml
+35 −0
@@ -0,0 +1,35 @@
1 +name: Test
2 +
3 +on:
4 + push: {branches: master}
5 + pull_request: {branches: master}
6 + repository_dispatch:
7 +
8 +jobs:
9 + test:
10 + runs-on: ubuntu-latest
11 + name: OTP ${{matrix.pair.otp-version}} / Elixir ${{matrix.pair.elixir-version}}
12 + strategy:
13 + matrix:
14 + pair:
15 + # Full Versions
16 + - otp-version: 22.0
17 + elixir-version: 1.9.1
18 + # Semver ranges
19 + - otp-version: 21.x
20 + elixir-version: <1.9.1
21 + # Branches
22 + - otp-version: 22.0
23 + elixir-version: master
24 + steps:
25 + - uses: actions/checkout@v1.0.0
26 + - name: Use actions/setup-elixir
27 + uses: ./
28 + with:
29 + otp-version: ${{matrix.pair.otp-version}}
30 + elixir-version: ${{matrix.pair.elixir-version}}
31 + - name: Run Mix project tests
32 + run: |-
33 + cd test-project
34 + mix deps.get
35 + mix test
added dist/index.js
+3377 −0
@@ -0,0 +1,3377 @@
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 +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
23 +/******/
24 +/******/ // Flag the module as loaded
25 +/******/ module.l = true;
26 +/******/
27 +/******/ // Return the exports of the module
28 +/******/ return module.exports;
29 +/******/ }
30 +/******/
31 +/******/
32 +/******/ __webpack_require__.ab = __dirname + "/";
33 +/******/
34 +/******/ // the startup function
35 +/******/ function startup() {
36 +/******/ // Load entry module and return exports
37 +/******/ return __webpack_require__(986);
38 +/******/ };
39 +/******/
40 +/******/ // run startup
41 +/******/ return startup();
42 +/******/ })
43 +/************************************************************************/
44 +/******/ ({
45 +
46 +/***/ 9:
47 +/***/ (function(__unusedmodule, exports, __webpack_require__) {
48 +
49 +"use strict";
50 +
51 +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
52 + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
53 + return new (P || (P = Promise))(function (resolve, reject) {
54 + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
55 + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
56 + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
57 + step((generator = generator.apply(thisArg, _arguments || [])).next());
58 + });
59 +};
60 +var __importStar = (this && this.__importStar) || function (mod) {
61 + if (mod && mod.__esModule) return mod;
62 + var result = {};
63 + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
64 + result["default"] = mod;
65 + return result;
66 +};
67 +Object.defineProperty(exports, "__esModule", { value: true });
68 +const os = __importStar(__webpack_require__(87));
69 +const events = __importStar(__webpack_require__(614));
70 +const child = __importStar(__webpack_require__(129));
71 +const path = __importStar(__webpack_require__(622));
72 +const io = __importStar(__webpack_require__(194));
73 +const ioUtil = __importStar(__webpack_require__(408));
74 +/* eslint-disable @typescript-eslint/unbound-method */
75 +const IS_WINDOWS = process.platform === 'win32';
76 +/*
77 + * Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way.
78 + */
79 +class ToolRunner extends events.EventEmitter {
80 + constructor(toolPath, args, options) {
81 + super();
82 + if (!toolPath) {
83 + throw new Error("Parameter 'toolPath' cannot be null or empty.");
84 + }
85 + this.toolPath = toolPath;
86 + this.args = args || [];
87 + this.options = options || {};
88 + }
89 + _debug(message) {
90 + if (this.options.listeners && this.options.listeners.debug) {
91 + this.options.listeners.debug(message);
92 + }
93 + }
94 + _getCommandString(options, noPrefix) {
95 + const toolPath = this._getSpawnFileName();
96 + const args = this._getSpawnArgs(options);
97 + let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool
98 + if (IS_WINDOWS) {
99 + // Windows + cmd file
100 + if (this._isCmdFile()) {
101 + cmd += toolPath;
102 + for (const a of args) {
103 + cmd += ` ${a}`;
104 + }
105 + }
106 + // Windows + verbatim
107 + else if (options.windowsVerbatimArguments) {
108 + cmd += `"${toolPath}"`;
109 + for (const a of args) {
110 + cmd += ` ${a}`;
111 + }
112 + }
113 + // Windows (regular)
114 + else {
115 + cmd += this._windowsQuoteCmdArg(toolPath);
116 + for (const a of args) {
117 + cmd += ` ${this._windowsQuoteCmdArg(a)}`;
118 + }
119 + }
120 + }
121 + else {
122 + // OSX/Linux - this can likely be improved with some form of quoting.
123 + // creating processes on Unix is fundamentally different than Windows.
124 + // on Unix, execvp() takes an arg array.
125 + cmd += toolPath;
126 + for (const a of args) {
127 + cmd += ` ${a}`;
128 + }
129 + }
130 + return cmd;
131 + }
132 + _processLineBuffer(data, strBuffer, onLine) {
133 + try {
134 + let s = strBuffer + data.toString();
135 + let n = s.indexOf(os.EOL);
136 + while (n > -1) {
137 + const line = s.substring(0, n);
138 + onLine(line);
139 + // the rest of the string ...
140 + s = s.substring(n + os.EOL.length);
141 + n = s.indexOf(os.EOL);
142 + }
143 + strBuffer = s;
144 + }
145 + catch (err) {
146 + // streaming lines to console is best effort. Don't fail a build.
147 + this._debug(`error processing line. Failed with error ${err}`);
148 + }
149 + }
150 + _getSpawnFileName() {
151 + if (IS_WINDOWS) {
152 + if (this._isCmdFile()) {
153 + return process.env['COMSPEC'] || 'cmd.exe';
154 + }
155 + }
156 + return this.toolPath;
157 + }
158 + _getSpawnArgs(options) {
159 + if (IS_WINDOWS) {
160 + if (this._isCmdFile()) {
161 + let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
162 + for (const a of this.args) {
163 + argline += ' ';
164 + argline += options.windowsVerbatimArguments
165 + ? a
166 + : this._windowsQuoteCmdArg(a);
167 + }
168 + argline += '"';
169 + return [argline];
170 + }
171 + }
172 + return this.args;
173 + }
174 + _endsWith(str, end) {
175 + return str.endsWith(end);
176 + }
177 + _isCmdFile() {
178 + const upperToolPath = this.toolPath.toUpperCase();
179 + return (this._endsWith(upperToolPath, '.CMD') ||
180 + this._endsWith(upperToolPath, '.BAT'));
181 + }
182 + _windowsQuoteCmdArg(arg) {
183 + // for .exe, apply the normal quoting rules that libuv applies
184 + if (!this._isCmdFile()) {
185 + return this._uvQuoteCmdArg(arg);
186 + }
187 + // otherwise apply quoting rules specific to the cmd.exe command line parser.
188 + // the libuv rules are generic and are not designed specifically for cmd.exe
189 + // command line parser.
190 + //
191 + // for a detailed description of the cmd.exe command line parser, refer to
192 + // http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
193 + // need quotes for empty arg
194 + if (!arg) {
195 + return '""';
196 + }
197 + // determine whether the arg needs to be quoted
198 + const cmdSpecialChars = [
199 + ' ',
200 + '\t',
201 + '&',
202 + '(',
203 + ')',
204 + '[',
205 + ']',
206 + '{',
207 + '}',
208 + '^',
209 + '=',
210 + ';',
211 + '!',
212 + "'",
213 + '+',
214 + ',',
215 + '`',
216 + '~',
217 + '|',
218 + '<',
219 + '>',
220 + '"'
221 + ];
222 + let needsQuotes = false;
223 + for (const char of arg) {
224 + if (cmdSpecialChars.some(x => x === char)) {
225 + needsQuotes = true;
226 + break;
227 + }
228 + }
229 + // short-circuit if quotes not needed
230 + if (!needsQuotes) {
231 + return arg;
232 + }
233 + // the following quoting rules are very similar to the rules that by libuv applies.
234 + //
235 + // 1) wrap the string in quotes
236 + //
237 + // 2) double-up quotes - i.e. " => ""
238 + //
239 + // this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
240 + // doesn't work well with a cmd.exe command line.
241 + //
242 + // note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
243 + // for example, the command line:
244 + // foo.exe "myarg:""my val"""
245 + // is parsed by a .NET console app into an arg array:
246 + // [ "myarg:\"my val\"" ]
247 + // which is the same end result when applying libuv quoting rules. although the actual
248 + // command line from libuv quoting rules would look like:
249 + // foo.exe "myarg:\"my val\""
250 + //
251 + // 3) double-up slashes that precede a quote,
252 + // e.g. hello \world => "hello \world"
253 + // hello\"world => "hello\\""world"
254 + // hello\\"world => "hello\\\\""world"
255 + // hello world\ => "hello world\\"
256 + //
257 + // technically this is not required for a cmd.exe command line, or the batch argument parser.
258 + // the reasons for including this as a .cmd quoting rule are:
259 + //
260 + // a) this is optimized for the scenario where the argument is passed from the .cmd file to an
261 + // external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
262 + //
263 + // b) it's what we've been doing previously (by deferring to node default behavior) and we
264 + // haven't heard any complaints about that aspect.
265 + //
266 + // note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
267 + // escaped when used on the command line directly - even though within a .cmd file % can be escaped
268 + // by using %%.
269 + //
270 + // the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
271 + // the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
272 + //
273 + // one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
274 + // often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
275 + // variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
276 + // to an external program.
277 + //
278 + // an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
279 + // % can be escaped within a .cmd file.
280 + let reverse = '"';
281 + let quoteHit = true;
282 + for (let i = arg.length; i > 0; i--) {
283 + // walk the string in reverse
284 + reverse += arg[i - 1];
285 + if (quoteHit && arg[i - 1] === '\\') {
286 + reverse += '\\'; // double the slash
287 + }
288 + else if (arg[i - 1] === '"') {
289 + quoteHit = true;
290 + reverse += '"'; // double the quote
291 + }
292 + else {
293 + quoteHit = false;
294 + }
295 + }
296 + reverse += '"';
297 + return reverse
298 + .split('')
299 + .reverse()
300 + .join('');
301 + }
302 + _uvQuoteCmdArg(arg) {
303 + // Tool runner wraps child_process.spawn() and needs to apply the same quoting as
304 + // Node in certain cases where the undocumented spawn option windowsVerbatimArguments
305 + // is used.
306 + //
307 + // Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
308 + // see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
309 + // pasting copyright notice from Node within this function:
310 + //
311 + // Copyright Joyent, Inc. and other Node contributors. All rights reserved.
312 + //
313 + // Permission is hereby granted, free of charge, to any person obtaining a copy
314 + // of this software and associated documentation files (the "Software"), to
315 + // deal in the Software without restriction, including without limitation the
316 + // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
317 + // sell copies of the Software, and to permit persons to whom the Software is
318 + // furnished to do so, subject to the following conditions:
319 + //
320 + // The above copyright notice and this permission notice shall be included in
321 + // all copies or substantial portions of the Software.
322 + //
323 + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
324 + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
325 + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
326 + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
327 + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
328 + // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
329 + // IN THE SOFTWARE.
330 + if (!arg) {
331 + // Need double quotation for empty argument
332 + return '""';
333 + }
334 + if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) {
335 + // No quotation needed
336 + return arg;
337 + }
338 + if (!arg.includes('"') && !arg.includes('\\')) {
339 + // No embedded double quotes or backslashes, so I can just wrap
340 + // quote marks around the whole thing.
341 + return `"${arg}"`;
342 + }
343 + // Expected input/output:
344 + // input : hello"world
345 + // output: "hello\"world"
346 + // input : hello""world
347 + // output: "hello\"\"world"
348 + // input : hello\world
349 + // output: hello\world
350 + // input : hello\\world
351 + // output: hello\\world
352 + // input : hello\"world
353 + // output: "hello\\\"world"
354 + // input : hello\\"world
355 + // output: "hello\\\\\"world"
356 + // input : hello world\
357 + // output: "hello world\\" - note the comment in libuv actually reads "hello world\"
358 + // but it appears the comment is wrong, it should be "hello world\\"
359 + let reverse = '"';
360 + let quoteHit = true;
361 + for (let i = arg.length; i > 0; i--) {
362 + // walk the string in reverse
363 + reverse += arg[i - 1];
364 + if (quoteHit && arg[i - 1] === '\\') {
365 + reverse += '\\';
366 + }
367 + else if (arg[i - 1] === '"') {
368 + quoteHit = true;
369 + reverse += '\\';
370 + }
371 + else {
372 + quoteHit = false;
373 + }
374 + }
375 + reverse += '"';
376 + return reverse
377 + .split('')
378 + .reverse()
379 + .join('');
380 + }
381 + _cloneExecOptions(options) {
382 + options = options || {};
383 + const result = {
384 + cwd: options.cwd || process.cwd(),
385 + env: options.env || process.env,
386 + silent: options.silent || false,
387 + windowsVerbatimArguments: options.windowsVerbatimArguments || false,
388 + failOnStdErr: options.failOnStdErr || false,
389 + ignoreReturnCode: options.ignoreReturnCode || false,
390 + delay: options.delay || 10000
391 + };
392 + result.outStream = options.outStream || process.stdout;
393 + result.errStream = options.errStream || process.stderr;
394 + return result;
395 + }
396 + _getSpawnOptions(options, toolPath) {
397 + options = options || {};
398 + const result = {};
399 + result.cwd = options.cwd;
400 + result.env = options.env;
401 + result['windowsVerbatimArguments'] =
402 + options.windowsVerbatimArguments || this._isCmdFile();
403 + if (options.windowsVerbatimArguments) {
404 + result.argv0 = `"${toolPath}"`;
405 + }
406 + return result;
407 + }
408 + /**
409 + * Exec a tool.
410 + * Output will be streamed to the live console.
411 + * Returns promise with return code
412 + *
413 + * @param tool path to tool to exec
414 + * @param options optional exec options. See ExecOptions
415 + * @returns number
416 + */
417 + exec() {
418 + return __awaiter(this, void 0, void 0, function* () {
419 + // root the tool path if it is unrooted and contains relative pathing
420 + if (!ioUtil.isRooted(this.toolPath) &&
421 + (this.toolPath.includes('/') ||
422 + (IS_WINDOWS && this.toolPath.includes('\\')))) {
423 + // prefer options.cwd if it is specified, however options.cwd may also need to be rooted
424 + this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
425 + }
426 + // if the tool is only a file name, then resolve it from the PATH
427 + // otherwise verify it exists (add extension on Windows if necessary)
428 + this.toolPath = yield io.which(this.toolPath, true);
429 + return new Promise((resolve, reject) => {
430 + this._debug(`exec tool: ${this.toolPath}`);
431 + this._debug('arguments:');
432 + for (const arg of this.args) {
433 + this._debug(` ${arg}`);
434 + }
435 + const optionsNonNull = this._cloneExecOptions(this.options);
436 + if (!optionsNonNull.silent && optionsNonNull.outStream) {
437 + optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
438 + }
439 + const state = new ExecState(optionsNonNull, this.toolPath);
440 + state.on('debug', (message) => {
441 + this._debug(message);
442 + });
443 + const fileName = this._getSpawnFileName();
444 + const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
445 + const stdbuffer = '';
446 + if (cp.stdout) {
447 + cp.stdout.on('data', (data) => {
448 + if (this.options.listeners && this.options.listeners.stdout) {
449 + this.options.listeners.stdout(data);
450 + }
451 + if (!optionsNonNull.silent && optionsNonNull.outStream) {
452 + optionsNonNull.outStream.write(data);
453 + }
454 + this._processLineBuffer(data, stdbuffer, (line) => {
455 + if (this.options.listeners && this.options.listeners.stdline) {
456 + this.options.listeners.stdline(line);
457 + }
458 + });
459 + });
460 + }
461 + const errbuffer = '';
462 + if (cp.stderr) {
463 + cp.stderr.on('data', (data) => {
464 + state.processStderr = true;
465 + if (this.options.listeners && this.options.listeners.stderr) {
466 + this.options.listeners.stderr(data);
467 + }
468 + if (!optionsNonNull.silent &&
469 + optionsNonNull.errStream &&
470 + optionsNonNull.outStream) {
471 + const s = optionsNonNull.failOnStdErr
472 + ? optionsNonNull.errStream
473 + : optionsNonNull.outStream;
474 + s.write(data);
475 + }
476 + this._processLineBuffer(data, errbuffer, (line) => {
477 + if (this.options.listeners && this.options.listeners.errline) {
478 + this.options.listeners.errline(line);
479 + }
480 + });
481 + });
482 + }
483 + cp.on('error', (err) => {
484 + state.processError = err.message;
485 + state.processExited = true;
486 + state.processClosed = true;
487 + state.CheckComplete();
488 + });
489 + cp.on('exit', (code) => {
490 + state.processExitCode = code;
491 + state.processExited = true;
492 + this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
493 + state.CheckComplete();
494 + });
495 + cp.on('close', (code) => {
496 + state.processExitCode = code;
497 + state.processExited = true;
498 + state.processClosed = true;
499 + this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
500 + state.CheckComplete();
501 + });
502 + state.on('done', (error, exitCode) => {
503 + if (stdbuffer.length > 0) {
504 + this.emit('stdline', stdbuffer);
505 + }
506 + if (errbuffer.length > 0) {
507 + this.emit('errline', errbuffer);
508 + }
509 + cp.removeAllListeners();
510 + if (error) {
511 + reject(error);
512 + }
513 + else {
514 + resolve(exitCode);
515 + }
516 + });
517 + if (this.options.input) {
518 + if (!cp.stdin) {
519 + throw new Error('child process missing stdin');
520 + }
521 + cp.stdin.end(this.options.input);
522 + }
523 + });
524 + });
525 + }
526 +}
527 +exports.ToolRunner = ToolRunner;
528 +/**
529 + * Convert an arg string to an array of args. Handles escaping
530 + *
531 + * @param argString string of arguments
532 + * @returns string[] array of arguments
533 + */
534 +function argStringToArray(argString) {
535 + const args = [];
536 + let inQuotes = false;
537 + let escaped = false;
538 + let arg = '';
539 + function append(c) {
540 + // we only escape double quotes.
541 + if (escaped && c !== '"') {
542 + arg += '\\';
543 + }
544 + arg += c;
545 + escaped = false;
546 + }
547 + for (let i = 0; i < argString.length; i++) {
548 + const c = argString.charAt(i);
549 + if (c === '"') {
550 + if (!escaped) {
551 + inQuotes = !inQuotes;
552 + }
553 + else {
554 + append(c);
555 + }
556 + continue;
557 + }
558 + if (c === '\\' && escaped) {
559 + append(c);
560 + continue;
561 + }
562 + if (c === '\\' && inQuotes) {
563 + escaped = true;
564 + continue;
565 + }
566 + if (c === ' ' && !inQuotes) {
567 + if (arg.length > 0) {
568 + args.push(arg);
569 + arg = '';
570 + }
571 + continue;
572 + }
573 + append(c);
574 + }
575 + if (arg.length > 0) {
576 + args.push(arg.trim());
577 + }
578 + return args;
579 +}
580 +exports.argStringToArray = argStringToArray;
581 +class ExecState extends events.EventEmitter {
582 + constructor(options, toolPath) {
583 + super();
584 + this.processClosed = false; // tracks whether the process has exited and stdio is closed
585 + this.processError = '';
586 + this.processExitCode = 0;
587 + this.processExited = false; // tracks whether the process has exited
588 + this.processStderr = false; // tracks whether stderr was written to
589 + this.delay = 10000; // 10 seconds
590 + this.done = false;
591 + this.timeout = null;
592 + if (!toolPath) {
593 + throw new Error('toolPath must not be empty');
594 + }
595 + this.options = options;
596 + this.toolPath = toolPath;
597 + if (options.delay) {
598 + this.delay = options.delay;
599 + }
600 + }
601 + CheckComplete() {
602 + if (this.done) {
603 + return;
604 + }
605 + if (this.processClosed) {
606 + this._setResult();
607 + }
608 + else if (this.processExited) {
609 + this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
610 + }
611 + }
612 + _debug(message) {
613 + this.emit('debug', message);
614 + }
615 + _setResult() {
616 + // determine whether there is an error
617 + let error;
618 + if (this.processExited) {
619 + if (this.processError) {
620 + 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}`);
621 + }
622 + else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
623 + error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
624 + }
625 + else if (this.processStderr && this.options.failOnStdErr) {
626 + error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
627 + }
628 + }
629 + // clear the timeout
630 + if (this.timeout) {
631 + clearTimeout(this.timeout);
632 + this.timeout = null;
633 + }
634 + this.done = true;
635 + this.emit('done', error, this.processExitCode);
636 + }
637 + static HandleTimeout(state) {
638 + if (state.done) {
639 + return;
640 + }
641 + if (!state.processClosed && state.processExited) {
642 + const message = `The STDIO streams did not close within ${state.delay /
643 + 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.`;
644 + state._debug(message);
645 + }
646 + state._setResult();
647 + }
648 +}
649 +//# sourceMappingURL=toolrunner.js.map
650 +
651 +/***/ }),
652 +
653 +/***/ 87:
654 +/***/ (function(module) {
655 +
656 +module.exports = require("os");
657 +
658 +/***/ }),
659 +
660 +/***/ 129:
661 +/***/ (function(module) {
662 +
663 +module.exports = require("child_process");
664 +
665 +/***/ }),
666 +
667 +/***/ 194:
668 +/***/ (function(__unusedmodule, exports, __webpack_require__) {
669 +
670 +"use strict";
671 +
672 +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
673 + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
674 + return new (P || (P = Promise))(function (resolve, reject) {
675 + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
676 + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
677 + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
678 + step((generator = generator.apply(thisArg, _arguments || [])).next());
679 + });
680 +};
681 +Object.defineProperty(exports, "__esModule", { value: true });
682 +const childProcess = __webpack_require__(129);
683 +const path = __webpack_require__(622);
684 +const util_1 = __webpack_require__(669);
685 +const ioUtil = __webpack_require__(408);
686 +const exec = util_1.promisify(childProcess.exec);
687 +/**
688 + * Copies a file or folder.
689 + * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
690 + *
691 + * @param source source path
692 + * @param dest destination path
693 + * @param options optional. See CopyOptions.
694 + */
695 +function cp(source, dest, options = {}) {
696 + return __awaiter(this, void 0, void 0, function* () {
697 + const { force, recursive } = readCopyOptions(options);
698 + const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
699 + // Dest is an existing file, but not forcing
700 + if (destStat && destStat.isFile() && !force) {
701 + return;
702 + }
703 + // If dest is an existing directory, should copy inside.
704 + const newDest = destStat && destStat.isDirectory()
705 + ? path.join(dest, path.basename(source))
706 + : dest;
707 + if (!(yield ioUtil.exists(source))) {
708 + throw new Error(`no such file or directory: ${source}`);
709 + }
710 + const sourceStat = yield ioUtil.stat(source);
711 + if (sourceStat.isDirectory()) {
712 + if (!recursive) {
713 + throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
714 + }
715 + else {
716 + yield cpDirRecursive(source, newDest, 0, force);
717 + }
718 + }
719 + else {
720 + if (path.relative(source, newDest) === '') {
721 + // a file cannot be copied to itself
722 + throw new Error(`'${newDest}' and '${source}' are the same file`);
723 + }
724 + yield copyFile(source, newDest, force);
725 + }
726 + });
727 +}
728 +exports.cp = cp;
729 +/**
730 + * Moves a path.
731 + *
732 + * @param source source path
733 + * @param dest destination path
734 + * @param options optional. See MoveOptions.
735 + */
736 +function mv(source, dest, options = {}) {
737 + return __awaiter(this, void 0, void 0, function* () {
738 + if (yield ioUtil.exists(dest)) {
739 + let destExists = true;
740 + if (yield ioUtil.isDirectory(dest)) {
741 + // If dest is directory copy src into dest
742 + dest = path.join(dest, path.basename(source));
743 + destExists = yield ioUtil.exists(dest);
744 + }
745 + if (destExists) {
746 + if (options.force == null || options.force) {
747 + yield rmRF(dest);
748 + }
749 + else {
750 + throw new Error('Destination already exists');
751 + }
752 + }
753 + }
754 + yield mkdirP(path.dirname(dest));
755 + yield ioUtil.rename(source, dest);
756 + });
757 +}
758 +exports.mv = mv;
759 +/**
760 + * Remove a path recursively with force
761 + *
762 + * @param inputPath path to remove
763 + */
764 +function rmRF(inputPath) {
765 + return __awaiter(this, void 0, void 0, function* () {
766 + if (ioUtil.IS_WINDOWS) {
767 + // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
768 + // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
769 + try {
770 + if (yield ioUtil.isDirectory(inputPath, true)) {
771 + yield exec(`rd /s /q "${inputPath}"`);
772 + }
773 + else {
774 + yield exec(`del /f /a "${inputPath}"`);
775 + }
776 + }
777 + catch (err) {
778 + // if you try to delete a file that doesn't exist, desired result is achieved
779 + // other errors are valid
780 + if (err.code !== 'ENOENT')
781 + throw err;
782 + }
783 + // Shelling out fails to remove a symlink folder with missing source, this unlink catches that
784 + try {
785 + yield ioUtil.unlink(inputPath);
786 + }
787 + catch (err) {
788 + // if you try to delete a file that doesn't exist, desired result is achieved
789 + // other errors are valid
790 + if (err.code !== 'ENOENT')
791 + throw err;
792 + }
793 + }
794 + else {
795 + let isDir = false;
796 + try {
797 + isDir = yield ioUtil.isDirectory(inputPath);
798 + }
799 + catch (err) {
800 + // if you try to delete a file that doesn't exist, desired result is achieved
801 + // other errors are valid
802 + if (err.code !== 'ENOENT')
803 + throw err;
804 + return;
805 + }
806 + if (isDir) {
807 + yield exec(`rm -rf "${inputPath}"`);
808 + }
809 + else {
810 + yield ioUtil.unlink(inputPath);
811 + }
812 + }
813 + });
814 +}
815 +exports.rmRF = rmRF;
816 +/**
817 + * Make a directory. Creates the full path with folders in between
818 + * Will throw if it fails
819 + *
820 + * @param fsPath path to create
821 + * @returns Promise<void>
822 + */
823 +function mkdirP(fsPath) {
824 + return __awaiter(this, void 0, void 0, function* () {
825 + yield ioUtil.mkdirP(fsPath);
826 + });
827 +}
828 +exports.mkdirP = mkdirP;
829 +/**
830 + * Returns path of a tool had the tool actually been invoked. Resolves via paths.
831 + * If you check and the tool does not exist, it will throw.
832 + *
833 + * @param tool name of the tool
834 + * @param check whether to check if tool exists
835 + * @returns Promise<string> path to tool
836 + */
837 +function which(tool, check) {
838 + return __awaiter(this, void 0, void 0, function* () {
839 + if (!tool) {
840 + throw new Error("parameter 'tool' is required");
841 + }
842 + // recursive when check=true
843 + if (check) {
844 + const result = yield which(tool, false);
845 + if (!result) {
846 + if (ioUtil.IS_WINDOWS) {
847 + 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.`);
848 + }
849 + else {
850 + 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.`);
851 + }
852 + }
853 + }
854 + try {
855 + // build the list of extensions to try
856 + const extensions = [];
857 + if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
858 + for (const extension of process.env.PATHEXT.split(path.delimiter)) {
859 + if (extension) {
860 + extensions.push(extension);
861 + }
862 + }
863 + }
864 + // if it's rooted, return it if exists. otherwise return empty.
865 + if (ioUtil.isRooted(tool)) {
866 + const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
867 + if (filePath) {
868 + return filePath;
869 + }
870 + return '';
871 + }
872 + // if any path separators, return empty
873 + if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
874 + return '';
875 + }
876 + // build the list of directories
877 + //
878 + // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
879 + // it feels like we should not do this. Checking the current directory seems like more of a use
880 + // case of a shell, and the which() function exposed by the toolkit should strive for consistency
881 + // across platforms.
882 + const directories = [];
883 + if (process.env.PATH) {
884 + for (const p of process.env.PATH.split(path.delimiter)) {
885 + if (p) {
886 + directories.push(p);
887 + }
888 + }
889 + }
890 + // return the first match
891 + for (const directory of directories) {
892 + const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
893 + if (filePath) {
894 + return filePath;
895 + }
896 + }
897 + return '';
898 + }
899 + catch (err) {
900 + throw new Error(`which failed with message ${err.message}`);
901 + }
902 + });
903 +}
904 +exports.which = which;
905 +function readCopyOptions(options) {
906 + const force = options.force == null ? true : options.force;
907 + const recursive = Boolean(options.recursive);
908 + return { force, recursive };
909 +}
910 +function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
911 + return __awaiter(this, void 0, void 0, function* () {
912 + // Ensure there is not a run away recursive copy
913 + if (currentDepth >= 255)
914 + return;
915 + currentDepth++;
916 + yield mkdirP(destDir);
917 + const files = yield ioUtil.readdir(sourceDir);
918 + for (const fileName of files) {
919 + const srcFile = `${sourceDir}/${fileName}`;
920 + const destFile = `${destDir}/${fileName}`;
921 + const srcFileStat = yield ioUtil.lstat(srcFile);
922 + if (srcFileStat.isDirectory()) {
923 + // Recurse
924 + yield cpDirRecursive(srcFile, destFile, currentDepth, force);
925 + }
926 + else {
927 + yield copyFile(srcFile, destFile, force);
928 + }
929 + }
930 + // Change the mode for the newly created directory
931 + yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
932 + });
933 +}
934 +// Buffered file copy
935 +function copyFile(srcFile, destFile, force) {
936 + return __awaiter(this, void 0, void 0, function* () {
937 + if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
938 + // unlink/re-link it
939 + try {
940 + yield ioUtil.lstat(destFile);
941 + yield ioUtil.unlink(destFile);
942 + }
943 + catch (e) {
944 + // Try to override file permission
945 + if (e.code === 'EPERM') {
946 + yield ioUtil.chmod(destFile, '0666');
947 + yield ioUtil.unlink(destFile);
948 + }
949 + // other errors = it doesn't exist, no work to do
950 + }
951 + // Copy over symlink
952 + const symlinkFull = yield ioUtil.readlink(srcFile);
953 + yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null);
954 + }
955 + else if (!(yield ioUtil.exists(destFile)) || force) {
956 + yield ioUtil.copyFile(srcFile, destFile);
957 + }
958 + });
959 +}
960 +//# sourceMappingURL=io.js.map
961 +
962 +/***/ }),
963 +
964 +/***/ 211:
965 +/***/ (function(module) {
966 +
967 +module.exports = require("https");
968 +
969 +/***/ }),
970 +
971 +/***/ 280:
972 +/***/ (function(module, exports) {
973 +
974 +exports = module.exports = SemVer
975 +
976 +var debug
977 +/* istanbul ignore next */
978 +if (typeof process === 'object' &&
979 + process.env &&
980 + process.env.NODE_DEBUG &&
981 + /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
982 + debug = function () {
983 + var args = Array.prototype.slice.call(arguments, 0)
984 + args.unshift('SEMVER')
985 + console.log.apply(console, args)
986 + }
987 +} else {
988 + debug = function () {}
989 +}
990 +
991 +// Note: this is the semver.org version of the spec that it implements
992 +// Not necessarily the package version of this code.
993 +exports.SEMVER_SPEC_VERSION = '2.0.0'
994 +
995 +var MAX_LENGTH = 256
996 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
997 + /* istanbul ignore next */ 9007199254740991
998 +
999 +// Max safe segment length for coercion.
1000 +var MAX_SAFE_COMPONENT_LENGTH = 16
1001 +
1002 +// The actual regexps go on exports.re
1003 +var re = exports.re = []
1004 +var src = exports.src = []
1005 +var t = exports.tokens = {}
1006 +var R = 0
1007 +
1008 +function tok (n) {
1009 + t[n] = R++
1010 +}
1011 +
1012 +// The following Regular Expressions can be used for tokenizing,
1013 +// validating, and parsing SemVer version strings.
1014 +
1015 +// ## Numeric Identifier
1016 +// A single `0`, or a non-zero digit followed by zero or more digits.
1017 +
1018 +tok('NUMERICIDENTIFIER')
1019 +src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*'
1020 +tok('NUMERICIDENTIFIERLOOSE')
1021 +src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+'
1022 +
1023 +// ## Non-numeric Identifier
1024 +// Zero or more digits, followed by a letter or hyphen, and then zero or
1025 +// more letters, digits, or hyphens.
1026 +
1027 +tok('NONNUMERICIDENTIFIER')
1028 +src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
1029 +
1030 +// ## Main Version
1031 +// Three dot-separated numeric identifiers.
1032 +
1033 +tok('MAINVERSION')
1034 +src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
1035 + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
1036 + '(' + src[t.NUMERICIDENTIFIER] + ')'
1037 +
1038 +tok('MAINVERSIONLOOSE')
1039 +src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
1040 + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
1041 + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'
1042 +
1043 +// ## Pre-release Version Identifier
1044 +// A numeric identifier, or a non-numeric identifier.
1045 +
1046 +tok('PRERELEASEIDENTIFIER')
1047 +src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
1048 + '|' + src[t.NONNUMERICIDENTIFIER] + ')'
1049 +
1050 +tok('PRERELEASEIDENTIFIERLOOSE')
1051 +src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
1052 + '|' + src[t.NONNUMERICIDENTIFIER] + ')'
1053 +
1054 +// ## Pre-release Version
1055 +// Hyphen, followed by one or more dot-separated pre-release version
1056 +// identifiers.
1057 +
1058 +tok('PRERELEASE')
1059 +src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
1060 + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))'
1061 +
1062 +tok('PRERELEASELOOSE')
1063 +src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
1064 + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'
1065 +
1066 +// ## Build Metadata Identifier
1067 +// Any combination of digits, letters, or hyphens.
1068 +
1069 +tok('BUILDIDENTIFIER')
1070 +src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
1071 +
1072 +// ## Build Metadata
1073 +// Plus sign, followed by one or more period-separated build metadata
1074 +// identifiers.
1075 +
1076 +tok('BUILD')
1077 +src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
1078 + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'
1079 +
1080 +// ## Full Version String
1081 +// A main version, followed optionally by a pre-release version and
1082 +// build metadata.
1083 +
1084 +// Note that the only major, minor, patch, and pre-release sections of
1085 +// the version string are capturing groups. The build metadata is not a
1086 +// capturing group, because it should not ever be used in version
1087 +// comparison.
1088 +
1089 +tok('FULL')
1090 +tok('FULLPLAIN')
1091 +src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
1092 + src[t.PRERELEASE] + '?' +
1093 + src[t.BUILD] + '?'
1094 +
1095 +src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'
1096 +
1097 +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
1098 +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
1099 +// common in the npm registry.
1100 +tok('LOOSEPLAIN')
1101 +src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
1102 + src[t.PRERELEASELOOSE] + '?' +
1103 + src[t.BUILD] + '?'
1104 +
1105 +tok('LOOSE')
1106 +src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$'
1107 +
1108 +tok('GTLT')
1109 +src[t.GTLT] = '((?:<|>)?=?)'
1110 +
1111 +// Something like "2.*" or "1.2.x".
1112 +// Note that "x.x" is a valid xRange identifer, meaning "any version"
1113 +// Only the first item is strictly required.
1114 +tok('XRANGEIDENTIFIERLOOSE')
1115 +src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
1116 +tok('XRANGEIDENTIFIER')
1117 +src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*'
1118 +
1119 +tok('XRANGEPLAIN')
1120 +src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
1121 + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
1122 + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
1123 + '(?:' + src[t.PRERELEASE] + ')?' +
1124 + src[t.BUILD] + '?' +
1125 + ')?)?'
1126 +
1127 +tok('XRANGEPLAINLOOSE')
1128 +src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
1129 + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
1130 + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
1131 + '(?:' + src[t.PRERELEASELOOSE] + ')?' +
1132 + src[t.BUILD] + '?' +
1133 + ')?)?'
1134 +
1135 +tok('XRANGE')
1136 +src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$'
1137 +tok('XRANGELOOSE')
1138 +src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'
1139 +
1140 +// Coercion.
1141 +// Extract anything that could conceivably be a part of a valid semver
1142 +tok('COERCE')
1143 +src[t.COERCE] = '(^|[^\\d])' +
1144 + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
1145 + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
1146 + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
1147 + '(?:$|[^\\d])'
1148 +tok('COERCERTL')
1149 +re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g')
1150 +
1151 +// Tilde ranges.
1152 +// Meaning is "reasonably at or greater than"
1153 +tok('LONETILDE')
1154 +src[t.LONETILDE] = '(?:~>?)'
1155 +
1156 +tok('TILDETRIM')
1157 +src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+'
1158 +re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g')
1159 +var tildeTrimReplace = '$1~'
1160 +
1161 +tok('TILDE')
1162 +src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$'
1163 +tok('TILDELOOSE')
1164 +src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'
1165 +
1166 +// Caret ranges.
1167 +// Meaning is "at least and backwards compatible with"
1168 +tok('LONECARET')
1169 +src[t.LONECARET] = '(?:\\^)'
1170 +
1171 +tok('CARETTRIM')
1172 +src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+'
1173 +re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g')
1174 +var caretTrimReplace = '$1^'
1175 +
1176 +tok('CARET')
1177 +src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$'
1178 +tok('CARETLOOSE')
1179 +src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'
1180 +
1181 +// A simple gt/lt/eq thing, or just "" to indicate "any version"
1182 +tok('COMPARATORLOOSE')
1183 +src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$'
1184 +tok('COMPARATOR')
1185 +src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'
1186 +
1187 +// An expression to strip any whitespace between the gtlt and the thing
1188 +// it modifies, so that `> 1.2.3` ==> `>1.2.3`
1189 +tok('COMPARATORTRIM')
1190 +src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
1191 + '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'
1192 +
1193 +// this one has to use the /g flag
1194 +re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g')
1195 +var comparatorTrimReplace = '$1$2$3'
1196 +
1197 +// Something like `1.2.3 - 1.2.4`
1198 +// Note that these all use the loose form, because they'll be
1199 +// checked against either the strict or loose comparator form
1200 +// later.
1201 +tok('HYPHENRANGE')
1202 +src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
1203 + '\\s+-\\s+' +
1204 + '(' + src[t.XRANGEPLAIN] + ')' +
1205 + '\\s*$'
1206 +
1207 +tok('HYPHENRANGELOOSE')
1208 +src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
1209 + '\\s+-\\s+' +
1210 + '(' + src[t.XRANGEPLAINLOOSE] + ')' +
1211 + '\\s*$'
1212 +
1213 +// Star ranges basically just allow anything at all.
1214 +tok('STAR')
1215 +src[t.STAR] = '(<|>)?=?\\s*\\*'
1216 +
1217 +// Compile to actual regexp objects.
1218 +// All are flag-free, unless they were created above with a flag.
1219 +for (var i = 0; i < R; i++) {
1220 + debug(i, src[i])
1221 + if (!re[i]) {
1222 + re[i] = new RegExp(src[i])
1223 + }
1224 +}
1225 +
1226 +exports.parse = parse
1227 +function parse (version, options) {
1228 + if (!options || typeof options !== 'object') {
1229 + options = {
1230 + loose: !!options,
1231 + includePrerelease: false
1232 + }
1233 + }
1234 +
1235 + if (version instanceof SemVer) {
1236 + return version
1237 + }
1238 +
1239 + if (typeof version !== 'string') {
1240 + return null
1241 + }
1242 +
1243 + if (version.length > MAX_LENGTH) {
1244 + return null
1245 + }
1246 +
1247 + var r = options.loose ? re[t.LOOSE] : re[t.FULL]
1248 + if (!r.test(version)) {
1249 + return null
1250 + }
1251 +
1252 + try {
1253 + return new SemVer(version, options)
1254 + } catch (er) {
1255 + return null
1256 + }
1257 +}
1258 +
1259 +exports.valid = valid
1260 +function valid (version, options) {
1261 + var v = parse(version, options)
1262 + return v ? v.version : null
1263 +}
1264 +
1265 +exports.clean = clean
1266 +function clean (version, options) {
1267 + var s = parse(version.trim().replace(/^[=v]+/, ''), options)
1268 + return s ? s.version : null
1269 +}
1270 +
1271 +exports.SemVer = SemVer
1272 +
1273 +function SemVer (version, options) {
1274 + if (!options || typeof options !== 'object') {
1275 + options = {
1276 + loose: !!options,
1277 + includePrerelease: false
1278 + }
1279 + }
1280 + if (version instanceof SemVer) {
1281 + if (version.loose === options.loose) {
1282 + return version
1283 + } else {
1284 + version = version.version
1285 + }
1286 + } else if (typeof version !== 'string') {
1287 + throw new TypeError('Invalid Version: ' + version)
1288 + }
1289 +
1290 + if (version.length > MAX_LENGTH) {
1291 + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
1292 + }
1293 +
1294 + if (!(this instanceof SemVer)) {
1295 + return new SemVer(version, options)
1296 + }
1297 +
1298 + debug('SemVer', version, options)
1299 + this.options = options
1300 + this.loose = !!options.loose
1301 +
1302 + var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
1303 +
1304 + if (!m) {
1305 + throw new TypeError('Invalid Version: ' + version)
1306 + }
1307 +
1308 + this.raw = version
1309 +
1310 + // these are actually numbers
1311 + this.major = +m[1]
1312 + this.minor = +m[2]
1313 + this.patch = +m[3]
1314 +
1315 + if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
1316 + throw new TypeError('Invalid major version')
1317 + }
1318 +
1319 + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
1320 + throw new TypeError('Invalid minor version')
1321 + }
1322 +
1323 + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
1324 + throw new TypeError('Invalid patch version')
1325 + }
1326 +
1327 + // numberify any prerelease numeric ids
1328 + if (!m[4]) {
1329 + this.prerelease = []
1330 + } else {
1331 + this.prerelease = m[4].split('.').map(function (id) {
1332 + if (/^[0-9]+$/.test(id)) {
1333 + var num = +id
1334 + if (num >= 0 && num < MAX_SAFE_INTEGER) {
1335 + return num
1336 + }
1337 + }
1338 + return id
1339 + })
1340 + }
1341 +
1342 + this.build = m[5] ? m[5].split('.') : []
1343 + this.format()
1344 +}
1345 +
1346 +SemVer.prototype.format = function () {
1347 + this.version = this.major + '.' + this.minor + '.' + this.patch
1348 + if (this.prerelease.length) {
1349 + this.version += '-' + this.prerelease.join('.')
1350 + }
1351 + return this.version
1352 +}
1353 +
1354 +SemVer.prototype.toString = function () {
1355 + return this.version
1356 +}
1357 +
1358 +SemVer.prototype.compare = function (other) {
1359 + debug('SemVer.compare', this.version, this.options, other)
1360 + if (!(other instanceof SemVer)) {
1361 + other = new SemVer(other, this.options)
1362 + }
1363 +
1364 + return this.compareMain(other) || this.comparePre(other)
1365 +}
1366 +
1367 +SemVer.prototype.compareMain = function (other) {
1368 + if (!(other instanceof SemVer)) {
1369 + other = new SemVer(other, this.options)
1370 + }
1371 +
1372 + return compareIdentifiers(this.major, other.major) ||
1373 + compareIdentifiers(this.minor, other.minor) ||
1374 + compareIdentifiers(this.patch, other.patch)
1375 +}
1376 +
1377 +SemVer.prototype.comparePre = function (other) {
1378 + if (!(other instanceof SemVer)) {
1379 + other = new SemVer(other, this.options)
1380 + }
1381 +
1382 + // NOT having a prerelease is > having one
1383 + if (this.prerelease.length && !other.prerelease.length) {
1384 + return -1
1385 + } else if (!this.prerelease.length && other.prerelease.length) {
1386 + return 1
1387 + } else if (!this.prerelease.length && !other.prerelease.length) {
1388 + return 0
1389 + }
1390 +
1391 + var i = 0
1392 + do {
1393 + var a = this.prerelease[i]
1394 + var b = other.prerelease[i]
1395 + debug('prerelease compare', i, a, b)
1396 + if (a === undefined && b === undefined) {
1397 + return 0
1398 + } else if (b === undefined) {
1399 + return 1
1400 + } else if (a === undefined) {
1401 + return -1
1402 + } else if (a === b) {
1403 + continue
1404 + } else {
1405 + return compareIdentifiers(a, b)
1406 + }
1407 + } while (++i)
1408 +}
1409 +
1410 +SemVer.prototype.compareBuild = function (other) {
1411 + if (!(other instanceof SemVer)) {
1412 + other = new SemVer(other, this.options)
1413 + }
1414 +
1415 + var i = 0
1416 + do {
1417 + var a = this.build[i]
1418 + var b = other.build[i]
1419 + debug('prerelease compare', i, a, b)
1420 + if (a === undefined && b === undefined) {
1421 + return 0
1422 + } else if (b === undefined) {
1423 + return 1
1424 + } else if (a === undefined) {
1425 + return -1
1426 + } else if (a === b) {
1427 + continue
1428 + } else {
1429 + return compareIdentifiers(a, b)
1430 + }
1431 + } while (++i)
1432 +}
1433 +
1434 +// preminor will bump the version up to the next minor release, and immediately
1435 +// down to pre-release. premajor and prepatch work the same way.
1436 +SemVer.prototype.inc = function (release, identifier) {
1437 + switch (release) {
1438 + case 'premajor':
1439 + this.prerelease.length = 0
1440 + this.patch = 0
1441 + this.minor = 0
1442 + this.major++
1443 + this.inc('pre', identifier)
1444 + break
1445 + case 'preminor':
1446 + this.prerelease.length = 0
1447 + this.patch = 0
1448 + this.minor++
1449 + this.inc('pre', identifier)
1450 + break
1451 + case 'prepatch':
1452 + // If this is already a prerelease, it will bump to the next version
1453 + // drop any prereleases that might already exist, since they are not
1454 + // relevant at this point.
1455 + this.prerelease.length = 0
1456 + this.inc('patch', identifier)
1457 + this.inc('pre', identifier)
1458 + break
1459 + // If the input is a non-prerelease version, this acts the same as
1460 + // prepatch.
1461 + case 'prerelease':
1462 + if (this.prerelease.length === 0) {
1463 + this.inc('patch', identifier)
1464 + }
1465 + this.inc('pre', identifier)
1466 + break
1467 +
1468 + case 'major':
1469 + // If this is a pre-major version, bump up to the same major version.
1470 + // Otherwise increment major.
1471 + // 1.0.0-5 bumps to 1.0.0
1472 + // 1.1.0 bumps to 2.0.0
1473 + if (this.minor !== 0 ||
1474 + this.patch !== 0 ||
1475 + this.prerelease.length === 0) {
1476 + this.major++
1477 + }
1478 + this.minor = 0
1479 + this.patch = 0
1480 + this.prerelease = []
1481 + break
1482 + case 'minor':
1483 + // If this is a pre-minor version, bump up to the same minor version.
1484 + // Otherwise increment minor.
1485 + // 1.2.0-5 bumps to 1.2.0
1486 + // 1.2.1 bumps to 1.3.0
1487 + if (this.patch !== 0 || this.prerelease.length === 0) {
1488 + this.minor++
1489 + }
1490 + this.patch = 0
1491 + this.prerelease = []
1492 + break
1493 + case 'patch':
1494 + // If this is not a pre-release version, it will increment the patch.
1495 + // If it is a pre-release it will bump up to the same patch version.
1496 + // 1.2.0-5 patches to 1.2.0
1497 + // 1.2.0 patches to 1.2.1
1498 + if (this.prerelease.length === 0) {
1499 + this.patch++
1500 + }
1501 + this.prerelease = []
1502 + break
1503 + // This probably shouldn't be used publicly.
1504 + // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
1505 + case 'pre':
1506 + if (this.prerelease.length === 0) {
1507 + this.prerelease = [0]
1508 + } else {
1509 + var i = this.prerelease.length
1510 + while (--i >= 0) {
1511 + if (typeof this.prerelease[i] === 'number') {
1512 + this.prerelease[i]++
1513 + i = -2
1514 + }
1515 + }
1516 + if (i === -1) {
1517 + // didn't increment anything
1518 + this.prerelease.push(0)
1519 + }
1520 + }
1521 + if (identifier) {
1522 + // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
1523 + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
1524 + if (this.prerelease[0] === identifier) {
1525 + if (isNaN(this.prerelease[1])) {
1526 + this.prerelease = [identifier, 0]
1527 + }
1528 + } else {
1529 + this.prerelease = [identifier, 0]
1530 + }
1531 + }
1532 + break
1533 +
1534 + default:
1535 + throw new Error('invalid increment argument: ' + release)
1536 + }
1537 + this.format()
1538 + this.raw = this.version
1539 + return this
1540 +}
1541 +
1542 +exports.inc = inc
1543 +function inc (version, release, loose, identifier) {
1544 + if (typeof (loose) === 'string') {
1545 + identifier = loose
1546 + loose = undefined
1547 + }
1548 +
1549 + try {
1550 + return new SemVer(version, loose).inc(release, identifier).version
1551 + } catch (er) {
1552 + return null
1553 + }
1554 +}
1555 +
1556 +exports.diff = diff
1557 +function diff (version1, version2) {
1558 + if (eq(version1, version2)) {
1559 + return null
1560 + } else {
1561 + var v1 = parse(version1)
1562 + var v2 = parse(version2)
1563 + var prefix = ''
1564 + if (v1.prerelease.length || v2.prerelease.length) {
1565 + prefix = 'pre'
1566 + var defaultResult = 'prerelease'
1567 + }
1568 + for (var key in v1) {
1569 + if (key === 'major' || key === 'minor' || key === 'patch') {
1570 + if (v1[key] !== v2[key]) {
1571 + return prefix + key
1572 + }
1573 + }
1574 + }
1575 + return defaultResult // may be undefined
1576 + }
1577 +}
1578 +
1579 +exports.compareIdentifiers = compareIdentifiers
1580 +
1581 +var numeric = /^[0-9]+$/
1582 +function compareIdentifiers (a, b) {
1583 + var anum = numeric.test(a)
1584 + var bnum = numeric.test(b)
1585 +
1586 + if (anum && bnum) {
1587 + a = +a
1588 + b = +b
1589 + }
1590 +
1591 + return a === b ? 0
1592 + : (anum && !bnum) ? -1
1593 + : (bnum && !anum) ? 1
1594 + : a < b ? -1
1595 + : 1
1596 +}
1597 +
1598 +exports.rcompareIdentifiers = rcompareIdentifiers
1599 +function rcompareIdentifiers (a, b) {
1600 + return compareIdentifiers(b, a)
1601 +}
1602 +
1603 +exports.major = major
1604 +function major (a, loose) {
1605 + return new SemVer(a, loose).major
1606 +}
1607 +
1608 +exports.minor = minor
1609 +function minor (a, loose) {
1610 + return new SemVer(a, loose).minor
1611 +}
1612 +
1613 +exports.patch = patch
1614 +function patch (a, loose) {
1615 + return new SemVer(a, loose).patch
1616 +}
1617 +
1618 +exports.compare = compare
1619 +function compare (a, b, loose) {
1620 + return new SemVer(a, loose).compare(new SemVer(b, loose))
1621 +}
1622 +
1623 +exports.compareLoose = compareLoose
1624 +function compareLoose (a, b) {
1625 + return compare(a, b, true)
1626 +}
1627 +
1628 +exports.compareBuild = compareBuild
1629 +function compareBuild (a, b, loose) {
1630 + var versionA = new SemVer(a, loose)
1631 + var versionB = new SemVer(b, loose)
1632 + return versionA.compare(versionB) || versionA.compareBuild(versionB)
1633 +}
1634 +
1635 +exports.rcompare = rcompare
1636 +function rcompare (a, b, loose) {
1637 + return compare(b, a, loose)
1638 +}
1639 +
1640 +exports.sort = sort
1641 +function sort (list, loose) {
1642 + return list.sort(function (a, b) {
1643 + return exports.compareBuild(a, b, loose)
1644 + })
1645 +}
1646 +
1647 +exports.rsort = rsort
1648 +function rsort (list, loose) {
1649 + return list.sort(function (a, b) {
1650 + return exports.compareBuild(b, a, loose)
1651 + })
1652 +}
1653 +
1654 +exports.gt = gt
1655 +function gt (a, b, loose) {
1656 + return compare(a, b, loose) > 0
1657 +}
1658 +
1659 +exports.lt = lt
1660 +function lt (a, b, loose) {
1661 + return compare(a, b, loose) < 0
1662 +}
1663 +
1664 +exports.eq = eq
1665 +function eq (a, b, loose) {
1666 + return compare(a, b, loose) === 0
1667 +}
1668 +
1669 +exports.neq = neq
1670 +function neq (a, b, loose) {
1671 + return compare(a, b, loose) !== 0
1672 +}
1673 +
1674 +exports.gte = gte
1675 +function gte (a, b, loose) {
1676 + return compare(a, b, loose) >= 0
1677 +}
1678 +
1679 +exports.lte = lte
1680 +function lte (a, b, loose) {
1681 + return compare(a, b, loose) <= 0
1682 +}
1683 +
1684 +exports.cmp = cmp
1685 +function cmp (a, op, b, loose) {
1686 + switch (op) {
1687 + case '===':
1688 + if (typeof a === 'object')
1689 + a = a.version
1690 + if (typeof b === 'object')
1691 + b = b.version
1692 + return a === b
1693 +
1694 + case '!==':
1695 + if (typeof a === 'object')
1696 + a = a.version
1697 + if (typeof b === 'object')
1698 + b = b.version
1699 + return a !== b
1700 +
1701 + case '':
1702 + case '=':
1703 + case '==':
1704 + return eq(a, b, loose)
1705 +
1706 + case '!=':
1707 + return neq(a, b, loose)
1708 +
1709 + case '>':
1710 + return gt(a, b, loose)
1711 +
1712 + case '>=':
1713 + return gte(a, b, loose)
1714 +
1715 + case '<':
1716 + return lt(a, b, loose)
1717 +
1718 + case '<=':
1719 + return lte(a, b, loose)
1720 +
1721 + default:
1722 + throw new TypeError('Invalid operator: ' + op)
1723 + }
1724 +}
1725 +
1726 +exports.Comparator = Comparator
1727 +function Comparator (comp, options) {
1728 + if (!options || typeof options !== 'object') {
1729 + options = {
1730 + loose: !!options,
1731 + includePrerelease: false
1732 + }
1733 + }
1734 +
1735 + if (comp instanceof Comparator) {
1736 + if (comp.loose === !!options.loose) {
1737 + return comp
1738 + } else {
1739 + comp = comp.value
1740 + }
1741 + }
1742 +
1743 + if (!(this instanceof Comparator)) {
1744 + return new Comparator(comp, options)
1745 + }
1746 +
1747 + debug('comparator', comp, options)
1748 + this.options = options
1749 + this.loose = !!options.loose
1750 + this.parse(comp)
1751 +
1752 + if (this.semver === ANY) {
1753 + this.value = ''
1754 + } else {
1755 + this.value = this.operator + this.semver.version
1756 + }
1757 +
1758 + debug('comp', this)
1759 +}
1760 +
1761 +var ANY = {}
1762 +Comparator.prototype.parse = function (comp) {
1763 + var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
1764 + var m = comp.match(r)
1765 +
1766 + if (!m) {
1767 + throw new TypeError('Invalid comparator: ' + comp)
1768 + }
1769 +
1770 + this.operator = m[1] !== undefined ? m[1] : ''
1771 + if (this.operator === '=') {
1772 + this.operator = ''
1773 + }
1774 +
1775 + // if it literally is just '>' or '' then allow anything.
1776 + if (!m[2]) {
1777 + this.semver = ANY
1778 + } else {
1779 + this.semver = new SemVer(m[2], this.options.loose)
1780 + }
1781 +}
1782 +
1783 +Comparator.prototype.toString = function () {
1784 + return this.value
1785 +}
1786 +
1787 +Comparator.prototype.test = function (version) {
1788 + debug('Comparator.test', version, this.options.loose)
1789 +
1790 + if (this.semver === ANY || version === ANY) {
1791 + return true
1792 + }
1793 +
1794 + if (typeof version === 'string') {
1795 + try {
1796 + version = new SemVer(version, this.options)
1797 + } catch (er) {
1798 + return false
1799 + }
1800 + }
1801 +
1802 + return cmp(version, this.operator, this.semver, this.options)
1803 +}
1804 +
1805 +Comparator.prototype.intersects = function (comp, options) {
1806 + if (!(comp instanceof Comparator)) {
1807 + throw new TypeError('a Comparator is required')
1808 + }
1809 +
1810 + if (!options || typeof options !== 'object') {
1811 + options = {
1812 + loose: !!options,
1813 + includePrerelease: false
1814 + }
1815 + }
1816 +
1817 + var rangeTmp
1818 +
1819 + if (this.operator === '') {
1820 + if (this.value === '') {
1821 + return true
1822 + }
1823 + rangeTmp = new Range(comp.value, options)
1824 + return satisfies(this.value, rangeTmp, options)
1825 + } else if (comp.operator === '') {
1826 + if (comp.value === '') {
1827 + return true
1828 + }
1829 + rangeTmp = new Range(this.value, options)
1830 + return satisfies(comp.semver, rangeTmp, options)
1831 + }
1832 +
1833 + var sameDirectionIncreasing =
1834 + (this.operator === '>=' || this.operator === '>') &&
1835 + (comp.operator === '>=' || comp.operator === '>')
1836 + var sameDirectionDecreasing =
1837 + (this.operator === '<=' || this.operator === '<') &&
1838 + (comp.operator === '<=' || comp.operator === '<')
1839 + var sameSemVer = this.semver.version === comp.semver.version
1840 + var differentDirectionsInclusive =
1841 + (this.operator === '>=' || this.operator === '<=') &&
1842 + (comp.operator === '>=' || comp.operator === '<=')
1843 + var oppositeDirectionsLessThan =
1844 + cmp(this.semver, '<', comp.semver, options) &&
1845 + ((this.operator === '>=' || this.operator === '>') &&
1846 + (comp.operator === '<=' || comp.operator === '<'))
1847 + var oppositeDirectionsGreaterThan =
1848 + cmp(this.semver, '>', comp.semver, options) &&
1849 + ((this.operator === '<=' || this.operator === '<') &&
1850 + (comp.operator === '>=' || comp.operator === '>'))
1851 +
1852 + return sameDirectionIncreasing || sameDirectionDecreasing ||
1853 + (sameSemVer && differentDirectionsInclusive) ||
1854 + oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
1855 +}
1856 +
1857 +exports.Range = Range
1858 +function Range (range, options) {
1859 + if (!options || typeof options !== 'object') {
1860 + options = {
1861 + loose: !!options,
1862 + includePrerelease: false
1863 + }
1864 + }
1865 +
1866 + if (range instanceof Range) {
1867 + if (range.loose === !!options.loose &&
1868 + range.includePrerelease === !!options.includePrerelease) {
1869 + return range
1870 + } else {
1871 + return new Range(range.raw, options)
1872 + }
1873 + }
1874 +
1875 + if (range instanceof Comparator) {
1876 + return new Range(range.value, options)
1877 + }
1878 +
1879 + if (!(this instanceof Range)) {
1880 + return new Range(range, options)
1881 + }
1882 +
1883 + this.options = options
1884 + this.loose = !!options.loose
1885 + this.includePrerelease = !!options.includePrerelease
1886 +
1887 + // First, split based on boolean or ||
1888 + this.raw = range
1889 + this.set = range.split(/\s*\|\|\s*/).map(function (range) {
1890 + return this.parseRange(range.trim())
1891 + }, this).filter(function (c) {
1892 + // throw out any that are not relevant for whatever reason
1893 + return c.length
1894 + })
1895 +
1896 + if (!this.set.length) {
1897 + throw new TypeError('Invalid SemVer Range: ' + range)
1898 + }
1899 +
1900 + this.format()
1901 +}
1902 +
1903 +Range.prototype.format = function () {
1904 + this.range = this.set.map(function (comps) {
1905 + return comps.join(' ').trim()
1906 + }).join('||').trim()
1907 + return this.range
1908 +}
1909 +
1910 +Range.prototype.toString = function () {
1911 + return this.range
1912 +}
1913 +
1914 +Range.prototype.parseRange = function (range) {
1915 + var loose = this.options.loose
1916 + range = range.trim()
1917 + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
1918 + var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
1919 + range = range.replace(hr, hyphenReplace)
1920 + debug('hyphen replace', range)
1921 + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
1922 + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
1923 + debug('comparator trim', range, re[t.COMPARATORTRIM])
1924 +
1925 + // `~ 1.2.3` => `~1.2.3`
1926 + range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
1927 +
1928 + // `^ 1.2.3` => `^1.2.3`
1929 + range = range.replace(re[t.CARETTRIM], caretTrimReplace)
1930 +
1931 + // normalize spaces
1932 + range = range.split(/\s+/).join(' ')
1933 +
1934 + // At this point, the range is completely trimmed and
1935 + // ready to be split into comparators.
1936 +
1937 + var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
1938 + var set = range.split(' ').map(function (comp) {
1939 + return parseComparator(comp, this.options)
1940 + }, this).join(' ').split(/\s+/)
1941 + if (this.options.loose) {
1942 + // in loose mode, throw out any that are not valid comparators
1943 + set = set.filter(function (comp) {
1944 + return !!comp.match(compRe)
1945 + })
1946 + }
1947 + set = set.map(function (comp) {
1948 + return new Comparator(comp, this.options)
1949 + }, this)
1950 +
1951 + return set
1952 +}
1953 +
1954 +Range.prototype.intersects = function (range, options) {
1955 + if (!(range instanceof Range)) {
1956 + throw new TypeError('a Range is required')
1957 + }
1958 +
1959 + return this.set.some(function (thisComparators) {
1960 + return (
1961 + isSatisfiable(thisComparators, options) &&
1962 + range.set.some(function (rangeComparators) {
1963 + return (
1964 + isSatisfiable(rangeComparators, options) &&
1965 + thisComparators.every(function (thisComparator) {
1966 + return rangeComparators.every(function (rangeComparator) {
1967 + return thisComparator.intersects(rangeComparator, options)
1968 + })
1969 + })
1970 + )
1971 + })
1972 + )
1973 + })
1974 +}
1975 +
1976 +// take a set of comparators and determine whether there
1977 +// exists a version which can satisfy it
1978 +function isSatisfiable (comparators, options) {
1979 + var result = true
1980 + var remainingComparators = comparators.slice()
1981 + var testComparator = remainingComparators.pop()
1982 +
1983 + while (result && remainingComparators.length) {
1984 + result = remainingComparators.every(function (otherComparator) {
1985 + return testComparator.intersects(otherComparator, options)
1986 + })
1987 +
1988 + testComparator = remainingComparators.pop()
1989 + }
1990 +
1991 + return result
1992 +}
1993 +
1994 +// Mostly just for testing and legacy API reasons
1995 +exports.toComparators = toComparators
1996 +function toComparators (range, options) {
1997 + return new Range(range, options).set.map(function (comp) {
1998 + return comp.map(function (c) {
1999 + return c.value
2000 + }).join(' ').trim().split(' ')
2001 + })
2002 +}
2003 +
2004 +// comprised of xranges, tildes, stars, and gtlt's at this point.
2005 +// already replaced the hyphen ranges
2006 +// turn into a set of JUST comparators.
2007 +function parseComparator (comp, options) {
2008 + debug('comp', comp, options)
2009 + comp = replaceCarets(comp, options)
2010 + debug('caret', comp)
2011 + comp = replaceTildes(comp, options)
2012 + debug('tildes', comp)
2013 + comp = replaceXRanges(comp, options)
2014 + debug('xrange', comp)
2015 + comp = replaceStars(comp, options)
2016 + debug('stars', comp)
2017 + return comp
2018 +}
2019 +
2020 +function isX (id) {
2021 + return !id || id.toLowerCase() === 'x' || id === '*'
2022 +}
2023 +
2024 +// ~, ~> --> * (any, kinda silly)
2025 +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
2026 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
2027 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
2028 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
2029 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
2030 +function replaceTildes (comp, options) {
2031 + return comp.trim().split(/\s+/).map(function (comp) {
2032 + return replaceTilde(comp, options)
2033 + }).join(' ')
2034 +}
2035 +
2036 +function replaceTilde (comp, options) {
2037 + var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
2038 + return comp.replace(r, function (_, M, m, p, pr) {
2039 + debug('tilde', comp, _, M, m, p, pr)
2040 + var ret
2041 +
2042 + if (isX(M)) {
2043 + ret = ''
2044 + } else if (isX(m)) {
2045 + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
2046 + } else if (isX(p)) {
2047 + // ~1.2 == >=1.2.0 <1.3.0
2048 + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
2049 + } else if (pr) {
2050 + debug('replaceTilde pr', pr)
2051 + ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
2052 + ' <' + M + '.' + (+m + 1) + '.0'
2053 + } else {
2054 + // ~1.2.3 == >=1.2.3 <1.3.0
2055 + ret = '>=' + M + '.' + m + '.' + p +
2056 + ' <' + M + '.' + (+m + 1) + '.0'
2057 + }
2058 +
2059 + debug('tilde return', ret)
2060 + return ret
2061 + })
2062 +}
2063 +
2064 +// ^ --> * (any, kinda silly)
2065 +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
2066 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
2067 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
2068 +// ^1.2.3 --> >=1.2.3 <2.0.0
2069 +// ^1.2.0 --> >=1.2.0 <2.0.0
2070 +function replaceCarets (comp, options) {
2071 + return comp.trim().split(/\s+/).map(function (comp) {
2072 + return replaceCaret(comp, options)
2073 + }).join(' ')
2074 +}
2075 +
2076 +function replaceCaret (comp, options) {
2077 + debug('caret', comp, options)
2078 + var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
2079 + return comp.replace(r, function (_, M, m, p, pr) {
2080 + debug('caret', comp, _, M, m, p, pr)
2081 + var ret
2082 +
2083 + if (isX(M)) {
2084 + ret = ''
2085 + } else if (isX(m)) {
2086 + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
2087 + } else if (isX(p)) {
2088 + if (M === '0') {
2089 + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
2090 + } else {
2091 + ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
2092 + }
2093 + } else if (pr) {
2094 + debug('replaceCaret pr', pr)
2095 + if (M === '0') {
2096 + if (m === '0') {
2097 + ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
2098 + ' <' + M + '.' + m + '.' + (+p + 1)
2099 + } else {
2100 + ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
2101 + ' <' + M + '.' + (+m + 1) + '.0'
2102 + }
2103 + } else {
2104 + ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
2105 + ' <' + (+M + 1) + '.0.0'
2106 + }
2107 + } else {
2108 + debug('no pr')
2109 + if (M === '0') {
2110 + if (m === '0') {
2111 + ret = '>=' + M + '.' + m + '.' + p +
2112 + ' <' + M + '.' + m + '.' + (+p + 1)
2113 + } else {
2114 + ret = '>=' + M + '.' + m + '.' + p +
2115 + ' <' + M + '.' + (+m + 1) + '.0'
2116 + }
2117 + } else {
2118 + ret = '>=' + M + '.' + m + '.' + p +
2119 + ' <' + (+M + 1) + '.0.0'
2120 + }
2121 + }
2122 +
2123 + debug('caret return', ret)
2124 + return ret
2125 + })
2126 +}
2127 +
2128 +function replaceXRanges (comp, options) {
2129 + debug('replaceXRanges', comp, options)
2130 + return comp.split(/\s+/).map(function (comp) {
2131 + return replaceXRange(comp, options)
2132 + }).join(' ')
2133 +}
2134 +
2135 +function replaceXRange (comp, options) {
2136 + comp = comp.trim()
2137 + var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
2138 + return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
2139 + debug('xRange', comp, ret, gtlt, M, m, p, pr)
2140 + var xM = isX(M)
2141 + var xm = xM || isX(m)
2142 + var xp = xm || isX(p)
2143 + var anyX = xp
2144 +
2145 + if (gtlt === '=' && anyX) {
2146 + gtlt = ''
2147 + }
2148 +
2149 + // if we're including prereleases in the match, then we need
2150 + // to fix this to -0, the lowest possible prerelease value
2151 + pr = options.includePrerelease ? '-0' : ''
2152 +
2153 + if (xM) {
2154 + if (gtlt === '>' || gtlt === '<') {
2155 + // nothing is allowed
2156 + ret = '<0.0.0-0'
2157 + } else {
2158 + // nothing is forbidden
2159 + ret = '*'
2160 + }
2161 + } else if (gtlt && anyX) {
2162 + // we know patch is an x, because we have any x at all.
2163 + // replace X with 0
2164 + if (xm) {
2165 + m = 0
2166 + }
2167 + p = 0
2168 +
2169 + if (gtlt === '>') {
2170 + // >1 => >=2.0.0
2171 + // >1.2 => >=1.3.0
2172 + // >1.2.3 => >= 1.2.4
2173 + gtlt = '>='
2174 + if (xm) {
2175 + M = +M + 1
2176 + m = 0
2177 + p = 0
2178 + } else {
2179 + m = +m + 1
2180 + p = 0
2181 + }
2182 + } else if (gtlt === '<=') {
2183 + // <=0.7.x is actually <0.8.0, since any 0.7.x should
2184 + // pass. Similarly, <=7.x is actually <8.0.0, etc.
2185 + gtlt = '<'
2186 + if (xm) {
2187 + M = +M + 1
2188 + } else {
2189 + m = +m + 1
2190 + }
2191 + }
2192 +
2193 + ret = gtlt + M + '.' + m + '.' + p + pr
2194 + } else if (xm) {
2195 + ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr
2196 + } else if (xp) {
2197 + ret = '>=' + M + '.' + m + '.0' + pr +
2198 + ' <' + M + '.' + (+m + 1) + '.0' + pr
2199 + }
2200 +
2201 + debug('xRange return', ret)
2202 +
2203 + return ret
2204 + })
2205 +}
2206 +
2207 +// Because * is AND-ed with everything else in the comparator,
2208 +// and '' means "any version", just remove the *s entirely.
2209 +function replaceStars (comp, options) {
2210 + debug('replaceStars', comp, options)
2211 + // Looseness is ignored here. star is always as loose as it gets!
2212 + return comp.trim().replace(re[t.STAR], '')
2213 +}
2214 +
2215 +// This function is passed to string.replace(re[t.HYPHENRANGE])
2216 +// M, m, patch, prerelease, build
2217 +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
2218 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
2219 +// 1.2 - 3.4 => >=1.2.0 <3.5.0
2220 +function hyphenReplace ($0,
2221 + from, fM, fm, fp, fpr, fb,
2222 + to, tM, tm, tp, tpr, tb) {
2223 + if (isX(fM)) {
2224 + from = ''
2225 + } else if (isX(fm)) {
2226 + from = '>=' + fM + '.0.0'
2227 + } else if (isX(fp)) {
2228 + from = '>=' + fM + '.' + fm + '.0'
2229 + } else {
2230 + from = '>=' + from
2231 + }
2232 +
2233 + if (isX(tM)) {
2234 + to = ''
2235 + } else if (isX(tm)) {
2236 + to = '<' + (+tM + 1) + '.0.0'
2237 + } else if (isX(tp)) {
2238 + to = '<' + tM + '.' + (+tm + 1) + '.0'
2239 + } else if (tpr) {
2240 + to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
2241 + } else {
2242 + to = '<=' + to
2243 + }
2244 +
2245 + return (from + ' ' + to).trim()
2246 +}
2247 +
2248 +// if ANY of the sets match ALL of its comparators, then pass
2249 +Range.prototype.test = function (version) {
2250 + if (!version) {
2251 + return false
2252 + }
2253 +
2254 + if (typeof version === 'string') {
2255 + try {
2256 + version = new SemVer(version, this.options)
2257 + } catch (er) {
2258 + return false
2259 + }
2260 + }
2261 +
2262 + for (var i = 0; i < this.set.length; i++) {
2263 + if (testSet(this.set[i], version, this.options)) {
2264 + return true
2265 + }
2266 + }
2267 + return false
2268 +}
2269 +
2270 +function testSet (set, version, options) {
2271 + for (var i = 0; i < set.length; i++) {
2272 + if (!set[i].test(version)) {
2273 + return false
2274 + }
2275 + }
2276 +
2277 + if (version.prerelease.length && !options.includePrerelease) {
2278 + // Find the set of versions that are allowed to have prereleases
2279 + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
2280 + // That should allow `1.2.3-pr.2` to pass.
2281 + // However, `1.2.4-alpha.notready` should NOT be allowed,
2282 + // even though it's within the range set by the comparators.
2283 + for (i = 0; i < set.length; i++) {
2284 + debug(set[i].semver)
2285 + if (set[i].semver === ANY) {
2286 + continue
2287 + }
2288 +
2289 + if (set[i].semver.prerelease.length > 0) {
2290 + var allowed = set[i].semver
2291 + if (allowed.major === version.major &&
2292 + allowed.minor === version.minor &&
2293 + allowed.patch === version.patch) {
2294 + return true
2295 + }
2296 + }
2297 + }
2298 +
2299 + // Version has a -pre, but it's not one of the ones we like.
2300 + return false
2301 + }
2302 +
2303 + return true
2304 +}
2305 +
2306 +exports.satisfies = satisfies
2307 +function satisfies (version, range, options) {
2308 + try {
2309 + range = new Range(range, options)
2310 + } catch (er) {
2311 + return false
2312 + }
2313 + return range.test(version)
2314 +}
2315 +
2316 +exports.maxSatisfying = maxSatisfying
2317 +function maxSatisfying (versions, range, options) {
2318 + var max = null
2319 + var maxSV = null
2320 + try {
2321 + var rangeObj = new Range(range, options)
2322 + } catch (er) {
2323 + return null
2324 + }
2325 + versions.forEach(function (v) {
2326 + if (rangeObj.test(v)) {
2327 + // satisfies(v, range, options)
2328 + if (!max || maxSV.compare(v) === -1) {
2329 + // compare(max, v, true)
2330 + max = v
2331 + maxSV = new SemVer(max, options)
2332 + }
2333 + }
2334 + })
2335 + return max
2336 +}
2337 +
2338 +exports.minSatisfying = minSatisfying
2339 +function minSatisfying (versions, range, options) {
2340 + var min = null
2341 + var minSV = null
2342 + try {
2343 + var rangeObj = new Range(range, options)
2344 + } catch (er) {
2345 + return null
2346 + }
2347 + versions.forEach(function (v) {
2348 + if (rangeObj.test(v)) {
2349 + // satisfies(v, range, options)
2350 + if (!min || minSV.compare(v) === 1) {
2351 + // compare(min, v, true)
2352 + min = v
2353 + minSV = new SemVer(min, options)
2354 + }
2355 + }
2356 + })
2357 + return min
2358 +}
2359 +
2360 +exports.minVersion = minVersion
2361 +function minVersion (range, loose) {
2362 + range = new Range(range, loose)
2363 +
2364 + var minver = new SemVer('0.0.0')
2365 + if (range.test(minver)) {
2366 + return minver
2367 + }
2368 +
2369 + minver = new SemVer('0.0.0-0')
2370 + if (range.test(minver)) {
2371 + return minver
2372 + }
2373 +
2374 + minver = null
2375 + for (var i = 0; i < range.set.length; ++i) {
2376 + var comparators = range.set[i]
2377 +
2378 + comparators.forEach(function (comparator) {
2379 + // Clone to avoid manipulating the comparator's semver object.
2380 + var compver = new SemVer(comparator.semver.version)
2381 + switch (comparator.operator) {
2382 + case '>':
2383 + if (compver.prerelease.length === 0) {
2384 + compver.patch++
2385 + } else {
2386 + compver.prerelease.push(0)
2387 + }
2388 + compver.raw = compver.format()
2389 + /* fallthrough */
2390 + case '':
2391 + case '>=':
2392 + if (!minver || gt(minver, compver)) {
2393 + minver = compver
2394 + }
2395 + break
2396 + case '<':
2397 + case '<=':
2398 + /* Ignore maximum versions */
2399 + break
2400 + /* istanbul ignore next */
2401 + default:
2402 + throw new Error('Unexpected operation: ' + comparator.operator)
2403 + }
2404 + })
2405 + }
2406 +
2407 + if (minver && range.test(minver)) {
2408 + return minver
2409 + }
2410 +
2411 + return null
2412 +}
2413 +
2414 +exports.validRange = validRange
2415 +function validRange (range, options) {
2416 + try {
2417 + // Return '*' instead of '' so that truthiness works.
2418 + // This will throw if it's invalid anyway
2419 + return new Range(range, options).range || '*'
2420 + } catch (er) {
2421 + return null
2422 + }
2423 +}
2424 +
2425 +// Determine if version is less than all the versions possible in the range
2426 +exports.ltr = ltr
2427 +function ltr (version, range, options) {
2428 + return outside(version, range, '<', options)
2429 +}
2430 +
2431 +// Determine if version is greater than all the versions possible in the range.
2432 +exports.gtr = gtr
2433 +function gtr (version, range, options) {
2434 + return outside(version, range, '>', options)
2435 +}
2436 +
2437 +exports.outside = outside
2438 +function outside (version, range, hilo, options) {
2439 + version = new SemVer(version, options)
2440 + range = new Range(range, options)
2441 +
2442 + var gtfn, ltefn, ltfn, comp, ecomp
2443 + switch (hilo) {
2444 + case '>':
2445 + gtfn = gt
2446 + ltefn = lte
2447 + ltfn = lt
2448 + comp = '>'
2449 + ecomp = '>='
2450 + break
2451 + case '<':
2452 + gtfn = lt
2453 + ltefn = gte
2454 + ltfn = gt
2455 + comp = '<'
2456 + ecomp = '<='
2457 + break
2458 + default:
2459 + throw new TypeError('Must provide a hilo val of "<" or ">"')
2460 + }
2461 +
2462 + // If it satisifes the range it is not outside
2463 + if (satisfies(version, range, options)) {
2464 + return false
2465 + }
2466 +
2467 + // From now on, variable terms are as if we're in "gtr" mode.
2468 + // but note that everything is flipped for the "ltr" function.
2469 +
2470 + for (var i = 0; i < range.set.length; ++i) {
2471 + var comparators = range.set[i]
2472 +
2473 + var high = null
2474 + var low = null
2475 +
2476 + comparators.forEach(function (comparator) {
2477 + if (comparator.semver === ANY) {
2478 + comparator = new Comparator('>=0.0.0')
2479 + }
2480 + high = high || comparator
2481 + low = low || comparator
2482 + if (gtfn(comparator.semver, high.semver, options)) {
2483 + high = comparator
2484 + } else if (ltfn(comparator.semver, low.semver, options)) {
2485 + low = comparator
2486 + }
2487 + })
2488 +
2489 + // If the edge version comparator has a operator then our version
2490 + // isn't outside it
2491 + if (high.operator === comp || high.operator === ecomp) {
2492 + return false
2493 + }
2494 +
2495 + // If the lowest version comparator has an operator and our version
2496 + // is less than it then it isn't higher than the range
2497 + if ((!low.operator || low.operator === comp) &&
2498 + ltefn(version, low.semver)) {
2499 + return false
2500 + } else if (low.operator === ecomp && ltfn(version, low.semver)) {
2501 + return false
2502 + }
2503 + }
2504 + return true
2505 +}
2506 +
2507 +exports.prerelease = prerelease
2508 +function prerelease (version, options) {
2509 + var parsed = parse(version, options)
2510 + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
2511 +}
2512 +
2513 +exports.intersects = intersects
2514 +function intersects (r1, r2, options) {
2515 + r1 = new Range(r1, options)
2516 + r2 = new Range(r2, options)
2517 + return r1.intersects(r2)
2518 +}
2519 +
2520 +exports.coerce = coerce
2521 +function coerce (version, options) {
2522 + if (version instanceof SemVer) {
2523 + return version
2524 + }
2525 +
2526 + if (typeof version === 'number') {
2527 + version = String(version)
2528 + }
2529 +
2530 + if (typeof version !== 'string') {
2531 + return null
2532 + }
2533 +
2534 + options = options || {}
2535 +
2536 + var match = null
2537 + if (!options.rtl) {
2538 + match = version.match(re[t.COERCE])
2539 + } else {
2540 + // Find the right-most coercible string that does not share
2541 + // a terminus with a more left-ward coercible string.
2542 + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
2543 + //
2544 + // Walk through the string checking with a /g regexp
2545 + // Manually set the index so as to pick up overlapping matches.
2546 + // Stop when we get a match that ends at the string end, since no
2547 + // coercible string can be more right-ward without the same terminus.
2548 + var next
2549 + while ((next = re[t.COERCERTL].exec(version)) &&
2550 + (!match || match.index + match[0].length !== version.length)
2551 + ) {
2552 + if (!match ||
2553 + next.index + next[0].length !== match.index + match[0].length) {
2554 + match = next
2555 + }
2556 + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
2557 + }
2558 + // leave it in a clean state
2559 + re[t.COERCERTL].lastIndex = -1
2560 + }
2561 +
2562 + if (match === null) {
2563 + return null
2564 + }
2565 +
2566 + return parse(match[2] +
2567 + '.' + (match[3] || '0') +
2568 + '.' + (match[4] || '0'), options)
2569 +}
2570 +
2571 +
2572 +/***/ }),
2573 +
2574 +/***/ 357:
2575 +/***/ (function(module) {
2576 +
2577 +module.exports = require("assert");
2578 +
2579 +/***/ }),
2580 +
2581 +/***/ 408:
2582 +/***/ (function(__unusedmodule, exports, __webpack_require__) {
2583 +
2584 +"use strict";
2585 +
2586 +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2587 + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2588 + return new (P || (P = Promise))(function (resolve, reject) {
2589 + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2590 + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2591 + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2592 + step((generator = generator.apply(thisArg, _arguments || [])).next());
2593 + });
2594 +};
2595 +var _a;
2596 +Object.defineProperty(exports, "__esModule", { value: true });
2597 +const assert_1 = __webpack_require__(357);
2598 +const fs = __webpack_require__(747);
2599 +const path = __webpack_require__(622);
2600 +_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;
2601 +exports.IS_WINDOWS = process.platform === 'win32';
2602 +function exists(fsPath) {
2603 + return __awaiter(this, void 0, void 0, function* () {
2604 + try {
2605 + yield exports.stat(fsPath);
2606 + }
2607 + catch (err) {
2608 + if (err.code === 'ENOENT') {
2609 + return false;
2610 + }
2611 + throw err;
2612 + }
2613 + return true;
2614 + });
2615 +}
2616 +exports.exists = exists;
2617 +function isDirectory(fsPath, useStat = false) {
2618 + return __awaiter(this, void 0, void 0, function* () {
2619 + const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
2620 + return stats.isDirectory();
2621 + });
2622 +}
2623 +exports.isDirectory = isDirectory;
2624 +/**
2625 + * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
2626 + * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
2627 + */
2628 +function isRooted(p) {
2629 + p = normalizeSeparators(p);
2630 + if (!p) {
2631 + throw new Error('isRooted() parameter "p" cannot be empty');
2632 + }
2633 + if (exports.IS_WINDOWS) {
2634 + return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
2635 + ); // e.g. C: or C:\hello
2636 + }
2637 + return p.startsWith('/');
2638 +}
2639 +exports.isRooted = isRooted;
2640 +/**
2641 + * Recursively create a directory at `fsPath`.
2642 + *
2643 + * This implementation is optimistic, meaning it attempts to create the full
2644 + * path first, and backs up the path stack from there.
2645 + *
2646 + * @param fsPath The path to create
2647 + * @param maxDepth The maximum recursion depth
2648 + * @param depth The current recursion depth
2649 + */
2650 +function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
2651 + return __awaiter(this, void 0, void 0, function* () {
2652 + assert_1.ok(fsPath, 'a path argument must be provided');
2653 + fsPath = path.resolve(fsPath);
2654 + if (depth >= maxDepth)
2655 + return exports.mkdir(fsPath);
2656 + try {
2657 + yield exports.mkdir(fsPath);
2658 + return;
2659 + }
2660 + catch (err) {
2661 + switch (err.code) {
2662 + case 'ENOENT': {
2663 + yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
2664 + yield exports.mkdir(fsPath);
2665 + return;
2666 + }
2667 + default: {
2668 + let stats;
2669 + try {
2670 + stats = yield exports.stat(fsPath);
2671 + }
2672 + catch (err2) {
2673 + throw err;
2674 + }
2675 + if (!stats.isDirectory())
2676 + throw err;
2677 + }
2678 + }
2679 + }
2680 + });
2681 +}
2682 +exports.mkdirP = mkdirP;
2683 +/**
2684 + * Best effort attempt to determine whether a file exists and is executable.
2685 + * @param filePath file path to check
2686 + * @param extensions additional file extensions to try
2687 + * @return if file exists and is executable, returns the file path. otherwise empty string.
2688 + */
2689 +function tryGetExecutablePath(filePath, extensions) {
2690 + return __awaiter(this, void 0, void 0, function* () {
2691 + let stats = undefined;
2692 + try {
2693 + // test file exists
2694 + stats = yield exports.stat(filePath);
2695 + }
2696 + catch (err) {
2697 + if (err.code !== 'ENOENT') {
2698 + // eslint-disable-next-line no-console
2699 + console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
2700 + }
2701 + }
2702 + if (stats && stats.isFile()) {
2703 + if (exports.IS_WINDOWS) {
2704 + // on Windows, test for valid extension
2705 + const upperExt = path.extname(filePath).toUpperCase();
2706 + if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
2707 + return filePath;
2708 + }
2709 + }
2710 + else {
2711 + if (isUnixExecutable(stats)) {
2712 + return filePath;
2713 + }
2714 + }
2715 + }
2716 + // try each extension
2717 + const originalFilePath = filePath;
2718 + for (const extension of extensions) {
2719 + filePath = originalFilePath + extension;
2720 + stats = undefined;
2721 + try {
2722 + stats = yield exports.stat(filePath);
2723 + }
2724 + catch (err) {
2725 + if (err.code !== 'ENOENT') {
2726 + // eslint-disable-next-line no-console
2727 + console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
2728 + }
2729 + }
2730 + if (stats && stats.isFile()) {
2731 + if (exports.IS_WINDOWS) {
2732 + // preserve the case of the actual file (since an extension was appended)
2733 + try {
2734 + const directory = path.dirname(filePath);
2735 + const upperName = path.basename(filePath).toUpperCase();
2736 + for (const actualName of yield exports.readdir(directory)) {
2737 + if (upperName === actualName.toUpperCase()) {
2738 + filePath = path.join(directory, actualName);
2739 + break;
2740 + }
2741 + }
2742 + }
2743 + catch (err) {
2744 + // eslint-disable-next-line no-console
2745 + console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
2746 + }
2747 + return filePath;
2748 + }
2749 + else {
2750 + if (isUnixExecutable(stats)) {
2751 + return filePath;
2752 + }
2753 + }
2754 + }
2755 + }
2756 + return '';
2757 + });
2758 +}
2759 +exports.tryGetExecutablePath = tryGetExecutablePath;
2760 +function normalizeSeparators(p) {
2761 + p = p || '';
2762 + if (exports.IS_WINDOWS) {
2763 + // convert slashes on Windows
2764 + p = p.replace(/\//g, '\\');
2765 + // remove redundant slashes
2766 + return p.replace(/\\\\+/g, '\\');
2767 + }
2768 + // remove redundant slashes
2769 + return p.replace(/\/\/+/g, '/');
2770 +}
2771 +// on Mac/Linux, test the execute bit
2772 +// R W X R W X R W X
2773 +// 256 128 64 32 16 8 4 2 1
2774 +function isUnixExecutable(stats) {
2775 + return ((stats.mode & 1) > 0 ||
2776 + ((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
2777 + ((stats.mode & 64) > 0 && stats.uid === process.getuid()));
2778 +}
2779 +//# sourceMappingURL=io-util.js.map
2780 +
2781 +/***/ }),
2782 +
2783 +/***/ 431:
2784 +/***/ (function(__unusedmodule, exports, __webpack_require__) {
2785 +
2786 +"use strict";
2787 +
2788 +var __importStar = (this && this.__importStar) || function (mod) {
2789 + if (mod && mod.__esModule) return mod;
2790 + var result = {};
2791 + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
2792 + result["default"] = mod;
2793 + return result;
2794 +};
2795 +Object.defineProperty(exports, "__esModule", { value: true });
2796 +const os = __importStar(__webpack_require__(87));
2797 +/**
2798 + * Commands
2799 + *
2800 + * Command Format:
2801 + * ::name key=value,key=value::message
2802 + *
2803 + * Examples:
2804 + * ::warning::This is the message
2805 + * ::set-env name=MY_VAR::some value
2806 + */
2807 +function issueCommand(command, properties, message) {
2808 + const cmd = new Command(command, properties, message);
2809 + process.stdout.write(cmd.toString() + os.EOL);
2810 +}
2811 +exports.issueCommand = issueCommand;
2812 +function issue(name, message = '') {
2813 + issueCommand(name, {}, message);
2814 +}
2815 +exports.issue = issue;
2816 +const CMD_STRING = '::';
2817 +class Command {
2818 + constructor(command, properties, message) {
2819 + if (!command) {
2820 + command = 'missing.command';
2821 + }
2822 + this.command = command;
2823 + this.properties = properties;
2824 + this.message = message;
2825 + }
2826 + toString() {
2827 + let cmdStr = CMD_STRING + this.command;
2828 + if (this.properties && Object.keys(this.properties).length > 0) {
2829 + cmdStr += ' ';
2830 + let first = true;
2831 + for (const key in this.properties) {
2832 + if (this.properties.hasOwnProperty(key)) {
2833 + const val = this.properties[key];
2834 + if (val) {
2835 + if (first) {
2836 + first = false;
2837 + }
2838 + else {
2839 + cmdStr += ',';
2840 + }
2841 + cmdStr += `${key}=${escapeProperty(val)}`;
2842 + }
2843 + }
2844 + }
2845 + }
2846 + cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
2847 + return cmdStr;
2848 + }
2849 +}
2850 +/**
2851 + * Sanitizes an input into a string so it can be passed into issueCommand safely
2852 + * @param input input to sanitize into a string
2853 + */
2854 +function toCommandValue(input) {
2855 + if (input === null || input === undefined) {
2856 + return '';
2857 + }
2858 + else if (typeof input === 'string' || input instanceof String) {
2859 + return input;
2860 + }
2861 + return JSON.stringify(input);
2862 +}
2863 +exports.toCommandValue = toCommandValue;
2864 +function escapeData(s) {
2865 + return toCommandValue(s)
2866 + .replace(/%/g, '%25')
2867 + .replace(/\r/g, '%0D')
2868 + .replace(/\n/g, '%0A');
2869 +}
2870 +function escapeProperty(s) {
2871 + return toCommandValue(s)
2872 + .replace(/%/g, '%25')
2873 + .replace(/\r/g, '%0D')
2874 + .replace(/\n/g, '%0A')
2875 + .replace(/:/g, '%3A')
2876 + .replace(/,/g, '%2C');
2877 +}
2878 +//# sourceMappingURL=command.js.map
2879 +
2880 +/***/ }),
2881 +
2882 +/***/ 449:
2883 +/***/ (function(module, __unusedexports, __webpack_require__) {
2884 +
2885 +const {exec} = __webpack_require__(917)
2886 +const path = __webpack_require__(622)
2887 +const semver = __webpack_require__(280)
2888 +
2889 +module.exports = {installElixir, installOTP}
2890 +
2891 +/**
2892 + * Install Elixir.
2893 + *
2894 + * @param {string} version
2895 + * @param {string} otpMajor
2896 + */
2897 +async function installElixir(version, otpMajor) {
2898 + if (process.platform === 'linux') {
2899 + const otpString = otpMajor ? `-otp-${otpMajor}` : ''
2900 + await exec(__webpack_require__.ab + "install-elixir", [version, otpString])
2901 + }
2902 +}
2903 +
2904 +/**
2905 + * Install OTP.
2906 + *
2907 + * @param {string} version
2908 + */
2909 +async function installOTP(version) {
2910 + if (process.platform === 'linux') {
2911 + await exec(__webpack_require__.ab + "install-otp", [version])
2912 + return
2913 + }
2914 +
2915 + throw new Error(
2916 + '@actions/setup-elixir only supports Ubuntu Linux at this time'
2917 + )
2918 +}
2919 +
2920 +
2921 +/***/ }),
2922 +
2923 +/***/ 470:
2924 +/***/ (function(__unusedmodule, exports, __webpack_require__) {
2925 +
2926 +"use strict";
2927 +
2928 +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2929 + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2930 + return new (P || (P = Promise))(function (resolve, reject) {
2931 + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2932 + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2933 + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2934 + step((generator = generator.apply(thisArg, _arguments || [])).next());
2935 + });
2936 +};
2937 +var __importStar = (this && this.__importStar) || function (mod) {
2938 + if (mod && mod.__esModule) return mod;
2939 + var result = {};
2940 + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
2941 + result["default"] = mod;
2942 + return result;
2943 +};
2944 +Object.defineProperty(exports, "__esModule", { value: true });
2945 +const command_1 = __webpack_require__(431);
2946 +const os = __importStar(__webpack_require__(87));
2947 +const path = __importStar(__webpack_require__(622));
2948 +/**
2949 + * The code to exit an action
2950 + */
2951 +var ExitCode;
2952 +(function (ExitCode) {
2953 + /**
2954 + * A code indicating that the action was successful
2955 + */
2956 + ExitCode[ExitCode["Success"] = 0] = "Success";
2957 + /**
2958 + * A code indicating that the action was a failure
2959 + */
2960 + ExitCode[ExitCode["Failure"] = 1] = "Failure";
2961 +})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
2962 +//-----------------------------------------------------------------------
2963 +// Variables
2964 +//-----------------------------------------------------------------------
2965 +/**
2966 + * Sets env variable for this action and future actions in the job
2967 + * @param name the name of the variable to set
2968 + * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
2969 + */
2970 +// eslint-disable-next-line @typescript-eslint/no-explicit-any
2971 +function exportVariable(name, val) {
2972 + const convertedVal = command_1.toCommandValue(val);
2973 + process.env[name] = convertedVal;
2974 + command_1.issueCommand('set-env', { name }, convertedVal);
2975 +}
2976 +exports.exportVariable = exportVariable;
2977 +/**
2978 + * Registers a secret which will get masked from logs
2979 + * @param secret value of the secret
2980 + */
2981 +function setSecret(secret) {
2982 + command_1.issueCommand('add-mask', {}, secret);
2983 +}
2984 +exports.setSecret = setSecret;
2985 +/**
2986 + * Prepends inputPath to the PATH (for this action and future actions)
2987 + * @param inputPath
2988 + */
2989 +function addPath(inputPath) {
2990 + command_1.issueCommand('add-path', {}, inputPath);
2991 + process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
2992 +}
2993 +exports.addPath = addPath;
2994 +/**
2995 + * Gets the value of an input. The value is also trimmed.
2996 + *
2997 + * @param name name of the input to get
2998 + * @param options optional. See InputOptions.
2999 + * @returns string
3000 + */
3001 +function getInput(name, options) {
3002 + const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
3003 + if (options && options.required && !val) {
3004 + throw new Error(`Input required and not supplied: ${name}`);
3005 + }
3006 + return val.trim();
3007 +}
3008 +exports.getInput = getInput;
3009 +/**
3010 + * Sets the value of an output.
3011 + *
3012 + * @param name name of the output to set
3013 + * @param value value to store. Non-string values will be converted to a string via JSON.stringify
3014 + */
3015 +// eslint-disable-next-line @typescript-eslint/no-explicit-any
3016 +function setOutput(name, value) {
3017 + command_1.issueCommand('set-output', { name }, value);
3018 +}
3019 +exports.setOutput = setOutput;
3020 +/**
3021 + * Enables or disables the echoing of commands into stdout for the rest of the step.
3022 + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
3023 + *
3024 + */
3025 +function setCommandEcho(enabled) {
3026 + command_1.issue('echo', enabled ? 'on' : 'off');
3027 +}
3028 +exports.setCommandEcho = setCommandEcho;
3029 +//-----------------------------------------------------------------------
3030 +// Results
3031 +//-----------------------------------------------------------------------
3032 +/**
3033 + * Sets the action status to failed.
3034 + * When the action exits it will be with an exit code of 1
3035 + * @param message add error issue message
3036 + */
3037 +function setFailed(message) {
3038 + process.exitCode = ExitCode.Failure;
3039 + error(message);
3040 +}
3041 +exports.setFailed = setFailed;
3042 +//-----------------------------------------------------------------------
3043 +// Logging Commands
3044 +//-----------------------------------------------------------------------
3045 +/**
3046 + * Gets whether Actions Step Debug is on or not
3047 + */
3048 +function isDebug() {
3049 + return process.env['RUNNER_DEBUG'] === '1';
3050 +}
3051 +exports.isDebug = isDebug;
3052 +/**
3053 + * Writes debug message to user log
3054 + * @param message debug message
3055 + */
3056 +function debug(message) {
3057 + command_1.issueCommand('debug', {}, message);
3058 +}
3059 +exports.debug = debug;
3060 +/**
3061 + * Adds an error issue
3062 + * @param message error issue message. Errors will be converted to string via toString()
3063 + */
3064 +function error(message) {
3065 + command_1.issue('error', message instanceof Error ? message.toString() : message);
3066 +}
3067 +exports.error = error;
3068 +/**
3069 + * Adds an warning issue
3070 + * @param message warning issue message. Errors will be converted to string via toString()
3071 + */
3072 +function warning(message) {
3073 + command_1.issue('warning', message instanceof Error ? message.toString() : message);
3074 +}
3075 +exports.warning = warning;
3076 +/**
3077 + * Writes info to log with console.log.
3078 + * @param message info message
3079 + */
3080 +function info(message) {
3081 + process.stdout.write(message + os.EOL);
3082 +}
3083 +exports.info = info;
3084 +/**
3085 + * Begin an output group.
3086 + *
3087 + * Output until the next `groupEnd` will be foldable in this group
3088 + *
3089 + * @param name The name of the output group
3090 + */
3091 +function startGroup(name) {
3092 + command_1.issue('group', name);
3093 +}
3094 +exports.startGroup = startGroup;
3095 +/**
3096 + * End an output group.
3097 + */
3098 +function endGroup() {
3099 + command_1.issue('endgroup');
3100 +}
3101 +exports.endGroup = endGroup;
3102 +/**
3103 + * Wrap an asynchronous function call in a group.
3104 + *
3105 + * Returns the same type as the function itself.
3106 + *
3107 + * @param name The name of the group
3108 + * @param fn The function to wrap in the group
3109 + */
3110 +function group(name, fn) {
3111 + return __awaiter(this, void 0, void 0, function* () {
3112 + startGroup(name);
3113 + let result;
3114 + try {
3115 + result = yield fn();
3116 + }
3117 + finally {
3118 + endGroup();
3119 + }
3120 + return result;
3121 + });
3122 +}
3123 +exports.group = group;
3124 +//-----------------------------------------------------------------------
3125 +// Wrapper action state
3126 +//-----------------------------------------------------------------------
3127 +/**
3128 + * Saves state for current action, the state can only be retrieved by this action's post job execution.
3129 + *
3130 + * @param name name of the state to store
3131 + * @param value value to store. Non-string values will be converted to a string via JSON.stringify
3132 + */
3133 +// eslint-disable-next-line @typescript-eslint/no-explicit-any
3134 +function saveState(name, value) {
3135 + command_1.issueCommand('save-state', { name }, value);
3136 +}
3137 +exports.saveState = saveState;
3138 +/**
3139 + * Gets the value of an state set by this action's main execution.
3140 + *
3141 + * @param name name of the state to get
3142 + * @returns string
3143 + */
3144 +function getState(name) {
3145 + return process.env[`STATE_${name}`] || '';
3146 +}
3147 +exports.getState = getState;
3148 +//# sourceMappingURL=core.js.map
3149 +
3150 +/***/ }),
3151 +
3152 +/***/ 614:
3153 +/***/ (function(module) {
3154 +
3155 +module.exports = require("events");
3156 +
3157 +/***/ }),
3158 +
3159 +/***/ 622:
3160 +/***/ (function(module) {
3161 +
3162 +module.exports = require("path");
3163 +
3164 +/***/ }),
3165 +
3166 +/***/ 669:
3167 +/***/ (function(module) {
3168 +
3169 +module.exports = require("util");
3170 +
3171 +/***/ }),
3172 +
3173 +/***/ 747:
3174 +/***/ (function(module) {
3175 +
3176 +module.exports = require("fs");
3177 +
3178 +/***/ }),
3179 +
3180 +/***/ 917:
3181 +/***/ (function(__unusedmodule, exports, __webpack_require__) {
3182 +
3183 +"use strict";
3184 +
3185 +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3186 + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3187 + return new (P || (P = Promise))(function (resolve, reject) {
3188 + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3189 + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3190 + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3191 + step((generator = generator.apply(thisArg, _arguments || [])).next());
3192 + });
3193 +};
3194 +var __importStar = (this && this.__importStar) || function (mod) {
3195 + if (mod && mod.__esModule) return mod;
3196 + var result = {};
3197 + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
3198 + result["default"] = mod;
3199 + return result;
3200 +};
3201 +Object.defineProperty(exports, "__esModule", { value: true });
3202 +const tr = __importStar(__webpack_require__(9));
3203 +/**
3204 + * Exec a command.
3205 + * Output will be streamed to the live console.
3206 + * Returns promise with return code
3207 + *
3208 + * @param commandLine command to execute (can include additional args). Must be correctly escaped.
3209 + * @param args optional arguments for tool. Escaping is handled by the lib.
3210 + * @param options optional exec options. See ExecOptions
3211 + * @returns Promise<number> exit code
3212 + */
3213 +function exec(commandLine, args, options) {
3214 + return __awaiter(this, void 0, void 0, function* () {
3215 + const commandArgs = tr.argStringToArray(commandLine);
3216 + if (commandArgs.length === 0) {
3217 + throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
3218 + }
3219 + // Path to tool to execute should be first arg
3220 + const toolPath = commandArgs[0];
3221 + args = commandArgs.slice(1).concat(args || []);
3222 + const runner = new tr.ToolRunner(toolPath, args, options);
3223 + return runner.exec();
3224 + });
3225 +}
3226 +exports.exec = exec;
3227 +//# sourceMappingURL=exec.js.map
3228 +
3229 +/***/ }),
3230 +
3231 +/***/ 986:
3232 +/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
3233 +
3234 +const core = __webpack_require__(470)
3235 +const {exec} = __webpack_require__(917)
3236 +const {installElixir, installOTP} = __webpack_require__(449)
3237 +const path = __webpack_require__(622)
3238 +const semver = __webpack_require__(280)
3239 +const https = __webpack_require__(211)
3240 +
3241 +main().catch(err => {
3242 + core.setFailed(err.message)
3243 +})
3244 +
3245 +async function main() {
3246 + checkPlatform()
3247 +
3248 + const otpSpec = core.getInput('otp-version', {required: true})
3249 + const elixirSpec = core.getInput('elixir-version', {required: true})
3250 + const otpVersion = await getOtpVersion(otpSpec)
3251 + const [elixirVersion, otpMajor] = await getElixirVersion(
3252 + elixirSpec,
3253 + otpVersion
3254 + )
3255 +
3256 + let installHex = core.getInput('install-hex')
3257 + installHex = installHex == null ? 'true' : installHex
3258 + let installRebar = core.getInput('install-rebar')
3259 + installRebar = installRebar == null ? 'true' : installRebar
3260 +
3261 + console.log(`##[group]Installing OTP ${otpVersion}`)
3262 + await installOTP(otpVersion)
3263 + console.log(`##[endgroup]`)
3264 +
3265 + console.log(`##[group]Installing Elixir ${elixirVersion}`)
3266 + await installElixir(elixirVersion, otpMajor)
3267 + console.log(`##[endgroup]`)
3268 +
3269 + process.env.PATH = `/tmp/.setup-elixir/elixir/bin:/tmp/.setup-elixir/otp/bin:${process.env.PATH}`
3270 +
3271 + if (installRebar === 'true') await exec('mix local.rebar --force')
3272 + if (installHex === 'true') await exec('mix local.hex --force')
3273 +
3274 + const matchersPath = __webpack_require__.ab + ".github"
3275 + console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`)
3276 +}
3277 +
3278 +function checkPlatform() {
3279 + if (process.platform !== 'linux')
3280 + throw new Error(
3281 + '@actions/setup-elixir only supports Ubuntu Linux at this time'
3282 + )
3283 +}
3284 +
3285 +async function getOtpVersion(spec) {
3286 + return getVersionFromSpec(spec, await getOtpVersions()) || spec
3287 +}
3288 +
3289 +async function getElixirVersion(spec, otpVersion) {
3290 + const versions = await getElixirVersions()
3291 + const semverRegex = /^v(\d+\.\d+\.\d+)/
3292 +
3293 + const semverVersions = Array.from(versions.keys())
3294 + .filter(str => str.match(semverRegex))
3295 + .map(str => str.match(semverRegex)[1])
3296 +
3297 + const version = getVersionFromSpec(spec, semverVersions)
3298 + const gitRef = version ? `v${version}` : spec
3299 + const [otpMajor] = otpVersion.match(/^\d+/)
3300 +
3301 + if (versions.get(gitRef).includes(otpMajor)) {
3302 + return [gitRef, otpMajor]
3303 + } else {
3304 + return [gitRef, null]
3305 + }
3306 +}
3307 +
3308 +function getVersionFromSpec(spec, versions) {
3309 + if (versions.includes(spec)) {
3310 + return spec
3311 + } else {
3312 + const range = semver.validRange(spec)
3313 + return semver.maxSatisfying(versions, range)
3314 + }
3315 +}
3316 +
3317 +async function getOtpVersions() {
3318 + const result = await get(
3319 + 'https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table'
3320 + )
3321 +
3322 + return result
3323 + .trim()
3324 + .split('\n')
3325 + .map(line => {
3326 + const [_, version] = line.match(/^OTP-([\.\d]+)/)
3327 + return version
3328 + })
3329 +}
3330 +
3331 +async function getElixirVersions() {
3332 + const result = await get('https://repo.hex.pm/builds/elixir/builds.txt')
3333 + const map = new Map()
3334 +
3335 + result
3336 + .trim()
3337 + .split('\n')
3338 + .forEach(line => {
3339 + const match =
3340 + line.match(/^(v\d+\.\d+\.\d+)-otp-(\d+)/) ||
3341 + line.match(/^([^-]+)-otp-(\d+)/)
3342 +
3343 + if (match) {
3344 + const [_, version, otp] = match
3345 + const array = map.get(version) || []
3346 + array.push(otp)
3347 + map.set(version, array)
3348 + }
3349 + })
3350 +
3351 + return map
3352 +}
3353 +
3354 +function get(url) {
3355 + return new Promise((resolve, reject) => {
3356 + const req = https.get(url)
3357 +
3358 + req.on('response', res => {
3359 + let data = ''
3360 + res.on('data', chunk => {
3361 + data += chunk
3362 + })
3363 + res.on('end', () => {
3364 + resolve(data)
3365 + })
3366 + })
3367 +
3368 + req.on('error', err => {
3369 + reject(err)
3370 + })
3371 + })
3372 +}
3373 +
3374 +
3375 +/***/ })
3376 +
3377 +/******/ });
added dist/install-elixir
+10 −0
@@ -0,0 +1,10 @@
1 +#!/bin/bash
2 +
3 +set -eo pipefail
4 +
5 +cd /tmp
6 +
7 +wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip
8 +unzip -d .setup-elixir/elixir ${1}${2}.zip
9 +rm ${1}${2}.zip
10 +echo "::add-path::$(pwd)/.setup-elixir/elixir/bin"
added dist/install-otp
+12 −0
@@ -0,0 +1,12 @@
1 +#!/bin/bash
2 +
3 +set -eo pipefail
4 +
5 +cd /tmp
6 +
7 +wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz
8 +mkdir -p .setup-elixir/otp
9 +tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
10 +rm otp.tar.gz
11 +.setup-elixir/otp/Install -minimal $(pwd)/.setup-elixir/otp
12 +echo "::add-path::$(pwd)/.setup-elixir/otp/bin"
modified package-lock.json
+27 −0
@@ -4,6 +4,26 @@
4 4 "lockfileVersion": 1,
5 5 "requires": true,
6 6 "dependencies": {
7 + "@actions/core": {
8 + "version": "1.2.4",
9 + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.4.tgz",
10 + "integrity": "sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg=="
11 + },
12 + "@actions/exec": {
13 + "version": "1.0.4",
14 + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz",
15 + "integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==",
16 + "requires": {
17 + "@actions/io": "^1.0.1"
18 + },
19 + "dependencies": {
20 + "@actions/io": {
21 + "version": "1.0.2",
22 + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.2.tgz",
23 + "integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg=="
24 + }
25 + }
26 + },
7 27 "@actions/io": {
8 28 "version": "1.0.0",
9 29 "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.0.tgz",
@@ -11,6 +31,8 @@
11 31 },
12 32 "@actions/tool-cache": {
13 33 "version": "1.1.0",
34 + "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.0.tgz",
35 + "integrity": "sha512-Oe/R1Gxv0G699OUL9ypxk9cTwHf1uXHhpcK7kpZt8d/Sbw915ktMkfxXt9+awOfLDwyl54sLi86KGCuSvnRuIQ==",
14 36 "requires": {
15 37 "@actions/core": "^1.0.0",
16 38 "@actions/exec": "^1.0.0",
@@ -402,6 +424,11 @@
402 424 "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
403 425 "dev": true
404 426 },
427 + "semver": {
428 + "version": "6.3.0",
429 + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
430 + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
431 + },
405 432 "semver-compare": {
406 433 "version": "1.0.0",
407 434 "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz",
modified package.json
+9 −0
@@ -2,6 +2,15 @@
2 2 "name": "setup-elixir",
3 3 "version": "0.0.0",
4 4 "license": "MIT",
5 + "private": true,
6 + "scripts": {
7 + "build": "ncc build src/setup-elixir.js"
8 + },
9 + "husky": {
10 + "hooks": {
11 + "pre-commit": "npm run build && git add dist/"
12 + }
13 + },
5 14 "dependencies": {
6 15 "@actions/core": "^1.0.0",
7 16 "@actions/exec": "^1.0.0",

Parents: 6f8a4fe