Skip to content

Commit a51c624

Browse files
feat: split contributors option into exclude-all-contributors and --skip-all-contributors-api (#899)
## PR Checklist - [x] Addresses an existing open issue: fixes #875; fixes #898 - [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 Splits the option into: * `--exclude-all-contributors`: disables the all-contributors feature altogether * `--skip-all-contributors-api`: allows the all-contributors feature, but skips fetching past contributions from GitHub
1 parent 9696273 commit a51c624

33 files changed

+565
-58
lines changed

cspell.json

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"pnpm-lock.yaml"
1010
],
1111
"words": [
12+
"allcontributors",
13+
"apexskier",
1214
"Codecov",
1315
"codespace",
1416
"commitlint",
@@ -20,11 +22,14 @@
2022
"knip",
2123
"lcov",
2224
"markdownlintignore",
25+
"mtfoley",
2326
"npmignore",
27+
"npmjs",
2428
"npmpackagejsonlintrc",
2529
"outro",
2630
"packagejson",
2731
"quickstart",
32+
"tada",
2833
"tsup",
2934
"Unstaged",
3035
"wontfix"

docs/Creation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Hooray! 🥳
2323
You can explicitly provide some or all of the options the script would prompt for as command-line flags.
2424
See [Options.md](./Options.md).
2525

26-
For example, running the creation script and skipping all APIs:
26+
For example, running the creation script and skipping all GitHub APIs:
2727

2828
```shell
29-
npx create-typescript-app --mode create --exclude-contributors --skip-github-api
29+
npx create-typescript-app --mode create --skip-all-contributors-api --skip-github-api
3030
```

docs/Initialization.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ See [Options.md](./Options.md).
3737

3838
`pnpm run initialize` will set `--mode` to `initialize`.
3939

40-
For example, running the initialization script and skipping all APIs:
40+
For example, running the initialization script and skipping all GitHub APIs:
4141

4242
```shell
43-
pnpm run initialize --exclude-contributors --skip-github-api
43+
pnpm run initialize --skip-all-contributors-api --skip-github-api
4444
```

docs/Migration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ npx create-typescript-app
1616
You can explicitly provide some or all of the options the script would prompt for as command-line flags.
1717
See [Options.md](./Options.md).
1818

19-
For example, running the migration script and skipping all APIs:
19+
For example, running the migration script and skipping all GitHub APIs:
2020

2121
```shell
22-
npx create-typescript-app --mode migrate --exclude-contributors --skip-github-api
22+
npx create-typescript-app --mode migrate --skip-all-contributors-api --skip-github-api
2323
```

docs/Options.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ The setup scripts can be directed with CLI flags to opt out tooling portions and
7474
The setup scripts normally will prompt you to select how much of the tooling you'd like to enable in a new repository.
7575
Alternately, you can bypass that prompt by providing any number of the following CLI flags:
7676

77+
- `--exclude-all-contributors`: Don't add all-contributors to track contributions and display them in a README.md table.
7778
- `--exclude-compliance`: Don't add a GitHub Actions workflow to verify that PRs match an expected format.
78-
- `--exclude-contributors`: Don't add all-contributors to track contributions and display them in a README.md table.
7979
- `--exclude-lint-json`: Don't apply linting and sorting to `*.json` and `*.jsonc` files.
8080
- `--exclude-lint-knip`: Don't add Knip to detect unused files, dependencies, and code exports.
8181
- `--exclude-lint-md`: Don't apply linting to `*.md` files.
@@ -107,18 +107,18 @@ npx create-typescript-app --exclude-lint-package-json --exclude-lint-packages --
107107

108108
You can prevent the migration script from making some network-based changes using any or all of the following CLI flags:
109109

110-
- `--exclude-contributors` _(`boolean`)_: Skips network calls that fetch all-contributors data from GitHub
111-
- This flag does nothing if `--exclude-contributors` was specified.
110+
- `--skip-all-contributors-api` _(`boolean`)_: Skips network calls that fetch all-contributors data from GitHub
111+
- This flag does nothing if `--skip-all-contributors` was specified.
112112
- `--skip-github-api` _(`boolean`)_: Skips calling to GitHub APIs.
113113
- `--skip-install` _(`boolean`)_: Skips installing all the new template packages with `pnpm`.
114114

115115
For example, providing all three flags will completely skip all network requests:
116116

117117
```shell
118-
npx create-typescript-app --exclude-contributors --skip-github-api --skip-install
118+
npx create-typescript-app --skip-all-contributors-api --skip-github-api --skip-install
119119
```
120120

121-
> 💡 Tip: To temporarily preview what the script would apply, you can run with all `--skip-*` flags, then `git add -A; git reset --hard HEAD` to completely reset all changes.
121+
> 💡 Tip: To temporarily preview what the script would apply without making changes on GitHub, you can run with all `--skip-*-api` flags, then `git add -A; git reset --hard HEAD` to completely reset all changes.
122122
123123
### Skipping Local Changes
124124

script/create-test-e2e.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ await $`rm -rf ${repository}`;
1212

1313
await $({
1414
stdio: "inherit",
15-
})`c8 -o ./coverage-create -r html -r lcov --src src node ./bin/index.js --base everything --mode create --author ${author} --email ${email} --description ${description} --owner ${owner} --title ${title} --repository ${repository} --exclude-contributors --skip-github-api`;
15+
})`c8 -o ./coverage-create -r html -r lcov --src src node ./bin/index.js --base everything --mode create --author ${author} --email ${email} --description ${description} --owner ${owner} --title ${title} --repository ${repository} --skip-all-contributors-api --skip-github-api`;
1616

1717
process.chdir(repository);
1818

script/initialize-test-e2e.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const repository = "new-repository-test";
1111
// First we run initialize to modifies the local repo, so we can test the changes
1212
await $({
1313
stdio: "inherit",
14-
})`node ./bin/index.js --description ${description} --base everything --mode initialize --owner ${owner} --title ${title} --repository ${repository} --skip-github-api --skip-restore`;
14+
})`node ./bin/index.js --description ${description} --base everything --mode initialize --owner ${owner} --title ${title} --repository ${repository} --skip-all-contributors-api --skip-github-api --skip-restore`;
1515

1616
const newPackageJson = JSON.parse(
1717
(await fs.readFile("./package.json")).toString(),
@@ -49,4 +49,4 @@ await $`pnpm i`;
4949
await $`pnpm run build`;
5050
await $({
5151
stdio: "inherit",
52-
})`c8 -o ./coverage-initialize -r html -r lcov --src src node ./bin/index.js --base everything --description ${description} --mode initialize --owner ${owner} --title ${title} --repository ${repository} --exclude-contributors --skip-github-api --skip-removal --skip-restore`;
52+
})`c8 -o ./coverage-initialize -r html -r lcov --src src node ./bin/index.js --base everything --description ${description} --mode initialize --owner ${owner} --title ${title} --repository ${repository} --skip-all-contributors-api --skip-github-api --skip-removal --skip-restore`;

script/migrate-test-e2e.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const title = "Create TypeScript App";
1111

1212
await $({
1313
stdio: "inherit",
14-
})`c8 -o ./coverage-migrate -r html -r lcov --src src node ./bin/index.js --base everything --mode migrate --description ${description} --email-github ${emailGithub} --email-npm ${emailNpm} --owner ${owner} --title ${title} --repository ${repository} --exclude-contributors --skip-github-api --skip-install`;
14+
})`c8 -o ./coverage-migrate -r html -r lcov --src src node ./bin/index.js --base everything --mode migrate --description ${description} --email-github ${emailGithub} --email-npm ${emailNpm} --owner ${owner} --title ${title} --repository ${repository} --skip-all-contributors-api --skip-github-api --skip-install`;
1515

1616
const { stdout: gitStatus } = await $`git status`;
1717
console.log(`Stdout from running \`git status\`:\n${gitStatus}`);

src/create/createRerunSuggestion.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const options = {
1313
github: "[email protected]",
1414
1515
},
16+
excludeAllContributors: true,
1617
excludeCompliance: true,
17-
excludeContributors: true,
1818
excludeLintJSDoc: true,
1919
excludeLintJson: true,
2020
excludeLintKnip: true,
@@ -45,7 +45,7 @@ describe("createRerunSuggestion", () => {
4545
const actual = createRerunSuggestion(options);
4646

4747
expect(actual).toMatchInlineSnapshot(
48-
'"npx create-typescript-app --mode create --base everything --access public --author TestAuthor --create-repository true --description \\"Test description.\\" --email-github [email protected] --email-npm [email protected] --exclude-compliance true --exclude-contributors true --exclude-lint-jsdoc true --exclude-lint-json true --exclude-lint-knip true --exclude-lint-package-json true --exclude-lint-perfectionist true --mode create --owner TestOwner --repository test-repository --skip-github-api true --skip-install true --skip-removal true --title \\"Test Title\\""',
48+
'"npx create-typescript-app --mode create --base everything --access public --author TestAuthor --create-repository true --description \\"Test description.\\" --email-github [email protected] --email-npm [email protected] --exclude-all-contributors true --exclude-compliance true --exclude-lint-jsdoc true --exclude-lint-json true --exclude-lint-knip true --exclude-lint-package-json true --exclude-lint-perfectionist true --mode create --owner TestOwner --repository test-repository --skip-github-api true --skip-install true --skip-removal true --title \\"Test Title\\""',
4949
);
5050
});
5151

@@ -60,7 +60,7 @@ describe("createRerunSuggestion", () => {
6060
});
6161

6262
expect(actual).toMatchInlineSnapshot(
63-
'"npx create-typescript-app --mode initialize --base everything --access public --author TestAuthor --create-repository true --description \\"Test description.\\" --email-github [email protected] --email-npm [email protected] --exclude-compliance true --exclude-contributors true --exclude-lint-jsdoc true --exclude-lint-json true --exclude-lint-knip true --exclude-lint-package-json true --exclude-lint-perfectionist true --logo test/src.png --logo-alt \\"Test alt.\\" --mode initialize --owner TestOwner --repository test-repository --skip-github-api true --skip-install true --skip-removal true --title \\"Test Title\\""',
63+
'"npx create-typescript-app --mode initialize --base everything --access public --author TestAuthor --create-repository true --description \\"Test description.\\" --email-github [email protected] --email-npm [email protected] --exclude-all-contributors true --exclude-compliance true --exclude-lint-jsdoc true --exclude-lint-json true --exclude-lint-knip true --exclude-lint-package-json true --exclude-lint-perfectionist true --logo test/src.png --logo-alt \\"Test alt.\\" --mode initialize --owner TestOwner --repository test-repository --skip-github-api true --skip-install true --skip-removal true --title \\"Test Title\\""',
6464
);
6565
});
6666

@@ -74,7 +74,7 @@ describe("createRerunSuggestion", () => {
7474
});
7575

7676
expect(actual).toMatchInlineSnapshot(
77-
'"npx create-typescript-app --mode initialize --base everything --access public --author TestAuthor --create-repository true --description \\"Test description.\\" --email-github [email protected] --email-npm [email protected] --exclude-compliance true --exclude-contributors true --exclude-lint-jsdoc true --exclude-lint-json true --exclude-lint-knip true --exclude-lint-md true --exclude-lint-package-json true --exclude-lint-perfectionist true --exclude-lint-spelling true --mode initialize --owner TestOwner --repository test-repository --skip-github-api true --skip-install true --skip-removal true --title \\"Test Title\\""',
77+
'"npx create-typescript-app --mode initialize --base everything --access public --author TestAuthor --create-repository true --description \\"Test description.\\" --email-github [email protected] --email-npm [email protected] --exclude-all-contributors true --exclude-compliance true --exclude-lint-jsdoc true --exclude-lint-json true --exclude-lint-knip true --exclude-lint-md true --exclude-lint-package-json true --exclude-lint-perfectionist true --exclude-lint-spelling true --mode initialize --owner TestOwner --repository test-repository --skip-github-api true --skip-install true --skip-removal true --title \\"Test Title\\""',
7878
);
7979
});
8080
});

src/create/createWithOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function createWithOptions({ github, options }: GitHubAndOptions) {
2727
],
2828
]);
2929

30-
if (!options.excludeContributors) {
30+
if (!options.excludeAllContributors && !options.skipAllContributorsApi) {
3131
await withSpinner("Adding contributors to table", async () => {
3232
await addToolAllContributors(options.owner);
3333
});

src/initialize/initializeWithOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function initializeWithOptions({
3333
["Resetting Git tags", resetGitTags],
3434
]);
3535

36-
if (!options.excludeContributors) {
36+
if (!options.excludeAllContributors) {
3737
await withSpinner("Updating existing contributor details", async () => {
3838
await addOwnerAsAllContributor(options.owner);
3939
});

src/migrate/migrateWithOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function migrateWithOptions({
4848
});
4949
}
5050

51-
if (!options.excludeContributors) {
51+
if (!options.excludeAllContributors && !options.skipAllContributorsApi) {
5252
await withSpinner("Detecting existing contributors", async () =>
5353
detectExistingContributors(github?.auth, options),
5454
);

src/shared/options/args.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const allArgOptions = {
77
email: { type: "string" },
88
"email-github": { type: "string" },
99
"email-npm": { type: "string" },
10+
"exclude-all-contributors": { type: "boolean" },
1011
"exclude-compliance": { type: "boolean" },
11-
"exclude-contributors": { type: "boolean" },
1212
"exclude-lint-deprecation": { type: "boolean" },
1313
"exclude-lint-eslint": { type: "boolean" },
1414
"exclude-lint-jsdoc": { type: "boolean" },
@@ -32,6 +32,7 @@ export const allArgOptions = {
3232
mode: { type: "string" },
3333
owner: { type: "string" },
3434
repository: { type: "string" },
35+
"skip-all-contributors-api": { type: "boolean" },
3536
"skip-github-api": { type: "boolean" },
3637
"skip-install": { type: "boolean" },
3738
"skip-removal": { type: "boolean" },

src/shared/options/augmentOptionsWithExcludes.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import { augmentOptionsWithExcludes } from "./augmentOptionsWithExcludes.js";
66
const optionsBase = {
77
access: "public",
88
author: undefined,
9-
base: undefined,
9+
base: "everything",
1010
createRepository: undefined,
1111
description: "",
1212
email: {
1313
github: "[email protected]",
1414
1515
},
16+
excludeAllContributors: undefined,
1617
excludeCompliance: undefined,
17-
excludeContributors: undefined,
1818
excludeLintDeprecation: undefined,
1919
excludeLintESLint: undefined,
2020
excludeLintJSDoc: undefined,
@@ -94,8 +94,8 @@ describe("augmentOptionsWithExcludes", () => {
9494

9595
expect(actual).toEqual({
9696
...options,
97+
excludeAllContributors: true,
9798
excludeCompliance: true,
98-
excludeContributors: true,
9999
excludeLintDeprecation: true,
100100
excludeLintESLint: true,
101101
excludeLintJSDoc: true,

src/shared/options/augmentOptionsWithExcludes.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ interface ExclusionDescription {
1313
type ExclusionKey = keyof Options & `exclude${string}`;
1414

1515
const exclusionDescriptions: Record<ExclusionKey, ExclusionDescription> = {
16+
excludeAllContributors: {
17+
hint: "--exclude-all-contributors",
18+
label:
19+
"Add all-contributors to track contributions and display them in a README.md table.",
20+
},
1621
excludeCompliance: {
1722
hint: "--exclude-compliance",
1823
label:
1924
"Add a GitHub Actions workflow to verify that PRs match an expected format.",
2025
uncommon: true,
2126
},
22-
excludeContributors: {
23-
hint: "--exclude-contributors",
24-
label:
25-
"Add all-contributors to track contributions and display them in a README.md table.",
26-
},
2727
excludeLintDeprecation: {
2828
hint: "--exclude-lint-deprecation",
2929
label:

src/shared/options/optionsSchema.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export const optionsSchemaShape = {
1919
npm: z.string().email(),
2020
})
2121
.optional(),
22+
excludeAllContributors: z.boolean().optional(),
2223
excludeCompliance: z.boolean().optional(),
23-
excludeContributors: z.boolean().optional(),
2424
excludeLintDeprecation: z.boolean().optional(),
2525
excludeLintESLint: z.boolean().optional(),
2626
excludeLintJSDoc: z.boolean().optional(),
@@ -46,6 +46,7 @@ export const optionsSchemaShape = {
4646
.optional(),
4747
owner: z.string().optional(),
4848
repository: z.string().optional(),
49+
skipAllContributorsApi: z.boolean().optional(),
4950
skipGitHubApi: z.boolean().optional(),
5051
skipInstall: z.boolean().optional(),
5152
skipRemoval: z.boolean().optional(),

src/shared/options/readOptions.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const emptyOptions = {
1111
createRepository: undefined,
1212
description: undefined,
1313
email: undefined,
14+
excludeAllContributors: undefined,
1415
excludeCompliance: undefined,
15-
excludeContributors: undefined,
1616
excludeLintDeprecation: undefined,
1717
excludeLintESLint: undefined,
1818
excludeLintJSDoc: undefined,
@@ -32,6 +32,7 @@ const emptyOptions = {
3232
funding: undefined,
3333
owner: undefined,
3434
repository: undefined,
35+
skipAllContributorsApi: undefined,
3536
skipGitHubApi: undefined,
3637
skipInstall: undefined,
3738
skipRemoval: undefined,

src/shared/options/readOptions.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export async function readOptions(
5656
npm: values.email ?? values["email-npm"],
5757
}
5858
: undefined,
59+
excludeAllContributors: values["exclude-all-contributors"],
5960
excludeCompliance: values["exclude-compliance"],
60-
excludeContributors: values["exclude-contributors"],
6161
excludeLintDeprecation: values["exclude-lint-deprecation"],
6262
excludeLintESLint: values["exclude-lint-eslint"],
6363
excludeLintJSDoc: values["exclude-lint-jsdoc"],
@@ -77,6 +77,7 @@ export async function readOptions(
7777
funding: values.funding,
7878
owner: values.owner,
7979
repository: values.repository,
80+
skipAllContributorsApi: values["skip-all-contributors-api"],
8081
skipGitHubApi: values["skip-github-api"],
8182
skipInstall: values["skip-install"],
8283
skipRemoval: values["skip-removal"],

src/shared/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export interface Options {
4040
createRepository?: boolean;
4141
description: string;
4242
email: OptionsEmail;
43+
excludeAllContributors?: boolean;
4344
excludeCompliance?: boolean;
44-
excludeContributors?: boolean;
4545
excludeLintDeprecation?: boolean;
4646
excludeLintESLint?: boolean;
4747
excludeLintJSDoc?: boolean;
@@ -64,6 +64,7 @@ export interface Options {
6464
mode: Mode;
6565
owner: string;
6666
repository: string;
67+
skipAllContributorsApi?: boolean;
6768
skipGitHubApi?: boolean;
6869
skipInstall?: boolean;
6970
skipRemoval?: boolean;

src/steps/finalizeDependencies.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const options = {
2626
github: "[email protected]",
2727
2828
},
29+
excludeAllContributors: undefined,
2930
excludeCompliance: undefined,
30-
excludeContributors: undefined,
3131
excludeLintJson: undefined,
3232
excludeLintKnip: undefined,
3333
excludeLintMd: undefined,
@@ -71,8 +71,8 @@ describe("finalize", () => {
7171
it("installs the base list of commands when all options are enabled", async () => {
7272
await finalizeDependencies({
7373
...options,
74+
excludeAllContributors: true,
7475
excludeCompliance: true,
75-
excludeContributors: true,
7676
excludeLintJson: true,
7777
excludeLintKnip: true,
7878
excludeLintMd: true,

src/steps/finalizeDependencies.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function finalizeDependencies(options: Options) {
2121
"prettier-plugin-packagejson",
2222
"tsup",
2323
"typescript",
24-
...(options.excludeContributors ? [] : ["all-contributors-cli"]),
24+
...(options.excludeAllContributors ? [] : ["all-contributors-cli"]),
2525
...(options.excludeLintJson
2626
? []
2727
: ["eslint-plugin-jsonc", "jsonc-eslint-parser"]),
@@ -68,7 +68,7 @@ export async function finalizeDependencies(options: Options) {
6868

6969
await execaCommand(`pnpm add ${devDependencies} -D`);
7070

71-
if (!options.excludeContributors) {
71+
if (!options.excludeAllContributors) {
7272
await execaCommand(`npx all-contributors-cli generate`);
7373
await removeDependencies(
7474
["all-contributors-cli", "all-contributors-for-repository"],

src/steps/updateLocalFiles.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const options = {
2929
github: "[email protected]",
3030
3131
},
32+
excludeAllContributors: undefined,
3233
excludeCompliance: undefined,
33-
excludeContributors: undefined,
3434
excludeLintJson: undefined,
3535
excludeLintKnip: undefined,
3636
excludeLintMd: undefined,

src/steps/writeReadme/generateTopContent.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const optionsBase = {
1313
github: "[email protected]",
1414
1515
},
16+
excludeAllContributors: undefined,
1617
excludeCompliance: undefined,
17-
excludeContributors: undefined,
1818
excludeLintJson: undefined,
1919
excludeLintKnip: undefined,
2020
excludeLintMd: undefined,

src/steps/writeReadme/generateTopContent.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function generateTopContent(options: Options, existingBadges: string[]) {
2323

2424
for (const [badgeLine, existingMatcher] of [
2525
[
26-
!options.excludeContributors &&
26+
!options.excludeAllContributors &&
2727
`<a href="#contributors" target="_blank">
2828
<!-- prettier-ignore-start -->
2929
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

0 commit comments

Comments
 (0)