Skip to content

Commit c179a7e

Browse files
feat: add more transition mode cleanups (#2003)
<!-- 👋 Hi, thanks for sending a PR to create-typescript-app! 🎁. Please fill out all fields below and make sure each item is true and [x] checked. Otherwise we may not be able to review your PR. --> ## PR Checklist - [x] Addresses an existing open issue: fixes #2002 - [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 Adds a collection of dependency and file cleanups based on older CTA versions. Also unifies their removals into new `blockRemoveDependencies` and `blockRemoveFiles` Blocks. This should actually speed things up by running one command for each of those two Blocks. Previously it was one command for each Block with things to remove. 🎁
1 parent 0b6ed77 commit c179a7e

40 files changed

+657
-256
lines changed

src/blocks/blockCSpell.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ describe("blockCSpell", () => {
5151
],
5252
},
5353
],
54+
"removedWorkflows": [
55+
"lint-spelling",
56+
"spelling",
57+
],
5458
},
5559
"block": [Function],
5660
},
@@ -121,6 +125,10 @@ describe("blockCSpell", () => {
121125
],
122126
},
123127
],
128+
"removedWorkflows": [
129+
"lint-spelling",
130+
"spelling",
131+
],
124132
},
125133
"block": [Function],
126134
},
@@ -188,6 +196,10 @@ describe("blockCSpell", () => {
188196
],
189197
},
190198
],
199+
"removedWorkflows": [
200+
"lint-spelling",
201+
"spelling",
202+
],
191203
},
192204
"block": [Function],
193205
},

src/blocks/blockCSpell.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const blockCSpell = base.createBlock({
4646
steps: [{ run: "pnpm lint:spelling" }],
4747
},
4848
],
49+
removedWorkflows: ["lint-spelling", "spelling"],
4950
}),
5051
blockPackageJson({
5152
properties: {
+64-60
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { testBlock } from "bingo-stratum-testers";
22
import { describe, expect, test } from "vitest";
33

4+
import { packageData } from "../data/packageData.js";
45
import { blockCTATransitions } from "./blockCTATransitions.js";
6+
import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
7+
import { blockPackageJson } from "./blockPackageJson.js";
58
import { optionsBase } from "./options.fakes.js";
69

710
describe("blockCTATransitions", () => {
@@ -10,66 +13,67 @@ describe("blockCTATransitions", () => {
1013
options: optionsBase,
1114
});
1215

13-
expect(creation).toMatchInlineSnapshot(`
14-
{
15-
"addons": [
16-
{
17-
"addons": {
18-
"jobs": [
19-
{
20-
"checkoutWith": {
21-
"fetch-depth": "0",
22-
"ref": "\${{github.event.pull_request.head.ref}}",
23-
"repository": "\${{github.event.pull_request.head.repo.full_name}}",
24-
"token": ""\${{ secrets.ACCESS_TOKEN }}"",
25-
},
26-
"if": "\${{ startsWith(github.head_ref, 'renovate/') && contains(github.event.pull_request.title, 'create-typescript-app') }}",
27-
"name": "CTA Transitions",
28-
"steps": [
29-
{
30-
"run": "pnpx create-typescript-app",
31-
},
32-
{
33-
"uses": "stefanzweifel/git-auto-commit-action@v5",
34-
"with": {
35-
"commit_author": "The Friendly Bingo Bot <[email protected]>",
36-
"commit_message": "Check in changes from re-running npx create-typescript-app",
37-
"commit_user_email": "[email protected]",
38-
"commit_user_name": "The Friendly Bingo Bot",
39-
},
40-
},
41-
{
42-
"uses": "mshick/add-pr-comment@v2",
43-
"with": {
44-
"issue": "\${{ github.event.pull_request.number }}",
45-
"message": "|
46-
🤖 Beep boop! I ran \`npx create-typescript-app\` and found same changes.
47-
Please review the latest commit to see if you want to merge it.
48-
Cheers! 💝
16+
expect(creation).toEqual({
17+
addons: [
18+
{
19+
addons: {
20+
jobs: [
21+
{
22+
checkoutWith: {
23+
"fetch-depth": "0",
24+
ref: "${{github.event.pull_request.head.ref}}",
25+
repository:
26+
"${{github.event.pull_request.head.repo.full_name}}",
27+
token: '"${{ secrets.ACCESS_TOKEN }}"',
28+
},
29+
if: "${{ startsWith(github.head_ref, 'renovate/') && contains(github.event.pull_request.title, 'create-typescript-app') }}",
30+
name: "CTA Transitions",
31+
steps: [
32+
{
33+
run: "pnpx create-typescript-app",
34+
},
35+
{
36+
uses: "stefanzweifel/git-auto-commit-action@v5",
37+
with: {
38+
commit_author:
39+
"The Friendly Bingo Bot <[email protected]>",
40+
commit_message:
41+
"Check in changes from re-running npx create-typescript-app",
42+
commit_user_email: "[email protected]",
43+
commit_user_name: "The Friendly Bingo Bot",
44+
},
45+
},
46+
{
47+
uses: "mshick/add-pr-comment@v2",
48+
with: {
49+
issue: "${{ github.event.pull_request.number }}",
50+
message: `|
51+
🤖 Beep boop! I ran \`npx create-typescript-app\` and found same changes.
52+
Please review the latest commit to see if you want to merge it.
53+
Cheers! 💝
4954
50-
> This change was automatically made in CI to keep your repository up-to-date with the templating in [create-typescript-app](https://github.com/JoshuaKGoldberg/create-typescript-app).
51-
> If you want to opt out of these automatic updates, delete the \`.github/workflows/cta-transitions.yml\` file on your \`main\` branch.",
52-
"repo-token": "\${{ secrets.ACCESS_TOKEN }}",
53-
},
54-
},
55-
],
56-
},
57-
],
58-
},
59-
"block": [Function],
60-
},
61-
{
62-
"addons": {
63-
"properties": {
64-
"devDependencies": {
65-
"create-typescript-app": "2.8.0",
66-
},
67-
},
68-
},
69-
"block": [Function],
70-
},
71-
],
72-
}
73-
`);
55+
> This change was automatically made in CI to keep your repository up-to-date with the templating in [create-typescript-app](https://github.com/JoshuaKGoldberg/create-typescript-app).
56+
> If you want to opt out of these automatic updates, delete the \`.github/workflows/cta-transitions.yml\` file on your \`main\` branch.`,
57+
"repo-token": "${{ secrets.ACCESS_TOKEN }}",
58+
},
59+
},
60+
],
61+
},
62+
],
63+
},
64+
block: blockGitHubActionsCI,
65+
},
66+
{
67+
addons: {
68+
properties: {
69+
devDependencies: {
70+
"create-typescript-app": packageData.version,
71+
},
72+
},
73+
},
74+
block: blockPackageJson,
75+
},
76+
],
77+
});
7478
});
7579
});

src/blocks/blockCodecov.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ describe("blockCodecov", () => {
7171
},
7272
"block": [Function],
7373
},
74-
],
75-
"scripts": [
7674
{
77-
"commands": [
78-
"rm .github/codecov.yml codecov.yml",
79-
],
80-
"phase": 0,
81-
"silent": true,
75+
"addons": {
76+
"files": [
77+
".github/codecov.yml",
78+
"codecov.yml",
79+
],
80+
},
81+
"block": [Function],
8282
},
8383
],
8484
}

src/blocks/blockCodecov.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { z } from "zod";
22

33
import { base } from "../base.js";
44
import { blockGitHubApps } from "./blockGitHubApps.js";
5+
import { blockRemoveFiles } from "./blockRemoveFiles.js";
56
import { blockVitest } from "./blockVitest.js";
6-
import { CommandPhase } from "./phases.js";
77

88
export const blockCodecov = base.createBlock({
99
about: {
@@ -36,12 +36,8 @@ export const blockCodecov = base.createBlock({
3636
},
3737
transition() {
3838
return {
39-
scripts: [
40-
{
41-
commands: ["rm .github/codecov.yml codecov.yml"],
42-
phase: CommandPhase.Migrations,
43-
silent: true,
44-
},
39+
addons: [
40+
blockRemoveFiles({ files: [".github/codecov.yml", "codecov.yml"] }),
4541
],
4642
};
4743
},

src/blocks/blockContributingDocs.test.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ describe("blockContributingDocs", () => {
126126

127127
expect(creation).toMatchInlineSnapshot(`
128128
{
129+
"addons": [
130+
{
131+
"addons": {
132+
"files": [
133+
"CONTRIBUTING.md",
134+
],
135+
},
136+
"block": [Function],
137+
},
138+
],
129139
"files": {
130140
".github": {
131141
"CONTRIBUTING.md": "# Contributing
@@ -228,15 +238,6 @@ describe("blockContributingDocs", () => {
228238
",
229239
},
230240
},
231-
"scripts": [
232-
{
233-
"commands": [
234-
"rm CONTRIBUTING.md",
235-
],
236-
"phase": 0,
237-
"silent": true,
238-
},
239-
],
240241
}
241242
`);
242243
});

src/blocks/blockContributingDocs.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { base } from "../base.js";
2-
import { CommandPhase } from "./phases.js";
2+
import { blockRemoveFiles } from "./blockRemoveFiles.js";
33

44
export const blockContributingDocs = base.createBlock({
55
about: {
@@ -113,13 +113,7 @@ ${options.emoji} is a good starter if you're not sure which to use.
113113
},
114114
transition() {
115115
return {
116-
scripts: [
117-
{
118-
commands: ["rm CONTRIBUTING.md"],
119-
phase: CommandPhase.Migrations,
120-
silent: true,
121-
},
122-
],
116+
addons: [blockRemoveFiles({ files: ["CONTRIBUTING.md"] })],
123117
};
124118
},
125119
});

src/blocks/blockContributorCovenant.test.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ describe("blockContributorCovenant", () => {
161161

162162
expect(creation).toMatchInlineSnapshot(`
163163
{
164+
"addons": [
165+
{
166+
"addons": {
167+
"files": [
168+
"CODE_OF_CONDUCT.md",
169+
],
170+
},
171+
"block": [Function],
172+
},
173+
],
164174
"files": {
165175
".github": {
166176
"CODE_OF_CONDUCT.md": "# Contributor Covenant Code of Conduct
@@ -298,15 +308,6 @@ describe("blockContributorCovenant", () => {
298308
",
299309
},
300310
},
301-
"scripts": [
302-
{
303-
"commands": [
304-
"rm CODE_OF_CONDUCT.md",
305-
],
306-
"phase": 0,
307-
"silent": true,
308-
},
309-
],
310311
}
311312
`);
312313
});

src/blocks/blockContributorCovenant.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { base } from "../base.js";
2-
import { CommandPhase } from "./phases.js";
2+
import { blockRemoveFiles } from "./blockRemoveFiles.js";
33

44
export const blockContributorCovenant = base.createBlock({
55
about: {
@@ -148,13 +148,7 @@ For answers to common questions about this code of conduct, see the FAQ at
148148
},
149149
transition() {
150150
return {
151-
scripts: [
152-
{
153-
commands: ["rm CODE_OF_CONDUCT.md"],
154-
phase: CommandPhase.Migrations,
155-
silent: true,
156-
},
157-
],
151+
addons: [blockRemoveFiles({ files: ["CODE_OF_CONDUCT.md"] })],
158152
};
159153
},
160154
});

src/blocks/blockDevelopmentDocs.test.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ describe("blockDevelopmentDocs", () => {
3838

3939
expect(creation).toMatchInlineSnapshot(`
4040
{
41+
"addons": [
42+
{
43+
"addons": {
44+
"files": [
45+
"DEVELOPMENT.md",
46+
],
47+
},
48+
"block": [Function],
49+
},
50+
],
4151
"files": {
4252
".github": {
4353
"DEVELOPMENT.md": "# Development
@@ -52,15 +62,6 @@ describe("blockDevelopmentDocs", () => {
5262
",
5363
},
5464
},
55-
"scripts": [
56-
{
57-
"commands": [
58-
"rm DEVELOPMENT.md",
59-
],
60-
"phase": 0,
61-
"silent": true,
62-
},
63-
],
6465
}
6566
`);
6667
});

src/blocks/blockDevelopmentDocs.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { z } from "zod";
22

33
import { base } from "../base.js";
4-
import { CommandPhase } from "./phases.js";
4+
import { blockRemoveFiles } from "./blockRemoveFiles.js";
55

66
const zInnerSection = z.object({
77
contents: z.string(),
@@ -100,13 +100,7 @@ export const blockDevelopmentDocs = base.createBlock({
100100
},
101101
transition() {
102102
return {
103-
scripts: [
104-
{
105-
commands: ["rm DEVELOPMENT.md"],
106-
phase: CommandPhase.Migrations,
107-
silent: true,
108-
},
109-
],
103+
addons: [blockRemoveFiles({ files: ["DEVELOPMENT.md"] })],
110104
};
111105
},
112106
});

0 commit comments

Comments
 (0)