create-typescript-app 2.4.0 → 2.4.2

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.
@@ -8,22 +8,45 @@ const blockRepositoryBranchRuleset = base.createBlock({
8
8
  requiredStatusChecks: z.array(z.string()).default([])
9
9
  },
10
10
  setup({ addons, options }) {
11
- return createRequestSend(
12
- addons.requiredStatusChecks,
13
- "POST /repos/{owner}/{repo}/rulesets",
14
- options,
15
- "branch-ruleset-create",
16
- void 0
17
- );
11
+ return {
12
+ requests: [
13
+ {
14
+ id: "branch-ruleset-create",
15
+ async send({ octokit }) {
16
+ await octokit.request(
17
+ "POST /repos/{owner}/{repo}/rulesets",
18
+ createInnerSend(addons.requiredStatusChecks, options)
19
+ );
20
+ }
21
+ }
22
+ ]
23
+ };
18
24
  },
19
25
  transition({ addons, options }) {
20
- return createRequestSend(
21
- addons.requiredStatusChecks,
22
- `PUT /repos/{owner}/{repo}/rulesets/{ruleset_id}`,
23
- options,
24
- "branch-ruleset-update",
25
- options.rulesetId
26
- );
26
+ return {
27
+ requests: [
28
+ {
29
+ id: "branch-ruleset-update",
30
+ async send({ octokit }) {
31
+ if (options.rulesetId) {
32
+ await octokit.request(
33
+ `PUT /repos/{owner}/{repo}/rulesets/{ruleset_id}`,
34
+ createInnerSend(
35
+ addons.requiredStatusChecks,
36
+ options,
37
+ options.rulesetId
38
+ )
39
+ );
40
+ } else {
41
+ await octokit.request(
42
+ `POST /repos/{owner}/{repo}/rulesets/{ruleset_id}`,
43
+ createInnerSend(addons.requiredStatusChecks, options)
44
+ );
45
+ }
46
+ }
47
+ }
48
+ ]
49
+ };
27
50
  },
28
51
  // TODO: Make produce() optional
29
52
  // This needs createBlock to be generic to know if block.produce({}) is ok
@@ -31,61 +54,54 @@ const blockRepositoryBranchRuleset = base.createBlock({
31
54
  return {};
32
55
  }
33
56
  });
34
- function createRequestSend(contexts, endpoint, options, requestId, rulesetId) {
57
+ function createInnerSend(contexts, options, rulesetId) {
35
58
  return {
36
- requests: [
59
+ bypass_actors: [
37
60
  {
38
- id: requestId,
39
- async send({ octokit }) {
40
- await octokit.request(endpoint, {
41
- bypass_actors: [
42
- {
43
- // This *seems* to be the Repository Admin role always?
44
- // https://github.com/github/rest-api-description/issues/4406
45
- actor_id: 5,
46
- actor_type: "RepositoryRole",
47
- bypass_mode: "always"
48
- }
49
- ],
50
- conditions: {
51
- ref_name: {
52
- exclude: [],
53
- include: ["refs/heads/main"]
54
- }
55
- },
56
- enforcement: "active",
57
- name: "Branch protection for main",
58
- owner: options.owner,
59
- repo: options.repository,
60
- rules: [
61
- { type: "deletion" },
62
- {
63
- parameters: {
64
- allowed_merge_methods: ["squash"],
65
- dismiss_stale_reviews_on_push: false,
66
- require_code_owner_review: false,
67
- require_last_push_approval: false,
68
- required_approving_review_count: 0,
69
- required_review_thread_resolution: false
70
- },
71
- type: "pull_request"
72
- },
73
- {
74
- parameters: {
75
- required_status_checks: contexts.map((context) => ({
76
- context
77
- })),
78
- strict_required_status_checks_policy: false
79
- },
80
- type: "required_status_checks"
81
- }
82
- ],
83
- ruleset_id: rulesetId,
84
- target: "branch"
85
- });
86
- }
61
+ // This *seems* to be the Repository Admin role always?
62
+ // https://github.com/github/rest-api-description/issues/4406
63
+ actor_id: 5,
64
+ actor_type: "RepositoryRole",
65
+ bypass_mode: "always"
66
+ }
67
+ ],
68
+ conditions: {
69
+ ref_name: {
70
+ exclude: [],
71
+ include: ["refs/heads/main"]
72
+ }
73
+ },
74
+ enforcement: "active",
75
+ name: "Branch protection for main",
76
+ owner: options.owner,
77
+ repo: options.repository,
78
+ rules: [
79
+ { type: "deletion" },
80
+ {
81
+ parameters: {
82
+ allowed_merge_methods: ["squash"],
83
+ dismiss_stale_reviews_on_push: false,
84
+ require_code_owner_review: false,
85
+ require_last_push_approval: false,
86
+ required_approving_review_count: 0,
87
+ required_review_thread_resolution: false
88
+ },
89
+ type: "pull_request"
90
+ },
91
+ {
92
+ parameters: {
93
+ required_status_checks: contexts.map((context) => ({
94
+ context
95
+ })),
96
+ strict_required_status_checks_policy: false
97
+ },
98
+ type: "required_status_checks"
87
99
  }
88
- ]
100
+ ],
101
+ // Type fun because the GitHub Octokit APIs don't provide named types...
102
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
103
+ ruleset_id: rulesetId === void 0 ? rulesetId : Number(rulesetId),
104
+ target: "branch"
89
105
  };
90
106
  }
91
107
  export {
@@ -1,5 +1,5 @@
1
1
  var name = "create-typescript-app";
2
- var version = "2.3.0";
2
+ var version = "2.4.1";
3
3
  var description = "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 🎁";
4
4
  var repository = {
5
5
  type: "git",
@@ -1,6 +1,6 @@
1
1
  import { AllContributorContributor } from '../types.js';
2
2
  import { TakeInput } from 'bingo';
3
3
 
4
- declare function readAllContributors(take: TakeInput): Promise<AllContributorContributor[]>;
4
+ declare function readAllContributors(take: TakeInput): Promise<AllContributorContributor[] | undefined>;
5
5
 
6
6
  export { readAllContributors };
@@ -11,7 +11,7 @@ async function readAllContributors(take) {
11
11
  const user = await take(inputFromOctokit, {
12
12
  endpoint: "GET /user"
13
13
  });
14
- return [
14
+ return user && [
15
15
  {
16
16
  avatar_url: user.avatar_url,
17
17
  contributions: ownerContributions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-typescript-app",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 🎁",
5
5
  "repository": {
6
6
  "type": "git",