Skip to content

Commit 869c703

Browse files
chore: adopt create engine's requests creations (#1776)
## PR Checklist - [x] Addresses an existing open issue: fixes #1752 - [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 in Blocks around Octokit settings. Also adds all three GitHub setter Blocks to `presetMinimal`. 💖
1 parent 0931fa0 commit 869c703

6 files changed

+149
-23
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@clack/prompts": "^0.8.2",
4545
"@prettier/sync": "^0.5.2",
4646
"chalk": "^5.3.0",
47-
"create": "0.1.0-alpha.4",
47+
"create": "0.1.0-alpha.5",
4848
"execa": "^9.5.1",
4949
"git-remote-origin-url": "^4.0.0",
5050
"git-url-parse": "^16.0.0",
@@ -82,7 +82,7 @@
8282
"all-contributors-cli": "6.26.1",
8383
"c8": "10.1.2",
8484
"console-fail-test": "0.5.0",
85-
"create-testers": "0.1.0-alpha.4",
85+
"create-testers": "0.1.0-alpha.5",
8686
"cspell": "8.16.1",
8787
"eslint": "9.16.0",
8888
"eslint-plugin-jsdoc": "50.6.0",

pnpm-lock.yaml

+54-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { z } from "zod";
2+
3+
import { base } from "../base.js";
4+
5+
export const blockRepositoryBranchProtection = base.createBlock({
6+
about: {
7+
name: "Repository Branch Protection",
8+
},
9+
addons: {
10+
requiredStatusChecks: z.array(z.string()).default([]),
11+
},
12+
produce({ addons, options }) {
13+
return {
14+
requests: [
15+
{
16+
id: "branch-protection",
17+
async send({ octokit }) {
18+
await octokit.request(
19+
`PUT /repos/{owner}/{repository}/branches/{main}/protection`,
20+
{
21+
allow_deletions: false,
22+
allow_force_pushes: true,
23+
allow_fork_pushes: false,
24+
allow_fork_syncing: true,
25+
block_creations: false,
26+
branch: "main",
27+
enforce_admins: false,
28+
owner: options.owner,
29+
repo: options.repository,
30+
required_conversation_resolution: true,
31+
required_linear_history: false,
32+
required_pull_request_reviews: null,
33+
required_status_checks: {
34+
checks: addons.requiredStatusChecks.map((context) => ({
35+
context,
36+
})),
37+
strict: false,
38+
},
39+
restrictions: null,
40+
},
41+
);
42+
},
43+
},
44+
],
45+
};
46+
},
47+
});

src/next/blocks/blockRepositoryLabels.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const blockRepositoryLabels = base.createBlock({
88
produce({ options }) {
99
return {
1010
scripts: [
11-
`npx set-github-repository-labels --outcomes ${JSON.stringify(outcomeLabels)} --owner "${options.owner}" --repository "${options.repository}"`,
11+
`npx set-github-repository-labels --labels ${JSON.stringify(outcomeLabels)} --owner "${options.owner}" --repository "${options.repository}"`,
1212
],
1313
};
1414
},
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { base } from "../base.js";
2+
3+
export const blockRepositorySettings = base.createBlock({
4+
about: {
5+
name: "Repository Settings",
6+
},
7+
produce({ options }) {
8+
return {
9+
requests: [
10+
{
11+
id: "repository-settings",
12+
async send({ octokit }) {
13+
await octokit.rest.repos.update({
14+
allow_auto_merge: true,
15+
allow_rebase_merge: false,
16+
allow_squash_merge: true,
17+
default_branch: "main",
18+
delete_branch_on_merge: true,
19+
description: options.description,
20+
has_wiki: false,
21+
owner: options.owner,
22+
repo: options.repository,
23+
security_and_analysis: {
24+
secret_scanning: {
25+
status: "enabled",
26+
},
27+
secret_scanning_push_protection: {
28+
status: "enabled",
29+
},
30+
},
31+
squash_merge_commit_message: "PR_BODY",
32+
squash_merge_commit_title: "PR_TITLE",
33+
});
34+
},
35+
},
36+
],
37+
};
38+
},
39+
});

src/next/presetMinimal.ts

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { blockMITLicense } from "./blocks/blockMITLicense.js";
1313
import { blockPackageJson } from "./blocks/blockPackageJson.js";
1414
import { blockPrettier } from "./blocks/blockPrettier.js";
1515
import { blockREADME } from "./blocks/blockREADME.js";
16+
import { blockRepositoryBranchProtection } from "./blocks/blockRepositoryBranchProtection.js";
17+
import { blockRepositoryLabels } from "./blocks/blockRepositoryLabels.js";
18+
import { blockRepositorySettings } from "./blocks/blockRepositorySettings.js";
1619
import { blockTemplatedBy } from "./blocks/blockTemplatedBy.js";
1720
import { blockTSup } from "./blocks/blockTSup.js";
1821
import { blockTypeScript } from "./blocks/blockTypeScript.js";
@@ -38,6 +41,9 @@ export const presetMinimal = base.createPreset({
3841
blockPackageJson,
3942
blockPrettier,
4043
blockREADME,
44+
blockRepositoryBranchProtection,
45+
blockRepositoryLabels,
46+
blockRepositorySettings,
4147
blockTemplatedBy,
4248
blockTSup,
4349
blockTypeScript,

0 commit comments

Comments
 (0)