create-typescript-app 2.9.4 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/blocks/blockCTATransitions.js +86 -46
- package/lib/blocks/blockGitHubActionsCI.js +29 -32
- package/lib/blocks/files/createSoloWorkflowFile.d.ts +3 -1
- package/lib/blocks/files/createSoloWorkflowFile.js +3 -1
- package/lib/blocks/files/formatYamlAction.d.ts +3 -0
- package/lib/blocks/files/formatYamlAction.js +8 -0
- package/lib/data/packageData.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { base } from "../base.js";
|
|
2
2
|
import { packageData } from "../data/packageData.js";
|
|
3
3
|
import { resolveUses } from "./actions/resolveUses.js";
|
|
4
|
-
import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
|
|
5
4
|
import { blockPackageJson } from "./blockPackageJson.js";
|
|
5
|
+
import { blockRepositoryBranchRuleset } from "./blockRepositoryBranchRuleset.js";
|
|
6
|
+
import { createSoloWorkflowFile } from "./files/createSoloWorkflowFile.js";
|
|
7
|
+
import { formatYamlAction } from "./files/formatYamlAction.js";
|
|
6
8
|
const blockCTATransitions = base.createBlock({
|
|
7
9
|
about: {
|
|
8
10
|
name: "CTA Transitions"
|
|
@@ -10,64 +12,102 @@ const blockCTATransitions = base.createBlock({
|
|
|
10
12
|
produce({ options }) {
|
|
11
13
|
return {
|
|
12
14
|
addons: [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
blockPackageJson({
|
|
16
|
+
properties: {
|
|
17
|
+
devDependencies: {
|
|
18
|
+
"create-typescript-app": packageData.version
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
blockRepositoryBranchRuleset({
|
|
23
|
+
requiredStatusChecks: ["Transition"]
|
|
24
|
+
})
|
|
25
|
+
],
|
|
26
|
+
files: {
|
|
27
|
+
".github": {
|
|
28
|
+
actions: {
|
|
29
|
+
transition: {
|
|
30
|
+
"action.yml": formatYamlAction({
|
|
31
|
+
description: "Runs create-typescript-app in transition mode",
|
|
32
|
+
name: "Transition",
|
|
33
|
+
runs: {
|
|
34
|
+
steps: [
|
|
35
|
+
{ uses: "./.github/actions/prepare" },
|
|
36
|
+
{
|
|
37
|
+
run: "pnpx create-typescript-app",
|
|
38
|
+
shell: "bash"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "auto-commit-action",
|
|
42
|
+
uses: "stefanzweifel/git-auto-commit-action@v5",
|
|
43
|
+
with: {
|
|
44
|
+
commit_author: "The Friendly Bingo Bot <bot@create.bingo>",
|
|
45
|
+
commit_message: "Check in changes from re-running npx create-typescript-app",
|
|
46
|
+
commit_user_email: "bot@create.bingo",
|
|
47
|
+
commit_user_name: "The Friendly Bingo Bot"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
if: "steps.auto-commit-action.outputs.changes_detected == 'true'",
|
|
52
|
+
uses: "mshick/add-pr-comment@v2",
|
|
53
|
+
with: {
|
|
54
|
+
issue: "${{ github.event.pull_request.number }}",
|
|
55
|
+
message: [
|
|
56
|
+
"\u{1F916} Beep boop! I ran `pnpx create-typescript-app` and it updated some files.",
|
|
57
|
+
"I went ahead and checked those changes into this PR for you. Please review the latest commit to see if you want to merge it.",
|
|
58
|
+
"Cheers!",
|
|
59
|
+
" \u2014 _The Friendly Bingo Bot_ \u{1F49D}",
|
|
60
|
+
"",
|
|
61
|
+
"> \u2139\uFE0F These automatic commits keep your repository up-to-date with new versions of [create-typescript-app](https://github.com/JoshuaKGoldberg/create-typescript-app). If you want to opt out, delete your `.github/workflows/cta-transitions.yml` file."
|
|
62
|
+
].join("\n")
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
using: "composite"
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
workflows: {
|
|
72
|
+
"cta.yml": createSoloWorkflowFile({
|
|
73
|
+
jobName: "Transition",
|
|
74
|
+
name: "CTA",
|
|
75
|
+
on: {
|
|
76
|
+
pull_request: {
|
|
77
|
+
branches: ["main"]
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
permissions: {
|
|
81
|
+
"pull-requests": "write"
|
|
21
82
|
},
|
|
22
|
-
if: "${{ startsWith(github.head_ref, 'renovate/') && contains(github.event.pull_request.title, 'create-typescript-app') }}",
|
|
23
|
-
name: "CTA Transitions",
|
|
24
83
|
steps: [
|
|
25
|
-
{ run: "pnpx create-typescript-app" },
|
|
26
84
|
{
|
|
27
85
|
uses: resolveUses(
|
|
28
|
-
"
|
|
29
|
-
"
|
|
86
|
+
"actions/checkout",
|
|
87
|
+
"v4",
|
|
30
88
|
options.workflowsVersions
|
|
31
89
|
),
|
|
32
90
|
with: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
91
|
+
"fetch-depth": 0,
|
|
92
|
+
ref: "${{github.event.pull_request.head.ref}}",
|
|
93
|
+
repository: "${{github.event.pull_request.head.repo.full_name}}",
|
|
94
|
+
token: "${{ secrets.ACCESS_TOKEN }}"
|
|
37
95
|
}
|
|
38
96
|
},
|
|
39
97
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
message: [
|
|
48
|
-
"|",
|
|
49
|
-
"\u{1F916} Beep boop! I ran `npx create-typescript-app` and found same changes.",
|
|
50
|
-
"Please review the latest commit to see if you want to merge it.",
|
|
51
|
-
"Cheers! \u{1F49D}",
|
|
52
|
-
"",
|
|
53
|
-
"> 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).",
|
|
54
|
-
"> If you want to opt out of these automatic updates, delete the `.github/workflows/cta-transitions.yml` file on your `main` branch."
|
|
55
|
-
].join("\n"),
|
|
56
|
-
"repo-token": "${{ secrets.ACCESS_TOKEN }}"
|
|
57
|
-
}
|
|
98
|
+
id: "check",
|
|
99
|
+
if: `(github.actor == '${options.owner}' || github.actor == 'renovate[bot]') && startsWith(github.head_ref, 'renovate/') && contains(github.event.pull_request.title, 'create-typescript-app')`,
|
|
100
|
+
uses: "./.github/actions/transition"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
if: "steps.check.outcome == 'skipped'",
|
|
104
|
+
run: "echo 'Skipping transition mode because the PR does not appear to be an automated or owner-created update to create-typescript-app.'"
|
|
58
105
|
}
|
|
59
106
|
]
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
}),
|
|
63
|
-
blockPackageJson({
|
|
64
|
-
properties: {
|
|
65
|
-
devDependencies: {
|
|
66
|
-
"create-typescript-app": packageData.version
|
|
67
|
-
}
|
|
107
|
+
})
|
|
68
108
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
109
|
+
}
|
|
110
|
+
}
|
|
71
111
|
};
|
|
72
112
|
}
|
|
73
113
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import jsYaml from "js-yaml";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import { base } from "../base.js";
|
|
4
3
|
import { resolveUses } from "./actions/resolveUses.js";
|
|
@@ -6,7 +5,7 @@ import { blockRemoveFiles } from "./blockRemoveFiles.js";
|
|
|
6
5
|
import { blockRepositoryBranchRuleset } from "./blockRepositoryBranchRuleset.js";
|
|
7
6
|
import { createMultiWorkflowFile } from "./files/createMultiWorkflowFile.js";
|
|
8
7
|
import { createSoloWorkflowFile } from "./files/createSoloWorkflowFile.js";
|
|
9
|
-
import {
|
|
8
|
+
import { formatYamlAction } from "./files/formatYamlAction.js";
|
|
10
9
|
const zActionStep = z.intersection(
|
|
11
10
|
z.object({
|
|
12
11
|
env: z.record(z.string(), z.string()).optional(),
|
|
@@ -42,36 +41,34 @@ const blockGitHubActionsCI = base.createBlock({
|
|
|
42
41
|
".github": {
|
|
43
42
|
actions: {
|
|
44
43
|
prepare: {
|
|
45
|
-
"action.yml":
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}).replaceAll(/\n(\S)/g, "\n\n$1")
|
|
74
|
-
)
|
|
44
|
+
"action.yml": formatYamlAction({
|
|
45
|
+
description: "Prepares the repo for a typical CI job",
|
|
46
|
+
name: "Prepare",
|
|
47
|
+
runs: {
|
|
48
|
+
steps: [
|
|
49
|
+
{
|
|
50
|
+
uses: resolveUses(
|
|
51
|
+
"pnpm/action-setup",
|
|
52
|
+
"v4",
|
|
53
|
+
options.workflowsVersions
|
|
54
|
+
)
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
uses: resolveUses(
|
|
58
|
+
"actions/setup-node",
|
|
59
|
+
"v4",
|
|
60
|
+
options.workflowsVersions
|
|
61
|
+
),
|
|
62
|
+
with: { cache: "pnpm", "node-version": "20" }
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
run: "pnpm install --frozen-lockfile",
|
|
66
|
+
shell: "bash"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
using: "composite"
|
|
70
|
+
}
|
|
71
|
+
})
|
|
75
72
|
}
|
|
76
73
|
},
|
|
77
74
|
workflows: {
|
|
@@ -27,6 +27,7 @@ interface WorkflowFileOn {
|
|
|
27
27
|
interface WorkflowFileOptions {
|
|
28
28
|
concurrency?: WorkflowFileConcurrency;
|
|
29
29
|
if?: string;
|
|
30
|
+
jobName?: string;
|
|
30
31
|
name: string;
|
|
31
32
|
on?: WorkflowFileOn;
|
|
32
33
|
permissions?: WorkflowFilePermissions;
|
|
@@ -40,12 +41,13 @@ interface WorkflowFilePermissions {
|
|
|
40
41
|
}
|
|
41
42
|
interface WorkflowFileStep {
|
|
42
43
|
env?: Record<string, string>;
|
|
44
|
+
id?: string;
|
|
43
45
|
if?: string;
|
|
44
46
|
name?: string;
|
|
45
47
|
run?: string;
|
|
46
48
|
uses?: string;
|
|
47
49
|
with?: Record<string, unknown>;
|
|
48
50
|
}
|
|
49
|
-
declare function createSoloWorkflowFile({ concurrency, name, on, permissions, ...options }: WorkflowFileOptions): string;
|
|
51
|
+
declare function createSoloWorkflowFile({ concurrency, jobName, name, on, permissions, ...options }: WorkflowFileOptions): string;
|
|
50
52
|
|
|
51
53
|
export { createSoloWorkflowFile };
|
|
@@ -2,6 +2,7 @@ import { createJobName } from "./createJobName.js";
|
|
|
2
2
|
import { formatWorkflowYaml } from "./formatWorkflowYaml.js";
|
|
3
3
|
function createSoloWorkflowFile({
|
|
4
4
|
concurrency,
|
|
5
|
+
jobName,
|
|
5
6
|
name,
|
|
6
7
|
on,
|
|
7
8
|
permissions,
|
|
@@ -10,8 +11,9 @@ function createSoloWorkflowFile({
|
|
|
10
11
|
return formatWorkflowYaml({
|
|
11
12
|
concurrency,
|
|
12
13
|
jobs: {
|
|
13
|
-
[createJobName(name)]: {
|
|
14
|
+
[createJobName(jobName ?? name)]: {
|
|
14
15
|
...options.if && { if: options.if },
|
|
16
|
+
...jobName && { name: jobName },
|
|
15
17
|
"runs-on": "ubuntu-latest",
|
|
16
18
|
steps: options.steps
|
|
17
19
|
}
|