create-typescript-app 2.9.4 → 2.11.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.
@@ -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
- blockGitHubActionsCI({
14
- jobs: [
15
- {
16
- checkoutWith: {
17
- "fetch-depth": "0",
18
- ref: "${{github.event.pull_request.head.ref}}",
19
- repository: "${{github.event.pull_request.head.repo.full_name}}",
20
- token: '"${{ secrets.ACCESS_TOKEN }}"'
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
- "stefanzweifel/git-auto-commit-action",
29
- "v5",
86
+ "actions/checkout",
87
+ "v4",
30
88
  options.workflowsVersions
31
89
  ),
32
90
  with: {
33
- commit_author: "The Friendly Bingo Bot <bot@create.bingo>",
34
- commit_message: "Check in changes from re-running npx create-typescript-app",
35
- commit_user_email: "bot@create.bingo",
36
- commit_user_name: "The Friendly Bingo Bot"
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
- uses: resolveUses(
41
- "mshick/add-pr-comment",
42
- "v2",
43
- options.workflowsVersions
44
- ),
45
- with: {
46
- issue: "${{ github.event.pull_request.number }}",
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 { removeUsesQuotes } from "./files/removeUsesQuotes.js";
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": removeUsesQuotes(
46
- jsYaml.dump({
47
- description: "Prepares the repo for a typical CI job",
48
- name: "Prepare",
49
- runs: {
50
- steps: [
51
- {
52
- uses: resolveUses(
53
- "pnpm/action-setup",
54
- "v4",
55
- options.workflowsVersions
56
- )
57
- },
58
- {
59
- uses: resolveUses(
60
- "actions/setup-node",
61
- "v4",
62
- options.workflowsVersions
63
- ),
64
- with: { cache: "pnpm", "node-version": "20" }
65
- },
66
- {
67
- run: "pnpm install --frozen-lockfile",
68
- shell: "bash"
69
- }
70
- ],
71
- using: "composite"
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: {
@@ -5,7 +5,7 @@ const blockTemplatedWith = base.createBlock({
5
5
  about: {
6
6
  name: "Templated With"
7
7
  },
8
- produce() {
8
+ produce({ options }) {
9
9
  return {
10
10
  addons: [
11
11
  blockCSpell({
@@ -13,12 +13,11 @@ const blockTemplatedWith = base.createBlock({
13
13
  }),
14
14
  blockREADME({
15
15
  notices: [
16
- `
17
- <!-- You can remove this notice if you don't want it \u{1F642} no worries! -->
18
-
19
- > \u{1F49D} This package was templated with [\`create-typescript-app\`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [Bingo engine](https://create.bingo).
16
+ options.owner !== "JoshuaKGoldberg" && `
17
+ <!-- You can remove this notice if you don't want it \u{1F642} no worries! -->`,
18
+ `> \u{1F49D} This package was templated with [\`create-typescript-app\`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [Bingo engine](https://create.bingo).
20
19
  `
21
- ]
20
+ ].filter((notice) => typeof notice === "string")
22
21
  })
23
22
  ]
24
23
  };
@@ -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
  }
@@ -0,0 +1,3 @@
1
+ declare function formatYamlAction(value: object): string;
2
+
3
+ export { formatYamlAction };
@@ -0,0 +1,8 @@
1
+ import jsYaml from "js-yaml";
2
+ import { removeUsesQuotes } from "./removeUsesQuotes.js";
3
+ function formatYamlAction(value) {
4
+ return removeUsesQuotes(jsYaml.dump(value).replaceAll(/\n(\S)/g, "\n\n$1"));
5
+ }
6
+ export {
7
+ formatYamlAction
8
+ };
@@ -1,5 +1,5 @@
1
1
  var name = "create-typescript-app";
2
- var version = "2.9.3";
2
+ var version = "2.10.0";
3
3
  var description = "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 🎁";
4
4
  var repository = {
5
5
  type: "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-typescript-app",
3
- "version": "2.9.4",
3
+ "version": "2.11.0",
4
4
  "description": "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 🎁",
5
5
  "repository": {
6
6
  "type": "git",