├── .eslintignore ├── .eslintrc.json ├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ └── test.yml ├── .gitignore ├── .nvmrc ├── .prettierignore ├── .prettierrc.json ├── LICENSE ├── README.md ├── action.yml ├── dist ├── index.js ├── index.js.map ├── licenses.txt └── sourcemap-register.js ├── jest.config.js ├── package-lock.json ├── package.json ├── src ├── branchProtection.ts ├── issue.ts ├── main.ts ├── pullRequest.ts ├── type.ts ├── user.ts ├── utils.test.ts ├── utils.ts └── wait.ts └── tsconfig.json /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ 4 | jest.config.js 5 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["jest", "@typescript-eslint"], 3 | "extends": ["plugin:github/recommended"], 4 | "parser": "@typescript-eslint/parser", 5 | "parserOptions": { 6 | "ecmaVersion": 9, 7 | "sourceType": "module", 8 | "project": "./tsconfig.json" 9 | }, 10 | "rules": { 11 | "no-shadow": "off", 12 | "eslint-comments/no-use": "off", 13 | "import/no-namespace": "off", 14 | "no-unused-vars": "off", 15 | "sort-imports": "off", 16 | "filenames/match-regex": "off", 17 | "i18n-text/no-en": "off", 18 | "@typescript-eslint/no-unused-vars": "error", 19 | "@typescript-eslint/explicit-member-accessibility": [ 20 | "error", 21 | {"accessibility": "no-public"} 22 | ], 23 | "@typescript-eslint/no-require-imports": "error", 24 | "@typescript-eslint/array-type": "error", 25 | "@typescript-eslint/await-thenable": "error", 26 | "@typescript-eslint/ban-ts-comment": "error", 27 | "camelcase": "off", 28 | "@typescript-eslint/consistent-type-assertions": "error", 29 | "@typescript-eslint/explicit-function-return-type": [ 30 | "error", 31 | {"allowExpressions": true} 32 | ], 33 | "@typescript-eslint/func-call-spacing": ["error", "never"], 34 | "@typescript-eslint/no-array-constructor": "error", 35 | "@typescript-eslint/no-empty-interface": "error", 36 | "@typescript-eslint/no-explicit-any": "error", 37 | "@typescript-eslint/no-extraneous-class": "error", 38 | "@typescript-eslint/no-for-in-array": "error", 39 | "@typescript-eslint/no-inferrable-types": "error", 40 | "@typescript-eslint/no-misused-new": "error", 41 | "@typescript-eslint/no-namespace": "error", 42 | "@typescript-eslint/no-non-null-assertion": "warn", 43 | "@typescript-eslint/no-unnecessary-qualifier": "error", 44 | "@typescript-eslint/no-unnecessary-type-assertion": "error", 45 | "@typescript-eslint/no-useless-constructor": "error", 46 | "@typescript-eslint/no-var-requires": "error", 47 | "@typescript-eslint/prefer-for-of": "warn", 48 | "@typescript-eslint/prefer-function-type": "warn", 49 | "@typescript-eslint/prefer-includes": "error", 50 | "@typescript-eslint/prefer-string-starts-ends-with": "error", 51 | "@typescript-eslint/promise-function-async": "error", 52 | "@typescript-eslint/require-array-sort-compare": "error", 53 | "@typescript-eslint/restrict-plus-operands": "error", 54 | "semi": "off", 55 | "@typescript-eslint/semi": ["error", "never"], 56 | "@typescript-eslint/type-annotation-spacing": "error", 57 | "@typescript-eslint/unbound-method": "error" 58 | }, 59 | "env": { 60 | "node": true, 61 | "es6": true, 62 | "jest/globals": true 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | dist/** -diff linguist-generated=true -------------------------------------------------------------------------------- /.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 | rebase-strategy: 'disabled' 11 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: 'build-test' 2 | on: # rebuild any PRs and main branch changes 3 | pull_request: 4 | push: 5 | branches: 6 | - main 7 | - 'releases/*' 8 | 9 | jobs: 10 | build: # make sure build/ci work properly 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - run: | 15 | npm install 16 | - run: | 17 | npm run all 18 | test: # make sure the action works on a clean machine without building 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: actions/checkout@v4 22 | - uses: ./ 23 | with: 24 | token: ${{ secrets.ACTION_PAT }} 25 | requiredApprovals: 2 26 | requiredLabels: auto-merge 27 | requiredStatusChecks: | 28 | build 29 | test 30 | -------------------------------------------------------------------------------- /.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 | # Custom 102 | action/ 103 | temp/ 104 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v16 2 | -------------------------------------------------------------------------------- /.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 | # Update Branch 2 | 3 | Merge your pull request in order when enabled the `Require branches to be up to date before merging`. 4 | 5 | Inspired by [Merge Queue feature of Mergify](https://mergify.io/features/merge-queue). 6 | 7 | > Safety 8 | > 9 | > Do not merge broken pull requests. By merging your pull requests serially using a queue, your code is safe. Each pull request is tested with the latest CI code. 10 | 11 | > Save CI time 12 | > 13 | > Rather than overconsuming your CI time by trying to merge multiple pull requests, just run it once before the pull request gets merged. 14 | 15 | ## Quick Start 16 | 17 | > This action only has effect if you enabled `Settings/Branches/YourBranchProtectionRule/Require status checks to pass before merging/Require branches to be up to date before merging`. 18 | 19 | 1. Enable `Allow auto-merge` in `Settings/Options`. 20 | 21 | 2. Create a workflow file (`.github/workflow/update-branch.yaml`): 22 | 23 | Example: 24 | 25 | ```yaml 26 | name: Update branch 27 | 28 | on: 29 | push: 30 | branches: 31 | - main 32 | pull_request: 33 | types: 34 | - labeled 35 | check_suite: 36 | types: 37 | - completed 38 | 39 | # Allows you to run this workflow manually from the Actions tab 40 | workflow_dispatch: 41 | 42 | jobs: 43 | update-branch: 44 | runs-on: ubuntu-latest 45 | steps: 46 | - uses: lcdsmao/update-branch@v3 47 | with: 48 | # Or use personal access token 49 | token: ${{ secrets.GITHUB_TOKEN }} 50 | # One of MERGE, SQUASH, REBASE (default: MERGE) 51 | autoMergeMethod: SQUASH 52 | # Ignore pull requests without these labels 53 | requiredLabels: auto-merge 54 | # Required at least 2 approves (default: 0) 55 | requiredApprovals: 2 56 | # Required approvals from all requested reviewers 57 | allRequestedReviewersMustApprove: true 58 | # Required these status checks success 59 | requiredStatusChecks: | 60 | build_pr 61 | WIP 62 | # Optionally set the maximum amount of pull requests to match against (default: 50) 63 | fetchMaxPr: 50 64 | # Optionally set the maximum amount of pull request checks to fetch (default: 100) 65 | fetchMaxPrChecks: 100 66 | # Optionally set the maximum amount of pull request labels to fetch (default: 10) 67 | fetchMaxPrLabels: 10 68 | # Optionally set the maximum amount of pull request comments to fetch (default: 50) 69 | fetchMaxComments: 50 70 | # The order pr checks should be fetched in. If the required checks are the last ones, consider setting to "last" 71 | prChecksFetchOrder: first 72 | ``` 73 | 74 | If you are using a personal access token and it has permission to access branch protection rules, you can set your jobs like: 75 | 76 | ```yaml 77 | jobs: 78 | update-branch: 79 | runs-on: ubuntu-latest 80 | steps: 81 | - uses: lcdsmao/update-branch@v3 82 | with: 83 | # Personal access token 84 | token: ${{ secrets.MY_PAT }} 85 | # One of MERGE, SQUASH, REBASE (default: MERGE) 86 | autoMergeMethod: SQUASH 87 | # Ignore pull requests without these labels 88 | requiredLabels: auto-merge 89 | # `Status checks` and `Require approvals` settings will be used 90 | # Or ignore this key then the action will automatically find main or master branch protection rule 91 | protectedBranchNamePattern: trunk 92 | ``` 93 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Update Branch' 2 | description: 'Merge your pull request in order when enabled the `Require branches to be up to date before merging`' 3 | author: 'lcdsmao' 4 | branding: 5 | icon: 'zap' 6 | color: 'yellow' 7 | inputs: 8 | token: 9 | required: true 10 | description: 'Github token or personal access token. Require personal access token to access branch protection rules or trigger other workflows.' 11 | autoMergeMethod: 12 | required: false 13 | description: 'Method to use when enable pull request auto merge.' 14 | default: 'MERGE' 15 | requiredLabels: 16 | required: false 17 | description: 'Labels must be present before merging.' 18 | requiredApprovals: 19 | required: false 20 | description: 'Count of approvals must be this number before merging.' 21 | default: '0' 22 | allRequestedReviewersMustApprove: 23 | required: false 24 | description: 'Must get approvals from all requested reviewers before merging.' 25 | default: 'true' 26 | requiredStatusChecks: 27 | required: false 28 | description: 'Multiple status checks required to be success.' 29 | default: '' 30 | protectedBranchNamePattern: 31 | required: false 32 | description: 'The name pattern of GitHub branch protection rules to apply. The default behavior is to find the name pattern of main or master. Require personal access token to let this feature work.' 33 | default: '' 34 | fetchMaxPr: 35 | required: false 36 | description: 'The maximum amount of pull request fetch when searching for eligible pull requests.' 37 | default: '50' 38 | fetchMaxPrChecks: 39 | required: false 40 | description: 'The maximum amount of pull request checks to fetch when searching for requiredStatusChecks.' 41 | default: '100' 42 | fetchMaxPrLabels: 43 | required: false 44 | description: 'The maximum amount of pull request labels to fetch when searching for requiredLabels.' 45 | default: '10' 46 | fetchMaxComments: 47 | required: false 48 | description: 'The maximum amount of comments to fetch when checking for required conversaion resolution.' 49 | default: '50' 50 | prChecksFetchOrder: 51 | required: false 52 | description: 'The order pr checks should be fetched in. If the required checks are the last ones, consider setting to "last"' 53 | default: 'first' 54 | runs: 55 | using: 'node16' 56 | main: 'dist/index.js' 57 | -------------------------------------------------------------------------------- /dist/licenses.txt: -------------------------------------------------------------------------------- 1 | @actions/core 2 | MIT 3 | The MIT License (MIT) 4 | 5 | Copyright 2019 GitHub 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | @actions/github 14 | MIT 15 | The MIT License (MIT) 16 | 17 | Copyright 2019 GitHub 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | @actions/http-client 26 | MIT 27 | Actions Http Client for Node.js 28 | 29 | Copyright (c) GitHub, Inc. 30 | 31 | All rights reserved. 32 | 33 | MIT License 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 36 | associated documentation files (the "Software"), to deal in the Software without restriction, 37 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 38 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 39 | subject to the following conditions: 40 | 41 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 44 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 45 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 46 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 47 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 48 | 49 | 50 | @octokit/auth-token 51 | MIT 52 | The MIT License 53 | 54 | Copyright (c) 2019 Octokit contributors 55 | 56 | Permission is hereby granted, free of charge, to any person obtaining a copy 57 | of this software and associated documentation files (the "Software"), to deal 58 | in the Software without restriction, including without limitation the rights 59 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 60 | copies of the Software, and to permit persons to whom the Software is 61 | furnished to do so, subject to the following conditions: 62 | 63 | The above copyright notice and this permission notice shall be included in 64 | all copies or substantial portions of the Software. 65 | 66 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 67 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 68 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 69 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 70 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 71 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 72 | THE SOFTWARE. 73 | 74 | 75 | @octokit/core 76 | MIT 77 | The MIT License 78 | 79 | Copyright (c) 2019 Octokit contributors 80 | 81 | Permission is hereby granted, free of charge, to any person obtaining a copy 82 | of this software and associated documentation files (the "Software"), to deal 83 | in the Software without restriction, including without limitation the rights 84 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 85 | copies of the Software, and to permit persons to whom the Software is 86 | furnished to do so, subject to the following conditions: 87 | 88 | The above copyright notice and this permission notice shall be included in 89 | all copies or substantial portions of the Software. 90 | 91 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 92 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 93 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 94 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 95 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 96 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 97 | THE SOFTWARE. 98 | 99 | 100 | @octokit/endpoint 101 | MIT 102 | The MIT License 103 | 104 | Copyright (c) 2018 Octokit contributors 105 | 106 | Permission is hereby granted, free of charge, to any person obtaining a copy 107 | of this software and associated documentation files (the "Software"), to deal 108 | in the Software without restriction, including without limitation the rights 109 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 110 | copies of the Software, and to permit persons to whom the Software is 111 | furnished to do so, subject to the following conditions: 112 | 113 | The above copyright notice and this permission notice shall be included in 114 | all copies or substantial portions of the Software. 115 | 116 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 117 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 118 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 119 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 120 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 121 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 122 | THE SOFTWARE. 123 | 124 | 125 | @octokit/graphql 126 | MIT 127 | The MIT License 128 | 129 | Copyright (c) 2018 Octokit contributors 130 | 131 | Permission is hereby granted, free of charge, to any person obtaining a copy 132 | of this software and associated documentation files (the "Software"), to deal 133 | in the Software without restriction, including without limitation the rights 134 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 135 | copies of the Software, and to permit persons to whom the Software is 136 | furnished to do so, subject to the following conditions: 137 | 138 | The above copyright notice and this permission notice shall be included in 139 | all copies or substantial portions of the Software. 140 | 141 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 142 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 143 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 144 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 145 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 146 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 147 | THE SOFTWARE. 148 | 149 | 150 | @octokit/plugin-paginate-rest 151 | MIT 152 | MIT License Copyright (c) 2019 Octokit contributors 153 | 154 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 155 | 156 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 157 | 158 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 159 | 160 | 161 | @octokit/plugin-rest-endpoint-methods 162 | MIT 163 | MIT License Copyright (c) 2019 Octokit contributors 164 | 165 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 166 | 167 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 168 | 169 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 170 | 171 | 172 | @octokit/request 173 | MIT 174 | The MIT License 175 | 176 | Copyright (c) 2018 Octokit contributors 177 | 178 | Permission is hereby granted, free of charge, to any person obtaining a copy 179 | of this software and associated documentation files (the "Software"), to deal 180 | in the Software without restriction, including without limitation the rights 181 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 182 | copies of the Software, and to permit persons to whom the Software is 183 | furnished to do so, subject to the following conditions: 184 | 185 | The above copyright notice and this permission notice shall be included in 186 | all copies or substantial portions of the Software. 187 | 188 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 189 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 190 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 191 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 192 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 193 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 194 | THE SOFTWARE. 195 | 196 | 197 | @octokit/request-error 198 | MIT 199 | The MIT License 200 | 201 | Copyright (c) 2019 Octokit contributors 202 | 203 | Permission is hereby granted, free of charge, to any person obtaining a copy 204 | of this software and associated documentation files (the "Software"), to deal 205 | in the Software without restriction, including without limitation the rights 206 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 207 | copies of the Software, and to permit persons to whom the Software is 208 | furnished to do so, subject to the following conditions: 209 | 210 | The above copyright notice and this permission notice shall be included in 211 | all copies or substantial portions of the Software. 212 | 213 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 214 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 215 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 216 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 217 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 218 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 219 | THE SOFTWARE. 220 | 221 | 222 | @vercel/ncc 223 | MIT 224 | Copyright 2018 ZEIT, Inc. 225 | 226 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 227 | 228 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 229 | 230 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 231 | 232 | async-retry 233 | MIT 234 | The MIT License (MIT) 235 | 236 | Copyright (c) 2021 Vercel, Inc. 237 | 238 | Permission is hereby granted, free of charge, to any person obtaining a copy 239 | of this software and associated documentation files (the "Software"), to deal 240 | in the Software without restriction, including without limitation the rights 241 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 242 | copies of the Software, and to permit persons to whom the Software is 243 | furnished to do so, subject to the following conditions: 244 | 245 | The above copyright notice and this permission notice shall be included in all 246 | copies or substantial portions of the Software. 247 | 248 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 249 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 250 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 251 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 252 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 253 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 254 | SOFTWARE. 255 | 256 | 257 | balanced-match 258 | MIT 259 | (MIT) 260 | 261 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 262 | 263 | Permission is hereby granted, free of charge, to any person obtaining a copy of 264 | this software and associated documentation files (the "Software"), to deal in 265 | the Software without restriction, including without limitation the rights to 266 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 267 | of the Software, and to permit persons to whom the Software is furnished to do 268 | so, subject to the following conditions: 269 | 270 | The above copyright notice and this permission notice shall be included in all 271 | copies or substantial portions of the Software. 272 | 273 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 274 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 275 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 276 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 277 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 278 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 279 | SOFTWARE. 280 | 281 | 282 | before-after-hook 283 | Apache-2.0 284 | Apache License 285 | Version 2.0, January 2004 286 | http://www.apache.org/licenses/ 287 | 288 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 289 | 290 | 1. Definitions. 291 | 292 | "License" shall mean the terms and conditions for use, reproduction, 293 | and distribution as defined by Sections 1 through 9 of this document. 294 | 295 | "Licensor" shall mean the copyright owner or entity authorized by 296 | the copyright owner that is granting the License. 297 | 298 | "Legal Entity" shall mean the union of the acting entity and all 299 | other entities that control, are controlled by, or are under common 300 | control with that entity. For the purposes of this definition, 301 | "control" means (i) the power, direct or indirect, to cause the 302 | direction or management of such entity, whether by contract or 303 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 304 | outstanding shares, or (iii) beneficial ownership of such entity. 305 | 306 | "You" (or "Your") shall mean an individual or Legal Entity 307 | exercising permissions granted by this License. 308 | 309 | "Source" form shall mean the preferred form for making modifications, 310 | including but not limited to software source code, documentation 311 | source, and configuration files. 312 | 313 | "Object" form shall mean any form resulting from mechanical 314 | transformation or translation of a Source form, including but 315 | not limited to compiled object code, generated documentation, 316 | and conversions to other media types. 317 | 318 | "Work" shall mean the work of authorship, whether in Source or 319 | Object form, made available under the License, as indicated by a 320 | copyright notice that is included in or attached to the work 321 | (an example is provided in the Appendix below). 322 | 323 | "Derivative Works" shall mean any work, whether in Source or Object 324 | form, that is based on (or derived from) the Work and for which the 325 | editorial revisions, annotations, elaborations, or other modifications 326 | represent, as a whole, an original work of authorship. For the purposes 327 | of this License, Derivative Works shall not include works that remain 328 | separable from, or merely link (or bind by name) to the interfaces of, 329 | the Work and Derivative Works thereof. 330 | 331 | "Contribution" shall mean any work of authorship, including 332 | the original version of the Work and any modifications or additions 333 | to that Work or Derivative Works thereof, that is intentionally 334 | submitted to Licensor for inclusion in the Work by the copyright owner 335 | or by an individual or Legal Entity authorized to submit on behalf of 336 | the copyright owner. For the purposes of this definition, "submitted" 337 | means any form of electronic, verbal, or written communication sent 338 | to the Licensor or its representatives, including but not limited to 339 | communication on electronic mailing lists, source code control systems, 340 | and issue tracking systems that are managed by, or on behalf of, the 341 | Licensor for the purpose of discussing and improving the Work, but 342 | excluding communication that is conspicuously marked or otherwise 343 | designated in writing by the copyright owner as "Not a Contribution." 344 | 345 | "Contributor" shall mean Licensor and any individual or Legal Entity 346 | on behalf of whom a Contribution has been received by Licensor and 347 | subsequently incorporated within the Work. 348 | 349 | 2. Grant of Copyright License. Subject to the terms and conditions of 350 | this License, each Contributor hereby grants to You a perpetual, 351 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 352 | copyright license to reproduce, prepare Derivative Works of, 353 | publicly display, publicly perform, sublicense, and distribute the 354 | Work and such Derivative Works in Source or Object form. 355 | 356 | 3. Grant of Patent License. Subject to the terms and conditions of 357 | this License, each Contributor hereby grants to You a perpetual, 358 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 359 | (except as stated in this section) patent license to make, have made, 360 | use, offer to sell, sell, import, and otherwise transfer the Work, 361 | where such license applies only to those patent claims licensable 362 | by such Contributor that are necessarily infringed by their 363 | Contribution(s) alone or by combination of their Contribution(s) 364 | with the Work to which such Contribution(s) was submitted. If You 365 | institute patent litigation against any entity (including a 366 | cross-claim or counterclaim in a lawsuit) alleging that the Work 367 | or a Contribution incorporated within the Work constitutes direct 368 | or contributory patent infringement, then any patent licenses 369 | granted to You under this License for that Work shall terminate 370 | as of the date such litigation is filed. 371 | 372 | 4. Redistribution. You may reproduce and distribute copies of the 373 | Work or Derivative Works thereof in any medium, with or without 374 | modifications, and in Source or Object form, provided that You 375 | meet the following conditions: 376 | 377 | (a) You must give any other recipients of the Work or 378 | Derivative Works a copy of this License; and 379 | 380 | (b) You must cause any modified files to carry prominent notices 381 | stating that You changed the files; and 382 | 383 | (c) You must retain, in the Source form of any Derivative Works 384 | that You distribute, all copyright, patent, trademark, and 385 | attribution notices from the Source form of the Work, 386 | excluding those notices that do not pertain to any part of 387 | the Derivative Works; and 388 | 389 | (d) If the Work includes a "NOTICE" text file as part of its 390 | distribution, then any Derivative Works that You distribute must 391 | include a readable copy of the attribution notices contained 392 | within such NOTICE file, excluding those notices that do not 393 | pertain to any part of the Derivative Works, in at least one 394 | of the following places: within a NOTICE text file distributed 395 | as part of the Derivative Works; within the Source form or 396 | documentation, if provided along with the Derivative Works; or, 397 | within a display generated by the Derivative Works, if and 398 | wherever such third-party notices normally appear. The contents 399 | of the NOTICE file are for informational purposes only and 400 | do not modify the License. You may add Your own attribution 401 | notices within Derivative Works that You distribute, alongside 402 | or as an addendum to the NOTICE text from the Work, provided 403 | that such additional attribution notices cannot be construed 404 | as modifying the License. 405 | 406 | You may add Your own copyright statement to Your modifications and 407 | may provide additional or different license terms and conditions 408 | for use, reproduction, or distribution of Your modifications, or 409 | for any such Derivative Works as a whole, provided Your use, 410 | reproduction, and distribution of the Work otherwise complies with 411 | the conditions stated in this License. 412 | 413 | 5. Submission of Contributions. Unless You explicitly state otherwise, 414 | any Contribution intentionally submitted for inclusion in the Work 415 | by You to the Licensor shall be under the terms and conditions of 416 | this License, without any additional terms or conditions. 417 | Notwithstanding the above, nothing herein shall supersede or modify 418 | the terms of any separate license agreement you may have executed 419 | with Licensor regarding such Contributions. 420 | 421 | 6. Trademarks. This License does not grant permission to use the trade 422 | names, trademarks, service marks, or product names of the Licensor, 423 | except as required for reasonable and customary use in describing the 424 | origin of the Work and reproducing the content of the NOTICE file. 425 | 426 | 7. Disclaimer of Warranty. Unless required by applicable law or 427 | agreed to in writing, Licensor provides the Work (and each 428 | Contributor provides its Contributions) on an "AS IS" BASIS, 429 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 430 | implied, including, without limitation, any warranties or conditions 431 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 432 | PARTICULAR PURPOSE. You are solely responsible for determining the 433 | appropriateness of using or redistributing the Work and assume any 434 | risks associated with Your exercise of permissions under this License. 435 | 436 | 8. Limitation of Liability. In no event and under no legal theory, 437 | whether in tort (including negligence), contract, or otherwise, 438 | unless required by applicable law (such as deliberate and grossly 439 | negligent acts) or agreed to in writing, shall any Contributor be 440 | liable to You for damages, including any direct, indirect, special, 441 | incidental, or consequential damages of any character arising as a 442 | result of this License or out of the use or inability to use the 443 | Work (including but not limited to damages for loss of goodwill, 444 | work stoppage, computer failure or malfunction, or any and all 445 | other commercial damages or losses), even if such Contributor 446 | has been advised of the possibility of such damages. 447 | 448 | 9. Accepting Warranty or Additional Liability. While redistributing 449 | the Work or Derivative Works thereof, You may choose to offer, 450 | and charge a fee for, acceptance of support, warranty, indemnity, 451 | or other liability obligations and/or rights consistent with this 452 | License. However, in accepting such obligations, You may act only 453 | on Your own behalf and on Your sole responsibility, not on behalf 454 | of any other Contributor, and only if You agree to indemnify, 455 | defend, and hold each Contributor harmless for any liability 456 | incurred by, or claims asserted against, such Contributor by reason 457 | of your accepting any such warranty or additional liability. 458 | 459 | END OF TERMS AND CONDITIONS 460 | 461 | APPENDIX: How to apply the Apache License to your work. 462 | 463 | To apply the Apache License to your work, attach the following 464 | boilerplate notice, with the fields enclosed by brackets "{}" 465 | replaced with your own identifying information. (Don't include 466 | the brackets!) The text should be enclosed in the appropriate 467 | comment syntax for the file format. We also recommend that a 468 | file or class name and description of purpose be included on the 469 | same "printed page" as the copyright notice for easier 470 | identification within third-party archives. 471 | 472 | Copyright 2018 Gregor Martynus and other contributors. 473 | 474 | Licensed under the Apache License, Version 2.0 (the "License"); 475 | you may not use this file except in compliance with the License. 476 | You may obtain a copy of the License at 477 | 478 | http://www.apache.org/licenses/LICENSE-2.0 479 | 480 | Unless required by applicable law or agreed to in writing, software 481 | distributed under the License is distributed on an "AS IS" BASIS, 482 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 483 | See the License for the specific language governing permissions and 484 | limitations under the License. 485 | 486 | 487 | brace-expansion 488 | MIT 489 | MIT License 490 | 491 | Copyright (c) 2013 Julian Gruber 492 | 493 | Permission is hereby granted, free of charge, to any person obtaining a copy 494 | of this software and associated documentation files (the "Software"), to deal 495 | in the Software without restriction, including without limitation the rights 496 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 497 | copies of the Software, and to permit persons to whom the Software is 498 | furnished to do so, subject to the following conditions: 499 | 500 | The above copyright notice and this permission notice shall be included in all 501 | copies or substantial portions of the Software. 502 | 503 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 504 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 505 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 506 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 507 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 508 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 509 | SOFTWARE. 510 | 511 | 512 | deprecation 513 | ISC 514 | The ISC License 515 | 516 | Copyright (c) Gregor Martynus and contributors 517 | 518 | Permission to use, copy, modify, and/or distribute this software for any 519 | purpose with or without fee is hereby granted, provided that the above 520 | copyright notice and this permission notice appear in all copies. 521 | 522 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 523 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 524 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 525 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 526 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 527 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 528 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 529 | 530 | 531 | is-plain-object 532 | MIT 533 | The MIT License (MIT) 534 | 535 | Copyright (c) 2014-2017, Jon Schlinkert. 536 | 537 | Permission is hereby granted, free of charge, to any person obtaining a copy 538 | of this software and associated documentation files (the "Software"), to deal 539 | in the Software without restriction, including without limitation the rights 540 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 541 | copies of the Software, and to permit persons to whom the Software is 542 | furnished to do so, subject to the following conditions: 543 | 544 | The above copyright notice and this permission notice shall be included in 545 | all copies or substantial portions of the Software. 546 | 547 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 548 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 549 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 550 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 551 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 552 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 553 | THE SOFTWARE. 554 | 555 | 556 | minimatch 557 | ISC 558 | The ISC License 559 | 560 | Copyright (c) 2011-2022 Isaac Z. Schlueter and Contributors 561 | 562 | Permission to use, copy, modify, and/or distribute this software for any 563 | purpose with or without fee is hereby granted, provided that the above 564 | copyright notice and this permission notice appear in all copies. 565 | 566 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 567 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 568 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 569 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 570 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 571 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 572 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 573 | 574 | 575 | node-fetch 576 | MIT 577 | The MIT License (MIT) 578 | 579 | Copyright (c) 2016 David Frank 580 | 581 | Permission is hereby granted, free of charge, to any person obtaining a copy 582 | of this software and associated documentation files (the "Software"), to deal 583 | in the Software without restriction, including without limitation the rights 584 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 585 | copies of the Software, and to permit persons to whom the Software is 586 | furnished to do so, subject to the following conditions: 587 | 588 | The above copyright notice and this permission notice shall be included in all 589 | copies or substantial portions of the Software. 590 | 591 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 592 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 593 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 594 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 595 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 596 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 597 | SOFTWARE. 598 | 599 | 600 | 601 | once 602 | ISC 603 | The ISC License 604 | 605 | Copyright (c) Isaac Z. Schlueter and Contributors 606 | 607 | Permission to use, copy, modify, and/or distribute this software for any 608 | purpose with or without fee is hereby granted, provided that the above 609 | copyright notice and this permission notice appear in all copies. 610 | 611 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 612 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 613 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 614 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 615 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 616 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 617 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 618 | 619 | 620 | retry 621 | MIT 622 | Copyright (c) 2011: 623 | Tim Koschützki (tim@debuggable.com) 624 | Felix Geisendörfer (felix@debuggable.com) 625 | 626 | Permission is hereby granted, free of charge, to any person obtaining a copy 627 | of this software and associated documentation files (the "Software"), to deal 628 | in the Software without restriction, including without limitation the rights 629 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 630 | copies of the Software, and to permit persons to whom the Software is 631 | furnished to do so, subject to the following conditions: 632 | 633 | The above copyright notice and this permission notice shall be included in 634 | all copies or substantial portions of the Software. 635 | 636 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 637 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 638 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 639 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 640 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 641 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 642 | THE SOFTWARE. 643 | 644 | 645 | tr46 646 | MIT 647 | 648 | tunnel 649 | MIT 650 | The MIT License (MIT) 651 | 652 | Copyright (c) 2012 Koichi Kobayashi 653 | 654 | Permission is hereby granted, free of charge, to any person obtaining a copy 655 | of this software and associated documentation files (the "Software"), to deal 656 | in the Software without restriction, including without limitation the rights 657 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 658 | copies of the Software, and to permit persons to whom the Software is 659 | furnished to do so, subject to the following conditions: 660 | 661 | The above copyright notice and this permission notice shall be included in 662 | all copies or substantial portions of the Software. 663 | 664 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 665 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 666 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 667 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 668 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 669 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 670 | THE SOFTWARE. 671 | 672 | 673 | universal-user-agent 674 | ISC 675 | # [ISC License](https://spdx.org/licenses/ISC) 676 | 677 | Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m) 678 | 679 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 680 | 681 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 682 | 683 | 684 | uuid 685 | MIT 686 | The MIT License (MIT) 687 | 688 | Copyright (c) 2010-2020 Robert Kieffer and other contributors 689 | 690 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 691 | 692 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 693 | 694 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 695 | 696 | 697 | webidl-conversions 698 | BSD-2-Clause 699 | # The BSD 2-Clause License 700 | 701 | Copyright (c) 2014, Domenic Denicola 702 | All rights reserved. 703 | 704 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 705 | 706 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 707 | 708 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 709 | 710 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 711 | 712 | 713 | whatwg-url 714 | MIT 715 | The MIT License (MIT) 716 | 717 | Copyright (c) 2015–2016 Sebastian Mayr 718 | 719 | Permission is hereby granted, free of charge, to any person obtaining a copy 720 | of this software and associated documentation files (the "Software"), to deal 721 | in the Software without restriction, including without limitation the rights 722 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 723 | copies of the Software, and to permit persons to whom the Software is 724 | furnished to do so, subject to the following conditions: 725 | 726 | The above copyright notice and this permission notice shall be included in 727 | all copies or substantial portions of the Software. 728 | 729 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 730 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 731 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 732 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 733 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 734 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 735 | THE SOFTWARE. 736 | 737 | 738 | wrappy 739 | ISC 740 | The ISC License 741 | 742 | Copyright (c) Isaac Z. Schlueter and Contributors 743 | 744 | Permission to use, copy, modify, and/or distribute this software for any 745 | purpose with or without fee is hereby granted, provided that the above 746 | copyright notice and this permission notice appear in all copies. 747 | 748 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 749 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 750 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 751 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 752 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 753 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 754 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 755 | -------------------------------------------------------------------------------- /dist/sourcemap-register.js: -------------------------------------------------------------------------------- 1 | (()=>{var e={650:e=>{var r=Object.prototype.toString;var n=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},274:(e,r,n)=>{var t=n(339);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(190);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}},680:(e,r,n)=>{var t=n(339);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.H=MappingList},758:(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(339);var i=n(345);var a=n(274).I;var u=n(449);var s=n(758).U;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"){d.push(v)}}}s(m,o.compareByGeneratedPositionsDeflated);this.__generatedMappings=m;s(d,o.compareByOriginalPositions);this.__originalMappings=d};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(449);var o=n(339);var i=n(274).I;var a=n(680).H;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 h=0,d=g.length;h0){if(!o.compareByGeneratedPositionsInflated(c,g[h-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.h=SourceMapGenerator},351:(e,r,n)=>{var t;var o=n(591).h;var i=n(339);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},997:(e,r,n)=>{n(591).h;r.SourceMapConsumer=n(952).SourceMapConsumer;n(351)},284:(e,r,n)=>{e=n.nmd(e);var t=n(997).SourceMapConsumer;var o=n(17);var i;try{i=n(147);if(!i.existsSync||!i.readFileSync){i=null}}catch(e){}var a=n(650);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 h=[];var d=[];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=h.slice(0);var _=d.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){h.length=0}h.unshift(r.retrieveFile)}if(r.retrieveSourceMap){if(r.overrideRetrieveSourceMap){d.length=0}d.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(){h.length=0;d.length=0;h=S.slice(0);d=_.slice(0);v=handlerExec(d);m=handlerExec(h)}},147:e=>{"use strict";e.exports=require("fs")},17: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__(284).install()})();module.exports=n})(); -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | clearMocks: true, 3 | moduleFileExtensions: ['js', 'ts'], 4 | testEnvironment: 'node', 5 | testMatch: ['**/*.test.ts'], 6 | testRunner: 'jest-circus/runner', 7 | transform: { 8 | '^.+\\.ts$': 'ts-jest' 9 | }, 10 | verbose: true 11 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "update-branch", 3 | "version": "3.0.0", 4 | "private": true, 5 | "description": "Merge your pull request in order.", 6 | "main": "lib/main.js", 7 | "scripts": { 8 | "build": "tsc", 9 | "format": "prettier --write **/*.ts", 10 | "format-check": "prettier --check **/*.ts", 11 | "lint": "eslint src/**/*.ts", 12 | "package": "ncc build --source-map --license licenses.txt", 13 | "test": "jest", 14 | "all": "npm run build && npm run format && npm run lint && npm run package && npm test" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/lcdsmao/update-branch.git" 19 | }, 20 | "keywords": [ 21 | "actions", 22 | "github", 23 | "auto-merge", 24 | "update-branch" 25 | ], 26 | "author": "MAO YUFENG", 27 | "license": "MIT", 28 | "dependencies": { 29 | "@actions/core": "^1.10.0", 30 | "@actions/github": "^5.0.0", 31 | "@octokit/graphql": "^5.0.4", 32 | "async-retry": "^1.3.3", 33 | "minimatch": "^5.0.0" 34 | }, 35 | "devDependencies": { 36 | "@types/async-retry": "^1.4.3", 37 | "@types/jest": "^29.2.0", 38 | "@types/minimatch": "^5.1.2", 39 | "@types/node": "^18.11.8", 40 | "@typescript-eslint/parser": "^5.12.0", 41 | "@vercel/ncc": "^0.34.0", 42 | "eslint": "^8.10.0", 43 | "eslint-plugin-github": "^4.3.0", 44 | "eslint-plugin-jest": "^27.1.3", 45 | "eslint-plugin-prettier": "^4.0.0", 46 | "jest": "^29.2.2", 47 | "jest-circus": "^29.2.2", 48 | "js-yaml": "^4.1.0", 49 | "prettier": "^2.4.1", 50 | "ts-jest": "^29.0.3", 51 | "typescript": "^4.4.3" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/branchProtection.ts: -------------------------------------------------------------------------------- 1 | import { 2 | BranchProtectionRuleInfo, 3 | GhContext, 4 | RepositoryListBranchProtectionRule 5 | } from './type' 6 | 7 | export async function getBranchProtectionRules( 8 | ctx: GhContext, 9 | pattern: string 10 | ): Promise { 11 | const response: RepositoryListBranchProtectionRule = 12 | await ctx.octokit.graphql( 13 | `query ($owner: String!, $repo: String!) { 14 | repository(name: $repo, owner: $owner) { 15 | branchProtectionRules(first: ${branchProtectionRuleCount}) { 16 | nodes { 17 | requiredApprovingReviewCount 18 | requiredStatusCheckContexts 19 | requiresConversationResolution 20 | pattern 21 | } 22 | } 23 | } 24 | }`, 25 | { 26 | owner: ctx.owner, 27 | repo: ctx.repo 28 | } 29 | ) 30 | return response.repository.branchProtectionRules.nodes.find(v => 31 | pattern 32 | ? v.pattern === pattern 33 | : v.pattern === 'main' || v.pattern === 'master' 34 | ) 35 | } 36 | 37 | const branchProtectionRuleCount = 10 38 | -------------------------------------------------------------------------------- /src/issue.ts: -------------------------------------------------------------------------------- 1 | import { 2 | GhContext, 3 | IssueInfo, 4 | RepositoryGetIssue, 5 | RepositoryListIssue 6 | } from './type' 7 | 8 | export async function findCreatedIssueWithBodyPrefix( 9 | ctx: GhContext, 10 | createdBy: string, 11 | bodyPrefix: string 12 | ): Promise { 13 | const data: RepositoryListIssue = await ctx.octokit.graphql( 14 | `query ($owner: String!, $repo: String!, $createdBy: String!) { 15 | repository(name: $repo, owner: $owner) { 16 | issues(first: 100, filterBy: {createdBy: $createdBy}, states: OPEN) { 17 | nodes { 18 | id 19 | body 20 | updatedAt 21 | } 22 | } 23 | } 24 | }`, 25 | { 26 | owner: ctx.owner, 27 | repo: ctx.repo, 28 | createdBy 29 | } 30 | ) 31 | return data.repository.issues.nodes.find(v => v.body.includes(bodyPrefix)) 32 | } 33 | 34 | export async function createIssue( 35 | ctx: GhContext, 36 | title: string 37 | ): Promise { 38 | const response = await ctx.octokit.request( 39 | 'POST /repos/{owner}/{repo}/issues', 40 | { 41 | owner: ctx.owner, 42 | repo: ctx.repo, 43 | title 44 | } 45 | ) 46 | return { 47 | id: response.data.node_id, 48 | body: '' 49 | } 50 | } 51 | 52 | export async function getIssue( 53 | ctx: GhContext, 54 | num: number 55 | ): Promise { 56 | const data: RepositoryGetIssue = await ctx.octokit.graphql( 57 | `query ($owner: String!, $repo: String!, $num: Int!) { 58 | repository(name: $repo, owner: $owner) { 59 | issue(number: $num) { 60 | id 61 | body 62 | } 63 | } 64 | }`, 65 | { 66 | owner: ctx.owner, 67 | repo: ctx.repo, 68 | num 69 | } 70 | ) 71 | return data.repository.issue 72 | } 73 | 74 | export async function updateIssue( 75 | ctx: GhContext, 76 | issue: IssueInfo 77 | ): Promise { 78 | await ctx.octokit.graphql( 79 | `mutation ($id: ID!, $body: String!) { 80 | updateIssue(input: {id: $id, body: $body}) { 81 | clientMutationId 82 | } 83 | }`, 84 | { 85 | id: issue.id, 86 | body: issue.body 87 | } 88 | ) 89 | } 90 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import * as github from '@actions/github' 3 | import {getBranchProtectionRules as getBranchProtectionRule} from './branchProtection' 4 | import {createIssue, findCreatedIssueWithBodyPrefix, updateIssue} from './issue' 5 | import { 6 | enablePullRequestAutoMerge, 7 | getPullRequest, 8 | listAvailablePullRequests, 9 | mergePullRequest, 10 | updateBranch 11 | } from './pullRequest' 12 | import {Condition, FetchConfig, GhContext, IssueInfo, RecordBody} from './type' 13 | import {getViewerName} from './user' 14 | import { 15 | createIssueBody, 16 | isIssueOutdated, 17 | isPendingMergePr, 18 | isStatusCheckPassPr, 19 | issueBodyPrefix, 20 | parseIssueBody, 21 | stringify 22 | } from './utils' 23 | 24 | async function run(): Promise { 25 | try { 26 | const token = core.getInput('token') 27 | const autoMergeMethod = core.getInput('autoMergeMethod') 28 | const requiredLabels = core 29 | .getInput('requiredLabels') 30 | .split('\n') 31 | .filter(s => s !== '') 32 | const requiredApprovals = parseInt(core.getInput('requiredApprovals')) 33 | const allRequestedReviewersMustApprove = 34 | core.getInput('allRequestedReviewersMustApprove') === 'true' 35 | const requiredStatusChecks = core 36 | .getInput('requiredStatusChecks') 37 | .split('\n') 38 | .filter(s => s !== '') 39 | const protectedBranchNamePattern = core.getInput( 40 | 'protectedBranchNamePattern' 41 | ) 42 | const prRunsContextOrder = core.getInput('prChecksFetchOrder') 43 | switch (prRunsContextOrder) { 44 | case 'first': 45 | case 'last': 46 | break 47 | default: 48 | core.setFailed( 49 | `prChecksFetchOrder=${prRunsContextOrder}. Valid values: [first, last]` 50 | ) 51 | return 52 | } 53 | const fetchConfig: FetchConfig = { 54 | prs: parseInt(core.getInput('fetchMaxPr')), 55 | checks: parseInt(core.getInput('fetchMaxPrChecks')), 56 | labels: parseInt(core.getInput('fetchMaxPrLabels')), 57 | comments: parseInt(core.getInput('fetchMaxComments')), 58 | prRunsContextOrder 59 | } 60 | 61 | const octokit = github.getOctokit(token) 62 | const {owner, repo} = github.context.repo 63 | const ctx: GhContext = {octokit, owner, repo, autoMergeMethod, fetchConfig} 64 | 65 | const branchProtectionRule = await getBranchProtectionRule( 66 | ctx, 67 | protectedBranchNamePattern 68 | ) 69 | 70 | const condition: Condition = { 71 | branchNamePattern: branchProtectionRule?.pattern, 72 | requiredApprovals: 73 | requiredApprovals || 74 | (branchProtectionRule?.requiredApprovingReviewCount ?? 0), 75 | allRequestedReviewersMustApprove, 76 | requiresConversationResolution: 77 | branchProtectionRule?.requiresConversationResolution ?? false, 78 | requiredStatusChecks: [ 79 | ...requiredStatusChecks, 80 | ...(branchProtectionRule?.requiredStatusCheckContexts ?? []) 81 | ], 82 | requiredLabels 83 | } 84 | 85 | core.info('Condition:') 86 | core.info(stringify(condition)) 87 | 88 | const viewerName = await getViewerName(ctx) 89 | const {recordIssue, recordBody} = await getRecordIssue(ctx, viewerName) 90 | const recordIssueOutdated = isIssueOutdated(recordIssue) 91 | // Sometimes unknown errors may occur, and issue body editing keeps true. 92 | // We ignore the editing field if the issue is outdated. 93 | if (recordBody.editing && !recordIssueOutdated) { 94 | core.info('Other actions are editing record. Exit.') 95 | return 96 | } 97 | await updateRecordIssueBody(ctx, recordIssue, { 98 | ...recordBody, 99 | editing: true 100 | }) 101 | 102 | let newRecordBody: RecordBody = {...recordBody, editing: false} 103 | try { 104 | newRecordBody = await maybeUpdateBranchAndMerge( 105 | ctx, 106 | recordBody, 107 | condition 108 | ) 109 | } finally { 110 | await updateRecordIssueBody(ctx, recordIssue, newRecordBody) 111 | } 112 | } catch (error) { 113 | if (error instanceof Error) { 114 | core.setFailed(error.message) 115 | } else if (typeof error === 'string') { 116 | core.setFailed(error) 117 | } 118 | } 119 | } 120 | 121 | async function maybeUpdateBranchAndMerge( 122 | ctx: GhContext, 123 | recordBody: RecordBody, 124 | condition: Condition 125 | ): Promise { 126 | const availablePrs = await listAvailablePullRequests(ctx) 127 | // Get pending merge pr after all pr status become available 128 | const pendingMergePrNum = recordBody.pendingMergePullRequestNumber 129 | if (pendingMergePrNum !== undefined) { 130 | const pendingMergePr = await getPullRequest(ctx, pendingMergePrNum) 131 | if (isPendingMergePr(pendingMergePr, condition)) { 132 | if ( 133 | pendingMergePr.mergeStateStatus === 'BLOCKED' || 134 | pendingMergePr.mergeStateStatus === 'UNKNOWN' 135 | ) { 136 | core.info(`Wait PR #${pendingMergePrNum} to be merged.`) 137 | return {...recordBody, editing: false} 138 | } else if (pendingMergePr.mergeStateStatus === 'BEHIND') { 139 | await enablePullRequestAutoMerge(ctx, pendingMergePr.id) 140 | await updateBranch(ctx, pendingMergePrNum) 141 | core.info( 142 | `Update branch and wait PR #${pendingMergePrNum} to be merged.` 143 | ) 144 | return {...recordBody, editing: false} 145 | } 146 | } 147 | core.info( 148 | `Pending merge PR #${pendingMergePrNum} can not be merged. Try to find other PR that needs update branch.` 149 | ) 150 | } 151 | 152 | const passPrs = availablePrs.filter(pr => isStatusCheckPassPr(pr, condition)) 153 | const cleanPr = passPrs.find( 154 | // Also allow UNSTABLE as we check via [isStatusCheckPassPr] and some checks maybe ignorable 155 | pr => pr.mergeStateStatus === 'CLEAN' || pr.mergeStateStatus === 'UNSTABLE' 156 | ) 157 | if (cleanPr) { 158 | core.info(`Merge PR #${cleanPr.number}.`) 159 | await mergePullRequest(ctx, cleanPr.id) 160 | return {editing: false} 161 | } 162 | 163 | const behindPr = passPrs.find(pr => pr.mergeStateStatus === 'BEHIND') 164 | if (behindPr) { 165 | core.info( 166 | `Found PR #${behindPr.number} can be merged. Try to update branch and enable auto merge.` 167 | ) 168 | await updateBranch(ctx, behindPr.number) 169 | await enablePullRequestAutoMerge(ctx, behindPr.id) 170 | return { 171 | editing: false, 172 | pendingMergePullRequestNumber: behindPr.number 173 | } 174 | } 175 | 176 | core.info('Found no PR that needs update branch.') 177 | return {editing: false} 178 | } 179 | 180 | async function updateRecordIssueBody( 181 | ctx: GhContext, 182 | recordIssue: IssueInfo, 183 | body: RecordBody 184 | ): Promise { 185 | await updateIssue(ctx, { 186 | ...recordIssue, 187 | body: createIssueBody(body) 188 | }) 189 | } 190 | 191 | async function getRecordIssue( 192 | ctx: GhContext, 193 | createdBy: string 194 | ): Promise<{recordIssue: IssueInfo; recordBody: RecordBody}> { 195 | let recordIssue = await findCreatedIssueWithBodyPrefix( 196 | ctx, 197 | createdBy, 198 | issueBodyPrefix 199 | ) 200 | if (!recordIssue) { 201 | recordIssue = await createIssue(ctx, issueTitle) 202 | } 203 | const recordBody = parseIssueBody(recordIssue.body) 204 | return { 205 | recordIssue, 206 | recordBody 207 | } 208 | } 209 | 210 | const issueTitle = 'Update Branch Dashboard' 211 | 212 | run() 213 | -------------------------------------------------------------------------------- /src/pullRequest.ts: -------------------------------------------------------------------------------- 1 | import retry from 'async-retry' 2 | import { 3 | FetchConfig, 4 | GhContext, 5 | PullRequestInfo, 6 | RepositoryGetPullRequest, 7 | RepositoryListPullRequest 8 | } from './type' 9 | 10 | export async function getPullRequest( 11 | ctx: GhContext, 12 | num: number 13 | ): Promise { 14 | const result: RepositoryGetPullRequest = await ctx.octokit.graphql( 15 | `query ($owner: String!, $repo: String!, $num: Int!) { 16 | repository(name: $repo, owner: $owner) { 17 | pullRequest(number: $num) { 18 | ${getPullRequestFragment(ctx.fetchConfig)} 19 | } 20 | } 21 | }`, 22 | { 23 | headers: { 24 | accept: 'application/vnd.github.merge-info-preview+json' 25 | }, 26 | owner: ctx.owner, 27 | repo: ctx.repo, 28 | num 29 | } 30 | ) 31 | return result.repository.pullRequest 32 | } 33 | 34 | export async function listAvailablePullRequests( 35 | ctx: GhContext 36 | ): Promise { 37 | return await retry( 38 | async () => { 39 | const pullRequests = await listPullRequests(ctx) 40 | const isAvailable = pullRequests.every(pr => pr.mergeable !== 'UNKNOWN') 41 | if (!isAvailable) throw Error('Some PRs state are UNKNOWN.') 42 | return pullRequests 43 | }, 44 | { 45 | minTimeout: 3000, 46 | retries: 5 47 | } 48 | ) 49 | } 50 | 51 | export async function updateBranch(ctx: GhContext, num: number): Promise { 52 | await ctx.octokit.request( 53 | 'PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch', 54 | { 55 | owner: ctx.owner, 56 | repo: ctx.repo, 57 | pull_number: num 58 | } 59 | ) 60 | } 61 | 62 | export async function enablePullRequestAutoMerge( 63 | ctx: GhContext, 64 | prId: String 65 | ): Promise { 66 | await ctx.octokit.graphql( 67 | `mutation ($id: ID!, $mergeMethod: PullRequestMergeMethod) { 68 | enablePullRequestAutoMerge(input: { pullRequestId: $id, mergeMethod: $mergeMethod }) { 69 | clientMutationId 70 | } 71 | }`, 72 | { 73 | id: prId, 74 | mergeMethod: ctx.autoMergeMethod 75 | } 76 | ) 77 | } 78 | 79 | export async function mergePullRequest( 80 | ctx: GhContext, 81 | prId: String 82 | ): Promise { 83 | await ctx.octokit.graphql( 84 | `mutation ($id: ID!, $mergeMethod: PullRequestMergeMethod) { 85 | mergePullRequest(input: { pullRequestId: $id, mergeMethod: $mergeMethod }) { 86 | clientMutationId 87 | } 88 | }`, 89 | { 90 | id: prId, 91 | mergeMethod: ctx.autoMergeMethod 92 | } 93 | ) 94 | } 95 | 96 | async function listPullRequests(ctx: GhContext): Promise { 97 | const result: RepositoryListPullRequest = await ctx.octokit.graphql( 98 | `query ($owner: String!, $repo: String!) { 99 | repository(name: $repo, owner: $owner) { 100 | pullRequests(first: ${ctx.fetchConfig.prs}, states: OPEN) { 101 | nodes { 102 | ${getPullRequestFragment(ctx.fetchConfig)} 103 | } 104 | } 105 | } 106 | }`, 107 | { 108 | headers: { 109 | accept: 'application/vnd.github.merge-info-preview+json' 110 | }, 111 | owner: ctx.owner, 112 | repo: ctx.repo 113 | } 114 | ) 115 | return result.repository.pullRequests.nodes 116 | } 117 | 118 | function getPullRequestFragment(cfg: FetchConfig): string { 119 | return ` 120 | id 121 | title 122 | baseRefName 123 | number 124 | merged 125 | mergeable 126 | mergeStateStatus 127 | reviews(states: APPROVED) { 128 | totalCount 129 | } 130 | reviewRequests { 131 | totalCount 132 | } 133 | labels(first: ${cfg.labels}) { 134 | nodes { 135 | name 136 | } 137 | } 138 | reviewThreads(last: ${cfg.comments}) { 139 | nodes { 140 | isResolved 141 | } 142 | } 143 | commits(last: 1) { 144 | nodes { 145 | commit { 146 | statusCheckRollup { 147 | contexts(${cfg.prRunsContextOrder}: ${cfg.checks}) { 148 | nodes { 149 | ... on CheckRun { 150 | name 151 | conclusion 152 | } 153 | ... on StatusContext { 154 | context 155 | state 156 | } 157 | } 158 | } 159 | state 160 | } 161 | } 162 | } 163 | }` 164 | } 165 | -------------------------------------------------------------------------------- /src/type.ts: -------------------------------------------------------------------------------- 1 | import {Octokit} from '@octokit/core' 2 | 3 | export interface FetchConfig { 4 | prs: number 5 | labels: number 6 | comments: number 7 | checks: number 8 | prRunsContextOrder: 'first' | 'last' 9 | } 10 | 11 | export interface GhContext { 12 | octokit: Octokit 13 | owner: string 14 | repo: string 15 | autoMergeMethod: string 16 | fetchConfig: FetchConfig 17 | } 18 | 19 | export interface Condition { 20 | branchNamePattern?: string 21 | requiredApprovals: number 22 | requiredStatusChecks: string[] 23 | allRequestedReviewersMustApprove: boolean 24 | requiresConversationResolution: boolean 25 | requiredLabels: string[] 26 | } 27 | 28 | export interface RecordBody { 29 | editing?: boolean 30 | pendingMergePullRequestNumber?: number 31 | } 32 | 33 | // https://docs.github.com/en/graphql/reference/enums#mergestatestatus 34 | export type MergeStateStatus = 35 | | 'BEHIND' 36 | | 'BLOCKED' 37 | | 'CLEAN' 38 | | 'DIRTY' 39 | | 'HAS_HOOKS' 40 | | 'UNKNOWN' 41 | | 'UNSTABLE' 42 | 43 | // https://docs.github.com/en/graphql/reference/enums#mergeablestate 44 | export type MergeableState = 'CONFLICTING' | 'MERGEABLE' | 'UNKNOWN' 45 | 46 | // https://docs.github.com/en/graphql/reference/enums#statusstate 47 | export type StatusState = 48 | | 'ERROR' 49 | | 'EXPECTED' 50 | | 'FAILURE' 51 | | 'PENDING' 52 | | 'SUCCESS' 53 | 54 | // https://docs.github.com/en/graphql/reference/enums#checkconclusionstate 55 | export type CheckConclusionState = 56 | | 'ACTION_REQUIRED' 57 | | 'CANCELLED' 58 | | 'FAILURE' 59 | | 'NEUTRAL' 60 | | 'SKIPPED' 61 | | 'STALE' 62 | | 'STARTUP_FAILURE' 63 | | 'SUCCESS' 64 | | 'TIMED_OUT' 65 | 66 | export interface PullRequestInfo { 67 | id: string 68 | title: string 69 | baseRefName: string 70 | reviews: { 71 | totalCount: number 72 | } 73 | reviewRequests: { 74 | totalCount: number 75 | } 76 | labels: { 77 | nodes: LabelInfo[] 78 | } 79 | reviewThreads: { 80 | nodes: ReviewThread[] 81 | } 82 | number: number 83 | merged: boolean 84 | mergeable: MergeableState 85 | mergeStateStatus: MergeStateStatus 86 | commits: { 87 | nodes: CommitInfo[] 88 | } 89 | } 90 | 91 | export interface IssueInfo { 92 | id: string 93 | body: string 94 | updatedAt?: string 95 | } 96 | 97 | export interface ReviewThread { 98 | isResolved: boolean 99 | } 100 | 101 | export interface CommitInfo { 102 | commit: { 103 | statusCheckRollup?: StatusCheckRollupInfo 104 | } 105 | } 106 | 107 | export interface LabelInfo { 108 | name: string 109 | } 110 | 111 | export interface StatusCheckRollupInfo { 112 | state: StatusState 113 | contexts: { 114 | nodes: StatusCheckInfo[] 115 | } 116 | } 117 | 118 | export interface StatusCheckInfo { 119 | // on CheckRun 120 | name?: string 121 | conclusion?: CheckConclusionState 122 | // on StatusContext 123 | context?: string 124 | state?: StatusState 125 | } 126 | 127 | export interface BranchProtectionRuleInfo { 128 | pattern: string 129 | requiredApprovingReviewCount?: number 130 | requiredStatusCheckContexts: string[] 131 | requiresConversationResolution: boolean 132 | } 133 | 134 | export interface RepositoryData { 135 | repository: T 136 | } 137 | 138 | export type RepositoryListPullRequest = RepositoryData<{ 139 | pullRequests: { 140 | nodes: PullRequestInfo[] 141 | } 142 | }> 143 | 144 | export type RepositoryGetPullRequest = RepositoryData<{ 145 | pullRequest: PullRequestInfo 146 | }> 147 | 148 | export type RepositoryListIssue = RepositoryData<{ 149 | issues: { 150 | nodes: IssueInfo[] 151 | } 152 | }> 153 | 154 | export type RepositoryGetIssue = RepositoryData<{ 155 | issue: IssueInfo 156 | }> 157 | 158 | export type RepositoryListBranchProtectionRule = RepositoryData<{ 159 | branchProtectionRules: { 160 | nodes: BranchProtectionRuleInfo[] 161 | } 162 | }> 163 | 164 | export interface ViewerData { 165 | viewer: { 166 | login: string 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/user.ts: -------------------------------------------------------------------------------- 1 | import {GhContext, ViewerData} from './type' 2 | 3 | export async function getViewerName(ctx: GhContext): Promise { 4 | const data: ViewerData = await ctx.octokit.graphql(` 5 | query { 6 | viewer { 7 | login 8 | } 9 | }`) 10 | return data.viewer.login 11 | } 12 | -------------------------------------------------------------------------------- /src/utils.test.ts: -------------------------------------------------------------------------------- 1 | import {createIssueBody, parseIssueBody} from './utils' 2 | 3 | test('parseIssueBody', () => { 4 | const rawBody = ` 5 | 6 | This issue provides [lcdsmao/update-branch](https://github.com/lcdsmao/update-branch) status. 7 | 8 | Status: 9 | 10 | \`\`\`json 11 | { 12 | "editing": false, 13 | "pendingMergePullRequestNumber": 1234 14 | } 15 | \`\`\` 16 | 17 | ` 18 | const body = parseIssueBody(rawBody) 19 | expect(body).toEqual({editing: false, pendingMergePullRequestNumber: 1234}) 20 | }) 21 | 22 | test('createIssueBody', () => { 23 | const body = createIssueBody({ 24 | editing: true, 25 | pendingMergePullRequestNumber: 2048 26 | }) 27 | expect(body).toEqual(` 28 | 29 | This issue provides [lcdsmao/update-branch](https://github.com/lcdsmao/update-branch) status. 30 | 31 | Status: 32 | 33 | \`\`\`json 34 | { 35 | "editing": true, 36 | "pendingMergePullRequestNumber": 2048 37 | } 38 | \`\`\` 39 | `) 40 | }) 41 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | import minimatch from 'minimatch' 2 | import {Condition, IssueInfo, PullRequestInfo, RecordBody} from './type' 3 | 4 | export function isPendingMergePr( 5 | pr: PullRequestInfo, 6 | condition: Condition 7 | ): boolean { 8 | const check = pr.commits.nodes[0].commit.statusCheckRollup 9 | if (!check) return false 10 | const checkNodes = check.contexts.nodes 11 | return ( 12 | isSatisfyBasicConditionPr(pr, condition) && 13 | (checkNodes.some(v => v.state === 'PENDING') || check.state === 'PENDING') 14 | ) 15 | } 16 | 17 | export function isStatusCheckPassPr( 18 | pr: PullRequestInfo, 19 | condition: Condition 20 | ): boolean { 21 | return ( 22 | isSatisfyBasicConditionPr(pr, condition) && 23 | isStatusChecksSuccess(pr, condition) 24 | ) 25 | } 26 | 27 | export function stringify(obj: T): string { 28 | return JSON.stringify(obj, null, 2) 29 | } 30 | 31 | function checkConversationResolution(pr: PullRequestInfo): boolean { 32 | return pr.reviewThreads.nodes.every(v => v.isResolved) 33 | } 34 | 35 | // Except status check 36 | function isSatisfyBasicConditionPr( 37 | pr: PullRequestInfo, 38 | condition: Condition 39 | ): boolean { 40 | return ( 41 | !pr.merged && 42 | pr.mergeable === 'MERGEABLE' && 43 | pr.reviews.totalCount >= condition.requiredApprovals && 44 | (pr.reviewRequests.totalCount === 0 || 45 | !condition.allRequestedReviewersMustApprove) && 46 | hasLabels(pr, condition) && 47 | minimatch(pr.baseRefName, condition.branchNamePattern ?? '*') && 48 | (!condition.requiresConversationResolution || 49 | checkConversationResolution(pr)) 50 | ) 51 | } 52 | 53 | function hasLabels(pr: PullRequestInfo, condition: Condition): boolean { 54 | const labelNames = pr.labels.nodes.map(v => v.name) 55 | return condition.requiredLabels.every(v => labelNames.includes(v)) 56 | } 57 | 58 | function isStatusChecksSuccess( 59 | pr: PullRequestInfo, 60 | condition: Condition 61 | ): boolean { 62 | const check = pr.commits.nodes[0].commit.statusCheckRollup 63 | if (!check) return false 64 | if (condition.requiredStatusChecks.length) { 65 | const nodeChecks = new Map( 66 | check.contexts.nodes.map(i => [i.name || i.context, i]) 67 | ) 68 | return condition.requiredStatusChecks.every(name => { 69 | const check = nodeChecks.get(name) 70 | return check?.conclusion === 'SUCCESS' || check?.state === 'SUCCESS' 71 | }) 72 | } else { 73 | return check.state === 'SUCCESS' 74 | } 75 | } 76 | 77 | export function isIssueOutdated(issue: IssueInfo): boolean { 78 | const outdatedMillis = 5 * 60 * 1000 // 5 minutes 79 | const updatedAt = issue.updatedAt ? Date.parse(issue.updatedAt) : 0 80 | return Date.now() - updatedAt > outdatedMillis 81 | } 82 | 83 | export function parseIssueBody(body: string): RecordBody { 84 | try { 85 | const json = body 86 | .split(issueBodyStatusPrefix) 87 | .filter(e => e) 88 | .pop() 89 | ?.split(issueBodyStatusSuffix) 90 | .filter(e => e)[0] 91 | return JSON.parse(json ?? '') 92 | } catch (e) { 93 | return {} 94 | } 95 | } 96 | 97 | export function createIssueBody(body: RecordBody): string { 98 | return ` 99 | ${issueBodyPrefix} 100 | This issue provides [lcdsmao/update-branch](https://github.com/lcdsmao/update-branch) status. 101 | 102 | Status: 103 | 104 | ${issueBodyStatusPrefix} 105 | ${stringify(body)} 106 | ${issueBodyStatusSuffix} 107 | ` 108 | } 109 | 110 | export const issueBodyPrefix = '' 111 | export const issueBodyStatusPrefix = '```json' 112 | export const issueBodyStatusSuffix = '```' 113 | -------------------------------------------------------------------------------- /src/wait.ts: -------------------------------------------------------------------------------- 1 | export async function wait(milliseconds: number): Promise { 2 | return new Promise(resolve => { 3 | if (isNaN(milliseconds)) { 4 | throw new Error('milliseconds not a number') 5 | } 6 | 7 | setTimeout(() => resolve('done!'), milliseconds) 8 | }) 9 | } 10 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 4 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 5 | "outDir": "./lib", /* Redirect output structure to the directory. */ 6 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 7 | "strict": true, /* Enable all strict type-checking options. */ 8 | "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 9 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 10 | }, 11 | "exclude": ["node_modules"] 12 | } 13 | --------------------------------------------------------------------------------