Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: split contributors option into exclude-all-contributors and --skip-all-contributors-api #899

Merged
merged 5 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"pnpm-lock.yaml"
],
"words": [
"allcontributors",
"apexskier",
"Codecov",
"codespace",
"commitlint",
Expand All @@ -20,11 +22,14 @@
"knip",
"lcov",
"markdownlintignore",
"mtfoley",
"npmignore",
"npmjs",
"npmpackagejsonlintrc",
"outro",
"packagejson",
"quickstart",
"tada",
"tsup",
"Unstaged",
"wontfix"
Expand Down
4 changes: 2 additions & 2 deletions docs/Creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Hooray! 🥳
You can explicitly provide some or all of the options the script would prompt for as command-line flags.
See [Options.md](./Options.md).

For example, running the creation script and skipping all APIs:
For example, running the creation script and skipping all GitHub APIs:

```shell
npx create-typescript-app --mode create --exclude-contributors --skip-github-api
npx create-typescript-app --mode create --skip-all-contributors-api --skip-github-api
```
4 changes: 2 additions & 2 deletions docs/Initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ See [Options.md](./Options.md).

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

For example, running the initialization script and skipping all APIs:
For example, running the initialization script and skipping all GitHub APIs:

```shell
pnpm run initialize --exclude-contributors --skip-github-api
pnpm run initialize --skip-all-contributors-api --skip-github-api
```
4 changes: 2 additions & 2 deletions docs/Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ npx create-typescript-app
You can explicitly provide some or all of the options the script would prompt for as command-line flags.
See [Options.md](./Options.md).

For example, running the migration script and skipping all APIs:
For example, running the migration script and skipping all GitHub APIs:

```shell
npx create-typescript-app --mode migrate --exclude-contributors --skip-github-api
npx create-typescript-app --mode migrate --skip-all-contributors-api --skip-github-api
```
10 changes: 5 additions & 5 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ The setup scripts can be directed with CLI flags to opt out tooling portions and
The setup scripts normally will prompt you to select how much of the tooling you'd like to enable in a new repository.
Alternately, you can bypass that prompt by providing any number of the following CLI flags:

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

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

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

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

```shell
npx create-typescript-app --exclude-contributors --skip-github-api --skip-install
npx create-typescript-app --skip-all-contributors-api --skip-github-api --skip-install
```

> 💡 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.
> 💡 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.

### Skipping Local Changes

Expand Down
2 changes: 1 addition & 1 deletion script/create-test-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ await $`rm -rf ${repository}`;

await $({
stdio: "inherit",
})`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`;
})`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`;

process.chdir(repository);

Expand Down
4 changes: 2 additions & 2 deletions script/initialize-test-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const repository = "new-repository-test";
// First we run initialize to modifies the local repo, so we can test the changes
await $({
stdio: "inherit",
})`node ./bin/index.js --description ${description} --base everything --mode initialize --owner ${owner} --title ${title} --repository ${repository} --skip-github-api --skip-restore`;
})`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`;

const newPackageJson = JSON.parse(
(await fs.readFile("./package.json")).toString(),
Expand Down Expand Up @@ -49,4 +49,4 @@ await $`pnpm i`;
await $`pnpm run build`;
await $({
stdio: "inherit",
})`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`;
})`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`;
2 changes: 1 addition & 1 deletion script/migrate-test-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const title = "Create TypeScript App";

await $({
stdio: "inherit",
})`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`;
})`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`;

const { stdout: gitStatus } = await $`git status`;
console.log(`Stdout from running \`git status\`:\n${gitStatus}`);
Expand Down
8 changes: 4 additions & 4 deletions src/create/createRerunSuggestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const options = {
github: "[email protected]",
npm: "[email protected]",
},
excludeAllContributors: true,
excludeCompliance: true,
excludeContributors: true,
excludeLintJSDoc: true,
excludeLintJson: true,
excludeLintKnip: true,
Expand Down Expand Up @@ -45,7 +45,7 @@ describe("createRerunSuggestion", () => {
const actual = createRerunSuggestion(options);

expect(actual).toMatchInlineSnapshot(
'"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\\""',
'"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\\""',
);
});

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

expect(actual).toMatchInlineSnapshot(
'"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\\""',
'"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\\""',
);
});

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

expect(actual).toMatchInlineSnapshot(
'"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\\""',
'"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\\""',
);
});
});
2 changes: 1 addition & 1 deletion src/create/createWithOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function createWithOptions({ github, options }: GitHubAndOptions) {
],
]);

if (!options.excludeContributors) {
if (!options.excludeAllContributors && !options.skipAllContributorsApi) {
await withSpinner("Adding contributors to table", async () => {
await addToolAllContributors(options.owner);
});
Expand Down
2 changes: 1 addition & 1 deletion src/initialize/initializeWithOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function initializeWithOptions({
["Resetting Git tags", resetGitTags],
]);

if (!options.excludeContributors) {
if (!options.excludeAllContributors) {
await withSpinner("Updating existing contributor details", async () => {
await addOwnerAsAllContributor(options.owner);
});
Expand Down
2 changes: 1 addition & 1 deletion src/migrate/migrateWithOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function migrateWithOptions({
});
}

if (!options.excludeContributors) {
if (!options.excludeAllContributors && !options.skipAllContributorsApi) {
await withSpinner("Detecting existing contributors", async () =>
detectExistingContributors(github?.auth, options),
);
Expand Down
3 changes: 2 additions & 1 deletion src/shared/options/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const allArgOptions = {
email: { type: "string" },
"email-github": { type: "string" },
"email-npm": { type: "string" },
"exclude-all-contributors": { type: "boolean" },
"exclude-compliance": { type: "boolean" },
"exclude-contributors": { type: "boolean" },
"exclude-lint-deprecation": { type: "boolean" },
"exclude-lint-eslint": { type: "boolean" },
"exclude-lint-jsdoc": { type: "boolean" },
Expand All @@ -32,6 +32,7 @@ export const allArgOptions = {
mode: { type: "string" },
owner: { type: "string" },
repository: { type: "string" },
"skip-all-contributors-api": { type: "boolean" },
"skip-github-api": { type: "boolean" },
"skip-install": { type: "boolean" },
"skip-removal": { type: "boolean" },
Expand Down
6 changes: 3 additions & 3 deletions src/shared/options/augmentOptionsWithExcludes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { augmentOptionsWithExcludes } from "./augmentOptionsWithExcludes.js";
const optionsBase = {
access: "public",
author: undefined,
base: undefined,
base: "everything",
createRepository: undefined,
description: "",
email: {
github: "[email protected]",
npm: "[email protected]",
},
excludeAllContributors: undefined,
excludeCompliance: undefined,
excludeContributors: undefined,
excludeLintDeprecation: undefined,
excludeLintESLint: undefined,
excludeLintJSDoc: undefined,
Expand Down Expand Up @@ -94,8 +94,8 @@ describe("augmentOptionsWithExcludes", () => {

expect(actual).toEqual({
...options,
excludeAllContributors: true,
excludeCompliance: true,
excludeContributors: true,
excludeLintDeprecation: true,
excludeLintESLint: true,
excludeLintJSDoc: true,
Expand Down
10 changes: 5 additions & 5 deletions src/shared/options/augmentOptionsWithExcludes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ interface ExclusionDescription {
type ExclusionKey = keyof Options & `exclude${string}`;

const exclusionDescriptions: Record<ExclusionKey, ExclusionDescription> = {
excludeAllContributors: {
hint: "--exclude-all-contributors",
label:
"Add all-contributors to track contributions and display them in a README.md table.",
},
excludeCompliance: {
hint: "--exclude-compliance",
label:
"Add a GitHub Actions workflow to verify that PRs match an expected format.",
uncommon: true,
},
excludeContributors: {
hint: "--exclude-contributors",
label:
"Add all-contributors to track contributions and display them in a README.md table.",
},
excludeLintDeprecation: {
hint: "--exclude-lint-deprecation",
label:
Expand Down
3 changes: 2 additions & 1 deletion src/shared/options/optionsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const optionsSchemaShape = {
npm: z.string().email(),
})
.optional(),
excludeAllContributors: z.boolean().optional(),
excludeCompliance: z.boolean().optional(),
excludeContributors: z.boolean().optional(),
excludeLintDeprecation: z.boolean().optional(),
excludeLintESLint: z.boolean().optional(),
excludeLintJSDoc: z.boolean().optional(),
Expand All @@ -46,6 +46,7 @@ export const optionsSchemaShape = {
.optional(),
owner: z.string().optional(),
repository: z.string().optional(),
skipAllContributorsApi: z.boolean().optional(),
skipGitHubApi: z.boolean().optional(),
skipInstall: z.boolean().optional(),
skipRemoval: z.boolean().optional(),
Expand Down
3 changes: 2 additions & 1 deletion src/shared/options/readOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const emptyOptions = {
createRepository: undefined,
description: undefined,
email: undefined,
excludeAllContributors: undefined,
excludeCompliance: undefined,
excludeContributors: undefined,
excludeLintDeprecation: undefined,
excludeLintESLint: undefined,
excludeLintJSDoc: undefined,
Expand All @@ -32,6 +32,7 @@ const emptyOptions = {
funding: undefined,
owner: undefined,
repository: undefined,
skipAllContributorsApi: undefined,
skipGitHubApi: undefined,
skipInstall: undefined,
skipRemoval: undefined,
Expand Down
3 changes: 2 additions & 1 deletion src/shared/options/readOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export async function readOptions(
npm: values.email ?? values["email-npm"],
}
: undefined,
excludeAllContributors: values["exclude-all-contributors"],
excludeCompliance: values["exclude-compliance"],
excludeContributors: values["exclude-contributors"],
excludeLintDeprecation: values["exclude-lint-deprecation"],
excludeLintESLint: values["exclude-lint-eslint"],
excludeLintJSDoc: values["exclude-lint-jsdoc"],
Expand All @@ -77,6 +77,7 @@ export async function readOptions(
funding: values.funding,
owner: values.owner,
repository: values.repository,
skipAllContributorsApi: values["skip-all-contributors-api"],
skipGitHubApi: values["skip-github-api"],
skipInstall: values["skip-install"],
skipRemoval: values["skip-removal"],
Expand Down
3 changes: 2 additions & 1 deletion src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export interface Options {
createRepository?: boolean;
description: string;
email: OptionsEmail;
excludeAllContributors?: boolean;
excludeCompliance?: boolean;
excludeContributors?: boolean;
excludeLintDeprecation?: boolean;
excludeLintESLint?: boolean;
excludeLintJSDoc?: boolean;
Expand All @@ -64,6 +64,7 @@ export interface Options {
mode: Mode;
owner: string;
repository: string;
skipAllContributorsApi?: boolean;
skipGitHubApi?: boolean;
skipInstall?: boolean;
skipRemoval?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/steps/finalizeDependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const options = {
github: "[email protected]",
npm: "[email protected]",
},
excludeAllContributors: undefined,
excludeCompliance: undefined,
excludeContributors: undefined,
excludeLintJson: undefined,
excludeLintKnip: undefined,
excludeLintMd: undefined,
Expand Down Expand Up @@ -71,8 +71,8 @@ describe("finalize", () => {
it("installs the base list of commands when all options are enabled", async () => {
await finalizeDependencies({
...options,
excludeAllContributors: true,
excludeCompliance: true,
excludeContributors: true,
excludeLintJson: true,
excludeLintKnip: true,
excludeLintMd: true,
Expand Down
4 changes: 2 additions & 2 deletions src/steps/finalizeDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function finalizeDependencies(options: Options) {
"prettier-plugin-packagejson",
"tsup",
"typescript",
...(options.excludeContributors ? [] : ["all-contributors-cli"]),
...(options.excludeAllContributors ? [] : ["all-contributors-cli"]),
...(options.excludeLintJson
? []
: ["eslint-plugin-jsonc", "jsonc-eslint-parser"]),
Expand Down Expand Up @@ -68,7 +68,7 @@ export async function finalizeDependencies(options: Options) {

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

if (!options.excludeContributors) {
if (!options.excludeAllContributors) {
await execaCommand(`npx all-contributors-cli generate`);
await removeDependencies(
["all-contributors-cli", "all-contributors-for-repository"],
Expand Down
2 changes: 1 addition & 1 deletion src/steps/updateLocalFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const options = {
github: "[email protected]",
npm: "[email protected]",
},
excludeAllContributors: undefined,
excludeCompliance: undefined,
excludeContributors: undefined,
excludeLintJson: undefined,
excludeLintKnip: undefined,
excludeLintMd: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/steps/writeReadme/generateTopContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const optionsBase = {
github: "[email protected]",
npm: "[email protected]",
},
excludeAllContributors: undefined,
excludeCompliance: undefined,
excludeContributors: undefined,
excludeLintJson: undefined,
excludeLintKnip: undefined,
excludeLintMd: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/steps/writeReadme/generateTopContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function generateTopContent(options: Options, existingBadges: string[]) {

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