├── .eslintignore ├── .eslintrc.json ├── .github └── workflows │ └── test.yml ├── .gitignore ├── .prettierignore ├── .prettierrc.json ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── action-types.yml ├── action.yml ├── building-release.md ├── dist └── index.js ├── jest.config.js ├── package-lock.json ├── package.json ├── src └── main.ts └── tsconfig.json /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["jest", "@typescript-eslint"], 3 | "extends": ["plugin:github/es6"], 4 | "parser": "@typescript-eslint/parser", 5 | "parserOptions": { 6 | "ecmaVersion": 9, 7 | "sourceType": "module", 8 | "project": "./tsconfig.json" 9 | }, 10 | "rules": { 11 | "eslint-comments/no-use": "off", 12 | "import/no-namespace": "off", 13 | "no-unused-vars": "off", 14 | "@typescript-eslint/no-unused-vars": "error", 15 | "@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}], 16 | "@typescript-eslint/no-require-imports": "error", 17 | "@typescript-eslint/array-type": "error", 18 | "@typescript-eslint/await-thenable": "error", 19 | "@typescript-eslint/ban-ts-ignore": "error", 20 | "camelcase": "off", 21 | "@typescript-eslint/camelcase": "error", 22 | "@typescript-eslint/class-name-casing": "error", 23 | "@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}], 24 | "@typescript-eslint/func-call-spacing": ["error", "never"], 25 | "@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"], 26 | "@typescript-eslint/no-array-constructor": "error", 27 | "@typescript-eslint/no-empty-interface": "error", 28 | "@typescript-eslint/no-explicit-any": "error", 29 | "@typescript-eslint/no-extraneous-class": "error", 30 | "@typescript-eslint/no-for-in-array": "error", 31 | "@typescript-eslint/no-inferrable-types": "error", 32 | "@typescript-eslint/no-misused-new": "error", 33 | "@typescript-eslint/no-namespace": "error", 34 | "@typescript-eslint/no-non-null-assertion": "warn", 35 | "@typescript-eslint/no-object-literal-type-assertion": "error", 36 | "@typescript-eslint/no-unnecessary-qualifier": "error", 37 | "@typescript-eslint/no-unnecessary-type-assertion": "error", 38 | "@typescript-eslint/no-useless-constructor": "error", 39 | "@typescript-eslint/no-var-requires": "error", 40 | "@typescript-eslint/prefer-for-of": "warn", 41 | "@typescript-eslint/prefer-function-type": "warn", 42 | "@typescript-eslint/prefer-includes": "error", 43 | "@typescript-eslint/prefer-interface": "error", 44 | "@typescript-eslint/prefer-string-starts-ends-with": "error", 45 | "@typescript-eslint/promise-function-async": "error", 46 | "@typescript-eslint/require-array-sort-compare": "error", 47 | "@typescript-eslint/restrict-plus-operands": "error", 48 | "semi": "off", 49 | "@typescript-eslint/semi": ["error", "never"], 50 | "@typescript-eslint/type-annotation-spacing": "error", 51 | "@typescript-eslint/unbound-method": "error" 52 | }, 53 | "env": { 54 | "node": true, 55 | "es6": true, 56 | "jest/globals": true 57 | } 58 | } -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: "build-test-dev" 2 | on: 3 | pull_request: 4 | branches: 5 | - dev 6 | paths-ignore: 7 | - '*.md' 8 | push: 9 | branches: 10 | - dev 11 | paths-ignore: 12 | - '*.md' 13 | workflow_dispatch: 14 | branches: 15 | - dev 16 | - arm64 17 | - master 18 | paths-ignore: 19 | - '*.md' 20 | 21 | 22 | jobs: 23 | build: 24 | runs-on: windows-latest 25 | steps: 26 | - uses: actions/checkout@v4 27 | 28 | - name: Setup MSBuild (vswhere-path) 29 | id: setup_msbuild_explicit 30 | uses: ./ 31 | with: 32 | vswhere-path: C:\ProgramData\chocolatey\bin 33 | 34 | - name: Setup MSBuild (PATH) 35 | id: setup_msbuild_path 36 | uses: ./ 37 | 38 | - name: Setup MSBuild (fallback) 39 | id: setup_msbuild_fallback 40 | uses: ./ 41 | env: 42 | PATH: '' 43 | 44 | - name: Setup MSBuild (x64) 45 | if: always() 46 | id: setup_msbuild_path_x64 47 | uses: ./ 48 | with: 49 | vs-prerelease: true 50 | msbuild-architecture: 'x64' 51 | 52 | - name: Setup MSBuild (arm64) 53 | if: always() 54 | id: setup_msbuild_path_arm 55 | uses: ./ 56 | with: 57 | vs-prerelease: true 58 | msbuild-architecture: 'arm64' 59 | 60 | - name: echo msbuild path 61 | run: | 62 | echo "vswhere-path: ${{ steps.setup_msbuild_explicit.outputs.msbuildPath }}" 63 | echo "PATH: ${{ steps.setup_msbuild_path.outputs.msbuildPath }}" 64 | echo "ARM PATH: ${{ steps.setup_msbuild_path_arm.outputs.msbuildPath }}" 65 | echo "ARM PATH: ${{ steps.setup_msbuild_path_x64.outputs.msbuildPath }}" 66 | echo "Fallback: ${{ steps.setup_msbuild_fallback.outputs.msbuildPath }}" 67 | 68 | - name: echo MSBuild 69 | run: msbuild -version 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directory 2 | node_modules 3 | 4 | # Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | jspm_packages/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Optional REPL history 60 | .node_repl_history 61 | 62 | # Output of 'npm pack' 63 | *.tgz 64 | 65 | # Yarn Integrity file 66 | .yarn-integrity 67 | 68 | # dotenv environment variables file 69 | .env 70 | .env.test 71 | 72 | # parcel-bundler cache (https://parceljs.org/) 73 | .cache 74 | 75 | # next.js build output 76 | .next 77 | 78 | # nuxt.js build output 79 | .nuxt 80 | 81 | # vuepress build output 82 | .vuepress/dist 83 | 84 | # Serverless directories 85 | .serverless/ 86 | 87 | # FuseBox cache 88 | .fusebox/ 89 | 90 | # DynamoDB Local files 91 | .dynamodb/ 92 | 93 | # OS metadata 94 | .DS_Store 95 | Thumbs.db 96 | 97 | # Ignore built ts files 98 | __tests__/runner/* 99 | lib/**/* -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": true, 7 | "trailingComma": "none", 8 | "bracketSpacing": false, 9 | "arrowParens": "avoid", 10 | "parser": "typescript" 11 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, 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, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # microsoft/setup-msbuild 2 | 3 | This action will help discover where the `MSBuild` tool is and automatically add it to the `PATH` environment variables for you so future steps in your Actions workflow can just initiate `msbuild` commands without knowing the full path. 4 | 5 | > [!IMPORTANT] 6 | > Please note this tool does NOT add other Visual Studio tools (like VSTest, cl, cmake, or others) to `PATH` 7 | 8 | ## Example Usage 9 | 10 | ```yml 11 | - name: Add msbuild to PATH 12 | uses: microsoft/setup-msbuild@v2 13 | 14 | - name: Build app for release 15 | run: msbuild src\YourProjectFile.csproj -t:rebuild -verbosity:diag -property:Configuration=Release 16 | ``` 17 | 18 | ## Runners and included software 19 | 20 | This action is intended to be used within the GitHub Actions workflows using the model of 'runners' either hosted (provided by GitHub) or self-hosted (provided by you). The version and parameters you specify below are going to be scoped to what software actually exists on the runner image being used. For example, hosted runner images from GitHub typically do NOT have pre-release versions of Visual Studio on them so using `vs-prerelease` parameter noted below may not have intended effect when using hosted runners. The software included for GitHub-hosted runner images can always be found here: which also includes information on when/how software on hosted images gets updated. 21 | 22 | ## Optional Parameters 23 | 24 | There are a few additional parameters that can be set if you need them. These are optional and should only be set if you know that you need them or what you are doing. 25 | 26 | ### Specifying specific versions of Visual Studio (optional) 27 | 28 | You may have a situation where your Actions runner has multiple versions of Visual Studio and you need to find a specific version of the tool. Simply add the `vs-version` input to specify the range of versions to find. If looking for a specific version, specify the minimum and maximum versions as shown in the example below, which will look for just 16.4. 29 | 30 | ```yml 31 | - name: Add msbuild to PATH 32 | uses: microsoft/setup-msbuild@v2 33 | with: 34 | vs-version: '[16.4,16.5)' 35 | ``` 36 | 37 | The syntax is the same used for Visual Studio extensions, where square brackets like "[" mean inclusive, and parenthesis like "(" mean exclusive. A comma is always required, but eliding the minimum version looks for all older versions and eliding the maximum version looks for all newer versions. See the [vswhere wiki](https://github.com/microsoft/vswhere/wiki) for more details. 38 | 39 | ### Use pre-release versions of Visual Studio (optional) 40 | 41 | If you need your Actions runner to target a pre-release version of Visual Studio, simply add the `vs-prerelease` input. This is necessary if you want to run an action on a virtual environment that contains a pre-release version of Visual Studio or self-hosted images that you may have that also have pre-release versions of Visual Studio installed. 42 | 43 | ```yml 44 | - name: Add msbuild to PATH 45 | uses: microsoft/setup-msbuild@v2 46 | with: 47 | vs-prerelease: true 48 | ``` 49 | 50 | ### Specifying MSBuild architecture (optional) 51 | 52 | By default the action will use the x86 architecture for MSBuild, but it is possible to target the x64 versions instead. Simply add the `msbuild-architecture` input. Valid input values are `x86` (default), `x64`, and `arm64`. Note that the success of these will rely on the runner OS. 53 | 54 | ```yml 55 | - name: Add msbuild to PATH 56 | uses: microsoft/setup-msbuild@v2 57 | with: 58 | msbuild-architecture: x64 59 | ``` 60 | 61 | ## How does this work? 62 | 63 | This makes use of the vswhere tool which is a tool delivered by Microsoft to help in identifying Visual Studio installs and various components. This tool is installed on the hosted Windows runners for GitHub Actions. If you are using a self-hosted runner, you either need to make sure vswhere.exe is in your agent's PATH or specify a full path to the location using: 64 | 65 | ```yml 66 | - name: Add msbuild to PATH 67 | uses: microsoft/setup-msbuild@v2 68 | with: 69 | vswhere-path: 'C:\path\to\your\tools\' 70 | ``` 71 | 72 | ## Notes on arguments 73 | 74 | While the Action enables you to specify a `vswhere` path as well as a `vs-version`, these are more advanced options and when using GitHub-hosted runners you should not need these and is recommended you don't specify them as they are optional. Using these require you to fully understand the runner environment, updates to the tools on the runner, and can cause failures if you are out of sync. For GitHub-hosted runners, omitting these arguments is the preferred usage. 75 | 76 | ## Building this repo 77 | 78 | As with most GitHub Actions, this requires NodeJS development tools. After installing NodeJS, you can build this by executing: 79 | 80 | ```bash 81 | npm install 82 | npm run build 83 | npm run pack 84 | ``` 85 | 86 | which will modify/create the /dist folder with the final index.js output 87 | 88 | # Credits 89 | 90 | Thank you to [Warren Buckley](https://github.com/warrenbuckley) for being a core contributor to this Action for the benefit of all developers! 91 | 92 | # Contributing 93 | 94 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 95 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 96 | the rights to use your contribution. For details, visit . 97 | 98 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide 99 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions 100 | provided by the bot. You will only need to do this once across all repos using our CLA. 101 | 102 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 103 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 104 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 105 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)) of a security vulnerability, please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /action-types.yml: -------------------------------------------------------------------------------- 1 | # See https://github.com/krzema12/github-actions-typing 2 | inputs: 3 | vswhere-path: 4 | type: string 5 | vs-version: 6 | type: string 7 | vs-prerelease: 8 | type: boolean 9 | msbuild-architecture: 10 | type: enum 11 | name: Architecture 12 | allowed-values: 13 | - x86 14 | - x64 15 | - arm64 16 | outputs: 17 | msbuildPath: 18 | type: string 19 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "setup-msbuild" 2 | description: "Helps set up MSBuild into PATH for later usage." 3 | author: "Microsoft" 4 | branding: 5 | color: purple 6 | icon: terminal 7 | inputs: 8 | vswhere-path: 9 | required: false 10 | description: "Folder location of where vswhere.exe is located if a self-hosted agent" 11 | vs-version: 12 | description: "Version of Visual Studio to search; defaults to latest if not specified" 13 | required: false 14 | vs-prerelease: 15 | description: "Enable searching for pre-release versions of Visual Studio/MSBuild" 16 | required: false 17 | msbuild-architecture: 18 | description: 'The preferred processor architecture of MSBuild. Can be either "x86", "x64", or "arm64". "x64" is only available from Visual Studio version 17.0 and later.' 19 | required: false 20 | default: "x86" 21 | outputs: 22 | msbuildPath: 23 | description: "The resulting location of msbuild for your inputs" 24 | 25 | runs: 26 | using: "node20" 27 | main: "dist/index.js" 28 | -------------------------------------------------------------------------------- /building-release.md: -------------------------------------------------------------------------------- 1 | # Building a release 2 | This is a quick document to walk through the process of building and releasing. 3 | 4 | ## Building the version 5 | - Create a new branch [vMajor.Minor.Revision] for the version from `dev` 6 | - Make changes in the new branch 7 | - Build the branch/package 8 | - `npm install` 9 | - `npm run build` 10 | - `npm run pack` 11 | - Prune the dependencies to only production 12 | - `npm prune --production` 13 | - Uncomment `node_modules` in `.gitignore` **for this branch only** 14 | - Commit the changes to the branch 15 | - Push the new version branch 16 | - `git push origin [vMajor.Minor.Revision]` 17 | 18 | ## Releasing the new version 19 | - Draft a new release to [vMajor.Minor.Revision] 20 | 21 | ## Update major version tag 22 | If the update is non-breaking and the major version binding you can update the version tag to make the new release available to those binding to the major version tag ([GitHub Actions Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)). 23 | 24 | Do this from the version branch after push (using a v1 tag as example only here) 25 | 26 | ``` 27 | git tag -fa v1 -m "Update v1 tag" 28 | git push origin v1 --force 29 | ``` -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | module.exports = 2 | /******/ (function(modules, runtime) { // webpackBootstrap 3 | /******/ "use strict"; 4 | /******/ // The module cache 5 | /******/ var installedModules = {}; 6 | /******/ 7 | /******/ // The require function 8 | /******/ function __webpack_require__(moduleId) { 9 | /******/ 10 | /******/ // Check if module is in cache 11 | /******/ if(installedModules[moduleId]) { 12 | /******/ return installedModules[moduleId].exports; 13 | /******/ } 14 | /******/ // Create a new module (and put it into the cache) 15 | /******/ var module = installedModules[moduleId] = { 16 | /******/ i: moduleId, 17 | /******/ l: false, 18 | /******/ exports: {} 19 | /******/ }; 20 | /******/ 21 | /******/ // Execute the module function 22 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 23 | /******/ 24 | /******/ // Flag the module as loaded 25 | /******/ module.l = true; 26 | /******/ 27 | /******/ // Return the exports of the module 28 | /******/ return module.exports; 29 | /******/ } 30 | /******/ 31 | /******/ 32 | /******/ __webpack_require__.ab = __dirname + "/"; 33 | /******/ 34 | /******/ // the startup function 35 | /******/ function startup() { 36 | /******/ // Load entry module and return exports 37 | /******/ return __webpack_require__(198); 38 | /******/ }; 39 | /******/ 40 | /******/ // run startup 41 | /******/ return startup(); 42 | /******/ }) 43 | /************************************************************************/ 44 | /******/ ({ 45 | 46 | /***/ 1: 47 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 48 | 49 | "use strict"; 50 | 51 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 52 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 53 | return new (P || (P = Promise))(function (resolve, reject) { 54 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 55 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 56 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 57 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 58 | }); 59 | }; 60 | Object.defineProperty(exports, "__esModule", { value: true }); 61 | const childProcess = __webpack_require__(129); 62 | const path = __webpack_require__(622); 63 | const util_1 = __webpack_require__(669); 64 | const ioUtil = __webpack_require__(672); 65 | const exec = util_1.promisify(childProcess.exec); 66 | /** 67 | * Copies a file or folder. 68 | * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js 69 | * 70 | * @param source source path 71 | * @param dest destination path 72 | * @param options optional. See CopyOptions. 73 | */ 74 | function cp(source, dest, options = {}) { 75 | return __awaiter(this, void 0, void 0, function* () { 76 | const { force, recursive } = readCopyOptions(options); 77 | const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null; 78 | // Dest is an existing file, but not forcing 79 | if (destStat && destStat.isFile() && !force) { 80 | return; 81 | } 82 | // If dest is an existing directory, should copy inside. 83 | const newDest = destStat && destStat.isDirectory() 84 | ? path.join(dest, path.basename(source)) 85 | : dest; 86 | if (!(yield ioUtil.exists(source))) { 87 | throw new Error(`no such file or directory: ${source}`); 88 | } 89 | const sourceStat = yield ioUtil.stat(source); 90 | if (sourceStat.isDirectory()) { 91 | if (!recursive) { 92 | throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`); 93 | } 94 | else { 95 | yield cpDirRecursive(source, newDest, 0, force); 96 | } 97 | } 98 | else { 99 | if (path.relative(source, newDest) === '') { 100 | // a file cannot be copied to itself 101 | throw new Error(`'${newDest}' and '${source}' are the same file`); 102 | } 103 | yield copyFile(source, newDest, force); 104 | } 105 | }); 106 | } 107 | exports.cp = cp; 108 | /** 109 | * Moves a path. 110 | * 111 | * @param source source path 112 | * @param dest destination path 113 | * @param options optional. See MoveOptions. 114 | */ 115 | function mv(source, dest, options = {}) { 116 | return __awaiter(this, void 0, void 0, function* () { 117 | if (yield ioUtil.exists(dest)) { 118 | let destExists = true; 119 | if (yield ioUtil.isDirectory(dest)) { 120 | // If dest is directory copy src into dest 121 | dest = path.join(dest, path.basename(source)); 122 | destExists = yield ioUtil.exists(dest); 123 | } 124 | if (destExists) { 125 | if (options.force == null || options.force) { 126 | yield rmRF(dest); 127 | } 128 | else { 129 | throw new Error('Destination already exists'); 130 | } 131 | } 132 | } 133 | yield mkdirP(path.dirname(dest)); 134 | yield ioUtil.rename(source, dest); 135 | }); 136 | } 137 | exports.mv = mv; 138 | /** 139 | * Remove a path recursively with force 140 | * 141 | * @param inputPath path to remove 142 | */ 143 | function rmRF(inputPath) { 144 | return __awaiter(this, void 0, void 0, function* () { 145 | if (ioUtil.IS_WINDOWS) { 146 | // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another 147 | // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. 148 | try { 149 | if (yield ioUtil.isDirectory(inputPath, true)) { 150 | yield exec(`rd /s /q "${inputPath}"`); 151 | } 152 | else { 153 | yield exec(`del /f /a "${inputPath}"`); 154 | } 155 | } 156 | catch (err) { 157 | // if you try to delete a file that doesn't exist, desired result is achieved 158 | // other errors are valid 159 | if (err.code !== 'ENOENT') 160 | throw err; 161 | } 162 | // Shelling out fails to remove a symlink folder with missing source, this unlink catches that 163 | try { 164 | yield ioUtil.unlink(inputPath); 165 | } 166 | catch (err) { 167 | // if you try to delete a file that doesn't exist, desired result is achieved 168 | // other errors are valid 169 | if (err.code !== 'ENOENT') 170 | throw err; 171 | } 172 | } 173 | else { 174 | let isDir = false; 175 | try { 176 | isDir = yield ioUtil.isDirectory(inputPath); 177 | } 178 | catch (err) { 179 | // if you try to delete a file that doesn't exist, desired result is achieved 180 | // other errors are valid 181 | if (err.code !== 'ENOENT') 182 | throw err; 183 | return; 184 | } 185 | if (isDir) { 186 | yield exec(`rm -rf "${inputPath}"`); 187 | } 188 | else { 189 | yield ioUtil.unlink(inputPath); 190 | } 191 | } 192 | }); 193 | } 194 | exports.rmRF = rmRF; 195 | /** 196 | * Make a directory. Creates the full path with folders in between 197 | * Will throw if it fails 198 | * 199 | * @param fsPath path to create 200 | * @returns Promise 201 | */ 202 | function mkdirP(fsPath) { 203 | return __awaiter(this, void 0, void 0, function* () { 204 | yield ioUtil.mkdirP(fsPath); 205 | }); 206 | } 207 | exports.mkdirP = mkdirP; 208 | /** 209 | * Returns path of a tool had the tool actually been invoked. Resolves via paths. 210 | * If you check and the tool does not exist, it will throw. 211 | * 212 | * @param tool name of the tool 213 | * @param check whether to check if tool exists 214 | * @returns Promise path to tool 215 | */ 216 | function which(tool, check) { 217 | return __awaiter(this, void 0, void 0, function* () { 218 | if (!tool) { 219 | throw new Error("parameter 'tool' is required"); 220 | } 221 | // recursive when check=true 222 | if (check) { 223 | const result = yield which(tool, false); 224 | if (!result) { 225 | if (ioUtil.IS_WINDOWS) { 226 | throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`); 227 | } 228 | else { 229 | throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`); 230 | } 231 | } 232 | } 233 | try { 234 | // build the list of extensions to try 235 | const extensions = []; 236 | if (ioUtil.IS_WINDOWS && process.env.PATHEXT) { 237 | for (const extension of process.env.PATHEXT.split(path.delimiter)) { 238 | if (extension) { 239 | extensions.push(extension); 240 | } 241 | } 242 | } 243 | // if it's rooted, return it if exists. otherwise return empty. 244 | if (ioUtil.isRooted(tool)) { 245 | const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions); 246 | if (filePath) { 247 | return filePath; 248 | } 249 | return ''; 250 | } 251 | // if any path separators, return empty 252 | if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) { 253 | return ''; 254 | } 255 | // build the list of directories 256 | // 257 | // Note, technically "where" checks the current directory on Windows. From a toolkit perspective, 258 | // it feels like we should not do this. Checking the current directory seems like more of a use 259 | // case of a shell, and the which() function exposed by the toolkit should strive for consistency 260 | // across platforms. 261 | const directories = []; 262 | if (process.env.PATH) { 263 | for (const p of process.env.PATH.split(path.delimiter)) { 264 | if (p) { 265 | directories.push(p); 266 | } 267 | } 268 | } 269 | // return the first match 270 | for (const directory of directories) { 271 | const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions); 272 | if (filePath) { 273 | return filePath; 274 | } 275 | } 276 | return ''; 277 | } 278 | catch (err) { 279 | throw new Error(`which failed with message ${err.message}`); 280 | } 281 | }); 282 | } 283 | exports.which = which; 284 | function readCopyOptions(options) { 285 | const force = options.force == null ? true : options.force; 286 | const recursive = Boolean(options.recursive); 287 | return { force, recursive }; 288 | } 289 | function cpDirRecursive(sourceDir, destDir, currentDepth, force) { 290 | return __awaiter(this, void 0, void 0, function* () { 291 | // Ensure there is not a run away recursive copy 292 | if (currentDepth >= 255) 293 | return; 294 | currentDepth++; 295 | yield mkdirP(destDir); 296 | const files = yield ioUtil.readdir(sourceDir); 297 | for (const fileName of files) { 298 | const srcFile = `${sourceDir}/${fileName}`; 299 | const destFile = `${destDir}/${fileName}`; 300 | const srcFileStat = yield ioUtil.lstat(srcFile); 301 | if (srcFileStat.isDirectory()) { 302 | // Recurse 303 | yield cpDirRecursive(srcFile, destFile, currentDepth, force); 304 | } 305 | else { 306 | yield copyFile(srcFile, destFile, force); 307 | } 308 | } 309 | // Change the mode for the newly created directory 310 | yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode); 311 | }); 312 | } 313 | // Buffered file copy 314 | function copyFile(srcFile, destFile, force) { 315 | return __awaiter(this, void 0, void 0, function* () { 316 | if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) { 317 | // unlink/re-link it 318 | try { 319 | yield ioUtil.lstat(destFile); 320 | yield ioUtil.unlink(destFile); 321 | } 322 | catch (e) { 323 | // Try to override file permission 324 | if (e.code === 'EPERM') { 325 | yield ioUtil.chmod(destFile, '0666'); 326 | yield ioUtil.unlink(destFile); 327 | } 328 | // other errors = it doesn't exist, no work to do 329 | } 330 | // Copy over symlink 331 | const symlinkFull = yield ioUtil.readlink(srcFile); 332 | yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null); 333 | } 334 | else if (!(yield ioUtil.exists(destFile)) || force) { 335 | yield ioUtil.copyFile(srcFile, destFile); 336 | } 337 | }); 338 | } 339 | //# sourceMappingURL=io.js.map 340 | 341 | /***/ }), 342 | 343 | /***/ 4: 344 | /***/ (function(__unusedmodule, exports) { 345 | 346 | "use strict"; 347 | 348 | 349 | Object.defineProperty(exports, "__esModule", { 350 | value: true 351 | }); 352 | exports.default = void 0; 353 | var _default = '00000000-0000-0000-0000-000000000000'; 354 | exports.default = _default; 355 | 356 | /***/ }), 357 | 358 | /***/ 9: 359 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 360 | 361 | "use strict"; 362 | 363 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 364 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 365 | return new (P || (P = Promise))(function (resolve, reject) { 366 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 367 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 368 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 369 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 370 | }); 371 | }; 372 | Object.defineProperty(exports, "__esModule", { value: true }); 373 | const os = __webpack_require__(87); 374 | const events = __webpack_require__(614); 375 | const child = __webpack_require__(129); 376 | const path = __webpack_require__(622); 377 | const io = __webpack_require__(1); 378 | const ioUtil = __webpack_require__(672); 379 | /* eslint-disable @typescript-eslint/unbound-method */ 380 | const IS_WINDOWS = process.platform === 'win32'; 381 | /* 382 | * Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way. 383 | */ 384 | class ToolRunner extends events.EventEmitter { 385 | constructor(toolPath, args, options) { 386 | super(); 387 | if (!toolPath) { 388 | throw new Error("Parameter 'toolPath' cannot be null or empty."); 389 | } 390 | this.toolPath = toolPath; 391 | this.args = args || []; 392 | this.options = options || {}; 393 | } 394 | _debug(message) { 395 | if (this.options.listeners && this.options.listeners.debug) { 396 | this.options.listeners.debug(message); 397 | } 398 | } 399 | _getCommandString(options, noPrefix) { 400 | const toolPath = this._getSpawnFileName(); 401 | const args = this._getSpawnArgs(options); 402 | let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool 403 | if (IS_WINDOWS) { 404 | // Windows + cmd file 405 | if (this._isCmdFile()) { 406 | cmd += toolPath; 407 | for (const a of args) { 408 | cmd += ` ${a}`; 409 | } 410 | } 411 | // Windows + verbatim 412 | else if (options.windowsVerbatimArguments) { 413 | cmd += `"${toolPath}"`; 414 | for (const a of args) { 415 | cmd += ` ${a}`; 416 | } 417 | } 418 | // Windows (regular) 419 | else { 420 | cmd += this._windowsQuoteCmdArg(toolPath); 421 | for (const a of args) { 422 | cmd += ` ${this._windowsQuoteCmdArg(a)}`; 423 | } 424 | } 425 | } 426 | else { 427 | // OSX/Linux - this can likely be improved with some form of quoting. 428 | // creating processes on Unix is fundamentally different than Windows. 429 | // on Unix, execvp() takes an arg array. 430 | cmd += toolPath; 431 | for (const a of args) { 432 | cmd += ` ${a}`; 433 | } 434 | } 435 | return cmd; 436 | } 437 | _processLineBuffer(data, strBuffer, onLine) { 438 | try { 439 | let s = strBuffer + data.toString(); 440 | let n = s.indexOf(os.EOL); 441 | while (n > -1) { 442 | const line = s.substring(0, n); 443 | onLine(line); 444 | // the rest of the string ... 445 | s = s.substring(n + os.EOL.length); 446 | n = s.indexOf(os.EOL); 447 | } 448 | strBuffer = s; 449 | } 450 | catch (err) { 451 | // streaming lines to console is best effort. Don't fail a build. 452 | this._debug(`error processing line. Failed with error ${err}`); 453 | } 454 | } 455 | _getSpawnFileName() { 456 | if (IS_WINDOWS) { 457 | if (this._isCmdFile()) { 458 | return process.env['COMSPEC'] || 'cmd.exe'; 459 | } 460 | } 461 | return this.toolPath; 462 | } 463 | _getSpawnArgs(options) { 464 | if (IS_WINDOWS) { 465 | if (this._isCmdFile()) { 466 | let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`; 467 | for (const a of this.args) { 468 | argline += ' '; 469 | argline += options.windowsVerbatimArguments 470 | ? a 471 | : this._windowsQuoteCmdArg(a); 472 | } 473 | argline += '"'; 474 | return [argline]; 475 | } 476 | } 477 | return this.args; 478 | } 479 | _endsWith(str, end) { 480 | return str.endsWith(end); 481 | } 482 | _isCmdFile() { 483 | const upperToolPath = this.toolPath.toUpperCase(); 484 | return (this._endsWith(upperToolPath, '.CMD') || 485 | this._endsWith(upperToolPath, '.BAT')); 486 | } 487 | _windowsQuoteCmdArg(arg) { 488 | // for .exe, apply the normal quoting rules that libuv applies 489 | if (!this._isCmdFile()) { 490 | return this._uvQuoteCmdArg(arg); 491 | } 492 | // otherwise apply quoting rules specific to the cmd.exe command line parser. 493 | // the libuv rules are generic and are not designed specifically for cmd.exe 494 | // command line parser. 495 | // 496 | // for a detailed description of the cmd.exe command line parser, refer to 497 | // http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912 498 | // need quotes for empty arg 499 | if (!arg) { 500 | return '""'; 501 | } 502 | // determine whether the arg needs to be quoted 503 | const cmdSpecialChars = [ 504 | ' ', 505 | '\t', 506 | '&', 507 | '(', 508 | ')', 509 | '[', 510 | ']', 511 | '{', 512 | '}', 513 | '^', 514 | '=', 515 | ';', 516 | '!', 517 | "'", 518 | '+', 519 | ',', 520 | '`', 521 | '~', 522 | '|', 523 | '<', 524 | '>', 525 | '"' 526 | ]; 527 | let needsQuotes = false; 528 | for (const char of arg) { 529 | if (cmdSpecialChars.some(x => x === char)) { 530 | needsQuotes = true; 531 | break; 532 | } 533 | } 534 | // short-circuit if quotes not needed 535 | if (!needsQuotes) { 536 | return arg; 537 | } 538 | // the following quoting rules are very similar to the rules that by libuv applies. 539 | // 540 | // 1) wrap the string in quotes 541 | // 542 | // 2) double-up quotes - i.e. " => "" 543 | // 544 | // this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately 545 | // doesn't work well with a cmd.exe command line. 546 | // 547 | // note, replacing " with "" also works well if the arg is passed to a downstream .NET console app. 548 | // for example, the command line: 549 | // foo.exe "myarg:""my val""" 550 | // is parsed by a .NET console app into an arg array: 551 | // [ "myarg:\"my val\"" ] 552 | // which is the same end result when applying libuv quoting rules. although the actual 553 | // command line from libuv quoting rules would look like: 554 | // foo.exe "myarg:\"my val\"" 555 | // 556 | // 3) double-up slashes that precede a quote, 557 | // e.g. hello \world => "hello \world" 558 | // hello\"world => "hello\\""world" 559 | // hello\\"world => "hello\\\\""world" 560 | // hello world\ => "hello world\\" 561 | // 562 | // technically this is not required for a cmd.exe command line, or the batch argument parser. 563 | // the reasons for including this as a .cmd quoting rule are: 564 | // 565 | // a) this is optimized for the scenario where the argument is passed from the .cmd file to an 566 | // external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule. 567 | // 568 | // b) it's what we've been doing previously (by deferring to node default behavior) and we 569 | // haven't heard any complaints about that aspect. 570 | // 571 | // note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be 572 | // escaped when used on the command line directly - even though within a .cmd file % can be escaped 573 | // by using %%. 574 | // 575 | // the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts 576 | // the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing. 577 | // 578 | // one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would 579 | // often work, since it is unlikely that var^ would exist, and the ^ character is removed when the 580 | // variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args 581 | // to an external program. 582 | // 583 | // an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file. 584 | // % can be escaped within a .cmd file. 585 | let reverse = '"'; 586 | let quoteHit = true; 587 | for (let i = arg.length; i > 0; i--) { 588 | // walk the string in reverse 589 | reverse += arg[i - 1]; 590 | if (quoteHit && arg[i - 1] === '\\') { 591 | reverse += '\\'; // double the slash 592 | } 593 | else if (arg[i - 1] === '"') { 594 | quoteHit = true; 595 | reverse += '"'; // double the quote 596 | } 597 | else { 598 | quoteHit = false; 599 | } 600 | } 601 | reverse += '"'; 602 | return reverse 603 | .split('') 604 | .reverse() 605 | .join(''); 606 | } 607 | _uvQuoteCmdArg(arg) { 608 | // Tool runner wraps child_process.spawn() and needs to apply the same quoting as 609 | // Node in certain cases where the undocumented spawn option windowsVerbatimArguments 610 | // is used. 611 | // 612 | // Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV, 613 | // see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details), 614 | // pasting copyright notice from Node within this function: 615 | // 616 | // Copyright Joyent, Inc. and other Node contributors. All rights reserved. 617 | // 618 | // Permission is hereby granted, free of charge, to any person obtaining a copy 619 | // of this software and associated documentation files (the "Software"), to 620 | // deal in the Software without restriction, including without limitation the 621 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 622 | // sell copies of the Software, and to permit persons to whom the Software is 623 | // furnished to do so, subject to the following conditions: 624 | // 625 | // The above copyright notice and this permission notice shall be included in 626 | // all copies or substantial portions of the Software. 627 | // 628 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 629 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 630 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 631 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 632 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 633 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 634 | // IN THE SOFTWARE. 635 | if (!arg) { 636 | // Need double quotation for empty argument 637 | return '""'; 638 | } 639 | if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) { 640 | // No quotation needed 641 | return arg; 642 | } 643 | if (!arg.includes('"') && !arg.includes('\\')) { 644 | // No embedded double quotes or backslashes, so I can just wrap 645 | // quote marks around the whole thing. 646 | return `"${arg}"`; 647 | } 648 | // Expected input/output: 649 | // input : hello"world 650 | // output: "hello\"world" 651 | // input : hello""world 652 | // output: "hello\"\"world" 653 | // input : hello\world 654 | // output: hello\world 655 | // input : hello\\world 656 | // output: hello\\world 657 | // input : hello\"world 658 | // output: "hello\\\"world" 659 | // input : hello\\"world 660 | // output: "hello\\\\\"world" 661 | // input : hello world\ 662 | // output: "hello world\\" - note the comment in libuv actually reads "hello world\" 663 | // but it appears the comment is wrong, it should be "hello world\\" 664 | let reverse = '"'; 665 | let quoteHit = true; 666 | for (let i = arg.length; i > 0; i--) { 667 | // walk the string in reverse 668 | reverse += arg[i - 1]; 669 | if (quoteHit && arg[i - 1] === '\\') { 670 | reverse += '\\'; 671 | } 672 | else if (arg[i - 1] === '"') { 673 | quoteHit = true; 674 | reverse += '\\'; 675 | } 676 | else { 677 | quoteHit = false; 678 | } 679 | } 680 | reverse += '"'; 681 | return reverse 682 | .split('') 683 | .reverse() 684 | .join(''); 685 | } 686 | _cloneExecOptions(options) { 687 | options = options || {}; 688 | const result = { 689 | cwd: options.cwd || process.cwd(), 690 | env: options.env || process.env, 691 | silent: options.silent || false, 692 | windowsVerbatimArguments: options.windowsVerbatimArguments || false, 693 | failOnStdErr: options.failOnStdErr || false, 694 | ignoreReturnCode: options.ignoreReturnCode || false, 695 | delay: options.delay || 10000 696 | }; 697 | result.outStream = options.outStream || process.stdout; 698 | result.errStream = options.errStream || process.stderr; 699 | return result; 700 | } 701 | _getSpawnOptions(options, toolPath) { 702 | options = options || {}; 703 | const result = {}; 704 | result.cwd = options.cwd; 705 | result.env = options.env; 706 | result['windowsVerbatimArguments'] = 707 | options.windowsVerbatimArguments || this._isCmdFile(); 708 | if (options.windowsVerbatimArguments) { 709 | result.argv0 = `"${toolPath}"`; 710 | } 711 | return result; 712 | } 713 | /** 714 | * Exec a tool. 715 | * Output will be streamed to the live console. 716 | * Returns promise with return code 717 | * 718 | * @param tool path to tool to exec 719 | * @param options optional exec options. See ExecOptions 720 | * @returns number 721 | */ 722 | exec() { 723 | return __awaiter(this, void 0, void 0, function* () { 724 | // root the tool path if it is unrooted and contains relative pathing 725 | if (!ioUtil.isRooted(this.toolPath) && 726 | (this.toolPath.includes('/') || 727 | (IS_WINDOWS && this.toolPath.includes('\\')))) { 728 | // prefer options.cwd if it is specified, however options.cwd may also need to be rooted 729 | this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); 730 | } 731 | // if the tool is only a file name, then resolve it from the PATH 732 | // otherwise verify it exists (add extension on Windows if necessary) 733 | this.toolPath = yield io.which(this.toolPath, true); 734 | return new Promise((resolve, reject) => { 735 | this._debug(`exec tool: ${this.toolPath}`); 736 | this._debug('arguments:'); 737 | for (const arg of this.args) { 738 | this._debug(` ${arg}`); 739 | } 740 | const optionsNonNull = this._cloneExecOptions(this.options); 741 | if (!optionsNonNull.silent && optionsNonNull.outStream) { 742 | optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL); 743 | } 744 | const state = new ExecState(optionsNonNull, this.toolPath); 745 | state.on('debug', (message) => { 746 | this._debug(message); 747 | }); 748 | const fileName = this._getSpawnFileName(); 749 | const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); 750 | const stdbuffer = ''; 751 | if (cp.stdout) { 752 | cp.stdout.on('data', (data) => { 753 | if (this.options.listeners && this.options.listeners.stdout) { 754 | this.options.listeners.stdout(data); 755 | } 756 | if (!optionsNonNull.silent && optionsNonNull.outStream) { 757 | optionsNonNull.outStream.write(data); 758 | } 759 | this._processLineBuffer(data, stdbuffer, (line) => { 760 | if (this.options.listeners && this.options.listeners.stdline) { 761 | this.options.listeners.stdline(line); 762 | } 763 | }); 764 | }); 765 | } 766 | const errbuffer = ''; 767 | if (cp.stderr) { 768 | cp.stderr.on('data', (data) => { 769 | state.processStderr = true; 770 | if (this.options.listeners && this.options.listeners.stderr) { 771 | this.options.listeners.stderr(data); 772 | } 773 | if (!optionsNonNull.silent && 774 | optionsNonNull.errStream && 775 | optionsNonNull.outStream) { 776 | const s = optionsNonNull.failOnStdErr 777 | ? optionsNonNull.errStream 778 | : optionsNonNull.outStream; 779 | s.write(data); 780 | } 781 | this._processLineBuffer(data, errbuffer, (line) => { 782 | if (this.options.listeners && this.options.listeners.errline) { 783 | this.options.listeners.errline(line); 784 | } 785 | }); 786 | }); 787 | } 788 | cp.on('error', (err) => { 789 | state.processError = err.message; 790 | state.processExited = true; 791 | state.processClosed = true; 792 | state.CheckComplete(); 793 | }); 794 | cp.on('exit', (code) => { 795 | state.processExitCode = code; 796 | state.processExited = true; 797 | this._debug(`Exit code ${code} received from tool '${this.toolPath}'`); 798 | state.CheckComplete(); 799 | }); 800 | cp.on('close', (code) => { 801 | state.processExitCode = code; 802 | state.processExited = true; 803 | state.processClosed = true; 804 | this._debug(`STDIO streams have closed for tool '${this.toolPath}'`); 805 | state.CheckComplete(); 806 | }); 807 | state.on('done', (error, exitCode) => { 808 | if (stdbuffer.length > 0) { 809 | this.emit('stdline', stdbuffer); 810 | } 811 | if (errbuffer.length > 0) { 812 | this.emit('errline', errbuffer); 813 | } 814 | cp.removeAllListeners(); 815 | if (error) { 816 | reject(error); 817 | } 818 | else { 819 | resolve(exitCode); 820 | } 821 | }); 822 | }); 823 | }); 824 | } 825 | } 826 | exports.ToolRunner = ToolRunner; 827 | /** 828 | * Convert an arg string to an array of args. Handles escaping 829 | * 830 | * @param argString string of arguments 831 | * @returns string[] array of arguments 832 | */ 833 | function argStringToArray(argString) { 834 | const args = []; 835 | let inQuotes = false; 836 | let escaped = false; 837 | let arg = ''; 838 | function append(c) { 839 | // we only escape double quotes. 840 | if (escaped && c !== '"') { 841 | arg += '\\'; 842 | } 843 | arg += c; 844 | escaped = false; 845 | } 846 | for (let i = 0; i < argString.length; i++) { 847 | const c = argString.charAt(i); 848 | if (c === '"') { 849 | if (!escaped) { 850 | inQuotes = !inQuotes; 851 | } 852 | else { 853 | append(c); 854 | } 855 | continue; 856 | } 857 | if (c === '\\' && escaped) { 858 | append(c); 859 | continue; 860 | } 861 | if (c === '\\' && inQuotes) { 862 | escaped = true; 863 | continue; 864 | } 865 | if (c === ' ' && !inQuotes) { 866 | if (arg.length > 0) { 867 | args.push(arg); 868 | arg = ''; 869 | } 870 | continue; 871 | } 872 | append(c); 873 | } 874 | if (arg.length > 0) { 875 | args.push(arg.trim()); 876 | } 877 | return args; 878 | } 879 | exports.argStringToArray = argStringToArray; 880 | class ExecState extends events.EventEmitter { 881 | constructor(options, toolPath) { 882 | super(); 883 | this.processClosed = false; // tracks whether the process has exited and stdio is closed 884 | this.processError = ''; 885 | this.processExitCode = 0; 886 | this.processExited = false; // tracks whether the process has exited 887 | this.processStderr = false; // tracks whether stderr was written to 888 | this.delay = 10000; // 10 seconds 889 | this.done = false; 890 | this.timeout = null; 891 | if (!toolPath) { 892 | throw new Error('toolPath must not be empty'); 893 | } 894 | this.options = options; 895 | this.toolPath = toolPath; 896 | if (options.delay) { 897 | this.delay = options.delay; 898 | } 899 | } 900 | CheckComplete() { 901 | if (this.done) { 902 | return; 903 | } 904 | if (this.processClosed) { 905 | this._setResult(); 906 | } 907 | else if (this.processExited) { 908 | this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this); 909 | } 910 | } 911 | _debug(message) { 912 | this.emit('debug', message); 913 | } 914 | _setResult() { 915 | // determine whether there is an error 916 | let error; 917 | if (this.processExited) { 918 | if (this.processError) { 919 | error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`); 920 | } 921 | else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) { 922 | error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`); 923 | } 924 | else if (this.processStderr && this.options.failOnStdErr) { 925 | error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`); 926 | } 927 | } 928 | // clear the timeout 929 | if (this.timeout) { 930 | clearTimeout(this.timeout); 931 | this.timeout = null; 932 | } 933 | this.done = true; 934 | this.emit('done', error, this.processExitCode); 935 | } 936 | static HandleTimeout(state) { 937 | if (state.done) { 938 | return; 939 | } 940 | if (!state.processClosed && state.processExited) { 941 | const message = `The STDIO streams did not close within ${state.delay / 942 | 1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`; 943 | state._debug(message); 944 | } 945 | state._setResult(); 946 | } 947 | } 948 | //# sourceMappingURL=toolrunner.js.map 949 | 950 | /***/ }), 951 | 952 | /***/ 16: 953 | /***/ (function(module) { 954 | 955 | module.exports = require("tls"); 956 | 957 | /***/ }), 958 | 959 | /***/ 25: 960 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 961 | 962 | "use strict"; 963 | 964 | 965 | Object.defineProperty(exports, "__esModule", { 966 | value: true 967 | }); 968 | Object.defineProperty(exports, "v1", { 969 | enumerable: true, 970 | get: function () { 971 | return _v.default; 972 | } 973 | }); 974 | Object.defineProperty(exports, "v3", { 975 | enumerable: true, 976 | get: function () { 977 | return _v2.default; 978 | } 979 | }); 980 | Object.defineProperty(exports, "v4", { 981 | enumerable: true, 982 | get: function () { 983 | return _v3.default; 984 | } 985 | }); 986 | Object.defineProperty(exports, "v5", { 987 | enumerable: true, 988 | get: function () { 989 | return _v4.default; 990 | } 991 | }); 992 | Object.defineProperty(exports, "NIL", { 993 | enumerable: true, 994 | get: function () { 995 | return _nil.default; 996 | } 997 | }); 998 | Object.defineProperty(exports, "version", { 999 | enumerable: true, 1000 | get: function () { 1001 | return _version.default; 1002 | } 1003 | }); 1004 | Object.defineProperty(exports, "validate", { 1005 | enumerable: true, 1006 | get: function () { 1007 | return _validate.default; 1008 | } 1009 | }); 1010 | Object.defineProperty(exports, "stringify", { 1011 | enumerable: true, 1012 | get: function () { 1013 | return _stringify.default; 1014 | } 1015 | }); 1016 | Object.defineProperty(exports, "parse", { 1017 | enumerable: true, 1018 | get: function () { 1019 | return _parse.default; 1020 | } 1021 | }); 1022 | 1023 | var _v = _interopRequireDefault(__webpack_require__(810)); 1024 | 1025 | var _v2 = _interopRequireDefault(__webpack_require__(572)); 1026 | 1027 | var _v3 = _interopRequireDefault(__webpack_require__(293)); 1028 | 1029 | var _v4 = _interopRequireDefault(__webpack_require__(638)); 1030 | 1031 | var _nil = _interopRequireDefault(__webpack_require__(4)); 1032 | 1033 | var _version = _interopRequireDefault(__webpack_require__(135)); 1034 | 1035 | var _validate = _interopRequireDefault(__webpack_require__(634)); 1036 | 1037 | var _stringify = _interopRequireDefault(__webpack_require__(960)); 1038 | 1039 | var _parse = _interopRequireDefault(__webpack_require__(204)); 1040 | 1041 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1042 | 1043 | /***/ }), 1044 | 1045 | /***/ 82: 1046 | /***/ (function(__unusedmodule, exports) { 1047 | 1048 | "use strict"; 1049 | 1050 | // We use any as a valid input type 1051 | /* eslint-disable @typescript-eslint/no-explicit-any */ 1052 | Object.defineProperty(exports, "__esModule", { value: true }); 1053 | exports.toCommandProperties = exports.toCommandValue = void 0; 1054 | /** 1055 | * Sanitizes an input into a string so it can be passed into issueCommand safely 1056 | * @param input input to sanitize into a string 1057 | */ 1058 | function toCommandValue(input) { 1059 | if (input === null || input === undefined) { 1060 | return ''; 1061 | } 1062 | else if (typeof input === 'string' || input instanceof String) { 1063 | return input; 1064 | } 1065 | return JSON.stringify(input); 1066 | } 1067 | exports.toCommandValue = toCommandValue; 1068 | /** 1069 | * 1070 | * @param annotationProperties 1071 | * @returns The command properties to send with the actual annotation command 1072 | * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646 1073 | */ 1074 | function toCommandProperties(annotationProperties) { 1075 | if (!Object.keys(annotationProperties).length) { 1076 | return {}; 1077 | } 1078 | return { 1079 | title: annotationProperties.title, 1080 | file: annotationProperties.file, 1081 | line: annotationProperties.startLine, 1082 | endLine: annotationProperties.endLine, 1083 | col: annotationProperties.startColumn, 1084 | endColumn: annotationProperties.endColumn 1085 | }; 1086 | } 1087 | exports.toCommandProperties = toCommandProperties; 1088 | //# sourceMappingURL=utils.js.map 1089 | 1090 | /***/ }), 1091 | 1092 | /***/ 87: 1093 | /***/ (function(module) { 1094 | 1095 | module.exports = require("os"); 1096 | 1097 | /***/ }), 1098 | 1099 | /***/ 95: 1100 | /***/ (function(__unusedmodule, exports) { 1101 | 1102 | "use strict"; 1103 | 1104 | Object.defineProperty(exports, "__esModule", { value: true }); 1105 | exports.checkBypass = exports.getProxyUrl = void 0; 1106 | function getProxyUrl(reqUrl) { 1107 | const usingSsl = reqUrl.protocol === 'https:'; 1108 | if (checkBypass(reqUrl)) { 1109 | return undefined; 1110 | } 1111 | const proxyVar = (() => { 1112 | if (usingSsl) { 1113 | return process.env['https_proxy'] || process.env['HTTPS_PROXY']; 1114 | } 1115 | else { 1116 | return process.env['http_proxy'] || process.env['HTTP_PROXY']; 1117 | } 1118 | })(); 1119 | if (proxyVar) { 1120 | return new URL(proxyVar); 1121 | } 1122 | else { 1123 | return undefined; 1124 | } 1125 | } 1126 | exports.getProxyUrl = getProxyUrl; 1127 | function checkBypass(reqUrl) { 1128 | if (!reqUrl.hostname) { 1129 | return false; 1130 | } 1131 | const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; 1132 | if (!noProxy) { 1133 | return false; 1134 | } 1135 | // Determine the request port 1136 | let reqPort; 1137 | if (reqUrl.port) { 1138 | reqPort = Number(reqUrl.port); 1139 | } 1140 | else if (reqUrl.protocol === 'http:') { 1141 | reqPort = 80; 1142 | } 1143 | else if (reqUrl.protocol === 'https:') { 1144 | reqPort = 443; 1145 | } 1146 | // Format the request hostname and hostname with port 1147 | const upperReqHosts = [reqUrl.hostname.toUpperCase()]; 1148 | if (typeof reqPort === 'number') { 1149 | upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); 1150 | } 1151 | // Compare request host against noproxy 1152 | for (const upperNoProxyItem of noProxy 1153 | .split(',') 1154 | .map(x => x.trim().toUpperCase()) 1155 | .filter(x => x)) { 1156 | if (upperReqHosts.some(x => x === upperNoProxyItem)) { 1157 | return true; 1158 | } 1159 | } 1160 | return false; 1161 | } 1162 | exports.checkBypass = checkBypass; 1163 | //# sourceMappingURL=proxy.js.map 1164 | 1165 | /***/ }), 1166 | 1167 | /***/ 102: 1168 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1169 | 1170 | "use strict"; 1171 | 1172 | // For internal use, subject to change. 1173 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 1174 | if (k2 === undefined) k2 = k; 1175 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 1176 | }) : (function(o, m, k, k2) { 1177 | if (k2 === undefined) k2 = k; 1178 | o[k2] = m[k]; 1179 | })); 1180 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 1181 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 1182 | }) : function(o, v) { 1183 | o["default"] = v; 1184 | }); 1185 | var __importStar = (this && this.__importStar) || function (mod) { 1186 | if (mod && mod.__esModule) return mod; 1187 | var result = {}; 1188 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 1189 | __setModuleDefault(result, mod); 1190 | return result; 1191 | }; 1192 | Object.defineProperty(exports, "__esModule", { value: true }); 1193 | exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; 1194 | // We use any as a valid input type 1195 | /* eslint-disable @typescript-eslint/no-explicit-any */ 1196 | const fs = __importStar(__webpack_require__(747)); 1197 | const os = __importStar(__webpack_require__(87)); 1198 | const uuid_1 = __webpack_require__(25); 1199 | const utils_1 = __webpack_require__(82); 1200 | function issueFileCommand(command, message) { 1201 | const filePath = process.env[`GITHUB_${command}`]; 1202 | if (!filePath) { 1203 | throw new Error(`Unable to find environment variable for file command ${command}`); 1204 | } 1205 | if (!fs.existsSync(filePath)) { 1206 | throw new Error(`Missing file at path: ${filePath}`); 1207 | } 1208 | fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { 1209 | encoding: 'utf8' 1210 | }); 1211 | } 1212 | exports.issueFileCommand = issueFileCommand; 1213 | function prepareKeyValueMessage(key, value) { 1214 | const delimiter = `ghadelimiter_${uuid_1.v4()}`; 1215 | const convertedValue = utils_1.toCommandValue(value); 1216 | // These should realistically never happen, but just in case someone finds a 1217 | // way to exploit uuid generation let's not allow keys or values that contain 1218 | // the delimiter. 1219 | if (key.includes(delimiter)) { 1220 | throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); 1221 | } 1222 | if (convertedValue.includes(delimiter)) { 1223 | throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); 1224 | } 1225 | return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; 1226 | } 1227 | exports.prepareKeyValueMessage = prepareKeyValueMessage; 1228 | //# sourceMappingURL=file-command.js.map 1229 | 1230 | /***/ }), 1231 | 1232 | /***/ 129: 1233 | /***/ (function(module) { 1234 | 1235 | module.exports = require("child_process"); 1236 | 1237 | /***/ }), 1238 | 1239 | /***/ 135: 1240 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1241 | 1242 | "use strict"; 1243 | 1244 | 1245 | Object.defineProperty(exports, "__esModule", { 1246 | value: true 1247 | }); 1248 | exports.default = void 0; 1249 | 1250 | var _validate = _interopRequireDefault(__webpack_require__(634)); 1251 | 1252 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1253 | 1254 | function version(uuid) { 1255 | if (!(0, _validate.default)(uuid)) { 1256 | throw TypeError('Invalid UUID'); 1257 | } 1258 | 1259 | return parseInt(uuid.substr(14, 1), 16); 1260 | } 1261 | 1262 | var _default = version; 1263 | exports.default = _default; 1264 | 1265 | /***/ }), 1266 | 1267 | /***/ 136: 1268 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1269 | 1270 | "use strict"; 1271 | 1272 | 1273 | Object.defineProperty(exports, "__esModule", { 1274 | value: true 1275 | }); 1276 | exports.default = _default; 1277 | exports.URL = exports.DNS = void 0; 1278 | 1279 | var _stringify = _interopRequireDefault(__webpack_require__(960)); 1280 | 1281 | var _parse = _interopRequireDefault(__webpack_require__(204)); 1282 | 1283 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1284 | 1285 | function stringToBytes(str) { 1286 | str = unescape(encodeURIComponent(str)); // UTF8 escape 1287 | 1288 | const bytes = []; 1289 | 1290 | for (let i = 0; i < str.length; ++i) { 1291 | bytes.push(str.charCodeAt(i)); 1292 | } 1293 | 1294 | return bytes; 1295 | } 1296 | 1297 | const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; 1298 | exports.DNS = DNS; 1299 | const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; 1300 | exports.URL = URL; 1301 | 1302 | function _default(name, version, hashfunc) { 1303 | function generateUUID(value, namespace, buf, offset) { 1304 | if (typeof value === 'string') { 1305 | value = stringToBytes(value); 1306 | } 1307 | 1308 | if (typeof namespace === 'string') { 1309 | namespace = (0, _parse.default)(namespace); 1310 | } 1311 | 1312 | if (namespace.length !== 16) { 1313 | throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); 1314 | } // Compute hash of namespace and value, Per 4.3 1315 | // Future: Use spread syntax when supported on all platforms, e.g. `bytes = 1316 | // hashfunc([...namespace, ... value])` 1317 | 1318 | 1319 | let bytes = new Uint8Array(16 + value.length); 1320 | bytes.set(namespace); 1321 | bytes.set(value, namespace.length); 1322 | bytes = hashfunc(bytes); 1323 | bytes[6] = bytes[6] & 0x0f | version; 1324 | bytes[8] = bytes[8] & 0x3f | 0x80; 1325 | 1326 | if (buf) { 1327 | offset = offset || 0; 1328 | 1329 | for (let i = 0; i < 16; ++i) { 1330 | buf[offset + i] = bytes[i]; 1331 | } 1332 | 1333 | return buf; 1334 | } 1335 | 1336 | return (0, _stringify.default)(bytes); 1337 | } // Function#name is not settable on some platforms (#270) 1338 | 1339 | 1340 | try { 1341 | generateUUID.name = name; // eslint-disable-next-line no-empty 1342 | } catch (err) {} // For CommonJS default export support 1343 | 1344 | 1345 | generateUUID.DNS = DNS; 1346 | generateUUID.URL = URL; 1347 | return generateUUID; 1348 | } 1349 | 1350 | /***/ }), 1351 | 1352 | /***/ 141: 1353 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1354 | 1355 | "use strict"; 1356 | 1357 | 1358 | var net = __webpack_require__(631); 1359 | var tls = __webpack_require__(16); 1360 | var http = __webpack_require__(605); 1361 | var https = __webpack_require__(211); 1362 | var events = __webpack_require__(614); 1363 | var assert = __webpack_require__(357); 1364 | var util = __webpack_require__(669); 1365 | 1366 | 1367 | exports.httpOverHttp = httpOverHttp; 1368 | exports.httpsOverHttp = httpsOverHttp; 1369 | exports.httpOverHttps = httpOverHttps; 1370 | exports.httpsOverHttps = httpsOverHttps; 1371 | 1372 | 1373 | function httpOverHttp(options) { 1374 | var agent = new TunnelingAgent(options); 1375 | agent.request = http.request; 1376 | return agent; 1377 | } 1378 | 1379 | function httpsOverHttp(options) { 1380 | var agent = new TunnelingAgent(options); 1381 | agent.request = http.request; 1382 | agent.createSocket = createSecureSocket; 1383 | agent.defaultPort = 443; 1384 | return agent; 1385 | } 1386 | 1387 | function httpOverHttps(options) { 1388 | var agent = new TunnelingAgent(options); 1389 | agent.request = https.request; 1390 | return agent; 1391 | } 1392 | 1393 | function httpsOverHttps(options) { 1394 | var agent = new TunnelingAgent(options); 1395 | agent.request = https.request; 1396 | agent.createSocket = createSecureSocket; 1397 | agent.defaultPort = 443; 1398 | return agent; 1399 | } 1400 | 1401 | 1402 | function TunnelingAgent(options) { 1403 | var self = this; 1404 | self.options = options || {}; 1405 | self.proxyOptions = self.options.proxy || {}; 1406 | self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; 1407 | self.requests = []; 1408 | self.sockets = []; 1409 | 1410 | self.on('free', function onFree(socket, host, port, localAddress) { 1411 | var options = toOptions(host, port, localAddress); 1412 | for (var i = 0, len = self.requests.length; i < len; ++i) { 1413 | var pending = self.requests[i]; 1414 | if (pending.host === options.host && pending.port === options.port) { 1415 | // Detect the request to connect same origin server, 1416 | // reuse the connection. 1417 | self.requests.splice(i, 1); 1418 | pending.request.onSocket(socket); 1419 | return; 1420 | } 1421 | } 1422 | socket.destroy(); 1423 | self.removeSocket(socket); 1424 | }); 1425 | } 1426 | util.inherits(TunnelingAgent, events.EventEmitter); 1427 | 1428 | TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { 1429 | var self = this; 1430 | var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); 1431 | 1432 | if (self.sockets.length >= this.maxSockets) { 1433 | // We are over limit so we'll add it to the queue. 1434 | self.requests.push(options); 1435 | return; 1436 | } 1437 | 1438 | // If we are under maxSockets create a new one. 1439 | self.createSocket(options, function(socket) { 1440 | socket.on('free', onFree); 1441 | socket.on('close', onCloseOrRemove); 1442 | socket.on('agentRemove', onCloseOrRemove); 1443 | req.onSocket(socket); 1444 | 1445 | function onFree() { 1446 | self.emit('free', socket, options); 1447 | } 1448 | 1449 | function onCloseOrRemove(err) { 1450 | self.removeSocket(socket); 1451 | socket.removeListener('free', onFree); 1452 | socket.removeListener('close', onCloseOrRemove); 1453 | socket.removeListener('agentRemove', onCloseOrRemove); 1454 | } 1455 | }); 1456 | }; 1457 | 1458 | TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { 1459 | var self = this; 1460 | var placeholder = {}; 1461 | self.sockets.push(placeholder); 1462 | 1463 | var connectOptions = mergeOptions({}, self.proxyOptions, { 1464 | method: 'CONNECT', 1465 | path: options.host + ':' + options.port, 1466 | agent: false, 1467 | headers: { 1468 | host: options.host + ':' + options.port 1469 | } 1470 | }); 1471 | if (options.localAddress) { 1472 | connectOptions.localAddress = options.localAddress; 1473 | } 1474 | if (connectOptions.proxyAuth) { 1475 | connectOptions.headers = connectOptions.headers || {}; 1476 | connectOptions.headers['Proxy-Authorization'] = 'Basic ' + 1477 | new Buffer(connectOptions.proxyAuth).toString('base64'); 1478 | } 1479 | 1480 | debug('making CONNECT request'); 1481 | var connectReq = self.request(connectOptions); 1482 | connectReq.useChunkedEncodingByDefault = false; // for v0.6 1483 | connectReq.once('response', onResponse); // for v0.6 1484 | connectReq.once('upgrade', onUpgrade); // for v0.6 1485 | connectReq.once('connect', onConnect); // for v0.7 or later 1486 | connectReq.once('error', onError); 1487 | connectReq.end(); 1488 | 1489 | function onResponse(res) { 1490 | // Very hacky. This is necessary to avoid http-parser leaks. 1491 | res.upgrade = true; 1492 | } 1493 | 1494 | function onUpgrade(res, socket, head) { 1495 | // Hacky. 1496 | process.nextTick(function() { 1497 | onConnect(res, socket, head); 1498 | }); 1499 | } 1500 | 1501 | function onConnect(res, socket, head) { 1502 | connectReq.removeAllListeners(); 1503 | socket.removeAllListeners(); 1504 | 1505 | if (res.statusCode !== 200) { 1506 | debug('tunneling socket could not be established, statusCode=%d', 1507 | res.statusCode); 1508 | socket.destroy(); 1509 | var error = new Error('tunneling socket could not be established, ' + 1510 | 'statusCode=' + res.statusCode); 1511 | error.code = 'ECONNRESET'; 1512 | options.request.emit('error', error); 1513 | self.removeSocket(placeholder); 1514 | return; 1515 | } 1516 | if (head.length > 0) { 1517 | debug('got illegal response body from proxy'); 1518 | socket.destroy(); 1519 | var error = new Error('got illegal response body from proxy'); 1520 | error.code = 'ECONNRESET'; 1521 | options.request.emit('error', error); 1522 | self.removeSocket(placeholder); 1523 | return; 1524 | } 1525 | debug('tunneling connection has established'); 1526 | self.sockets[self.sockets.indexOf(placeholder)] = socket; 1527 | return cb(socket); 1528 | } 1529 | 1530 | function onError(cause) { 1531 | connectReq.removeAllListeners(); 1532 | 1533 | debug('tunneling socket could not be established, cause=%s\n', 1534 | cause.message, cause.stack); 1535 | var error = new Error('tunneling socket could not be established, ' + 1536 | 'cause=' + cause.message); 1537 | error.code = 'ECONNRESET'; 1538 | options.request.emit('error', error); 1539 | self.removeSocket(placeholder); 1540 | } 1541 | }; 1542 | 1543 | TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { 1544 | var pos = this.sockets.indexOf(socket) 1545 | if (pos === -1) { 1546 | return; 1547 | } 1548 | this.sockets.splice(pos, 1); 1549 | 1550 | var pending = this.requests.shift(); 1551 | if (pending) { 1552 | // If we have pending requests and a socket gets closed a new one 1553 | // needs to be created to take over in the pool for the one that closed. 1554 | this.createSocket(pending, function(socket) { 1555 | pending.request.onSocket(socket); 1556 | }); 1557 | } 1558 | }; 1559 | 1560 | function createSecureSocket(options, cb) { 1561 | var self = this; 1562 | TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { 1563 | var hostHeader = options.request.getHeader('host'); 1564 | var tlsOptions = mergeOptions({}, self.options, { 1565 | socket: socket, 1566 | servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host 1567 | }); 1568 | 1569 | // 0 is dummy port for v0.6 1570 | var secureSocket = tls.connect(0, tlsOptions); 1571 | self.sockets[self.sockets.indexOf(socket)] = secureSocket; 1572 | cb(secureSocket); 1573 | }); 1574 | } 1575 | 1576 | 1577 | function toOptions(host, port, localAddress) { 1578 | if (typeof host === 'string') { // since v0.10 1579 | return { 1580 | host: host, 1581 | port: port, 1582 | localAddress: localAddress 1583 | }; 1584 | } 1585 | return host; // for v0.11 or later 1586 | } 1587 | 1588 | function mergeOptions(target) { 1589 | for (var i = 1, len = arguments.length; i < len; ++i) { 1590 | var overrides = arguments[i]; 1591 | if (typeof overrides === 'object') { 1592 | var keys = Object.keys(overrides); 1593 | for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { 1594 | var k = keys[j]; 1595 | if (overrides[k] !== undefined) { 1596 | target[k] = overrides[k]; 1597 | } 1598 | } 1599 | } 1600 | } 1601 | return target; 1602 | } 1603 | 1604 | 1605 | var debug; 1606 | if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { 1607 | debug = function() { 1608 | var args = Array.prototype.slice.call(arguments); 1609 | if (typeof args[0] === 'string') { 1610 | args[0] = 'TUNNEL: ' + args[0]; 1611 | } else { 1612 | args.unshift('TUNNEL:'); 1613 | } 1614 | console.error.apply(console, args); 1615 | } 1616 | } else { 1617 | debug = function() {}; 1618 | } 1619 | exports.debug = debug; // for test 1620 | 1621 | 1622 | /***/ }), 1623 | 1624 | /***/ 198: 1625 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1626 | 1627 | "use strict"; 1628 | 1629 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 1630 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 1631 | return new (P || (P = Promise))(function (resolve, reject) { 1632 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 1633 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 1634 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 1635 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 1636 | }); 1637 | }; 1638 | var __importStar = (this && this.__importStar) || function (mod) { 1639 | if (mod && mod.__esModule) return mod; 1640 | var result = {}; 1641 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; 1642 | result["default"] = mod; 1643 | return result; 1644 | }; 1645 | Object.defineProperty(exports, "__esModule", { value: true }); 1646 | const core = __importStar(__webpack_require__(470)); 1647 | const exec = __importStar(__webpack_require__(986)); 1648 | const fs = __importStar(__webpack_require__(747)); 1649 | const path = __importStar(__webpack_require__(622)); 1650 | const io = __importStar(__webpack_require__(1)); 1651 | const IS_WINDOWS = process.platform === 'win32'; 1652 | const VS_VERSION = core.getInput('vs-version') || 'latest'; 1653 | const VSWHERE_PATH = core.getInput('vswhere-path'); 1654 | const ALLOW_PRERELEASE = core.getInput('vs-prerelease') || 'false'; 1655 | let MSBUILD_ARCH = core.getInput('msbuild-architecture') || 'x86'; 1656 | // if a specific version of VS is requested 1657 | let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest '; 1658 | if (ALLOW_PRERELEASE === 'true') { 1659 | VSWHERE_EXEC += ' -prerelease '; 1660 | } 1661 | if (VS_VERSION !== 'latest') { 1662 | VSWHERE_EXEC += `-version "${VS_VERSION}" `; 1663 | } 1664 | core.debug(`Execution arguments: ${VSWHERE_EXEC}`); 1665 | function run() { 1666 | return __awaiter(this, void 0, void 0, function* () { 1667 | try { 1668 | // exit if non Windows runner 1669 | if (IS_WINDOWS === false) { 1670 | core.setFailed('setup-msbuild can only be run on Windows runners'); 1671 | return; 1672 | } 1673 | // check to see if we are using a specific path for vswhere 1674 | let vswhereToolExe = ''; 1675 | if (VSWHERE_PATH) { 1676 | // specified a path for vswhere, use it 1677 | core.debug(`Using given vswhere-path: ${VSWHERE_PATH}`); 1678 | vswhereToolExe = path.join(VSWHERE_PATH, 'vswhere.exe'); 1679 | } 1680 | else { 1681 | // check in PATH to see if it is there 1682 | try { 1683 | const vsWhereInPath = yield io.which('vswhere', true); 1684 | core.debug(`Found tool in PATH: ${vsWhereInPath}`); 1685 | vswhereToolExe = vsWhereInPath; 1686 | } 1687 | catch (_a) { 1688 | // fall back to VS-installed path 1689 | vswhereToolExe = path.join(process.env['ProgramFiles(x86)'], 'Microsoft Visual Studio\\Installer\\vswhere.exe'); 1690 | core.debug(`Trying Visual Studio-installed path: ${vswhereToolExe}`); 1691 | } 1692 | } 1693 | if (!fs.existsSync(vswhereToolExe)) { 1694 | core.setFailed('setup-msbuild requires the path to where vswhere.exe exists'); 1695 | return; 1696 | } 1697 | core.debug(`Full tool exe: ${vswhereToolExe}`); 1698 | let foundToolPath = ''; 1699 | const options = {}; 1700 | options.listeners = { 1701 | stdout: (data) => { 1702 | const installationPath = data.toString().trim(); 1703 | core.debug(`Found installation path: ${installationPath}`); 1704 | // x64 and arm64 only exist in one possible location, so no fallback probing 1705 | if (MSBUILD_ARCH === 'x64' || MSBUILD_ARCH === 'arm64') { 1706 | // x64 is actually amd64 so change to that 1707 | if (MSBUILD_ARCH === 'x64') { 1708 | MSBUILD_ARCH = 'amd64'; 1709 | } 1710 | let toolPath = path.join(installationPath, `MSBuild\\Current\\Bin\\${MSBUILD_ARCH}\\MSBuild.exe`); 1711 | core.debug(`Checking for path: ${toolPath}`); 1712 | if (!fs.existsSync(toolPath)) { 1713 | return; 1714 | } 1715 | foundToolPath = toolPath; 1716 | } 1717 | else { 1718 | let toolPath = path.join(installationPath, 'MSBuild\\Current\\Bin\\MSBuild.exe'); 1719 | core.debug(`Checking for path: ${toolPath}`); 1720 | if (!fs.existsSync(toolPath)) { 1721 | toolPath = path.join(installationPath, 'MSBuild\\15.0\\Bin\\MSBuild.exe'); 1722 | core.debug(`Checking for path: ${toolPath}`); 1723 | if (!fs.existsSync(toolPath)) { 1724 | return; 1725 | } 1726 | } 1727 | foundToolPath = toolPath; 1728 | } 1729 | } 1730 | }; 1731 | // execute the find putting the result of the command in the options foundToolPath 1732 | yield exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options); 1733 | if (!foundToolPath) { 1734 | core.setFailed('Unable to find MSBuild.'); 1735 | return; 1736 | } 1737 | // extract the folder location for the tool 1738 | const toolFolderPath = path.dirname(foundToolPath); 1739 | // set the outputs for the action to the folder path of msbuild 1740 | core.setOutput('msbuildPath', toolFolderPath); 1741 | // add tool path to PATH 1742 | core.addPath(toolFolderPath); 1743 | core.debug(`Tool path added to PATH: ${toolFolderPath}`); 1744 | } 1745 | catch (error) { 1746 | core.setFailed(error.message); 1747 | } 1748 | }); 1749 | } 1750 | run(); 1751 | 1752 | 1753 | /***/ }), 1754 | 1755 | /***/ 204: 1756 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1757 | 1758 | "use strict"; 1759 | 1760 | 1761 | Object.defineProperty(exports, "__esModule", { 1762 | value: true 1763 | }); 1764 | exports.default = void 0; 1765 | 1766 | var _validate = _interopRequireDefault(__webpack_require__(634)); 1767 | 1768 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1769 | 1770 | function parse(uuid) { 1771 | if (!(0, _validate.default)(uuid)) { 1772 | throw TypeError('Invalid UUID'); 1773 | } 1774 | 1775 | let v; 1776 | const arr = new Uint8Array(16); // Parse ########-....-....-....-............ 1777 | 1778 | arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; 1779 | arr[1] = v >>> 16 & 0xff; 1780 | arr[2] = v >>> 8 & 0xff; 1781 | arr[3] = v & 0xff; // Parse ........-####-....-....-............ 1782 | 1783 | arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; 1784 | arr[5] = v & 0xff; // Parse ........-....-####-....-............ 1785 | 1786 | arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; 1787 | arr[7] = v & 0xff; // Parse ........-....-....-####-............ 1788 | 1789 | arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; 1790 | arr[9] = v & 0xff; // Parse ........-....-....-....-############ 1791 | // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) 1792 | 1793 | arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; 1794 | arr[11] = v / 0x100000000 & 0xff; 1795 | arr[12] = v >>> 24 & 0xff; 1796 | arr[13] = v >>> 16 & 0xff; 1797 | arr[14] = v >>> 8 & 0xff; 1798 | arr[15] = v & 0xff; 1799 | return arr; 1800 | } 1801 | 1802 | var _default = parse; 1803 | exports.default = _default; 1804 | 1805 | /***/ }), 1806 | 1807 | /***/ 211: 1808 | /***/ (function(module) { 1809 | 1810 | module.exports = require("https"); 1811 | 1812 | /***/ }), 1813 | 1814 | /***/ 293: 1815 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1816 | 1817 | "use strict"; 1818 | 1819 | 1820 | Object.defineProperty(exports, "__esModule", { 1821 | value: true 1822 | }); 1823 | exports.default = void 0; 1824 | 1825 | var _rng = _interopRequireDefault(__webpack_require__(506)); 1826 | 1827 | var _stringify = _interopRequireDefault(__webpack_require__(960)); 1828 | 1829 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1830 | 1831 | function v4(options, buf, offset) { 1832 | options = options || {}; 1833 | 1834 | const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` 1835 | 1836 | 1837 | rnds[6] = rnds[6] & 0x0f | 0x40; 1838 | rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided 1839 | 1840 | if (buf) { 1841 | offset = offset || 0; 1842 | 1843 | for (let i = 0; i < 16; ++i) { 1844 | buf[offset + i] = rnds[i]; 1845 | } 1846 | 1847 | return buf; 1848 | } 1849 | 1850 | return (0, _stringify.default)(rnds); 1851 | } 1852 | 1853 | var _default = v4; 1854 | exports.default = _default; 1855 | 1856 | /***/ }), 1857 | 1858 | /***/ 329: 1859 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1860 | 1861 | "use strict"; 1862 | 1863 | 1864 | Object.defineProperty(exports, "__esModule", { 1865 | value: true 1866 | }); 1867 | exports.default = void 0; 1868 | 1869 | var _crypto = _interopRequireDefault(__webpack_require__(417)); 1870 | 1871 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1872 | 1873 | function sha1(bytes) { 1874 | if (Array.isArray(bytes)) { 1875 | bytes = Buffer.from(bytes); 1876 | } else if (typeof bytes === 'string') { 1877 | bytes = Buffer.from(bytes, 'utf8'); 1878 | } 1879 | 1880 | return _crypto.default.createHash('sha1').update(bytes).digest(); 1881 | } 1882 | 1883 | var _default = sha1; 1884 | exports.default = _default; 1885 | 1886 | /***/ }), 1887 | 1888 | /***/ 357: 1889 | /***/ (function(module) { 1890 | 1891 | module.exports = require("assert"); 1892 | 1893 | /***/ }), 1894 | 1895 | /***/ 363: 1896 | /***/ (function(__unusedmodule, exports) { 1897 | 1898 | "use strict"; 1899 | 1900 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 1901 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 1902 | return new (P || (P = Promise))(function (resolve, reject) { 1903 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 1904 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 1905 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 1906 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 1907 | }); 1908 | }; 1909 | Object.defineProperty(exports, "__esModule", { value: true }); 1910 | exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0; 1911 | class BasicCredentialHandler { 1912 | constructor(username, password) { 1913 | this.username = username; 1914 | this.password = password; 1915 | } 1916 | prepareRequest(options) { 1917 | if (!options.headers) { 1918 | throw Error('The request has no headers'); 1919 | } 1920 | options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`; 1921 | } 1922 | // This handler cannot handle 401 1923 | canHandleAuthentication() { 1924 | return false; 1925 | } 1926 | handleAuthentication() { 1927 | return __awaiter(this, void 0, void 0, function* () { 1928 | throw new Error('not implemented'); 1929 | }); 1930 | } 1931 | } 1932 | exports.BasicCredentialHandler = BasicCredentialHandler; 1933 | class BearerCredentialHandler { 1934 | constructor(token) { 1935 | this.token = token; 1936 | } 1937 | // currently implements pre-authorization 1938 | // TODO: support preAuth = false where it hooks on 401 1939 | prepareRequest(options) { 1940 | if (!options.headers) { 1941 | throw Error('The request has no headers'); 1942 | } 1943 | options.headers['Authorization'] = `Bearer ${this.token}`; 1944 | } 1945 | // This handler cannot handle 401 1946 | canHandleAuthentication() { 1947 | return false; 1948 | } 1949 | handleAuthentication() { 1950 | return __awaiter(this, void 0, void 0, function* () { 1951 | throw new Error('not implemented'); 1952 | }); 1953 | } 1954 | } 1955 | exports.BearerCredentialHandler = BearerCredentialHandler; 1956 | class PersonalAccessTokenCredentialHandler { 1957 | constructor(token) { 1958 | this.token = token; 1959 | } 1960 | // currently implements pre-authorization 1961 | // TODO: support preAuth = false where it hooks on 401 1962 | prepareRequest(options) { 1963 | if (!options.headers) { 1964 | throw Error('The request has no headers'); 1965 | } 1966 | options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`; 1967 | } 1968 | // This handler cannot handle 401 1969 | canHandleAuthentication() { 1970 | return false; 1971 | } 1972 | handleAuthentication() { 1973 | return __awaiter(this, void 0, void 0, function* () { 1974 | throw new Error('not implemented'); 1975 | }); 1976 | } 1977 | } 1978 | exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; 1979 | //# sourceMappingURL=auth.js.map 1980 | 1981 | /***/ }), 1982 | 1983 | /***/ 413: 1984 | /***/ (function(module, __unusedexports, __webpack_require__) { 1985 | 1986 | module.exports = __webpack_require__(141); 1987 | 1988 | 1989 | /***/ }), 1990 | 1991 | /***/ 417: 1992 | /***/ (function(module) { 1993 | 1994 | module.exports = require("crypto"); 1995 | 1996 | /***/ }), 1997 | 1998 | /***/ 431: 1999 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2000 | 2001 | "use strict"; 2002 | 2003 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 2004 | if (k2 === undefined) k2 = k; 2005 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 2006 | }) : (function(o, m, k, k2) { 2007 | if (k2 === undefined) k2 = k; 2008 | o[k2] = m[k]; 2009 | })); 2010 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 2011 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 2012 | }) : function(o, v) { 2013 | o["default"] = v; 2014 | }); 2015 | var __importStar = (this && this.__importStar) || function (mod) { 2016 | if (mod && mod.__esModule) return mod; 2017 | var result = {}; 2018 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 2019 | __setModuleDefault(result, mod); 2020 | return result; 2021 | }; 2022 | Object.defineProperty(exports, "__esModule", { value: true }); 2023 | exports.issue = exports.issueCommand = void 0; 2024 | const os = __importStar(__webpack_require__(87)); 2025 | const utils_1 = __webpack_require__(82); 2026 | /** 2027 | * Commands 2028 | * 2029 | * Command Format: 2030 | * ::name key=value,key=value::message 2031 | * 2032 | * Examples: 2033 | * ::warning::This is the message 2034 | * ::set-env name=MY_VAR::some value 2035 | */ 2036 | function issueCommand(command, properties, message) { 2037 | const cmd = new Command(command, properties, message); 2038 | process.stdout.write(cmd.toString() + os.EOL); 2039 | } 2040 | exports.issueCommand = issueCommand; 2041 | function issue(name, message = '') { 2042 | issueCommand(name, {}, message); 2043 | } 2044 | exports.issue = issue; 2045 | const CMD_STRING = '::'; 2046 | class Command { 2047 | constructor(command, properties, message) { 2048 | if (!command) { 2049 | command = 'missing.command'; 2050 | } 2051 | this.command = command; 2052 | this.properties = properties; 2053 | this.message = message; 2054 | } 2055 | toString() { 2056 | let cmdStr = CMD_STRING + this.command; 2057 | if (this.properties && Object.keys(this.properties).length > 0) { 2058 | cmdStr += ' '; 2059 | let first = true; 2060 | for (const key in this.properties) { 2061 | if (this.properties.hasOwnProperty(key)) { 2062 | const val = this.properties[key]; 2063 | if (val) { 2064 | if (first) { 2065 | first = false; 2066 | } 2067 | else { 2068 | cmdStr += ','; 2069 | } 2070 | cmdStr += `${key}=${escapeProperty(val)}`; 2071 | } 2072 | } 2073 | } 2074 | } 2075 | cmdStr += `${CMD_STRING}${escapeData(this.message)}`; 2076 | return cmdStr; 2077 | } 2078 | } 2079 | function escapeData(s) { 2080 | return utils_1.toCommandValue(s) 2081 | .replace(/%/g, '%25') 2082 | .replace(/\r/g, '%0D') 2083 | .replace(/\n/g, '%0A'); 2084 | } 2085 | function escapeProperty(s) { 2086 | return utils_1.toCommandValue(s) 2087 | .replace(/%/g, '%25') 2088 | .replace(/\r/g, '%0D') 2089 | .replace(/\n/g, '%0A') 2090 | .replace(/:/g, '%3A') 2091 | .replace(/,/g, '%2C'); 2092 | } 2093 | //# sourceMappingURL=command.js.map 2094 | 2095 | /***/ }), 2096 | 2097 | /***/ 470: 2098 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2099 | 2100 | "use strict"; 2101 | 2102 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 2103 | if (k2 === undefined) k2 = k; 2104 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 2105 | }) : (function(o, m, k, k2) { 2106 | if (k2 === undefined) k2 = k; 2107 | o[k2] = m[k]; 2108 | })); 2109 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 2110 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 2111 | }) : function(o, v) { 2112 | o["default"] = v; 2113 | }); 2114 | var __importStar = (this && this.__importStar) || function (mod) { 2115 | if (mod && mod.__esModule) return mod; 2116 | var result = {}; 2117 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 2118 | __setModuleDefault(result, mod); 2119 | return result; 2120 | }; 2121 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 2122 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 2123 | return new (P || (P = Promise))(function (resolve, reject) { 2124 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 2125 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 2126 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 2127 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 2128 | }); 2129 | }; 2130 | Object.defineProperty(exports, "__esModule", { value: true }); 2131 | 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; 2132 | const command_1 = __webpack_require__(431); 2133 | const file_command_1 = __webpack_require__(102); 2134 | const utils_1 = __webpack_require__(82); 2135 | const os = __importStar(__webpack_require__(87)); 2136 | const path = __importStar(__webpack_require__(622)); 2137 | const oidc_utils_1 = __webpack_require__(742); 2138 | /** 2139 | * The code to exit an action 2140 | */ 2141 | var ExitCode; 2142 | (function (ExitCode) { 2143 | /** 2144 | * A code indicating that the action was successful 2145 | */ 2146 | ExitCode[ExitCode["Success"] = 0] = "Success"; 2147 | /** 2148 | * A code indicating that the action was a failure 2149 | */ 2150 | ExitCode[ExitCode["Failure"] = 1] = "Failure"; 2151 | })(ExitCode = exports.ExitCode || (exports.ExitCode = {})); 2152 | //----------------------------------------------------------------------- 2153 | // Variables 2154 | //----------------------------------------------------------------------- 2155 | /** 2156 | * Sets env variable for this action and future actions in the job 2157 | * @param name the name of the variable to set 2158 | * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify 2159 | */ 2160 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 2161 | function exportVariable(name, val) { 2162 | const convertedVal = utils_1.toCommandValue(val); 2163 | process.env[name] = convertedVal; 2164 | const filePath = process.env['GITHUB_ENV'] || ''; 2165 | if (filePath) { 2166 | return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); 2167 | } 2168 | command_1.issueCommand('set-env', { name }, convertedVal); 2169 | } 2170 | exports.exportVariable = exportVariable; 2171 | /** 2172 | * Registers a secret which will get masked from logs 2173 | * @param secret value of the secret 2174 | */ 2175 | function setSecret(secret) { 2176 | command_1.issueCommand('add-mask', {}, secret); 2177 | } 2178 | exports.setSecret = setSecret; 2179 | /** 2180 | * Prepends inputPath to the PATH (for this action and future actions) 2181 | * @param inputPath 2182 | */ 2183 | function addPath(inputPath) { 2184 | const filePath = process.env['GITHUB_PATH'] || ''; 2185 | if (filePath) { 2186 | file_command_1.issueFileCommand('PATH', inputPath); 2187 | } 2188 | else { 2189 | command_1.issueCommand('add-path', {}, inputPath); 2190 | } 2191 | process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; 2192 | } 2193 | exports.addPath = addPath; 2194 | /** 2195 | * Gets the value of an input. 2196 | * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. 2197 | * Returns an empty string if the value is not defined. 2198 | * 2199 | * @param name name of the input to get 2200 | * @param options optional. See InputOptions. 2201 | * @returns string 2202 | */ 2203 | function getInput(name, options) { 2204 | const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; 2205 | if (options && options.required && !val) { 2206 | throw new Error(`Input required and not supplied: ${name}`); 2207 | } 2208 | if (options && options.trimWhitespace === false) { 2209 | return val; 2210 | } 2211 | return val.trim(); 2212 | } 2213 | exports.getInput = getInput; 2214 | /** 2215 | * Gets the values of an multiline input. Each value is also trimmed. 2216 | * 2217 | * @param name name of the input to get 2218 | * @param options optional. See InputOptions. 2219 | * @returns string[] 2220 | * 2221 | */ 2222 | function getMultilineInput(name, options) { 2223 | const inputs = getInput(name, options) 2224 | .split('\n') 2225 | .filter(x => x !== ''); 2226 | if (options && options.trimWhitespace === false) { 2227 | return inputs; 2228 | } 2229 | return inputs.map(input => input.trim()); 2230 | } 2231 | exports.getMultilineInput = getMultilineInput; 2232 | /** 2233 | * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification. 2234 | * Support boolean input list: `true | True | TRUE | false | False | FALSE` . 2235 | * The return value is also in boolean type. 2236 | * ref: https://yaml.org/spec/1.2/spec.html#id2804923 2237 | * 2238 | * @param name name of the input to get 2239 | * @param options optional. See InputOptions. 2240 | * @returns boolean 2241 | */ 2242 | function getBooleanInput(name, options) { 2243 | const trueValue = ['true', 'True', 'TRUE']; 2244 | const falseValue = ['false', 'False', 'FALSE']; 2245 | const val = getInput(name, options); 2246 | if (trueValue.includes(val)) 2247 | return true; 2248 | if (falseValue.includes(val)) 2249 | return false; 2250 | throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` + 2251 | `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); 2252 | } 2253 | exports.getBooleanInput = getBooleanInput; 2254 | /** 2255 | * Sets the value of an output. 2256 | * 2257 | * @param name name of the output to set 2258 | * @param value value to store. Non-string values will be converted to a string via JSON.stringify 2259 | */ 2260 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 2261 | function setOutput(name, value) { 2262 | const filePath = process.env['GITHUB_OUTPUT'] || ''; 2263 | if (filePath) { 2264 | return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); 2265 | } 2266 | process.stdout.write(os.EOL); 2267 | command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); 2268 | } 2269 | exports.setOutput = setOutput; 2270 | /** 2271 | * Enables or disables the echoing of commands into stdout for the rest of the step. 2272 | * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. 2273 | * 2274 | */ 2275 | function setCommandEcho(enabled) { 2276 | command_1.issue('echo', enabled ? 'on' : 'off'); 2277 | } 2278 | exports.setCommandEcho = setCommandEcho; 2279 | //----------------------------------------------------------------------- 2280 | // Results 2281 | //----------------------------------------------------------------------- 2282 | /** 2283 | * Sets the action status to failed. 2284 | * When the action exits it will be with an exit code of 1 2285 | * @param message add error issue message 2286 | */ 2287 | function setFailed(message) { 2288 | process.exitCode = ExitCode.Failure; 2289 | error(message); 2290 | } 2291 | exports.setFailed = setFailed; 2292 | //----------------------------------------------------------------------- 2293 | // Logging Commands 2294 | //----------------------------------------------------------------------- 2295 | /** 2296 | * Gets whether Actions Step Debug is on or not 2297 | */ 2298 | function isDebug() { 2299 | return process.env['RUNNER_DEBUG'] === '1'; 2300 | } 2301 | exports.isDebug = isDebug; 2302 | /** 2303 | * Writes debug message to user log 2304 | * @param message debug message 2305 | */ 2306 | function debug(message) { 2307 | command_1.issueCommand('debug', {}, message); 2308 | } 2309 | exports.debug = debug; 2310 | /** 2311 | * Adds an error issue 2312 | * @param message error issue message. Errors will be converted to string via toString() 2313 | * @param properties optional properties to add to the annotation. 2314 | */ 2315 | function error(message, properties = {}) { 2316 | command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 2317 | } 2318 | exports.error = error; 2319 | /** 2320 | * Adds a warning issue 2321 | * @param message warning issue message. Errors will be converted to string via toString() 2322 | * @param properties optional properties to add to the annotation. 2323 | */ 2324 | function warning(message, properties = {}) { 2325 | command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 2326 | } 2327 | exports.warning = warning; 2328 | /** 2329 | * Adds a notice issue 2330 | * @param message notice issue message. Errors will be converted to string via toString() 2331 | * @param properties optional properties to add to the annotation. 2332 | */ 2333 | function notice(message, properties = {}) { 2334 | command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); 2335 | } 2336 | exports.notice = notice; 2337 | /** 2338 | * Writes info to log with console.log. 2339 | * @param message info message 2340 | */ 2341 | function info(message) { 2342 | process.stdout.write(message + os.EOL); 2343 | } 2344 | exports.info = info; 2345 | /** 2346 | * Begin an output group. 2347 | * 2348 | * Output until the next `groupEnd` will be foldable in this group 2349 | * 2350 | * @param name The name of the output group 2351 | */ 2352 | function startGroup(name) { 2353 | command_1.issue('group', name); 2354 | } 2355 | exports.startGroup = startGroup; 2356 | /** 2357 | * End an output group. 2358 | */ 2359 | function endGroup() { 2360 | command_1.issue('endgroup'); 2361 | } 2362 | exports.endGroup = endGroup; 2363 | /** 2364 | * Wrap an asynchronous function call in a group. 2365 | * 2366 | * Returns the same type as the function itself. 2367 | * 2368 | * @param name The name of the group 2369 | * @param fn The function to wrap in the group 2370 | */ 2371 | function group(name, fn) { 2372 | return __awaiter(this, void 0, void 0, function* () { 2373 | startGroup(name); 2374 | let result; 2375 | try { 2376 | result = yield fn(); 2377 | } 2378 | finally { 2379 | endGroup(); 2380 | } 2381 | return result; 2382 | }); 2383 | } 2384 | exports.group = group; 2385 | //----------------------------------------------------------------------- 2386 | // Wrapper action state 2387 | //----------------------------------------------------------------------- 2388 | /** 2389 | * Saves state for current action, the state can only be retrieved by this action's post job execution. 2390 | * 2391 | * @param name name of the state to store 2392 | * @param value value to store. Non-string values will be converted to a string via JSON.stringify 2393 | */ 2394 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 2395 | function saveState(name, value) { 2396 | const filePath = process.env['GITHUB_STATE'] || ''; 2397 | if (filePath) { 2398 | return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); 2399 | } 2400 | command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); 2401 | } 2402 | exports.saveState = saveState; 2403 | /** 2404 | * Gets the value of an state set by this action's main execution. 2405 | * 2406 | * @param name name of the state to get 2407 | * @returns string 2408 | */ 2409 | function getState(name) { 2410 | return process.env[`STATE_${name}`] || ''; 2411 | } 2412 | exports.getState = getState; 2413 | function getIDToken(aud) { 2414 | return __awaiter(this, void 0, void 0, function* () { 2415 | return yield oidc_utils_1.OidcClient.getIDToken(aud); 2416 | }); 2417 | } 2418 | exports.getIDToken = getIDToken; 2419 | /** 2420 | * Summary exports 2421 | */ 2422 | var summary_1 = __webpack_require__(665); 2423 | Object.defineProperty(exports, "summary", { enumerable: true, get: function () { return summary_1.summary; } }); 2424 | /** 2425 | * @deprecated use core.summary 2426 | */ 2427 | var summary_2 = __webpack_require__(665); 2428 | Object.defineProperty(exports, "markdownSummary", { enumerable: true, get: function () { return summary_2.markdownSummary; } }); 2429 | /** 2430 | * Path exports 2431 | */ 2432 | var path_utils_1 = __webpack_require__(573); 2433 | Object.defineProperty(exports, "toPosixPath", { enumerable: true, get: function () { return path_utils_1.toPosixPath; } }); 2434 | Object.defineProperty(exports, "toWin32Path", { enumerable: true, get: function () { return path_utils_1.toWin32Path; } }); 2435 | Object.defineProperty(exports, "toPlatformPath", { enumerable: true, get: function () { return path_utils_1.toPlatformPath; } }); 2436 | //# sourceMappingURL=core.js.map 2437 | 2438 | /***/ }), 2439 | 2440 | /***/ 506: 2441 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2442 | 2443 | "use strict"; 2444 | 2445 | 2446 | Object.defineProperty(exports, "__esModule", { 2447 | value: true 2448 | }); 2449 | exports.default = rng; 2450 | 2451 | var _crypto = _interopRequireDefault(__webpack_require__(417)); 2452 | 2453 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2454 | 2455 | const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate 2456 | 2457 | let poolPtr = rnds8Pool.length; 2458 | 2459 | function rng() { 2460 | if (poolPtr > rnds8Pool.length - 16) { 2461 | _crypto.default.randomFillSync(rnds8Pool); 2462 | 2463 | poolPtr = 0; 2464 | } 2465 | 2466 | return rnds8Pool.slice(poolPtr, poolPtr += 16); 2467 | } 2468 | 2469 | /***/ }), 2470 | 2471 | /***/ 525: 2472 | /***/ (function(__unusedmodule, exports) { 2473 | 2474 | "use strict"; 2475 | 2476 | 2477 | Object.defineProperty(exports, "__esModule", { 2478 | value: true 2479 | }); 2480 | exports.default = void 0; 2481 | 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; 2482 | exports.default = _default; 2483 | 2484 | /***/ }), 2485 | 2486 | /***/ 572: 2487 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2488 | 2489 | "use strict"; 2490 | 2491 | 2492 | Object.defineProperty(exports, "__esModule", { 2493 | value: true 2494 | }); 2495 | exports.default = void 0; 2496 | 2497 | var _v = _interopRequireDefault(__webpack_require__(136)); 2498 | 2499 | var _md = _interopRequireDefault(__webpack_require__(659)); 2500 | 2501 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2502 | 2503 | const v3 = (0, _v.default)('v3', 0x30, _md.default); 2504 | var _default = v3; 2505 | exports.default = _default; 2506 | 2507 | /***/ }), 2508 | 2509 | /***/ 573: 2510 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2511 | 2512 | "use strict"; 2513 | 2514 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 2515 | if (k2 === undefined) k2 = k; 2516 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 2517 | }) : (function(o, m, k, k2) { 2518 | if (k2 === undefined) k2 = k; 2519 | o[k2] = m[k]; 2520 | })); 2521 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 2522 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 2523 | }) : function(o, v) { 2524 | o["default"] = v; 2525 | }); 2526 | var __importStar = (this && this.__importStar) || function (mod) { 2527 | if (mod && mod.__esModule) return mod; 2528 | var result = {}; 2529 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 2530 | __setModuleDefault(result, mod); 2531 | return result; 2532 | }; 2533 | Object.defineProperty(exports, "__esModule", { value: true }); 2534 | exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; 2535 | const path = __importStar(__webpack_require__(622)); 2536 | /** 2537 | * toPosixPath converts the given path to the posix form. On Windows, \\ will be 2538 | * replaced with /. 2539 | * 2540 | * @param pth. Path to transform. 2541 | * @return string Posix path. 2542 | */ 2543 | function toPosixPath(pth) { 2544 | return pth.replace(/[\\]/g, '/'); 2545 | } 2546 | exports.toPosixPath = toPosixPath; 2547 | /** 2548 | * toWin32Path converts the given path to the win32 form. On Linux, / will be 2549 | * replaced with \\. 2550 | * 2551 | * @param pth. Path to transform. 2552 | * @return string Win32 path. 2553 | */ 2554 | function toWin32Path(pth) { 2555 | return pth.replace(/[/]/g, '\\'); 2556 | } 2557 | exports.toWin32Path = toWin32Path; 2558 | /** 2559 | * toPlatformPath converts the given path to a platform-specific path. It does 2560 | * this by replacing instances of / and \ with the platform-specific path 2561 | * separator. 2562 | * 2563 | * @param pth The path to platformize. 2564 | * @return string The platform-specific path. 2565 | */ 2566 | function toPlatformPath(pth) { 2567 | return pth.replace(/[/\\]/g, path.sep); 2568 | } 2569 | exports.toPlatformPath = toPlatformPath; 2570 | //# sourceMappingURL=path-utils.js.map 2571 | 2572 | /***/ }), 2573 | 2574 | /***/ 605: 2575 | /***/ (function(module) { 2576 | 2577 | module.exports = require("http"); 2578 | 2579 | /***/ }), 2580 | 2581 | /***/ 614: 2582 | /***/ (function(module) { 2583 | 2584 | module.exports = require("events"); 2585 | 2586 | /***/ }), 2587 | 2588 | /***/ 622: 2589 | /***/ (function(module) { 2590 | 2591 | module.exports = require("path"); 2592 | 2593 | /***/ }), 2594 | 2595 | /***/ 631: 2596 | /***/ (function(module) { 2597 | 2598 | module.exports = require("net"); 2599 | 2600 | /***/ }), 2601 | 2602 | /***/ 634: 2603 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2604 | 2605 | "use strict"; 2606 | 2607 | 2608 | Object.defineProperty(exports, "__esModule", { 2609 | value: true 2610 | }); 2611 | exports.default = void 0; 2612 | 2613 | var _regex = _interopRequireDefault(__webpack_require__(525)); 2614 | 2615 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2616 | 2617 | function validate(uuid) { 2618 | return typeof uuid === 'string' && _regex.default.test(uuid); 2619 | } 2620 | 2621 | var _default = validate; 2622 | exports.default = _default; 2623 | 2624 | /***/ }), 2625 | 2626 | /***/ 638: 2627 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2628 | 2629 | "use strict"; 2630 | 2631 | 2632 | Object.defineProperty(exports, "__esModule", { 2633 | value: true 2634 | }); 2635 | exports.default = void 0; 2636 | 2637 | var _v = _interopRequireDefault(__webpack_require__(136)); 2638 | 2639 | var _sha = _interopRequireDefault(__webpack_require__(329)); 2640 | 2641 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2642 | 2643 | const v5 = (0, _v.default)('v5', 0x50, _sha.default); 2644 | var _default = v5; 2645 | exports.default = _default; 2646 | 2647 | /***/ }), 2648 | 2649 | /***/ 659: 2650 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2651 | 2652 | "use strict"; 2653 | 2654 | 2655 | Object.defineProperty(exports, "__esModule", { 2656 | value: true 2657 | }); 2658 | exports.default = void 0; 2659 | 2660 | var _crypto = _interopRequireDefault(__webpack_require__(417)); 2661 | 2662 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2663 | 2664 | function md5(bytes) { 2665 | if (Array.isArray(bytes)) { 2666 | bytes = Buffer.from(bytes); 2667 | } else if (typeof bytes === 'string') { 2668 | bytes = Buffer.from(bytes, 'utf8'); 2669 | } 2670 | 2671 | return _crypto.default.createHash('md5').update(bytes).digest(); 2672 | } 2673 | 2674 | var _default = md5; 2675 | exports.default = _default; 2676 | 2677 | /***/ }), 2678 | 2679 | /***/ 665: 2680 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2681 | 2682 | "use strict"; 2683 | 2684 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 2685 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 2686 | return new (P || (P = Promise))(function (resolve, reject) { 2687 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 2688 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 2689 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 2690 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 2691 | }); 2692 | }; 2693 | Object.defineProperty(exports, "__esModule", { value: true }); 2694 | exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; 2695 | const os_1 = __webpack_require__(87); 2696 | const fs_1 = __webpack_require__(747); 2697 | const { access, appendFile, writeFile } = fs_1.promises; 2698 | exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; 2699 | exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; 2700 | class Summary { 2701 | constructor() { 2702 | this._buffer = ''; 2703 | } 2704 | /** 2705 | * Finds the summary file path from the environment, rejects if env var is not found or file does not exist 2706 | * Also checks r/w permissions. 2707 | * 2708 | * @returns step summary file path 2709 | */ 2710 | filePath() { 2711 | return __awaiter(this, void 0, void 0, function* () { 2712 | if (this._filePath) { 2713 | return this._filePath; 2714 | } 2715 | const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; 2716 | if (!pathFromEnv) { 2717 | throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); 2718 | } 2719 | try { 2720 | yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); 2721 | } 2722 | catch (_a) { 2723 | throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); 2724 | } 2725 | this._filePath = pathFromEnv; 2726 | return this._filePath; 2727 | }); 2728 | } 2729 | /** 2730 | * Wraps content in an HTML tag, adding any HTML attributes 2731 | * 2732 | * @param {string} tag HTML tag to wrap 2733 | * @param {string | null} content content within the tag 2734 | * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add 2735 | * 2736 | * @returns {string} content wrapped in HTML element 2737 | */ 2738 | wrap(tag, content, attrs = {}) { 2739 | const htmlAttrs = Object.entries(attrs) 2740 | .map(([key, value]) => ` ${key}="${value}"`) 2741 | .join(''); 2742 | if (!content) { 2743 | return `<${tag}${htmlAttrs}>`; 2744 | } 2745 | return `<${tag}${htmlAttrs}>${content}`; 2746 | } 2747 | /** 2748 | * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. 2749 | * 2750 | * @param {SummaryWriteOptions} [options] (optional) options for write operation 2751 | * 2752 | * @returns {Promise} summary instance 2753 | */ 2754 | write(options) { 2755 | return __awaiter(this, void 0, void 0, function* () { 2756 | const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); 2757 | const filePath = yield this.filePath(); 2758 | const writeFunc = overwrite ? writeFile : appendFile; 2759 | yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); 2760 | return this.emptyBuffer(); 2761 | }); 2762 | } 2763 | /** 2764 | * Clears the summary buffer and wipes the summary file 2765 | * 2766 | * @returns {Summary} summary instance 2767 | */ 2768 | clear() { 2769 | return __awaiter(this, void 0, void 0, function* () { 2770 | return this.emptyBuffer().write({ overwrite: true }); 2771 | }); 2772 | } 2773 | /** 2774 | * Returns the current summary buffer as a string 2775 | * 2776 | * @returns {string} string of summary buffer 2777 | */ 2778 | stringify() { 2779 | return this._buffer; 2780 | } 2781 | /** 2782 | * If the summary buffer is empty 2783 | * 2784 | * @returns {boolen} true if the buffer is empty 2785 | */ 2786 | isEmptyBuffer() { 2787 | return this._buffer.length === 0; 2788 | } 2789 | /** 2790 | * Resets the summary buffer without writing to summary file 2791 | * 2792 | * @returns {Summary} summary instance 2793 | */ 2794 | emptyBuffer() { 2795 | this._buffer = ''; 2796 | return this; 2797 | } 2798 | /** 2799 | * Adds raw text to the summary buffer 2800 | * 2801 | * @param {string} text content to add 2802 | * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) 2803 | * 2804 | * @returns {Summary} summary instance 2805 | */ 2806 | addRaw(text, addEOL = false) { 2807 | this._buffer += text; 2808 | return addEOL ? this.addEOL() : this; 2809 | } 2810 | /** 2811 | * Adds the operating system-specific end-of-line marker to the buffer 2812 | * 2813 | * @returns {Summary} summary instance 2814 | */ 2815 | addEOL() { 2816 | return this.addRaw(os_1.EOL); 2817 | } 2818 | /** 2819 | * Adds an HTML codeblock to the summary buffer 2820 | * 2821 | * @param {string} code content to render within fenced code block 2822 | * @param {string} lang (optional) language to syntax highlight code 2823 | * 2824 | * @returns {Summary} summary instance 2825 | */ 2826 | addCodeBlock(code, lang) { 2827 | const attrs = Object.assign({}, (lang && { lang })); 2828 | const element = this.wrap('pre', this.wrap('code', code), attrs); 2829 | return this.addRaw(element).addEOL(); 2830 | } 2831 | /** 2832 | * Adds an HTML list to the summary buffer 2833 | * 2834 | * @param {string[]} items list of items to render 2835 | * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) 2836 | * 2837 | * @returns {Summary} summary instance 2838 | */ 2839 | addList(items, ordered = false) { 2840 | const tag = ordered ? 'ol' : 'ul'; 2841 | const listItems = items.map(item => this.wrap('li', item)).join(''); 2842 | const element = this.wrap(tag, listItems); 2843 | return this.addRaw(element).addEOL(); 2844 | } 2845 | /** 2846 | * Adds an HTML table to the summary buffer 2847 | * 2848 | * @param {SummaryTableCell[]} rows table rows 2849 | * 2850 | * @returns {Summary} summary instance 2851 | */ 2852 | addTable(rows) { 2853 | const tableBody = rows 2854 | .map(row => { 2855 | const cells = row 2856 | .map(cell => { 2857 | if (typeof cell === 'string') { 2858 | return this.wrap('td', cell); 2859 | } 2860 | const { header, data, colspan, rowspan } = cell; 2861 | const tag = header ? 'th' : 'td'; 2862 | const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); 2863 | return this.wrap(tag, data, attrs); 2864 | }) 2865 | .join(''); 2866 | return this.wrap('tr', cells); 2867 | }) 2868 | .join(''); 2869 | const element = this.wrap('table', tableBody); 2870 | return this.addRaw(element).addEOL(); 2871 | } 2872 | /** 2873 | * Adds a collapsable HTML details element to the summary buffer 2874 | * 2875 | * @param {string} label text for the closed state 2876 | * @param {string} content collapsable content 2877 | * 2878 | * @returns {Summary} summary instance 2879 | */ 2880 | addDetails(label, content) { 2881 | const element = this.wrap('details', this.wrap('summary', label) + content); 2882 | return this.addRaw(element).addEOL(); 2883 | } 2884 | /** 2885 | * Adds an HTML image tag to the summary buffer 2886 | * 2887 | * @param {string} src path to the image you to embed 2888 | * @param {string} alt text description of the image 2889 | * @param {SummaryImageOptions} options (optional) addition image attributes 2890 | * 2891 | * @returns {Summary} summary instance 2892 | */ 2893 | addImage(src, alt, options) { 2894 | const { width, height } = options || {}; 2895 | const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); 2896 | const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); 2897 | return this.addRaw(element).addEOL(); 2898 | } 2899 | /** 2900 | * Adds an HTML section heading element 2901 | * 2902 | * @param {string} text heading text 2903 | * @param {number | string} [level=1] (optional) the heading level, default: 1 2904 | * 2905 | * @returns {Summary} summary instance 2906 | */ 2907 | addHeading(text, level) { 2908 | const tag = `h${level}`; 2909 | const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) 2910 | ? tag 2911 | : 'h1'; 2912 | const element = this.wrap(allowedTag, text); 2913 | return this.addRaw(element).addEOL(); 2914 | } 2915 | /** 2916 | * Adds an HTML thematic break (
) to the summary buffer 2917 | * 2918 | * @returns {Summary} summary instance 2919 | */ 2920 | addSeparator() { 2921 | const element = this.wrap('hr', null); 2922 | return this.addRaw(element).addEOL(); 2923 | } 2924 | /** 2925 | * Adds an HTML line break (
) to the summary buffer 2926 | * 2927 | * @returns {Summary} summary instance 2928 | */ 2929 | addBreak() { 2930 | const element = this.wrap('br', null); 2931 | return this.addRaw(element).addEOL(); 2932 | } 2933 | /** 2934 | * Adds an HTML blockquote to the summary buffer 2935 | * 2936 | * @param {string} text quote text 2937 | * @param {string} cite (optional) citation url 2938 | * 2939 | * @returns {Summary} summary instance 2940 | */ 2941 | addQuote(text, cite) { 2942 | const attrs = Object.assign({}, (cite && { cite })); 2943 | const element = this.wrap('blockquote', text, attrs); 2944 | return this.addRaw(element).addEOL(); 2945 | } 2946 | /** 2947 | * Adds an HTML anchor tag to the summary buffer 2948 | * 2949 | * @param {string} text link text/content 2950 | * @param {string} href hyperlink 2951 | * 2952 | * @returns {Summary} summary instance 2953 | */ 2954 | addLink(text, href) { 2955 | const element = this.wrap('a', text, { href }); 2956 | return this.addRaw(element).addEOL(); 2957 | } 2958 | } 2959 | const _summary = new Summary(); 2960 | /** 2961 | * @deprecated use `core.summary` 2962 | */ 2963 | exports.markdownSummary = _summary; 2964 | exports.summary = _summary; 2965 | //# sourceMappingURL=summary.js.map 2966 | 2967 | /***/ }), 2968 | 2969 | /***/ 669: 2970 | /***/ (function(module) { 2971 | 2972 | module.exports = require("util"); 2973 | 2974 | /***/ }), 2975 | 2976 | /***/ 672: 2977 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 2978 | 2979 | "use strict"; 2980 | 2981 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 2982 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 2983 | return new (P || (P = Promise))(function (resolve, reject) { 2984 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 2985 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 2986 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 2987 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 2988 | }); 2989 | }; 2990 | var _a; 2991 | Object.defineProperty(exports, "__esModule", { value: true }); 2992 | const assert_1 = __webpack_require__(357); 2993 | const fs = __webpack_require__(747); 2994 | const path = __webpack_require__(622); 2995 | _a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; 2996 | exports.IS_WINDOWS = process.platform === 'win32'; 2997 | function exists(fsPath) { 2998 | return __awaiter(this, void 0, void 0, function* () { 2999 | try { 3000 | yield exports.stat(fsPath); 3001 | } 3002 | catch (err) { 3003 | if (err.code === 'ENOENT') { 3004 | return false; 3005 | } 3006 | throw err; 3007 | } 3008 | return true; 3009 | }); 3010 | } 3011 | exports.exists = exists; 3012 | function isDirectory(fsPath, useStat = false) { 3013 | return __awaiter(this, void 0, void 0, function* () { 3014 | const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath); 3015 | return stats.isDirectory(); 3016 | }); 3017 | } 3018 | exports.isDirectory = isDirectory; 3019 | /** 3020 | * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: 3021 | * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases). 3022 | */ 3023 | function isRooted(p) { 3024 | p = normalizeSeparators(p); 3025 | if (!p) { 3026 | throw new Error('isRooted() parameter "p" cannot be empty'); 3027 | } 3028 | if (exports.IS_WINDOWS) { 3029 | return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello 3030 | ); // e.g. C: or C:\hello 3031 | } 3032 | return p.startsWith('/'); 3033 | } 3034 | exports.isRooted = isRooted; 3035 | /** 3036 | * Recursively create a directory at `fsPath`. 3037 | * 3038 | * This implementation is optimistic, meaning it attempts to create the full 3039 | * path first, and backs up the path stack from there. 3040 | * 3041 | * @param fsPath The path to create 3042 | * @param maxDepth The maximum recursion depth 3043 | * @param depth The current recursion depth 3044 | */ 3045 | function mkdirP(fsPath, maxDepth = 1000, depth = 1) { 3046 | return __awaiter(this, void 0, void 0, function* () { 3047 | assert_1.ok(fsPath, 'a path argument must be provided'); 3048 | fsPath = path.resolve(fsPath); 3049 | if (depth >= maxDepth) 3050 | return exports.mkdir(fsPath); 3051 | try { 3052 | yield exports.mkdir(fsPath); 3053 | return; 3054 | } 3055 | catch (err) { 3056 | switch (err.code) { 3057 | case 'ENOENT': { 3058 | yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1); 3059 | yield exports.mkdir(fsPath); 3060 | return; 3061 | } 3062 | default: { 3063 | let stats; 3064 | try { 3065 | stats = yield exports.stat(fsPath); 3066 | } 3067 | catch (err2) { 3068 | throw err; 3069 | } 3070 | if (!stats.isDirectory()) 3071 | throw err; 3072 | } 3073 | } 3074 | } 3075 | }); 3076 | } 3077 | exports.mkdirP = mkdirP; 3078 | /** 3079 | * Best effort attempt to determine whether a file exists and is executable. 3080 | * @param filePath file path to check 3081 | * @param extensions additional file extensions to try 3082 | * @return if file exists and is executable, returns the file path. otherwise empty string. 3083 | */ 3084 | function tryGetExecutablePath(filePath, extensions) { 3085 | return __awaiter(this, void 0, void 0, function* () { 3086 | let stats = undefined; 3087 | try { 3088 | // test file exists 3089 | stats = yield exports.stat(filePath); 3090 | } 3091 | catch (err) { 3092 | if (err.code !== 'ENOENT') { 3093 | // eslint-disable-next-line no-console 3094 | console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); 3095 | } 3096 | } 3097 | if (stats && stats.isFile()) { 3098 | if (exports.IS_WINDOWS) { 3099 | // on Windows, test for valid extension 3100 | const upperExt = path.extname(filePath).toUpperCase(); 3101 | if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) { 3102 | return filePath; 3103 | } 3104 | } 3105 | else { 3106 | if (isUnixExecutable(stats)) { 3107 | return filePath; 3108 | } 3109 | } 3110 | } 3111 | // try each extension 3112 | const originalFilePath = filePath; 3113 | for (const extension of extensions) { 3114 | filePath = originalFilePath + extension; 3115 | stats = undefined; 3116 | try { 3117 | stats = yield exports.stat(filePath); 3118 | } 3119 | catch (err) { 3120 | if (err.code !== 'ENOENT') { 3121 | // eslint-disable-next-line no-console 3122 | console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); 3123 | } 3124 | } 3125 | if (stats && stats.isFile()) { 3126 | if (exports.IS_WINDOWS) { 3127 | // preserve the case of the actual file (since an extension was appended) 3128 | try { 3129 | const directory = path.dirname(filePath); 3130 | const upperName = path.basename(filePath).toUpperCase(); 3131 | for (const actualName of yield exports.readdir(directory)) { 3132 | if (upperName === actualName.toUpperCase()) { 3133 | filePath = path.join(directory, actualName); 3134 | break; 3135 | } 3136 | } 3137 | } 3138 | catch (err) { 3139 | // eslint-disable-next-line no-console 3140 | console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); 3141 | } 3142 | return filePath; 3143 | } 3144 | else { 3145 | if (isUnixExecutable(stats)) { 3146 | return filePath; 3147 | } 3148 | } 3149 | } 3150 | } 3151 | return ''; 3152 | }); 3153 | } 3154 | exports.tryGetExecutablePath = tryGetExecutablePath; 3155 | function normalizeSeparators(p) { 3156 | p = p || ''; 3157 | if (exports.IS_WINDOWS) { 3158 | // convert slashes on Windows 3159 | p = p.replace(/\//g, '\\'); 3160 | // remove redundant slashes 3161 | return p.replace(/\\\\+/g, '\\'); 3162 | } 3163 | // remove redundant slashes 3164 | return p.replace(/\/\/+/g, '/'); 3165 | } 3166 | // on Mac/Linux, test the execute bit 3167 | // R W X R W X R W X 3168 | // 256 128 64 32 16 8 4 2 1 3169 | function isUnixExecutable(stats) { 3170 | return ((stats.mode & 1) > 0 || 3171 | ((stats.mode & 8) > 0 && stats.gid === process.getgid()) || 3172 | ((stats.mode & 64) > 0 && stats.uid === process.getuid())); 3173 | } 3174 | //# sourceMappingURL=io-util.js.map 3175 | 3176 | /***/ }), 3177 | 3178 | /***/ 742: 3179 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 3180 | 3181 | "use strict"; 3182 | 3183 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3184 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 3185 | return new (P || (P = Promise))(function (resolve, reject) { 3186 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 3187 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 3188 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 3189 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 3190 | }); 3191 | }; 3192 | Object.defineProperty(exports, "__esModule", { value: true }); 3193 | exports.OidcClient = void 0; 3194 | const http_client_1 = __webpack_require__(993); 3195 | const auth_1 = __webpack_require__(363); 3196 | const core_1 = __webpack_require__(470); 3197 | class OidcClient { 3198 | static createHttpClient(allowRetry = true, maxRetry = 10) { 3199 | const requestOptions = { 3200 | allowRetries: allowRetry, 3201 | maxRetries: maxRetry 3202 | }; 3203 | return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions); 3204 | } 3205 | static getRequestToken() { 3206 | const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN']; 3207 | if (!token) { 3208 | throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable'); 3209 | } 3210 | return token; 3211 | } 3212 | static getIDTokenUrl() { 3213 | const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']; 3214 | if (!runtimeUrl) { 3215 | throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable'); 3216 | } 3217 | return runtimeUrl; 3218 | } 3219 | static getCall(id_token_url) { 3220 | var _a; 3221 | return __awaiter(this, void 0, void 0, function* () { 3222 | const httpclient = OidcClient.createHttpClient(); 3223 | const res = yield httpclient 3224 | .getJson(id_token_url) 3225 | .catch(error => { 3226 | throw new Error(`Failed to get ID Token. \n 3227 | Error Code : ${error.statusCode}\n 3228 | Error Message: ${error.result.message}`); 3229 | }); 3230 | const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; 3231 | if (!id_token) { 3232 | throw new Error('Response json body do not have ID Token field'); 3233 | } 3234 | return id_token; 3235 | }); 3236 | } 3237 | static getIDToken(audience) { 3238 | return __awaiter(this, void 0, void 0, function* () { 3239 | try { 3240 | // New ID Token is requested from action service 3241 | let id_token_url = OidcClient.getIDTokenUrl(); 3242 | if (audience) { 3243 | const encodedAudience = encodeURIComponent(audience); 3244 | id_token_url = `${id_token_url}&audience=${encodedAudience}`; 3245 | } 3246 | core_1.debug(`ID token url is ${id_token_url}`); 3247 | const id_token = yield OidcClient.getCall(id_token_url); 3248 | core_1.setSecret(id_token); 3249 | return id_token; 3250 | } 3251 | catch (error) { 3252 | throw new Error(`Error message: ${error.message}`); 3253 | } 3254 | }); 3255 | } 3256 | } 3257 | exports.OidcClient = OidcClient; 3258 | //# sourceMappingURL=oidc-utils.js.map 3259 | 3260 | /***/ }), 3261 | 3262 | /***/ 747: 3263 | /***/ (function(module) { 3264 | 3265 | module.exports = require("fs"); 3266 | 3267 | /***/ }), 3268 | 3269 | /***/ 810: 3270 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 3271 | 3272 | "use strict"; 3273 | 3274 | 3275 | Object.defineProperty(exports, "__esModule", { 3276 | value: true 3277 | }); 3278 | exports.default = void 0; 3279 | 3280 | var _rng = _interopRequireDefault(__webpack_require__(506)); 3281 | 3282 | var _stringify = _interopRequireDefault(__webpack_require__(960)); 3283 | 3284 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3285 | 3286 | // **`v1()` - Generate time-based UUID** 3287 | // 3288 | // Inspired by https://github.com/LiosK/UUID.js 3289 | // and http://docs.python.org/library/uuid.html 3290 | let _nodeId; 3291 | 3292 | let _clockseq; // Previous uuid creation time 3293 | 3294 | 3295 | let _lastMSecs = 0; 3296 | let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details 3297 | 3298 | function v1(options, buf, offset) { 3299 | let i = buf && offset || 0; 3300 | const b = buf || new Array(16); 3301 | options = options || {}; 3302 | let node = options.node || _nodeId; 3303 | let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not 3304 | // specified. We do this lazily to minimize issues related to insufficient 3305 | // system entropy. See #189 3306 | 3307 | if (node == null || clockseq == null) { 3308 | const seedBytes = options.random || (options.rng || _rng.default)(); 3309 | 3310 | if (node == null) { 3311 | // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) 3312 | node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; 3313 | } 3314 | 3315 | if (clockseq == null) { 3316 | // Per 4.2.2, randomize (14 bit) clockseq 3317 | clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; 3318 | } 3319 | } // UUID timestamps are 100 nano-second units since the Gregorian epoch, 3320 | // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so 3321 | // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' 3322 | // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. 3323 | 3324 | 3325 | let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock 3326 | // cycle to simulate higher resolution clock 3327 | 3328 | let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) 3329 | 3330 | const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression 3331 | 3332 | if (dt < 0 && options.clockseq === undefined) { 3333 | clockseq = clockseq + 1 & 0x3fff; 3334 | } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new 3335 | // time interval 3336 | 3337 | 3338 | if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { 3339 | nsecs = 0; 3340 | } // Per 4.2.1.2 Throw error if too many uuids are requested 3341 | 3342 | 3343 | if (nsecs >= 10000) { 3344 | throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); 3345 | } 3346 | 3347 | _lastMSecs = msecs; 3348 | _lastNSecs = nsecs; 3349 | _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch 3350 | 3351 | msecs += 12219292800000; // `time_low` 3352 | 3353 | const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; 3354 | b[i++] = tl >>> 24 & 0xff; 3355 | b[i++] = tl >>> 16 & 0xff; 3356 | b[i++] = tl >>> 8 & 0xff; 3357 | b[i++] = tl & 0xff; // `time_mid` 3358 | 3359 | const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; 3360 | b[i++] = tmh >>> 8 & 0xff; 3361 | b[i++] = tmh & 0xff; // `time_high_and_version` 3362 | 3363 | b[i++] = tmh >>> 24 & 0xf | 0x10; // include version 3364 | 3365 | b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) 3366 | 3367 | b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` 3368 | 3369 | b[i++] = clockseq & 0xff; // `node` 3370 | 3371 | for (let n = 0; n < 6; ++n) { 3372 | b[i + n] = node[n]; 3373 | } 3374 | 3375 | return buf || (0, _stringify.default)(b); 3376 | } 3377 | 3378 | var _default = v1; 3379 | exports.default = _default; 3380 | 3381 | /***/ }), 3382 | 3383 | /***/ 960: 3384 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 3385 | 3386 | "use strict"; 3387 | 3388 | 3389 | Object.defineProperty(exports, "__esModule", { 3390 | value: true 3391 | }); 3392 | exports.default = void 0; 3393 | 3394 | var _validate = _interopRequireDefault(__webpack_require__(634)); 3395 | 3396 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3397 | 3398 | /** 3399 | * Convert array of 16 byte values to UUID string format of the form: 3400 | * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 3401 | */ 3402 | const byteToHex = []; 3403 | 3404 | for (let i = 0; i < 256; ++i) { 3405 | byteToHex.push((i + 0x100).toString(16).substr(1)); 3406 | } 3407 | 3408 | function stringify(arr, offset = 0) { 3409 | // Note: Be careful editing this code! It's been tuned for performance 3410 | // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 3411 | 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 3412 | // of the following: 3413 | // - One or more input array values don't map to a hex octet (leading to 3414 | // "undefined" in the uuid) 3415 | // - Invalid input values for the RFC `version` or `variant` fields 3416 | 3417 | if (!(0, _validate.default)(uuid)) { 3418 | throw TypeError('Stringified UUID is invalid'); 3419 | } 3420 | 3421 | return uuid; 3422 | } 3423 | 3424 | var _default = stringify; 3425 | exports.default = _default; 3426 | 3427 | /***/ }), 3428 | 3429 | /***/ 986: 3430 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 3431 | 3432 | "use strict"; 3433 | 3434 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3435 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 3436 | return new (P || (P = Promise))(function (resolve, reject) { 3437 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 3438 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 3439 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 3440 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 3441 | }); 3442 | }; 3443 | Object.defineProperty(exports, "__esModule", { value: true }); 3444 | const tr = __webpack_require__(9); 3445 | /** 3446 | * Exec a command. 3447 | * Output will be streamed to the live console. 3448 | * Returns promise with return code 3449 | * 3450 | * @param commandLine command to execute (can include additional args). Must be correctly escaped. 3451 | * @param args optional arguments for tool. Escaping is handled by the lib. 3452 | * @param options optional exec options. See ExecOptions 3453 | * @returns Promise exit code 3454 | */ 3455 | function exec(commandLine, args, options) { 3456 | return __awaiter(this, void 0, void 0, function* () { 3457 | const commandArgs = tr.argStringToArray(commandLine); 3458 | if (commandArgs.length === 0) { 3459 | throw new Error(`Parameter 'commandLine' cannot be null or empty.`); 3460 | } 3461 | // Path to tool to execute should be first arg 3462 | const toolPath = commandArgs[0]; 3463 | args = commandArgs.slice(1).concat(args || []); 3464 | const runner = new tr.ToolRunner(toolPath, args, options); 3465 | return runner.exec(); 3466 | }); 3467 | } 3468 | exports.exec = exec; 3469 | //# sourceMappingURL=exec.js.map 3470 | 3471 | /***/ }), 3472 | 3473 | /***/ 993: 3474 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 3475 | 3476 | "use strict"; 3477 | 3478 | /* eslint-disable @typescript-eslint/no-explicit-any */ 3479 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3480 | if (k2 === undefined) k2 = k; 3481 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 3482 | }) : (function(o, m, k, k2) { 3483 | if (k2 === undefined) k2 = k; 3484 | o[k2] = m[k]; 3485 | })); 3486 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 3487 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 3488 | }) : function(o, v) { 3489 | o["default"] = v; 3490 | }); 3491 | var __importStar = (this && this.__importStar) || function (mod) { 3492 | if (mod && mod.__esModule) return mod; 3493 | var result = {}; 3494 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 3495 | __setModuleDefault(result, mod); 3496 | return result; 3497 | }; 3498 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3499 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 3500 | return new (P || (P = Promise))(function (resolve, reject) { 3501 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 3502 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 3503 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 3504 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 3505 | }); 3506 | }; 3507 | Object.defineProperty(exports, "__esModule", { value: true }); 3508 | exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; 3509 | const http = __importStar(__webpack_require__(605)); 3510 | const https = __importStar(__webpack_require__(211)); 3511 | const pm = __importStar(__webpack_require__(95)); 3512 | const tunnel = __importStar(__webpack_require__(413)); 3513 | var HttpCodes; 3514 | (function (HttpCodes) { 3515 | HttpCodes[HttpCodes["OK"] = 200] = "OK"; 3516 | HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; 3517 | HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; 3518 | HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; 3519 | HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; 3520 | HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; 3521 | HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; 3522 | HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; 3523 | HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; 3524 | HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; 3525 | HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; 3526 | HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; 3527 | HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; 3528 | HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; 3529 | HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; 3530 | HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; 3531 | HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; 3532 | HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; 3533 | HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; 3534 | HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; 3535 | HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; 3536 | HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; 3537 | HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; 3538 | HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; 3539 | HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; 3540 | HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; 3541 | HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; 3542 | })(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); 3543 | var Headers; 3544 | (function (Headers) { 3545 | Headers["Accept"] = "accept"; 3546 | Headers["ContentType"] = "content-type"; 3547 | })(Headers = exports.Headers || (exports.Headers = {})); 3548 | var MediaTypes; 3549 | (function (MediaTypes) { 3550 | MediaTypes["ApplicationJson"] = "application/json"; 3551 | })(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); 3552 | /** 3553 | * Returns the proxy URL, depending upon the supplied url and proxy environment variables. 3554 | * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com 3555 | */ 3556 | function getProxyUrl(serverUrl) { 3557 | const proxyUrl = pm.getProxyUrl(new URL(serverUrl)); 3558 | return proxyUrl ? proxyUrl.href : ''; 3559 | } 3560 | exports.getProxyUrl = getProxyUrl; 3561 | const HttpRedirectCodes = [ 3562 | HttpCodes.MovedPermanently, 3563 | HttpCodes.ResourceMoved, 3564 | HttpCodes.SeeOther, 3565 | HttpCodes.TemporaryRedirect, 3566 | HttpCodes.PermanentRedirect 3567 | ]; 3568 | const HttpResponseRetryCodes = [ 3569 | HttpCodes.BadGateway, 3570 | HttpCodes.ServiceUnavailable, 3571 | HttpCodes.GatewayTimeout 3572 | ]; 3573 | const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; 3574 | const ExponentialBackoffCeiling = 10; 3575 | const ExponentialBackoffTimeSlice = 5; 3576 | class HttpClientError extends Error { 3577 | constructor(message, statusCode) { 3578 | super(message); 3579 | this.name = 'HttpClientError'; 3580 | this.statusCode = statusCode; 3581 | Object.setPrototypeOf(this, HttpClientError.prototype); 3582 | } 3583 | } 3584 | exports.HttpClientError = HttpClientError; 3585 | class HttpClientResponse { 3586 | constructor(message) { 3587 | this.message = message; 3588 | } 3589 | readBody() { 3590 | return __awaiter(this, void 0, void 0, function* () { 3591 | return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { 3592 | let output = Buffer.alloc(0); 3593 | this.message.on('data', (chunk) => { 3594 | output = Buffer.concat([output, chunk]); 3595 | }); 3596 | this.message.on('end', () => { 3597 | resolve(output.toString()); 3598 | }); 3599 | })); 3600 | }); 3601 | } 3602 | } 3603 | exports.HttpClientResponse = HttpClientResponse; 3604 | function isHttps(requestUrl) { 3605 | const parsedUrl = new URL(requestUrl); 3606 | return parsedUrl.protocol === 'https:'; 3607 | } 3608 | exports.isHttps = isHttps; 3609 | class HttpClient { 3610 | constructor(userAgent, handlers, requestOptions) { 3611 | this._ignoreSslError = false; 3612 | this._allowRedirects = true; 3613 | this._allowRedirectDowngrade = false; 3614 | this._maxRedirects = 50; 3615 | this._allowRetries = false; 3616 | this._maxRetries = 1; 3617 | this._keepAlive = false; 3618 | this._disposed = false; 3619 | this.userAgent = userAgent; 3620 | this.handlers = handlers || []; 3621 | this.requestOptions = requestOptions; 3622 | if (requestOptions) { 3623 | if (requestOptions.ignoreSslError != null) { 3624 | this._ignoreSslError = requestOptions.ignoreSslError; 3625 | } 3626 | this._socketTimeout = requestOptions.socketTimeout; 3627 | if (requestOptions.allowRedirects != null) { 3628 | this._allowRedirects = requestOptions.allowRedirects; 3629 | } 3630 | if (requestOptions.allowRedirectDowngrade != null) { 3631 | this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; 3632 | } 3633 | if (requestOptions.maxRedirects != null) { 3634 | this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); 3635 | } 3636 | if (requestOptions.keepAlive != null) { 3637 | this._keepAlive = requestOptions.keepAlive; 3638 | } 3639 | if (requestOptions.allowRetries != null) { 3640 | this._allowRetries = requestOptions.allowRetries; 3641 | } 3642 | if (requestOptions.maxRetries != null) { 3643 | this._maxRetries = requestOptions.maxRetries; 3644 | } 3645 | } 3646 | } 3647 | options(requestUrl, additionalHeaders) { 3648 | return __awaiter(this, void 0, void 0, function* () { 3649 | return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); 3650 | }); 3651 | } 3652 | get(requestUrl, additionalHeaders) { 3653 | return __awaiter(this, void 0, void 0, function* () { 3654 | return this.request('GET', requestUrl, null, additionalHeaders || {}); 3655 | }); 3656 | } 3657 | del(requestUrl, additionalHeaders) { 3658 | return __awaiter(this, void 0, void 0, function* () { 3659 | return this.request('DELETE', requestUrl, null, additionalHeaders || {}); 3660 | }); 3661 | } 3662 | post(requestUrl, data, additionalHeaders) { 3663 | return __awaiter(this, void 0, void 0, function* () { 3664 | return this.request('POST', requestUrl, data, additionalHeaders || {}); 3665 | }); 3666 | } 3667 | patch(requestUrl, data, additionalHeaders) { 3668 | return __awaiter(this, void 0, void 0, function* () { 3669 | return this.request('PATCH', requestUrl, data, additionalHeaders || {}); 3670 | }); 3671 | } 3672 | put(requestUrl, data, additionalHeaders) { 3673 | return __awaiter(this, void 0, void 0, function* () { 3674 | return this.request('PUT', requestUrl, data, additionalHeaders || {}); 3675 | }); 3676 | } 3677 | head(requestUrl, additionalHeaders) { 3678 | return __awaiter(this, void 0, void 0, function* () { 3679 | return this.request('HEAD', requestUrl, null, additionalHeaders || {}); 3680 | }); 3681 | } 3682 | sendStream(verb, requestUrl, stream, additionalHeaders) { 3683 | return __awaiter(this, void 0, void 0, function* () { 3684 | return this.request(verb, requestUrl, stream, additionalHeaders); 3685 | }); 3686 | } 3687 | /** 3688 | * Gets a typed object from an endpoint 3689 | * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise 3690 | */ 3691 | getJson(requestUrl, additionalHeaders = {}) { 3692 | return __awaiter(this, void 0, void 0, function* () { 3693 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 3694 | const res = yield this.get(requestUrl, additionalHeaders); 3695 | return this._processResponse(res, this.requestOptions); 3696 | }); 3697 | } 3698 | postJson(requestUrl, obj, additionalHeaders = {}) { 3699 | return __awaiter(this, void 0, void 0, function* () { 3700 | const data = JSON.stringify(obj, null, 2); 3701 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 3702 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 3703 | const res = yield this.post(requestUrl, data, additionalHeaders); 3704 | return this._processResponse(res, this.requestOptions); 3705 | }); 3706 | } 3707 | putJson(requestUrl, obj, additionalHeaders = {}) { 3708 | return __awaiter(this, void 0, void 0, function* () { 3709 | const data = JSON.stringify(obj, null, 2); 3710 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 3711 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 3712 | const res = yield this.put(requestUrl, data, additionalHeaders); 3713 | return this._processResponse(res, this.requestOptions); 3714 | }); 3715 | } 3716 | patchJson(requestUrl, obj, additionalHeaders = {}) { 3717 | return __awaiter(this, void 0, void 0, function* () { 3718 | const data = JSON.stringify(obj, null, 2); 3719 | additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); 3720 | additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); 3721 | const res = yield this.patch(requestUrl, data, additionalHeaders); 3722 | return this._processResponse(res, this.requestOptions); 3723 | }); 3724 | } 3725 | /** 3726 | * Makes a raw http request. 3727 | * All other methods such as get, post, patch, and request ultimately call this. 3728 | * Prefer get, del, post and patch 3729 | */ 3730 | request(verb, requestUrl, data, headers) { 3731 | return __awaiter(this, void 0, void 0, function* () { 3732 | if (this._disposed) { 3733 | throw new Error('Client has already been disposed.'); 3734 | } 3735 | const parsedUrl = new URL(requestUrl); 3736 | let info = this._prepareRequest(verb, parsedUrl, headers); 3737 | // Only perform retries on reads since writes may not be idempotent. 3738 | const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) 3739 | ? this._maxRetries + 1 3740 | : 1; 3741 | let numTries = 0; 3742 | let response; 3743 | do { 3744 | response = yield this.requestRaw(info, data); 3745 | // Check if it's an authentication challenge 3746 | if (response && 3747 | response.message && 3748 | response.message.statusCode === HttpCodes.Unauthorized) { 3749 | let authenticationHandler; 3750 | for (const handler of this.handlers) { 3751 | if (handler.canHandleAuthentication(response)) { 3752 | authenticationHandler = handler; 3753 | break; 3754 | } 3755 | } 3756 | if (authenticationHandler) { 3757 | return authenticationHandler.handleAuthentication(this, info, data); 3758 | } 3759 | else { 3760 | // We have received an unauthorized response but have no handlers to handle it. 3761 | // Let the response return to the caller. 3762 | return response; 3763 | } 3764 | } 3765 | let redirectsRemaining = this._maxRedirects; 3766 | while (response.message.statusCode && 3767 | HttpRedirectCodes.includes(response.message.statusCode) && 3768 | this._allowRedirects && 3769 | redirectsRemaining > 0) { 3770 | const redirectUrl = response.message.headers['location']; 3771 | if (!redirectUrl) { 3772 | // if there's no location to redirect to, we won't 3773 | break; 3774 | } 3775 | const parsedRedirectUrl = new URL(redirectUrl); 3776 | if (parsedUrl.protocol === 'https:' && 3777 | parsedUrl.protocol !== parsedRedirectUrl.protocol && 3778 | !this._allowRedirectDowngrade) { 3779 | 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.'); 3780 | } 3781 | // we need to finish reading the response before reassigning response 3782 | // which will leak the open socket. 3783 | yield response.readBody(); 3784 | // strip authorization header if redirected to a different hostname 3785 | if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { 3786 | for (const header in headers) { 3787 | // header names are case insensitive 3788 | if (header.toLowerCase() === 'authorization') { 3789 | delete headers[header]; 3790 | } 3791 | } 3792 | } 3793 | // let's make the request with the new redirectUrl 3794 | info = this._prepareRequest(verb, parsedRedirectUrl, headers); 3795 | response = yield this.requestRaw(info, data); 3796 | redirectsRemaining--; 3797 | } 3798 | if (!response.message.statusCode || 3799 | !HttpResponseRetryCodes.includes(response.message.statusCode)) { 3800 | // If not a retry code, return immediately instead of retrying 3801 | return response; 3802 | } 3803 | numTries += 1; 3804 | if (numTries < maxTries) { 3805 | yield response.readBody(); 3806 | yield this._performExponentialBackoff(numTries); 3807 | } 3808 | } while (numTries < maxTries); 3809 | return response; 3810 | }); 3811 | } 3812 | /** 3813 | * Needs to be called if keepAlive is set to true in request options. 3814 | */ 3815 | dispose() { 3816 | if (this._agent) { 3817 | this._agent.destroy(); 3818 | } 3819 | this._disposed = true; 3820 | } 3821 | /** 3822 | * Raw request. 3823 | * @param info 3824 | * @param data 3825 | */ 3826 | requestRaw(info, data) { 3827 | return __awaiter(this, void 0, void 0, function* () { 3828 | return new Promise((resolve, reject) => { 3829 | function callbackForResult(err, res) { 3830 | if (err) { 3831 | reject(err); 3832 | } 3833 | else if (!res) { 3834 | // If `err` is not passed, then `res` must be passed. 3835 | reject(new Error('Unknown error')); 3836 | } 3837 | else { 3838 | resolve(res); 3839 | } 3840 | } 3841 | this.requestRawWithCallback(info, data, callbackForResult); 3842 | }); 3843 | }); 3844 | } 3845 | /** 3846 | * Raw request with callback. 3847 | * @param info 3848 | * @param data 3849 | * @param onResult 3850 | */ 3851 | requestRawWithCallback(info, data, onResult) { 3852 | if (typeof data === 'string') { 3853 | if (!info.options.headers) { 3854 | info.options.headers = {}; 3855 | } 3856 | info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); 3857 | } 3858 | let callbackCalled = false; 3859 | function handleResult(err, res) { 3860 | if (!callbackCalled) { 3861 | callbackCalled = true; 3862 | onResult(err, res); 3863 | } 3864 | } 3865 | const req = info.httpModule.request(info.options, (msg) => { 3866 | const res = new HttpClientResponse(msg); 3867 | handleResult(undefined, res); 3868 | }); 3869 | let socket; 3870 | req.on('socket', sock => { 3871 | socket = sock; 3872 | }); 3873 | // If we ever get disconnected, we want the socket to timeout eventually 3874 | req.setTimeout(this._socketTimeout || 3 * 60000, () => { 3875 | if (socket) { 3876 | socket.end(); 3877 | } 3878 | handleResult(new Error(`Request timeout: ${info.options.path}`)); 3879 | }); 3880 | req.on('error', function (err) { 3881 | // err has statusCode property 3882 | // res should have headers 3883 | handleResult(err); 3884 | }); 3885 | if (data && typeof data === 'string') { 3886 | req.write(data, 'utf8'); 3887 | } 3888 | if (data && typeof data !== 'string') { 3889 | data.on('close', function () { 3890 | req.end(); 3891 | }); 3892 | data.pipe(req); 3893 | } 3894 | else { 3895 | req.end(); 3896 | } 3897 | } 3898 | /** 3899 | * Gets an http agent. This function is useful when you need an http agent that handles 3900 | * routing through a proxy server - depending upon the url and proxy environment variables. 3901 | * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com 3902 | */ 3903 | getAgent(serverUrl) { 3904 | const parsedUrl = new URL(serverUrl); 3905 | return this._getAgent(parsedUrl); 3906 | } 3907 | _prepareRequest(method, requestUrl, headers) { 3908 | const info = {}; 3909 | info.parsedUrl = requestUrl; 3910 | const usingSsl = info.parsedUrl.protocol === 'https:'; 3911 | info.httpModule = usingSsl ? https : http; 3912 | const defaultPort = usingSsl ? 443 : 80; 3913 | info.options = {}; 3914 | info.options.host = info.parsedUrl.hostname; 3915 | info.options.port = info.parsedUrl.port 3916 | ? parseInt(info.parsedUrl.port) 3917 | : defaultPort; 3918 | info.options.path = 3919 | (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); 3920 | info.options.method = method; 3921 | info.options.headers = this._mergeHeaders(headers); 3922 | if (this.userAgent != null) { 3923 | info.options.headers['user-agent'] = this.userAgent; 3924 | } 3925 | info.options.agent = this._getAgent(info.parsedUrl); 3926 | // gives handlers an opportunity to participate 3927 | if (this.handlers) { 3928 | for (const handler of this.handlers) { 3929 | handler.prepareRequest(info.options); 3930 | } 3931 | } 3932 | return info; 3933 | } 3934 | _mergeHeaders(headers) { 3935 | if (this.requestOptions && this.requestOptions.headers) { 3936 | return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {})); 3937 | } 3938 | return lowercaseKeys(headers || {}); 3939 | } 3940 | _getExistingOrDefaultHeader(additionalHeaders, header, _default) { 3941 | let clientHeader; 3942 | if (this.requestOptions && this.requestOptions.headers) { 3943 | clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; 3944 | } 3945 | return additionalHeaders[header] || clientHeader || _default; 3946 | } 3947 | _getAgent(parsedUrl) { 3948 | let agent; 3949 | const proxyUrl = pm.getProxyUrl(parsedUrl); 3950 | const useProxy = proxyUrl && proxyUrl.hostname; 3951 | if (this._keepAlive && useProxy) { 3952 | agent = this._proxyAgent; 3953 | } 3954 | if (this._keepAlive && !useProxy) { 3955 | agent = this._agent; 3956 | } 3957 | // if agent is already assigned use that agent. 3958 | if (agent) { 3959 | return agent; 3960 | } 3961 | const usingSsl = parsedUrl.protocol === 'https:'; 3962 | let maxSockets = 100; 3963 | if (this.requestOptions) { 3964 | maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; 3965 | } 3966 | // This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis. 3967 | if (proxyUrl && proxyUrl.hostname) { 3968 | const agentOptions = { 3969 | maxSockets, 3970 | keepAlive: this._keepAlive, 3971 | proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && { 3972 | proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` 3973 | })), { host: proxyUrl.hostname, port: proxyUrl.port }) 3974 | }; 3975 | let tunnelAgent; 3976 | const overHttps = proxyUrl.protocol === 'https:'; 3977 | if (usingSsl) { 3978 | tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; 3979 | } 3980 | else { 3981 | tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; 3982 | } 3983 | agent = tunnelAgent(agentOptions); 3984 | this._proxyAgent = agent; 3985 | } 3986 | // if reusing agent across request and tunneling agent isn't assigned create a new agent 3987 | if (this._keepAlive && !agent) { 3988 | const options = { keepAlive: this._keepAlive, maxSockets }; 3989 | agent = usingSsl ? new https.Agent(options) : new http.Agent(options); 3990 | this._agent = agent; 3991 | } 3992 | // if not using private agent and tunnel agent isn't setup then use global agent 3993 | if (!agent) { 3994 | agent = usingSsl ? https.globalAgent : http.globalAgent; 3995 | } 3996 | if (usingSsl && this._ignoreSslError) { 3997 | // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process 3998 | // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options 3999 | // we have to cast it to any and change it directly 4000 | agent.options = Object.assign(agent.options || {}, { 4001 | rejectUnauthorized: false 4002 | }); 4003 | } 4004 | return agent; 4005 | } 4006 | _performExponentialBackoff(retryNumber) { 4007 | return __awaiter(this, void 0, void 0, function* () { 4008 | retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); 4009 | const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); 4010 | return new Promise(resolve => setTimeout(() => resolve(), ms)); 4011 | }); 4012 | } 4013 | _processResponse(res, options) { 4014 | return __awaiter(this, void 0, void 0, function* () { 4015 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { 4016 | const statusCode = res.message.statusCode || 0; 4017 | const response = { 4018 | statusCode, 4019 | result: null, 4020 | headers: {} 4021 | }; 4022 | // not found leads to null obj returned 4023 | if (statusCode === HttpCodes.NotFound) { 4024 | resolve(response); 4025 | } 4026 | // get the result from the body 4027 | function dateTimeDeserializer(key, value) { 4028 | if (typeof value === 'string') { 4029 | const a = new Date(value); 4030 | if (!isNaN(a.valueOf())) { 4031 | return a; 4032 | } 4033 | } 4034 | return value; 4035 | } 4036 | let obj; 4037 | let contents; 4038 | try { 4039 | contents = yield res.readBody(); 4040 | if (contents && contents.length > 0) { 4041 | if (options && options.deserializeDates) { 4042 | obj = JSON.parse(contents, dateTimeDeserializer); 4043 | } 4044 | else { 4045 | obj = JSON.parse(contents); 4046 | } 4047 | response.result = obj; 4048 | } 4049 | response.headers = res.message.headers; 4050 | } 4051 | catch (err) { 4052 | // Invalid resource (contents not json); leaving result obj null 4053 | } 4054 | // note that 3xx redirects are handled by the http layer. 4055 | if (statusCode > 299) { 4056 | let msg; 4057 | // if exception/error in body, attempt to get better error 4058 | if (obj && obj.message) { 4059 | msg = obj.message; 4060 | } 4061 | else if (contents && contents.length > 0) { 4062 | // it may be the case that the exception is in the body message as string 4063 | msg = contents; 4064 | } 4065 | else { 4066 | msg = `Failed request: (${statusCode})`; 4067 | } 4068 | const err = new HttpClientError(msg, statusCode); 4069 | err.result = response.result; 4070 | reject(err); 4071 | } 4072 | else { 4073 | resolve(response); 4074 | } 4075 | })); 4076 | }); 4077 | } 4078 | } 4079 | exports.HttpClient = HttpClient; 4080 | const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); 4081 | //# sourceMappingURL=index.js.map 4082 | 4083 | /***/ }) 4084 | 4085 | /******/ }); -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | clearMocks: true, 3 | moduleFileExtensions: ['js', 'ts'], 4 | testEnvironment: 'node', 5 | testMatch: ['**/*.test.ts'], 6 | testRunner: 'jest-circus/runner', 7 | transform: { 8 | '^.+\\.ts$': 'ts-jest' 9 | }, 10 | verbose: true 11 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "setup-msbuild", 3 | "version": "2.0.0", 4 | "private": true, 5 | "description": "Helps set up specific MSBuild tool into PATH for later usage.", 6 | "main": "lib/main.js", 7 | "scripts": { 8 | "build": "tsc", 9 | "format": "prettier --write **/*.ts", 10 | "format-check": "prettier --check **/*.ts", 11 | "lint": "eslint src/**/*.ts", 12 | "pack": "ncc build", 13 | "test": "jest", 14 | "all": "npm run build && npm run format && npm run lint && npm run pack" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/microsoft/setup-msbuild.git" 19 | }, 20 | "keywords": [ 21 | "actions", 22 | "vs", 23 | "setup", 24 | "visual studio", 25 | "msbuild", 26 | "vstest" 27 | ], 28 | "author": "Microsoft", 29 | "license": "MIT", 30 | "dependencies": { 31 | "@actions/core": "^1.10.0", 32 | "@actions/exec": "^1.0.3", 33 | "@actions/tool-cache": "^1.3.0" 34 | }, 35 | "devDependencies": { 36 | "@types/jest": "^24.0.23", 37 | "@types/node": "^12.12.25", 38 | "@typescript-eslint/parser": "^2.8.0", 39 | "@zeit/ncc": "^0.20.5", 40 | "eslint": "^5.16.0", 41 | "eslint-plugin-github": "^2.0.0", 42 | "eslint-plugin-jest": "^22.21.0", 43 | "jest": "^24.9.0", 44 | "jest-circus": "^24.9.0", 45 | "js-yaml": "^3.13.1", 46 | "prettier": "^1.19.1", 47 | "ts-jest": "^24.2.0", 48 | "typescript": "^3.6.4" 49 | } 50 | } -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import * as exec from '@actions/exec' 3 | import * as fs from 'fs' 4 | import * as path from 'path' 5 | import * as io from '@actions/io' 6 | import {ExecOptions} from '@actions/exec/lib/interfaces' 7 | 8 | const IS_WINDOWS = process.platform === 'win32' 9 | const VS_VERSION = core.getInput('vs-version') || 'latest' 10 | const VSWHERE_PATH = core.getInput('vswhere-path') 11 | const ALLOW_PRERELEASE = core.getInput('vs-prerelease') || 'false' 12 | let MSBUILD_ARCH = core.getInput('msbuild-architecture') || 'x86' 13 | 14 | // if a specific version of VS is requested 15 | let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest ' 16 | if (ALLOW_PRERELEASE === 'true') { 17 | VSWHERE_EXEC += ' -prerelease ' 18 | } 19 | 20 | if (VS_VERSION !== 'latest') { 21 | VSWHERE_EXEC += `-version "${VS_VERSION}" ` 22 | } 23 | 24 | core.debug(`Execution arguments: ${VSWHERE_EXEC}`) 25 | 26 | async function run(): Promise { 27 | try { 28 | // exit if non Windows runner 29 | if (IS_WINDOWS === false) { 30 | core.setFailed('setup-msbuild can only be run on Windows runners') 31 | return 32 | } 33 | 34 | // check to see if we are using a specific path for vswhere 35 | let vswhereToolExe = '' 36 | 37 | if (VSWHERE_PATH) { 38 | // specified a path for vswhere, use it 39 | core.debug(`Using given vswhere-path: ${VSWHERE_PATH}`) 40 | vswhereToolExe = path.join(VSWHERE_PATH, 'vswhere.exe') 41 | } else { 42 | // check in PATH to see if it is there 43 | try { 44 | const vsWhereInPath: string = await io.which('vswhere', true) 45 | core.debug(`Found tool in PATH: ${vsWhereInPath}`) 46 | vswhereToolExe = vsWhereInPath 47 | } catch { 48 | // fall back to VS-installed path 49 | vswhereToolExe = path.join( 50 | process.env['ProgramFiles(x86)'] as string, 51 | 'Microsoft Visual Studio\\Installer\\vswhere.exe' 52 | ) 53 | core.debug(`Trying Visual Studio-installed path: ${vswhereToolExe}`) 54 | } 55 | } 56 | 57 | if (!fs.existsSync(vswhereToolExe)) { 58 | core.setFailed( 59 | 'setup-msbuild requires the path to where vswhere.exe exists' 60 | ) 61 | 62 | return 63 | } 64 | 65 | core.debug(`Full tool exe: ${vswhereToolExe}`) 66 | 67 | let foundToolPath = '' 68 | const options: ExecOptions = {} 69 | options.listeners = { 70 | stdout: (data: Buffer) => { 71 | const installationPath = data.toString().trim() 72 | core.debug(`Found installation path: ${installationPath}`) 73 | 74 | // x64 and arm64 only exist in one possible location, so no fallback probing 75 | if (MSBUILD_ARCH === 'x64' || MSBUILD_ARCH === 'arm64') { 76 | // x64 is actually amd64 so change to that 77 | if (MSBUILD_ARCH === 'x64') { 78 | MSBUILD_ARCH = 'amd64' 79 | } 80 | let toolPath = path.join( 81 | installationPath, 82 | `MSBuild\\Current\\Bin\\${MSBUILD_ARCH}\\MSBuild.exe` 83 | ) 84 | core.debug(`Checking for path: ${toolPath}`) 85 | if (!fs.existsSync(toolPath)) { 86 | return 87 | } 88 | foundToolPath = toolPath 89 | } else { 90 | let toolPath = path.join( 91 | installationPath, 92 | 'MSBuild\\Current\\Bin\\MSBuild.exe' 93 | ) 94 | 95 | core.debug(`Checking for path: ${toolPath}`) 96 | if (!fs.existsSync(toolPath)) { 97 | toolPath = path.join( 98 | installationPath, 99 | 'MSBuild\\15.0\\Bin\\MSBuild.exe' 100 | ) 101 | 102 | core.debug(`Checking for path: ${toolPath}`) 103 | if (!fs.existsSync(toolPath)) { 104 | return 105 | } 106 | } 107 | 108 | foundToolPath = toolPath 109 | } 110 | } 111 | } 112 | 113 | // execute the find putting the result of the command in the options foundToolPath 114 | await exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options) 115 | 116 | if (!foundToolPath) { 117 | core.setFailed('Unable to find MSBuild.') 118 | return 119 | } 120 | 121 | // extract the folder location for the tool 122 | const toolFolderPath = path.dirname(foundToolPath) 123 | 124 | // set the outputs for the action to the folder path of msbuild 125 | core.setOutput('msbuildPath', toolFolderPath) 126 | 127 | // add tool path to PATH 128 | core.addPath(toolFolderPath) 129 | core.debug(`Tool path added to PATH: ${toolFolderPath}`) 130 | } catch (error) { 131 | core.setFailed(error.message) 132 | } 133 | } 134 | 135 | run() 136 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 4 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 5 | "outDir": "./lib", /* Redirect output structure to the directory. */ 6 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 7 | "strict": true, /* Enable all strict type-checking options. */ 8 | "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 9 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 10 | }, 11 | "exclude": ["node_modules", "**/*.test.ts"] 12 | } 13 | --------------------------------------------------------------------------------