├── .github
├── FUNDING.yml
└── workflows
│ └── ci.yml
├── .gitignore
├── .husky
└── pre-commit
├── LICENSE
├── README.md
├── action.yml
├── bin
└── cli
├── dist
└── action.js
├── package.json
├── renovate.json
├── src
├── action.ts
├── badges.ts
├── create.ts
└── index.ts
├── test
├── index.test.ts
└── sample-logo.svg
└── tsconfig.json
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | ko_fi: jaywcjlove
2 | buy_me_a_coffee: jaywcjlove
3 | custom: ["https://www.paypal.me/kennyiseeyou", "https://jaywcjlove.github.io/#/sponsor"]
4 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push:
4 | branches:
5 | - main
6 |
7 | env:
8 | CI: false
9 |
10 | jobs:
11 | build-deploy:
12 | runs-on: ubuntu-latest
13 | permissions:
14 | contents: write
15 | id-token: write
16 | steps:
17 | - uses: actions/checkout@v4
18 | - uses: actions/setup-node@v4
19 | with:
20 | node-version: 20
21 | registry-url: 'https://registry.npmjs.org'
22 |
23 | - run: npm install
24 | - run: npm run build
25 | - run: npm run coverage
26 | - run: npm run make-badges
27 | - run: pwd
28 | - run: ls -al
29 | - run: ls -al coverage
30 |
31 |
32 | - name: Create idoc config
33 | run: |
34 | cat > idoc.yml << EOF
35 | site: "Coverage Badges {{version}}"
36 | menus:
37 | Home: index.html
38 | footer: |
39 | Sponsor •
40 | Create Tag •
41 | Contributors •
42 | Read File Content •
43 | Generated Badges
44 |
45 | Released under the MIT License. Copyright © {{idocYear}} Kenny Wong
46 | Generated by idoc v{{idocVersion}}
47 |
48 | EOF
49 |
50 | - run: npm install idoc@1 -g
51 | - run: idoc
52 | - run: cp -rp coverage/lcov-report dist
53 |
54 | - run: cat coverage/coverage-summary.json
55 |
56 | - name: Create Coverage Badges
57 | uses: ./
58 | # uses: jaywcjlove/coverage-badges-cli@main
59 | with:
60 | style: flat
61 | label: flat style
62 | source: coverage/coverage-summary.json
63 | output: dist/badges-flat.svg
64 |
65 | - name: Create Coverage Badges
66 | uses: jaywcjlove/coverage-badges-cli@main
67 | id: coverage_badges
68 | with:
69 | label: classic style
70 | source: coverage/coverage-summary.json
71 | output: dist/badges-classic.svg
72 |
73 | - name: Create Defalut Coverage Badges
74 | uses: jaywcjlove/coverage-badges-cli@main
75 | with:
76 | source: coverage/coverage-summary.json
77 | output: dist/badges.svg
78 |
79 | - name: Generate Contributors Images
80 | uses: jaywcjlove/github-action-contributors@main
81 | with:
82 | filter-author: (renovate\[bot\]|renovate-bot|dependabot\[bot\])
83 | output: dist/CONTRIBUTORS.svg
84 | avatarSize: 42
85 |
86 | - run: echo '${{ steps.coverage_badges.outputs.svg }}'
87 |
88 | # - run: npm i markdown-to-html-cli -g
89 | # - run: markdown-to-html --output coverage/index.html --github-corners https://github.com/jaywcjlove/coverage-badges-cli
90 |
91 | - name: Create Tag
92 | id: create_tag
93 | uses: jaywcjlove/create-tag-action@main
94 | with:
95 | package-path: ./package.json
96 |
97 | - name: get tag version
98 | id: tag_version
99 | uses: jaywcjlove/changelog-generator@main
100 |
101 | - name: Deploy
102 | uses: peaceiris/actions-gh-pages@v4
103 | if: github.ref == 'refs/heads/main'
104 | with:
105 | commit_message: ${{steps.tag_version.outputs.tag}} ${{ github.event.head_commit.message }}
106 | github_token: ${{ secrets.GITHUB_TOKEN }}
107 | publish_dir: ./dist
108 |
109 | - name: Generate Changelog
110 | id: changelog
111 | uses: jaywcjlove/changelog-generator@main
112 | with:
113 | token: ${{ secrets.GITHUB_TOKEN }}
114 | head-ref: ${{steps.create_tag.outputs.version}}
115 | filter-author: (小弟调调™|Renovate Bot)
116 | filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
117 |
118 | - name: Create Release
119 | uses: ncipollo/release-action@v1
120 | if: steps.create_tag.outputs.successful
121 | with:
122 | allowUpdates: true
123 | name: ${{ steps.create_tag.outputs.version }}
124 | tag: ${{ steps.create_tag.outputs.version }}
125 | token: ${{ secrets.GITHUB_TOKEN }}
126 | body: |
127 | [](https://jaywcjlove.github.io/#/sponsor) [](https://uiwjs.github.io/npm-unpkg/#/pkg/coverage-badges-cli@${{steps.changelog.outputs.version}}/file/README.md)
128 |
129 | Documentation ${{ steps.changelog.outputs.tag }}: https://raw.githack.com/jaywcjlove/coverage-badges-cli/${{ steps.changelog.outputs.gh-pages-short-hash }}/index.html
130 | Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
131 |
132 | ${{ steps.changelog.outputs.changelog }}
133 |
134 | - name: package.json info
135 | uses: jaywcjlove/github-action-package@main
136 | with:
137 | path: package.json
138 | unset: scripts,jest,lint-staged,devDependencies
139 |
140 | # - run: npm install @jsdevtools/npm-publish -g
141 | # - run: npm-publish --token="${{ secrets.NPM_TOKEN }}" ./package.json
142 | - run: npm publish --access public --provenance
143 | name: 📦 coverage-badges-cli publish to NPM
144 | continue-on-error: true
145 | env:
146 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io/api/node
2 | # Edit at https://www.gitignore.io/?templates=node
3 |
4 | esm
5 | cjs
6 | lib
7 | package-lock.json
8 | __snapshots__
9 |
10 | ### Node ###
11 | # Logs
12 | logs
13 | *.log
14 | npm-debug.log*
15 | yarn-debug.log*
16 | yarn-error.log*
17 | lerna-debug.log*
18 |
19 | # Diagnostic reports (https://nodejs.org/api/report.html)
20 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
21 |
22 | # Runtime data
23 | pids
24 | *.pid
25 | *.seed
26 | *.pid.lock
27 |
28 | # Directory for instrumented libs generated by jscoverage/JSCover
29 | lib-cov
30 |
31 | # Coverage directory used by tools like istanbul
32 | coverage
33 |
34 | # nyc test coverage
35 | .nyc_output
36 |
37 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
38 | .grunt
39 |
40 | # Bower dependency directory (https://bower.io/)
41 | bower_components
42 |
43 | # node-waf configuration
44 | .lock-wscript
45 |
46 | # Compiled binary addons (https://nodejs.org/api/addons.html)
47 | build/Release
48 |
49 | # Dependency directories
50 | node_modules/
51 | jspm_packages/
52 |
53 | # TypeScript v1 declaration files
54 | typings/
55 |
56 | # Optional npm cache directory
57 | .npm
58 |
59 | # Optional eslint cache
60 | .eslintcache
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # next.js build output
79 | .next
80 |
81 | # nuxt.js build output
82 | .nuxt
83 |
84 | # vuepress build output
85 | .vuepress/dist
86 |
87 | # Serverless directories
88 | .serverless/
89 |
90 | # FuseBox cache
91 | .fusebox/
92 |
93 | # DynamoDB Local files
94 | .dynamodb/
95 |
96 | # End of https://www.gitignore.io/api/node
97 |
98 | .DS_Store
99 | .cache
100 | .vscode
101 | .idea
102 | .env
103 |
104 | *.bak
105 | *.tem
106 | *.temp
107 | #.swp
108 | *.*~
109 | ~*.*
110 |
111 | # IDEA
112 | *.iml
113 | *.ipr
114 | *.iws
115 | .idea/
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | npx --no lint-staged
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 小弟调调
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-badges-cli
2 | ===
3 |
4 |
5 | [](https://jaywcjlove.github.io/#/sponsor)
6 | [](https://github.com/jaywcjlove/coverage-badges-cli/actions/workflows/ci.yml)
7 | [](https://jaywcjlove.github.io/coverage-badges-cli/lcov-report/)
8 | [](https://www.npmjs.com/package/coverage-badges-cli)
9 | [](https://www.npmjs.com/package/coverage-badges-cli/)
10 |
11 | Create coverage badges from coverage reports. Using GitHub Actions and GitHub Workflow CPU time (no 3rd parties servers).
12 |
13 | Don't worry about the [coverage.io](https://coveralls.io/) service is down.
14 |
15 | ## Install
16 |
17 | ```shell
18 | $ npm i coverage-badges-cli
19 | ```
20 |
21 | ## Example
22 |
23 | ```js
24 | {
25 | "scripts": {
26 | "coverage": "jest --coverage"
27 | "make-badges": "coverage-badges",
28 | },
29 | "jest": {
30 | "collectCoverageFrom": [
31 | "/packages/**/*.{tsx,ts}",
32 | "!**/*.{js,d.ts}"
33 | ],
34 | "coverageReporters": [
35 | "lcov",
36 | "json-summary"
37 | ],
38 | }
39 | }
40 | ```
41 |
42 | This config creates a coverage badge in a default directory ./badges.
43 |
44 | You can add `` to your README.md after the badge creation.
45 |
46 | ## Github Actions
47 |
48 | ### Input Parameters
49 |
50 | 
51 | 
52 |
53 | - `source` - The path of the target file "coverage-summary.json".
54 | - `output` - Output image path.
55 | - `label` - The left label of the badge, usually static (default `coverage`).
56 | - `labelColor` - \ or \ (default: `555`).
57 | - `color` - \ or \ (default: '')
58 | - `scale` - Set badge scale (default: `1`).
59 | - `style` - Badges style: `flat`, `classic` (default `classic`).
60 | - ~~`type`~~ - (No longer supported after v1.2.0) Coverage report type: `lines`, `statements`, `functions`, `branches` (default `statements`)
61 | - `jsonPath` - Path to the coverage percentage number to be used in the badge (default `total.statements.pct`)
62 | - `icon` - Path to icon file
63 |
64 | ```yml
65 | - name: Create Coverage Badges
66 | uses: jaywcjlove/coverage-badges-cli@main
67 | with:
68 | style: flat
69 | source: coverage/coverage-summary.json
70 | output: coverage/badges.svg
71 | jsonPath: totals.percent_covered
72 |
73 | - name: Deploy
74 | uses: peaceiris/actions-gh-pages@v3
75 | with:
76 | github_token: ${{ secrets.GITHUB_TOKEN }}
77 | publish_dir: ./build
78 | ```
79 |
80 | ### Output Parameters
81 |
82 | svg svg image string: `