├── .editorconfig ├── .eslintrc ├── .github └── workflows │ └── test.yml ├── LICENSE ├── README.md ├── action.yml ├── dist ├── index.js └── licenses.txt ├── index.js ├── package-lock.json └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "es2021": true 4 | }, 5 | "extends": "standard", 6 | "parserOptions": { 7 | "ecmaVersion": 12, 8 | "sourceType": "module" 9 | }, 10 | "ignorePatterns": "dist/" 11 | } 12 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: [push] 4 | 5 | jobs: 6 | tests: 7 | runs-on: ubuntu-latest 8 | name: Tests 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - run: npm ci 14 | - run: npm test 15 | 16 | - name: Command that outputs stdout and stderr 17 | uses: ./ 18 | id: both 19 | continue-on-error: true 20 | with: 21 | run: node -e "console.log('foo');console.error('bar')" 22 | - name: Assert stdout 23 | if: "${{ steps.both.outputs.stdout != 'foo\n' }}" 24 | run: exit 1 25 | - name: Assert stderr 26 | if: "${{ steps.both.outputs.stderr != 'bar\n' }}" 27 | run: exit 1 28 | 29 | - name: Test multiline command with environment variable 30 | uses: ./ 31 | id: multi 32 | env: 33 | HELLO: Hello 34 | with: 35 | run: | 36 | echo $HELLO 37 | echo world! 38 | - name: Assert stdout 39 | if: "${{ steps.multi.outputs.stdout != 'Hello\nworld!\n' }}" 40 | run: exit 1 41 | - name: Assert stderr 42 | if: "${{ steps.multi.outputs.stderr != '' }}" 43 | run: exit 1 44 | 45 | - name: Test unknown shell 46 | uses: ./ 47 | continue-on-error: true 48 | id: unknown-shell 49 | with: 50 | run: ls -al 51 | shell: unknown 52 | - name: Should fail on unknown shell 53 | if: ${{ steps.unknown-shell.outcome != 'failure' }} 54 | run: exit 1 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 Mathias Rasmussen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Command Output 2 | 3 | A `run` alternative that stores command output in a variable. 4 | 5 | ## Inputs 6 | 7 | ### `run` 8 | 9 | **Required** The command to run. 10 | 11 | ### `shell` 12 | 13 | The shell used to run command. 14 | 15 | ## Outputs 16 | 17 | ### `stdout` 18 | 19 | The output of the command written to stdout. 20 | 21 | ### `stderr` 22 | 23 | The output of the command written to stderr. 24 | 25 | ## Example usage 26 | 27 | #### Store today's date in variable 28 | 29 | ```yaml 30 | steps: 31 | - name: Get today's date 32 | uses: mathiasvr/command-output@v2.0.0 33 | id: today 34 | with: 35 | run: date +'%Y-%m-%d' 36 | 37 | - run: echo Today is ${{ steps.today.outputs.stdout }} 38 | ``` 39 | 40 | #### Use stdout and stderr output as condition 41 | 42 | ```yaml 43 | steps: 44 | - name: Read file if it exists? 45 | uses: mathiasvr/command-output@v2.0.0 46 | continue-on-error: true 47 | id: cmd 48 | with: 49 | run: cat unknown.txt 50 | 51 | - run: echo Command succeeded 52 | if: ${{ steps.cmd.outputs.stdout }} 53 | 54 | - run: echo Command failed 55 | if: ${{ steps.cmd.outputs.stderr }} 56 | ``` 57 | 58 | 59 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Command Output 2 | description: Run a command and store its output 3 | inputs: 4 | run: 5 | description: Command to run 6 | required: true 7 | shell: 8 | description: Shell used to run command 9 | required: false 10 | default: bash 11 | outputs: 12 | stdout: 13 | description: Output of the command 14 | stderr: 15 | description: Error of the command 16 | runs: 17 | using: node16 18 | main: dist/index.js 19 | branding: 20 | icon: terminal 21 | color: gray-dark 22 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | /******/ (() => { // webpackBootstrap 2 | /******/ var __webpack_modules__ = ({ 3 | 4 | /***/ 351: 5 | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { 6 | 7 | "use strict"; 8 | 9 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 12 | }) : (function(o, m, k, k2) { 13 | if (k2 === undefined) k2 = k; 14 | o[k2] = m[k]; 15 | })); 16 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 17 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 18 | }) : function(o, v) { 19 | o["default"] = v; 20 | }); 21 | var __importStar = (this && this.__importStar) || function (mod) { 22 | if (mod && mod.__esModule) return mod; 23 | var result = {}; 24 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 25 | __setModuleDefault(result, mod); 26 | return result; 27 | }; 28 | Object.defineProperty(exports, "__esModule", ({ value: true })); 29 | exports.issue = exports.issueCommand = void 0; 30 | const os = __importStar(__nccwpck_require__(37)); 31 | const utils_1 = __nccwpck_require__(278); 32 | /** 33 | * Commands 34 | * 35 | * Command Format: 36 | * ::name key=value,key=value::message 37 | * 38 | * Examples: 39 | * ::warning::This is the message 40 | * ::set-env name=MY_VAR::some value 41 | */ 42 | function issueCommand(command, properties, message) { 43 | const cmd = new Command(command, properties, message); 44 | process.stdout.write(cmd.toString() + os.EOL); 45 | } 46 | exports.issueCommand = issueCommand; 47 | function issue(name, message = '') { 48 | issueCommand(name, {}, message); 49 | } 50 | exports.issue = issue; 51 | const CMD_STRING = '::'; 52 | class Command { 53 | constructor(command, properties, message) { 54 | if (!command) { 55 | command = 'missing.command'; 56 | } 57 | this.command = command; 58 | this.properties = properties; 59 | this.message = message; 60 | } 61 | toString() { 62 | let cmdStr = CMD_STRING + this.command; 63 | if (this.properties && Object.keys(this.properties).length > 0) { 64 | cmdStr += ' '; 65 | let first = true; 66 | for (const key in this.properties) { 67 | if (this.properties.hasOwnProperty(key)) { 68 | const val = this.properties[key]; 69 | if (val) { 70 | if (first) { 71 | first = false; 72 | } 73 | else { 74 | cmdStr += ','; 75 | } 76 | cmdStr += `${key}=${escapeProperty(val)}`; 77 | } 78 | } 79 | } 80 | } 81 | cmdStr += `${CMD_STRING}${escapeData(this.message)}`; 82 | return cmdStr; 83 | } 84 | } 85 | function escapeData(s) { 86 | return utils_1.toCommandValue(s) 87 | .replace(/%/g, '%25') 88 | .replace(/\r/g, '%0D') 89 | .replace(/\n/g, '%0A'); 90 | } 91 | function escapeProperty(s) { 92 | return utils_1.toCommandValue(s) 93 | .replace(/%/g, '%25') 94 | .replace(/\r/g, '%0D') 95 | .replace(/\n/g, '%0A') 96 | .replace(/:/g, '%3A') 97 | .replace(/,/g, '%2C'); 98 | } 99 | //# sourceMappingURL=command.js.map 100 | 101 | /***/ }), 102 | 103 | /***/ 186: 104 | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { 105 | 106 | "use strict"; 107 | 108 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 109 | if (k2 === undefined) k2 = k; 110 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 111 | }) : (function(o, m, k, k2) { 112 | if (k2 === undefined) k2 = k; 113 | o[k2] = m[k]; 114 | })); 115 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 116 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 117 | }) : function(o, v) { 118 | o["default"] = v; 119 | }); 120 | var __importStar = (this && this.__importStar) || function (mod) { 121 | if (mod && mod.__esModule) return mod; 122 | var result = {}; 123 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 124 | __setModuleDefault(result, mod); 125 | return result; 126 | }; 127 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 128 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 129 | return new (P || (P = Promise))(function (resolve, reject) { 130 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 131 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 132 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 133 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 134 | }); 135 | }; 136 | Object.defineProperty(exports, "__esModule", ({ value: true })); 137 | exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; 138 | const command_1 = __nccwpck_require__(351); 139 | const file_command_1 = __nccwpck_require__(717); 140 | const utils_1 = __nccwpck_require__(278); 141 | const os = __importStar(__nccwpck_require__(37)); 142 | const path = __importStar(__nccwpck_require__(17)); 143 | const oidc_utils_1 = __nccwpck_require__(41); 144 | /** 145 | * The code to exit an action 146 | */ 147 | var ExitCode; 148 | (function (ExitCode) { 149 | /** 150 | * A code indicating that the action was successful 151 | */ 152 | ExitCode[ExitCode["Success"] = 0] = "Success"; 153 | /** 154 | * A code indicating that the action was a failure 155 | */ 156 | ExitCode[ExitCode["Failure"] = 1] = "Failure"; 157 | })(ExitCode = exports.ExitCode || (exports.ExitCode = {})); 158 | //----------------------------------------------------------------------- 159 | // Variables 160 | //----------------------------------------------------------------------- 161 | /** 162 | * Sets env variable for this action and future actions in the job 163 | * @param name the name of the variable to set 164 | * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify 165 | */ 166 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 167 | function exportVariable(name, val) { 168 | const convertedVal = utils_1.toCommandValue(val); 169 | process.env[name] = convertedVal; 170 | const filePath = process.env['GITHUB_ENV'] || ''; 171 | if (filePath) { 172 | return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); 173 | } 174 | command_1.issueCommand('set-env', { name }, convertedVal); 175 | } 176 | exports.exportVariable = exportVariable; 177 | /** 178 | * Registers a secret which will get masked from logs 179 | * @param secret value of the secret 180 | */ 181 | function setSecret(secret) { 182 | command_1.issueCommand('add-mask', {}, secret); 183 | } 184 | exports.setSecret = setSecret; 185 | /** 186 | * Prepends inputPath to the PATH (for this action and future actions) 187 | * @param inputPath 188 | */ 189 | function addPath(inputPath) { 190 | const filePath = process.env['GITHUB_PATH'] || ''; 191 | if (filePath) { 192 | file_command_1.issueFileCommand('PATH', inputPath); 193 | } 194 | else { 195 | command_1.issueCommand('add-path', {}, inputPath); 196 | } 197 | process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; 198 | } 199 | exports.addPath = addPath; 200 | /** 201 | * Gets the value of an input. 202 | * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. 203 | * Returns an empty string if the value is not defined. 204 | * 205 | * @param name name of the input to get 206 | * @param options optional. See InputOptions. 207 | * @returns string 208 | */ 209 | function getInput(name, options) { 210 | const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; 211 | if (options && options.required && !val) { 212 | throw new Error(`Input required and not supplied: ${name}`); 213 | } 214 | if (options && options.trimWhitespace === false) { 215 | return val; 216 | } 217 | return val.trim(); 218 | } 219 | exports.getInput = getInput; 220 | /** 221 | * Gets the values of an multiline input. Each value is also trimmed. 222 | * 223 | * @param name name of the input to get 224 | * @param options optional. See InputOptions. 225 | * @returns string[] 226 | * 227 | */ 228 | function getMultilineInput(name, options) { 229 | const inputs = getInput(name, options) 230 | .split('\n') 231 | .filter(x => x !== ''); 232 | if (options && options.trimWhitespace === false) { 233 | return inputs; 234 | } 235 | return inputs.map(input => input.trim()); 236 | } 237 | exports.getMultilineInput = getMultilineInput; 238 | /** 239 | * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification. 240 | * Support boolean input list: `true | True | TRUE | false | False | FALSE` . 241 | * The return value is also in boolean type. 242 | * ref: https://yaml.org/spec/1.2/spec.html#id2804923 243 | * 244 | * @param name name of the input to get 245 | * @param options optional. See InputOptions. 246 | * @returns boolean 247 | */ 248 | function getBooleanInput(name, options) { 249 | const trueValue = ['true', 'True', 'TRUE']; 250 | const falseValue = ['false', 'False', 'FALSE']; 251 | const val = getInput(name, options); 252 | if (trueValue.includes(val)) 253 | return true; 254 | if (falseValue.includes(val)) 255 | return false; 256 | throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` + 257 | `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); 258 | } 259 | exports.getBooleanInput = getBooleanInput; 260 | /** 261 | * Sets the value of an output. 262 | * 263 | * @param name name of the output to set 264 | * @param value value to store. Non-string values will be converted to a string via JSON.stringify 265 | */ 266 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 267 | function setOutput(name, value) { 268 | const filePath = process.env['GITHUB_OUTPUT'] || ''; 269 | if (filePath) { 270 | return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); 271 | } 272 | process.stdout.write(os.EOL); 273 | command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); 274 | } 275 | exports.setOutput = setOutput; 276 | /** 277 | * Enables or disables the echoing of commands into stdout for the rest of the step. 278 | * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. 279 | * 280 | */ 281 | function setCommandEcho(enabled) { 282 | command_1.issue('echo', enabled ? 'on' : 'off'); 283 | } 284 | exports.setCommandEcho = setCommandEcho; 285 | //----------------------------------------------------------------------- 286 | // Results 287 | //----------------------------------------------------------------------- 288 | /** 289 | * Sets the action status to failed. 290 | * When the action exits it will be with an exit code of 1 291 | * @param message add error issue message 292 | */ 293 | function setFailed(message) { 294 | process.exitCode = ExitCode.Failure; 295 | error(message); 296 | } 297 | exports.setFailed = setFailed; 298 | //----------------------------------------------------------------------- 299 | // Logging Commands 300 | //----------------------------------------------------------------------- 301 | /** 302 | * Gets whether Actions Step Debug is on or not 303 | */ 304 | function isDebug() { 305 | return process.env['RUNNER_DEBUG'] === '1'; 306 | } 307 | exports.isDebug = isDebug; 308 | /** 309 | * Writes debug message to user log 310 | * @param message debug message 311 | */ 312 | function debug(message) { 313 | command_1.issueCommand('debug', {}, message); 314 | } 315 | exports.debug = debug; 316 | /** 317 | * Adds an error issue 318 | * @param message error issue message. Errors will be converted to string via toString() 319 | * @param properties optional properties to add to the annotation. 320 | */ 321 | function error(message, properties = {}) { 322 | command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 323 | } 324 | exports.error = error; 325 | /** 326 | * Adds a warning issue 327 | * @param message warning issue message. Errors will be converted to string via toString() 328 | * @param properties optional properties to add to the annotation. 329 | */ 330 | function warning(message, properties = {}) { 331 | command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 332 | } 333 | exports.warning = warning; 334 | /** 335 | * Adds a notice issue 336 | * @param message notice issue message. Errors will be converted to string via toString() 337 | * @param properties optional properties to add to the annotation. 338 | */ 339 | function notice(message, properties = {}) { 340 | command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 341 | } 342 | exports.notice = notice; 343 | /** 344 | * Writes info to log with console.log. 345 | * @param message info message 346 | */ 347 | function info(message) { 348 | process.stdout.write(message + os.EOL); 349 | } 350 | exports.info = info; 351 | /** 352 | * Begin an output group. 353 | * 354 | * Output until the next `groupEnd` will be foldable in this group 355 | * 356 | * @param name The name of the output group 357 | */ 358 | function startGroup(name) { 359 | command_1.issue('group', name); 360 | } 361 | exports.startGroup = startGroup; 362 | /** 363 | * End an output group. 364 | */ 365 | function endGroup() { 366 | command_1.issue('endgroup'); 367 | } 368 | exports.endGroup = endGroup; 369 | /** 370 | * Wrap an asynchronous function call in a group. 371 | * 372 | * Returns the same type as the function itself. 373 | * 374 | * @param name The name of the group 375 | * @param fn The function to wrap in the group 376 | */ 377 | function group(name, fn) { 378 | return __awaiter(this, void 0, void 0, function* () { 379 | startGroup(name); 380 | let result; 381 | try { 382 | result = yield fn(); 383 | } 384 | finally { 385 | endGroup(); 386 | } 387 | return result; 388 | }); 389 | } 390 | exports.group = group; 391 | //----------------------------------------------------------------------- 392 | // Wrapper action state 393 | //----------------------------------------------------------------------- 394 | /** 395 | * Saves state for current action, the state can only be retrieved by this action's post job execution. 396 | * 397 | * @param name name of the state to store 398 | * @param value value to store. Non-string values will be converted to a string via JSON.stringify 399 | */ 400 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 401 | function saveState(name, value) { 402 | const filePath = process.env['GITHUB_STATE'] || ''; 403 | if (filePath) { 404 | return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); 405 | } 406 | command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); 407 | } 408 | exports.saveState = saveState; 409 | /** 410 | * Gets the value of an state set by this action's main execution. 411 | * 412 | * @param name name of the state to get 413 | * @returns string 414 | */ 415 | function getState(name) { 416 | return process.env[`STATE_${name}`] || ''; 417 | } 418 | exports.getState = getState; 419 | function getIDToken(aud) { 420 | return __awaiter(this, void 0, void 0, function* () { 421 | return yield oidc_utils_1.OidcClient.getIDToken(aud); 422 | }); 423 | } 424 | exports.getIDToken = getIDToken; 425 | /** 426 | * Summary exports 427 | */ 428 | var summary_1 = __nccwpck_require__(327); 429 | Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); 430 | /** 431 | * @deprecated use core.summary 432 | */ 433 | var summary_2 = __nccwpck_require__(327); 434 | Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); 435 | /** 436 | * Path exports 437 | */ 438 | var path_utils_1 = __nccwpck_require__(981); 439 | Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); 440 | Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); 441 | Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); 442 | //# sourceMappingURL=core.js.map 443 | 444 | /***/ }), 445 | 446 | /***/ 717: 447 | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { 448 | 449 | "use strict"; 450 | 451 | // For internal use, subject to change. 452 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 453 | if (k2 === undefined) k2 = k; 454 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 455 | }) : (function(o, m, k, k2) { 456 | if (k2 === undefined) k2 = k; 457 | o[k2] = m[k]; 458 | })); 459 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 460 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 461 | }) : function(o, v) { 462 | o["default"] = v; 463 | }); 464 | var __importStar = (this && this.__importStar) || function (mod) { 465 | if (mod && mod.__esModule) return mod; 466 | var result = {}; 467 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 468 | __setModuleDefault(result, mod); 469 | return result; 470 | }; 471 | Object.defineProperty(exports, "__esModule", ({ value: true })); 472 | exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; 473 | // We use any as a valid input type 474 | /* eslint-disable @typescript-eslint/no-explicit-any */ 475 | const fs = __importStar(__nccwpck_require__(147)); 476 | const os = __importStar(__nccwpck_require__(37)); 477 | const uuid_1 = __nccwpck_require__(840); 478 | const utils_1 = __nccwpck_require__(278); 479 | function issueFileCommand(command, message) { 480 | const filePath = process.env[`GITHUB_${command}`]; 481 | if (!filePath) { 482 | throw new Error(`Unable to find environment variable for file command ${command}`); 483 | } 484 | if (!fs.existsSync(filePath)) { 485 | throw new Error(`Missing file at path: ${filePath}`); 486 | } 487 | fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { 488 | encoding: 'utf8' 489 | }); 490 | } 491 | exports.issueFileCommand = issueFileCommand; 492 | function prepareKeyValueMessage(key, value) { 493 | const delimiter = `ghadelimiter_${uuid_1.v4()}`; 494 | const convertedValue = utils_1.toCommandValue(value); 495 | // These should realistically never happen, but just in case someone finds a 496 | // way to exploit uuid generation let's not allow keys or values that contain 497 | // the delimiter. 498 | if (key.includes(delimiter)) { 499 | throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); 500 | } 501 | if (convertedValue.includes(delimiter)) { 502 | throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); 503 | } 504 | return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; 505 | } 506 | exports.prepareKeyValueMessage = prepareKeyValueMessage; 507 | //# sourceMappingURL=file-command.js.map 508 | 509 | /***/ }), 510 | 511 | /***/ 41: 512 | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { 513 | 514 | "use strict"; 515 | 516 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 517 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 518 | return new (P || (P = Promise))(function (resolve, reject) { 519 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 520 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 521 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 522 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 523 | }); 524 | }; 525 | Object.defineProperty(exports, "__esModule", ({ value: true })); 526 | exports.OidcClient = void 0; 527 | const http_client_1 = __nccwpck_require__(255); 528 | const auth_1 = __nccwpck_require__(526); 529 | const core_1 = __nccwpck_require__(186); 530 | class OidcClient { 531 | static createHttpClient(allowRetry = true, maxRetry = 10) { 532 | const requestOptions = { 533 | allowRetries: allowRetry, 534 | maxRetries: maxRetry 535 | }; 536 | return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions); 537 | } 538 | static getRequestToken() { 539 | const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN']; 540 | if (!token) { 541 | throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable'); 542 | } 543 | return token; 544 | } 545 | static getIDTokenUrl() { 546 | const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']; 547 | if (!runtimeUrl) { 548 | throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable'); 549 | } 550 | return runtimeUrl; 551 | } 552 | static getCall(id_token_url) { 553 | var _a; 554 | return __awaiter(this, void 0, void 0, function* () { 555 | const httpclient = OidcClient.createHttpClient(); 556 | const res = yield httpclient 557 | .getJson(id_token_url) 558 | .catch(error => { 559 | throw new Error(`Failed to get ID Token. \n 560 | Error Code : ${error.statusCode}\n 561 | Error Message: ${error.result.message}`); 562 | }); 563 | const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; 564 | if (!id_token) { 565 | throw new Error('Response json body do not have ID Token field'); 566 | } 567 | return id_token; 568 | }); 569 | } 570 | static getIDToken(audience) { 571 | return __awaiter(this, void 0, void 0, function* () { 572 | try { 573 | // New ID Token is requested from action service 574 | let id_token_url = OidcClient.getIDTokenUrl(); 575 | if (audience) { 576 | const encodedAudience = encodeURIComponent(audience); 577 | id_token_url = `${id_token_url}&audience=${encodedAudience}`; 578 | } 579 | core_1.debug(`ID token url is ${id_token_url}`); 580 | const id_token = yield OidcClient.getCall(id_token_url); 581 | core_1.setSecret(id_token); 582 | return id_token; 583 | } 584 | catch (error) { 585 | throw new Error(`Error message: ${error.message}`); 586 | } 587 | }); 588 | } 589 | } 590 | exports.OidcClient = OidcClient; 591 | //# sourceMappingURL=oidc-utils.js.map 592 | 593 | /***/ }), 594 | 595 | /***/ 981: 596 | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { 597 | 598 | "use strict"; 599 | 600 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 601 | if (k2 === undefined) k2 = k; 602 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 603 | }) : (function(o, m, k, k2) { 604 | if (k2 === undefined) k2 = k; 605 | o[k2] = m[k]; 606 | })); 607 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 608 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 609 | }) : function(o, v) { 610 | o["default"] = v; 611 | }); 612 | var __importStar = (this && this.__importStar) || function (mod) { 613 | if (mod && mod.__esModule) return mod; 614 | var result = {}; 615 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 616 | __setModuleDefault(result, mod); 617 | return result; 618 | }; 619 | Object.defineProperty(exports, "__esModule", ({ value: true })); 620 | exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; 621 | const path = __importStar(__nccwpck_require__(17)); 622 | /** 623 | * toPosixPath converts the given path to the posix form. On Windows, \\ will be 624 | * replaced with /. 625 | * 626 | * @param pth. Path to transform. 627 | * @return string Posix path. 628 | */ 629 | function toPosixPath(pth) { 630 | return pth.replace(/[\\]/g, '/'); 631 | } 632 | exports.toPosixPath = toPosixPath; 633 | /** 634 | * toWin32Path converts the given path to the win32 form. On Linux, / will be 635 | * replaced with \\. 636 | * 637 | * @param pth. Path to transform. 638 | * @return string Win32 path. 639 | */ 640 | function toWin32Path(pth) { 641 | return pth.replace(/[/]/g, '\\'); 642 | } 643 | exports.toWin32Path = toWin32Path; 644 | /** 645 | * toPlatformPath converts the given path to a platform-specific path. It does 646 | * this by replacing instances of / and \ with the platform-specific path 647 | * separator. 648 | * 649 | * @param pth The path to platformize. 650 | * @return string The platform-specific path. 651 | */ 652 | function toPlatformPath(pth) { 653 | return pth.replace(/[/\\]/g, path.sep); 654 | } 655 | exports.toPlatformPath = toPlatformPath; 656 | //# sourceMappingURL=path-utils.js.map 657 | 658 | /***/ }), 659 | 660 | /***/ 327: 661 | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { 662 | 663 | "use strict"; 664 | 665 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 666 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 667 | return new (P || (P = Promise))(function (resolve, reject) { 668 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 669 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 670 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 671 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 672 | }); 673 | }; 674 | Object.defineProperty(exports, "__esModule", ({ value: true })); 675 | exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; 676 | const os_1 = __nccwpck_require__(37); 677 | const fs_1 = __nccwpck_require__(147); 678 | const { access, appendFile, writeFile } = fs_1.promises; 679 | exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; 680 | exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; 681 | class Summary { 682 | constructor() { 683 | this._buffer = ''; 684 | } 685 | /** 686 | * Finds the summary file path from the environment, rejects if env var is not found or file does not exist 687 | * Also checks r/w permissions. 688 | * 689 | * @returns step summary file path 690 | */ 691 | filePath() { 692 | return __awaiter(this, void 0, void 0, function* () { 693 | if (this._filePath) { 694 | return this._filePath; 695 | } 696 | const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; 697 | if (!pathFromEnv) { 698 | throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); 699 | } 700 | try { 701 | yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); 702 | } 703 | catch (_a) { 704 | throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); 705 | } 706 | this._filePath = pathFromEnv; 707 | return this._filePath; 708 | }); 709 | } 710 | /** 711 | * Wraps content in an HTML tag, adding any HTML attributes 712 | * 713 | * @param {string} tag HTML tag to wrap 714 | * @param {string | null} content content within the tag 715 | * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add 716 | * 717 | * @returns {string} content wrapped in HTML element 718 | */ 719 | wrap(tag, content, attrs = {}) { 720 | const htmlAttrs = Object.entries(attrs) 721 | .map(([key, value]) => ` ${key}="${value}"`) 722 | .join(''); 723 | if (!content) { 724 | return `<${tag}${htmlAttrs}>`; 725 | } 726 | return `<${tag}${htmlAttrs}>${content}`; 727 | } 728 | /** 729 | * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. 730 | * 731 | * @param {SummaryWriteOptions} [options] (optional) options for write operation 732 | * 733 | * @returns {Promise} summary instance 734 | */ 735 | write(options) { 736 | return __awaiter(this, void 0, void 0, function* () { 737 | const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); 738 | const filePath = yield this.filePath(); 739 | const writeFunc = overwrite ? writeFile : appendFile; 740 | yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); 741 | return this.emptyBuffer(); 742 | }); 743 | } 744 | /** 745 | * Clears the summary buffer and wipes the summary file 746 | * 747 | * @returns {Summary} summary instance 748 | */ 749 | clear() { 750 | return __awaiter(this, void 0, void 0, function* () { 751 | return this.emptyBuffer().write({ overwrite: true }); 752 | }); 753 | } 754 | /** 755 | * Returns the current summary buffer as a string 756 | * 757 | * @returns {string} string of summary buffer 758 | */ 759 | stringify() { 760 | return this._buffer; 761 | } 762 | /** 763 | * If the summary buffer is empty 764 | * 765 | * @returns {boolen} true if the buffer is empty 766 | */ 767 | isEmptyBuffer() { 768 | return this._buffer.length === 0; 769 | } 770 | /** 771 | * Resets the summary buffer without writing to summary file 772 | * 773 | * @returns {Summary} summary instance 774 | */ 775 | emptyBuffer() { 776 | this._buffer = ''; 777 | return this; 778 | } 779 | /** 780 | * Adds raw text to the summary buffer 781 | * 782 | * @param {string} text content to add 783 | * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) 784 | * 785 | * @returns {Summary} summary instance 786 | */ 787 | addRaw(text, addEOL = false) { 788 | this._buffer += text; 789 | return addEOL ? this.addEOL() : this; 790 | } 791 | /** 792 | * Adds the operating system-specific end-of-line marker to the buffer 793 | * 794 | * @returns {Summary} summary instance 795 | */ 796 | addEOL() { 797 | return this.addRaw(os_1.EOL); 798 | } 799 | /** 800 | * Adds an HTML codeblock to the summary buffer 801 | * 802 | * @param {string} code content to render within fenced code block 803 | * @param {string} lang (optional) language to syntax highlight code 804 | * 805 | * @returns {Summary} summary instance 806 | */ 807 | addCodeBlock(code, lang) { 808 | const attrs = Object.assign({}, (lang && { lang })); 809 | const element = this.wrap('pre', this.wrap('code', code), attrs); 810 | return this.addRaw(element).addEOL(); 811 | } 812 | /** 813 | * Adds an HTML list to the summary buffer 814 | * 815 | * @param {string[]} items list of items to render 816 | * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) 817 | * 818 | * @returns {Summary} summary instance 819 | */ 820 | addList(items, ordered = false) { 821 | const tag = ordered ? 'ol' : 'ul'; 822 | const listItems = items.map(item => this.wrap('li', item)).join(''); 823 | const element = this.wrap(tag, listItems); 824 | return this.addRaw(element).addEOL(); 825 | } 826 | /** 827 | * Adds an HTML table to the summary buffer 828 | * 829 | * @param {SummaryTableCell[]} rows table rows 830 | * 831 | * @returns {Summary} summary instance 832 | */ 833 | addTable(rows) { 834 | const tableBody = rows 835 | .map(row => { 836 | const cells = row 837 | .map(cell => { 838 | if (typeof cell === 'string') { 839 | return this.wrap('td', cell); 840 | } 841 | const { header, data, colspan, rowspan } = cell; 842 | const tag = header ? 'th' : 'td'; 843 | const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); 844 | return this.wrap(tag, data, attrs); 845 | }) 846 | .join(''); 847 | return this.wrap('tr', cells); 848 | }) 849 | .join(''); 850 | const element = this.wrap('table', tableBody); 851 | return this.addRaw(element).addEOL(); 852 | } 853 | /** 854 | * Adds a collapsable HTML details element to the summary buffer 855 | * 856 | * @param {string} label text for the closed state 857 | * @param {string} content collapsable content 858 | * 859 | * @returns {Summary} summary instance 860 | */ 861 | addDetails(label, content) { 862 | const element = this.wrap('details', this.wrap('summary', label) + content); 863 | return this.addRaw(element).addEOL(); 864 | } 865 | /** 866 | * Adds an HTML image tag to the summary buffer 867 | * 868 | * @param {string} src path to the image you to embed 869 | * @param {string} alt text description of the image 870 | * @param {SummaryImageOptions} options (optional) addition image attributes 871 | * 872 | * @returns {Summary} summary instance 873 | */ 874 | addImage(src, alt, options) { 875 | const { width, height } = options || {}; 876 | const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); 877 | const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); 878 | return this.addRaw(element).addEOL(); 879 | } 880 | /** 881 | * Adds an HTML section heading element 882 | * 883 | * @param {string} text heading text 884 | * @param {number | string} [level=1] (optional) the heading level, default: 1 885 | * 886 | * @returns {Summary} summary instance 887 | */ 888 | addHeading(text, level) { 889 | const tag = `h${level}`; 890 | const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) 891 | ? tag 892 | : 'h1'; 893 | const element = this.wrap(allowedTag, text); 894 | return this.addRaw(element).addEOL(); 895 | } 896 | /** 897 | * Adds an HTML thematic break (
) to the summary buffer 898 | * 899 | * @returns {Summary} summary instance 900 | */ 901 | addSeparator() { 902 | const element = this.wrap('hr', null); 903 | return this.addRaw(element).addEOL(); 904 | } 905 | /** 906 | * Adds an HTML line break (
) to the summary buffer 907 | * 908 | * @returns {Summary} summary instance 909 | */ 910 | addBreak() { 911 | const element = this.wrap('br', null); 912 | return this.addRaw(element).addEOL(); 913 | } 914 | /** 915 | * Adds an HTML blockquote to the summary buffer 916 | * 917 | * @param {string} text quote text 918 | * @param {string} cite (optional) citation url 919 | * 920 | * @returns {Summary} summary instance 921 | */ 922 | addQuote(text, cite) { 923 | const attrs = Object.assign({}, (cite && { cite })); 924 | const element = this.wrap('blockquote', text, attrs); 925 | return this.addRaw(element).addEOL(); 926 | } 927 | /** 928 | * Adds an HTML anchor tag to the summary buffer 929 | * 930 | * @param {string} text link text/content 931 | * @param {string} href hyperlink 932 | * 933 | * @returns {Summary} summary instance 934 | */ 935 | addLink(text, href) { 936 | const element = this.wrap('a', text, { href }); 937 | return this.addRaw(element).addEOL(); 938 | } 939 | } 940 | const _summary = new Summary(); 941 | /** 942 | * @deprecated use `core.summary` 943 | */ 944 | exports.markdownSummary = _summary; 945 | exports.summary = _summary; 946 | //# sourceMappingURL=summary.js.map 947 | 948 | /***/ }), 949 | 950 | /***/ 278: 951 | /***/ ((__unused_webpack_module, exports) => { 952 | 953 | "use strict"; 954 | 955 | // We use any as a valid input type 956 | /* eslint-disable @typescript-eslint/no-explicit-any */ 957 | Object.defineProperty(exports, "__esModule", ({ value: true })); 958 | exports.toCommandProperties = exports.toCommandValue = void 0; 959 | /** 960 | * Sanitizes an input into a string so it can be passed into issueCommand safely 961 | * @param input input to sanitize into a string 962 | */ 963 | function toCommandValue(input) { 964 | if (input === null || input === undefined) { 965 | return ''; 966 | } 967 | else if (typeof input === 'string' || input instanceof String) { 968 | return input; 969 | } 970 | return JSON.stringify(input); 971 | } 972 | exports.toCommandValue = toCommandValue; 973 | /** 974 | * 975 | * @param annotationProperties 976 | * @returns The command properties to send with the actual annotation command 977 | * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646 978 | */ 979 | function toCommandProperties(annotationProperties) { 980 | if (!Object.keys(annotationProperties).length) { 981 | return {}; 982 | } 983 | return { 984 | title: annotationProperties.title, 985 | file: annotationProperties.file, 986 | line: annotationProperties.startLine, 987 | endLine: annotationProperties.endLine, 988 | col: annotationProperties.startColumn, 989 | endColumn: annotationProperties.endColumn 990 | }; 991 | } 992 | exports.toCommandProperties = toCommandProperties; 993 | //# sourceMappingURL=utils.js.map 994 | 995 | /***/ }), 996 | 997 | /***/ 526: 998 | /***/ (function(__unused_webpack_module, exports) { 999 | 1000 | "use strict"; 1001 | 1002 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 1003 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 1004 | return new (P || (P = Promise))(function (resolve, reject) { 1005 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 1006 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 1007 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 1008 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 1009 | }); 1010 | }; 1011 | Object.defineProperty(exports, "__esModule", ({ value: true })); 1012 | exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0; 1013 | class BasicCredentialHandler { 1014 | constructor(username, password) { 1015 | this.username = username; 1016 | this.password = password; 1017 | } 1018 | prepareRequest(options) { 1019 | if (!options.headers) { 1020 | throw Error('The request has no headers'); 1021 | } 1022 | options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`; 1023 | } 1024 | // This handler cannot handle 401 1025 | canHandleAuthentication() { 1026 | return false; 1027 | } 1028 | handleAuthentication() { 1029 | return __awaiter(this, void 0, void 0, function* () { 1030 | throw new Error('not implemented'); 1031 | }); 1032 | } 1033 | } 1034 | exports.BasicCredentialHandler = BasicCredentialHandler; 1035 | class BearerCredentialHandler { 1036 | constructor(token) { 1037 | this.token = token; 1038 | } 1039 | // currently implements pre-authorization 1040 | // TODO: support preAuth = false where it hooks on 401 1041 | prepareRequest(options) { 1042 | if (!options.headers) { 1043 | throw Error('The request has no headers'); 1044 | } 1045 | options.headers['Authorization'] = `Bearer ${this.token}`; 1046 | } 1047 | // This handler cannot handle 401 1048 | canHandleAuthentication() { 1049 | return false; 1050 | } 1051 | handleAuthentication() { 1052 | return __awaiter(this, void 0, void 0, function* () { 1053 | throw new Error('not implemented'); 1054 | }); 1055 | } 1056 | } 1057 | exports.BearerCredentialHandler = BearerCredentialHandler; 1058 | class PersonalAccessTokenCredentialHandler { 1059 | constructor(token) { 1060 | this.token = token; 1061 | } 1062 | // currently implements pre-authorization 1063 | // TODO: support preAuth = false where it hooks on 401 1064 | prepareRequest(options) { 1065 | if (!options.headers) { 1066 | throw Error('The request has no headers'); 1067 | } 1068 | options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`; 1069 | } 1070 | // This handler cannot handle 401 1071 | canHandleAuthentication() { 1072 | return false; 1073 | } 1074 | handleAuthentication() { 1075 | return __awaiter(this, void 0, void 0, function* () { 1076 | throw new Error('not implemented'); 1077 | }); 1078 | } 1079 | } 1080 | exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; 1081 | //# sourceMappingURL=auth.js.map 1082 | 1083 | /***/ }), 1084 | 1085 | /***/ 255: 1086 | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { 1087 | 1088 | "use strict"; 1089 | 1090 | /* eslint-disable @typescript-eslint/no-explicit-any */ 1091 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 1092 | if (k2 === undefined) k2 = k; 1093 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 1094 | }) : (function(o, m, k, k2) { 1095 | if (k2 === undefined) k2 = k; 1096 | o[k2] = m[k]; 1097 | })); 1098 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 1099 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 1100 | }) : function(o, v) { 1101 | o["default"] = v; 1102 | }); 1103 | var __importStar = (this && this.__importStar) || function (mod) { 1104 | if (mod && mod.__esModule) return mod; 1105 | var result = {}; 1106 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 1107 | __setModuleDefault(result, mod); 1108 | return result; 1109 | }; 1110 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 1111 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 1112 | return new (P || (P = Promise))(function (resolve, reject) { 1113 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 1114 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 1115 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 1116 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 1117 | }); 1118 | }; 1119 | Object.defineProperty(exports, "__esModule", ({ value: true })); 1120 | exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; 1121 | const http = __importStar(__nccwpck_require__(685)); 1122 | const https = __importStar(__nccwpck_require__(687)); 1123 | const pm = __importStar(__nccwpck_require__(835)); 1124 | const tunnel = __importStar(__nccwpck_require__(294)); 1125 | var HttpCodes; 1126 | (function (HttpCodes) { 1127 | HttpCodes[HttpCodes["OK"] = 200] = "OK"; 1128 | HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; 1129 | HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; 1130 | HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; 1131 | HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; 1132 | HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; 1133 | HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; 1134 | HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; 1135 | HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; 1136 | HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; 1137 | HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; 1138 | HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; 1139 | HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; 1140 | HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; 1141 | HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; 1142 | HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; 1143 | HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; 1144 | HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; 1145 | HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; 1146 | HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; 1147 | HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; 1148 | HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; 1149 | HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; 1150 | HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; 1151 | HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; 1152 | HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; 1153 | HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; 1154 | })(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); 1155 | var Headers; 1156 | (function (Headers) { 1157 | Headers["Accept"] = "accept"; 1158 | Headers["ContentType"] = "content-type"; 1159 | })(Headers = exports.Headers || (exports.Headers = {})); 1160 | var MediaTypes; 1161 | (function (MediaTypes) { 1162 | MediaTypes["ApplicationJson"] = "application/json"; 1163 | })(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); 1164 | /** 1165 | * Returns the proxy URL, depending upon the supplied url and proxy environment variables. 1166 | * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com 1167 | */ 1168 | function getProxyUrl(serverUrl) { 1169 | const proxyUrl = pm.getProxyUrl(new URL(serverUrl)); 1170 | return proxyUrl ? proxyUrl.href : ''; 1171 | } 1172 | exports.getProxyUrl = getProxyUrl; 1173 | const HttpRedirectCodes = [ 1174 | HttpCodes.MovedPermanently, 1175 | HttpCodes.ResourceMoved, 1176 | HttpCodes.SeeOther, 1177 | HttpCodes.TemporaryRedirect, 1178 | HttpCodes.PermanentRedirect 1179 | ]; 1180 | const HttpResponseRetryCodes = [ 1181 | HttpCodes.BadGateway, 1182 | HttpCodes.ServiceUnavailable, 1183 | HttpCodes.GatewayTimeout 1184 | ]; 1185 | const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; 1186 | const ExponentialBackoffCeiling = 10; 1187 | const ExponentialBackoffTimeSlice = 5; 1188 | class HttpClientError extends Error { 1189 | constructor(message, statusCode) { 1190 | super(message); 1191 | this.name = 'HttpClientError'; 1192 | this.statusCode = statusCode; 1193 | Object.setPrototypeOf(this, HttpClientError.prototype); 1194 | } 1195 | } 1196 | exports.HttpClientError = HttpClientError; 1197 | class HttpClientResponse { 1198 | constructor(message) { 1199 | this.message = message; 1200 | } 1201 | readBody() { 1202 | return __awaiter(this, void 0, void 0, function* () { 1203 | return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { 1204 | let output = Buffer.alloc(0); 1205 | this.message.on('data', (chunk) => { 1206 | output = Buffer.concat([output, chunk]); 1207 | }); 1208 | this.message.on('end', () => { 1209 | resolve(output.toString()); 1210 | }); 1211 | })); 1212 | }); 1213 | } 1214 | } 1215 | exports.HttpClientResponse = HttpClientResponse; 1216 | function isHttps(requestUrl) { 1217 | const parsedUrl = new URL(requestUrl); 1218 | return parsedUrl.protocol === 'https:'; 1219 | } 1220 | exports.isHttps = isHttps; 1221 | class HttpClient { 1222 | constructor(userAgent, handlers, requestOptions) { 1223 | this._ignoreSslError = false; 1224 | this._allowRedirects = true; 1225 | this._allowRedirectDowngrade = false; 1226 | this._maxRedirects = 50; 1227 | this._allowRetries = false; 1228 | this._maxRetries = 1; 1229 | this._keepAlive = false; 1230 | this._disposed = false; 1231 | this.userAgent = userAgent; 1232 | this.handlers = handlers || []; 1233 | this.requestOptions = requestOptions; 1234 | if (requestOptions) { 1235 | if (requestOptions.ignoreSslError != null) { 1236 | this._ignoreSslError = requestOptions.ignoreSslError; 1237 | } 1238 | this._socketTimeout = requestOptions.socketTimeout; 1239 | if (requestOptions.allowRedirects != null) { 1240 | this._allowRedirects = requestOptions.allowRedirects; 1241 | } 1242 | if (requestOptions.allowRedirectDowngrade != null) { 1243 | this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; 1244 | } 1245 | if (requestOptions.maxRedirects != null) { 1246 | this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); 1247 | } 1248 | if (requestOptions.keepAlive != null) { 1249 | this._keepAlive = requestOptions.keepAlive; 1250 | } 1251 | if (requestOptions.allowRetries != null) { 1252 | this._allowRetries = requestOptions.allowRetries; 1253 | } 1254 | if (requestOptions.maxRetries != null) { 1255 | this._maxRetries = requestOptions.maxRetries; 1256 | } 1257 | } 1258 | } 1259 | options(requestUrl, additionalHeaders) { 1260 | return __awaiter(this, void 0, void 0, function* () { 1261 | return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); 1262 | }); 1263 | } 1264 | get(requestUrl, additionalHeaders) { 1265 | return __awaiter(this, void 0, void 0, function* () { 1266 | return this.request('GET', requestUrl, null, additionalHeaders || {}); 1267 | }); 1268 | } 1269 | del(requestUrl, additionalHeaders) { 1270 | return __awaiter(this, void 0, void 0, function* () { 1271 | return this.request('DELETE', requestUrl, null, additionalHeaders || {}); 1272 | }); 1273 | } 1274 | post(requestUrl, data, additionalHeaders) { 1275 | return __awaiter(this, void 0, void 0, function* () { 1276 | return this.request('POST', requestUrl, data, additionalHeaders || {}); 1277 | }); 1278 | } 1279 | patch(requestUrl, data, additionalHeaders) { 1280 | return __awaiter(this, void 0, void 0, function* () { 1281 | return this.request('PATCH', requestUrl, data, additionalHeaders || {}); 1282 | }); 1283 | } 1284 | put(requestUrl, data, additionalHeaders) { 1285 | return __awaiter(this, void 0, void 0, function* () { 1286 | return this.request('PUT', requestUrl, data, additionalHeaders || {}); 1287 | }); 1288 | } 1289 | head(requestUrl, additionalHeaders) { 1290 | return __awaiter(this, void 0, void 0, function* () { 1291 | return this.request('HEAD', requestUrl, null, additionalHeaders || {}); 1292 | }); 1293 | } 1294 | sendStream(verb, requestUrl, stream, additionalHeaders) { 1295 | return __awaiter(this, void 0, void 0, function* () { 1296 | return this.request(verb, requestUrl, stream, additionalHeaders); 1297 | }); 1298 | } 1299 | /** 1300 | * Gets a typed object from an endpoint 1301 | * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise 1302 | */ 1303 | getJson(requestUrl, additionalHeaders = {}) { 1304 | return __awaiter(this, void 0, void 0, function* () { 1305 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 1306 | const res = yield this.get(requestUrl, additionalHeaders); 1307 | return this._processResponse(res, this.requestOptions); 1308 | }); 1309 | } 1310 | postJson(requestUrl, obj, additionalHeaders = {}) { 1311 | return __awaiter(this, void 0, void 0, function* () { 1312 | const data = JSON.stringify(obj, null, 2); 1313 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 1314 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 1315 | const res = yield this.post(requestUrl, data, additionalHeaders); 1316 | return this._processResponse(res, this.requestOptions); 1317 | }); 1318 | } 1319 | putJson(requestUrl, obj, additionalHeaders = {}) { 1320 | return __awaiter(this, void 0, void 0, function* () { 1321 | const data = JSON.stringify(obj, null, 2); 1322 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 1323 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 1324 | const res = yield this.put(requestUrl, data, additionalHeaders); 1325 | return this._processResponse(res, this.requestOptions); 1326 | }); 1327 | } 1328 | patchJson(requestUrl, obj, additionalHeaders = {}) { 1329 | return __awaiter(this, void 0, void 0, function* () { 1330 | const data = JSON.stringify(obj, null, 2); 1331 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 1332 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 1333 | const res = yield this.patch(requestUrl, data, additionalHeaders); 1334 | return this._processResponse(res, this.requestOptions); 1335 | }); 1336 | } 1337 | /** 1338 | * Makes a raw http request. 1339 | * All other methods such as get, post, patch, and request ultimately call this. 1340 | * Prefer get, del, post and patch 1341 | */ 1342 | request(verb, requestUrl, data, headers) { 1343 | return __awaiter(this, void 0, void 0, function* () { 1344 | if (this._disposed) { 1345 | throw new Error('Client has already been disposed.'); 1346 | } 1347 | const parsedUrl = new URL(requestUrl); 1348 | let info = this._prepareRequest(verb, parsedUrl, headers); 1349 | // Only perform retries on reads since writes may not be idempotent. 1350 | const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) 1351 | ? this._maxRetries + 1 1352 | : 1; 1353 | let numTries = 0; 1354 | let response; 1355 | do { 1356 | response = yield this.requestRaw(info, data); 1357 | // Check if it's an authentication challenge 1358 | if (response && 1359 | response.message && 1360 | response.message.statusCode === HttpCodes.Unauthorized) { 1361 | let authenticationHandler; 1362 | for (const handler of this.handlers) { 1363 | if (handler.canHandleAuthentication(response)) { 1364 | authenticationHandler = handler; 1365 | break; 1366 | } 1367 | } 1368 | if (authenticationHandler) { 1369 | return authenticationHandler.handleAuthentication(this, info, data); 1370 | } 1371 | else { 1372 | // We have received an unauthorized response but have no handlers to handle it. 1373 | // Let the response return to the caller. 1374 | return response; 1375 | } 1376 | } 1377 | let redirectsRemaining = this._maxRedirects; 1378 | while (response.message.statusCode && 1379 | HttpRedirectCodes.includes(response.message.statusCode) && 1380 | this._allowRedirects && 1381 | redirectsRemaining > 0) { 1382 | const redirectUrl = response.message.headers['location']; 1383 | if (!redirectUrl) { 1384 | // if there's no location to redirect to, we won't 1385 | break; 1386 | } 1387 | const parsedRedirectUrl = new URL(redirectUrl); 1388 | if (parsedUrl.protocol === 'https:' && 1389 | parsedUrl.protocol !== parsedRedirectUrl.protocol && 1390 | !this._allowRedirectDowngrade) { 1391 | throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); 1392 | } 1393 | // we need to finish reading the response before reassigning response 1394 | // which will leak the open socket. 1395 | yield response.readBody(); 1396 | // strip authorization header if redirected to a different hostname 1397 | if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { 1398 | for (const header in headers) { 1399 | // header names are case insensitive 1400 | if (header.toLowerCase() === 'authorization') { 1401 | delete headers[header]; 1402 | } 1403 | } 1404 | } 1405 | // let's make the request with the new redirectUrl 1406 | info = this._prepareRequest(verb, parsedRedirectUrl, headers); 1407 | response = yield this.requestRaw(info, data); 1408 | redirectsRemaining--; 1409 | } 1410 | if (!response.message.statusCode || 1411 | !HttpResponseRetryCodes.includes(response.message.statusCode)) { 1412 | // If not a retry code, return immediately instead of retrying 1413 | return response; 1414 | } 1415 | numTries += 1; 1416 | if (numTries < maxTries) { 1417 | yield response.readBody(); 1418 | yield this._performExponentialBackoff(numTries); 1419 | } 1420 | } while (numTries < maxTries); 1421 | return response; 1422 | }); 1423 | } 1424 | /** 1425 | * Needs to be called if keepAlive is set to true in request options. 1426 | */ 1427 | dispose() { 1428 | if (this._agent) { 1429 | this._agent.destroy(); 1430 | } 1431 | this._disposed = true; 1432 | } 1433 | /** 1434 | * Raw request. 1435 | * @param info 1436 | * @param data 1437 | */ 1438 | requestRaw(info, data) { 1439 | return __awaiter(this, void 0, void 0, function* () { 1440 | return new Promise((resolve, reject) => { 1441 | function callbackForResult(err, res) { 1442 | if (err) { 1443 | reject(err); 1444 | } 1445 | else if (!res) { 1446 | // If `err` is not passed, then `res` must be passed. 1447 | reject(new Error('Unknown error')); 1448 | } 1449 | else { 1450 | resolve(res); 1451 | } 1452 | } 1453 | this.requestRawWithCallback(info, data, callbackForResult); 1454 | }); 1455 | }); 1456 | } 1457 | /** 1458 | * Raw request with callback. 1459 | * @param info 1460 | * @param data 1461 | * @param onResult 1462 | */ 1463 | requestRawWithCallback(info, data, onResult) { 1464 | if (typeof data === 'string') { 1465 | if (!info.options.headers) { 1466 | info.options.headers = {}; 1467 | } 1468 | info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); 1469 | } 1470 | let callbackCalled = false; 1471 | function handleResult(err, res) { 1472 | if (!callbackCalled) { 1473 | callbackCalled = true; 1474 | onResult(err, res); 1475 | } 1476 | } 1477 | const req = info.httpModule.request(info.options, (msg) => { 1478 | const res = new HttpClientResponse(msg); 1479 | handleResult(undefined, res); 1480 | }); 1481 | let socket; 1482 | req.on('socket', sock => { 1483 | socket = sock; 1484 | }); 1485 | // If we ever get disconnected, we want the socket to timeout eventually 1486 | req.setTimeout(this._socketTimeout || 3 * 60000, () => { 1487 | if (socket) { 1488 | socket.end(); 1489 | } 1490 | handleResult(new Error(`Request timeout: ${info.options.path}`)); 1491 | }); 1492 | req.on('error', function (err) { 1493 | // err has statusCode property 1494 | // res should have headers 1495 | handleResult(err); 1496 | }); 1497 | if (data && typeof data === 'string') { 1498 | req.write(data, 'utf8'); 1499 | } 1500 | if (data && typeof data !== 'string') { 1501 | data.on('close', function () { 1502 | req.end(); 1503 | }); 1504 | data.pipe(req); 1505 | } 1506 | else { 1507 | req.end(); 1508 | } 1509 | } 1510 | /** 1511 | * Gets an http agent. This function is useful when you need an http agent that handles 1512 | * routing through a proxy server - depending upon the url and proxy environment variables. 1513 | * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com 1514 | */ 1515 | getAgent(serverUrl) { 1516 | const parsedUrl = new URL(serverUrl); 1517 | return this._getAgent(parsedUrl); 1518 | } 1519 | _prepareRequest(method, requestUrl, headers) { 1520 | const info = {}; 1521 | info.parsedUrl = requestUrl; 1522 | const usingSsl = info.parsedUrl.protocol === 'https:'; 1523 | info.httpModule = usingSsl ? https : http; 1524 | const defaultPort = usingSsl ? 443 : 80; 1525 | info.options = {}; 1526 | info.options.host = info.parsedUrl.hostname; 1527 | info.options.port = info.parsedUrl.port 1528 | ? parseInt(info.parsedUrl.port) 1529 | : defaultPort; 1530 | info.options.path = 1531 | (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); 1532 | info.options.method = method; 1533 | info.options.headers = this._mergeHeaders(headers); 1534 | if (this.userAgent != null) { 1535 | info.options.headers['user-agent'] = this.userAgent; 1536 | } 1537 | info.options.agent = this._getAgent(info.parsedUrl); 1538 | // gives handlers an opportunity to participate 1539 | if (this.handlers) { 1540 | for (const handler of this.handlers) { 1541 | handler.prepareRequest(info.options); 1542 | } 1543 | } 1544 | return info; 1545 | } 1546 | _mergeHeaders(headers) { 1547 | if (this.requestOptions && this.requestOptions.headers) { 1548 | return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {})); 1549 | } 1550 | return lowercaseKeys(headers || {}); 1551 | } 1552 | _getExistingOrDefaultHeader(additionalHeaders, header, _default) { 1553 | let clientHeader; 1554 | if (this.requestOptions && this.requestOptions.headers) { 1555 | clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; 1556 | } 1557 | return additionalHeaders[header] || clientHeader || _default; 1558 | } 1559 | _getAgent(parsedUrl) { 1560 | let agent; 1561 | const proxyUrl = pm.getProxyUrl(parsedUrl); 1562 | const useProxy = proxyUrl && proxyUrl.hostname; 1563 | if (this._keepAlive && useProxy) { 1564 | agent = this._proxyAgent; 1565 | } 1566 | if (this._keepAlive && !useProxy) { 1567 | agent = this._agent; 1568 | } 1569 | // if agent is already assigned use that agent. 1570 | if (agent) { 1571 | return agent; 1572 | } 1573 | const usingSsl = parsedUrl.protocol === 'https:'; 1574 | let maxSockets = 100; 1575 | if (this.requestOptions) { 1576 | maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; 1577 | } 1578 | // This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis. 1579 | if (proxyUrl && proxyUrl.hostname) { 1580 | const agentOptions = { 1581 | maxSockets, 1582 | keepAlive: this._keepAlive, 1583 | proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && { 1584 | proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` 1585 | })), { host: proxyUrl.hostname, port: proxyUrl.port }) 1586 | }; 1587 | let tunnelAgent; 1588 | const overHttps = proxyUrl.protocol === 'https:'; 1589 | if (usingSsl) { 1590 | tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; 1591 | } 1592 | else { 1593 | tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; 1594 | } 1595 | agent = tunnelAgent(agentOptions); 1596 | this._proxyAgent = agent; 1597 | } 1598 | // if reusing agent across request and tunneling agent isn't assigned create a new agent 1599 | if (this._keepAlive && !agent) { 1600 | const options = { keepAlive: this._keepAlive, maxSockets }; 1601 | agent = usingSsl ? new https.Agent(options) : new http.Agent(options); 1602 | this._agent = agent; 1603 | } 1604 | // if not using private agent and tunnel agent isn't setup then use global agent 1605 | if (!agent) { 1606 | agent = usingSsl ? https.globalAgent : http.globalAgent; 1607 | } 1608 | if (usingSsl && this._ignoreSslError) { 1609 | // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process 1610 | // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options 1611 | // we have to cast it to any and change it directly 1612 | agent.options = Object.assign(agent.options || {}, { 1613 | rejectUnauthorized: false 1614 | }); 1615 | } 1616 | return agent; 1617 | } 1618 | _performExponentialBackoff(retryNumber) { 1619 | return __awaiter(this, void 0, void 0, function* () { 1620 | retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); 1621 | const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); 1622 | return new Promise(resolve => setTimeout(() => resolve(), ms)); 1623 | }); 1624 | } 1625 | _processResponse(res, options) { 1626 | return __awaiter(this, void 0, void 0, function* () { 1627 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { 1628 | const statusCode = res.message.statusCode || 0; 1629 | const response = { 1630 | statusCode, 1631 | result: null, 1632 | headers: {} 1633 | }; 1634 | // not found leads to null obj returned 1635 | if (statusCode === HttpCodes.NotFound) { 1636 | resolve(response); 1637 | } 1638 | // get the result from the body 1639 | function dateTimeDeserializer(key, value) { 1640 | if (typeof value === 'string') { 1641 | const a = new Date(value); 1642 | if (!isNaN(a.valueOf())) { 1643 | return a; 1644 | } 1645 | } 1646 | return value; 1647 | } 1648 | let obj; 1649 | let contents; 1650 | try { 1651 | contents = yield res.readBody(); 1652 | if (contents && contents.length > 0) { 1653 | if (options && options.deserializeDates) { 1654 | obj = JSON.parse(contents, dateTimeDeserializer); 1655 | } 1656 | else { 1657 | obj = JSON.parse(contents); 1658 | } 1659 | response.result = obj; 1660 | } 1661 | response.headers = res.message.headers; 1662 | } 1663 | catch (err) { 1664 | // Invalid resource (contents not json); leaving result obj null 1665 | } 1666 | // note that 3xx redirects are handled by the http layer. 1667 | if (statusCode > 299) { 1668 | let msg; 1669 | // if exception/error in body, attempt to get better error 1670 | if (obj && obj.message) { 1671 | msg = obj.message; 1672 | } 1673 | else if (contents && contents.length > 0) { 1674 | // it may be the case that the exception is in the body message as string 1675 | msg = contents; 1676 | } 1677 | else { 1678 | msg = `Failed request: (${statusCode})`; 1679 | } 1680 | const err = new HttpClientError(msg, statusCode); 1681 | err.result = response.result; 1682 | reject(err); 1683 | } 1684 | else { 1685 | resolve(response); 1686 | } 1687 | })); 1688 | }); 1689 | } 1690 | } 1691 | exports.HttpClient = HttpClient; 1692 | const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); 1693 | //# sourceMappingURL=index.js.map 1694 | 1695 | /***/ }), 1696 | 1697 | /***/ 835: 1698 | /***/ ((__unused_webpack_module, exports) => { 1699 | 1700 | "use strict"; 1701 | 1702 | Object.defineProperty(exports, "__esModule", ({ value: true })); 1703 | exports.checkBypass = exports.getProxyUrl = void 0; 1704 | function getProxyUrl(reqUrl) { 1705 | const usingSsl = reqUrl.protocol === 'https:'; 1706 | if (checkBypass(reqUrl)) { 1707 | return undefined; 1708 | } 1709 | const proxyVar = (() => { 1710 | if (usingSsl) { 1711 | return process.env['https_proxy'] || process.env['HTTPS_PROXY']; 1712 | } 1713 | else { 1714 | return process.env['http_proxy'] || process.env['HTTP_PROXY']; 1715 | } 1716 | })(); 1717 | if (proxyVar) { 1718 | return new URL(proxyVar); 1719 | } 1720 | else { 1721 | return undefined; 1722 | } 1723 | } 1724 | exports.getProxyUrl = getProxyUrl; 1725 | function checkBypass(reqUrl) { 1726 | if (!reqUrl.hostname) { 1727 | return false; 1728 | } 1729 | const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; 1730 | if (!noProxy) { 1731 | return false; 1732 | } 1733 | // Determine the request port 1734 | let reqPort; 1735 | if (reqUrl.port) { 1736 | reqPort = Number(reqUrl.port); 1737 | } 1738 | else if (reqUrl.protocol === 'http:') { 1739 | reqPort = 80; 1740 | } 1741 | else if (reqUrl.protocol === 'https:') { 1742 | reqPort = 443; 1743 | } 1744 | // Format the request hostname and hostname with port 1745 | const upperReqHosts = [reqUrl.hostname.toUpperCase()]; 1746 | if (typeof reqPort === 'number') { 1747 | upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); 1748 | } 1749 | // Compare request host against noproxy 1750 | for (const upperNoProxyItem of noProxy 1751 | .split(',') 1752 | .map(x => x.trim().toUpperCase()) 1753 | .filter(x => x)) { 1754 | if (upperReqHosts.some(x => x === upperNoProxyItem)) { 1755 | return true; 1756 | } 1757 | } 1758 | return false; 1759 | } 1760 | exports.checkBypass = checkBypass; 1761 | //# sourceMappingURL=proxy.js.map 1762 | 1763 | /***/ }), 1764 | 1765 | /***/ 294: 1766 | /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { 1767 | 1768 | module.exports = __nccwpck_require__(219); 1769 | 1770 | 1771 | /***/ }), 1772 | 1773 | /***/ 219: 1774 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 1775 | 1776 | "use strict"; 1777 | 1778 | 1779 | var net = __nccwpck_require__(808); 1780 | var tls = __nccwpck_require__(404); 1781 | var http = __nccwpck_require__(685); 1782 | var https = __nccwpck_require__(687); 1783 | var events = __nccwpck_require__(361); 1784 | var assert = __nccwpck_require__(491); 1785 | var util = __nccwpck_require__(837); 1786 | 1787 | 1788 | exports.httpOverHttp = httpOverHttp; 1789 | exports.httpsOverHttp = httpsOverHttp; 1790 | exports.httpOverHttps = httpOverHttps; 1791 | exports.httpsOverHttps = httpsOverHttps; 1792 | 1793 | 1794 | function httpOverHttp(options) { 1795 | var agent = new TunnelingAgent(options); 1796 | agent.request = http.request; 1797 | return agent; 1798 | } 1799 | 1800 | function httpsOverHttp(options) { 1801 | var agent = new TunnelingAgent(options); 1802 | agent.request = http.request; 1803 | agent.createSocket = createSecureSocket; 1804 | agent.defaultPort = 443; 1805 | return agent; 1806 | } 1807 | 1808 | function httpOverHttps(options) { 1809 | var agent = new TunnelingAgent(options); 1810 | agent.request = https.request; 1811 | return agent; 1812 | } 1813 | 1814 | function httpsOverHttps(options) { 1815 | var agent = new TunnelingAgent(options); 1816 | agent.request = https.request; 1817 | agent.createSocket = createSecureSocket; 1818 | agent.defaultPort = 443; 1819 | return agent; 1820 | } 1821 | 1822 | 1823 | function TunnelingAgent(options) { 1824 | var self = this; 1825 | self.options = options || {}; 1826 | self.proxyOptions = self.options.proxy || {}; 1827 | self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; 1828 | self.requests = []; 1829 | self.sockets = []; 1830 | 1831 | self.on('free', function onFree(socket, host, port, localAddress) { 1832 | var options = toOptions(host, port, localAddress); 1833 | for (var i = 0, len = self.requests.length; i < len; ++i) { 1834 | var pending = self.requests[i]; 1835 | if (pending.host === options.host && pending.port === options.port) { 1836 | // Detect the request to connect same origin server, 1837 | // reuse the connection. 1838 | self.requests.splice(i, 1); 1839 | pending.request.onSocket(socket); 1840 | return; 1841 | } 1842 | } 1843 | socket.destroy(); 1844 | self.removeSocket(socket); 1845 | }); 1846 | } 1847 | util.inherits(TunnelingAgent, events.EventEmitter); 1848 | 1849 | TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { 1850 | var self = this; 1851 | var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); 1852 | 1853 | if (self.sockets.length >= this.maxSockets) { 1854 | // We are over limit so we'll add it to the queue. 1855 | self.requests.push(options); 1856 | return; 1857 | } 1858 | 1859 | // If we are under maxSockets create a new one. 1860 | self.createSocket(options, function(socket) { 1861 | socket.on('free', onFree); 1862 | socket.on('close', onCloseOrRemove); 1863 | socket.on('agentRemove', onCloseOrRemove); 1864 | req.onSocket(socket); 1865 | 1866 | function onFree() { 1867 | self.emit('free', socket, options); 1868 | } 1869 | 1870 | function onCloseOrRemove(err) { 1871 | self.removeSocket(socket); 1872 | socket.removeListener('free', onFree); 1873 | socket.removeListener('close', onCloseOrRemove); 1874 | socket.removeListener('agentRemove', onCloseOrRemove); 1875 | } 1876 | }); 1877 | }; 1878 | 1879 | TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { 1880 | var self = this; 1881 | var placeholder = {}; 1882 | self.sockets.push(placeholder); 1883 | 1884 | var connectOptions = mergeOptions({}, self.proxyOptions, { 1885 | method: 'CONNECT', 1886 | path: options.host + ':' + options.port, 1887 | agent: false, 1888 | headers: { 1889 | host: options.host + ':' + options.port 1890 | } 1891 | }); 1892 | if (options.localAddress) { 1893 | connectOptions.localAddress = options.localAddress; 1894 | } 1895 | if (connectOptions.proxyAuth) { 1896 | connectOptions.headers = connectOptions.headers || {}; 1897 | connectOptions.headers['Proxy-Authorization'] = 'Basic ' + 1898 | new Buffer(connectOptions.proxyAuth).toString('base64'); 1899 | } 1900 | 1901 | debug('making CONNECT request'); 1902 | var connectReq = self.request(connectOptions); 1903 | connectReq.useChunkedEncodingByDefault = false; // for v0.6 1904 | connectReq.once('response', onResponse); // for v0.6 1905 | connectReq.once('upgrade', onUpgrade); // for v0.6 1906 | connectReq.once('connect', onConnect); // for v0.7 or later 1907 | connectReq.once('error', onError); 1908 | connectReq.end(); 1909 | 1910 | function onResponse(res) { 1911 | // Very hacky. This is necessary to avoid http-parser leaks. 1912 | res.upgrade = true; 1913 | } 1914 | 1915 | function onUpgrade(res, socket, head) { 1916 | // Hacky. 1917 | process.nextTick(function() { 1918 | onConnect(res, socket, head); 1919 | }); 1920 | } 1921 | 1922 | function onConnect(res, socket, head) { 1923 | connectReq.removeAllListeners(); 1924 | socket.removeAllListeners(); 1925 | 1926 | if (res.statusCode !== 200) { 1927 | debug('tunneling socket could not be established, statusCode=%d', 1928 | res.statusCode); 1929 | socket.destroy(); 1930 | var error = new Error('tunneling socket could not be established, ' + 1931 | 'statusCode=' + res.statusCode); 1932 | error.code = 'ECONNRESET'; 1933 | options.request.emit('error', error); 1934 | self.removeSocket(placeholder); 1935 | return; 1936 | } 1937 | if (head.length > 0) { 1938 | debug('got illegal response body from proxy'); 1939 | socket.destroy(); 1940 | var error = new Error('got illegal response body from proxy'); 1941 | error.code = 'ECONNRESET'; 1942 | options.request.emit('error', error); 1943 | self.removeSocket(placeholder); 1944 | return; 1945 | } 1946 | debug('tunneling connection has established'); 1947 | self.sockets[self.sockets.indexOf(placeholder)] = socket; 1948 | return cb(socket); 1949 | } 1950 | 1951 | function onError(cause) { 1952 | connectReq.removeAllListeners(); 1953 | 1954 | debug('tunneling socket could not be established, cause=%s\n', 1955 | cause.message, cause.stack); 1956 | var error = new Error('tunneling socket could not be established, ' + 1957 | 'cause=' + cause.message); 1958 | error.code = 'ECONNRESET'; 1959 | options.request.emit('error', error); 1960 | self.removeSocket(placeholder); 1961 | } 1962 | }; 1963 | 1964 | TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { 1965 | var pos = this.sockets.indexOf(socket) 1966 | if (pos === -1) { 1967 | return; 1968 | } 1969 | this.sockets.splice(pos, 1); 1970 | 1971 | var pending = this.requests.shift(); 1972 | if (pending) { 1973 | // If we have pending requests and a socket gets closed a new one 1974 | // needs to be created to take over in the pool for the one that closed. 1975 | this.createSocket(pending, function(socket) { 1976 | pending.request.onSocket(socket); 1977 | }); 1978 | } 1979 | }; 1980 | 1981 | function createSecureSocket(options, cb) { 1982 | var self = this; 1983 | TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { 1984 | var hostHeader = options.request.getHeader('host'); 1985 | var tlsOptions = mergeOptions({}, self.options, { 1986 | socket: socket, 1987 | servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host 1988 | }); 1989 | 1990 | // 0 is dummy port for v0.6 1991 | var secureSocket = tls.connect(0, tlsOptions); 1992 | self.sockets[self.sockets.indexOf(socket)] = secureSocket; 1993 | cb(secureSocket); 1994 | }); 1995 | } 1996 | 1997 | 1998 | function toOptions(host, port, localAddress) { 1999 | if (typeof host === 'string') { // since v0.10 2000 | return { 2001 | host: host, 2002 | port: port, 2003 | localAddress: localAddress 2004 | }; 2005 | } 2006 | return host; // for v0.11 or later 2007 | } 2008 | 2009 | function mergeOptions(target) { 2010 | for (var i = 1, len = arguments.length; i < len; ++i) { 2011 | var overrides = arguments[i]; 2012 | if (typeof overrides === 'object') { 2013 | var keys = Object.keys(overrides); 2014 | for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { 2015 | var k = keys[j]; 2016 | if (overrides[k] !== undefined) { 2017 | target[k] = overrides[k]; 2018 | } 2019 | } 2020 | } 2021 | } 2022 | return target; 2023 | } 2024 | 2025 | 2026 | var debug; 2027 | if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { 2028 | debug = function() { 2029 | var args = Array.prototype.slice.call(arguments); 2030 | if (typeof args[0] === 'string') { 2031 | args[0] = 'TUNNEL: ' + args[0]; 2032 | } else { 2033 | args.unshift('TUNNEL:'); 2034 | } 2035 | console.error.apply(console, args); 2036 | } 2037 | } else { 2038 | debug = function() {}; 2039 | } 2040 | exports.debug = debug; // for test 2041 | 2042 | 2043 | /***/ }), 2044 | 2045 | /***/ 840: 2046 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2047 | 2048 | "use strict"; 2049 | 2050 | 2051 | Object.defineProperty(exports, "__esModule", ({ 2052 | value: true 2053 | })); 2054 | Object.defineProperty(exports, "v1", ({ 2055 | enumerable: true, 2056 | get: function () { 2057 | return _v.default; 2058 | } 2059 | })); 2060 | Object.defineProperty(exports, "v3", ({ 2061 | enumerable: true, 2062 | get: function () { 2063 | return _v2.default; 2064 | } 2065 | })); 2066 | Object.defineProperty(exports, "v4", ({ 2067 | enumerable: true, 2068 | get: function () { 2069 | return _v3.default; 2070 | } 2071 | })); 2072 | Object.defineProperty(exports, "v5", ({ 2073 | enumerable: true, 2074 | get: function () { 2075 | return _v4.default; 2076 | } 2077 | })); 2078 | Object.defineProperty(exports, "NIL", ({ 2079 | enumerable: true, 2080 | get: function () { 2081 | return _nil.default; 2082 | } 2083 | })); 2084 | Object.defineProperty(exports, "version", ({ 2085 | enumerable: true, 2086 | get: function () { 2087 | return _version.default; 2088 | } 2089 | })); 2090 | Object.defineProperty(exports, "validate", ({ 2091 | enumerable: true, 2092 | get: function () { 2093 | return _validate.default; 2094 | } 2095 | })); 2096 | Object.defineProperty(exports, "stringify", ({ 2097 | enumerable: true, 2098 | get: function () { 2099 | return _stringify.default; 2100 | } 2101 | })); 2102 | Object.defineProperty(exports, "parse", ({ 2103 | enumerable: true, 2104 | get: function () { 2105 | return _parse.default; 2106 | } 2107 | })); 2108 | 2109 | var _v = _interopRequireDefault(__nccwpck_require__(628)); 2110 | 2111 | var _v2 = _interopRequireDefault(__nccwpck_require__(409)); 2112 | 2113 | var _v3 = _interopRequireDefault(__nccwpck_require__(122)); 2114 | 2115 | var _v4 = _interopRequireDefault(__nccwpck_require__(120)); 2116 | 2117 | var _nil = _interopRequireDefault(__nccwpck_require__(332)); 2118 | 2119 | var _version = _interopRequireDefault(__nccwpck_require__(595)); 2120 | 2121 | var _validate = _interopRequireDefault(__nccwpck_require__(900)); 2122 | 2123 | var _stringify = _interopRequireDefault(__nccwpck_require__(950)); 2124 | 2125 | var _parse = _interopRequireDefault(__nccwpck_require__(746)); 2126 | 2127 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2128 | 2129 | /***/ }), 2130 | 2131 | /***/ 569: 2132 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2133 | 2134 | "use strict"; 2135 | 2136 | 2137 | Object.defineProperty(exports, "__esModule", ({ 2138 | value: true 2139 | })); 2140 | exports["default"] = void 0; 2141 | 2142 | var _crypto = _interopRequireDefault(__nccwpck_require__(113)); 2143 | 2144 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2145 | 2146 | function md5(bytes) { 2147 | if (Array.isArray(bytes)) { 2148 | bytes = Buffer.from(bytes); 2149 | } else if (typeof bytes === 'string') { 2150 | bytes = Buffer.from(bytes, 'utf8'); 2151 | } 2152 | 2153 | return _crypto.default.createHash('md5').update(bytes).digest(); 2154 | } 2155 | 2156 | var _default = md5; 2157 | exports["default"] = _default; 2158 | 2159 | /***/ }), 2160 | 2161 | /***/ 332: 2162 | /***/ ((__unused_webpack_module, exports) => { 2163 | 2164 | "use strict"; 2165 | 2166 | 2167 | Object.defineProperty(exports, "__esModule", ({ 2168 | value: true 2169 | })); 2170 | exports["default"] = void 0; 2171 | var _default = '00000000-0000-0000-0000-000000000000'; 2172 | exports["default"] = _default; 2173 | 2174 | /***/ }), 2175 | 2176 | /***/ 746: 2177 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2178 | 2179 | "use strict"; 2180 | 2181 | 2182 | Object.defineProperty(exports, "__esModule", ({ 2183 | value: true 2184 | })); 2185 | exports["default"] = void 0; 2186 | 2187 | var _validate = _interopRequireDefault(__nccwpck_require__(900)); 2188 | 2189 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2190 | 2191 | function parse(uuid) { 2192 | if (!(0, _validate.default)(uuid)) { 2193 | throw TypeError('Invalid UUID'); 2194 | } 2195 | 2196 | let v; 2197 | const arr = new Uint8Array(16); // Parse ########-....-....-....-............ 2198 | 2199 | arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; 2200 | arr[1] = v >>> 16 & 0xff; 2201 | arr[2] = v >>> 8 & 0xff; 2202 | arr[3] = v & 0xff; // Parse ........-####-....-....-............ 2203 | 2204 | arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; 2205 | arr[5] = v & 0xff; // Parse ........-....-####-....-............ 2206 | 2207 | arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; 2208 | arr[7] = v & 0xff; // Parse ........-....-....-####-............ 2209 | 2210 | arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; 2211 | arr[9] = v & 0xff; // Parse ........-....-....-....-############ 2212 | // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) 2213 | 2214 | arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; 2215 | arr[11] = v / 0x100000000 & 0xff; 2216 | arr[12] = v >>> 24 & 0xff; 2217 | arr[13] = v >>> 16 & 0xff; 2218 | arr[14] = v >>> 8 & 0xff; 2219 | arr[15] = v & 0xff; 2220 | return arr; 2221 | } 2222 | 2223 | var _default = parse; 2224 | exports["default"] = _default; 2225 | 2226 | /***/ }), 2227 | 2228 | /***/ 814: 2229 | /***/ ((__unused_webpack_module, exports) => { 2230 | 2231 | "use strict"; 2232 | 2233 | 2234 | Object.defineProperty(exports, "__esModule", ({ 2235 | value: true 2236 | })); 2237 | exports["default"] = void 0; 2238 | var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; 2239 | exports["default"] = _default; 2240 | 2241 | /***/ }), 2242 | 2243 | /***/ 807: 2244 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2245 | 2246 | "use strict"; 2247 | 2248 | 2249 | Object.defineProperty(exports, "__esModule", ({ 2250 | value: true 2251 | })); 2252 | exports["default"] = rng; 2253 | 2254 | var _crypto = _interopRequireDefault(__nccwpck_require__(113)); 2255 | 2256 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2257 | 2258 | const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate 2259 | 2260 | let poolPtr = rnds8Pool.length; 2261 | 2262 | function rng() { 2263 | if (poolPtr > rnds8Pool.length - 16) { 2264 | _crypto.default.randomFillSync(rnds8Pool); 2265 | 2266 | poolPtr = 0; 2267 | } 2268 | 2269 | return rnds8Pool.slice(poolPtr, poolPtr += 16); 2270 | } 2271 | 2272 | /***/ }), 2273 | 2274 | /***/ 274: 2275 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2276 | 2277 | "use strict"; 2278 | 2279 | 2280 | Object.defineProperty(exports, "__esModule", ({ 2281 | value: true 2282 | })); 2283 | exports["default"] = void 0; 2284 | 2285 | var _crypto = _interopRequireDefault(__nccwpck_require__(113)); 2286 | 2287 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2288 | 2289 | function sha1(bytes) { 2290 | if (Array.isArray(bytes)) { 2291 | bytes = Buffer.from(bytes); 2292 | } else if (typeof bytes === 'string') { 2293 | bytes = Buffer.from(bytes, 'utf8'); 2294 | } 2295 | 2296 | return _crypto.default.createHash('sha1').update(bytes).digest(); 2297 | } 2298 | 2299 | var _default = sha1; 2300 | exports["default"] = _default; 2301 | 2302 | /***/ }), 2303 | 2304 | /***/ 950: 2305 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2306 | 2307 | "use strict"; 2308 | 2309 | 2310 | Object.defineProperty(exports, "__esModule", ({ 2311 | value: true 2312 | })); 2313 | exports["default"] = void 0; 2314 | 2315 | var _validate = _interopRequireDefault(__nccwpck_require__(900)); 2316 | 2317 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2318 | 2319 | /** 2320 | * Convert array of 16 byte values to UUID string format of the form: 2321 | * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 2322 | */ 2323 | const byteToHex = []; 2324 | 2325 | for (let i = 0; i < 256; ++i) { 2326 | byteToHex.push((i + 0x100).toString(16).substr(1)); 2327 | } 2328 | 2329 | function stringify(arr, offset = 0) { 2330 | // Note: Be careful editing this code! It's been tuned for performance 2331 | // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 2332 | const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one 2333 | // of the following: 2334 | // - One or more input array values don't map to a hex octet (leading to 2335 | // "undefined" in the uuid) 2336 | // - Invalid input values for the RFC `version` or `variant` fields 2337 | 2338 | if (!(0, _validate.default)(uuid)) { 2339 | throw TypeError('Stringified UUID is invalid'); 2340 | } 2341 | 2342 | return uuid; 2343 | } 2344 | 2345 | var _default = stringify; 2346 | exports["default"] = _default; 2347 | 2348 | /***/ }), 2349 | 2350 | /***/ 628: 2351 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2352 | 2353 | "use strict"; 2354 | 2355 | 2356 | Object.defineProperty(exports, "__esModule", ({ 2357 | value: true 2358 | })); 2359 | exports["default"] = void 0; 2360 | 2361 | var _rng = _interopRequireDefault(__nccwpck_require__(807)); 2362 | 2363 | var _stringify = _interopRequireDefault(__nccwpck_require__(950)); 2364 | 2365 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2366 | 2367 | // **`v1()` - Generate time-based UUID** 2368 | // 2369 | // Inspired by https://github.com/LiosK/UUID.js 2370 | // and http://docs.python.org/library/uuid.html 2371 | let _nodeId; 2372 | 2373 | let _clockseq; // Previous uuid creation time 2374 | 2375 | 2376 | let _lastMSecs = 0; 2377 | let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details 2378 | 2379 | function v1(options, buf, offset) { 2380 | let i = buf && offset || 0; 2381 | const b = buf || new Array(16); 2382 | options = options || {}; 2383 | let node = options.node || _nodeId; 2384 | let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not 2385 | // specified. We do this lazily to minimize issues related to insufficient 2386 | // system entropy. See #189 2387 | 2388 | if (node == null || clockseq == null) { 2389 | const seedBytes = options.random || (options.rng || _rng.default)(); 2390 | 2391 | if (node == null) { 2392 | // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) 2393 | node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; 2394 | } 2395 | 2396 | if (clockseq == null) { 2397 | // Per 4.2.2, randomize (14 bit) clockseq 2398 | clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; 2399 | } 2400 | } // UUID timestamps are 100 nano-second units since the Gregorian epoch, 2401 | // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so 2402 | // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' 2403 | // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. 2404 | 2405 | 2406 | let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock 2407 | // cycle to simulate higher resolution clock 2408 | 2409 | let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) 2410 | 2411 | const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression 2412 | 2413 | if (dt < 0 && options.clockseq === undefined) { 2414 | clockseq = clockseq + 1 & 0x3fff; 2415 | } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new 2416 | // time interval 2417 | 2418 | 2419 | if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { 2420 | nsecs = 0; 2421 | } // Per 4.2.1.2 Throw error if too many uuids are requested 2422 | 2423 | 2424 | if (nsecs >= 10000) { 2425 | throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); 2426 | } 2427 | 2428 | _lastMSecs = msecs; 2429 | _lastNSecs = nsecs; 2430 | _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch 2431 | 2432 | msecs += 12219292800000; // `time_low` 2433 | 2434 | const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; 2435 | b[i++] = tl >>> 24 & 0xff; 2436 | b[i++] = tl >>> 16 & 0xff; 2437 | b[i++] = tl >>> 8 & 0xff; 2438 | b[i++] = tl & 0xff; // `time_mid` 2439 | 2440 | const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; 2441 | b[i++] = tmh >>> 8 & 0xff; 2442 | b[i++] = tmh & 0xff; // `time_high_and_version` 2443 | 2444 | b[i++] = tmh >>> 24 & 0xf | 0x10; // include version 2445 | 2446 | b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) 2447 | 2448 | b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` 2449 | 2450 | b[i++] = clockseq & 0xff; // `node` 2451 | 2452 | for (let n = 0; n < 6; ++n) { 2453 | b[i + n] = node[n]; 2454 | } 2455 | 2456 | return buf || (0, _stringify.default)(b); 2457 | } 2458 | 2459 | var _default = v1; 2460 | exports["default"] = _default; 2461 | 2462 | /***/ }), 2463 | 2464 | /***/ 409: 2465 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2466 | 2467 | "use strict"; 2468 | 2469 | 2470 | Object.defineProperty(exports, "__esModule", ({ 2471 | value: true 2472 | })); 2473 | exports["default"] = void 0; 2474 | 2475 | var _v = _interopRequireDefault(__nccwpck_require__(998)); 2476 | 2477 | var _md = _interopRequireDefault(__nccwpck_require__(569)); 2478 | 2479 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2480 | 2481 | const v3 = (0, _v.default)('v3', 0x30, _md.default); 2482 | var _default = v3; 2483 | exports["default"] = _default; 2484 | 2485 | /***/ }), 2486 | 2487 | /***/ 998: 2488 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2489 | 2490 | "use strict"; 2491 | 2492 | 2493 | Object.defineProperty(exports, "__esModule", ({ 2494 | value: true 2495 | })); 2496 | exports["default"] = _default; 2497 | exports.URL = exports.DNS = void 0; 2498 | 2499 | var _stringify = _interopRequireDefault(__nccwpck_require__(950)); 2500 | 2501 | var _parse = _interopRequireDefault(__nccwpck_require__(746)); 2502 | 2503 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2504 | 2505 | function stringToBytes(str) { 2506 | str = unescape(encodeURIComponent(str)); // UTF8 escape 2507 | 2508 | const bytes = []; 2509 | 2510 | for (let i = 0; i < str.length; ++i) { 2511 | bytes.push(str.charCodeAt(i)); 2512 | } 2513 | 2514 | return bytes; 2515 | } 2516 | 2517 | const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; 2518 | exports.DNS = DNS; 2519 | const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; 2520 | exports.URL = URL; 2521 | 2522 | function _default(name, version, hashfunc) { 2523 | function generateUUID(value, namespace, buf, offset) { 2524 | if (typeof value === 'string') { 2525 | value = stringToBytes(value); 2526 | } 2527 | 2528 | if (typeof namespace === 'string') { 2529 | namespace = (0, _parse.default)(namespace); 2530 | } 2531 | 2532 | if (namespace.length !== 16) { 2533 | throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); 2534 | } // Compute hash of namespace and value, Per 4.3 2535 | // Future: Use spread syntax when supported on all platforms, e.g. `bytes = 2536 | // hashfunc([...namespace, ... value])` 2537 | 2538 | 2539 | let bytes = new Uint8Array(16 + value.length); 2540 | bytes.set(namespace); 2541 | bytes.set(value, namespace.length); 2542 | bytes = hashfunc(bytes); 2543 | bytes[6] = bytes[6] & 0x0f | version; 2544 | bytes[8] = bytes[8] & 0x3f | 0x80; 2545 | 2546 | if (buf) { 2547 | offset = offset || 0; 2548 | 2549 | for (let i = 0; i < 16; ++i) { 2550 | buf[offset + i] = bytes[i]; 2551 | } 2552 | 2553 | return buf; 2554 | } 2555 | 2556 | return (0, _stringify.default)(bytes); 2557 | } // Function#name is not settable on some platforms (#270) 2558 | 2559 | 2560 | try { 2561 | generateUUID.name = name; // eslint-disable-next-line no-empty 2562 | } catch (err) {} // For CommonJS default export support 2563 | 2564 | 2565 | generateUUID.DNS = DNS; 2566 | generateUUID.URL = URL; 2567 | return generateUUID; 2568 | } 2569 | 2570 | /***/ }), 2571 | 2572 | /***/ 122: 2573 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2574 | 2575 | "use strict"; 2576 | 2577 | 2578 | Object.defineProperty(exports, "__esModule", ({ 2579 | value: true 2580 | })); 2581 | exports["default"] = void 0; 2582 | 2583 | var _rng = _interopRequireDefault(__nccwpck_require__(807)); 2584 | 2585 | var _stringify = _interopRequireDefault(__nccwpck_require__(950)); 2586 | 2587 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2588 | 2589 | function v4(options, buf, offset) { 2590 | options = options || {}; 2591 | 2592 | const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` 2593 | 2594 | 2595 | rnds[6] = rnds[6] & 0x0f | 0x40; 2596 | rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided 2597 | 2598 | if (buf) { 2599 | offset = offset || 0; 2600 | 2601 | for (let i = 0; i < 16; ++i) { 2602 | buf[offset + i] = rnds[i]; 2603 | } 2604 | 2605 | return buf; 2606 | } 2607 | 2608 | return (0, _stringify.default)(rnds); 2609 | } 2610 | 2611 | var _default = v4; 2612 | exports["default"] = _default; 2613 | 2614 | /***/ }), 2615 | 2616 | /***/ 120: 2617 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2618 | 2619 | "use strict"; 2620 | 2621 | 2622 | Object.defineProperty(exports, "__esModule", ({ 2623 | value: true 2624 | })); 2625 | exports["default"] = void 0; 2626 | 2627 | var _v = _interopRequireDefault(__nccwpck_require__(998)); 2628 | 2629 | var _sha = _interopRequireDefault(__nccwpck_require__(274)); 2630 | 2631 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2632 | 2633 | const v5 = (0, _v.default)('v5', 0x50, _sha.default); 2634 | var _default = v5; 2635 | exports["default"] = _default; 2636 | 2637 | /***/ }), 2638 | 2639 | /***/ 900: 2640 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2641 | 2642 | "use strict"; 2643 | 2644 | 2645 | Object.defineProperty(exports, "__esModule", ({ 2646 | value: true 2647 | })); 2648 | exports["default"] = void 0; 2649 | 2650 | var _regex = _interopRequireDefault(__nccwpck_require__(814)); 2651 | 2652 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2653 | 2654 | function validate(uuid) { 2655 | return typeof uuid === 'string' && _regex.default.test(uuid); 2656 | } 2657 | 2658 | var _default = validate; 2659 | exports["default"] = _default; 2660 | 2661 | /***/ }), 2662 | 2663 | /***/ 595: 2664 | /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { 2665 | 2666 | "use strict"; 2667 | 2668 | 2669 | Object.defineProperty(exports, "__esModule", ({ 2670 | value: true 2671 | })); 2672 | exports["default"] = void 0; 2673 | 2674 | var _validate = _interopRequireDefault(__nccwpck_require__(900)); 2675 | 2676 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2677 | 2678 | function version(uuid) { 2679 | if (!(0, _validate.default)(uuid)) { 2680 | throw TypeError('Invalid UUID'); 2681 | } 2682 | 2683 | return parseInt(uuid.substr(14, 1), 16); 2684 | } 2685 | 2686 | var _default = version; 2687 | exports["default"] = _default; 2688 | 2689 | /***/ }), 2690 | 2691 | /***/ 491: 2692 | /***/ ((module) => { 2693 | 2694 | "use strict"; 2695 | module.exports = require("assert"); 2696 | 2697 | /***/ }), 2698 | 2699 | /***/ 300: 2700 | /***/ ((module) => { 2701 | 2702 | "use strict"; 2703 | module.exports = require("buffer"); 2704 | 2705 | /***/ }), 2706 | 2707 | /***/ 81: 2708 | /***/ ((module) => { 2709 | 2710 | "use strict"; 2711 | module.exports = require("child_process"); 2712 | 2713 | /***/ }), 2714 | 2715 | /***/ 113: 2716 | /***/ ((module) => { 2717 | 2718 | "use strict"; 2719 | module.exports = require("crypto"); 2720 | 2721 | /***/ }), 2722 | 2723 | /***/ 361: 2724 | /***/ ((module) => { 2725 | 2726 | "use strict"; 2727 | module.exports = require("events"); 2728 | 2729 | /***/ }), 2730 | 2731 | /***/ 147: 2732 | /***/ ((module) => { 2733 | 2734 | "use strict"; 2735 | module.exports = require("fs"); 2736 | 2737 | /***/ }), 2738 | 2739 | /***/ 685: 2740 | /***/ ((module) => { 2741 | 2742 | "use strict"; 2743 | module.exports = require("http"); 2744 | 2745 | /***/ }), 2746 | 2747 | /***/ 687: 2748 | /***/ ((module) => { 2749 | 2750 | "use strict"; 2751 | module.exports = require("https"); 2752 | 2753 | /***/ }), 2754 | 2755 | /***/ 808: 2756 | /***/ ((module) => { 2757 | 2758 | "use strict"; 2759 | module.exports = require("net"); 2760 | 2761 | /***/ }), 2762 | 2763 | /***/ 37: 2764 | /***/ ((module) => { 2765 | 2766 | "use strict"; 2767 | module.exports = require("os"); 2768 | 2769 | /***/ }), 2770 | 2771 | /***/ 17: 2772 | /***/ ((module) => { 2773 | 2774 | "use strict"; 2775 | module.exports = require("path"); 2776 | 2777 | /***/ }), 2778 | 2779 | /***/ 282: 2780 | /***/ ((module) => { 2781 | 2782 | "use strict"; 2783 | module.exports = require("process"); 2784 | 2785 | /***/ }), 2786 | 2787 | /***/ 781: 2788 | /***/ ((module) => { 2789 | 2790 | "use strict"; 2791 | module.exports = require("stream"); 2792 | 2793 | /***/ }), 2794 | 2795 | /***/ 404: 2796 | /***/ ((module) => { 2797 | 2798 | "use strict"; 2799 | module.exports = require("tls"); 2800 | 2801 | /***/ }), 2802 | 2803 | /***/ 837: 2804 | /***/ ((module) => { 2805 | 2806 | "use strict"; 2807 | module.exports = require("util"); 2808 | 2809 | /***/ }) 2810 | 2811 | /******/ }); 2812 | /************************************************************************/ 2813 | /******/ // The module cache 2814 | /******/ var __webpack_module_cache__ = {}; 2815 | /******/ 2816 | /******/ // The require function 2817 | /******/ function __nccwpck_require__(moduleId) { 2818 | /******/ // Check if module is in cache 2819 | /******/ var cachedModule = __webpack_module_cache__[moduleId]; 2820 | /******/ if (cachedModule !== undefined) { 2821 | /******/ return cachedModule.exports; 2822 | /******/ } 2823 | /******/ // Create a new module (and put it into the cache) 2824 | /******/ var module = __webpack_module_cache__[moduleId] = { 2825 | /******/ // no module.id needed 2826 | /******/ // no module.loaded needed 2827 | /******/ exports: {} 2828 | /******/ }; 2829 | /******/ 2830 | /******/ // Execute the module function 2831 | /******/ var threw = true; 2832 | /******/ try { 2833 | /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__); 2834 | /******/ threw = false; 2835 | /******/ } finally { 2836 | /******/ if(threw) delete __webpack_module_cache__[moduleId]; 2837 | /******/ } 2838 | /******/ 2839 | /******/ // Return the exports of the module 2840 | /******/ return module.exports; 2841 | /******/ } 2842 | /******/ 2843 | /************************************************************************/ 2844 | /******/ /* webpack/runtime/compat */ 2845 | /******/ 2846 | /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; 2847 | /******/ 2848 | /************************************************************************/ 2849 | var __webpack_exports__ = {}; 2850 | // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 2851 | (() => { 2852 | const { spawn } = __nccwpck_require__(81) 2853 | const { Transform } = __nccwpck_require__(781) 2854 | const { Buffer } = __nccwpck_require__(300) 2855 | const process = __nccwpck_require__(282) 2856 | 2857 | const core = __nccwpck_require__(186) 2858 | 2859 | // Default shell invocation used by GitHub Action 'run:' 2860 | const shellArgs = { 2861 | bash: ['--noprofile', '--norc', '-eo', 'pipefail', '-c'], 2862 | sh: ['-e', '-c'], 2863 | python: ['-c'], 2864 | pwsh: ['-command', '.'], 2865 | powershell: ['-command', '.'] 2866 | } 2867 | 2868 | class RecordStream extends Transform { 2869 | constructor () { 2870 | super() 2871 | this._data = Buffer.from([]) 2872 | } 2873 | 2874 | get output () { 2875 | return this._data 2876 | } 2877 | 2878 | _transform (chunk, encoding, callback) { 2879 | this._data = Buffer.concat([this._data, chunk]) 2880 | callback(null, chunk) 2881 | } 2882 | } 2883 | 2884 | function run (command, shell) { 2885 | return new Promise((resolve, reject) => { 2886 | const outRec = new RecordStream() 2887 | const errRec = new RecordStream() 2888 | 2889 | const args = shellArgs[shell] 2890 | 2891 | if (!args) { 2892 | return reject(new Error(`Option "shell" must be one of: ${Object.keys(shellArgs).join(', ')}.`)) 2893 | } 2894 | 2895 | // Execute the command 2896 | const cmd = spawn(shell, [...args, command]) 2897 | 2898 | // Record stream output and pass it through main process 2899 | cmd.stdout.pipe(outRec).pipe(process.stdout) 2900 | cmd.stderr.pipe(errRec).pipe(process.stderr) 2901 | 2902 | cmd.on('error', error => reject(error)) 2903 | 2904 | cmd.on('close', code => { 2905 | core.setOutput('stdout', outRec.output.toString()) 2906 | core.setOutput('stderr', errRec.output.toString()) 2907 | 2908 | if (code === 0) { 2909 | resolve() 2910 | } else { 2911 | reject(new Error(`Process completed with exit code ${code}.`)) 2912 | } 2913 | }) 2914 | }) 2915 | } 2916 | 2917 | run(core.getInput('run'), core.getInput('shell')) 2918 | .catch(error => core.setFailed(error.message)) 2919 | 2920 | })(); 2921 | 2922 | module.exports = __webpack_exports__; 2923 | /******/ })() 2924 | ; -------------------------------------------------------------------------------- /dist/licenses.txt: -------------------------------------------------------------------------------- 1 | @actions/core 2 | MIT 3 | The MIT License (MIT) 4 | 5 | Copyright 2019 GitHub 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | @actions/http-client 14 | MIT 15 | Actions Http Client for Node.js 16 | 17 | Copyright (c) GitHub, Inc. 18 | 19 | All rights reserved. 20 | 21 | MIT License 22 | 23 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 24 | associated documentation files (the "Software"), to deal in the Software without restriction, 25 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 26 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 27 | subject to the following conditions: 28 | 29 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 32 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 33 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 34 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 35 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | 37 | 38 | tunnel 39 | MIT 40 | The MIT License (MIT) 41 | 42 | Copyright (c) 2012 Koichi Kobayashi 43 | 44 | Permission is hereby granted, free of charge, to any person obtaining a copy 45 | of this software and associated documentation files (the "Software"), to deal 46 | in the Software without restriction, including without limitation the rights 47 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 48 | copies of the Software, and to permit persons to whom the Software is 49 | furnished to do so, subject to the following conditions: 50 | 51 | The above copyright notice and this permission notice shall be included in 52 | all copies or substantial portions of the Software. 53 | 54 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 55 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 56 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 57 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 58 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 59 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 60 | THE SOFTWARE. 61 | 62 | 63 | uuid 64 | MIT 65 | The MIT License (MIT) 66 | 67 | Copyright (c) 2010-2020 Robert Kieffer and other contributors 68 | 69 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 70 | 71 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 72 | 73 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 74 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { spawn } = require('child_process') 2 | const { Transform } = require('stream') 3 | const { Buffer } = require('buffer') 4 | const process = require('process') 5 | 6 | const core = require('@actions/core') 7 | 8 | // Default shell invocation used by GitHub Action 'run:' 9 | const shellArgs = { 10 | bash: ['--noprofile', '--norc', '-eo', 'pipefail', '-c'], 11 | sh: ['-e', '-c'], 12 | python: ['-c'], 13 | pwsh: ['-command', '.'], 14 | powershell: ['-command', '.'] 15 | } 16 | 17 | class RecordStream extends Transform { 18 | constructor () { 19 | super() 20 | this._data = Buffer.from([]) 21 | } 22 | 23 | get output () { 24 | return this._data 25 | } 26 | 27 | _transform (chunk, encoding, callback) { 28 | this._data = Buffer.concat([this._data, chunk]) 29 | callback(null, chunk) 30 | } 31 | } 32 | 33 | function run (command, shell) { 34 | return new Promise((resolve, reject) => { 35 | const outRec = new RecordStream() 36 | const errRec = new RecordStream() 37 | 38 | const args = shellArgs[shell] 39 | 40 | if (!args) { 41 | return reject(new Error(`Option "shell" must be one of: ${Object.keys(shellArgs).join(', ')}.`)) 42 | } 43 | 44 | // Execute the command 45 | const cmd = spawn(shell, [...args, command]) 46 | 47 | // Record stream output and pass it through main process 48 | cmd.stdout.pipe(outRec).pipe(process.stdout) 49 | cmd.stderr.pipe(errRec).pipe(process.stderr) 50 | 51 | cmd.on('error', error => reject(error)) 52 | 53 | cmd.on('close', code => { 54 | core.setOutput('stdout', outRec.output.toString()) 55 | core.setOutput('stderr', errRec.output.toString()) 56 | 57 | if (code === 0) { 58 | resolve() 59 | } else { 60 | reject(new Error(`Process completed with exit code ${code}.`)) 61 | } 62 | }) 63 | }) 64 | } 65 | 66 | run(core.getInput('run'), core.getInput('shell')) 67 | .catch(error => core.setFailed(error.message)) 68 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "command-output", 3 | "version": "2.0.0", 4 | "description": "Run a command and store its output", 5 | "private": true, 6 | "main": "index.js", 7 | "scripts": { 8 | "build": "ncc build index.js --license licenses.txt", 9 | "lint": "eslint .", 10 | "test": "npm run lint" 11 | }, 12 | "keywords": [], 13 | "author": "Mathias Rasmussen ", 14 | "license": "MIT", 15 | "devDependencies": { 16 | "@actions/core": "^1.10.0", 17 | "@vercel/ncc": "^0.36.1", 18 | "eslint-config-standard": "^17.0.0" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/mathiasvr/command-output.git" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/mathiasvr/command-output/issues" 26 | }, 27 | "homepage": "https://github.com/mathiasvr/command-output#readme" 28 | } 29 | --------------------------------------------------------------------------------