├── .eslintignore ├── .eslintrc.json ├── .github ├── dependabot.yml └── workflows │ ├── test.yml │ └── update-dist.yml ├── .gitignore ├── .prettierignore ├── .prettierrc.json ├── LICENSE ├── README.md ├── action.yml ├── dist ├── restore │ ├── index.js │ ├── index.js.map │ └── sourcemap-register.js └── save │ ├── index.js │ ├── index.js.map │ └── sourcemap-register.js ├── package-lock.json ├── package.json ├── src ├── restore.ts └── save.ts ├── test ├── .mill-version ├── build.sc ├── cs ├── foo.sc ├── foo.sh ├── mill └── mill.bat └── tsconfig.json /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["@typescript-eslint"], 3 | "extends": ["plugin:github/typescript"], 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": "warn", 17 | "@typescript-eslint/array-type": "error", 18 | "@typescript-eslint/await-thenable": "error", 19 | "@typescript-eslint/ban-ts-comment": "error", 20 | "camelcase": "off", 21 | "@typescript-eslint/consistent-type-assertions": "error", 22 | "@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}], 23 | "@typescript-eslint/func-call-spacing": ["error", "never"], 24 | "@typescript-eslint/no-array-constructor": "error", 25 | "@typescript-eslint/no-empty-interface": "error", 26 | "@typescript-eslint/no-explicit-any": "warn", 27 | "@typescript-eslint/no-extraneous-class": "error", 28 | "@typescript-eslint/no-for-in-array": "error", 29 | "@typescript-eslint/no-inferrable-types": "error", 30 | "@typescript-eslint/no-misused-new": "error", 31 | "@typescript-eslint/no-namespace": "error", 32 | "@typescript-eslint/no-non-null-assertion": "warn", 33 | "@typescript-eslint/no-unnecessary-qualifier": "error", 34 | "@typescript-eslint/no-unnecessary-type-assertion": "error", 35 | "@typescript-eslint/no-useless-constructor": "error", 36 | "@typescript-eslint/no-var-requires": "warn", 37 | "@typescript-eslint/prefer-for-of": "warn", 38 | "@typescript-eslint/prefer-function-type": "warn", 39 | "@typescript-eslint/prefer-includes": "error", 40 | "@typescript-eslint/prefer-string-starts-ends-with": "error", 41 | "@typescript-eslint/promise-function-async": "error", 42 | "@typescript-eslint/require-array-sort-compare": "error", 43 | "@typescript-eslint/restrict-plus-operands": "error", 44 | "semi": "off", 45 | "@typescript-eslint/semi": ["error", "never"], 46 | "@typescript-eslint/type-annotation-spacing": "error", 47 | "@typescript-eslint/unbound-method": "error", 48 | "i18n-text/no-en": "off" 49 | }, 50 | "env": { 51 | "node": true, 52 | "es6": true 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Enable version updates for npm 4 | - package-ecosystem: 'npm' 5 | # Look for `package.json` and `lock` files in the `root` directory 6 | directory: '/' 7 | # Check the npm registry for updates every day (weekdays) 8 | schedule: 9 | interval: 'daily' 10 | - package-ecosystem: "github-actions" 11 | directory: "/" 12 | schedule: 13 | interval: "weekly" 14 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: 'build-test' 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | test: 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | platform: [ubuntu-latest, macos-latest, windows-latest] 14 | runs-on: ${{ matrix.platform }} 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/setup-node@v4 18 | with: 19 | node-version: 20 20 | cache: 'npm' 21 | - name: Build 22 | shell: bash -l {0} 23 | run: | 24 | npm ci 25 | test "$OSTYPE" != "msys" || npm run format 26 | npm run all 27 | 28 | - uses: ./ 29 | with: 30 | root: test 31 | extraFiles: test/foo.sh # for the ammonite version? 32 | 33 | - run: cd test && eval "$(./cs java --env --jvm 17)" && ./mill -i __.compile && ./foo.sh 34 | if: runner.os != 'Windows' 35 | shell: bash 36 | 37 | - run: cd test && eval "$(./cs java --env --jvm 17)" && cmd /c "mill.bat -i __.compile" && ./foo.sh 38 | if: runner.os == 'Windows' 39 | shell: bash 40 | -------------------------------------------------------------------------------- /.github/workflows/update-dist.yml: -------------------------------------------------------------------------------- 1 | name: Update dist 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | update-dist: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | - uses: actions/setup-node@v4 13 | with: 14 | node-version: 20 15 | cache: 'npm' 16 | - name: Build 17 | shell: bash -l {0} 18 | run: | 19 | npm ci 20 | test "$OSTYPE" != "msys" || npm run format 21 | npm run all 22 | 23 | - name: Create Pull Request 24 | id: cpr 25 | uses: peter-evans/create-pull-request@v7 26 | with: 27 | commit-message: Update dist 28 | author: GitHub 29 | delete-branch: true 30 | title: Update dist 31 | 32 | - name: Check Pull Request 33 | run: | 34 | echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" 35 | echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" 36 | -------------------------------------------------------------------------------- /.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/**/* 100 | 101 | .ammonite/ 102 | -------------------------------------------------------------------------------- /.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 | } 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2018 GitHub, Inc. and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # coursier cache action 2 | 3 | A GitHub action to save / restore the coursier / sbt / mill / Ammonite caches of your build. 4 | 5 | ## Usage 6 | 7 | Add a `coursier/cache-action@v6` step to your YAML workflow, like 8 | ```yaml 9 | steps: 10 | - uses: actions/checkout@v4 11 | - uses: coursier/cache-action@v6 12 | ``` 13 | 14 | ## Cached directories 15 | 16 | ### Coursier cache 17 | 18 | Always cached. 19 | 20 | Add files to take into account in its cache key via [`extraFiles`](#extrafiles). 21 | 22 | ### `~/.sbt` and `~/.ivy2/cache` 23 | 24 | Cached when sbt files are found (any of `*.sbt`, `project/**.scala`, `project/**.sbt`, `project/build.properties`). 25 | 26 | Add files to take into account in its cache key via [`extraSbtFiles`](#extrasbtfiles). 27 | 28 | ### `~/.cache/mill` 29 | 30 | Cached when mill files are found (any of `.mill-version`, `./mill`). 31 | 32 | Add files to take into account in its cache key via [`extraMillFiles`](#extramillfiles). 33 | 34 | ### `~/.ammonite` 35 | 36 | Cached when Ammonite scripts are found (any of `*.sc`, `*/*.sc`). 37 | 38 | Add files to take into account in its cache key via [`ammoniteScripts`](#ammonitescripts). 39 | 40 | ## Parameters 41 | 42 | ### `root` 43 | 44 | *Optional* Root directory containing build definition sources (`build.sbt`, `build.sc`, etc.) 45 | 46 | If the sbt or mill build definition files are in a sub-directory, pass the path to this 47 | sub-directory here. 48 | 49 | ### `path` 50 | 51 | *Optional* Override for the path of the coursier cache. 52 | 53 | By default, the coursier cache is assumed to be in the [default OS-dependent location](https://get-coursier.io/docs/cache.html#default-location). 54 | Set this input to override that. Note that this action will also set the `COURSIER_CACHE` environment variable 55 | if an override is specified, so that you don't have to set it yourself. 56 | 57 | ### `extraFiles` 58 | 59 | *Optional* Extra files to take into account in the cache key. 60 | 61 | By default, sbt build definition files (`*.sbt`, `project/**.{scala,sbt}`, `project/build.properties`) and 62 | mill build definition files (`*.sc`, `./mill`) are hashed to uniquely identify the cached data. Upon 63 | cache restoration, if an exact match is found, the cache is not saved again at the end of the job. 64 | In case of no exact match, it is assumed new files may have been fetched; the previous cache for the 65 | current OS, if any, is restored, but a new cache is persisted with a new key at the end of the job. 66 | 67 | To take into account extra files in the cache key, pass via `extraFiles` either 68 | - a single path as a string 69 | - multiple paths in a JSON array, encoded in a string 70 | 71 | Blobs are accepted (processed by [@actions/glob](https://www.npmjs.com/package/@actions/glob)). 72 | 73 | ### `extraSbtFiles` 74 | 75 | *Optional* Extra sbt files to take into account in the sbt cache key. Same format as extraFiles. 76 | 77 | ### `extraMillFiles` 78 | 79 | *Optional* Extra mill files to take into account in the mill cache key. Same format as extraFiles. 80 | 81 | ### `ammoniteScripts` 82 | 83 | *Optional* Extra Ammonite scripts to take into account in the Ammonite cache key. Same format as extraFiles. 84 | 85 | ### `extraKey` 86 | 87 | *Optional* 88 | 89 | Extra value to be appended to the coursier cache key. 90 | 91 | See `extraFiles` for more details. 92 | 93 | ### `extraHashedContent` 94 | 95 | *Optional* 96 | 97 | Extra content to take into account in the cache key. 98 | 99 | See `extraFiles` for more details. 100 | 101 | The content of `extraHashedContent` is taken into account in the hash for the coursier cache key. 102 | 103 | ### `ignoreJob` 104 | 105 | *Optional* 106 | 107 | Default: `false` 108 | 109 | Set `true` if you don't want to use a job id as part of cache key. 110 | 111 | ### `ignoreMatrix` 112 | 113 | *Optional* 114 | 115 | Default: `false` 116 | 117 | Set `true` if you don't want to use a matrix jobs as part of cache key. 118 | 119 | ## Outputs 120 | 121 | * `cache-hit-coursier` - A boolean value to indicate a match was found for the coursier cache 122 | * `cache-hit-sbt-ivy2-cache` - A boolean value to indicate a match was found for the sbt-ivy2-cache cache 123 | * `cache-hit-mill` - A boolean value to indicate a match was found for the mill cache 124 | * `cache-hit-ammonite` - A boolean value to indicate a match was found for the ammonite cache 125 | 126 | > See [Skipping steps based on cache-hit](#Skipping-steps-based-on-cache-hit) for info on using this output 127 | 128 | ## Skipping steps based on cache-hit 129 | 130 | Using the `cache-hit-...` outputs above, subsequent steps can be skipped when a cache hit occurs on a given key. 131 | 132 | Example: 133 | ```yaml 134 | steps: 135 | - uses: actions/checkout@v3 136 | 137 | - uses: coursier/cache-action@v6 138 | id: coursier-cache 139 | 140 | - name: Fetch Dependencies 141 | if: steps.coursier-cache.outputs.cache-hit-coursier != 'true' 142 | run: sbt +update 143 | ``` 144 | 145 | > Note: The `id` defined in `coursier/cache-action` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit-coursier`) 146 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'coursier-cache-action' 2 | description: 'Restores and saves the coursier cache' 3 | author: 'Alexandre Archambault' 4 | branding: 5 | icon: 'arrow-down' 6 | color: 'white' 7 | inputs: 8 | root: 9 | required: false 10 | description: > 11 | Root directory containing build definition sources (build.sbt, build.sc, etc.) 12 | If the sbt or mill build definition files are in a sub-directory, pass the path to this 13 | sub-directory here. 14 | default: '.' 15 | path: 16 | required: false 17 | description: > 18 | Override for the path of the coursier cache. 19 | By default, the coursier cache is assumed to be in the default OS-dependent location. 20 | Set this input to override that. Note that this action will also set COURSIER_CACHE 21 | if an override is specified, so that you don't have to set it yourself. 22 | default: '' 23 | job: 24 | required: false 25 | description: > 26 | Job name, to be used in the cache key, so that each job has its own cache. 27 | default: '${{ github.job }}' 28 | matrix: 29 | required: false 30 | description: > 31 | Matrix values, when using the matrix strategy. 32 | When using build matrices for more than the OS (for Scala versions, JDKs, test suites, …), 33 | pass the matrix values here, with `matrix: -dollar-{{ toJson(matrix) }}`. The matrix instance is hashed, 34 | and added to the cache key, so that each matrix instance has its own cache, and those caches don't 35 | collide. 36 | default: '${{ toJson(matrix) }}' 37 | extraFiles: 38 | required: false 39 | description: > 40 | Extra files to take into account in the cache key. 41 | By default, sbt build definition files (*.sbt, project/**.{scala,sbt}, project/build.properties) and 42 | mill build definition files (*.sc, ./mill) are hashed to uniquely identify the cached data. Upon 43 | cache restoration, if an exact match is found, the cache is not saved again at the end of the job. 44 | In case of no exact match, it is assumed new files may have been fetched; the previous cache for the 45 | current OS, if any, is restored, but a new cache is persisted with a new key at the end of the job. 46 | To take into account extra files in the cache key, pass via extraFiles either 47 | - a single path as a string 48 | - multiple paths in a JSON array, encoded in a string 49 | Blobs are accepted (processed by [@actions/glob](https://www.npmjs.com/package/@actions/glob)). 50 | default: '' 51 | extraKey: 52 | required: false 53 | description: > 54 | Extra value to be appended to the coursier cache key. 55 | See extraFiles for more details. 56 | default: '' 57 | extraHashedContent: 58 | required: false 59 | description: > 60 | Extra content to take into account in the cache key. 61 | See extraFiles for more details. 62 | The content of extraHashedContent is taken into account in the hash for the coursier cache key. 63 | default: '' 64 | extraSbtFiles: 65 | required: false 66 | description: > 67 | Extra sbt files to take into account in the sbt cache key. Same format as extraFiles. 68 | default: '' 69 | extraSbtKey: 70 | required: false 71 | description: > 72 | Extra value to be appended to the sbt cache key. 73 | See extraFiles for more details. 74 | default: '' 75 | extraSbtHashedContent: 76 | required: false 77 | description: > 78 | Extra content to take into account in the sbt cache key. Same format as extraHashedContent. 79 | default: '' 80 | extraMillFiles: 81 | required: false 82 | description: > 83 | Extra mill files to take into account in the mill cache key. Same format as extraFiles. 84 | default: '' 85 | extraMillKey: 86 | required: false 87 | description: > 88 | Extra value to be appended to the mill cache key. 89 | See extraFiles for more details. 90 | default: '' 91 | extraMillHashedContent: 92 | required: false 93 | description: > 94 | Extra content to take into account in the mill cache key. Same format as extraHashedContent. 95 | default: '' 96 | ammoniteScripts: 97 | required: false 98 | description: > 99 | Ammonite scripts to take into account in the Ammonite cache key. Same format as extraFiles. 100 | default: '' 101 | extraAmmoniteKey: 102 | required: false 103 | description: > 104 | Extra value to be appended to the Ammonite cache key. 105 | See extraFiles for more details. 106 | default: '' 107 | extraAmmoniteHashedContent: 108 | required: false 109 | description: > 110 | Extra content to take into account in the Ammonite cache key. Same format as extraHashedContent. 111 | default: '' 112 | ignoreJob: 113 | required: false 114 | description: > 115 | Set 'true' if you don't want to use a job id as part of cache key. 116 | default: 'false' 117 | ignoreMatrix: 118 | required: false 119 | description: > 120 | Set 'true' if you don't want to use a matrix jobs as part of cache key. 121 | default: 'false' 122 | outputs: 123 | cache-hit-coursier: 124 | description: 'A boolean value to indicate a match was found for the coursier cache' 125 | cache-hit-sbt-ivy2-cache: 126 | description: 'A boolean value to indicate a match was found for the sbt-ivy2-cache cache' 127 | cache-hit-mill: 128 | description: 'A boolean value to indicate a match was found for the mill cache' 129 | cache-hit-ammonite: 130 | description: 'A boolean value to indicate a match was found for the ammonite cache' 131 | runs: 132 | using: 'node20' 133 | main: 'dist/restore/index.js' 134 | post: 'dist/save/index.js' 135 | post-if: 'success()' 136 | -------------------------------------------------------------------------------- /dist/restore/sourcemap-register.js: -------------------------------------------------------------------------------- 1 | (()=>{var e={296:e=>{var r=Object.prototype.toString;var n=typeof Buffer!=="undefined"&&typeof Buffer.alloc==="function"&&typeof Buffer.allocUnsafe==="function"&&typeof Buffer.from==="function";function isArrayBuffer(e){return r.call(e).slice(8,-1)==="ArrayBuffer"}function fromArrayBuffer(e,r,t){r>>>=0;var o=e.byteLength-r;if(o<0){throw new RangeError("'offset' is out of bounds")}if(t===undefined){t=o}else{t>>>=0;if(t>o){throw new RangeError("'length' is out of bounds")}}return n?Buffer.from(e.slice(r,r+t)):new Buffer(new Uint8Array(e.slice(r,r+t)))}function fromString(e,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}return n?Buffer.from(e,r):new Buffer(e,r)}function bufferFrom(e,r,t){if(typeof e==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(e)){return fromArrayBuffer(e,r,t)}if(typeof e==="string"){return fromString(e,r)}return n?Buffer.from(e):new Buffer(e)}e.exports=bufferFrom},599:(e,r,n)=>{e=n.nmd(e);var t=n(927).SourceMapConsumer;var o=n(928);var i;try{i=n(896);if(!i.existsSync||!i.readFileSync){i=null}}catch(e){}var a=n(296);function dynamicRequire(e,r){return e.require(r)}var u=false;var s=false;var l=false;var c="auto";var p={};var f={};var g=/^data:application\/json[^,]+base64,/;var d=[];var h=[];function isInBrowser(){if(c==="browser")return true;if(c==="node")return false;return typeof window!=="undefined"&&typeof XMLHttpRequest==="function"&&!(window.require&&window.module&&window.process&&window.process.type==="renderer")}function hasGlobalProcessEventEmitter(){return typeof process==="object"&&process!==null&&typeof process.on==="function"}function globalProcessVersion(){if(typeof process==="object"&&process!==null){return process.version}else{return""}}function globalProcessStderr(){if(typeof process==="object"&&process!==null){return process.stderr}}function globalProcessExit(e){if(typeof process==="object"&&process!==null&&typeof process.exit==="function"){return process.exit(e)}}function handlerExec(e){return function(r){for(var n=0;n"}var n=this.getLineNumber();if(n!=null){r+=":"+n;var t=this.getColumnNumber();if(t){r+=":"+t}}}var o="";var i=this.getFunctionName();var a=true;var u=this.isConstructor();var s=!(this.isToplevel()||u);if(s){var l=this.getTypeName();if(l==="[object Object]"){l="null"}var c=this.getMethodName();if(i){if(l&&i.indexOf(l)!=0){o+=l+"."}o+=i;if(c&&i.indexOf("."+c)!=i.length-c.length-1){o+=" [as "+c+"]"}}else{o+=l+"."+(c||"")}}else if(u){o+="new "+(i||"")}else if(i){o+=i}else{o+=r;a=false}if(a){o+=" ("+r+")"}return o}function cloneCallSite(e){var r={};Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(n){r[n]=/^(?:is|get)/.test(n)?function(){return e[n].call(e)}:e[n]}));r.toString=CallSiteToString;return r}function wrapCallSite(e,r){if(r===undefined){r={nextPosition:null,curPosition:null}}if(e.isNative()){r.curPosition=null;return e}var n=e.getFileName()||e.getScriptNameOrSourceURL();if(n){var t=e.getLineNumber();var o=e.getColumnNumber()-1;var i=/^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;var a=i.test(globalProcessVersion())?0:62;if(t===1&&o>a&&!isInBrowser()&&!e.isEval()){o-=a}var u=mapSourcePosition({source:n,line:t,column:o});r.curPosition=u;e=cloneCallSite(e);var s=e.getFunctionName;e.getFunctionName=function(){if(r.nextPosition==null){return s()}return r.nextPosition.name||s()};e.getFileName=function(){return u.source};e.getLineNumber=function(){return u.line};e.getColumnNumber=function(){return u.column+1};e.getScriptNameOrSourceURL=function(){return u.source};return e}var l=e.isEval()&&e.getEvalOrigin();if(l){l=mapEvalOrigin(l);e=cloneCallSite(e);e.getEvalOrigin=function(){return l};return e}return e}function prepareStackTrace(e,r){if(l){p={};f={}}var n=e.name||"Error";var t=e.message||"";var o=n+": "+t;var i={nextPosition:null,curPosition:null};var a=[];for(var u=r.length-1;u>=0;u--){a.push("\n at "+wrapCallSite(r[u],i));i.nextPosition=i.curPosition}i.curPosition=i.nextPosition=null;return o+a.reverse().join("")}function getErrorSource(e){var r=/\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(e.stack);if(r){var n=r[1];var t=+r[2];var o=+r[3];var a=p[n];if(!a&&i&&i.existsSync(n)){try{a=i.readFileSync(n,"utf8")}catch(e){a=""}}if(a){var u=a.split(/(?:\r\n|\r|\n)/)[t-1];if(u){return n+":"+t+"\n"+u+"\n"+new Array(o).join(" ")+"^"}}}return null}function printErrorAndExit(e){var r=getErrorSource(e);var n=globalProcessStderr();if(n&&n._handle&&n._handle.setBlocking){n._handle.setBlocking(true)}if(r){console.error();console.error(r)}console.error(e.stack);globalProcessExit(1)}function shimEmitUncaughtException(){var e=process.emit;process.emit=function(r){if(r==="uncaughtException"){var n=arguments[1]&&arguments[1].stack;var t=this.listeners(r).length>0;if(n&&!t){return printErrorAndExit(arguments[1])}}return e.apply(this,arguments)}}var S=d.slice(0);var _=h.slice(0);r.wrapCallSite=wrapCallSite;r.getErrorSource=getErrorSource;r.mapSourcePosition=mapSourcePosition;r.retrieveSourceMap=v;r.install=function(r){r=r||{};if(r.environment){c=r.environment;if(["node","browser","auto"].indexOf(c)===-1){throw new Error("environment "+c+" was unknown. Available options are {auto, browser, node}")}}if(r.retrieveFile){if(r.overrideRetrieveFile){d.length=0}d.unshift(r.retrieveFile)}if(r.retrieveSourceMap){if(r.overrideRetrieveSourceMap){h.length=0}h.unshift(r.retrieveSourceMap)}if(r.hookRequire&&!isInBrowser()){var n=dynamicRequire(e,"module");var t=n.prototype._compile;if(!t.__sourceMapSupport){n.prototype._compile=function(e,r){p[r]=e;f[r]=undefined;return t.call(this,e,r)};n.prototype._compile.__sourceMapSupport=true}}if(!l){l="emptyCacheBetweenOperations"in r?r.emptyCacheBetweenOperations:false}if(!u){u=true;Error.prepareStackTrace=prepareStackTrace}if(!s){var o="handleUncaughtExceptions"in r?r.handleUncaughtExceptions:true;try{var i=dynamicRequire(e,"worker_threads");if(i.isMainThread===false){o=false}}catch(e){}if(o&&hasGlobalProcessEventEmitter()){s=true;shimEmitUncaughtException()}}};r.resetRetrieveHandlers=function(){d.length=0;h.length=0;d=S.slice(0);h=_.slice(0);v=handlerExec(h);m=handlerExec(d)}},517:(e,r,n)=>{var t=n(297);var o=Object.prototype.hasOwnProperty;var i=typeof Map!=="undefined";function ArraySet(){this._array=[];this._set=i?new Map:Object.create(null)}ArraySet.fromArray=function ArraySet_fromArray(e,r){var n=new ArraySet;for(var t=0,o=e.length;t=0){return r}}else{var n=t.toSetString(e);if(o.call(this._set,n)){return this._set[n]}}throw new Error('"'+e+'" is not in the set.')};ArraySet.prototype.at=function ArraySet_at(e){if(e>=0&&e{var t=n(158);var o=5;var i=1<>1;return r?-n:n}r.encode=function base64VLQ_encode(e){var r="";var n;var i=toVLQSigned(e);do{n=i&a;i>>>=o;if(i>0){n|=u}r+=t.encode(n)}while(i>0);return r};r.decode=function base64VLQ_decode(e,r,n){var i=e.length;var s=0;var l=0;var c,p;do{if(r>=i){throw new Error("Expected more digits in base 64 VLQ value.")}p=t.decode(e.charCodeAt(r++));if(p===-1){throw new Error("Invalid base64 digit: "+e.charAt(r-1))}c=!!(p&u);p&=a;s=s+(p<{var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");r.encode=function(e){if(0<=e&&e{r.GREATEST_LOWER_BOUND=1;r.LEAST_UPPER_BOUND=2;function recursiveSearch(e,n,t,o,i,a){var u=Math.floor((n-e)/2)+e;var s=i(t,o[u],true);if(s===0){return u}else if(s>0){if(n-u>1){return recursiveSearch(u,n,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return n1){return recursiveSearch(e,u,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return u}else{return e<0?-1:e}}}r.search=function search(e,n,t,o){if(n.length===0){return-1}var i=recursiveSearch(-1,n.length,e,n,t,o||r.GREATEST_LOWER_BOUND);if(i<0){return-1}while(i-1>=0){if(t(n[i],n[i-1],true)!==0){break}--i}return i}},24:(e,r,n)=>{var t=n(297);function generatedPositionAfter(e,r){var n=e.generatedLine;var o=r.generatedLine;var i=e.generatedColumn;var a=r.generatedColumn;return o>n||o==n&&a>=i||t.compareByGeneratedPositionsInflated(e,r)<=0}function MappingList(){this._array=[];this._sorted=true;this._last={generatedLine:-1,generatedColumn:0}}MappingList.prototype.unsortedForEach=function MappingList_forEach(e,r){this._array.forEach(e,r)};MappingList.prototype.add=function MappingList_add(e){if(generatedPositionAfter(this._last,e)){this._last=e;this._array.push(e)}else{this._sorted=false;this._array.push(e)}};MappingList.prototype.toArray=function MappingList_toArray(){if(!this._sorted){this._array.sort(t.compareByGeneratedPositionsInflated);this._sorted=true}return this._array};r.P=MappingList},299:(e,r)=>{function swap(e,r,n){var t=e[r];e[r]=e[n];e[n]=t}function randomIntInRange(e,r){return Math.round(e+Math.random()*(r-e))}function doQuickSort(e,r,n,t){if(n{var t;var o=n(297);var i=n(197);var a=n(517).C;var u=n(818);var s=n(299).g;function SourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}return n.sections!=null?new IndexedSourceMapConsumer(n,r):new BasicSourceMapConsumer(n,r)}SourceMapConsumer.fromSourceMap=function(e,r){return BasicSourceMapConsumer.fromSourceMap(e,r)};SourceMapConsumer.prototype._version=3;SourceMapConsumer.prototype.__generatedMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_generatedMappings",{configurable:true,enumerable:true,get:function(){if(!this.__generatedMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__generatedMappings}});SourceMapConsumer.prototype.__originalMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_originalMappings",{configurable:true,enumerable:true,get:function(){if(!this.__originalMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__originalMappings}});SourceMapConsumer.prototype._charIsMappingSeparator=function SourceMapConsumer_charIsMappingSeparator(e,r){var n=e.charAt(r);return n===";"||n===","};SourceMapConsumer.prototype._parseMappings=function SourceMapConsumer_parseMappings(e,r){throw new Error("Subclasses must implement _parseMappings")};SourceMapConsumer.GENERATED_ORDER=1;SourceMapConsumer.ORIGINAL_ORDER=2;SourceMapConsumer.GREATEST_LOWER_BOUND=1;SourceMapConsumer.LEAST_UPPER_BOUND=2;SourceMapConsumer.prototype.eachMapping=function SourceMapConsumer_eachMapping(e,r,n){var t=r||null;var i=n||SourceMapConsumer.GENERATED_ORDER;var a;switch(i){case SourceMapConsumer.GENERATED_ORDER:a=this._generatedMappings;break;case SourceMapConsumer.ORIGINAL_ORDER:a=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var u=this.sourceRoot;a.map((function(e){var r=e.source===null?null:this._sources.at(e.source);r=o.computeSourceURL(u,r,this._sourceMapURL);return{source:r,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name===null?null:this._names.at(e.name)}}),this).forEach(e,t)};SourceMapConsumer.prototype.allGeneratedPositionsFor=function SourceMapConsumer_allGeneratedPositionsFor(e){var r=o.getArg(e,"line");var n={source:o.getArg(e,"source"),originalLine:r,originalColumn:o.getArg(e,"column",0)};n.source=this._findSourceIndex(n.source);if(n.source<0){return[]}var t=[];var a=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,i.LEAST_UPPER_BOUND);if(a>=0){var u=this._originalMappings[a];if(e.column===undefined){var s=u.originalLine;while(u&&u.originalLine===s){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}else{var l=u.originalColumn;while(u&&u.originalLine===r&&u.originalColumn==l){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}}return t};r.SourceMapConsumer=SourceMapConsumer;function BasicSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sources");var u=o.getArg(n,"names",[]);var s=o.getArg(n,"sourceRoot",null);var l=o.getArg(n,"sourcesContent",null);var c=o.getArg(n,"mappings");var p=o.getArg(n,"file",null);if(t!=this._version){throw new Error("Unsupported version: "+t)}if(s){s=o.normalize(s)}i=i.map(String).map(o.normalize).map((function(e){return s&&o.isAbsolute(s)&&o.isAbsolute(e)?o.relative(s,e):e}));this._names=a.fromArray(u.map(String),true);this._sources=a.fromArray(i,true);this._absoluteSources=this._sources.toArray().map((function(e){return o.computeSourceURL(s,e,r)}));this.sourceRoot=s;this.sourcesContent=l;this._mappings=c;this._sourceMapURL=r;this.file=p}BasicSourceMapConsumer.prototype=Object.create(SourceMapConsumer.prototype);BasicSourceMapConsumer.prototype.consumer=SourceMapConsumer;BasicSourceMapConsumer.prototype._findSourceIndex=function(e){var r=e;if(this.sourceRoot!=null){r=o.relative(this.sourceRoot,r)}if(this._sources.has(r)){return this._sources.indexOf(r)}var n;for(n=0;n1){v.source=l+_[1];l+=_[1];v.originalLine=i+_[2];i=v.originalLine;v.originalLine+=1;v.originalColumn=a+_[3];a=v.originalColumn;if(_.length>4){v.name=c+_[4];c+=_[4]}}m.push(v);if(typeof v.originalLine==="number"){h.push(v)}}}s(m,o.compareByGeneratedPositionsDeflated);this.__generatedMappings=m;s(h,o.compareByOriginalPositions);this.__originalMappings=h};BasicSourceMapConsumer.prototype._findMapping=function SourceMapConsumer_findMapping(e,r,n,t,o,a){if(e[n]<=0){throw new TypeError("Line must be greater than or equal to 1, got "+e[n])}if(e[t]<0){throw new TypeError("Column must be greater than or equal to 0, got "+e[t])}return i.search(e,r,o,a)};BasicSourceMapConsumer.prototype.computeColumnSpans=function SourceMapConsumer_computeColumnSpans(){for(var e=0;e=0){var t=this._generatedMappings[n];if(t.generatedLine===r.generatedLine){var i=o.getArg(t,"source",null);if(i!==null){i=this._sources.at(i);i=o.computeSourceURL(this.sourceRoot,i,this._sourceMapURL)}var a=o.getArg(t,"name",null);if(a!==null){a=this._names.at(a)}return{source:i,line:o.getArg(t,"originalLine",null),column:o.getArg(t,"originalColumn",null),name:a}}}return{source:null,line:null,column:null,name:null}};BasicSourceMapConsumer.prototype.hasContentsOfAllSources=function BasicSourceMapConsumer_hasContentsOfAllSources(){if(!this.sourcesContent){return false}return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return e==null}))};BasicSourceMapConsumer.prototype.sourceContentFor=function SourceMapConsumer_sourceContentFor(e,r){if(!this.sourcesContent){return null}var n=this._findSourceIndex(e);if(n>=0){return this.sourcesContent[n]}var t=e;if(this.sourceRoot!=null){t=o.relative(this.sourceRoot,t)}var i;if(this.sourceRoot!=null&&(i=o.urlParse(this.sourceRoot))){var a=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(a)){return this.sourcesContent[this._sources.indexOf(a)]}if((!i.path||i.path=="/")&&this._sources.has("/"+t)){return this.sourcesContent[this._sources.indexOf("/"+t)]}}if(r){return null}else{throw new Error('"'+t+'" is not in the SourceMap.')}};BasicSourceMapConsumer.prototype.generatedPositionFor=function SourceMapConsumer_generatedPositionFor(e){var r=o.getArg(e,"source");r=this._findSourceIndex(r);if(r<0){return{line:null,column:null,lastColumn:null}}var n={source:r,originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")};var t=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,o.getArg(e,"bias",SourceMapConsumer.GREATEST_LOWER_BOUND));if(t>=0){var i=this._originalMappings[t];if(i.source===n.source){return{line:o.getArg(i,"generatedLine",null),column:o.getArg(i,"generatedColumn",null),lastColumn:o.getArg(i,"lastGeneratedColumn",null)}}}return{line:null,column:null,lastColumn:null}};t=BasicSourceMapConsumer;function IndexedSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sections");if(t!=this._version){throw new Error("Unsupported version: "+t)}this._sources=new a;this._names=new a;var u={line:-1,column:0};this._sections=i.map((function(e){if(e.url){throw new Error("Support for url field in sections not implemented.")}var n=o.getArg(e,"offset");var t=o.getArg(n,"line");var i=o.getArg(n,"column");if(t{var t=n(818);var o=n(297);var i=n(517).C;var a=n(24).P;function SourceMapGenerator(e){if(!e){e={}}this._file=o.getArg(e,"file",null);this._sourceRoot=o.getArg(e,"sourceRoot",null);this._skipValidation=o.getArg(e,"skipValidation",false);this._sources=new i;this._names=new i;this._mappings=new a;this._sourcesContents=null}SourceMapGenerator.prototype._version=3;SourceMapGenerator.fromSourceMap=function SourceMapGenerator_fromSourceMap(e){var r=e.sourceRoot;var n=new SourceMapGenerator({file:e.file,sourceRoot:r});e.eachMapping((function(e){var t={generated:{line:e.generatedLine,column:e.generatedColumn}};if(e.source!=null){t.source=e.source;if(r!=null){t.source=o.relative(r,t.source)}t.original={line:e.originalLine,column:e.originalColumn};if(e.name!=null){t.name=e.name}}n.addMapping(t)}));e.sources.forEach((function(t){var i=t;if(r!==null){i=o.relative(r,t)}if(!n._sources.has(i)){n._sources.add(i)}var a=e.sourceContentFor(t);if(a!=null){n.setSourceContent(t,a)}}));return n};SourceMapGenerator.prototype.addMapping=function SourceMapGenerator_addMapping(e){var r=o.getArg(e,"generated");var n=o.getArg(e,"original",null);var t=o.getArg(e,"source",null);var i=o.getArg(e,"name",null);if(!this._skipValidation){this._validateMapping(r,n,t,i)}if(t!=null){t=String(t);if(!this._sources.has(t)){this._sources.add(t)}}if(i!=null){i=String(i);if(!this._names.has(i)){this._names.add(i)}}this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:t,name:i})};SourceMapGenerator.prototype.setSourceContent=function SourceMapGenerator_setSourceContent(e,r){var n=e;if(this._sourceRoot!=null){n=o.relative(this._sourceRoot,n)}if(r!=null){if(!this._sourcesContents){this._sourcesContents=Object.create(null)}this._sourcesContents[o.toSetString(n)]=r}else if(this._sourcesContents){delete this._sourcesContents[o.toSetString(n)];if(Object.keys(this._sourcesContents).length===0){this._sourcesContents=null}}};SourceMapGenerator.prototype.applySourceMap=function SourceMapGenerator_applySourceMap(e,r,n){var t=r;if(r==null){if(e.file==null){throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, "+'or the source map\'s "file" property. Both were omitted.')}t=e.file}var a=this._sourceRoot;if(a!=null){t=o.relative(a,t)}var u=new i;var s=new i;this._mappings.unsortedForEach((function(r){if(r.source===t&&r.originalLine!=null){var i=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});if(i.source!=null){r.source=i.source;if(n!=null){r.source=o.join(n,r.source)}if(a!=null){r.source=o.relative(a,r.source)}r.originalLine=i.line;r.originalColumn=i.column;if(i.name!=null){r.name=i.name}}}var l=r.source;if(l!=null&&!u.has(l)){u.add(l)}var c=r.name;if(c!=null&&!s.has(c)){s.add(c)}}),this);this._sources=u;this._names=s;e.sources.forEach((function(r){var t=e.sourceContentFor(r);if(t!=null){if(n!=null){r=o.join(n,r)}if(a!=null){r=o.relative(a,r)}this.setSourceContent(r,t)}}),this)};SourceMapGenerator.prototype._validateMapping=function SourceMapGenerator_validateMapping(e,r,n,t){if(r&&typeof r.line!=="number"&&typeof r.column!=="number"){throw new Error("original.line and original.column are not numbers -- you probably meant to omit "+"the original mapping entirely and only map the generated position. If so, pass "+"null for the original mapping instead of an object with empty or null values.")}if(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!r&&!n&&!t){return}else if(e&&"line"in e&&"column"in e&&r&&"line"in r&&"column"in r&&e.line>0&&e.column>=0&&r.line>0&&r.column>=0&&n){return}else{throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:r,name:t}))}};SourceMapGenerator.prototype._serializeMappings=function SourceMapGenerator_serializeMappings(){var e=0;var r=1;var n=0;var i=0;var a=0;var u=0;var s="";var l;var c;var p;var f;var g=this._mappings.toArray();for(var d=0,h=g.length;d0){if(!o.compareByGeneratedPositionsInflated(c,g[d-1])){continue}l+=","}}l+=t.encode(c.generatedColumn-e);e=c.generatedColumn;if(c.source!=null){f=this._sources.indexOf(c.source);l+=t.encode(f-u);u=f;l+=t.encode(c.originalLine-1-i);i=c.originalLine-1;l+=t.encode(c.originalColumn-n);n=c.originalColumn;if(c.name!=null){p=this._names.indexOf(c.name);l+=t.encode(p-a);a=p}}s+=l}return s};SourceMapGenerator.prototype._generateSourcesContent=function SourceMapGenerator_generateSourcesContent(e,r){return e.map((function(e){if(!this._sourcesContents){return null}if(r!=null){e=o.relative(r,e)}var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)};SourceMapGenerator.prototype.toJSON=function SourceMapGenerator_toJSON(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null){e.file=this._file}if(this._sourceRoot!=null){e.sourceRoot=this._sourceRoot}if(this._sourcesContents){e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)}return e};SourceMapGenerator.prototype.toString=function SourceMapGenerator_toString(){return JSON.stringify(this.toJSON())};r.x=SourceMapGenerator},565:(e,r,n)=>{var t;var o=n(163).x;var i=n(297);var a=/(\r?\n)/;var u=10;var s="$$$isSourceNode$$$";function SourceNode(e,r,n,t,o){this.children=[];this.sourceContents={};this.line=e==null?null:e;this.column=r==null?null:r;this.source=n==null?null:n;this.name=o==null?null:o;this[s]=true;if(t!=null)this.add(t)}SourceNode.fromStringWithSourceMap=function SourceNode_fromStringWithSourceMap(e,r,n){var t=new SourceNode;var o=e.split(a);var u=0;var shiftNextLine=function(){var e=getNextLine();var r=getNextLine()||"";return e+r;function getNextLine(){return u=0;r--){this.prepend(e[r])}}else if(e[s]||typeof e==="string"){this.children.unshift(e)}else{throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e)}return this};SourceNode.prototype.walk=function SourceNode_walk(e){var r;for(var n=0,t=this.children.length;n0){r=[];for(n=0;n{function getArg(e,r,n){if(r in e){return e[r]}else if(arguments.length===3){return n}else{throw new Error('"'+r+'" is a required argument.')}}r.getArg=getArg;var n=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;var t=/^data:.+\,.+$/;function urlParse(e){var r=e.match(n);if(!r){return null}return{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}}r.urlParse=urlParse;function urlGenerate(e){var r="";if(e.scheme){r+=e.scheme+":"}r+="//";if(e.auth){r+=e.auth+"@"}if(e.host){r+=e.host}if(e.port){r+=":"+e.port}if(e.path){r+=e.path}return r}r.urlGenerate=urlGenerate;function normalize(e){var n=e;var t=urlParse(e);if(t){if(!t.path){return e}n=t.path}var o=r.isAbsolute(n);var i=n.split(/\/+/);for(var a,u=0,s=i.length-1;s>=0;s--){a=i[s];if(a==="."){i.splice(s,1)}else if(a===".."){u++}else if(u>0){if(a===""){i.splice(s+1,u);u=0}else{i.splice(s,2);u--}}}n=i.join("/");if(n===""){n=o?"/":"."}if(t){t.path=n;return urlGenerate(t)}return n}r.normalize=normalize;function join(e,r){if(e===""){e="."}if(r===""){r="."}var n=urlParse(r);var o=urlParse(e);if(o){e=o.path||"/"}if(n&&!n.scheme){if(o){n.scheme=o.scheme}return urlGenerate(n)}if(n||r.match(t)){return r}if(o&&!o.host&&!o.path){o.host=r;return urlGenerate(o)}var i=r.charAt(0)==="/"?r:normalize(e.replace(/\/+$/,"")+"/"+r);if(o){o.path=i;return urlGenerate(o)}return i}r.join=join;r.isAbsolute=function(e){return e.charAt(0)==="/"||n.test(e)};function relative(e,r){if(e===""){e="."}e=e.replace(/\/$/,"");var n=0;while(r.indexOf(e+"/")!==0){var t=e.lastIndexOf("/");if(t<0){return r}e=e.slice(0,t);if(e.match(/^([^\/]+:\/)?\/*$/)){return r}++n}return Array(n+1).join("../")+r.substr(e.length+1)}r.relative=relative;var o=function(){var e=Object.create(null);return!("__proto__"in e)}();function identity(e){return e}function toSetString(e){if(isProtoString(e)){return"$"+e}return e}r.toSetString=o?identity:toSetString;function fromSetString(e){if(isProtoString(e)){return e.slice(1)}return e}r.fromSetString=o?identity:fromSetString;function isProtoString(e){if(!e){return false}var r=e.length;if(r<9){return false}if(e.charCodeAt(r-1)!==95||e.charCodeAt(r-2)!==95||e.charCodeAt(r-3)!==111||e.charCodeAt(r-4)!==116||e.charCodeAt(r-5)!==111||e.charCodeAt(r-6)!==114||e.charCodeAt(r-7)!==112||e.charCodeAt(r-8)!==95||e.charCodeAt(r-9)!==95){return false}for(var n=r-10;n>=0;n--){if(e.charCodeAt(n)!==36){return false}}return true}function compareByOriginalPositions(e,r,n){var t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0||n){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0){return t}t=e.generatedLine-r.generatedLine;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByOriginalPositions=compareByOriginalPositions;function compareByGeneratedPositionsDeflated(e,r,n){var t=e.generatedLine-r.generatedLine;if(t!==0){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0||n){return t}t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsDeflated=compareByGeneratedPositionsDeflated;function strcmp(e,r){if(e===r){return 0}if(e===null){return 1}if(r===null){return-1}if(e>r){return 1}return-1}function compareByGeneratedPositionsInflated(e,r){var n=e.generatedLine-r.generatedLine;if(n!==0){return n}n=e.generatedColumn-r.generatedColumn;if(n!==0){return n}n=strcmp(e.source,r.source);if(n!==0){return n}n=e.originalLine-r.originalLine;if(n!==0){return n}n=e.originalColumn-r.originalColumn;if(n!==0){return n}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;function parseSourceMapInput(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}r.parseSourceMapInput=parseSourceMapInput;function computeSourceURL(e,r,n){r=r||"";if(e){if(e[e.length-1]!=="/"&&r[0]!=="/"){e+="/"}r=e+r}if(n){var t=urlParse(n);if(!t){throw new Error("sourceMapURL could not be parsed")}if(t.path){var o=t.path.lastIndexOf("/");if(o>=0){t.path=t.path.substring(0,o+1)}}r=join(urlGenerate(t),r)}return normalize(r)}r.computeSourceURL=computeSourceURL},927:(e,r,n)=>{n(163).x;r.SourceMapConsumer=n(684).SourceMapConsumer;n(565)},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")}};var r={};function __webpack_require__(n){var t=r[n];if(t!==undefined){return t.exports}var o=r[n]={id:n,loaded:false,exports:{}};var i=true;try{e[n](o,o.exports,__webpack_require__);i=false}finally{if(i)delete r[n]}o.loaded=true;return o.exports}(()=>{__webpack_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __webpack_require__!=="undefined")__webpack_require__.ab=__dirname+"/";var n={};__webpack_require__(599).install();module.exports=n})(); -------------------------------------------------------------------------------- /dist/save/sourcemap-register.js: -------------------------------------------------------------------------------- 1 | (()=>{var e={296:e=>{var r=Object.prototype.toString;var n=typeof Buffer!=="undefined"&&typeof Buffer.alloc==="function"&&typeof Buffer.allocUnsafe==="function"&&typeof Buffer.from==="function";function isArrayBuffer(e){return r.call(e).slice(8,-1)==="ArrayBuffer"}function fromArrayBuffer(e,r,t){r>>>=0;var o=e.byteLength-r;if(o<0){throw new RangeError("'offset' is out of bounds")}if(t===undefined){t=o}else{t>>>=0;if(t>o){throw new RangeError("'length' is out of bounds")}}return n?Buffer.from(e.slice(r,r+t)):new Buffer(new Uint8Array(e.slice(r,r+t)))}function fromString(e,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}return n?Buffer.from(e,r):new Buffer(e,r)}function bufferFrom(e,r,t){if(typeof e==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(e)){return fromArrayBuffer(e,r,t)}if(typeof e==="string"){return fromString(e,r)}return n?Buffer.from(e):new Buffer(e)}e.exports=bufferFrom},599:(e,r,n)=>{e=n.nmd(e);var t=n(927).SourceMapConsumer;var o=n(928);var i;try{i=n(896);if(!i.existsSync||!i.readFileSync){i=null}}catch(e){}var a=n(296);function dynamicRequire(e,r){return e.require(r)}var u=false;var s=false;var l=false;var c="auto";var p={};var f={};var g=/^data:application\/json[^,]+base64,/;var d=[];var h=[];function isInBrowser(){if(c==="browser")return true;if(c==="node")return false;return typeof window!=="undefined"&&typeof XMLHttpRequest==="function"&&!(window.require&&window.module&&window.process&&window.process.type==="renderer")}function hasGlobalProcessEventEmitter(){return typeof process==="object"&&process!==null&&typeof process.on==="function"}function globalProcessVersion(){if(typeof process==="object"&&process!==null){return process.version}else{return""}}function globalProcessStderr(){if(typeof process==="object"&&process!==null){return process.stderr}}function globalProcessExit(e){if(typeof process==="object"&&process!==null&&typeof process.exit==="function"){return process.exit(e)}}function handlerExec(e){return function(r){for(var n=0;n"}var n=this.getLineNumber();if(n!=null){r+=":"+n;var t=this.getColumnNumber();if(t){r+=":"+t}}}var o="";var i=this.getFunctionName();var a=true;var u=this.isConstructor();var s=!(this.isToplevel()||u);if(s){var l=this.getTypeName();if(l==="[object Object]"){l="null"}var c=this.getMethodName();if(i){if(l&&i.indexOf(l)!=0){o+=l+"."}o+=i;if(c&&i.indexOf("."+c)!=i.length-c.length-1){o+=" [as "+c+"]"}}else{o+=l+"."+(c||"")}}else if(u){o+="new "+(i||"")}else if(i){o+=i}else{o+=r;a=false}if(a){o+=" ("+r+")"}return o}function cloneCallSite(e){var r={};Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(n){r[n]=/^(?:is|get)/.test(n)?function(){return e[n].call(e)}:e[n]}));r.toString=CallSiteToString;return r}function wrapCallSite(e,r){if(r===undefined){r={nextPosition:null,curPosition:null}}if(e.isNative()){r.curPosition=null;return e}var n=e.getFileName()||e.getScriptNameOrSourceURL();if(n){var t=e.getLineNumber();var o=e.getColumnNumber()-1;var i=/^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;var a=i.test(globalProcessVersion())?0:62;if(t===1&&o>a&&!isInBrowser()&&!e.isEval()){o-=a}var u=mapSourcePosition({source:n,line:t,column:o});r.curPosition=u;e=cloneCallSite(e);var s=e.getFunctionName;e.getFunctionName=function(){if(r.nextPosition==null){return s()}return r.nextPosition.name||s()};e.getFileName=function(){return u.source};e.getLineNumber=function(){return u.line};e.getColumnNumber=function(){return u.column+1};e.getScriptNameOrSourceURL=function(){return u.source};return e}var l=e.isEval()&&e.getEvalOrigin();if(l){l=mapEvalOrigin(l);e=cloneCallSite(e);e.getEvalOrigin=function(){return l};return e}return e}function prepareStackTrace(e,r){if(l){p={};f={}}var n=e.name||"Error";var t=e.message||"";var o=n+": "+t;var i={nextPosition:null,curPosition:null};var a=[];for(var u=r.length-1;u>=0;u--){a.push("\n at "+wrapCallSite(r[u],i));i.nextPosition=i.curPosition}i.curPosition=i.nextPosition=null;return o+a.reverse().join("")}function getErrorSource(e){var r=/\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(e.stack);if(r){var n=r[1];var t=+r[2];var o=+r[3];var a=p[n];if(!a&&i&&i.existsSync(n)){try{a=i.readFileSync(n,"utf8")}catch(e){a=""}}if(a){var u=a.split(/(?:\r\n|\r|\n)/)[t-1];if(u){return n+":"+t+"\n"+u+"\n"+new Array(o).join(" ")+"^"}}}return null}function printErrorAndExit(e){var r=getErrorSource(e);var n=globalProcessStderr();if(n&&n._handle&&n._handle.setBlocking){n._handle.setBlocking(true)}if(r){console.error();console.error(r)}console.error(e.stack);globalProcessExit(1)}function shimEmitUncaughtException(){var e=process.emit;process.emit=function(r){if(r==="uncaughtException"){var n=arguments[1]&&arguments[1].stack;var t=this.listeners(r).length>0;if(n&&!t){return printErrorAndExit(arguments[1])}}return e.apply(this,arguments)}}var S=d.slice(0);var _=h.slice(0);r.wrapCallSite=wrapCallSite;r.getErrorSource=getErrorSource;r.mapSourcePosition=mapSourcePosition;r.retrieveSourceMap=v;r.install=function(r){r=r||{};if(r.environment){c=r.environment;if(["node","browser","auto"].indexOf(c)===-1){throw new Error("environment "+c+" was unknown. Available options are {auto, browser, node}")}}if(r.retrieveFile){if(r.overrideRetrieveFile){d.length=0}d.unshift(r.retrieveFile)}if(r.retrieveSourceMap){if(r.overrideRetrieveSourceMap){h.length=0}h.unshift(r.retrieveSourceMap)}if(r.hookRequire&&!isInBrowser()){var n=dynamicRequire(e,"module");var t=n.prototype._compile;if(!t.__sourceMapSupport){n.prototype._compile=function(e,r){p[r]=e;f[r]=undefined;return t.call(this,e,r)};n.prototype._compile.__sourceMapSupport=true}}if(!l){l="emptyCacheBetweenOperations"in r?r.emptyCacheBetweenOperations:false}if(!u){u=true;Error.prepareStackTrace=prepareStackTrace}if(!s){var o="handleUncaughtExceptions"in r?r.handleUncaughtExceptions:true;try{var i=dynamicRequire(e,"worker_threads");if(i.isMainThread===false){o=false}}catch(e){}if(o&&hasGlobalProcessEventEmitter()){s=true;shimEmitUncaughtException()}}};r.resetRetrieveHandlers=function(){d.length=0;h.length=0;d=S.slice(0);h=_.slice(0);v=handlerExec(h);m=handlerExec(d)}},517:(e,r,n)=>{var t=n(297);var o=Object.prototype.hasOwnProperty;var i=typeof Map!=="undefined";function ArraySet(){this._array=[];this._set=i?new Map:Object.create(null)}ArraySet.fromArray=function ArraySet_fromArray(e,r){var n=new ArraySet;for(var t=0,o=e.length;t=0){return r}}else{var n=t.toSetString(e);if(o.call(this._set,n)){return this._set[n]}}throw new Error('"'+e+'" is not in the set.')};ArraySet.prototype.at=function ArraySet_at(e){if(e>=0&&e{var t=n(158);var o=5;var i=1<>1;return r?-n:n}r.encode=function base64VLQ_encode(e){var r="";var n;var i=toVLQSigned(e);do{n=i&a;i>>>=o;if(i>0){n|=u}r+=t.encode(n)}while(i>0);return r};r.decode=function base64VLQ_decode(e,r,n){var i=e.length;var s=0;var l=0;var c,p;do{if(r>=i){throw new Error("Expected more digits in base 64 VLQ value.")}p=t.decode(e.charCodeAt(r++));if(p===-1){throw new Error("Invalid base64 digit: "+e.charAt(r-1))}c=!!(p&u);p&=a;s=s+(p<{var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");r.encode=function(e){if(0<=e&&e{r.GREATEST_LOWER_BOUND=1;r.LEAST_UPPER_BOUND=2;function recursiveSearch(e,n,t,o,i,a){var u=Math.floor((n-e)/2)+e;var s=i(t,o[u],true);if(s===0){return u}else if(s>0){if(n-u>1){return recursiveSearch(u,n,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return n1){return recursiveSearch(e,u,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return u}else{return e<0?-1:e}}}r.search=function search(e,n,t,o){if(n.length===0){return-1}var i=recursiveSearch(-1,n.length,e,n,t,o||r.GREATEST_LOWER_BOUND);if(i<0){return-1}while(i-1>=0){if(t(n[i],n[i-1],true)!==0){break}--i}return i}},24:(e,r,n)=>{var t=n(297);function generatedPositionAfter(e,r){var n=e.generatedLine;var o=r.generatedLine;var i=e.generatedColumn;var a=r.generatedColumn;return o>n||o==n&&a>=i||t.compareByGeneratedPositionsInflated(e,r)<=0}function MappingList(){this._array=[];this._sorted=true;this._last={generatedLine:-1,generatedColumn:0}}MappingList.prototype.unsortedForEach=function MappingList_forEach(e,r){this._array.forEach(e,r)};MappingList.prototype.add=function MappingList_add(e){if(generatedPositionAfter(this._last,e)){this._last=e;this._array.push(e)}else{this._sorted=false;this._array.push(e)}};MappingList.prototype.toArray=function MappingList_toArray(){if(!this._sorted){this._array.sort(t.compareByGeneratedPositionsInflated);this._sorted=true}return this._array};r.P=MappingList},299:(e,r)=>{function swap(e,r,n){var t=e[r];e[r]=e[n];e[n]=t}function randomIntInRange(e,r){return Math.round(e+Math.random()*(r-e))}function doQuickSort(e,r,n,t){if(n{var t;var o=n(297);var i=n(197);var a=n(517).C;var u=n(818);var s=n(299).g;function SourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}return n.sections!=null?new IndexedSourceMapConsumer(n,r):new BasicSourceMapConsumer(n,r)}SourceMapConsumer.fromSourceMap=function(e,r){return BasicSourceMapConsumer.fromSourceMap(e,r)};SourceMapConsumer.prototype._version=3;SourceMapConsumer.prototype.__generatedMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_generatedMappings",{configurable:true,enumerable:true,get:function(){if(!this.__generatedMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__generatedMappings}});SourceMapConsumer.prototype.__originalMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_originalMappings",{configurable:true,enumerable:true,get:function(){if(!this.__originalMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__originalMappings}});SourceMapConsumer.prototype._charIsMappingSeparator=function SourceMapConsumer_charIsMappingSeparator(e,r){var n=e.charAt(r);return n===";"||n===","};SourceMapConsumer.prototype._parseMappings=function SourceMapConsumer_parseMappings(e,r){throw new Error("Subclasses must implement _parseMappings")};SourceMapConsumer.GENERATED_ORDER=1;SourceMapConsumer.ORIGINAL_ORDER=2;SourceMapConsumer.GREATEST_LOWER_BOUND=1;SourceMapConsumer.LEAST_UPPER_BOUND=2;SourceMapConsumer.prototype.eachMapping=function SourceMapConsumer_eachMapping(e,r,n){var t=r||null;var i=n||SourceMapConsumer.GENERATED_ORDER;var a;switch(i){case SourceMapConsumer.GENERATED_ORDER:a=this._generatedMappings;break;case SourceMapConsumer.ORIGINAL_ORDER:a=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var u=this.sourceRoot;a.map((function(e){var r=e.source===null?null:this._sources.at(e.source);r=o.computeSourceURL(u,r,this._sourceMapURL);return{source:r,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name===null?null:this._names.at(e.name)}}),this).forEach(e,t)};SourceMapConsumer.prototype.allGeneratedPositionsFor=function SourceMapConsumer_allGeneratedPositionsFor(e){var r=o.getArg(e,"line");var n={source:o.getArg(e,"source"),originalLine:r,originalColumn:o.getArg(e,"column",0)};n.source=this._findSourceIndex(n.source);if(n.source<0){return[]}var t=[];var a=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,i.LEAST_UPPER_BOUND);if(a>=0){var u=this._originalMappings[a];if(e.column===undefined){var s=u.originalLine;while(u&&u.originalLine===s){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}else{var l=u.originalColumn;while(u&&u.originalLine===r&&u.originalColumn==l){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}}return t};r.SourceMapConsumer=SourceMapConsumer;function BasicSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sources");var u=o.getArg(n,"names",[]);var s=o.getArg(n,"sourceRoot",null);var l=o.getArg(n,"sourcesContent",null);var c=o.getArg(n,"mappings");var p=o.getArg(n,"file",null);if(t!=this._version){throw new Error("Unsupported version: "+t)}if(s){s=o.normalize(s)}i=i.map(String).map(o.normalize).map((function(e){return s&&o.isAbsolute(s)&&o.isAbsolute(e)?o.relative(s,e):e}));this._names=a.fromArray(u.map(String),true);this._sources=a.fromArray(i,true);this._absoluteSources=this._sources.toArray().map((function(e){return o.computeSourceURL(s,e,r)}));this.sourceRoot=s;this.sourcesContent=l;this._mappings=c;this._sourceMapURL=r;this.file=p}BasicSourceMapConsumer.prototype=Object.create(SourceMapConsumer.prototype);BasicSourceMapConsumer.prototype.consumer=SourceMapConsumer;BasicSourceMapConsumer.prototype._findSourceIndex=function(e){var r=e;if(this.sourceRoot!=null){r=o.relative(this.sourceRoot,r)}if(this._sources.has(r)){return this._sources.indexOf(r)}var n;for(n=0;n1){v.source=l+_[1];l+=_[1];v.originalLine=i+_[2];i=v.originalLine;v.originalLine+=1;v.originalColumn=a+_[3];a=v.originalColumn;if(_.length>4){v.name=c+_[4];c+=_[4]}}m.push(v);if(typeof v.originalLine==="number"){h.push(v)}}}s(m,o.compareByGeneratedPositionsDeflated);this.__generatedMappings=m;s(h,o.compareByOriginalPositions);this.__originalMappings=h};BasicSourceMapConsumer.prototype._findMapping=function SourceMapConsumer_findMapping(e,r,n,t,o,a){if(e[n]<=0){throw new TypeError("Line must be greater than or equal to 1, got "+e[n])}if(e[t]<0){throw new TypeError("Column must be greater than or equal to 0, got "+e[t])}return i.search(e,r,o,a)};BasicSourceMapConsumer.prototype.computeColumnSpans=function SourceMapConsumer_computeColumnSpans(){for(var e=0;e=0){var t=this._generatedMappings[n];if(t.generatedLine===r.generatedLine){var i=o.getArg(t,"source",null);if(i!==null){i=this._sources.at(i);i=o.computeSourceURL(this.sourceRoot,i,this._sourceMapURL)}var a=o.getArg(t,"name",null);if(a!==null){a=this._names.at(a)}return{source:i,line:o.getArg(t,"originalLine",null),column:o.getArg(t,"originalColumn",null),name:a}}}return{source:null,line:null,column:null,name:null}};BasicSourceMapConsumer.prototype.hasContentsOfAllSources=function BasicSourceMapConsumer_hasContentsOfAllSources(){if(!this.sourcesContent){return false}return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return e==null}))};BasicSourceMapConsumer.prototype.sourceContentFor=function SourceMapConsumer_sourceContentFor(e,r){if(!this.sourcesContent){return null}var n=this._findSourceIndex(e);if(n>=0){return this.sourcesContent[n]}var t=e;if(this.sourceRoot!=null){t=o.relative(this.sourceRoot,t)}var i;if(this.sourceRoot!=null&&(i=o.urlParse(this.sourceRoot))){var a=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(a)){return this.sourcesContent[this._sources.indexOf(a)]}if((!i.path||i.path=="/")&&this._sources.has("/"+t)){return this.sourcesContent[this._sources.indexOf("/"+t)]}}if(r){return null}else{throw new Error('"'+t+'" is not in the SourceMap.')}};BasicSourceMapConsumer.prototype.generatedPositionFor=function SourceMapConsumer_generatedPositionFor(e){var r=o.getArg(e,"source");r=this._findSourceIndex(r);if(r<0){return{line:null,column:null,lastColumn:null}}var n={source:r,originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")};var t=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,o.getArg(e,"bias",SourceMapConsumer.GREATEST_LOWER_BOUND));if(t>=0){var i=this._originalMappings[t];if(i.source===n.source){return{line:o.getArg(i,"generatedLine",null),column:o.getArg(i,"generatedColumn",null),lastColumn:o.getArg(i,"lastGeneratedColumn",null)}}}return{line:null,column:null,lastColumn:null}};t=BasicSourceMapConsumer;function IndexedSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sections");if(t!=this._version){throw new Error("Unsupported version: "+t)}this._sources=new a;this._names=new a;var u={line:-1,column:0};this._sections=i.map((function(e){if(e.url){throw new Error("Support for url field in sections not implemented.")}var n=o.getArg(e,"offset");var t=o.getArg(n,"line");var i=o.getArg(n,"column");if(t{var t=n(818);var o=n(297);var i=n(517).C;var a=n(24).P;function SourceMapGenerator(e){if(!e){e={}}this._file=o.getArg(e,"file",null);this._sourceRoot=o.getArg(e,"sourceRoot",null);this._skipValidation=o.getArg(e,"skipValidation",false);this._sources=new i;this._names=new i;this._mappings=new a;this._sourcesContents=null}SourceMapGenerator.prototype._version=3;SourceMapGenerator.fromSourceMap=function SourceMapGenerator_fromSourceMap(e){var r=e.sourceRoot;var n=new SourceMapGenerator({file:e.file,sourceRoot:r});e.eachMapping((function(e){var t={generated:{line:e.generatedLine,column:e.generatedColumn}};if(e.source!=null){t.source=e.source;if(r!=null){t.source=o.relative(r,t.source)}t.original={line:e.originalLine,column:e.originalColumn};if(e.name!=null){t.name=e.name}}n.addMapping(t)}));e.sources.forEach((function(t){var i=t;if(r!==null){i=o.relative(r,t)}if(!n._sources.has(i)){n._sources.add(i)}var a=e.sourceContentFor(t);if(a!=null){n.setSourceContent(t,a)}}));return n};SourceMapGenerator.prototype.addMapping=function SourceMapGenerator_addMapping(e){var r=o.getArg(e,"generated");var n=o.getArg(e,"original",null);var t=o.getArg(e,"source",null);var i=o.getArg(e,"name",null);if(!this._skipValidation){this._validateMapping(r,n,t,i)}if(t!=null){t=String(t);if(!this._sources.has(t)){this._sources.add(t)}}if(i!=null){i=String(i);if(!this._names.has(i)){this._names.add(i)}}this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:t,name:i})};SourceMapGenerator.prototype.setSourceContent=function SourceMapGenerator_setSourceContent(e,r){var n=e;if(this._sourceRoot!=null){n=o.relative(this._sourceRoot,n)}if(r!=null){if(!this._sourcesContents){this._sourcesContents=Object.create(null)}this._sourcesContents[o.toSetString(n)]=r}else if(this._sourcesContents){delete this._sourcesContents[o.toSetString(n)];if(Object.keys(this._sourcesContents).length===0){this._sourcesContents=null}}};SourceMapGenerator.prototype.applySourceMap=function SourceMapGenerator_applySourceMap(e,r,n){var t=r;if(r==null){if(e.file==null){throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, "+'or the source map\'s "file" property. Both were omitted.')}t=e.file}var a=this._sourceRoot;if(a!=null){t=o.relative(a,t)}var u=new i;var s=new i;this._mappings.unsortedForEach((function(r){if(r.source===t&&r.originalLine!=null){var i=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});if(i.source!=null){r.source=i.source;if(n!=null){r.source=o.join(n,r.source)}if(a!=null){r.source=o.relative(a,r.source)}r.originalLine=i.line;r.originalColumn=i.column;if(i.name!=null){r.name=i.name}}}var l=r.source;if(l!=null&&!u.has(l)){u.add(l)}var c=r.name;if(c!=null&&!s.has(c)){s.add(c)}}),this);this._sources=u;this._names=s;e.sources.forEach((function(r){var t=e.sourceContentFor(r);if(t!=null){if(n!=null){r=o.join(n,r)}if(a!=null){r=o.relative(a,r)}this.setSourceContent(r,t)}}),this)};SourceMapGenerator.prototype._validateMapping=function SourceMapGenerator_validateMapping(e,r,n,t){if(r&&typeof r.line!=="number"&&typeof r.column!=="number"){throw new Error("original.line and original.column are not numbers -- you probably meant to omit "+"the original mapping entirely and only map the generated position. If so, pass "+"null for the original mapping instead of an object with empty or null values.")}if(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!r&&!n&&!t){return}else if(e&&"line"in e&&"column"in e&&r&&"line"in r&&"column"in r&&e.line>0&&e.column>=0&&r.line>0&&r.column>=0&&n){return}else{throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:r,name:t}))}};SourceMapGenerator.prototype._serializeMappings=function SourceMapGenerator_serializeMappings(){var e=0;var r=1;var n=0;var i=0;var a=0;var u=0;var s="";var l;var c;var p;var f;var g=this._mappings.toArray();for(var d=0,h=g.length;d0){if(!o.compareByGeneratedPositionsInflated(c,g[d-1])){continue}l+=","}}l+=t.encode(c.generatedColumn-e);e=c.generatedColumn;if(c.source!=null){f=this._sources.indexOf(c.source);l+=t.encode(f-u);u=f;l+=t.encode(c.originalLine-1-i);i=c.originalLine-1;l+=t.encode(c.originalColumn-n);n=c.originalColumn;if(c.name!=null){p=this._names.indexOf(c.name);l+=t.encode(p-a);a=p}}s+=l}return s};SourceMapGenerator.prototype._generateSourcesContent=function SourceMapGenerator_generateSourcesContent(e,r){return e.map((function(e){if(!this._sourcesContents){return null}if(r!=null){e=o.relative(r,e)}var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)};SourceMapGenerator.prototype.toJSON=function SourceMapGenerator_toJSON(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null){e.file=this._file}if(this._sourceRoot!=null){e.sourceRoot=this._sourceRoot}if(this._sourcesContents){e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)}return e};SourceMapGenerator.prototype.toString=function SourceMapGenerator_toString(){return JSON.stringify(this.toJSON())};r.x=SourceMapGenerator},565:(e,r,n)=>{var t;var o=n(163).x;var i=n(297);var a=/(\r?\n)/;var u=10;var s="$$$isSourceNode$$$";function SourceNode(e,r,n,t,o){this.children=[];this.sourceContents={};this.line=e==null?null:e;this.column=r==null?null:r;this.source=n==null?null:n;this.name=o==null?null:o;this[s]=true;if(t!=null)this.add(t)}SourceNode.fromStringWithSourceMap=function SourceNode_fromStringWithSourceMap(e,r,n){var t=new SourceNode;var o=e.split(a);var u=0;var shiftNextLine=function(){var e=getNextLine();var r=getNextLine()||"";return e+r;function getNextLine(){return u=0;r--){this.prepend(e[r])}}else if(e[s]||typeof e==="string"){this.children.unshift(e)}else{throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e)}return this};SourceNode.prototype.walk=function SourceNode_walk(e){var r;for(var n=0,t=this.children.length;n0){r=[];for(n=0;n{function getArg(e,r,n){if(r in e){return e[r]}else if(arguments.length===3){return n}else{throw new Error('"'+r+'" is a required argument.')}}r.getArg=getArg;var n=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;var t=/^data:.+\,.+$/;function urlParse(e){var r=e.match(n);if(!r){return null}return{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}}r.urlParse=urlParse;function urlGenerate(e){var r="";if(e.scheme){r+=e.scheme+":"}r+="//";if(e.auth){r+=e.auth+"@"}if(e.host){r+=e.host}if(e.port){r+=":"+e.port}if(e.path){r+=e.path}return r}r.urlGenerate=urlGenerate;function normalize(e){var n=e;var t=urlParse(e);if(t){if(!t.path){return e}n=t.path}var o=r.isAbsolute(n);var i=n.split(/\/+/);for(var a,u=0,s=i.length-1;s>=0;s--){a=i[s];if(a==="."){i.splice(s,1)}else if(a===".."){u++}else if(u>0){if(a===""){i.splice(s+1,u);u=0}else{i.splice(s,2);u--}}}n=i.join("/");if(n===""){n=o?"/":"."}if(t){t.path=n;return urlGenerate(t)}return n}r.normalize=normalize;function join(e,r){if(e===""){e="."}if(r===""){r="."}var n=urlParse(r);var o=urlParse(e);if(o){e=o.path||"/"}if(n&&!n.scheme){if(o){n.scheme=o.scheme}return urlGenerate(n)}if(n||r.match(t)){return r}if(o&&!o.host&&!o.path){o.host=r;return urlGenerate(o)}var i=r.charAt(0)==="/"?r:normalize(e.replace(/\/+$/,"")+"/"+r);if(o){o.path=i;return urlGenerate(o)}return i}r.join=join;r.isAbsolute=function(e){return e.charAt(0)==="/"||n.test(e)};function relative(e,r){if(e===""){e="."}e=e.replace(/\/$/,"");var n=0;while(r.indexOf(e+"/")!==0){var t=e.lastIndexOf("/");if(t<0){return r}e=e.slice(0,t);if(e.match(/^([^\/]+:\/)?\/*$/)){return r}++n}return Array(n+1).join("../")+r.substr(e.length+1)}r.relative=relative;var o=function(){var e=Object.create(null);return!("__proto__"in e)}();function identity(e){return e}function toSetString(e){if(isProtoString(e)){return"$"+e}return e}r.toSetString=o?identity:toSetString;function fromSetString(e){if(isProtoString(e)){return e.slice(1)}return e}r.fromSetString=o?identity:fromSetString;function isProtoString(e){if(!e){return false}var r=e.length;if(r<9){return false}if(e.charCodeAt(r-1)!==95||e.charCodeAt(r-2)!==95||e.charCodeAt(r-3)!==111||e.charCodeAt(r-4)!==116||e.charCodeAt(r-5)!==111||e.charCodeAt(r-6)!==114||e.charCodeAt(r-7)!==112||e.charCodeAt(r-8)!==95||e.charCodeAt(r-9)!==95){return false}for(var n=r-10;n>=0;n--){if(e.charCodeAt(n)!==36){return false}}return true}function compareByOriginalPositions(e,r,n){var t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0||n){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0){return t}t=e.generatedLine-r.generatedLine;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByOriginalPositions=compareByOriginalPositions;function compareByGeneratedPositionsDeflated(e,r,n){var t=e.generatedLine-r.generatedLine;if(t!==0){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0||n){return t}t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsDeflated=compareByGeneratedPositionsDeflated;function strcmp(e,r){if(e===r){return 0}if(e===null){return 1}if(r===null){return-1}if(e>r){return 1}return-1}function compareByGeneratedPositionsInflated(e,r){var n=e.generatedLine-r.generatedLine;if(n!==0){return n}n=e.generatedColumn-r.generatedColumn;if(n!==0){return n}n=strcmp(e.source,r.source);if(n!==0){return n}n=e.originalLine-r.originalLine;if(n!==0){return n}n=e.originalColumn-r.originalColumn;if(n!==0){return n}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;function parseSourceMapInput(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}r.parseSourceMapInput=parseSourceMapInput;function computeSourceURL(e,r,n){r=r||"";if(e){if(e[e.length-1]!=="/"&&r[0]!=="/"){e+="/"}r=e+r}if(n){var t=urlParse(n);if(!t){throw new Error("sourceMapURL could not be parsed")}if(t.path){var o=t.path.lastIndexOf("/");if(o>=0){t.path=t.path.substring(0,o+1)}}r=join(urlGenerate(t),r)}return normalize(r)}r.computeSourceURL=computeSourceURL},927:(e,r,n)=>{n(163).x;r.SourceMapConsumer=n(684).SourceMapConsumer;n(565)},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")}};var r={};function __webpack_require__(n){var t=r[n];if(t!==undefined){return t.exports}var o=r[n]={id:n,loaded:false,exports:{}};var i=true;try{e[n](o,o.exports,__webpack_require__);i=false}finally{if(i)delete r[n]}o.loaded=true;return o.exports}(()=>{__webpack_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __webpack_require__!=="undefined")__webpack_require__.ab=__dirname+"/";var n={};__webpack_require__(599).install();module.exports=n})(); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-action", 3 | "version": "0.0.0", 4 | "private": true, 5 | "description": "TypeScript template action", 6 | "main": "lib/main.js", 7 | "scripts": { 8 | "build": "ncc build src/restore.ts --source-map --minify --out dist/restore && ncc build src/save.ts --source-map --minify --out dist/save", 9 | "format": "prettier --write **/*.ts", 10 | "format-check": "prettier --check **/*.ts", 11 | "lint": "eslint src/**/*.ts", 12 | "test": "echo 'No test framework configured'", 13 | "all": "npm run build && npm run format-check && npm run lint && npm test" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/actions/typescript-action.git" 18 | }, 19 | "keywords": [ 20 | "actions", 21 | "node", 22 | "setup" 23 | ], 24 | "author": "", 25 | "license": "MIT", 26 | "dependencies": { 27 | "@actions/cache": "^4.0.3", 28 | "@actions/core": "^1.10.1", 29 | "@actions/glob": "^0.5.0" 30 | }, 31 | "devDependencies": { 32 | "@types/node": "^22.14.1", 33 | "@typescript-eslint/eslint-plugin": "^7.0.0", 34 | "@typescript-eslint/parser": "^6.20.0", 35 | "@vercel/ncc": "^0.38.3", 36 | "eslint": "^8.57.0", 37 | "eslint-plugin-github": "^4.10.2", 38 | "js-yaml": "^4.1.0", 39 | "prettier": "^3.5.3", 40 | "typescript": "^5.4.4" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/restore.ts: -------------------------------------------------------------------------------- 1 | import * as cache from '@actions/cache' 2 | import * as core from '@actions/core' 3 | import * as exec from '@actions/exec' 4 | import * as glob from '@actions/glob' 5 | import {stat} from 'fs' 6 | import {readFile, unlink, writeFile} from 'fs/promises' 7 | let _unameValue = '' 8 | 9 | // This should catch some ETIMEDOUT errors seen in the restore cache step. 10 | // Same as https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/src/save.ts#L10 11 | process.on('uncaughtException', e => core.info(`[warning] ${e.message}`)) 12 | 13 | async function uname(): Promise { 14 | if (!_unameValue) { 15 | // from https://github.com/c-hive/gha-npm-cache/blob/1d899ca6403e4536a2855679ab78f5b89a870863/src/restore.js#L6-L17 16 | let output = '' 17 | const options = { 18 | silent: true, 19 | listeners: { 20 | stdout: (data: unknown) => { 21 | output += String(data) 22 | } 23 | } 24 | } 25 | await exec.exec('uname', ['-s'], options) 26 | 27 | _unameValue = output.trim() 28 | } 29 | 30 | return _unameValue 31 | } 32 | 33 | function getOs(unameShort: string): string { 34 | if (unameShort.startsWith('Darwin')) return 'darwin' 35 | if (unameShort.startsWith('Linux')) return 'linux' 36 | if ( 37 | unameShort.startsWith('CYGWIN') || 38 | unameShort.startsWith('MINGW') || 39 | unameShort.startsWith('MSYS') 40 | ) 41 | return 'win' 42 | return 'unknown' 43 | } 44 | 45 | function getCachePath(os: string): string { 46 | if (os === 'win') return '~\\AppData\\Local\\Coursier\\Cache' 47 | if (os === 'darwin') return '~/Library/Caches/Coursier' 48 | return '~/.cache/coursier' 49 | } 50 | 51 | async function doHashFiles(files: string[]): Promise { 52 | return glob.hashFiles(files.filter(Boolean).join('\n')) 53 | } 54 | 55 | async function doGlob(globs: string[]): Promise { 56 | const globber = await glob.create(globs.join('\n')) 57 | return globber.glob() 58 | } 59 | 60 | async function hashContent( 61 | inputFiles: string[], 62 | hashedContent: string 63 | ): Promise { 64 | let hash = '' 65 | let allInputFiles = inputFiles 66 | 67 | const tmpFilePath = '.tmp-cs-cache-key' 68 | 69 | if (hashedContent.length !== 0) { 70 | await writeFile(tmpFilePath, hashedContent) 71 | 72 | allInputFiles = inputFiles.concat([tmpFilePath]) 73 | } 74 | 75 | hash = await doHashFiles(allInputFiles) 76 | 77 | if (hashedContent.length !== 0) { 78 | await unlink(tmpFilePath) 79 | } 80 | 81 | return hash 82 | } 83 | 84 | async function restoreCache( 85 | id: string, 86 | paths: string[], 87 | inputFiles: string[], 88 | job: string, 89 | extraSharedKey: string, 90 | extraKey: string, 91 | matrixHashedContent: string, 92 | extraHashedContent: string 93 | ): Promise { 94 | const upperId = id.toLocaleUpperCase('en-US') 95 | const cacheHitId = `cache-hit-${id}` 96 | 97 | let key = id 98 | const restoreKeys: string[] = [] 99 | 100 | if (job.length > 0) { 101 | restoreKeys.push(`${key}-`) 102 | key = `${key}-${job}` 103 | } 104 | 105 | if (matrixHashedContent.length > 0) { 106 | restoreKeys.push(`${key}-`) 107 | const matrixHash = await hashContent([], matrixHashedContent) 108 | key = `${key}-matrix-${matrixHash}` 109 | } 110 | 111 | if (extraSharedKey.length > 0) { 112 | restoreKeys.push(`${key}-`) 113 | key = `${key}-${extraSharedKey}` 114 | } 115 | 116 | if (extraKey.length > 0) { 117 | restoreKeys.push(`${key}-`) 118 | key = `${key}-${extraKey}` 119 | } 120 | 121 | if (inputFiles.length > 0 || extraHashedContent.length > 0) { 122 | restoreKeys.push(`${key}-`) 123 | const hash = await hashContent(inputFiles, extraHashedContent) 124 | key = `${key}-${hash}` 125 | } 126 | 127 | restoreKeys.reverse() 128 | 129 | core.info(`${id} cache keys:`) 130 | core.info(` ${key}`) 131 | for (const restoreKey of restoreKeys) { 132 | core.info(` ${restoreKey}`) 133 | } 134 | 135 | core.saveState(`${upperId}_CACHE_PATHS`, JSON.stringify(paths)) 136 | core.saveState(`${upperId}_CACHE_KEY`, key) 137 | 138 | let restoreKey: string | undefined = undefined 139 | 140 | try { 141 | restoreKey = await cache.restoreCache(paths, key, restoreKeys) 142 | } catch (err: unknown) { 143 | const msg = err instanceof Error ? err.message : String(err) 144 | core.info(`[warning] ${msg}`) 145 | } 146 | 147 | if (!restoreKey) { 148 | core.setOutput(cacheHitId, 'false') 149 | core.info(`${id} cache not found.`) 150 | core.info(`${id} cache will be saved in post run job.`) 151 | return 152 | } 153 | 154 | if (restoreKey === key) { 155 | core.setOutput(cacheHitId, 'true') 156 | core.info(`${id} cache hit.`) 157 | core.info(`${id} cache will not be saved in post run job.`) 158 | } else { 159 | core.setOutput(cacheHitId, 'false') 160 | core.info(`${id} cache miss, fell back on ${restoreKey}.`) 161 | core.info(`${id} cache will be saved in post run job.`) 162 | } 163 | core.info(' ') 164 | core.saveState(`${upperId}_CACHE_RESULT`, restoreKey) 165 | } 166 | 167 | async function restoreCoursierCache( 168 | inputFiles: string[], 169 | job: string, 170 | extraSharedKey: string, 171 | extraKey: string, 172 | matrixHashedContent: string, 173 | extraHashedContent: string 174 | ): Promise { 175 | let paths: string[] = [] 176 | 177 | const userSpecifiedCachePath = core.getInput('path') 178 | if (userSpecifiedCachePath) { 179 | paths = [userSpecifiedCachePath] 180 | core.exportVariable('COURSIER_CACHE', userSpecifiedCachePath) 181 | } else { 182 | paths = [getCachePath(getOs(await uname()))] 183 | } 184 | 185 | await restoreCache( 186 | 'coursier', 187 | paths, 188 | inputFiles, 189 | job, 190 | extraSharedKey, 191 | extraKey, 192 | matrixHashedContent, 193 | extraHashedContent 194 | ) 195 | } 196 | 197 | async function restoreSbtCache( 198 | inputFiles: string[], 199 | job: string, 200 | extraSharedKey: string, 201 | extraKey: string, 202 | matrixHashedContent: string, 203 | extraHashedContent: string 204 | ): Promise { 205 | await restoreCache( 206 | 'sbt-ivy2-cache', 207 | ['~/.sbt', '~/.ivy2/cache'], 208 | inputFiles, 209 | job, 210 | extraSharedKey, 211 | extraKey, 212 | matrixHashedContent, 213 | extraHashedContent 214 | ) 215 | } 216 | 217 | async function restoreMillCache( 218 | inputFiles: string[], 219 | job: string, 220 | extraSharedKey: string, 221 | extraKey: string, 222 | matrixHashedContent: string, 223 | extraHashedContent: string 224 | ): Promise { 225 | await restoreCache( 226 | 'mill', 227 | ['~/.cache/mill'], 228 | inputFiles, 229 | job, 230 | extraSharedKey, 231 | extraKey, 232 | matrixHashedContent, 233 | extraHashedContent 234 | ) 235 | } 236 | 237 | async function restoreAmmoniteCache( 238 | inputFiles: string[], 239 | job: string, 240 | extraSharedKey: string, 241 | extraKey: string, 242 | matrixHashedContent: string, 243 | extraHashedContent: string 244 | ): Promise { 245 | await restoreCache( 246 | 'ammonite', 247 | ['~/.ammonite'], 248 | inputFiles, 249 | job, 250 | extraSharedKey, 251 | extraKey, 252 | matrixHashedContent, 253 | extraHashedContent 254 | ) 255 | } 256 | 257 | function readExtraFiles(variableName: string): string[] { 258 | const extraFilesStr = core.getInput(variableName) 259 | let extraFiles: string[] = [] 260 | if (extraFilesStr) { 261 | if (extraFilesStr.startsWith('[')) { 262 | extraFiles = JSON.parse(extraFilesStr) as string[] 263 | } else { 264 | extraFiles = [extraFilesStr] 265 | } 266 | } 267 | return extraFiles 268 | } 269 | 270 | function readExtraKeys(variableName: string): string { 271 | let extraFilesStr = core.getInput(variableName) 272 | if (!extraFilesStr) extraFilesStr = '' 273 | return extraFilesStr 274 | } 275 | 276 | function readExtraBoolean(variableName: string): boolean { 277 | return core.getBooleanInput(variableName, {required: false}) 278 | } 279 | 280 | async function run(): Promise { 281 | let root = core.getInput('root') 282 | if (!root.endsWith('/')) { 283 | root = `${root}/` 284 | } 285 | 286 | let extraFiles = readExtraFiles('extraFiles') 287 | 288 | if (core.getInput('read-cs-cache-files') !== 'false') { 289 | const isFilePromise = new Promise((resolve, reject) => { 290 | stat('.github/cs-cache-files', (err, stats) => { 291 | if (err && err.code === 'ENOENT') resolve(false) 292 | else if (err) reject(err) 293 | else resolve(stats.isFile()) 294 | }) 295 | }) 296 | const isFile = await isFilePromise 297 | if (isFile) { 298 | const content = (await readFile('.github/cs-cache-files')).toString() 299 | extraFiles = extraFiles.concat(content.split(/\r?\n/)) 300 | } 301 | } 302 | 303 | const extraSbtFiles = readExtraFiles('extraSbtFiles') 304 | const extraMillFiles = readExtraFiles('extraMillFiles') 305 | const extraAmmoniteFiles = readExtraFiles('ammoniteScripts') 306 | 307 | const extraHashedContent = readExtraKeys('extraHashedContent') 308 | const extraCoursierHashedContent = readExtraKeys('extraCoursierHashedContent') 309 | const extraSbtHashedContent = readExtraKeys('extraSbtHashedContent') 310 | const extraMillHashedContent = readExtraKeys('extraMillHashedContent') 311 | const extraAmmoniteHashedContent = readExtraKeys('extraAmmoniteHashedContent') 312 | 313 | const extraKey = readExtraKeys('extraKey') 314 | const extraCoursierKey = readExtraKeys('extraCoursierKey') 315 | const extraSbtKey = readExtraKeys('extraSbtKey') 316 | const extraMillKey = readExtraKeys('extraMillKey') 317 | const extraAmmoniteKey = readExtraKeys('extraAmmoniteKey') 318 | 319 | const ignoreJobAsPartCacheKey = readExtraBoolean('ignoreJob') 320 | const ignoreMatrixAsPartCacheKey = readExtraBoolean('ignoreMatrix') 321 | 322 | const job = ignoreJobAsPartCacheKey ? '' : readExtraKeys('job') 323 | let matrix = readExtraKeys('matrix') 324 | if ( 325 | matrix === 'null' || 326 | matrix === 'undefined' || 327 | matrix === '{}' || 328 | ignoreMatrixAsPartCacheKey 329 | ) { 330 | matrix = '' 331 | } 332 | 333 | const sbtGlobs = [ 334 | `${root}*.sbt`, 335 | `${root}project/**.sbt`, 336 | `${root}project/build.properties`, 337 | `${root}project/**.scala` 338 | ].concat(extraSbtFiles) 339 | 340 | const millSpecificGlobs = [`${root}.mill-version`, `${root}mill`].concat( 341 | extraMillFiles 342 | ) 343 | const millGlobs = [`${root}*.sc`] 344 | .concat(millSpecificGlobs) 345 | .concat(extraMillFiles) 346 | 347 | const ammoniteGlobs = [`${root}*.sc`, `${root}*/*.sc`].concat( 348 | extraAmmoniteFiles 349 | ) 350 | 351 | const [hasSbtFiles, hasMillFiles, hasAmmoniteFiles] = await Promise.all([ 352 | // eslint-disable-next-line github/no-then 353 | doGlob(sbtGlobs).then(files => files.length > 0), 354 | // eslint-disable-next-line github/no-then 355 | doGlob(millSpecificGlobs).then(files => files.length > 0), 356 | // eslint-disable-next-line github/no-then 357 | doGlob(ammoniteGlobs).then(files => files.length > 0) 358 | ]) 359 | 360 | await restoreCoursierCache( 361 | sbtGlobs.concat(millGlobs).concat(ammoniteGlobs).concat(extraFiles), 362 | job, 363 | extraKey, 364 | extraCoursierKey, 365 | matrix, 366 | JSON.stringify({ 367 | sbt: extraSbtHashedContent, 368 | mill: extraMillHashedContent, 369 | amm: extraAmmoniteHashedContent, 370 | other: extraHashedContent, 371 | coursier: extraCoursierHashedContent 372 | }) 373 | ) 374 | 375 | if (hasSbtFiles) { 376 | await restoreSbtCache( 377 | sbtGlobs.concat(extraFiles), 378 | job, 379 | extraKey, 380 | extraSbtKey, 381 | matrix, 382 | JSON.stringify({ 383 | sbt: extraSbtHashedContent, 384 | other: extraHashedContent 385 | }) 386 | ) 387 | } 388 | 389 | if (hasMillFiles) { 390 | await restoreMillCache( 391 | millGlobs.concat(extraFiles), 392 | job, 393 | extraKey, 394 | extraMillKey, 395 | matrix, 396 | JSON.stringify({ 397 | mill: extraMillHashedContent, 398 | other: extraHashedContent 399 | }) 400 | ) 401 | } 402 | 403 | if (hasAmmoniteFiles) { 404 | await restoreAmmoniteCache( 405 | ammoniteGlobs.concat(extraFiles), 406 | job, 407 | extraKey, 408 | extraAmmoniteKey, 409 | matrix, 410 | JSON.stringify({ 411 | amm: extraAmmoniteHashedContent, 412 | other: extraHashedContent 413 | }) 414 | ) 415 | } 416 | } 417 | 418 | async function doRun(): Promise { 419 | try { 420 | await run() 421 | } catch (err: unknown) { 422 | const msg = err instanceof Error ? err.message : String(err) 423 | core.setFailed(msg) 424 | } 425 | } 426 | 427 | doRun() 428 | -------------------------------------------------------------------------------- /src/save.ts: -------------------------------------------------------------------------------- 1 | // adapted from https://github.com/c-hive/gha-npm-cache/blob/1d899ca6403e4536a2855679ab78f5b89a870863/src/save.js 2 | 3 | import * as cache from '@actions/cache' 4 | import * as core from '@actions/core' 5 | 6 | async function saveCache(id: string): Promise { 7 | const upperId = id.toLocaleUpperCase('en-US') 8 | const primaryKey = core.getState(`${upperId}_CACHE_KEY`) 9 | 10 | if (!primaryKey) { 11 | return 12 | } 13 | 14 | const cacheKey = core.getState(`${upperId}_CACHE_RESULT`) 15 | const cachePaths = JSON.parse( 16 | core.getState(`${upperId}_CACHE_PATHS`) 17 | ) as string[] 18 | 19 | core.info(`${id} cache key:`) 20 | core.info(` ${primaryKey}`) 21 | if (cacheKey.length > 0) { 22 | core.info(`${id} cache restored from:`) 23 | core.info(` ${cacheKey}`) 24 | } 25 | 26 | if (cacheKey === primaryKey) { 27 | core.info(`${id} cache hit, not saving cache.`) 28 | return 29 | } 30 | 31 | // https://github.com/actions/cache/blob/9ab95382c899bf0953a0c6c1374373fc40456ffe/src/save.ts#L39-L49 32 | try { 33 | core.info(`Saving ${id} cache`) 34 | await cache.saveCache(cachePaths, primaryKey) 35 | } catch (err: unknown) { 36 | if (err instanceof cache.ValidationError) { 37 | throw err 38 | } else if (err instanceof cache.ReserveCacheError) { 39 | core.info(err.message) 40 | } else { 41 | const msg = err instanceof Error ? err.message : String(err) 42 | core.info(`[warning] ${msg}`) 43 | } 44 | } 45 | core.info(' ') 46 | } 47 | 48 | // This should catch some EBADF errors seen in the post cache step. 49 | // Same as https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/src/save.ts#L10 50 | process.on('uncaughtException', e => core.info(`[warning] ${e.message}`)) 51 | 52 | async function run(): Promise { 53 | await saveCache('coursier') 54 | await saveCache('sbt-ivy2-cache') 55 | await saveCache('mill') 56 | await saveCache('ammonite') 57 | } 58 | 59 | async function doRun(): Promise { 60 | try { 61 | await run() 62 | } catch (err: unknown) { 63 | const msg = err instanceof Error ? err.message : String(err) 64 | core.info(`[warning] Caught ${msg}, ignoring it`) 65 | } 66 | 67 | // Explicit termination to make sure we don't hang with some dangling promises. 68 | // Same as https://github.com/actions/cache/blob/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9/src/saveImpl.ts#L116-L123 69 | core.info('All caches saved') 70 | process.exit(0) 71 | } 72 | 73 | doRun() 74 | -------------------------------------------------------------------------------- /test/.mill-version: -------------------------------------------------------------------------------- 1 | 0.12.10 2 | -------------------------------------------------------------------------------- /test/build.sc: -------------------------------------------------------------------------------- 1 | import mill._ 2 | import mill.scalalib._ 3 | 4 | object thing extends ScalaModule { 5 | def scalaVersion = "2.13.5" 6 | def ivyDeps = Agg(ivy"com.github.alexarchambault::case-app-cats:2.0.4") 7 | } 8 | -------------------------------------------------------------------------------- /test/cs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # cs launcher script 4 | # This script lives at https://github.com/coursier/ci-scripts/blob/master/cs.sh 5 | # (Raw version for curl: https://github.com/coursier/ci-scripts/raw/master/cs.sh) 6 | 7 | # Originally adapted from https://github.com/VirtusLab/scala-cli/blob/b754d2afdda114e97febfb0090773cc582bafd19/scala-cli.sh 8 | 9 | set -eu 10 | 11 | CS_VERSION="2.1.25-M4" 12 | 13 | GH_ORG="coursier" 14 | GH_NAME="coursier" 15 | 16 | TAG="v$CS_VERSION" 17 | 18 | IS_WINDOWS=false 19 | if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "MINGW" ]; then 20 | IS_WINDOWS=true 21 | fi 22 | 23 | if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "Linux" ]; then 24 | arch="$(uname -m)" 25 | if [ "$arch" == "aarch64" ] || [ "$arch" == "x86_64" ]; then 26 | CS_URL="https://github.com/$GH_ORG/$GH_NAME/releases/download/$TAG/cs-$arch-pc-linux.gz" 27 | CACHE_BASE="$HOME/.cache/coursier/v1" 28 | else 29 | echo "No native coursier launcher available for architecture $arch on Linux" 1>&2 30 | exit 1 31 | fi 32 | elif [ "$(uname)" == "Darwin" ]; then 33 | arch="$(uname -m)" 34 | CACHE_BASE="$HOME/Library/Caches/Coursier/v1" 35 | if [ "$arch" == "x86_64" ]; then 36 | CS_URL="https://github.com/$GH_ORG/$GH_NAME/releases/download/$TAG/cs-x86_64-apple-darwin.gz" 37 | elif [[ "$arch" == "arm64" ]]; then 38 | CS_URL="https://github.com/$GH_ORG/$GH_NAME/releases/download/$TAG/cs-aarch64-apple-darwin.gz" 39 | else 40 | echo "No native coursier launcher available for architecture $arch on macOS" 1>&2 41 | exit 1 42 | fi 43 | elif [ "$IS_WINDOWS" == true ]; then 44 | CS_URL="https://github.com/$GH_ORG/$GH_NAME/releases/download/$TAG/cs-x86_64-pc-win32.zip" 45 | CACHE_BASE="$LOCALAPPDATA/Coursier/cache/v1" 46 | else 47 | echo "This standalone cs launcher supports only Linux and macOS." 1>&2 48 | exit 1 49 | fi 50 | 51 | CACHE_DEST="$CACHE_BASE/$(echo "$CS_URL" | sed 's@://@/@')" 52 | 53 | if [ "$IS_WINDOWS" == true ]; then 54 | CS_BIN_PATH="${CACHE_DEST%.zip}.exe" 55 | else 56 | CS_BIN_PATH=${CACHE_DEST%.gz} 57 | fi 58 | 59 | if [ ! -f "$CACHE_DEST" ]; then 60 | mkdir -p "$(dirname "$CACHE_DEST")" 61 | TMP_DEST="$CACHE_DEST.tmp-setup" 62 | echo "Downloading $CS_URL" 1>&2 63 | curl -fLo "$TMP_DEST" "$CS_URL" 64 | mv "$TMP_DEST" "$CACHE_DEST" 65 | fi 66 | 67 | if [ ! -f "$CS_BIN_PATH" ]; then 68 | if [ "$IS_WINDOWS" == true ]; then 69 | unzip -p "$CACHE_DEST" cs-x86_64-pc-win32.exe > "$CS_BIN_PATH" 70 | else 71 | gunzip -k "$CACHE_DEST" 72 | fi 73 | fi 74 | 75 | if [ "$IS_WINDOWS" != true ]; then 76 | if [ ! -x "$CS_BIN_PATH" ]; then 77 | chmod +x "$CS_BIN_PATH" 78 | fi 79 | fi 80 | 81 | exec "$CS_BIN_PATH" "$@" 82 | -------------------------------------------------------------------------------- /test/foo.sc: -------------------------------------------------------------------------------- 1 | import $ivy.`com.chuusai::shapeless:2.3.3` 2 | 3 | import shapeless._ 4 | 5 | val l = 1 :: true :: "a" :: HNil 6 | 7 | println("This is foo.sc") 8 | -------------------------------------------------------------------------------- /test/foo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | cd "$(dirname "${BASH_SOURCE[0]}")" 5 | exec ./cs launch ammonite:2.2.0-1-56b4d41 --scala 2.13.3 --jvm 17 -- ./foo.sc 6 | -------------------------------------------------------------------------------- /test/mill: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages. 4 | # 5 | # This script determines the Mill version to use by trying these sources 6 | # - env-variable `MILL_VERSION` 7 | # - local file `.mill-version` 8 | # - local file `.config/mill-version` 9 | # - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2) 10 | # - env-variable `DEFAULT_MILL_VERSION` 11 | # 12 | # If a version has the suffix '-native' a native binary will be used. 13 | # If a version has the suffix '-jvm' an executable jar file will be used, requiring an already installed Java runtime. 14 | # If no such suffix is found, the script will pick a default based on version and platform. 15 | # 16 | # Once a version was determined, it tries to use either 17 | # - a system-installed mill, if found and it's version matches 18 | # - an already downloaded version under ~/.cache/mill/download 19 | # 20 | # If no working mill version was found on the system, 21 | # this script downloads a binary file from Maven Central or Github Pages (this is version dependent) 22 | # into a cache location (~/.cache/mill/download). 23 | # 24 | # Mill Project URL: https://github.com/com-lihaoyi/mill 25 | # Script Version: 0.13.0-M1-13-935205 26 | # 27 | # If you want to improve this script, please also contribute your changes back! 28 | # This script was generated from: scripts/src/mill.sh 29 | # 30 | # Licensed under the Apache License, Version 2.0 31 | 32 | set -e 33 | 34 | if [ -z "${DEFAULT_MILL_VERSION}" ] ; then 35 | DEFAULT_MILL_VERSION="0.12.10" 36 | fi 37 | 38 | 39 | if [ -z "${GITHUB_RELEASE_CDN}" ] ; then 40 | GITHUB_RELEASE_CDN="" 41 | fi 42 | 43 | 44 | MILL_REPO_URL="https://github.com/com-lihaoyi/mill" 45 | 46 | if [ -z "${CURL_CMD}" ] ; then 47 | CURL_CMD=curl 48 | fi 49 | 50 | # Explicit commandline argument takes precedence over all other methods 51 | if [ "$1" = "--mill-version" ] ; then 52 | shift 53 | if [ "x$1" != "x" ] ; then 54 | MILL_VERSION="$1" 55 | shift 56 | else 57 | echo "You specified --mill-version without a version." 1>&2 58 | echo "Please provide a version that matches one provided on" 1>&2 59 | echo "${MILL_REPO_URL}/releases" 1>&2 60 | false 61 | fi 62 | fi 63 | 64 | # Please note, that if a MILL_VERSION is already set in the environment, 65 | # We reuse it's value and skip searching for a value. 66 | 67 | # If not already set, read .mill-version file 68 | if [ -z "${MILL_VERSION}" ] ; then 69 | if [ -f ".mill-version" ] ; then 70 | MILL_VERSION="$(tr '\r' '\n' < .mill-version | head -n 1 2> /dev/null)" 71 | elif [ -f ".config/mill-version" ] ; then 72 | MILL_VERSION="$(tr '\r' '\n' < .config/mill-version | head -n 1 2> /dev/null)" 73 | fi 74 | fi 75 | 76 | MILL_USER_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/mill" 77 | 78 | if [ -z "${MILL_DOWNLOAD_PATH}" ] ; then 79 | MILL_DOWNLOAD_PATH="${MILL_USER_CACHE_DIR}/download" 80 | fi 81 | 82 | # If not already set, try to fetch newest from Github 83 | if [ -z "${MILL_VERSION}" ] ; then 84 | # TODO: try to load latest version from release page 85 | echo "No mill version specified." 1>&2 86 | echo "You should provide a version via '.mill-version' file or --mill-version option." 1>&2 87 | 88 | mkdir -p "${MILL_DOWNLOAD_PATH}" 89 | LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 2>/dev/null || ( 90 | # we might be on OSX or BSD which don't have -d option for touch 91 | # but probably a -A [-][[hh]mm]SS 92 | touch "${MILL_DOWNLOAD_PATH}/.expire_latest"; touch -A -010000 "${MILL_DOWNLOAD_PATH}/.expire_latest" 93 | ) || ( 94 | # in case we still failed, we retry the first touch command with the intention 95 | # to show the (previously suppressed) error message 96 | LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 97 | ) 98 | 99 | # POSIX shell variant of bash's -nt operator, see https://unix.stackexchange.com/a/449744/6993 100 | # if [ "${MILL_DOWNLOAD_PATH}/.latest" -nt "${MILL_DOWNLOAD_PATH}/.expire_latest" ] ; then 101 | if [ -n "$(find -L "${MILL_DOWNLOAD_PATH}/.latest" -prune -newer "${MILL_DOWNLOAD_PATH}/.expire_latest")" ]; then 102 | # we know a current latest version 103 | MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null) 104 | fi 105 | 106 | if [ -z "${MILL_VERSION}" ] ; then 107 | # we don't know a current latest version 108 | echo "Retrieving latest mill version ..." 1>&2 109 | LANG=C ${CURL_CMD} -s -i -f -I ${MILL_REPO_URL}/releases/latest 2> /dev/null | grep --ignore-case Location: | sed s'/^.*tag\///' | tr -d '\r\n' > "${MILL_DOWNLOAD_PATH}/.latest" 110 | MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null) 111 | fi 112 | 113 | if [ -z "${MILL_VERSION}" ] ; then 114 | # Last resort 115 | MILL_VERSION="${DEFAULT_MILL_VERSION}" 116 | echo "Falling back to hardcoded mill version ${MILL_VERSION}" 1>&2 117 | else 118 | echo "Using mill version ${MILL_VERSION}" 1>&2 119 | fi 120 | fi 121 | 122 | MILL_NATIVE_SUFFIX="-native" 123 | MILL_JVM_SUFFIX="-jvm" 124 | FULL_MILL_VERSION=$MILL_VERSION 125 | ARTIFACT_SUFFIX="" 126 | set_artifact_suffix(){ 127 | if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" = "Linux" ]; then 128 | if [ "$(uname -m)" = "aarch64" ]; then 129 | ARTIFACT_SUFFIX="-native-linux-aarch64" 130 | else 131 | ARTIFACT_SUFFIX="-native-linux-amd64" 132 | fi 133 | elif [ "$(uname)" = "Darwin" ]; then 134 | if [ "$(uname -m)" = "arm64" ]; then 135 | ARTIFACT_SUFFIX="-native-mac-aarch64" 136 | else 137 | ARTIFACT_SUFFIX="-native-mac-amd64" 138 | fi 139 | else 140 | echo "This native mill launcher supports only Linux and macOS." 1>&2 141 | exit 1 142 | fi 143 | } 144 | 145 | case "$MILL_VERSION" in 146 | *"$MILL_NATIVE_SUFFIX") 147 | MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_SUFFIX"} 148 | set_artifact_suffix 149 | ;; 150 | 151 | *"$MILL_JVM_SUFFIX") 152 | MILL_VERSION=${MILL_VERSION%"$MILL_JVM_SUFFIX"} 153 | ;; 154 | 155 | *) 156 | case "$MILL_VERSION" in 157 | 0.1.*) ;; 158 | 0.2.*) ;; 159 | 0.3.*) ;; 160 | 0.4.*) ;; 161 | 0.5.*) ;; 162 | 0.6.*) ;; 163 | 0.7.*) ;; 164 | 0.8.*) ;; 165 | 0.9.*) ;; 166 | 0.10.*) ;; 167 | 0.11.*) ;; 168 | 0.12.*) ;; 169 | *) 170 | set_artifact_suffix 171 | esac 172 | ;; 173 | esac 174 | 175 | MILL="${MILL_DOWNLOAD_PATH}/$MILL_VERSION$ARTIFACT_SUFFIX" 176 | 177 | try_to_use_system_mill() { 178 | if [ "$(uname)" != "Linux" ]; then 179 | return 0 180 | fi 181 | 182 | MILL_IN_PATH="$(command -v mill || true)" 183 | 184 | if [ -z "${MILL_IN_PATH}" ]; then 185 | return 0 186 | fi 187 | 188 | SYSTEM_MILL_FIRST_TWO_BYTES=$(head --bytes=2 "${MILL_IN_PATH}") 189 | if [ "${SYSTEM_MILL_FIRST_TWO_BYTES}" = "#!" ]; then 190 | # MILL_IN_PATH is (very likely) a shell script and not the mill 191 | # executable, ignore it. 192 | return 0 193 | fi 194 | 195 | SYSTEM_MILL_PATH=$(readlink -e "${MILL_IN_PATH}") 196 | SYSTEM_MILL_SIZE=$(stat --format=%s "${SYSTEM_MILL_PATH}") 197 | SYSTEM_MILL_MTIME=$(stat --format=%y "${SYSTEM_MILL_PATH}") 198 | 199 | if [ ! -d "${MILL_USER_CACHE_DIR}" ]; then 200 | mkdir -p "${MILL_USER_CACHE_DIR}" 201 | fi 202 | 203 | SYSTEM_MILL_INFO_FILE="${MILL_USER_CACHE_DIR}/system-mill-info" 204 | if [ -f "${SYSTEM_MILL_INFO_FILE}" ]; then 205 | parseSystemMillInfo() { 206 | LINE_NUMBER="${1}" 207 | # Select the line number of the SYSTEM_MILL_INFO_FILE, cut the 208 | # variable definition in that line in two halves and return 209 | # the value, and finally remove the quotes. 210 | sed -n "${LINE_NUMBER}p" "${SYSTEM_MILL_INFO_FILE}" |\ 211 | cut -d= -f2 |\ 212 | sed 's/"\(.*\)"/\1/' 213 | } 214 | 215 | CACHED_SYSTEM_MILL_PATH=$(parseSystemMillInfo 1) 216 | CACHED_SYSTEM_MILL_VERSION=$(parseSystemMillInfo 2) 217 | CACHED_SYSTEM_MILL_SIZE=$(parseSystemMillInfo 3) 218 | CACHED_SYSTEM_MILL_MTIME=$(parseSystemMillInfo 4) 219 | 220 | if [ "${SYSTEM_MILL_PATH}" = "${CACHED_SYSTEM_MILL_PATH}" ] \ 221 | && [ "${SYSTEM_MILL_SIZE}" = "${CACHED_SYSTEM_MILL_SIZE}" ] \ 222 | && [ "${SYSTEM_MILL_MTIME}" = "${CACHED_SYSTEM_MILL_MTIME}" ]; then 223 | if [ "${CACHED_SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then 224 | MILL="${SYSTEM_MILL_PATH}" 225 | return 0 226 | else 227 | return 0 228 | fi 229 | fi 230 | fi 231 | 232 | SYSTEM_MILL_VERSION=$(${SYSTEM_MILL_PATH} --version | head -n1 | sed -n 's/^Mill.*version \(.*\)/\1/p') 233 | 234 | cat < "${SYSTEM_MILL_INFO_FILE}" 235 | CACHED_SYSTEM_MILL_PATH="${SYSTEM_MILL_PATH}" 236 | CACHED_SYSTEM_MILL_VERSION="${SYSTEM_MILL_VERSION}" 237 | CACHED_SYSTEM_MILL_SIZE="${SYSTEM_MILL_SIZE}" 238 | CACHED_SYSTEM_MILL_MTIME="${SYSTEM_MILL_MTIME}" 239 | EOF 240 | 241 | if [ "${SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then 242 | MILL="${SYSTEM_MILL_PATH}" 243 | fi 244 | } 245 | try_to_use_system_mill 246 | 247 | # If not already downloaded, download it 248 | if [ ! -s "${MILL}" ] ; then 249 | 250 | # support old non-XDG download dir 251 | MILL_OLD_DOWNLOAD_PATH="${HOME}/.mill/download" 252 | OLD_MILL="${MILL_OLD_DOWNLOAD_PATH}/${MILL_VERSION}" 253 | if [ -x "${OLD_MILL}" ] ; then 254 | MILL="${OLD_MILL}" 255 | else 256 | case $MILL_VERSION in 257 | 0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.* ) 258 | DOWNLOAD_SUFFIX="" 259 | DOWNLOAD_FROM_MAVEN=0 260 | ;; 261 | 0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M* ) 262 | DOWNLOAD_SUFFIX="-assembly" 263 | DOWNLOAD_FROM_MAVEN=0 264 | ;; 265 | *) 266 | DOWNLOAD_SUFFIX="-assembly" 267 | DOWNLOAD_FROM_MAVEN=1 268 | ;; 269 | esac 270 | 271 | DOWNLOAD_FILE=$(mktemp mill.XXXXXX) 272 | 273 | if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then 274 | DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.jar" 275 | else 276 | MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/') 277 | DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}" 278 | unset MILL_VERSION_TAG 279 | fi 280 | 281 | # TODO: handle command not found 282 | echo "Downloading mill ${MILL_VERSION} from ${DOWNLOAD_URL} ..." 1>&2 283 | ${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${DOWNLOAD_URL}" 284 | chmod +x "${DOWNLOAD_FILE}" 285 | mkdir -p "${MILL_DOWNLOAD_PATH}" 286 | mv "${DOWNLOAD_FILE}" "${MILL}" 287 | 288 | unset DOWNLOAD_FILE 289 | unset DOWNLOAD_SUFFIX 290 | fi 291 | fi 292 | 293 | if [ -z "$MILL_MAIN_CLI" ] ; then 294 | MILL_MAIN_CLI="${0}" 295 | fi 296 | 297 | MILL_FIRST_ARG="" 298 | if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then 299 | # Need to preserve the first position of those listed options 300 | MILL_FIRST_ARG=$1 301 | shift 302 | fi 303 | 304 | unset MILL_DOWNLOAD_PATH 305 | unset MILL_OLD_DOWNLOAD_PATH 306 | unset OLD_MILL 307 | unset MILL_VERSION 308 | unset MILL_REPO_URL 309 | 310 | # We don't quote MILL_FIRST_ARG on purpose, so we can expand the empty value without quotes 311 | # shellcheck disable=SC2086 312 | exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@" 313 | -------------------------------------------------------------------------------- /test/mill.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages. 4 | rem 5 | rem This script determines the Mill version to use by trying these sources 6 | rem - env-variable `MILL_VERSION` 7 | rem - local file `.mill-version` 8 | rem - local file `.config/mill-version` 9 | rem - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2) 10 | rem - env-variable `DEFAULT_MILL_VERSION` 11 | rem 12 | rem If a version has the suffix '-native' a native binary will be used. 13 | rem If a version has the suffix '-jvm' an executable jar file will be used, requiring an already installed Java runtime. 14 | rem If no such suffix is found, the script will pick a default based on version and platform. 15 | rem 16 | rem Once a version was determined, it tries to use either 17 | rem - a system-installed mill, if found and it's version matches 18 | rem - an already downloaded version under %USERPROFILE%\.mill\download 19 | rem 20 | rem If no working mill version was found on the system, 21 | rem this script downloads a binary file from Maven Central or Github Pages (this is version dependent) 22 | rem into a cache location (%USERPROFILE%\.mill\download). 23 | rem 24 | rem Mill Project URL: https://github.com/com-lihaoyi/mill 25 | rem Script Version: 0.13.0-M1-13-935205 26 | rem 27 | rem If you want to improve this script, please also contribute your changes back! 28 | rem This script was generated from: scripts/src/mill.bat 29 | rem 30 | rem Licensed under the Apache License, Version 2.0 31 | 32 | rem setlocal seems to be unavailable on Windows 95/98/ME 33 | rem but I don't think we need to support them in 2019 34 | setlocal enabledelayedexpansion 35 | 36 | if [!DEFAULT_MILL_VERSION!]==[] ( 37 | set "DEFAULT_MILL_VERSION=0.12.10" 38 | ) 39 | 40 | if [!GITHUB_RELEASE_CDN!]==[] ( 41 | set "GITHUB_RELEASE_CDN=" 42 | ) 43 | 44 | if [!MILL_MAIN_CLI!]==[] ( 45 | set "MILL_MAIN_CLI=%~f0" 46 | ) 47 | 48 | set "MILL_REPO_URL=https://github.com/com-lihaoyi/mill" 49 | 50 | rem %~1% removes surrounding quotes 51 | if [%~1%]==[--mill-version] ( 52 | if not [%~2%]==[] ( 53 | set MILL_VERSION=%~2% 54 | rem shift command doesn't work within parentheses 55 | set "STRIP_VERSION_PARAMS=true" 56 | ) else ( 57 | echo You specified --mill-version without a version. 1>&2 58 | echo Please provide a version that matches one provided on 1>&2 59 | echo %MILL_REPO_URL%/releases 1>&2 60 | exit /b 1 61 | ) 62 | ) 63 | 64 | if not defined STRIP_VERSION_PARAMS GOTO AfterStripVersionParams 65 | rem strip the: --mill-version {version} 66 | shift 67 | shift 68 | :AfterStripVersionParams 69 | 70 | if [!MILL_VERSION!]==[] ( 71 | if exist .mill-version ( 72 | set /p MILL_VERSION=<.mill-version 73 | ) else ( 74 | if exist .config\mill-version ( 75 | set /p MILL_VERSION=<.config\mill-version 76 | ) 77 | ) 78 | ) 79 | 80 | if [!MILL_VERSION!]==[] ( 81 | set MILL_VERSION=%DEFAULT_MILL_VERSION% 82 | ) 83 | 84 | if [!MILL_DOWNLOAD_PATH!]==[] ( 85 | set MILL_DOWNLOAD_PATH=%USERPROFILE%\.mill\download 86 | ) 87 | 88 | rem without bat file extension, cmd doesn't seem to be able to run it 89 | 90 | set "MILL_NATIVE_SUFFIX=-native" 91 | set "MILL_JVM_SUFFIX=-jvm" 92 | set "FULL_MILL_VERSION=%MILL_VERSION%" 93 | set "MILL_EXT=.bat" 94 | set "ARTIFACT_SUFFIX=" 95 | REM Check if MILL_VERSION contains MILL_NATIVE_SUFFIX 96 | echo !MILL_VERSION! | findstr /C:"%MILL_NATIVE_SUFFIX%" >nul 97 | if !errorlevel! equ 0 ( 98 | set "MILL_VERSION=%MILL_VERSION:-native=%" 99 | REM -native images compiled with graal do not support windows-arm 100 | REM https://github.com/oracle/graal/issues/9215 101 | IF /I NOT "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( 102 | set "ARTIFACT_SUFFIX=-native-windows-amd64" 103 | set "MILL_EXT=.exe" 104 | ) else ( 105 | rem no-op 106 | ) 107 | ) else ( 108 | echo !MILL_VERSION! | findstr /C:"%MILL_JVM_SUFFIX%" >nul 109 | if !errorlevel! equ 0 ( 110 | set "MILL_VERSION=%MILL_VERSION:-jvm=%" 111 | ) else ( 112 | set "SKIP_VERSION=false" 113 | set "PREFIX=%MILL_VERSION:~0,4%" 114 | if "!PREFIX!"=="0.1." set "SKIP_VERSION=true" 115 | if "!PREFIX!"=="0.2." set "SKIP_VERSION=true" 116 | if "!PREFIX!"=="0.3." set "SKIP_VERSION=true" 117 | if "!PREFIX!"=="0.4." set "SKIP_VERSION=true" 118 | if "!PREFIX!"=="0.5." set "SKIP_VERSION=true" 119 | if "!PREFIX!"=="0.6." set "SKIP_VERSION=true" 120 | if "!PREFIX!"=="0.7." set "SKIP_VERSION=true" 121 | if "!PREFIX!"=="0.8." set "SKIP_VERSION=true" 122 | if "!PREFIX!"=="0.9." set "SKIP_VERSION=true" 123 | set "PREFIX=%MILL_VERSION:~0,5%" 124 | if "!PREFIX!"=="0.10." set "SKIP_VERSION=true" 125 | if "!PREFIX!"=="0.11." set "SKIP_VERSION=true" 126 | if "!PREFIX!"=="0.12." set "SKIP_VERSION=true" 127 | 128 | if "!SKIP_VERSION!"=="false" ( 129 | IF /I NOT "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( 130 | set "ARTIFACT_SUFFIX=-native-windows-amd64" 131 | set "MILL_EXT=.exe" 132 | ) 133 | ) else ( 134 | rem no-op 135 | ) 136 | ) 137 | ) 138 | 139 | set MILL=%MILL_DOWNLOAD_PATH%\!FULL_MILL_VERSION!!MILL_EXT! 140 | 141 | if not exist "%MILL%" ( 142 | set VERSION_PREFIX=%MILL_VERSION:~0,4% 143 | rem Since 0.5.0 144 | set DOWNLOAD_SUFFIX=-assembly 145 | rem Since 0.11.0 146 | set DOWNLOAD_FROM_MAVEN=1 147 | if [!VERSION_PREFIX!]==[0.0.] ( 148 | set DOWNLOAD_SUFFIX= 149 | set DOWNLOAD_FROM_MAVEN=0 150 | ) 151 | if [!VERSION_PREFIX!]==[0.1.] ( 152 | set DOWNLOAD_SUFFIX= 153 | set DOWNLOAD_FROM_MAVEN=0 154 | ) 155 | if [!VERSION_PREFIX!]==[0.2.] ( 156 | set DOWNLOAD_SUFFIX= 157 | set DOWNLOAD_FROM_MAVEN=0 158 | ) 159 | if [!VERSION_PREFIX!]==[0.3.] ( 160 | set DOWNLOAD_SUFFIX= 161 | set DOWNLOAD_FROM_MAVEN=0 162 | ) 163 | if [!VERSION_PREFIX!]==[0.4.] ( 164 | set DOWNLOAD_SUFFIX= 165 | set DOWNLOAD_FROM_MAVEN=0 166 | ) 167 | if [!VERSION_PREFIX!]==[0.5.] ( 168 | set DOWNLOAD_FROM_MAVEN=0 169 | ) 170 | if [!VERSION_PREFIX!]==[0.6.] ( 171 | set DOWNLOAD_FROM_MAVEN=0 172 | ) 173 | if [!VERSION_PREFIX!]==[0.7.] ( 174 | set DOWNLOAD_FROM_MAVEN=0 175 | ) 176 | if [!VERSION_PREFIX!]==[0.8.] ( 177 | set DOWNLOAD_FROM_MAVEN=0 178 | ) 179 | if [!VERSION_PREFIX!]==[0.9.] ( 180 | set DOWNLOAD_FROM_MAVEN=0 181 | ) 182 | set VERSION_PREFIX=%MILL_VERSION:~0,5% 183 | if [!VERSION_PREFIX!]==[0.10.] ( 184 | set DOWNLOAD_FROM_MAVEN=0 185 | ) 186 | set VERSION_PREFIX=%MILL_VERSION:~0,8% 187 | if [!VERSION_PREFIX!]==[0.11.0-M] ( 188 | set DOWNLOAD_FROM_MAVEN=0 189 | ) 190 | set VERSION_PREFIX= 191 | 192 | for /F "delims=- tokens=1" %%A in ("!MILL_VERSION!") do set MILL_VERSION_BASE=%%A 193 | for /F "delims=- tokens=2" %%A in ("!MILL_VERSION!") do set MILL_VERSION_MILESTONE=%%A 194 | set VERSION_MILESTONE_START=!MILL_VERSION_MILESTONE:~0,1! 195 | if [!VERSION_MILESTONE_START!]==[M] ( 196 | set MILL_VERSION_TAG="!MILL_VERSION_BASE!-!MILL_VERSION_MILESTONE!" 197 | ) else ( 198 | set MILL_VERSION_TAG=!MILL_VERSION_BASE! 199 | ) 200 | 201 | rem there seems to be no way to generate a unique temporary file path (on native Windows) 202 | set DOWNLOAD_FILE=%MILL%.tmp 203 | 204 | if [!DOWNLOAD_FROM_MAVEN!]==[1] ( 205 | set DOWNLOAD_URL=https://repo1.maven.org/maven2/com/lihaoyi/mill-dist!ARTIFACT_SUFFIX!/!MILL_VERSION!/mill-dist!ARTIFACT_SUFFIX!-!MILL_VERSION!.jar 206 | ) else ( 207 | set DOWNLOAD_URL=!GITHUB_RELEASE_CDN!%MILL_REPO_URL%/releases/download/!MILL_VERSION_TAG!/!MILL_VERSION!!DOWNLOAD_SUFFIX! 208 | ) 209 | 210 | echo Downloading mill !MILL_VERSION! from !DOWNLOAD_URL! ... 1>&2 211 | 212 | if not exist "%MILL_DOWNLOAD_PATH%" mkdir "%MILL_DOWNLOAD_PATH%" 213 | rem curl is bundled with recent Windows 10 214 | rem but I don't think we can expect all the users to have it in 2019 215 | where /Q curl 216 | if !ERRORLEVEL! EQU 0 ( 217 | curl -f -L "!DOWNLOAD_URL!" -o "!DOWNLOAD_FILE!" 218 | ) else ( 219 | rem bitsadmin seems to be available on Windows 7 220 | rem without /dynamic, github returns 403 221 | rem bitsadmin is sometimes needlessly slow but it looks better with /priority foreground 222 | bitsadmin /transfer millDownloadJob /dynamic /priority foreground "!DOWNLOAD_URL!" "!DOWNLOAD_FILE!" 223 | ) 224 | if not exist "!DOWNLOAD_FILE!" ( 225 | echo Could not download mill !MILL_VERSION! 1>&2 226 | exit /b 1 227 | ) 228 | 229 | move /y "!DOWNLOAD_FILE!" "%MILL%" 230 | 231 | set DOWNLOAD_FILE= 232 | set DOWNLOAD_SUFFIX= 233 | ) 234 | 235 | set MILL_DOWNLOAD_PATH= 236 | set MILL_VERSION= 237 | set MILL_REPO_URL= 238 | 239 | rem Need to preserve the first position of those listed options 240 | set MILL_FIRST_ARG= 241 | if [%~1%]==[--bsp] ( 242 | set MILL_FIRST_ARG=%1% 243 | ) else ( 244 | if [%~1%]==[-i] ( 245 | set MILL_FIRST_ARG=%1% 246 | ) else ( 247 | if [%~1%]==[--interactive] ( 248 | set MILL_FIRST_ARG=%1% 249 | ) else ( 250 | if [%~1%]==[--no-server] ( 251 | set MILL_FIRST_ARG=%1% 252 | ) else ( 253 | if [%~1%]==[--repl] ( 254 | set MILL_FIRST_ARG=%1% 255 | ) else ( 256 | if [%~1%]==[--help] ( 257 | set MILL_FIRST_ARG=%1% 258 | ) 259 | ) 260 | ) 261 | ) 262 | ) 263 | ) 264 | 265 | set "MILL_PARAMS=%*%" 266 | 267 | if not [!MILL_FIRST_ARG!]==[] ( 268 | if defined STRIP_VERSION_PARAMS ( 269 | for /f "tokens=1-3*" %%a in ("%*") do ( 270 | set "MILL_PARAMS=%%d" 271 | ) 272 | ) else ( 273 | for /f "tokens=1*" %%a in ("%*") do ( 274 | set "MILL_PARAMS=%%b" 275 | ) 276 | ) 277 | ) else ( 278 | if defined STRIP_VERSION_PARAMS ( 279 | for /f "tokens=1-2*" %%a in ("%*") do ( 280 | rem strip %%a - It's the "--mill-version" option. 281 | rem strip %%b - it's the version number that comes after the option. 282 | rem keep %%c - It's the remaining options. 283 | set "MILL_PARAMS=%%c" 284 | ) 285 | ) 286 | ) 287 | 288 | "%MILL%" %MILL_FIRST_ARG% -D "mill.main.cli=%MILL_MAIN_CLI%" %MILL_PARAMS% 289 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2022", /* 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 | --------------------------------------------------------------------------------