Skip to content

Commit 3260079

Browse files
fix: provide README badges via addons (#2037)
## PR Checklist - [x] Addresses an existing open issue: fixes #2036 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Caught a couple of discrepancies in how the README.md badges are printed. Nice. 🎁
1 parent 67c8855 commit 3260079

11 files changed

+360
-205
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<!-- prettier-ignore-end -->
1414
<a href="https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="🤝 Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
1515
<a href="https://codecov.io/gh/JoshuaKGoldberg/create-typescript-app" target="_blank"><img alt="🧪 Coverage" src="https://img.shields.io/codecov/c/github/JoshuaKGoldberg/create-typescript-app?label=%F0%9F%A7%AA%20coverage" /></a>
16-
<a href="https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/LICENSE.md" target="_blank"><img alt="📝 License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg"></a>
17-
<a href="http://npmjs.com/package/create-typescript-app"><img alt="📦 npm version" src="https://img.shields.io/npm/v/create-typescript-app?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
16+
<a href="https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/LICENSE.md" target="_blank"><img alt="📝 License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg" /></a>
17+
<a href="http://npmjs.com/package/create-typescript-app" target="_blank"><img alt="📦 npm version" src="https://img.shields.io/npm/v/create-typescript-app?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
1818
<img alt="💪 TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
1919
</p>
2020

src/blocks/blockAllContributors.test.ts

+105-89
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ describe("blockAllContributors", () => {
2222
{
2323
"addons": {
2424
"badges": [
25-
"<!-- prettier-ignore-start -->
26-
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
27-
<a href="#contributors" target="_blank"><img alt="👪 All Contributors: undefined" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-undefined-21bb42.svg" /></a>
25+
{
26+
"alt": "👪 All Contributors: undefined",
27+
"comments": {
28+
"after": "
2829
<!-- ALL-CONTRIBUTORS-BADGE:END -->
2930
<!-- prettier-ignore-end -->",
31+
"before": "<!-- prettier-ignore-start -->
32+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
33+
",
34+
},
35+
"href": "#contributors",
36+
"src": "https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-undefined-21bb42.svg",
37+
},
3038
],
3139
"sections": undefined,
3240
},
@@ -110,96 +118,104 @@ describe("blockAllContributors", () => {
110118
});
111119

112120
expect(creation).toMatchInlineSnapshot(`
113-
{
114-
"addons": [
115-
{
116-
"addons": {
117-
"ignores": [
118-
"/.all-contributorsrc",
119-
],
120-
},
121-
"block": [Function],
122-
},
123-
{
124-
"addons": {
125-
"badges": [
126-
"<!-- prettier-ignore-start -->
127-
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
128-
<a href="#contributors" target="_blank"><img alt="👪 All Contributors: 1" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-1-21bb42.svg" /></a>
129-
<!-- ALL-CONTRIBUTORS-BADGE:END -->
130-
<!-- prettier-ignore-end -->",
131-
],
132-
"sections": [
133-
"## Contributors
121+
{
122+
"addons": [
123+
{
124+
"addons": {
125+
"ignores": [
126+
"/.all-contributorsrc",
127+
],
128+
},
129+
"block": [Function],
130+
},
131+
{
132+
"addons": {
133+
"badges": [
134+
{
135+
"alt": "👪 All Contributors: 1",
136+
"comments": {
137+
"after": "
138+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
139+
<!-- prettier-ignore-end -->",
140+
"before": "<!-- prettier-ignore-start -->
141+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
142+
",
143+
},
144+
"href": "#contributors",
145+
"src": "https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-1-21bb42.svg",
146+
},
147+
],
148+
"sections": [
149+
"## Contributors
134150
135-
<!-- spellchecker: disable -->
136-
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
137-
<!-- prettier-ignore-start -->
138-
<!-- markdownlint-disable -->
139-
<table>
140-
<tbody>
141-
<tr>
142-
<td align="center" valign="top" width="14.28%"><a href="http://www.joshuakgoldberg.com"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg"/><br /><sub><b>Josh Goldberg</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">🐛</a> <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/commits?author=JoshuaKGoldberg" title="Code">💻</a> <a href="#design-JoshuaKGoldberg" title="Design">🎨</a> <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/commits?author=JoshuaKGoldberg" title="Documentation">📖</a> <a href="#ideas-JoshuaKGoldberg" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">🚧</a> <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/pulls?q=is%3Apr+reviewed-by%3AJoshuaKGoldberg" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/commits?author=JoshuaKGoldberg" title="Tests">⚠️</a> <a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a></td>
143-
</tr>
144-
</tbody>
145-
</table>
151+
<!-- spellchecker: disable -->
152+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
153+
<!-- prettier-ignore-start -->
154+
<!-- markdownlint-disable -->
155+
<table>
156+
<tbody>
157+
<tr>
158+
<td align="center" valign="top" width="14.28%"><a href="http://www.joshuakgoldberg.com"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg"/><br /><sub><b>Josh Goldberg</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">🐛</a> <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/commits?author=JoshuaKGoldberg" title="Code">💻</a> <a href="#design-JoshuaKGoldberg" title="Design">🎨</a> <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/commits?author=JoshuaKGoldberg" title="Documentation">📖</a> <a href="#ideas-JoshuaKGoldberg" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">🚧</a> <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/pulls?q=is%3Apr+reviewed-by%3AJoshuaKGoldberg" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/commits?author=JoshuaKGoldberg" title="Tests">⚠️</a> <a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a></td>
159+
</tr>
160+
</tbody>
161+
</table>
146162
147-
<!-- markdownlint-restore -->
148-
<!-- prettier-ignore-end -->
163+
<!-- markdownlint-restore -->
164+
<!-- prettier-ignore-end -->
149165
150-
<!-- ALL-CONTRIBUTORS-LIST:END -->
151-
<!-- spellchecker: enable -->",
152-
],
153-
},
154-
"block": [Function],
155-
},
156-
{
157-
"addons": {
158-
"secrets": [
159-
{
160-
"description": "a GitHub PAT with repo and workflow permissions",
161-
"name": "ACCESS_TOKEN",
162-
},
163-
],
164-
},
165-
"block": [Function],
166-
},
167-
],
168-
"files": {
169-
".all-contributorsrc": "{"badgeTemplate":"\\t<a href=\\"#contributors\\" target=\\"_blank\\"><img alt=\\"👪 All Contributors: <%= contributors.length %>\\" src=\\"https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-<%= contributors.length %>-21bb42.svg\\" /></a>","contributors":[{"avatar_url":"https://avatars.githubusercontent.com/u/3335181?v=4","contributions":["bug","code","design","doc","ideas","infra","maintenance","review","test","tool"],"login":"JoshuaKGoldberg","name":"Josh Goldberg","profile":"http://www.joshuakgoldberg.com"}],"contributorsSortAlphabetically":true,"projectName":"test-repository","projectOwner":"test-owner"}",
170-
".github": {
171-
"workflows": {
172-
"contributors.yml": "jobs:
173-
contributors:
174-
runs-on: ubuntu-latest
175-
steps:
176-
- uses: actions/checkout@v4
177-
with:
178-
fetch-depth: 0
179-
- uses: ./.github/actions/prepare
180-
- env:
181-
GITHUB_TOKEN: \${{ secrets.ACCESS_TOKEN }}
182-
uses: JoshuaKGoldberg/[email protected]
166+
<!-- ALL-CONTRIBUTORS-LIST:END -->
167+
<!-- spellchecker: enable -->",
168+
],
169+
},
170+
"block": [Function],
171+
},
172+
{
173+
"addons": {
174+
"secrets": [
175+
{
176+
"description": "a GitHub PAT with repo and workflow permissions",
177+
"name": "ACCESS_TOKEN",
178+
},
179+
],
180+
},
181+
"block": [Function],
182+
},
183+
],
184+
"files": {
185+
".all-contributorsrc": "{"badgeTemplate":"\\t<a href=\\"#contributors\\" target=\\"_blank\\"><img alt=\\"👪 All Contributors: <%= contributors.length %>\\" src=\\"https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-<%= contributors.length %>-21bb42.svg\\" /></a>","contributors":[{"avatar_url":"https://avatars.githubusercontent.com/u/3335181?v=4","contributions":["bug","code","design","doc","ideas","infra","maintenance","review","test","tool"],"login":"JoshuaKGoldberg","name":"Josh Goldberg","profile":"http://www.joshuakgoldberg.com"}],"contributorsSortAlphabetically":true,"projectName":"test-repository","projectOwner":"test-owner"}",
186+
".github": {
187+
"workflows": {
188+
"contributors.yml": "jobs:
189+
contributors:
190+
runs-on: ubuntu-latest
191+
steps:
192+
- uses: actions/checkout@v4
193+
with:
194+
fetch-depth: 0
195+
- uses: ./.github/actions/prepare
196+
- env:
197+
GITHUB_TOKEN: \${{ secrets.ACCESS_TOKEN }}
198+
uses: JoshuaKGoldberg/[email protected]
183199
184-
name: Contributors
200+
name: Contributors
185201
186-
on:
187-
push:
188-
branches:
189-
- main
190-
",
191-
},
192-
},
193-
},
194-
"scripts": [
195-
{
196-
"commands": [
197-
"pnpx all-contributors-cli add test-owner code,content,doc,ideas,infra,maintenance,projectManagement,tool",
198-
],
199-
"phase": 3,
200-
},
201-
],
202-
}
203-
`);
202+
on:
203+
push:
204+
branches:
205+
- main
206+
",
207+
},
208+
},
209+
},
210+
"scripts": [
211+
{
212+
"commands": [
213+
"pnpx all-contributors-cli add test-owner code,content,doc,ideas,infra,maintenance,projectManagement,tool",
214+
],
215+
"phase": 3,
216+
},
217+
],
218+
}
219+
`);
204220
});
205221
});

src/blocks/blockAllContributors.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ export const blockAllContributors = base.createBlock({
2323
}),
2424
blockREADME({
2525
badges: [
26-
`<!-- prettier-ignore-start -->
27-
\t<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
28-
\t<a href="#contributors" target="_blank"><img alt="👪 All Contributors: ${contributions}" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-${contributions}-21bb42.svg" /></a>
26+
{
27+
alt: `👪 All Contributors: ${contributions}`,
28+
comments: {
29+
after: `
2930
<!-- ALL-CONTRIBUTORS-BADGE:END -->
3031
\t<!-- prettier-ignore-end -->`,
32+
before: `<!-- prettier-ignore-start -->
33+
\t<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
34+
\t`,
35+
},
36+
href: "#contributors",
37+
src: `https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-${contributions}-21bb42.svg`,
38+
},
3139
],
3240
sections: options.contributors
3341
? [printAllContributorsTable(options.contributors)]

0 commit comments

Comments
 (0)