├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ └── qa.yml ├── .prettierignore ├── .prettierrc.js ├── CHANGELOG.md ├── LICENSE ├── README.md ├── action.yml ├── build └── build ├── dist ├── index.js ├── index.js.map ├── licenses.txt └── sourcemap-register.js ├── eslint.config.mjs ├── jest.config.js ├── package-lock.json ├── package.json ├── screenshot-light.png ├── screenshot.png ├── src ├── index.ts └── types │ ├── App.ts │ ├── Bips.ts │ ├── Comment.ts │ ├── CommentConfiguration.ts │ ├── CommentMode.ts │ ├── Configuration.ts │ ├── CoverageItem.ts │ ├── CoverageSummary.ts │ ├── FileSystem.ts │ ├── Format.ts │ ├── Integer.ts │ ├── JsonParser.ts │ ├── Metric.ts │ ├── MetricCollection.ts │ ├── MetricLevel.ts │ ├── MetricType.ts │ ├── Report.ts │ ├── ReportResult.ts │ ├── Status.ts │ ├── StatusState.ts │ ├── Threshold.ts │ ├── XmlParser.ts │ └── github │ ├── GiHubComment.ts │ ├── GitHub.ts │ ├── GitHubAction.ts │ ├── GitHubAdapter.ts │ ├── GitHubClient.ts │ ├── GitHubClientAdapter.ts │ ├── GitHubPullRequest.ts │ └── GitHubWebhook.ts ├── tests ├── stubs │ ├── clover │ │ ├── clover.xml │ │ └── clover_no_branches.xml │ └── json-summary │ │ └── coverage-summary.json └── types │ ├── Comment.test.ts │ ├── CoverageSummary.test.ts │ ├── Filesystem.test.ts │ ├── GitHubAdapter.test.ts │ ├── Metric.test.ts │ ├── Report.test.ts │ ├── Status.test.ts │ └── Threshold.test.ts └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = true 9 | indent_style = space 10 | indent_size = 4 11 | trim_trailing_whitespace = true 12 | max_line_length = 120 13 | 14 | [*.{diff,md}] 15 | trim_trailing_whitespace = false 16 | 17 | [*.{html,css,ts,js,json,xml,yml,yaml}] 18 | indent_size = 2 19 | 20 | [*.txt] 21 | indent_style = tab 22 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" 9 | versioning-strategy: increase-if-necessary 10 | directory: "/" 11 | schedule: 12 | interval: "daily" 13 | assignees: 14 | - "slavcodev" 15 | - package-ecosystem: "github-actions" 16 | directory: "/" 17 | schedule: 18 | interval: "daily" 19 | assignees: 20 | - "slavcodev" 21 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | paths: 7 | - '**.js' 8 | - '**.json' 9 | - '**.yml' 10 | push: 11 | branches: 12 | - main 13 | paths: 14 | - '**.js' 15 | - '**.json' 16 | - '**.yml' 17 | 18 | jobs: 19 | build: 20 | runs-on: ubuntu-latest 21 | 22 | permissions: 23 | contents: read 24 | pull-requests: write 25 | statuses: write 26 | 27 | steps: 28 | - name: Checkout 29 | uses: actions/checkout@v4 30 | 31 | - uses: actions/setup-node@v4 32 | with: 33 | node-version: 20.x 34 | 35 | - uses: actions/cache@v4 36 | id: cache 37 | with: 38 | path: ~/.npm 39 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 40 | restore-keys: | 41 | ${{ runner.os }}-node- 42 | 43 | - # if: steps.cache.outputs.cache-hit != 'true' 44 | run: npm ci 45 | 46 | - run: npm test 47 | 48 | - run: npm run lint 49 | 50 | - id: coverage-monitor-clover 51 | uses: ./ 52 | name: "Run slavcodev/coverage-monitor-action@v1#coverage-monitor-clover" 53 | with: 54 | github_token: ${{ secrets.GITHUB_TOKEN }} 55 | coverage_path: ".coverage/clover.xml" 56 | comment_context: "Coverage from clover" 57 | 58 | - id: coverage-monitor-json 59 | uses: ./ 60 | name: "Run slavcodev/coverage-monitor-action@v1#coverage-monitor-json" 61 | with: 62 | github_token: ${{ secrets.GITHUB_TOKEN }} 63 | coverage_path: ".coverage/coverage-summary.json" 64 | comment_context: "Coverage from json-summary" 65 | check: false 66 | -------------------------------------------------------------------------------- /.github/workflows/qa.yml: -------------------------------------------------------------------------------- 1 | name: qa 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | push: 7 | branches: 8 | - 'main' 9 | paths-ignore: 10 | - '**.md' 11 | 12 | pull_request: 13 | paths-ignore: 14 | - '**.md' 15 | 16 | jobs: 17 | # Make sure the checked-in `dist/index.js` actually matches what we expect it to be. 18 | check-dist: 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v4 23 | 24 | - uses: actions/setup-node@v4 25 | with: 26 | node-version: 20.x 27 | 28 | - run: npm ci 29 | 30 | - run: npm run build 31 | 32 | - name: Compare the expected and actual dist/ directories 33 | id: diff 34 | run: | 35 | if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then 36 | echo "Detected uncommitted changes after build. See status below:" 37 | git diff 38 | exit 1 39 | fi 40 | 41 | - uses: actions/upload-artifact@v4 42 | if: ${{ failure() && steps.diff.conclusion == 'failure' }} 43 | with: 44 | name: dist 45 | path: dist/ 46 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | // https://prettier.io/docs/en/configuration.html 2 | // https://prettier.io/docs/en/options.html 3 | // eslint-disable-next-line import/no-commonjs 4 | // Keep same in .eslintrc.js 5 | module.exports = { 6 | printWidth: 120, 7 | tabWidth: 2, 8 | useTabs: false, 9 | semi: true, 10 | singleQuote: true, 11 | trailingComma: 'all', 12 | bracketSpacing: false, 13 | arrowParens: 'always', 14 | }; 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file 3 | using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | 16 | 17 | ## [Unreleased] 18 | 19 | _TBD_ 20 | 21 | ## [1.9.0] 2024-01-31 22 | 23 | ### Changed 24 | 25 | - Updated dependencies. 26 | 27 | ## [1.8.0] 2022-08-09 28 | 29 | ### Changed 30 | 31 | - Updated dependencies. 32 | 33 | ## [1.7.0] 2022-07-15 34 | 35 | ### Changed 36 | 37 | - Updated dependencies. 38 | 39 | ## [1.6.0] 2022-03-07 40 | 41 | ### Added 42 | 43 | - Added footer to comment and add a boolean option `comment_footer`, defaults to `true`. 44 | - Expressed the support of Ukraine in this difficult time. 45 | 46 | ## [1.5.0] 2022-03-01 47 | 48 | ### Changed 49 | 50 | - Rewrote the action using TypeScript. 51 | 52 | ## [1.4.1] 2022-02-22 53 | 54 | ### Fixed 55 | 56 | - Fixed using `0` in threshold config rather than using default value. 57 | The default value is used only when threshold option is not set. 58 | 59 | ## [1.4.0] 2022-02-21 60 | 61 | ### Deprecated 62 | 63 | - Deprecated the option `clover_file`, replaced with `coverage_path`. 64 | 65 | ### Added 66 | 67 | - Added `working_dir` string property, the working directory for the action. Defaults to workflow workspace. 68 | - Allowed the action in other context, not only `pull_request`. In other word, the coverage will always be analyzed, 69 | but the `check` and `comment` will be posted only on `pull_request`. 70 | - Added two new options `coverage_path` and `coverage_format`. 71 | - Added support of coverage file generated [`json-summary` Istanbul's reporter](https://istanbul.js.org/docs/advanced/alternative-reporters/#json-summary). 72 | 73 | ### Changed 74 | 75 | - Migrated action to Node.js v16. 76 | - Migrated from `@zeit/ncc` to `@vercel/ncc`. 77 | - Refactored the code, split functions in smaller files. 78 | 79 | ## [1.3.1] 2022-02-20 80 | 81 | ### Fixed 82 | 83 | - Fixed table badge to use threshold metric instead of lines rate. 84 | 85 | ### Changed 86 | 87 | - Updated comment table to hide metric row when metric not found in coverage, instead of showing `N/A`. 88 | 89 | ## [1.3.0] 2022-02-19 90 | 91 | ### Added 92 | 93 | - Added `threshold_metric` string property, the metric which should be considered, when calculating level. 94 | 95 | ### Changed 96 | 97 | - Updated GitHub toolkit packages, fixed vulnerabilities alerts. 98 | - Updated the table to include all 4 metrics. 99 | - Updated comment table to show `N/A` if metric was not found in coverage file. 100 | 101 | ## [1.2.0] 2020-09-08 102 | 103 | ### Changed 104 | 105 | - Updated GitHub toolkit packages, fixed vulnerabilities alerts. 106 | 107 | ## [1.1.2] 2020-09-08 108 | 109 | ### Fixed 110 | 111 | - Hotfix to fix SHA lookup in the pull request payload. 112 | 113 | ## [1.1.1] 2020-09-08 114 | 115 | ### Fixed 116 | 117 | - Fixed the parsing webhook payload - missing `after` key. 118 | 119 | ## [1.1.0] 2020-03-02 120 | 121 | ### Added 122 | 123 | - Added `comment_context` string property, the label posted in comment to differentiate the comment posted by each action. 124 | - Added `comment_mode` property to control a behaviour for posting comments to a PR. 125 | 126 | ## [1.0.1] 2019-11-11 127 | 128 | ### Fixed 129 | 130 | - Fixed the inputs types at which the application did not work correctly, especially for booleans. 131 | 132 | ## [1.0.0] 2019-11-11 133 | 134 | Initial release. 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Veaceslav Medvedev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Coverage monitor 2 | 3 | [![Status][ico-github-actions]][link-github] 4 | [![Latest Version][ico-version]][link-github] 5 | [![License][ico-license]][link-license] 6 | [![License][ico-stand-with-ukraine]][link-stand-with-ukraine] 7 | 8 | [ico-github-actions]: https://github.com/slavcodev/coverage-monitor-action/workflows/build/badge.svg 9 | [ico-version]: https://img.shields.io/github/tag/slavcodev/coverage-monitor-action.svg?label=latest 10 | [ico-license]: https://img.shields.io/badge/License-MIT-blue.svg 11 | [ico-stand-with-ukraine]: https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg 12 | 13 | [link-github]: https://github.com/slavcodev/coverage-monitor-action 14 | [link-license]: LICENSE 15 | [link-contributing]: .github/CONTRIBUTING.md 16 | [link-stand-with-ukraine]: https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md 17 | 18 | A GitHub Action that monitor coverage. 19 | 20 | ## Usage 21 | 22 | ### Pre-requisites 23 | 24 | Create a workflow `.yml` file in your repositories `.github/workflows` directory. 25 | 26 | ### Inputs 27 | 28 | 29 | | Options | Description | 30 | | :-- | :-- | 31 | | `github_token` | **Required.** The GITHUB_TOKEN secret. | 32 | | `coverage_path` | **Required.** Path to coverage reports. | 33 | | `coverage_format` | Format of coverage, supported: `auto`, `clover` and `json-summary`. Defaults to `auto`. | 34 | | `working_dir` | The working directory of the action. Defaults to workflow workspace. | 35 | | `clover_file` | **Deprecated.** Path to Clover XML file. Prefer `coverage_path` instead of `clover_file`. | 36 | | `threshold_alert` | Mark the build as unstable when coverage is less than this threshold. Defaults to `50`. | 37 | | `threshold_warning` | Warning when coverage is less than this threshold. Defaults to `90`. | 38 | | `threshold_metric` | A metric to check threshold on, supported: `statements`, `lines`, `methods` or `branches`. Defaults to `lines`. | 39 | | `check` | Whether check the coverage thresholds. Default to `true`. Ignored when event does not support checks, is not `pull_request`. | 40 | | `status_context` | A string label to differentiate this status from the status of other systems. Defaults to `Coverage Report`. | 41 | | `comment` | Whether comment the coverage report. Default to `true`. Ignored when event does not support comments, is not `pull_request`. | 42 | | `comment_context` | A string label to differentiate the comment posted by this action. Defaults to `Coverage Report`. | 43 | | `comment_mode` | A mode for comments, supported: `replace`, `update` or `insert`. Defaults to `replace`. | 44 | | `comment_footer` | Whether comment may contain footer. Defaults to `true`. 45 | 46 | ### Example workflow 47 | 48 | ~~~yaml 49 | name: Tests 50 | on: [pull_request] 51 | 52 | jobs: 53 | build: 54 | runs-on: ubuntu-latest 55 | 56 | permissions: 57 | contents: read 58 | pull-requests: write 59 | statuses: write 60 | 61 | steps: 62 | - uses: actions/checkout@v4 63 | 64 | - name: Test 65 | run: npm test 66 | 67 | - name: Monitor coverage 68 | uses: slavcodev/coverage-monitor-action@v1 69 | with: 70 | github_token: ${{ secrets.GITHUB_TOKEN }} 71 | coverage_path: "logs/clover.xml" 72 | threshold_alert: 10 73 | threshold_warning: 50 74 | threshold_metric: "lines" 75 | ~~~ 76 | 77 | ### Permissions for the `GITHUB_TOKEN` 78 | 79 | The action requires access to certain resources, thus requires the secret `GITHUB_TOKEN` with certain permissions. 80 | 81 | The minimum required permissions includes the following (without considering the other steps of your job): 82 | 83 | ~~~yaml 84 | 85 | permissions: 86 | # Access to your repository. 87 | contents: read 88 | # Access to pull request. The `write` access if you the `comment` is enabled 89 | # within the action, otherwise can be `read`. 90 | pull-requests: write 91 | # Access to pull request statuses. The `write` access if you the `check` is enabled 92 | # within the action, otherwise can be `read`. 93 | statuses: write 94 | ~~~ 95 | 96 | Refer to the documentation on settings at the following URLs: 97 | * [Automatic Token Authentication - GitHub Docs](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow) 98 | * [Assigning Permissions to Jobs - GitHub Docs](https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs) 99 | * [Permissions required for GitHub Apps - GitHub Docs](https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps) 100 | 101 | ## Preview 102 | 103 | [![Screenshot][img-screenshot-dark]][link-example-pr] 104 | [![Screenshot][img-screenshot-light]][link-example-pr] 105 | 106 | [img-screenshot-dark]: screenshot.png#gh-dark-mode-only 107 | [img-screenshot-light]: screenshot-light.png#gh-light-mode-only 108 | [link-example-pr]: https://github.com/slavcodev/coverage-monitor-action/pull/1 109 | 110 | ## Contributing 111 | 112 | We would love for you to contribute, pull requests are welcome! 113 | Please see the [CONTRIBUTING.md][link-contributing] for more information. 114 | 115 | 116 | ## License 117 | 118 | [MIT License][link-license] 119 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Coverage monitor' 2 | description: 'A GitHub Action that monitor coverage.' 3 | branding: 4 | icon: "check" 5 | color: "green" 6 | inputs: 7 | github_token: 8 | description: "**Required.** The GITHUB_TOKEN secret." 9 | required: true 10 | coverage_path: 11 | description: "**Required.** Path to coverage reports." 12 | required: false 13 | coverage_format: 14 | description: | 15 | Format of coverage, supported: `auto`, `clover` and `json-summary`. 16 | If not set the action will try to guess the format, by file extension, name and eventually by content. 17 | required: false 18 | default: 'auto' 19 | clover_file: 20 | description: | 21 | **Deprecated.** Path to Clover XML file. This option is deprecated, replaced with `coverage_path`. 22 | If both `clover_file` and `coverage_path` are set, the action will fail. 23 | required: false 24 | deprecationMessage: 'Use `coverage_path` instead' 25 | working_dir: 26 | description: "The working directory of the action. Defaults to workflow workspace." 27 | required: false 28 | default: '' 29 | threshold_alert: 30 | description: "Mark the build as unstable when coverage is less than this threshold." 31 | required: false 32 | default: '50' 33 | threshold_warning: 34 | description: "Warning when coverage is less than this threshold." 35 | required: false 36 | default: '90' 37 | threshold_metric: 38 | description: "A metric to check threshold on, supported: `statements`, `lines`, `methods` or `branches`." 39 | required: false 40 | default: 'lines' 41 | check: 42 | description: "Whether check the coverage thresholds." 43 | required: false 44 | default: 'true' 45 | status_context: 46 | description: "A string label to differentiate this status from the status of other systems." 47 | required: false 48 | default: 'Coverage Report' 49 | comment: 50 | description: "Whether comment the coverage report." 51 | required: false 52 | default: 'true' 53 | comment_context: 54 | description: "A string label to differentiate the comment posted by this action." 55 | required: false 56 | default: 'Coverage Report' 57 | comment_mode: 58 | description: "A mode for comments, supported: `replace`, `update` or `insert`." 59 | required: false 60 | default: 'replace' 61 | comment_footer: 62 | description: "Whether comment may contain footer." 63 | required: false 64 | default: 'true' 65 | runs: 66 | using: 'node20' 67 | main: 'dist/index.js' 68 | -------------------------------------------------------------------------------- /build/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | change=$(git diff --name-only | grep "src.*\.js") 4 | 5 | if [[ -n ${change} ]]; then 6 | npm run build 7 | fi 8 | -------------------------------------------------------------------------------- /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/exec 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/github 26 | MIT 27 | The MIT License (MIT) 28 | 29 | Copyright 2019 GitHub 30 | 31 | 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: 32 | 33 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 34 | 35 | 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. 36 | 37 | @actions/http-client 38 | MIT 39 | Actions Http Client for Node.js 40 | 41 | Copyright (c) GitHub, Inc. 42 | 43 | All rights reserved. 44 | 45 | MIT License 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 48 | associated documentation files (the "Software"), to deal in the Software without restriction, 49 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 50 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 51 | subject to the following conditions: 52 | 53 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 54 | 55 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 56 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 57 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 58 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 59 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 60 | 61 | 62 | @actions/io 63 | MIT 64 | The MIT License (MIT) 65 | 66 | Copyright 2019 GitHub 67 | 68 | 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: 69 | 70 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 71 | 72 | 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. 73 | 74 | @fastify/busboy 75 | MIT 76 | Copyright Brian White. All rights reserved. 77 | 78 | Permission is hereby granted, free of charge, to any person obtaining a copy 79 | of this software and associated documentation files (the "Software"), to 80 | deal in the Software without restriction, including without limitation the 81 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 82 | sell copies of the Software, and to permit persons to whom the Software is 83 | furnished to do so, subject to the following conditions: 84 | 85 | The above copyright notice and this permission notice shall be included in 86 | all copies or substantial portions of the Software. 87 | 88 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 89 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 90 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 91 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 92 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 93 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 94 | IN THE SOFTWARE. 95 | 96 | @octokit/auth-token 97 | MIT 98 | The MIT License 99 | 100 | Copyright (c) 2019 Octokit contributors 101 | 102 | Permission is hereby granted, free of charge, to any person obtaining a copy 103 | of this software and associated documentation files (the "Software"), to deal 104 | in the Software without restriction, including without limitation the rights 105 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 106 | copies of the Software, and to permit persons to whom the Software is 107 | furnished to do so, subject to the following conditions: 108 | 109 | The above copyright notice and this permission notice shall be included in 110 | all copies or substantial portions of the Software. 111 | 112 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 113 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 114 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 115 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 116 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 117 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 118 | THE SOFTWARE. 119 | 120 | 121 | @octokit/core 122 | MIT 123 | The MIT License 124 | 125 | Copyright (c) 2019 Octokit contributors 126 | 127 | Permission is hereby granted, free of charge, to any person obtaining a copy 128 | of this software and associated documentation files (the "Software"), to deal 129 | in the Software without restriction, including without limitation the rights 130 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 131 | copies of the Software, and to permit persons to whom the Software is 132 | furnished to do so, subject to the following conditions: 133 | 134 | The above copyright notice and this permission notice shall be included in 135 | all copies or substantial portions of the Software. 136 | 137 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 138 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 139 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 140 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 141 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 142 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 143 | THE SOFTWARE. 144 | 145 | 146 | @octokit/endpoint 147 | MIT 148 | The MIT License 149 | 150 | Copyright (c) 2018 Octokit contributors 151 | 152 | Permission is hereby granted, free of charge, to any person obtaining a copy 153 | of this software and associated documentation files (the "Software"), to deal 154 | in the Software without restriction, including without limitation the rights 155 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 156 | copies of the Software, and to permit persons to whom the Software is 157 | furnished to do so, subject to the following conditions: 158 | 159 | The above copyright notice and this permission notice shall be included in 160 | all copies or substantial portions of the Software. 161 | 162 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 163 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 164 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 165 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 166 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 167 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 168 | THE SOFTWARE. 169 | 170 | 171 | @octokit/graphql 172 | MIT 173 | The MIT License 174 | 175 | Copyright (c) 2018 Octokit contributors 176 | 177 | Permission is hereby granted, free of charge, to any person obtaining a copy 178 | of this software and associated documentation files (the "Software"), to deal 179 | in the Software without restriction, including without limitation the rights 180 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 181 | copies of the Software, and to permit persons to whom the Software is 182 | furnished to do so, subject to the following conditions: 183 | 184 | The above copyright notice and this permission notice shall be included in 185 | all copies or substantial portions of the Software. 186 | 187 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 188 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 189 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 190 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 191 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 192 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 193 | THE SOFTWARE. 194 | 195 | 196 | @octokit/plugin-paginate-rest 197 | MIT 198 | MIT License Copyright (c) 2019 Octokit contributors 199 | 200 | 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: 201 | 202 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 203 | 204 | 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. 205 | 206 | 207 | @octokit/plugin-rest-endpoint-methods 208 | MIT 209 | MIT License Copyright (c) 2019 Octokit contributors 210 | 211 | 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: 212 | 213 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 214 | 215 | 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. 216 | 217 | 218 | @octokit/request 219 | MIT 220 | The MIT License 221 | 222 | Copyright (c) 2018 Octokit contributors 223 | 224 | Permission is hereby granted, free of charge, to any person obtaining a copy 225 | of this software and associated documentation files (the "Software"), to deal 226 | in the Software without restriction, including without limitation the rights 227 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 228 | copies of the Software, and to permit persons to whom the Software is 229 | furnished to do so, subject to the following conditions: 230 | 231 | The above copyright notice and this permission notice shall be included in 232 | all copies or substantial portions of the Software. 233 | 234 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 235 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 236 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 237 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 238 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 239 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 240 | THE SOFTWARE. 241 | 242 | 243 | @octokit/request-error 244 | MIT 245 | The MIT License 246 | 247 | Copyright (c) 2019 Octokit contributors 248 | 249 | Permission is hereby granted, free of charge, to any person obtaining a copy 250 | of this software and associated documentation files (the "Software"), to deal 251 | in the Software without restriction, including without limitation the rights 252 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 253 | copies of the Software, and to permit persons to whom the Software is 254 | furnished to do so, subject to the following conditions: 255 | 256 | The above copyright notice and this permission notice shall be included in 257 | all copies or substantial portions of the Software. 258 | 259 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 260 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 261 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 262 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 263 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 264 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 265 | THE SOFTWARE. 266 | 267 | 268 | before-after-hook 269 | Apache-2.0 270 | Apache License 271 | Version 2.0, January 2004 272 | http://www.apache.org/licenses/ 273 | 274 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 275 | 276 | 1. Definitions. 277 | 278 | "License" shall mean the terms and conditions for use, reproduction, 279 | and distribution as defined by Sections 1 through 9 of this document. 280 | 281 | "Licensor" shall mean the copyright owner or entity authorized by 282 | the copyright owner that is granting the License. 283 | 284 | "Legal Entity" shall mean the union of the acting entity and all 285 | other entities that control, are controlled by, or are under common 286 | control with that entity. For the purposes of this definition, 287 | "control" means (i) the power, direct or indirect, to cause the 288 | direction or management of such entity, whether by contract or 289 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 290 | outstanding shares, or (iii) beneficial ownership of such entity. 291 | 292 | "You" (or "Your") shall mean an individual or Legal Entity 293 | exercising permissions granted by this License. 294 | 295 | "Source" form shall mean the preferred form for making modifications, 296 | including but not limited to software source code, documentation 297 | source, and configuration files. 298 | 299 | "Object" form shall mean any form resulting from mechanical 300 | transformation or translation of a Source form, including but 301 | not limited to compiled object code, generated documentation, 302 | and conversions to other media types. 303 | 304 | "Work" shall mean the work of authorship, whether in Source or 305 | Object form, made available under the License, as indicated by a 306 | copyright notice that is included in or attached to the work 307 | (an example is provided in the Appendix below). 308 | 309 | "Derivative Works" shall mean any work, whether in Source or Object 310 | form, that is based on (or derived from) the Work and for which the 311 | editorial revisions, annotations, elaborations, or other modifications 312 | represent, as a whole, an original work of authorship. For the purposes 313 | of this License, Derivative Works shall not include works that remain 314 | separable from, or merely link (or bind by name) to the interfaces of, 315 | the Work and Derivative Works thereof. 316 | 317 | "Contribution" shall mean any work of authorship, including 318 | the original version of the Work and any modifications or additions 319 | to that Work or Derivative Works thereof, that is intentionally 320 | submitted to Licensor for inclusion in the Work by the copyright owner 321 | or by an individual or Legal Entity authorized to submit on behalf of 322 | the copyright owner. For the purposes of this definition, "submitted" 323 | means any form of electronic, verbal, or written communication sent 324 | to the Licensor or its representatives, including but not limited to 325 | communication on electronic mailing lists, source code control systems, 326 | and issue tracking systems that are managed by, or on behalf of, the 327 | Licensor for the purpose of discussing and improving the Work, but 328 | excluding communication that is conspicuously marked or otherwise 329 | designated in writing by the copyright owner as "Not a Contribution." 330 | 331 | "Contributor" shall mean Licensor and any individual or Legal Entity 332 | on behalf of whom a Contribution has been received by Licensor and 333 | subsequently incorporated within the Work. 334 | 335 | 2. Grant of Copyright License. Subject to the terms and conditions of 336 | this License, each Contributor hereby grants to You a perpetual, 337 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 338 | copyright license to reproduce, prepare Derivative Works of, 339 | publicly display, publicly perform, sublicense, and distribute the 340 | Work and such Derivative Works in Source or Object form. 341 | 342 | 3. Grant of Patent License. Subject to the terms and conditions of 343 | this License, each Contributor hereby grants to You a perpetual, 344 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 345 | (except as stated in this section) patent license to make, have made, 346 | use, offer to sell, sell, import, and otherwise transfer the Work, 347 | where such license applies only to those patent claims licensable 348 | by such Contributor that are necessarily infringed by their 349 | Contribution(s) alone or by combination of their Contribution(s) 350 | with the Work to which such Contribution(s) was submitted. If You 351 | institute patent litigation against any entity (including a 352 | cross-claim or counterclaim in a lawsuit) alleging that the Work 353 | or a Contribution incorporated within the Work constitutes direct 354 | or contributory patent infringement, then any patent licenses 355 | granted to You under this License for that Work shall terminate 356 | as of the date such litigation is filed. 357 | 358 | 4. Redistribution. You may reproduce and distribute copies of the 359 | Work or Derivative Works thereof in any medium, with or without 360 | modifications, and in Source or Object form, provided that You 361 | meet the following conditions: 362 | 363 | (a) You must give any other recipients of the Work or 364 | Derivative Works a copy of this License; and 365 | 366 | (b) You must cause any modified files to carry prominent notices 367 | stating that You changed the files; and 368 | 369 | (c) You must retain, in the Source form of any Derivative Works 370 | that You distribute, all copyright, patent, trademark, and 371 | attribution notices from the Source form of the Work, 372 | excluding those notices that do not pertain to any part of 373 | the Derivative Works; and 374 | 375 | (d) If the Work includes a "NOTICE" text file as part of its 376 | distribution, then any Derivative Works that You distribute must 377 | include a readable copy of the attribution notices contained 378 | within such NOTICE file, excluding those notices that do not 379 | pertain to any part of the Derivative Works, in at least one 380 | of the following places: within a NOTICE text file distributed 381 | as part of the Derivative Works; within the Source form or 382 | documentation, if provided along with the Derivative Works; or, 383 | within a display generated by the Derivative Works, if and 384 | wherever such third-party notices normally appear. The contents 385 | of the NOTICE file are for informational purposes only and 386 | do not modify the License. You may add Your own attribution 387 | notices within Derivative Works that You distribute, alongside 388 | or as an addendum to the NOTICE text from the Work, provided 389 | that such additional attribution notices cannot be construed 390 | as modifying the License. 391 | 392 | You may add Your own copyright statement to Your modifications and 393 | may provide additional or different license terms and conditions 394 | for use, reproduction, or distribution of Your modifications, or 395 | for any such Derivative Works as a whole, provided Your use, 396 | reproduction, and distribution of the Work otherwise complies with 397 | the conditions stated in this License. 398 | 399 | 5. Submission of Contributions. Unless You explicitly state otherwise, 400 | any Contribution intentionally submitted for inclusion in the Work 401 | by You to the Licensor shall be under the terms and conditions of 402 | this License, without any additional terms or conditions. 403 | Notwithstanding the above, nothing herein shall supersede or modify 404 | the terms of any separate license agreement you may have executed 405 | with Licensor regarding such Contributions. 406 | 407 | 6. Trademarks. This License does not grant permission to use the trade 408 | names, trademarks, service marks, or product names of the Licensor, 409 | except as required for reasonable and customary use in describing the 410 | origin of the Work and reproducing the content of the NOTICE file. 411 | 412 | 7. Disclaimer of Warranty. Unless required by applicable law or 413 | agreed to in writing, Licensor provides the Work (and each 414 | Contributor provides its Contributions) on an "AS IS" BASIS, 415 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 416 | implied, including, without limitation, any warranties or conditions 417 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 418 | PARTICULAR PURPOSE. You are solely responsible for determining the 419 | appropriateness of using or redistributing the Work and assume any 420 | risks associated with Your exercise of permissions under this License. 421 | 422 | 8. Limitation of Liability. In no event and under no legal theory, 423 | whether in tort (including negligence), contract, or otherwise, 424 | unless required by applicable law (such as deliberate and grossly 425 | negligent acts) or agreed to in writing, shall any Contributor be 426 | liable to You for damages, including any direct, indirect, special, 427 | incidental, or consequential damages of any character arising as a 428 | result of this License or out of the use or inability to use the 429 | Work (including but not limited to damages for loss of goodwill, 430 | work stoppage, computer failure or malfunction, or any and all 431 | other commercial damages or losses), even if such Contributor 432 | has been advised of the possibility of such damages. 433 | 434 | 9. Accepting Warranty or Additional Liability. While redistributing 435 | the Work or Derivative Works thereof, You may choose to offer, 436 | and charge a fee for, acceptance of support, warranty, indemnity, 437 | or other liability obligations and/or rights consistent with this 438 | License. However, in accepting such obligations, You may act only 439 | on Your own behalf and on Your sole responsibility, not on behalf 440 | of any other Contributor, and only if You agree to indemnify, 441 | defend, and hold each Contributor harmless for any liability 442 | incurred by, or claims asserted against, such Contributor by reason 443 | of your accepting any such warranty or additional liability. 444 | 445 | END OF TERMS AND CONDITIONS 446 | 447 | APPENDIX: How to apply the Apache License to your work. 448 | 449 | To apply the Apache License to your work, attach the following 450 | boilerplate notice, with the fields enclosed by brackets "{}" 451 | replaced with your own identifying information. (Don't include 452 | the brackets!) The text should be enclosed in the appropriate 453 | comment syntax for the file format. We also recommend that a 454 | file or class name and description of purpose be included on the 455 | same "printed page" as the copyright notice for easier 456 | identification within third-party archives. 457 | 458 | Copyright 2018 Gregor Martynus and other contributors. 459 | 460 | Licensed under the Apache License, Version 2.0 (the "License"); 461 | you may not use this file except in compliance with the License. 462 | You may obtain a copy of the License at 463 | 464 | http://www.apache.org/licenses/LICENSE-2.0 465 | 466 | Unless required by applicable law or agreed to in writing, software 467 | distributed under the License is distributed on an "AS IS" BASIS, 468 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 469 | See the License for the specific language governing permissions and 470 | limitations under the License. 471 | 472 | 473 | deprecation 474 | ISC 475 | The ISC License 476 | 477 | Copyright (c) Gregor Martynus and contributors 478 | 479 | Permission to use, copy, modify, and/or distribute this software for any 480 | purpose with or without fee is hereby granted, provided that the above 481 | copyright notice and this permission notice appear in all copies. 482 | 483 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 484 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 485 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 486 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 487 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 488 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 489 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 490 | 491 | 492 | once 493 | ISC 494 | The ISC License 495 | 496 | Copyright (c) Isaac Z. Schlueter and Contributors 497 | 498 | Permission to use, copy, modify, and/or distribute this software for any 499 | purpose with or without fee is hereby granted, provided that the above 500 | copyright notice and this permission notice appear in all copies. 501 | 502 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 503 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 504 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 505 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 506 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 507 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 508 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 509 | 510 | 511 | sax 512 | ISC 513 | The ISC License 514 | 515 | Copyright (c) 2010-2024 Isaac Z. Schlueter and Contributors 516 | 517 | Permission to use, copy, modify, and/or distribute this software for any 518 | purpose with or without fee is hereby granted, provided that the above 519 | copyright notice and this permission notice appear in all copies. 520 | 521 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 522 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 523 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 524 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 525 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 526 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 527 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 528 | 529 | ==== 530 | 531 | `String.fromCodePoint` by Mathias Bynens used according to terms of MIT 532 | License, as follows: 533 | 534 | Copyright (c) 2010-2024 Mathias Bynens 535 | 536 | Permission is hereby granted, free of charge, to any person obtaining 537 | a copy of this software and associated documentation files (the 538 | "Software"), to deal in the Software without restriction, including 539 | without limitation the rights to use, copy, modify, merge, publish, 540 | distribute, sublicense, and/or sell copies of the Software, and to 541 | permit persons to whom the Software is furnished to do so, subject to 542 | the following conditions: 543 | 544 | The above copyright notice and this permission notice shall be 545 | included in all copies or substantial portions of the Software. 546 | 547 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 548 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 549 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 550 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 551 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 552 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 553 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 554 | 555 | 556 | tunnel 557 | MIT 558 | The MIT License (MIT) 559 | 560 | Copyright (c) 2012 Koichi Kobayashi 561 | 562 | Permission is hereby granted, free of charge, to any person obtaining a copy 563 | of this software and associated documentation files (the "Software"), to deal 564 | in the Software without restriction, including without limitation the rights 565 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 566 | copies of the Software, and to permit persons to whom the Software is 567 | furnished to do so, subject to the following conditions: 568 | 569 | The above copyright notice and this permission notice shall be included in 570 | all copies or substantial portions of the Software. 571 | 572 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 573 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 574 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 575 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 576 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 577 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 578 | THE SOFTWARE. 579 | 580 | 581 | undici 582 | MIT 583 | MIT License 584 | 585 | Copyright (c) Matteo Collina and Undici contributors 586 | 587 | Permission is hereby granted, free of charge, to any person obtaining a copy 588 | of this software and associated documentation files (the "Software"), to deal 589 | in the Software without restriction, including without limitation the rights 590 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 591 | copies of the Software, and to permit persons to whom the Software is 592 | furnished to do so, subject to the following conditions: 593 | 594 | The above copyright notice and this permission notice shall be included in all 595 | copies or substantial portions of the Software. 596 | 597 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 598 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 599 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 600 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 601 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 602 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 603 | SOFTWARE. 604 | 605 | 606 | universal-user-agent 607 | ISC 608 | # [ISC License](https://spdx.org/licenses/ISC) 609 | 610 | Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m) 611 | 612 | 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. 613 | 614 | 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. 615 | 616 | 617 | wrappy 618 | ISC 619 | The ISC License 620 | 621 | Copyright (c) Isaac Z. Schlueter and Contributors 622 | 623 | Permission to use, copy, modify, and/or distribute this software for any 624 | purpose with or without fee is hereby granted, provided that the above 625 | copyright notice and this permission notice appear in all copies. 626 | 627 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 628 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 629 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 630 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 631 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 632 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 633 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 634 | 635 | 636 | xml2js 637 | MIT 638 | Copyright 2010, 2011, 2012, 2013. All rights reserved. 639 | 640 | Permission is hereby granted, free of charge, to any person obtaining a copy 641 | of this software and associated documentation files (the "Software"), to 642 | deal in the Software without restriction, including without limitation the 643 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 644 | sell copies of the Software, and to permit persons to whom the Software is 645 | furnished to do so, subject to the following conditions: 646 | 647 | The above copyright notice and this permission notice shall be included in 648 | all copies or substantial portions of the Software. 649 | 650 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 651 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 652 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 653 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 654 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 655 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 656 | IN THE SOFTWARE. 657 | 658 | 659 | xmlbuilder 660 | MIT 661 | The MIT License (MIT) 662 | 663 | Copyright (c) 2013 Ozgur Ozcitak 664 | 665 | Permission is hereby granted, free of charge, to any person obtaining a copy 666 | of this software and associated documentation files (the "Software"), to deal 667 | in the Software without restriction, including without limitation the rights 668 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 669 | copies of the Software, and to permit persons to whom the Software is 670 | furnished to do so, subject to the following conditions: 671 | 672 | The above copyright notice and this permission notice shall be included in 673 | all copies or substantial portions of the Software. 674 | 675 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 676 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 677 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 678 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 679 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 680 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 681 | THE SOFTWARE. 682 | -------------------------------------------------------------------------------- /dist/sourcemap-register.js: -------------------------------------------------------------------------------- 1 | (()=>{var e={296:e=>{var r=Object.prototype.toString;var n=typeof Buffer!=="undefined"&&typeof Buffer.alloc==="function"&&typeof Buffer.allocUnsafe==="function"&&typeof Buffer.from==="function";function isArrayBuffer(e){return r.call(e).slice(8,-1)==="ArrayBuffer"}function fromArrayBuffer(e,r,t){r>>>=0;var o=e.byteLength-r;if(o<0){throw new RangeError("'offset' is out of bounds")}if(t===undefined){t=o}else{t>>>=0;if(t>o){throw new RangeError("'length' is out of bounds")}}return n?Buffer.from(e.slice(r,r+t)):new Buffer(new Uint8Array(e.slice(r,r+t)))}function fromString(e,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}return n?Buffer.from(e,r):new Buffer(e,r)}function bufferFrom(e,r,t){if(typeof e==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(e)){return fromArrayBuffer(e,r,t)}if(typeof e==="string"){return fromString(e,r)}return n?Buffer.from(e):new Buffer(e)}e.exports=bufferFrom},599:(e,r,n)=>{e=n.nmd(e);var t=n(927).SourceMapConsumer;var o=n(928);var i;try{i=n(896);if(!i.existsSync||!i.readFileSync){i=null}}catch(e){}var a=n(296);function dynamicRequire(e,r){return e.require(r)}var u=false;var s=false;var l=false;var c="auto";var p={};var f={};var g=/^data:application\/json[^,]+base64,/;var d=[];var h=[];function isInBrowser(){if(c==="browser")return true;if(c==="node")return false;return typeof window!=="undefined"&&typeof XMLHttpRequest==="function"&&!(window.require&&window.module&&window.process&&window.process.type==="renderer")}function hasGlobalProcessEventEmitter(){return typeof process==="object"&&process!==null&&typeof process.on==="function"}function globalProcessVersion(){if(typeof process==="object"&&process!==null){return process.version}else{return""}}function globalProcessStderr(){if(typeof process==="object"&&process!==null){return process.stderr}}function globalProcessExit(e){if(typeof process==="object"&&process!==null&&typeof process.exit==="function"){return process.exit(e)}}function handlerExec(e){return function(r){for(var n=0;n"}var n=this.getLineNumber();if(n!=null){r+=":"+n;var t=this.getColumnNumber();if(t){r+=":"+t}}}var o="";var i=this.getFunctionName();var a=true;var u=this.isConstructor();var s=!(this.isToplevel()||u);if(s){var l=this.getTypeName();if(l==="[object Object]"){l="null"}var c=this.getMethodName();if(i){if(l&&i.indexOf(l)!=0){o+=l+"."}o+=i;if(c&&i.indexOf("."+c)!=i.length-c.length-1){o+=" [as "+c+"]"}}else{o+=l+"."+(c||"")}}else if(u){o+="new "+(i||"")}else if(i){o+=i}else{o+=r;a=false}if(a){o+=" ("+r+")"}return o}function cloneCallSite(e){var r={};Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(n){r[n]=/^(?:is|get)/.test(n)?function(){return e[n].call(e)}:e[n]}));r.toString=CallSiteToString;return r}function wrapCallSite(e,r){if(r===undefined){r={nextPosition:null,curPosition:null}}if(e.isNative()){r.curPosition=null;return e}var n=e.getFileName()||e.getScriptNameOrSourceURL();if(n){var t=e.getLineNumber();var o=e.getColumnNumber()-1;var i=/^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;var a=i.test(globalProcessVersion())?0:62;if(t===1&&o>a&&!isInBrowser()&&!e.isEval()){o-=a}var u=mapSourcePosition({source:n,line:t,column:o});r.curPosition=u;e=cloneCallSite(e);var s=e.getFunctionName;e.getFunctionName=function(){if(r.nextPosition==null){return s()}return r.nextPosition.name||s()};e.getFileName=function(){return u.source};e.getLineNumber=function(){return u.line};e.getColumnNumber=function(){return u.column+1};e.getScriptNameOrSourceURL=function(){return u.source};return e}var l=e.isEval()&&e.getEvalOrigin();if(l){l=mapEvalOrigin(l);e=cloneCallSite(e);e.getEvalOrigin=function(){return l};return e}return e}function prepareStackTrace(e,r){if(l){p={};f={}}var n=e.name||"Error";var t=e.message||"";var o=n+": "+t;var i={nextPosition:null,curPosition:null};var a=[];for(var u=r.length-1;u>=0;u--){a.push("\n at "+wrapCallSite(r[u],i));i.nextPosition=i.curPosition}i.curPosition=i.nextPosition=null;return o+a.reverse().join("")}function getErrorSource(e){var r=/\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(e.stack);if(r){var n=r[1];var t=+r[2];var o=+r[3];var a=p[n];if(!a&&i&&i.existsSync(n)){try{a=i.readFileSync(n,"utf8")}catch(e){a=""}}if(a){var u=a.split(/(?:\r\n|\r|\n)/)[t-1];if(u){return n+":"+t+"\n"+u+"\n"+new Array(o).join(" ")+"^"}}}return null}function printErrorAndExit(e){var r=getErrorSource(e);var n=globalProcessStderr();if(n&&n._handle&&n._handle.setBlocking){n._handle.setBlocking(true)}if(r){console.error();console.error(r)}console.error(e.stack);globalProcessExit(1)}function shimEmitUncaughtException(){var e=process.emit;process.emit=function(r){if(r==="uncaughtException"){var n=arguments[1]&&arguments[1].stack;var t=this.listeners(r).length>0;if(n&&!t){return printErrorAndExit(arguments[1])}}return e.apply(this,arguments)}}var S=d.slice(0);var _=h.slice(0);r.wrapCallSite=wrapCallSite;r.getErrorSource=getErrorSource;r.mapSourcePosition=mapSourcePosition;r.retrieveSourceMap=v;r.install=function(r){r=r||{};if(r.environment){c=r.environment;if(["node","browser","auto"].indexOf(c)===-1){throw new Error("environment "+c+" was unknown. Available options are {auto, browser, node}")}}if(r.retrieveFile){if(r.overrideRetrieveFile){d.length=0}d.unshift(r.retrieveFile)}if(r.retrieveSourceMap){if(r.overrideRetrieveSourceMap){h.length=0}h.unshift(r.retrieveSourceMap)}if(r.hookRequire&&!isInBrowser()){var n=dynamicRequire(e,"module");var t=n.prototype._compile;if(!t.__sourceMapSupport){n.prototype._compile=function(e,r){p[r]=e;f[r]=undefined;return t.call(this,e,r)};n.prototype._compile.__sourceMapSupport=true}}if(!l){l="emptyCacheBetweenOperations"in r?r.emptyCacheBetweenOperations:false}if(!u){u=true;Error.prepareStackTrace=prepareStackTrace}if(!s){var o="handleUncaughtExceptions"in r?r.handleUncaughtExceptions:true;try{var i=dynamicRequire(e,"worker_threads");if(i.isMainThread===false){o=false}}catch(e){}if(o&&hasGlobalProcessEventEmitter()){s=true;shimEmitUncaughtException()}}};r.resetRetrieveHandlers=function(){d.length=0;h.length=0;d=S.slice(0);h=_.slice(0);v=handlerExec(h);m=handlerExec(d)}},517:(e,r,n)=>{var t=n(297);var o=Object.prototype.hasOwnProperty;var i=typeof Map!=="undefined";function ArraySet(){this._array=[];this._set=i?new Map:Object.create(null)}ArraySet.fromArray=function ArraySet_fromArray(e,r){var n=new ArraySet;for(var t=0,o=e.length;t=0){return r}}else{var n=t.toSetString(e);if(o.call(this._set,n)){return this._set[n]}}throw new Error('"'+e+'" is not in the set.')};ArraySet.prototype.at=function ArraySet_at(e){if(e>=0&&e{var t=n(158);var o=5;var i=1<>1;return r?-n:n}r.encode=function base64VLQ_encode(e){var r="";var n;var i=toVLQSigned(e);do{n=i&a;i>>>=o;if(i>0){n|=u}r+=t.encode(n)}while(i>0);return r};r.decode=function base64VLQ_decode(e,r,n){var i=e.length;var s=0;var l=0;var c,p;do{if(r>=i){throw new Error("Expected more digits in base 64 VLQ value.")}p=t.decode(e.charCodeAt(r++));if(p===-1){throw new Error("Invalid base64 digit: "+e.charAt(r-1))}c=!!(p&u);p&=a;s=s+(p<{var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");r.encode=function(e){if(0<=e&&e{r.GREATEST_LOWER_BOUND=1;r.LEAST_UPPER_BOUND=2;function recursiveSearch(e,n,t,o,i,a){var u=Math.floor((n-e)/2)+e;var s=i(t,o[u],true);if(s===0){return u}else if(s>0){if(n-u>1){return recursiveSearch(u,n,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return n1){return recursiveSearch(e,u,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return u}else{return e<0?-1:e}}}r.search=function search(e,n,t,o){if(n.length===0){return-1}var i=recursiveSearch(-1,n.length,e,n,t,o||r.GREATEST_LOWER_BOUND);if(i<0){return-1}while(i-1>=0){if(t(n[i],n[i-1],true)!==0){break}--i}return i}},24:(e,r,n)=>{var t=n(297);function generatedPositionAfter(e,r){var n=e.generatedLine;var o=r.generatedLine;var i=e.generatedColumn;var a=r.generatedColumn;return o>n||o==n&&a>=i||t.compareByGeneratedPositionsInflated(e,r)<=0}function MappingList(){this._array=[];this._sorted=true;this._last={generatedLine:-1,generatedColumn:0}}MappingList.prototype.unsortedForEach=function MappingList_forEach(e,r){this._array.forEach(e,r)};MappingList.prototype.add=function MappingList_add(e){if(generatedPositionAfter(this._last,e)){this._last=e;this._array.push(e)}else{this._sorted=false;this._array.push(e)}};MappingList.prototype.toArray=function MappingList_toArray(){if(!this._sorted){this._array.sort(t.compareByGeneratedPositionsInflated);this._sorted=true}return this._array};r.P=MappingList},299:(e,r)=>{function swap(e,r,n){var t=e[r];e[r]=e[n];e[n]=t}function randomIntInRange(e,r){return Math.round(e+Math.random()*(r-e))}function doQuickSort(e,r,n,t){if(n{var t;var o=n(297);var i=n(197);var a=n(517).C;var u=n(818);var s=n(299).g;function SourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}return n.sections!=null?new IndexedSourceMapConsumer(n,r):new BasicSourceMapConsumer(n,r)}SourceMapConsumer.fromSourceMap=function(e,r){return BasicSourceMapConsumer.fromSourceMap(e,r)};SourceMapConsumer.prototype._version=3;SourceMapConsumer.prototype.__generatedMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_generatedMappings",{configurable:true,enumerable:true,get:function(){if(!this.__generatedMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__generatedMappings}});SourceMapConsumer.prototype.__originalMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_originalMappings",{configurable:true,enumerable:true,get:function(){if(!this.__originalMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__originalMappings}});SourceMapConsumer.prototype._charIsMappingSeparator=function SourceMapConsumer_charIsMappingSeparator(e,r){var n=e.charAt(r);return n===";"||n===","};SourceMapConsumer.prototype._parseMappings=function SourceMapConsumer_parseMappings(e,r){throw new Error("Subclasses must implement _parseMappings")};SourceMapConsumer.GENERATED_ORDER=1;SourceMapConsumer.ORIGINAL_ORDER=2;SourceMapConsumer.GREATEST_LOWER_BOUND=1;SourceMapConsumer.LEAST_UPPER_BOUND=2;SourceMapConsumer.prototype.eachMapping=function SourceMapConsumer_eachMapping(e,r,n){var t=r||null;var i=n||SourceMapConsumer.GENERATED_ORDER;var a;switch(i){case SourceMapConsumer.GENERATED_ORDER:a=this._generatedMappings;break;case SourceMapConsumer.ORIGINAL_ORDER:a=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var u=this.sourceRoot;a.map((function(e){var r=e.source===null?null:this._sources.at(e.source);r=o.computeSourceURL(u,r,this._sourceMapURL);return{source:r,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name===null?null:this._names.at(e.name)}}),this).forEach(e,t)};SourceMapConsumer.prototype.allGeneratedPositionsFor=function SourceMapConsumer_allGeneratedPositionsFor(e){var r=o.getArg(e,"line");var n={source:o.getArg(e,"source"),originalLine:r,originalColumn:o.getArg(e,"column",0)};n.source=this._findSourceIndex(n.source);if(n.source<0){return[]}var t=[];var a=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,i.LEAST_UPPER_BOUND);if(a>=0){var u=this._originalMappings[a];if(e.column===undefined){var s=u.originalLine;while(u&&u.originalLine===s){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}else{var l=u.originalColumn;while(u&&u.originalLine===r&&u.originalColumn==l){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}}return t};r.SourceMapConsumer=SourceMapConsumer;function BasicSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sources");var u=o.getArg(n,"names",[]);var s=o.getArg(n,"sourceRoot",null);var l=o.getArg(n,"sourcesContent",null);var c=o.getArg(n,"mappings");var p=o.getArg(n,"file",null);if(t!=this._version){throw new Error("Unsupported version: "+t)}if(s){s=o.normalize(s)}i=i.map(String).map(o.normalize).map((function(e){return s&&o.isAbsolute(s)&&o.isAbsolute(e)?o.relative(s,e):e}));this._names=a.fromArray(u.map(String),true);this._sources=a.fromArray(i,true);this._absoluteSources=this._sources.toArray().map((function(e){return o.computeSourceURL(s,e,r)}));this.sourceRoot=s;this.sourcesContent=l;this._mappings=c;this._sourceMapURL=r;this.file=p}BasicSourceMapConsumer.prototype=Object.create(SourceMapConsumer.prototype);BasicSourceMapConsumer.prototype.consumer=SourceMapConsumer;BasicSourceMapConsumer.prototype._findSourceIndex=function(e){var r=e;if(this.sourceRoot!=null){r=o.relative(this.sourceRoot,r)}if(this._sources.has(r)){return this._sources.indexOf(r)}var n;for(n=0;n1){v.source=l+_[1];l+=_[1];v.originalLine=i+_[2];i=v.originalLine;v.originalLine+=1;v.originalColumn=a+_[3];a=v.originalColumn;if(_.length>4){v.name=c+_[4];c+=_[4]}}m.push(v);if(typeof v.originalLine==="number"){h.push(v)}}}s(m,o.compareByGeneratedPositionsDeflated);this.__generatedMappings=m;s(h,o.compareByOriginalPositions);this.__originalMappings=h};BasicSourceMapConsumer.prototype._findMapping=function SourceMapConsumer_findMapping(e,r,n,t,o,a){if(e[n]<=0){throw new TypeError("Line must be greater than or equal to 1, got "+e[n])}if(e[t]<0){throw new TypeError("Column must be greater than or equal to 0, got "+e[t])}return i.search(e,r,o,a)};BasicSourceMapConsumer.prototype.computeColumnSpans=function SourceMapConsumer_computeColumnSpans(){for(var e=0;e=0){var t=this._generatedMappings[n];if(t.generatedLine===r.generatedLine){var i=o.getArg(t,"source",null);if(i!==null){i=this._sources.at(i);i=o.computeSourceURL(this.sourceRoot,i,this._sourceMapURL)}var a=o.getArg(t,"name",null);if(a!==null){a=this._names.at(a)}return{source:i,line:o.getArg(t,"originalLine",null),column:o.getArg(t,"originalColumn",null),name:a}}}return{source:null,line:null,column:null,name:null}};BasicSourceMapConsumer.prototype.hasContentsOfAllSources=function BasicSourceMapConsumer_hasContentsOfAllSources(){if(!this.sourcesContent){return false}return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return e==null}))};BasicSourceMapConsumer.prototype.sourceContentFor=function SourceMapConsumer_sourceContentFor(e,r){if(!this.sourcesContent){return null}var n=this._findSourceIndex(e);if(n>=0){return this.sourcesContent[n]}var t=e;if(this.sourceRoot!=null){t=o.relative(this.sourceRoot,t)}var i;if(this.sourceRoot!=null&&(i=o.urlParse(this.sourceRoot))){var a=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(a)){return this.sourcesContent[this._sources.indexOf(a)]}if((!i.path||i.path=="/")&&this._sources.has("/"+t)){return this.sourcesContent[this._sources.indexOf("/"+t)]}}if(r){return null}else{throw new Error('"'+t+'" is not in the SourceMap.')}};BasicSourceMapConsumer.prototype.generatedPositionFor=function SourceMapConsumer_generatedPositionFor(e){var r=o.getArg(e,"source");r=this._findSourceIndex(r);if(r<0){return{line:null,column:null,lastColumn:null}}var n={source:r,originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")};var t=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,o.getArg(e,"bias",SourceMapConsumer.GREATEST_LOWER_BOUND));if(t>=0){var i=this._originalMappings[t];if(i.source===n.source){return{line:o.getArg(i,"generatedLine",null),column:o.getArg(i,"generatedColumn",null),lastColumn:o.getArg(i,"lastGeneratedColumn",null)}}}return{line:null,column:null,lastColumn:null}};t=BasicSourceMapConsumer;function IndexedSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sections");if(t!=this._version){throw new Error("Unsupported version: "+t)}this._sources=new a;this._names=new a;var u={line:-1,column:0};this._sections=i.map((function(e){if(e.url){throw new Error("Support for url field in sections not implemented.")}var n=o.getArg(e,"offset");var t=o.getArg(n,"line");var i=o.getArg(n,"column");if(t{var t=n(818);var o=n(297);var i=n(517).C;var a=n(24).P;function SourceMapGenerator(e){if(!e){e={}}this._file=o.getArg(e,"file",null);this._sourceRoot=o.getArg(e,"sourceRoot",null);this._skipValidation=o.getArg(e,"skipValidation",false);this._sources=new i;this._names=new i;this._mappings=new a;this._sourcesContents=null}SourceMapGenerator.prototype._version=3;SourceMapGenerator.fromSourceMap=function SourceMapGenerator_fromSourceMap(e){var r=e.sourceRoot;var n=new SourceMapGenerator({file:e.file,sourceRoot:r});e.eachMapping((function(e){var t={generated:{line:e.generatedLine,column:e.generatedColumn}};if(e.source!=null){t.source=e.source;if(r!=null){t.source=o.relative(r,t.source)}t.original={line:e.originalLine,column:e.originalColumn};if(e.name!=null){t.name=e.name}}n.addMapping(t)}));e.sources.forEach((function(t){var i=t;if(r!==null){i=o.relative(r,t)}if(!n._sources.has(i)){n._sources.add(i)}var a=e.sourceContentFor(t);if(a!=null){n.setSourceContent(t,a)}}));return n};SourceMapGenerator.prototype.addMapping=function SourceMapGenerator_addMapping(e){var r=o.getArg(e,"generated");var n=o.getArg(e,"original",null);var t=o.getArg(e,"source",null);var i=o.getArg(e,"name",null);if(!this._skipValidation){this._validateMapping(r,n,t,i)}if(t!=null){t=String(t);if(!this._sources.has(t)){this._sources.add(t)}}if(i!=null){i=String(i);if(!this._names.has(i)){this._names.add(i)}}this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:t,name:i})};SourceMapGenerator.prototype.setSourceContent=function SourceMapGenerator_setSourceContent(e,r){var n=e;if(this._sourceRoot!=null){n=o.relative(this._sourceRoot,n)}if(r!=null){if(!this._sourcesContents){this._sourcesContents=Object.create(null)}this._sourcesContents[o.toSetString(n)]=r}else if(this._sourcesContents){delete this._sourcesContents[o.toSetString(n)];if(Object.keys(this._sourcesContents).length===0){this._sourcesContents=null}}};SourceMapGenerator.prototype.applySourceMap=function SourceMapGenerator_applySourceMap(e,r,n){var t=r;if(r==null){if(e.file==null){throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, "+'or the source map\'s "file" property. Both were omitted.')}t=e.file}var a=this._sourceRoot;if(a!=null){t=o.relative(a,t)}var u=new i;var s=new i;this._mappings.unsortedForEach((function(r){if(r.source===t&&r.originalLine!=null){var i=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});if(i.source!=null){r.source=i.source;if(n!=null){r.source=o.join(n,r.source)}if(a!=null){r.source=o.relative(a,r.source)}r.originalLine=i.line;r.originalColumn=i.column;if(i.name!=null){r.name=i.name}}}var l=r.source;if(l!=null&&!u.has(l)){u.add(l)}var c=r.name;if(c!=null&&!s.has(c)){s.add(c)}}),this);this._sources=u;this._names=s;e.sources.forEach((function(r){var t=e.sourceContentFor(r);if(t!=null){if(n!=null){r=o.join(n,r)}if(a!=null){r=o.relative(a,r)}this.setSourceContent(r,t)}}),this)};SourceMapGenerator.prototype._validateMapping=function SourceMapGenerator_validateMapping(e,r,n,t){if(r&&typeof r.line!=="number"&&typeof r.column!=="number"){throw new Error("original.line and original.column are not numbers -- you probably meant to omit "+"the original mapping entirely and only map the generated position. If so, pass "+"null for the original mapping instead of an object with empty or null values.")}if(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!r&&!n&&!t){return}else if(e&&"line"in e&&"column"in e&&r&&"line"in r&&"column"in r&&e.line>0&&e.column>=0&&r.line>0&&r.column>=0&&n){return}else{throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:r,name:t}))}};SourceMapGenerator.prototype._serializeMappings=function SourceMapGenerator_serializeMappings(){var e=0;var r=1;var n=0;var i=0;var a=0;var u=0;var s="";var l;var c;var p;var f;var g=this._mappings.toArray();for(var d=0,h=g.length;d0){if(!o.compareByGeneratedPositionsInflated(c,g[d-1])){continue}l+=","}}l+=t.encode(c.generatedColumn-e);e=c.generatedColumn;if(c.source!=null){f=this._sources.indexOf(c.source);l+=t.encode(f-u);u=f;l+=t.encode(c.originalLine-1-i);i=c.originalLine-1;l+=t.encode(c.originalColumn-n);n=c.originalColumn;if(c.name!=null){p=this._names.indexOf(c.name);l+=t.encode(p-a);a=p}}s+=l}return s};SourceMapGenerator.prototype._generateSourcesContent=function SourceMapGenerator_generateSourcesContent(e,r){return e.map((function(e){if(!this._sourcesContents){return null}if(r!=null){e=o.relative(r,e)}var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)};SourceMapGenerator.prototype.toJSON=function SourceMapGenerator_toJSON(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null){e.file=this._file}if(this._sourceRoot!=null){e.sourceRoot=this._sourceRoot}if(this._sourcesContents){e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)}return e};SourceMapGenerator.prototype.toString=function SourceMapGenerator_toString(){return JSON.stringify(this.toJSON())};r.x=SourceMapGenerator},565:(e,r,n)=>{var t;var o=n(163).x;var i=n(297);var a=/(\r?\n)/;var u=10;var s="$$$isSourceNode$$$";function SourceNode(e,r,n,t,o){this.children=[];this.sourceContents={};this.line=e==null?null:e;this.column=r==null?null:r;this.source=n==null?null:n;this.name=o==null?null:o;this[s]=true;if(t!=null)this.add(t)}SourceNode.fromStringWithSourceMap=function SourceNode_fromStringWithSourceMap(e,r,n){var t=new SourceNode;var o=e.split(a);var u=0;var shiftNextLine=function(){var e=getNextLine();var r=getNextLine()||"";return e+r;function getNextLine(){return u=0;r--){this.prepend(e[r])}}else if(e[s]||typeof e==="string"){this.children.unshift(e)}else{throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e)}return this};SourceNode.prototype.walk=function SourceNode_walk(e){var r;for(var n=0,t=this.children.length;n0){r=[];for(n=0;n{function getArg(e,r,n){if(r in e){return e[r]}else if(arguments.length===3){return n}else{throw new Error('"'+r+'" is a required argument.')}}r.getArg=getArg;var n=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;var t=/^data:.+\,.+$/;function urlParse(e){var r=e.match(n);if(!r){return null}return{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}}r.urlParse=urlParse;function urlGenerate(e){var r="";if(e.scheme){r+=e.scheme+":"}r+="//";if(e.auth){r+=e.auth+"@"}if(e.host){r+=e.host}if(e.port){r+=":"+e.port}if(e.path){r+=e.path}return r}r.urlGenerate=urlGenerate;function normalize(e){var n=e;var t=urlParse(e);if(t){if(!t.path){return e}n=t.path}var o=r.isAbsolute(n);var i=n.split(/\/+/);for(var a,u=0,s=i.length-1;s>=0;s--){a=i[s];if(a==="."){i.splice(s,1)}else if(a===".."){u++}else if(u>0){if(a===""){i.splice(s+1,u);u=0}else{i.splice(s,2);u--}}}n=i.join("/");if(n===""){n=o?"/":"."}if(t){t.path=n;return urlGenerate(t)}return n}r.normalize=normalize;function join(e,r){if(e===""){e="."}if(r===""){r="."}var n=urlParse(r);var o=urlParse(e);if(o){e=o.path||"/"}if(n&&!n.scheme){if(o){n.scheme=o.scheme}return urlGenerate(n)}if(n||r.match(t)){return r}if(o&&!o.host&&!o.path){o.host=r;return urlGenerate(o)}var i=r.charAt(0)==="/"?r:normalize(e.replace(/\/+$/,"")+"/"+r);if(o){o.path=i;return urlGenerate(o)}return i}r.join=join;r.isAbsolute=function(e){return e.charAt(0)==="/"||n.test(e)};function relative(e,r){if(e===""){e="."}e=e.replace(/\/$/,"");var n=0;while(r.indexOf(e+"/")!==0){var t=e.lastIndexOf("/");if(t<0){return r}e=e.slice(0,t);if(e.match(/^([^\/]+:\/)?\/*$/)){return r}++n}return Array(n+1).join("../")+r.substr(e.length+1)}r.relative=relative;var o=function(){var e=Object.create(null);return!("__proto__"in e)}();function identity(e){return e}function toSetString(e){if(isProtoString(e)){return"$"+e}return e}r.toSetString=o?identity:toSetString;function fromSetString(e){if(isProtoString(e)){return e.slice(1)}return e}r.fromSetString=o?identity:fromSetString;function isProtoString(e){if(!e){return false}var r=e.length;if(r<9){return false}if(e.charCodeAt(r-1)!==95||e.charCodeAt(r-2)!==95||e.charCodeAt(r-3)!==111||e.charCodeAt(r-4)!==116||e.charCodeAt(r-5)!==111||e.charCodeAt(r-6)!==114||e.charCodeAt(r-7)!==112||e.charCodeAt(r-8)!==95||e.charCodeAt(r-9)!==95){return false}for(var n=r-10;n>=0;n--){if(e.charCodeAt(n)!==36){return false}}return true}function compareByOriginalPositions(e,r,n){var t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0||n){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0){return t}t=e.generatedLine-r.generatedLine;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByOriginalPositions=compareByOriginalPositions;function compareByGeneratedPositionsDeflated(e,r,n){var t=e.generatedLine-r.generatedLine;if(t!==0){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0||n){return t}t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsDeflated=compareByGeneratedPositionsDeflated;function strcmp(e,r){if(e===r){return 0}if(e===null){return 1}if(r===null){return-1}if(e>r){return 1}return-1}function compareByGeneratedPositionsInflated(e,r){var n=e.generatedLine-r.generatedLine;if(n!==0){return n}n=e.generatedColumn-r.generatedColumn;if(n!==0){return n}n=strcmp(e.source,r.source);if(n!==0){return n}n=e.originalLine-r.originalLine;if(n!==0){return n}n=e.originalColumn-r.originalColumn;if(n!==0){return n}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;function parseSourceMapInput(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}r.parseSourceMapInput=parseSourceMapInput;function computeSourceURL(e,r,n){r=r||"";if(e){if(e[e.length-1]!=="/"&&r[0]!=="/"){e+="/"}r=e+r}if(n){var t=urlParse(n);if(!t){throw new Error("sourceMapURL could not be parsed")}if(t.path){var o=t.path.lastIndexOf("/");if(o>=0){t.path=t.path.substring(0,o+1)}}r=join(urlGenerate(t),r)}return normalize(r)}r.computeSourceURL=computeSourceURL},927:(e,r,n)=>{n(163).x;r.SourceMapConsumer=n(684).SourceMapConsumer;n(565)},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")}};var r={};function __webpack_require__(n){var t=r[n];if(t!==undefined){return t.exports}var o=r[n]={id:n,loaded:false,exports:{}};var i=true;try{e[n](o,o.exports,__webpack_require__);i=false}finally{if(i)delete r[n]}o.loaded=true;return o.exports}(()=>{__webpack_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __webpack_require__!=="undefined")__webpack_require__.ab=__dirname+"/";var n={};__webpack_require__(599).install();module.exports=n})(); -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import jest from "eslint-plugin-jest"; 2 | import typescriptEslint from "@typescript-eslint/eslint-plugin"; 3 | import globals from "globals"; 4 | import tsParser from "@typescript-eslint/parser"; 5 | import path from "node:path"; 6 | import { fileURLToPath } from "node:url"; 7 | import { FlatCompat } from "@eslint/eslintrc"; 8 | import eslintJs from "@eslint/js"; 9 | import eslintTs from 'typescript-eslint'; 10 | import importPlugin from 'eslint-plugin-import'; 11 | 12 | const __filename = fileURLToPath(import.meta.url); 13 | const __dirname = path.dirname(__filename); 14 | const compat = new FlatCompat({ 15 | baseDirectory: __dirname, 16 | recommendedConfig: eslintJs.configs.recommended, 17 | allConfig: eslintJs.configs.all 18 | }); 19 | 20 | const languageOptions = { 21 | globals: { 22 | ...globals.node, 23 | ...globals.jest, 24 | ...jest.environments.globals.globals, 25 | }, 26 | ecmaVersion: 2023, 27 | sourceType: 'module', 28 | } 29 | 30 | const tsFiles = ['{src,tests}/**/*.ts'] 31 | 32 | // Add the files for applying the recommended TypeScript configs 33 | // only for the Typescript files. 34 | // This is necessary when we have the multiple extensions files 35 | // (e.g. .ts, .tsx, .js, .cjs, .mjs, etc.). 36 | const recommendedTypeScriptConfigs = [ 37 | ...eslintTs.configs.recommended.map((config) => ({ 38 | ...config, 39 | files: tsFiles, 40 | })), 41 | ...eslintTs.configs.stylistic.map((config) => ({ 42 | ...config, 43 | files: tsFiles, 44 | })), 45 | ] 46 | 47 | const customTypescriptConfig = { 48 | files: tsFiles, 49 | plugins: { 50 | import: importPlugin, 51 | 'import/parsers': tsParser, 52 | jest, 53 | "@typescript-eslint": typescriptEslint, 54 | }, 55 | 56 | languageOptions: { 57 | ...languageOptions, 58 | parser: tsParser, 59 | ecmaVersion: 9, 60 | parserOptions: { 61 | project: "./tsconfig.json", 62 | }, 63 | }, 64 | 65 | rules: { 66 | "no-console": "off", 67 | "i18n-text/no-en": "off", 68 | "eslint-comments/no-use": "off", 69 | "import/no-namespace": "off", 70 | "no-unused-vars": "off", 71 | "@typescript-eslint/no-unused-vars": "error", 72 | 73 | "@typescript-eslint/explicit-member-accessibility": ["error", { 74 | accessibility: "no-public", 75 | }], 76 | 77 | "@typescript-eslint/no-require-imports": "error", 78 | "@typescript-eslint/array-type": "error", 79 | "@typescript-eslint/await-thenable": "error", 80 | "@typescript-eslint/ban-ts-comment": "error", 81 | camelcase: "off", 82 | "@typescript-eslint/consistent-type-assertions": "error", 83 | 84 | "@typescript-eslint/explicit-function-return-type": ["error", { 85 | allowExpressions: true, 86 | }], 87 | 88 | "@typescript-eslint/no-array-constructor": "error", 89 | "@typescript-eslint/no-empty-interface": "error", 90 | "@typescript-eslint/no-explicit-any": "error", 91 | "@typescript-eslint/no-extraneous-class": "error", 92 | "@typescript-eslint/no-for-in-array": "error", 93 | "@typescript-eslint/no-inferrable-types": "error", 94 | "@typescript-eslint/no-misused-new": "error", 95 | "@typescript-eslint/no-namespace": "error", 96 | "@typescript-eslint/no-non-null-assertion": "warn", 97 | "@typescript-eslint/no-unnecessary-qualifier": "error", 98 | "@typescript-eslint/no-unnecessary-type-assertion": "error", 99 | "@typescript-eslint/no-useless-constructor": "error", 100 | "@typescript-eslint/no-var-requires": "error", 101 | "@typescript-eslint/prefer-for-of": "warn", 102 | "@typescript-eslint/prefer-function-type": "warn", 103 | "@typescript-eslint/prefer-includes": "error", 104 | "@typescript-eslint/prefer-string-starts-ends-with": "error", 105 | "@typescript-eslint/promise-function-async": "error", 106 | "@typescript-eslint/require-array-sort-compare": "error", 107 | "@typescript-eslint/restrict-plus-operands": "error", 108 | semi: "off", 109 | "@typescript-eslint/unbound-method": "error", 110 | 111 | "prettier/prettier": ["error", { 112 | printWidth: 120, 113 | tabWidth: 2, 114 | useTabs: false, 115 | semi: true, 116 | singleQuote: true, 117 | trailingComma: "all", 118 | bracketSpacing: false, 119 | arrowParens: "always", 120 | }], 121 | 122 | "filenames/match-regex": "off", 123 | "no-shadow": "off", 124 | "@typescript-eslint/no-shadow": ["error"], 125 | }, 126 | } 127 | 128 | export default [ 129 | { ignores: ["**/dist/", "**/node_modules/"] }, 130 | eslintJs.configs.recommended, 131 | ...compat.extends("plugin:github/recommended"), 132 | ...recommendedTypeScriptConfigs, 133 | customTypescriptConfig, 134 | ]; 135 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // https://jestjs.io/docs/en/configuration.html 2 | // eslint-disable-next-line import/no-commonjs 3 | module.exports = { 4 | clearMocks: true, 5 | moduleFileExtensions: ['js', 'ts'], 6 | testMatch: ['**/*.test.ts'], 7 | transform: { 8 | '^.+\\.ts$': 'ts-jest', 9 | }, 10 | verbose: true, 11 | collectCoverage: true, 12 | coverageDirectory: '.coverage', 13 | collectCoverageFrom: [ 14 | '**/src/**/*.ts', 15 | "!**/node_modules/**", 16 | "!**/tests/**" 17 | ], 18 | // https://istanbul.js.org/docs/advanced/alternative-reporters/ 19 | // https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib 20 | // coverageReporters: ['clover', 'html', 'json-summary', 'json', 'cobertura', 'teamcity', 'text-summary', 'text'], 21 | coverageReporters: ['clover', 'json-summary', 'html'], 22 | coveragePathIgnorePatterns: ['tests'], 23 | }; 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coverage-monitor-action", 3 | "version": "1.8.0", 4 | "private": true, 5 | "description": "A GitHub Action that monitor coverage.", 6 | "main": "lib/index.js", 7 | "scripts": { 8 | "build": "tsc", 9 | "format": "prettier --write '**/*.ts'", 10 | "format-check": "prettier --check '**/*.ts'", 11 | "lint": "eslint src/**/*.ts && echo \"All done\"", 12 | "package": "ncc build --source-map --license licenses.txt", 13 | "test": "jest", 14 | "all": "npm run format && npm run lint && npm test && npm run build && npm run package" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/slavcodev/coverage-monitor-action.git" 19 | }, 20 | "keywords": [ 21 | "actions", 22 | "coverage", 23 | "clover", 24 | "json-summary", 25 | "istanbul-coverage-reports", 26 | "nyc" 27 | ], 28 | "author": "Veaceslav Medvedev", 29 | "license": "MIT", 30 | "dependencies": { 31 | "@actions/core": "^1.9.1", 32 | "@actions/github": "^6.0.0", 33 | "xml2js": "^0.6.0" 34 | }, 35 | "devDependencies": { 36 | "@eslint/eslintrc": "^3.2.0", 37 | "@eslint/js": "^9.17.0", 38 | "@types/jest": "^29.5.12", 39 | "@types/node": "^22.0.0", 40 | "@types/xml2js": "^0.4.9", 41 | "@typescript-eslint/eslint-plugin": "^8.1.0", 42 | "@typescript-eslint/parser": "^8.1.0", 43 | "@vercel/ncc": "^0.38.0", 44 | "eslint": "^9.17.0", 45 | "eslint-plugin-github": "latest", 46 | "eslint-plugin-import": "latest", 47 | "eslint-plugin-jest": "latest", 48 | "eslint-plugin-prettier": "latest", 49 | "globals": "^16.0.0", 50 | "jest": "^29.7.0", 51 | "prettier": "^3.0.0", 52 | "ts-jest": "^29.1.2", 53 | "typescript": "^5.3.3", 54 | "typescript-eslint": "^8.18.0" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /screenshot-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slavcodev/coverage-monitor-action/d1d5b26f992294903887db302430b73a11cf15a5/screenshot-light.png -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slavcodev/coverage-monitor-action/d1d5b26f992294903887db302430b73a11cf15a5/screenshot.png -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core'; 2 | import * as github from '@actions/github'; 3 | import App from './types/App'; 4 | 5 | (async function (): Promise { 6 | try { 7 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 8 | // @ts-ignore 9 | const app = new App(core, github); 10 | await app.run(); 11 | } catch (error) { 12 | if (error instanceof Error) core.setFailed(error.message); 13 | } 14 | })(); 15 | -------------------------------------------------------------------------------- /src/types/App.ts: -------------------------------------------------------------------------------- 1 | import FileSystem from './FileSystem'; 2 | import GitHub from './github/GitHub'; 3 | import GitHubAction from './github/GitHubAction'; 4 | import GitHubAdapter from './github/GitHubAdapter'; 5 | import GitHubClientAdapter from './github/GitHubClientAdapter'; 6 | import Threshold from './Threshold'; 7 | 8 | export default class App { 9 | readonly #core: GitHub; 10 | readonly #action: GitHubAction; 11 | 12 | constructor(core: GitHub, action: GitHubAction) { 13 | this.#core = core; 14 | this.#action = action; 15 | } 16 | 17 | async run(): Promise { 18 | if (this.#core.isDebug()) { 19 | this.#core.debug('Processing webhook request...'); 20 | console.log(this.#action.context); 21 | } 22 | 23 | const adapter = new GitHubAdapter(this.#core); 24 | const config = adapter.loadConfig(); 25 | const fs = new FileSystem(config.workingDir); 26 | const coverage = await fs.parseFile(config.coveragePath, config.coverageFormat); 27 | const report = coverage.report( 28 | new Threshold(config.threshold.metric, config.threshold.alert, config.threshold.warning), 29 | ); 30 | 31 | if (this.#core.isDebug()) { 32 | this.#core.debug('Prepared coverage report'); 33 | console.log(report); 34 | } 35 | 36 | const client = new GitHubClientAdapter( 37 | this.#action.getOctokit(config.githubToken).rest, 38 | this.#action.context, 39 | adapter.parseWebhook(this.#action.context), 40 | ); 41 | 42 | const requests = []; 43 | 44 | if (config.check) { 45 | requests.push(client.createStatus(config.check.context, report)); 46 | } 47 | 48 | if (config.comment) { 49 | requests.push(client.commentReport(config.comment, config.comment.context, report)); 50 | } 51 | 52 | if (requests.length > 0) { 53 | await Promise.all(requests); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/types/Bips.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Basis points, otherwise known as bps or "bips," are a unit of measure used in finance to describe the percentage rate. 3 | * The benefit of using bips is to avoid usage of float numbers. 4 | * 5 | * One basis point is equivalent to 0.01%, i.e. 100% is 10000 bips. This means the number allowed is from 0 to 10000. 6 | */ 7 | type Bips = number; 8 | 9 | export default Bips; 10 | -------------------------------------------------------------------------------- /src/types/Comment.ts: -------------------------------------------------------------------------------- 1 | import Metric from './Metric'; 2 | import MetricCollection from './MetricCollection'; 3 | import MetricType from './MetricType'; 4 | import ReportResult from './ReportResult'; 5 | 6 | export default class Comment { 7 | constructor( 8 | readonly metrics: MetricCollection, 9 | readonly result: ReportResult, 10 | readonly context: string, 11 | readonly footer: boolean, 12 | ) {} 13 | 14 | static generateBadgeUrl({rate, level}: ReportResult): string { 15 | return `https://img.shields.io/static/v1?label=coverage&message=${Math.round(rate / 100)}%&color=${level}`; 16 | } 17 | 18 | static generateEmoji({rate}: ReportResult): string { 19 | return rate === 10000 ? ' 🎉' : ''; 20 | } 21 | 22 | static generateFooter(): string { 23 | return `\n### [![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)`; 24 | } 25 | 26 | static generateTableRow(title: string, {rate, total, covered}: Metric): string { 27 | return total ? `| ${title}: | ${rate / 100}% ( ${covered} / ${total} ) |\n` : ''; 28 | } 29 | 30 | generateCommentHeader(): string { 31 | return ``; 32 | } 33 | 34 | generateTable(): string { 35 | return `${this.generateCommentHeader()} 36 | ## ${this.context}${Comment.generateEmoji(this.result)} 37 | 38 | | Totals | ![Coverage](${Comment.generateBadgeUrl(this.result)}) | 39 | | :-- | :-- | 40 | ${[ 41 | Comment.generateTableRow('Statements', this.metrics[MetricType.Statements]), 42 | Comment.generateTableRow('Methods', this.metrics[MetricType.Methods]), 43 | Comment.generateTableRow('Lines', this.metrics[MetricType.Lines]), 44 | Comment.generateTableRow('Branches', this.metrics[MetricType.Branches]), 45 | ].join('')}${this.footer ? Comment.generateFooter() : ''}`; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/types/CommentConfiguration.ts: -------------------------------------------------------------------------------- 1 | import CommentMode from './CommentMode'; 2 | 3 | export default interface CommentConfiguration { 4 | mode: CommentMode; 5 | context: string; 6 | footer: boolean; 7 | } 8 | -------------------------------------------------------------------------------- /src/types/CommentMode.ts: -------------------------------------------------------------------------------- 1 | enum CommentMode { 2 | Replace = 'replace', 3 | Insert = 'insert', 4 | Update = 'update', 5 | } 6 | 7 | export default CommentMode; 8 | -------------------------------------------------------------------------------- /src/types/Configuration.ts: -------------------------------------------------------------------------------- 1 | import Bips from './Bips'; 2 | import CommentConfiguration from './CommentConfiguration'; 3 | import MetricType from './MetricType'; 4 | 5 | export default class Configuration { 6 | readonly githubToken: string; 7 | readonly coveragePath: string; 8 | readonly coverageFormat: string; 9 | readonly workingDir: string; 10 | readonly threshold: { 11 | metric: MetricType; 12 | alert: Bips; 13 | warning: Bips; 14 | }; 15 | readonly comment?: CommentConfiguration; 16 | readonly check?: { 17 | context: string; 18 | }; 19 | 20 | constructor({githubToken, coveragePath, coverageFormat, workingDir, threshold, comment, check}: Configuration) { 21 | this.githubToken = githubToken; 22 | this.coveragePath = coveragePath; 23 | this.coverageFormat = coverageFormat; 24 | this.workingDir = workingDir; 25 | this.threshold = threshold; 26 | this.githubToken = githubToken; 27 | this.comment = comment; 28 | this.check = check; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/types/CoverageItem.ts: -------------------------------------------------------------------------------- 1 | import Integer from './Integer'; 2 | 3 | export default interface CoverageItem { 4 | total: Integer; 5 | covered: Integer; 6 | } 7 | -------------------------------------------------------------------------------- /src/types/CoverageSummary.ts: -------------------------------------------------------------------------------- 1 | import CoverageItem from './CoverageItem'; 2 | import Metric from './Metric'; 3 | import MetricCollection from './MetricCollection'; 4 | import MetricType from './MetricType'; 5 | import Report from './Report'; 6 | import Threshold from './Threshold'; 7 | 8 | export default class CoverageSummary { 9 | constructor(readonly metrics: MetricCollection) {} 10 | 11 | report(threshold: Threshold): Report { 12 | return new Report( 13 | { 14 | [MetricType.Statements]: new Metric(this.metrics[MetricType.Statements]), 15 | [MetricType.Lines]: new Metric(this.metrics[MetricType.Lines]), 16 | [MetricType.Methods]: new Metric(this.metrics[MetricType.Methods]), 17 | [MetricType.Branches]: new Metric(this.metrics[MetricType.Branches]), 18 | }, 19 | threshold, 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/types/FileSystem.ts: -------------------------------------------------------------------------------- 1 | import CoverageSummary from './CoverageSummary'; 2 | import Format from './Format'; 3 | import JsonParser from './JsonParser'; 4 | import XmlParser from './XmlParser'; 5 | import fs from 'fs/promises'; 6 | import path from 'path'; 7 | 8 | export default class FileSystem { 9 | #xmlParser: XmlParser; 10 | #jsonParser: JsonParser; 11 | 12 | constructor(readonly workingDir: string) { 13 | this.#xmlParser = new XmlParser(); 14 | this.#jsonParser = new JsonParser(); 15 | } 16 | 17 | async readFile(filename: string): Promise { 18 | return (await fs.readFile(path.join(this.workingDir, filename), {encoding: 'utf-8'})).replace('\ufeff', ''); 19 | } 20 | 21 | guessFormat(filename: string): Format { 22 | switch (filename.substring(filename.lastIndexOf('.') + 1)) { 23 | case 'xml': 24 | return Format.Clover; 25 | case 'json': 26 | return Format.JsonSummary; 27 | default: 28 | throw new Error(`Cannot guess format of "${filename}"`); 29 | } 30 | } 31 | 32 | async parseFile(filename: string, format: string): Promise { 33 | switch (format) { 34 | case Format.Auto: 35 | return this.parseFile(filename, this.guessFormat(filename)); 36 | case Format.Clover: 37 | return new CoverageSummary(await this.#xmlParser.parseCloverXml(await this.readFile(filename))); 38 | case Format.JsonSummary: 39 | return new CoverageSummary(await this.#jsonParser.parseJsonSummary(await this.readFile(filename))); 40 | default: 41 | throw new Error(`Invalid option "coverage_format" - supported ${Object.values(Format).join(', ')}`); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/types/Format.ts: -------------------------------------------------------------------------------- 1 | enum Format { 2 | Auto = 'auto', 3 | Clover = 'clover', 4 | JsonSummary = 'json-summary', 5 | } 6 | 7 | export default Format; 8 | -------------------------------------------------------------------------------- /src/types/Integer.ts: -------------------------------------------------------------------------------- 1 | type Integer = number; 2 | 3 | export default Integer; 4 | -------------------------------------------------------------------------------- /src/types/JsonParser.ts: -------------------------------------------------------------------------------- 1 | import CoverageItem from './CoverageItem'; 2 | import MetricCollection from './MetricCollection'; 3 | 4 | interface JsonSummaryItem { 5 | total: number; 6 | covered: number; 7 | } 8 | 9 | interface JsonSummaryRecord { 10 | total: { 11 | statements: JsonSummaryItem; 12 | lines: JsonSummaryItem; 13 | functions: JsonSummaryItem; 14 | branches: JsonSummaryItem; 15 | }; 16 | } 17 | 18 | export default class JsonParser { 19 | #parseJsonFile(buffer: string): JsonSummaryRecord { 20 | return JSON.parse(buffer) as JsonSummaryRecord; 21 | } 22 | 23 | async parseJsonSummary(buffer: string): Promise> { 24 | const {total} = this.#parseJsonFile(buffer); 25 | 26 | return { 27 | statements: {total: Number(total.statements.total), covered: Number(total.statements.covered)}, 28 | lines: {total: Number(total.lines.total), covered: Number(total.lines.covered)}, 29 | methods: {total: Number(total.functions.total), covered: Number(total.functions.covered)}, 30 | branches: {total: Number(total.branches.total), covered: Number(total.branches.covered)}, 31 | }; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/types/Metric.ts: -------------------------------------------------------------------------------- 1 | import Bips from './Bips'; 2 | import Integer from './Integer'; 3 | import ReportResult from './ReportResult'; 4 | import Threshold from './Threshold'; 5 | 6 | export default class Metric { 7 | readonly total: Integer; 8 | readonly covered: Integer; 9 | readonly rate: Bips; 10 | 11 | constructor({total, covered}: {total: Integer; covered: Integer}) { 12 | this.total = total; 13 | this.covered = covered; 14 | this.rate = total ? Number(Number((covered / total) * 10000).toFixed(0)) : 0; 15 | } 16 | 17 | report(threshold: Threshold): ReportResult { 18 | return { 19 | metric: threshold.metric, 20 | level: threshold.calc(this.rate), 21 | ...this, 22 | }; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/types/MetricCollection.ts: -------------------------------------------------------------------------------- 1 | import Metric from './Metric'; 2 | import MetricType from './MetricType'; 3 | 4 | type MetricCollection = Record; 5 | 6 | export default MetricCollection; 7 | -------------------------------------------------------------------------------- /src/types/MetricLevel.ts: -------------------------------------------------------------------------------- 1 | enum MetricLevel { 2 | Red = 'red', 3 | Yellow = 'yellow', 4 | Green = 'green', 5 | } 6 | 7 | export default MetricLevel; 8 | -------------------------------------------------------------------------------- /src/types/MetricType.ts: -------------------------------------------------------------------------------- 1 | enum MetricType { 2 | Lines = 'lines', 3 | Statements = 'statements', 4 | Branches = 'branches', 5 | Methods = 'methods', 6 | } 7 | 8 | export default MetricType; 9 | -------------------------------------------------------------------------------- /src/types/Report.ts: -------------------------------------------------------------------------------- 1 | import Comment from './Comment'; 2 | import MetricCollection from './MetricCollection'; 3 | import ReportResult from './ReportResult'; 4 | import Status from './Status'; 5 | import Threshold from './Threshold'; 6 | 7 | export default class Report { 8 | readonly result: ReportResult; 9 | 10 | constructor( 11 | readonly metrics: MetricCollection, 12 | readonly threshold: Threshold, 13 | ) { 14 | this.result = this.metrics[this.threshold.metric].report(threshold); 15 | } 16 | 17 | toComment(context: string, footer: boolean): Comment { 18 | return new Comment(this.metrics, this.result, context, footer); 19 | } 20 | 21 | toStatus(context: string, targetUrl: string): Status { 22 | return new Status(this.result, context, targetUrl); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/types/ReportResult.ts: -------------------------------------------------------------------------------- 1 | import Bips from './Bips'; 2 | import Integer from './Integer'; 3 | import MetricLevel from './MetricLevel'; 4 | import MetricType from './MetricType'; 5 | 6 | export default interface ReportResult { 7 | readonly total: Integer; 8 | readonly covered: Integer; 9 | readonly rate: Bips; 10 | readonly level: MetricLevel; 11 | readonly metric: MetricType; 12 | } 13 | -------------------------------------------------------------------------------- /src/types/Status.ts: -------------------------------------------------------------------------------- 1 | import MetricLevel from './MetricLevel'; 2 | import ReportResult from './ReportResult'; 3 | import StatusState from './StatusState'; 4 | 5 | export default class Status { 6 | readonly state: StatusState; 7 | readonly description: string; 8 | 9 | constructor( 10 | {level, rate, metric}: ReportResult, 11 | readonly context: string, 12 | readonly target_url: string, 13 | ) { 14 | if (level === MetricLevel.Red) { 15 | this.state = StatusState.Failure; 16 | this.description = `Error: Too low ${metric} coverage - ${rate / 100}%`; 17 | } else if (level === MetricLevel.Yellow) { 18 | this.state = StatusState.Success; 19 | this.description = `Warning: low ${metric} coverage - ${rate / 100}%`; 20 | } else { 21 | this.state = StatusState.Success; 22 | this.description = `Success: ${metric} coverage - ${rate / 100}%`; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/types/StatusState.ts: -------------------------------------------------------------------------------- 1 | enum StatusState { 2 | Success = 'success', 3 | Failure = 'failure', 4 | } 5 | 6 | export default StatusState; 7 | -------------------------------------------------------------------------------- /src/types/Threshold.ts: -------------------------------------------------------------------------------- 1 | import Bips from './Bips'; 2 | import MetricLevel from './MetricLevel'; 3 | import MetricType from './MetricType'; 4 | 5 | export default class Threshold { 6 | constructor( 7 | readonly metric: MetricType, 8 | readonly alert: Bips, 9 | readonly warning: Bips, 10 | ) {} 11 | 12 | calc(rate: Bips): MetricLevel { 13 | if (rate < this.alert) { 14 | return MetricLevel.Red; 15 | } else if (rate < this.warning) { 16 | return MetricLevel.Yellow; 17 | } else { 18 | return MetricLevel.Green; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/types/XmlParser.ts: -------------------------------------------------------------------------------- 1 | import CoverageItem from './CoverageItem'; 2 | import MetricCollection from './MetricCollection'; 3 | import xml2js from 'xml2js'; 4 | 5 | interface XmlNode { 6 | attributes: Record; 7 | children: Record; 8 | content: string; 9 | } 10 | 11 | export default class XmlParser { 12 | #parser: xml2js.Parser; 13 | 14 | constructor() { 15 | // noinspection SpellCheckingInspection 16 | this.#parser = new xml2js.Parser({ 17 | // Normalize all tag names to lowercase. 18 | normalizeTags: true, 19 | // Always put child nodes in an array if true; otherwise an array is created only if there is more than one. 20 | explicitArray: true, 21 | attrkey: 'attributes', 22 | charkey: 'content', 23 | childkey: 'children', 24 | // Put child elements to separate property (see `childkey`). 25 | explicitChildren: true, 26 | // Set this if you want to get the root node in the resulting object. 27 | explicitRoot: false, 28 | }); 29 | } 30 | 31 | async #parseXmlFile(buffer: string): Promise { 32 | return (await this.#parser.parseStringPromise(buffer)) as XmlNode; 33 | } 34 | 35 | async parseCloverXml(buffer: string): Promise> { 36 | const xml = await this.#parseXmlFile(buffer); 37 | 38 | const { 39 | elements, 40 | coveredelements, 41 | statements, 42 | coveredstatements, 43 | methods, 44 | coveredmethods, 45 | conditionals, 46 | coveredconditionals, 47 | } = xml.children.project[0].children.metrics[0].attributes; 48 | 49 | return { 50 | statements: {total: Number(elements), covered: Number(coveredelements)}, 51 | lines: {total: Number(statements), covered: Number(coveredstatements)}, 52 | methods: {total: Number(methods), covered: Number(coveredmethods)}, 53 | branches: {total: Number(conditionals), covered: Number(coveredconditionals)}, 54 | }; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/types/github/GiHubComment.ts: -------------------------------------------------------------------------------- 1 | export default interface GitHubComment { 2 | id: string; 3 | body: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/types/github/GitHub.ts: -------------------------------------------------------------------------------- 1 | export default interface GitHub { 2 | isDebug(): boolean; 3 | debug(message: string): void; 4 | getInput(name: string, options?: {required: boolean}): string; 5 | } 6 | -------------------------------------------------------------------------------- /src/types/github/GitHubAction.ts: -------------------------------------------------------------------------------- 1 | import GitHubClient from './GitHubClient'; 2 | import GitHubWebhook from './GitHubWebhook'; 3 | 4 | export default interface GitHubAction { 5 | context: GitHubWebhook; 6 | getOctokit(authToken: string, options?: unknown): {rest: GitHubClient}; 7 | } 8 | -------------------------------------------------------------------------------- /src/types/github/GitHubAdapter.ts: -------------------------------------------------------------------------------- 1 | import Bips from '../Bips'; 2 | import CommentMode from '../CommentMode'; 3 | import Configuration from '../Configuration'; 4 | import Format from '../Format'; 5 | import GitHub from './GitHub'; 6 | import GitHubPullRequest from './GitHubPullRequest'; 7 | import GitHubWebhook from './GitHubWebhook'; 8 | import MetricType from '../MetricType'; 9 | 10 | export default class GitHubAdapter { 11 | readonly #core: GitHub; 12 | 13 | constructor(core: GitHub) { 14 | this.#core = core; 15 | } 16 | 17 | static #toBool(value: string | boolean, def: boolean): boolean { 18 | if (typeof value === 'boolean') { 19 | return value; 20 | } 21 | 22 | switch (`${value}`.toLowerCase()) { 23 | case 'true': 24 | case 'on': 25 | case 'yes': 26 | return true; 27 | case 'false': 28 | case 'off': 29 | case 'no': 30 | return false; 31 | default: 32 | return def; 33 | } 34 | } 35 | 36 | static #toBips(value: string, def: number): Bips { 37 | return value !== undefined ? Math.round(Number(value) * 100) : def; 38 | } 39 | 40 | static #getWorkingDirectory(): string { 41 | return process.env.GITHUB_WORKSPACE || process.cwd(); 42 | } 43 | 44 | loadConfig(): Configuration { 45 | const githubToken = this.#core.getInput('github_token', {required: true}); 46 | const workingDir = this.#core.getInput('working_dir') || GitHubAdapter.#getWorkingDirectory(); 47 | 48 | const cloverFile = this.#core.getInput('clover_file'); 49 | const coveragePath = this.#core.getInput('coverage_path') || cloverFile; 50 | const coverageFormat = (this.#core.getInput('coverage_format') || Format.Auto) as Format; 51 | 52 | const thresholdAlert = GitHubAdapter.#toBips(this.#core.getInput('threshold_alert'), 5000); 53 | const thresholdWarning = GitHubAdapter.#toBips(this.#core.getInput('threshold_warning'), 9000); 54 | const thresholdMetric = (this.#core.getInput('threshold_metric') || MetricType.Lines) as MetricType; 55 | 56 | const check = GitHubAdapter.#toBool(this.#core.getInput('check'), true); 57 | const statusContext = this.#core.getInput('status_context') || 'Coverage Report'; 58 | 59 | const comment = GitHubAdapter.#toBool(this.#core.getInput('comment'), true); 60 | const commentFooter = GitHubAdapter.#toBool(this.#core.getInput('comment_footer'), true); 61 | const commentContext = this.#core.getInput('comment_context') || 'Coverage Report'; 62 | const commentMode = (this.#core.getInput('comment_mode') || CommentMode.Replace) as CommentMode; 63 | 64 | if (cloverFile && coveragePath !== cloverFile) { 65 | throw new Error('The `clover_file` option is deprecated and cannot be set along with `coverage_path`'); 66 | } 67 | 68 | if (!coveragePath) { 69 | throw new Error('Missing or invalid option `coverage_path`'); 70 | } 71 | 72 | if (!Object.values(Format).includes(coverageFormat)) { 73 | throw new Error(`Invalid option "coverage_format" - supported ${Object.values(Format).join(', ')}`); 74 | } 75 | 76 | if (!Object.values(MetricType).includes(thresholdMetric)) { 77 | throw new Error(`Invalid option "threshold_metric" - supported ${Object.values(MetricType).join(', ')}`); 78 | } 79 | 80 | if (!Object.values(CommentMode).includes(commentMode)) { 81 | throw new Error(`Invalid option "comment_mode" - supported ${Object.values(CommentMode).join(', ')}`); 82 | } 83 | 84 | return new Configuration({ 85 | githubToken, 86 | coveragePath, 87 | coverageFormat, 88 | workingDir, 89 | threshold: {alert: thresholdAlert, warning: thresholdWarning, metric: thresholdMetric}, 90 | comment: comment ? {context: commentContext, mode: commentMode, footer: commentFooter} : undefined, 91 | check: check ? {context: statusContext} : undefined, 92 | }); 93 | } 94 | 95 | parseWebhook(request: GitHubWebhook): GitHubPullRequest | undefined { 96 | const {payload} = request || {}; 97 | 98 | if (!payload) { 99 | throw new Error('Invalid github event'); 100 | } 101 | 102 | const {pull_request: pr} = payload; 103 | 104 | if (!pr) { 105 | return undefined; 106 | } 107 | 108 | const {number, html_url: url, head: {sha} = {}} = pr; 109 | 110 | if (!number || !url || !sha) { 111 | throw new Error('Invalid pull_request event'); 112 | } 113 | 114 | return {number, url, sha}; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/types/github/GitHubClient.ts: -------------------------------------------------------------------------------- 1 | import GitHubComment from './GiHubComment'; 2 | 3 | export default interface GitHubClient { 4 | repos: { 5 | createCommitStatus(payload: {}): Promise; 6 | }; 7 | issues: { 8 | listComments(payload: {}): Promise<{data: GitHubComment[]}>; 9 | createComment(payload: {}): Promise; 10 | updateComment(payload: {}): Promise; 11 | deleteComment(payload: {}): Promise; 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /src/types/github/GitHubClientAdapter.ts: -------------------------------------------------------------------------------- 1 | import CommentConfiguration from '../CommentConfiguration'; 2 | import CommentMode from '../CommentMode'; 3 | import GitHubClient from './GitHubClient'; 4 | import GitHubComment from './GiHubComment'; 5 | import GitHubPullRequest from './GitHubPullRequest'; 6 | import GitHubWebhook from './GitHubWebhook'; 7 | import Report from '../Report'; 8 | 9 | export default class GitHubClientAdapter { 10 | readonly #client: GitHubClient; 11 | readonly #context: GitHubWebhook; 12 | readonly #pr: GitHubPullRequest | undefined; 13 | 14 | constructor(client: GitHubClient, context: GitHubWebhook, pr: GitHubPullRequest | undefined) { 15 | this.#client = client; 16 | this.#context = context; 17 | this.#pr = pr; 18 | } 19 | 20 | async createStatus(context: string, report: Report): Promise { 21 | if (!this.#pr) { 22 | return; 23 | } 24 | 25 | await this.#client.repos.createCommitStatus({ 26 | ...this.#context.repo, 27 | sha: this.#pr.sha, 28 | ...report.toStatus(context, this.#pr.url), 29 | }); 30 | } 31 | 32 | async commentReport({mode, footer}: CommentConfiguration, context: string, report: Report): Promise { 33 | if (!this.#pr) { 34 | return; 35 | } 36 | 37 | const comment = report.toComment(context, footer); 38 | 39 | switch (mode) { 40 | case CommentMode.Insert: 41 | return this.#insertComment({ 42 | prNumber: this.#pr.number, 43 | body: comment.generateTable(), 44 | }); 45 | case CommentMode.Update: 46 | return this.#upsertComment({ 47 | prNumber: this.#pr.number, 48 | body: comment.generateTable(), 49 | commentHeader: comment.generateCommentHeader(), 50 | }); 51 | case CommentMode.Replace: 52 | default: 53 | return this.#replaceComment({ 54 | prNumber: this.#pr.number, 55 | body: comment.generateTable(), 56 | commentHeader: comment.generateCommentHeader(), 57 | }); 58 | } 59 | } 60 | 61 | async #listComments({prNumber, commentHeader}: {prNumber: number; commentHeader: string}): Promise { 62 | const {data: existingComments} = await this.#client.issues.listComments({ 63 | ...this.#context.repo, 64 | issue_number: prNumber, 65 | }); 66 | 67 | return existingComments.filter(({body}) => body.startsWith(commentHeader)); 68 | } 69 | 70 | async #insertComment({prNumber, body}: {prNumber: number; body: string}): Promise { 71 | await this.#client.issues.createComment({...this.#context.repo, issue_number: prNumber, body}); 72 | } 73 | 74 | async #updateComment({body, commentId}: {body: string; commentId: string}): Promise { 75 | await this.#client.issues.updateComment({...this.#context.repo, comment_id: commentId, body}); 76 | } 77 | 78 | async #deleteComments({comments}: {comments: {id: string}[]}): Promise { 79 | await Promise.all( 80 | comments.map(async ({id}) => this.#client.issues.deleteComment({...this.#context.repo, comment_id: id})), 81 | ); 82 | } 83 | 84 | async #upsertComment({ 85 | prNumber, 86 | body, 87 | commentHeader, 88 | }: { 89 | prNumber: number; 90 | body: string; 91 | commentHeader: string; 92 | }): Promise { 93 | const existingComments = await this.#listComments({prNumber, commentHeader}); 94 | const last = existingComments.pop(); 95 | 96 | await Promise.all([ 97 | this.#deleteComments({comments: existingComments}), 98 | last ? this.#updateComment({body, commentId: last.id}) : this.#insertComment({prNumber, body}), 99 | ]); 100 | } 101 | 102 | async #replaceComment({ 103 | prNumber, 104 | body, 105 | commentHeader, 106 | }: { 107 | prNumber: number; 108 | body: string; 109 | commentHeader: string; 110 | }): Promise { 111 | const existingComments = await this.#listComments({prNumber, commentHeader}); 112 | 113 | await Promise.all([this.#deleteComments({comments: existingComments}), this.#insertComment({prNumber, body})]); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/types/github/GitHubPullRequest.ts: -------------------------------------------------------------------------------- 1 | export default interface GitHubPullRequest { 2 | number: number; 3 | sha: string; 4 | url: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/types/github/GitHubWebhook.ts: -------------------------------------------------------------------------------- 1 | export default interface GitHubWebhook { 2 | repo?: Record; 3 | payload?: { 4 | pull_request: { 5 | number: number; 6 | html_url: string; 7 | head: { 8 | sha: string; 9 | }; 10 | }; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /tests/stubs/clover/clover.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /tests/stubs/clover/clover_no_branches.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/stubs/json-summary/coverage-summary.json: -------------------------------------------------------------------------------- 1 | { 2 | "total": { 3 | "lines": { 4 | "total": 90, 5 | "covered": 78, 6 | "skipped": 0, 7 | "pct": 86.66 8 | }, 9 | "statements": { 10 | "total": 91, 11 | "covered": 78, 12 | "skipped": 0, 13 | "pct": 85.71 14 | }, 15 | "functions": { 16 | "total": 27, 17 | "covered": 18, 18 | "skipped": 0, 19 | "pct": 66.66 20 | }, 21 | "branches": { 22 | "total": 57, 23 | "covered": 53, 24 | "skipped": 0, 25 | "pct": 92.98 26 | }, 27 | "branchesTrue": { 28 | "total": 0, 29 | "covered": 0, 30 | "skipped": 0, 31 | "pct": "Unknown" 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/types/Comment.test.ts: -------------------------------------------------------------------------------- 1 | import Comment from '../../src/types/Comment'; 2 | import Metric from '../../src/types/Metric'; 3 | import MetricLevel from '../../src/types/MetricLevel'; 4 | import MetricType from '../../src/types/MetricType'; 5 | import Report from '../../src/types/Report'; 6 | import ReportResult from '../../src/types/ReportResult'; 7 | import Threshold from '../../src/types/Threshold'; 8 | 9 | describe(`${Comment.name}`, () => { 10 | const defaultReportResult: ReportResult = { 11 | total: 10, 12 | covered: 10, 13 | rate: 10000, 14 | level: MetricLevel.Green, 15 | metric: MetricType.Branches, 16 | }; 17 | 18 | it('generates badge URL', async () => { 19 | expect.hasAssertions(); 20 | 21 | expect(Comment.generateBadgeUrl({...defaultReportResult, rate: 940, level: MetricLevel.Green})).toBe( 22 | 'https://img.shields.io/static/v1?label=coverage&message=9%&color=green', 23 | ); 24 | }); 25 | 26 | it.each([ 27 | {expected: ' 🎉', reportResult: {...defaultReportResult, rate: 10000}}, 28 | {expected: '', reportResult: {...defaultReportResult, rate: 9999}}, 29 | ] as { 30 | expected: string; 31 | reportResult: ReportResult; 32 | }[])('generates emoji $expected', async ({expected, reportResult}) => { 33 | expect.hasAssertions(); 34 | expect(Comment.generateEmoji(reportResult)).toBe(expected); 35 | }); 36 | 37 | it('generates table', async () => { 38 | expect.hasAssertions(); 39 | 40 | const report: Report = new Report( 41 | { 42 | statements: new Metric({total: 10, covered: 1}), 43 | lines: new Metric({total: 10, covered: 2}), 44 | methods: new Metric({total: 10, covered: 3}), 45 | branches: new Metric({total: 10, covered: 4}), 46 | }, 47 | new Threshold(MetricType.Lines, 0, 5000), 48 | ); 49 | 50 | const expectedString = ` 51 | ## foobar coverage 52 | 53 | | Totals | ![Coverage](https://img.shields.io/static/v1?label=coverage&message=20%&color=yellow) | 54 | | :-- | :-- | 55 | | Statements: | 10% ( 1 / 10 ) | 56 | | Methods: | 30% ( 3 / 10 ) | 57 | | Lines: | 20% ( 2 / 10 ) | 58 | | Branches: | 40% ( 4 / 10 ) | 59 | `; 60 | 61 | expect(report.toComment('foobar coverage', false).generateTable()).toBe(expectedString); 62 | }); 63 | 64 | it('hides metric rows in table when metric is not available (total is zero)', async () => { 65 | expect.hasAssertions(); 66 | 67 | const report: Report = new Report( 68 | { 69 | statements: new Metric({total: 10, covered: 1}), 70 | lines: new Metric({total: 10, covered: 2}), 71 | methods: new Metric({total: 0, covered: 0}), 72 | branches: new Metric({total: 10, covered: 4}), 73 | }, 74 | new Threshold(MetricType.Branches, 30, 5000), 75 | ); 76 | 77 | const expectedString = ` 78 | ## Coverage Report 79 | 80 | | Totals | ![Coverage](https://img.shields.io/static/v1?label=coverage&message=40%&color=yellow) | 81 | | :-- | :-- | 82 | | Statements: | 10% ( 1 / 10 ) | 83 | | Lines: | 20% ( 2 / 10 ) | 84 | | Branches: | 40% ( 4 / 10 ) | 85 | `; 86 | 87 | expect(report.toComment('Coverage Report', false).generateTable()).toBe(expectedString); 88 | }); 89 | 90 | it('appends footer if enabled', async () => { 91 | expect.hasAssertions(); 92 | 93 | const report: Report = new Report( 94 | { 95 | statements: new Metric({total: 10, covered: 1}), 96 | lines: new Metric({total: 10, covered: 2}), 97 | methods: new Metric({total: 0, covered: 0}), 98 | branches: new Metric({total: 10, covered: 4}), 99 | }, 100 | new Threshold(MetricType.Branches, 30, 5000), 101 | ); 102 | 103 | const expectedString = ` 104 | ## Coverage Report 105 | 106 | | Totals | ![Coverage](https://img.shields.io/static/v1?label=coverage&message=40%&color=yellow) | 107 | | :-- | :-- | 108 | | Statements: | 10% ( 1 / 10 ) | 109 | | Lines: | 20% ( 2 / 10 ) | 110 | | Branches: | 40% ( 4 / 10 ) | 111 | ${Comment.generateFooter()}`; 112 | 113 | expect(report.toComment('Coverage Report', true).generateTable()).toBe(expectedString); 114 | }); 115 | }); 116 | -------------------------------------------------------------------------------- /tests/types/CoverageSummary.test.ts: -------------------------------------------------------------------------------- 1 | import Bips from '../../src/types/Bips'; 2 | import CoverageSummary from '../../src/types/CoverageSummary'; 3 | import Integer from '../../src/types/Integer'; 4 | import MetricLevel from '../../src/types/MetricLevel'; 5 | import MetricType from '../../src/types/MetricType'; 6 | import Threshold from '../../src/types/Threshold'; 7 | 8 | describe(`${CoverageSummary.name}`, () => { 9 | const coverage = new CoverageSummary({ 10 | lines: {total: 34, covered: 32}, 11 | statements: {total: 66, covered: 45}, 12 | methods: {total: 0, covered: 0}, 13 | branches: {total: 20, covered: 11}, 14 | }); 15 | 16 | it.each([ 17 | { 18 | threshold: {metric: MetricType.Branches, alert: 6000, warning: 8000}, 19 | expectedResult: { 20 | metric: MetricType.Branches, 21 | total: 20, 22 | covered: 11, 23 | rate: 5500, 24 | level: MetricLevel.Red, 25 | }, 26 | }, 27 | { 28 | threshold: {metric: MetricType.Lines, alert: 1, warning: 8000}, 29 | expectedResult: { 30 | metric: MetricType.Lines, 31 | total: 34, 32 | covered: 32, 33 | rate: 9412, 34 | level: MetricLevel.Green, 35 | }, 36 | }, 37 | { 38 | threshold: {metric: MetricType.Statements, alert: 0, warning: 7000}, 39 | expectedResult: { 40 | metric: MetricType.Statements, 41 | total: 66, 42 | covered: 45, 43 | rate: 6818, 44 | level: MetricLevel.Yellow, 45 | }, 46 | }, 47 | { 48 | threshold: {metric: MetricType.Methods, alert: 0, warning: 5000}, 49 | expectedResult: { 50 | metric: MetricType.Methods, 51 | total: 0, 52 | covered: 0, 53 | rate: 0, 54 | level: MetricLevel.Yellow, 55 | }, 56 | }, 57 | ] as { 58 | threshold: {metric: MetricType; alert: Bips; warning: Bips}; 59 | expectedResult: {total: Integer; covered: Integer; rate: Bips; level: MetricLevel; metric: MetricType}; 60 | }[])('parses clover xml: $threshold', async ({threshold: {metric, alert, warning}, expectedResult}) => { 61 | expect.hasAssertions(); 62 | expect({...coverage.report(new Threshold(metric, alert, warning)).result}).toStrictEqual(expectedResult); 63 | }); 64 | }); 65 | -------------------------------------------------------------------------------- /tests/types/Filesystem.test.ts: -------------------------------------------------------------------------------- 1 | import CoverageSummary from '../../src/types/CoverageSummary'; 2 | import FileSystem from '../../src/types/FileSystem'; 3 | import Format from '../../src/types/Format'; 4 | import path from 'path'; 5 | 6 | describe(`${FileSystem.name}`, () => { 7 | const coverageFiles = [ 8 | { 9 | format: Format.Clover, 10 | filename: 'clover/clover.xml', 11 | expectedCoverage: { 12 | lines: {total: 34, covered: 24}, 13 | statements: {total: 66, covered: 45}, 14 | methods: {total: 12, covered: 10}, 15 | branches: {total: 20, covered: 11}, 16 | }, 17 | }, 18 | { 19 | format: Format.Auto, 20 | filename: 'clover/clover_no_branches.xml', 21 | expectedCoverage: { 22 | lines: {total: 10, covered: 9}, 23 | statements: {total: 12, covered: 11}, 24 | methods: {total: 4, covered: 3}, 25 | branches: {total: 0, covered: 0}, 26 | }, 27 | }, 28 | { 29 | format: Format.JsonSummary, 30 | filename: 'json-summary/coverage-summary.json', 31 | expectedCoverage: { 32 | lines: {total: 90, covered: 78}, 33 | statements: {total: 91, covered: 78}, 34 | methods: {total: 27, covered: 18}, 35 | branches: {total: 57, covered: 53}, 36 | }, 37 | }, 38 | { 39 | format: Format.Auto, 40 | filename: 'json-summary/coverage-summary.json', 41 | expectedCoverage: { 42 | lines: {total: 90, covered: 78}, 43 | statements: {total: 91, covered: 78}, 44 | methods: {total: 27, covered: 18}, 45 | branches: {total: 57, covered: 53}, 46 | }, 47 | }, 48 | ]; 49 | 50 | const fs = new FileSystem(path.join(__dirname, '../stubs')); 51 | 52 | it.each(coverageFiles)('parses coverage: $filename ($format)', async ({format, filename, expectedCoverage}) => { 53 | expect.hasAssertions(); 54 | const coverage = await fs.parseFile(filename, format); 55 | expect(coverage).toStrictEqual(new CoverageSummary(expectedCoverage)); 56 | }); 57 | 58 | it('fails on invalid file', async () => { 59 | expect.hasAssertions(); 60 | await expect(fs.parseFile('unknown.xml', Format.Auto)).rejects.toThrow('no such file or directory'); 61 | }); 62 | 63 | it('fails on invalid format', async () => { 64 | expect.hasAssertions(); 65 | await expect(fs.parseFile('json-summary/coverage-summary.json', 'foo')).rejects.toThrow( 66 | `Invalid option "coverage_format" - supported ${Object.values(Format).join(', ')}`, 67 | ); 68 | }); 69 | 70 | it('fails on format guessing failure', async () => { 71 | expect.hasAssertions(); 72 | await expect(fs.parseFile('coverage.png', Format.Auto)).rejects.toThrow('Cannot guess format of "coverage.png"'); 73 | }); 74 | }); 75 | -------------------------------------------------------------------------------- /tests/types/GitHubAdapter.test.ts: -------------------------------------------------------------------------------- 1 | import Configuration from '../../src/types/Configuration'; 2 | import GitHub from '../../src/types/github/GitHub'; 3 | import GitHubAdapter from '../../src/types/github/GitHubAdapter'; 4 | 5 | describe(`${GitHubAdapter.name}`, () => { 6 | const defaultInput = { 7 | threshold_alert: 50, 8 | threshold_warning: 90, 9 | threshold_metric: 'lines', 10 | check: true, 11 | status_context: 'Coverage Report', 12 | comment: true, 13 | comment_context: 'Coverage Report', 14 | comment_mode: 'replace', 15 | }; 16 | 17 | const defaultOutput = { 18 | workingDir: process.cwd(), 19 | coverageFormat: 'auto', 20 | threshold: { 21 | alert: 5000, 22 | warning: 9000, 23 | metric: 'lines', 24 | }, 25 | comment: { 26 | context: 'Coverage Report', 27 | mode: 'replace', 28 | footer: true, 29 | }, 30 | check: { 31 | context: 'Coverage Report', 32 | }, 33 | }; 34 | 35 | const core = (input: Record = {}): GitHub => ({ 36 | isDebug(): boolean { 37 | return true; 38 | }, 39 | debug(message: string): void { 40 | console.debug(message); 41 | }, 42 | getInput(name: string, {required}: {required?: boolean} = {}): string { 43 | const value = input[name]; 44 | 45 | if (required && value === undefined) { 46 | throw new Error(`Missing options ${name}`); 47 | } 48 | 49 | return value; 50 | }, 51 | }); 52 | 53 | it.each([ 54 | { 55 | scenario: 'minimum set', 56 | input: {github_token: '***', coverage_path: 'clover.xml'}, 57 | expected: {...defaultOutput, githubToken: '***', coveragePath: 'clover.xml'}, 58 | }, 59 | { 60 | scenario: 'defaults', 61 | input: {...defaultInput, github_token: '***', coverage_path: 'clover.xml'}, 62 | expected: {...defaultOutput, githubToken: '***', coveragePath: 'clover.xml'}, 63 | }, 64 | { 65 | scenario: 'neither check nor comment', 66 | input: { 67 | ...defaultInput, 68 | github_token: '***', 69 | coverage_path: 'clover.xml', 70 | check: false, 71 | comment: false, 72 | }, 73 | expected: { 74 | ...defaultOutput, 75 | githubToken: '***', 76 | coveragePath: 'clover.xml', 77 | check: undefined, 78 | comment: undefined, 79 | }, 80 | }, 81 | { 82 | scenario: 'specific threshold values', 83 | input: { 84 | ...defaultInput, 85 | github_token: '***', 86 | coverage_path: 'clover.xml', 87 | threshold_alert: 10, 88 | threshold_warning: 20, 89 | }, 90 | expected: { 91 | ...defaultOutput, 92 | githubToken: '***', 93 | coveragePath: 'clover.xml', 94 | threshold: { 95 | alert: 1000, 96 | warning: 2000, 97 | metric: 'lines', 98 | }, 99 | }, 100 | }, 101 | { 102 | scenario: 'specific threshold metric', 103 | input: { 104 | ...defaultInput, 105 | github_token: '***', 106 | coverage_path: 'clover.xml', 107 | threshold_metric: 'branches', 108 | }, 109 | expected: { 110 | ...defaultOutput, 111 | githubToken: '***', 112 | coveragePath: 'clover.xml', 113 | threshold: { 114 | alert: 5000, 115 | warning: 9000, 116 | metric: 'branches', 117 | }, 118 | }, 119 | }, 120 | { 121 | scenario: 'default metric when not set', 122 | input: { 123 | ...defaultInput, 124 | github_token: '***', 125 | coverage_path: 'clover.xml', 126 | threshold_metric: undefined, 127 | }, 128 | expected: { 129 | ...defaultOutput, 130 | githubToken: '***', 131 | coveragePath: 'clover.xml', 132 | threshold: { 133 | alert: 5000, 134 | warning: 9000, 135 | metric: 'lines', 136 | }, 137 | }, 138 | }, 139 | { 140 | scenario: 'working dir', 141 | input: { 142 | ...defaultInput, 143 | github_token: '***', 144 | coverage_path: 'clover.xml', 145 | working_dir: 'foo', 146 | }, 147 | expected: { 148 | ...defaultOutput, 149 | githubToken: '***', 150 | coveragePath: 'clover.xml', 151 | workingDir: 'foo', 152 | }, 153 | }, 154 | { 155 | scenario: 'values required coercing', 156 | input: { 157 | ...defaultInput, 158 | github_token: '***', 159 | coverage_path: 'clover.xml', 160 | check: 'true', 161 | comment: 'false', 162 | }, 163 | expected: { 164 | ...defaultOutput, 165 | githubToken: '***', 166 | coveragePath: 'clover.xml', 167 | comment: undefined, 168 | }, 169 | }, 170 | { 171 | scenario: 'values required coercing (on/off)', 172 | input: { 173 | ...defaultInput, 174 | github_token: '***', 175 | coverage_path: 'clover.xml', 176 | check: 'on', 177 | comment: 'off', 178 | }, 179 | expected: { 180 | ...defaultOutput, 181 | githubToken: '***', 182 | coveragePath: 'clover.xml', 183 | comment: undefined, 184 | }, 185 | }, 186 | { 187 | scenario: 'values required coercing (yes/no)', 188 | input: { 189 | ...defaultInput, 190 | github_token: '***', 191 | coverage_path: 'clover.xml', 192 | check: 'yes', 193 | comment: 'no', 194 | }, 195 | expected: { 196 | ...defaultOutput, 197 | githubToken: '***', 198 | coveragePath: 'clover.xml', 199 | comment: undefined, 200 | }, 201 | }, 202 | { 203 | scenario: 'specific comment', 204 | input: { 205 | ...defaultInput, 206 | github_token: '***', 207 | coverage_path: 'clover.xml', 208 | comment_context: 'Foobar', 209 | comment_mode: 'insert', 210 | }, 211 | expected: { 212 | ...defaultOutput, 213 | githubToken: '***', 214 | coveragePath: 'clover.xml', 215 | comment: { 216 | context: 'Foobar', 217 | mode: 'insert', 218 | footer: true, 219 | }, 220 | }, 221 | }, 222 | { 223 | scenario: 'default comment mode when not set', 224 | input: { 225 | ...defaultInput, 226 | github_token: '***', 227 | coverage_path: 'clover.xml', 228 | comment_mode: undefined, 229 | }, 230 | expected: { 231 | ...defaultOutput, 232 | githubToken: '***', 233 | coveragePath: 'clover.xml', 234 | comment: { 235 | context: 'Coverage Report', 236 | mode: 'replace', 237 | footer: true, 238 | }, 239 | }, 240 | }, 241 | { 242 | scenario: 'comment footer disabled ', 243 | input: {github_token: '***', coverage_path: 'clover.xml', comment_footer: false}, 244 | expected: { 245 | ...defaultOutput, 246 | githubToken: '***', 247 | coveragePath: 'clover.xml', 248 | comment: { 249 | context: 'Coverage Report', 250 | mode: 'replace', 251 | footer: false, 252 | }, 253 | }, 254 | }, 255 | { 256 | scenario: 'deprecated clover file', 257 | input: {github_token: '***', clover_file: 'clover.xml'}, 258 | expected: {...defaultOutput, githubToken: '***', coveragePath: 'clover.xml'}, 259 | }, 260 | { 261 | scenario: 'coverage `auto` format', 262 | input: {github_token: '***', coverage_path: 'coverage-summary.json', coverage_format: 'auto'}, 263 | expected: { 264 | ...defaultOutput, 265 | githubToken: '***', 266 | coveragePath: 'coverage-summary.json', 267 | coverageFormat: 'auto', 268 | }, 269 | }, 270 | { 271 | scenario: 'coverage `json-summary` format', 272 | input: {github_token: '***', coverage_path: 'coverage-summary.json', coverage_format: 'json-summary'}, 273 | expected: { 274 | ...defaultOutput, 275 | githubToken: '***', 276 | coveragePath: 'coverage-summary.json', 277 | coverageFormat: 'json-summary', 278 | }, 279 | }, 280 | { 281 | scenario: 'coverage `clover` format', 282 | input: {github_token: '***', coverage_path: 'clover.xml', coverage_format: 'clover'}, 283 | expected: { 284 | ...defaultOutput, 285 | githubToken: '***', 286 | coveragePath: 'clover.xml', 287 | coverageFormat: 'clover', 288 | }, 289 | }, 290 | { 291 | scenario: 'no alerts', 292 | input: {github_token: '***', coverage_path: 'clover.xml', threshold_alert: 0}, 293 | expected: { 294 | ...defaultOutput, 295 | githubToken: '***', 296 | coveragePath: 'clover.xml', 297 | threshold: {...defaultOutput.threshold, alert: 0}, 298 | }, 299 | }, 300 | ] as { 301 | scenario: string; 302 | input: Record; 303 | expected: Configuration; 304 | }[])('loads config with $scenario', async ({scenario, input, expected}) => { 305 | expect.hasAssertions(); 306 | const github = new GitHubAdapter(core(input)); 307 | try { 308 | expect({...github.loadConfig()}).toStrictEqual(expected); 309 | } catch (e) { 310 | throw new Error(scenario); 311 | } 312 | }); 313 | 314 | it.each([ 315 | { 316 | error: 'The `clover_file` option is deprecated and cannot be set along with `coverage_path`', 317 | input: {github_token: '***', coverage_path: 'coverage-summary.json', clover_file: 'clover.xml'}, 318 | }, 319 | { 320 | error: 'Missing or invalid option `coverage_path`', 321 | input: {github_token: '***'}, 322 | }, 323 | { 324 | error: 'Invalid option "coverage_format" - supported auto, clover, json-summary', 325 | input: {github_token: '***', coverage_path: 'coverage-summary.json', coverage_format: 'foo'}, 326 | }, 327 | { 328 | error: 'Invalid option "threshold_metric" - supported lines, statements, branches, methods', 329 | input: {github_token: '***', coverage_path: 'clover.xml', threshold_metric: 'foo'}, 330 | }, 331 | { 332 | error: 'Invalid option "comment_mode" - supported replace, insert, update', 333 | input: {github_token: '***', coverage_path: 'clover.xml', comment_mode: 'foo'}, 334 | }, 335 | ] as { 336 | error: string; 337 | input: Record; 338 | }[])('fails on error: "$error"', async ({error, input}) => { 339 | expect.hasAssertions(); 340 | const github = new GitHubAdapter(core(input)); 341 | expect(() => github.loadConfig()).toThrow(error); 342 | }); 343 | 344 | it.each([ 345 | {scenario: 'not a pull request event', request: {payload: {}}, expected: undefined}, 346 | { 347 | scenario: 'not a pull request event (explicit)', 348 | request: {payload: {pull_request: undefined}}, 349 | expected: undefined, 350 | }, 351 | { 352 | scenario: 'pull request event', 353 | request: {payload: {pull_request: {number: 1234, html_url: 'https://example.com', head: {sha: 'foo'}}}}, 354 | expected: {number: 1234, url: 'https://example.com', sha: 'foo'}, 355 | }, 356 | ] as { 357 | scenario: string; 358 | request: {}; 359 | expected: {}; 360 | }[])('parses webhook request on $scenario', async ({scenario, request, expected}) => { 361 | expect.hasAssertions(); 362 | const github = new GitHubAdapter(core()); 363 | try { 364 | expect(github.parseWebhook(request)).toStrictEqual(expected); 365 | } catch (e) { 366 | throw new Error(scenario); 367 | } 368 | }); 369 | 370 | it.each([ 371 | {scenario: 'undefined request', request: undefined, error: 'Invalid github event'}, 372 | {scenario: 'empty request', request: {}, error: 'Invalid github event'}, 373 | {scenario: 'missing payload', request: {payload: undefined}, error: 'Invalid github event'}, 374 | { 375 | scenario: 'invalid pull request', 376 | request: {payload: {pull_request: {}}}, 377 | error: 'Invalid pull_request event', 378 | }, 379 | { 380 | scenario: 'missing number', 381 | request: {payload: {pull_request: {html_url: 'https://example.com', head: {sha: 'foo'}}}}, 382 | error: 'Invalid pull_request event', 383 | }, 384 | { 385 | scenario: 'missing pull request URL', 386 | request: {payload: {pull_request: {number: 1234, head: {sha: 'foo'}}}}, 387 | error: 'Invalid pull_request event', 388 | }, 389 | { 390 | scenario: 'missing head info', 391 | request: {payload: {pull_request: {number: 1234, html_url: 'https://example.com'}}}, 392 | error: 'Invalid pull_request event', 393 | }, 394 | { 395 | scenario: 'invalid head sha', 396 | request: {payload: {pull_request: {number: 1234, html_url: 'https://example.com', head: {}}}}, 397 | error: 'Invalid pull_request event', 398 | }, 399 | ] as { 400 | scenario: string; 401 | request: {}; 402 | error: string; 403 | }[])('fails on parse webhook request on $scenario', async ({scenario, request, error}) => { 404 | expect.hasAssertions(); 405 | const github = new GitHubAdapter(core()); 406 | try { 407 | expect(() => github.parseWebhook(request)).toThrow(new Error(error)); 408 | } catch (e) { 409 | throw new Error(scenario); 410 | } 411 | }); 412 | }); 413 | -------------------------------------------------------------------------------- /tests/types/Metric.test.ts: -------------------------------------------------------------------------------- 1 | import Bips from '../../src/types/Bips'; 2 | import Integer from '../../src/types/Integer'; 3 | import Metric from '../../src/types/Metric'; 4 | import MetricLevel from '../../src/types/MetricLevel'; 5 | import MetricType from '../../src/types/MetricType'; 6 | import Threshold from '../../src/types/Threshold'; 7 | 8 | describe(`${Metric.name}`, () => { 9 | const defaultThreshold: {alert: Bips; warning: Bips} = {alert: 5000, warning: 9000}; 10 | const defaultTotal = 100; 11 | 12 | it.each([ 13 | {covered: 49, threshold: defaultThreshold, expectedRate: 4900, expectedLevel: MetricLevel.Red}, 14 | {covered: 50, threshold: defaultThreshold, expectedRate: 5000, expectedLevel: MetricLevel.Yellow}, 15 | {covered: 51, threshold: defaultThreshold, expectedRate: 5100, expectedLevel: MetricLevel.Yellow}, 16 | {covered: 89, threshold: defaultThreshold, expectedRate: 8900, expectedLevel: MetricLevel.Yellow}, 17 | {covered: 90, threshold: defaultThreshold, expectedRate: 9000, expectedLevel: MetricLevel.Green}, 18 | {covered: 91, threshold: defaultThreshold, expectedRate: 9100, expectedLevel: MetricLevel.Green}, 19 | {covered: 100, threshold: defaultThreshold, expectedRate: 10000, expectedLevel: MetricLevel.Green}, 20 | {covered: 95, threshold: {alert: 0, warning: 9000}, expectedRate: 9500, expectedLevel: MetricLevel.Green}, 21 | ] as { 22 | covered: Integer; 23 | threshold: {alert: Bips; warning: Bips}; 24 | expectedRate: Bips; 25 | expectedLevel: MetricLevel; 26 | }[])( 27 | 'calculates the coverage rate of $covered from 100 is $expectedRate, in relation to $threshold the level is $expectedLevel', 28 | async ({covered, threshold: {alert, warning}, expectedRate, expectedLevel}) => { 29 | expect.hasAssertions(); 30 | const metric = new Metric({total: defaultTotal, covered}); 31 | expect(metric.rate).toBe(expectedRate); 32 | expect(metric.report(new Threshold(MetricType.Branches, alert, warning)).level).toBe(expectedLevel); 33 | }, 34 | ); 35 | 36 | it('calculates the coverage rate even there is no total', async () => { 37 | expect.hasAssertions(); 38 | const metric = new Metric({total: 0, covered: 0}); 39 | expect(metric.rate).toBe(0); 40 | expect(metric.report(new Threshold(MetricType.Branches, 0, 50)).level).toBe(MetricLevel.Yellow); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /tests/types/Report.test.ts: -------------------------------------------------------------------------------- 1 | import Metric from '../../src/types/Metric'; 2 | import MetricLevel from '../../src/types/MetricLevel'; 3 | import MetricType from '../../src/types/MetricType'; 4 | import Report from '../../src/types/Report'; 5 | import StatusState from '../../src/types/StatusState'; 6 | import Threshold from '../../src/types/Threshold'; 7 | 8 | describe(`${Report.name}`, () => { 9 | const metrics = { 10 | statements: new Metric({total: 10, covered: 6}), 11 | lines: new Metric({total: 10, covered: 2}), 12 | methods: new Metric({total: 0, covered: 0}), 13 | branches: new Metric({total: 10, covered: 4}), 14 | }; 15 | 16 | it.each([ 17 | { 18 | threshold: new Threshold(MetricType.Branches, 3000, 5000), 19 | expectedResult: { 20 | total: 10, 21 | covered: 4, 22 | rate: 4000, 23 | level: MetricLevel.Yellow, 24 | metric: MetricType.Branches, 25 | }, 26 | }, 27 | { 28 | threshold: new Threshold(MetricType.Methods, 3000, 5000), 29 | expectedResult: { 30 | total: 0, 31 | covered: 0, 32 | rate: 0, 33 | level: MetricLevel.Red, 34 | metric: MetricType.Methods, 35 | }, 36 | }, 37 | { 38 | threshold: new Threshold(MetricType.Lines, 3000, 5000), 39 | expectedResult: { 40 | total: 10, 41 | covered: 2, 42 | rate: 2000, 43 | level: MetricLevel.Red, 44 | metric: MetricType.Lines, 45 | }, 46 | }, 47 | { 48 | threshold: new Threshold(MetricType.Statements, 3000, 5000), 49 | expectedResult: { 50 | total: 10, 51 | covered: 6, 52 | rate: 6000, 53 | level: MetricLevel.Green, 54 | metric: MetricType.Statements, 55 | }, 56 | }, 57 | ])( 58 | 'calculates the coverage report by $threshold and results to $expectedResult', 59 | async ({threshold, expectedResult}) => { 60 | expect.hasAssertions(); 61 | const report: Report = new Report(metrics, threshold); 62 | expect(report.result).toStrictEqual(expectedResult); 63 | }, 64 | ); 65 | 66 | it('provides report comment', async () => { 67 | expect.hasAssertions(); 68 | const report: Report = new Report(metrics, new Threshold(MetricType.Branches, 3000, 5000)); 69 | const comment = report.toComment('Comment context', false); 70 | expect(comment.context).toBe('Comment context'); 71 | expect(comment.result).toStrictEqual({ 72 | total: 10, 73 | covered: 4, 74 | rate: 4000, 75 | level: MetricLevel.Yellow, 76 | metric: MetricType.Branches, 77 | }); 78 | }); 79 | 80 | it('provides report status', async () => { 81 | expect.hasAssertions(); 82 | const report: Report = new Report(metrics, new Threshold(MetricType.Branches, 3000, 5000)); 83 | const status = report.toStatus('Status context', 'https://example.com'); 84 | expect(status.context).toBe('Status context'); 85 | expect(status.target_url).toBe('https://example.com'); 86 | expect(status.state).toBe(StatusState.Success); 87 | expect(status.description).toBe('Warning: low branches coverage - 40%'); 88 | }); 89 | }); 90 | -------------------------------------------------------------------------------- /tests/types/Status.test.ts: -------------------------------------------------------------------------------- 1 | import MetricLevel from '../../src/types/MetricLevel'; 2 | import MetricType from '../../src/types/MetricType'; 3 | import ReportResult from '../../src/types/ReportResult'; 4 | import Status from '../../src/types/Status'; 5 | import StatusState from '../../src/types/StatusState'; 6 | import Threshold from '../../src/types/Threshold'; 7 | 8 | describe(`${Status.name}`, () => { 9 | it.each([ 10 | { 11 | metric: {metric: MetricType.Lines, rate: 5000, level: MetricLevel.Red}, 12 | expectedState: StatusState.Failure, 13 | expectedDescription: 'Error: Too low lines coverage - 50%', 14 | }, 15 | { 16 | metric: {metric: MetricType.Statements, rate: 5000, level: MetricLevel.Yellow}, 17 | expectedState: StatusState.Success, 18 | expectedDescription: 'Warning: low statements coverage - 50%', 19 | }, 20 | { 21 | metric: {metric: MetricType.Branches, rate: 5000, level: MetricLevel.Green}, 22 | expectedState: StatusState.Success, 23 | expectedDescription: 'Success: branches coverage - 50%', 24 | }, 25 | ] as { 26 | threshold: Threshold; 27 | metric: ReportResult; 28 | expectedState: StatusState; 29 | expectedDescription: string; 30 | }[])('generates status "$expectedDescription"', async ({metric, expectedState, expectedDescription}) => { 31 | expect.hasAssertions(); 32 | const targetUrl = 'https://example.com'; 33 | const statusContext = 'coverage'; 34 | 35 | expect({...new Status(metric, statusContext, targetUrl)}).toStrictEqual({ 36 | state: expectedState, 37 | description: expectedDescription, 38 | target_url: targetUrl, 39 | context: statusContext, 40 | }); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /tests/types/Threshold.test.ts: -------------------------------------------------------------------------------- 1 | import Bips from '../../src/types/Bips'; 2 | import MetricLevel from '../../src/types/MetricLevel'; 3 | import MetricType from '../../src/types/MetricType'; 4 | import Threshold from '../../src/types/Threshold'; 5 | 6 | describe(`${Threshold.name}`, () => { 7 | const defaultThreshold: {alert: Bips; warning: Bips} = {alert: 5000, warning: 9000}; 8 | 9 | it.each([ 10 | {rate: 4900, threshold: defaultThreshold, expectedLevel: MetricLevel.Red}, 11 | {rate: 5000, threshold: defaultThreshold, expectedLevel: MetricLevel.Yellow}, 12 | {rate: 5100, threshold: defaultThreshold, expectedLevel: MetricLevel.Yellow}, 13 | {rate: 8900, threshold: defaultThreshold, expectedLevel: MetricLevel.Yellow}, 14 | {rate: 9000, threshold: defaultThreshold, expectedLevel: MetricLevel.Green}, 15 | {rate: 9100, threshold: defaultThreshold, expectedLevel: MetricLevel.Green}, 16 | {rate: 10000, threshold: defaultThreshold, expectedLevel: MetricLevel.Green}, 17 | {rate: 9500, threshold: {...defaultThreshold, alert: 0}, expectedLevel: MetricLevel.Green}, 18 | ] as { 19 | rate: Bips; 20 | threshold: {alert: Bips; warning: Bips}; 21 | expectedLevel: MetricLevel; 22 | }[])( 23 | 'calculates level $rate with $threshold is $level', 24 | async ({rate, threshold: {alert, warning}, expectedLevel}) => { 25 | expect.hasAssertions(); 26 | expect(new Threshold(MetricType.Branches, alert, warning).calc(rate)).toBe(expectedLevel); 27 | }, 28 | ); 29 | }); 30 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. 4 | "target": "es6", 5 | // Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. 6 | "module": "commonjs", 7 | // Redirect output structure to the directory. 8 | "outDir": "./lib", 9 | // Specify the root directory of input files. Use to control the output directory structure with --outDir. 10 | "rootDir": "./src", 11 | // Enable all strict type-checking options. 12 | "strict": true, 13 | // Raise error on expressions and declarations with an implied 'any' type. 14 | "noImplicitAny": true, 15 | // Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. 16 | // Implies 'allowSyntheticDefaultImports'. 17 | "esModuleInterop": true 18 | }, 19 | "exclude": [ 20 | "node_modules", 21 | "**/*.test.ts" 22 | ] 23 | } 24 | --------------------------------------------------------------------------------