Skip to content

Commit a386c87

Browse files
feat: add --exclude-* with a fallback prompt (#695)
## PR Checklist - [x] Addresses an existing open issue: fixes #694 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/template-typescript-node-package/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Drastically streamlines and simplifies the way defaults/overrides are provided to `readInputs`. In fact, they're no longer take in at all - all three setup scripts now use the same kinds of default gathering! This way they all use whatever information is available to them. Updates the docs to reflect this standardization. Renames `lint:package` to `lint:package-json`. `--exclude-lint-package` was too visually similar to `--exclude-lint-packages` for comfort. Adds a `--base` CLI flag that can be set as `"everything"`, `"minimal"`, or `"prompt"`.
1 parent 4aa3fb8 commit a386c87

File tree

112 files changed

+2239
-2398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2239
-2398
lines changed

.github/DEVELOPMENT.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Each should be shown in VS Code, and can be run manually on the command-line:
4444
- `pnpm lint` ([ESLint](https://eslint.org) with [typescript-eslint](https://typescript-eslint.io)): Lints JavaScript and TypeScript source files
4545
- `pnpm lint:knip` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports
4646
- `pnpm lint:md` ([Markdownlint](https://github.com/DavidAnson/markdownlint)): Checks Markdown source files
47-
- `pnpm lint:package` ([npm-package-json-lint](https://npmpackagejsonlint.org/)): Lints the `package.json` file
47+
- `pnpm lint:package-json` ([npm-package-json-lint](https://npmpackagejsonlint.org/)): Lints the `package.json` file
4848
- `pnpm lint:packages` ([pnpm dedupe --check](https://pnpm.io/cli/dedupe)): Checks for unnecessarily duplicated packages in the `pnpm-lock.yml` file
4949
- `pnpm lint:spelling` ([cspell](https://cspell.org)): Spell checks across all source files
5050

@@ -91,6 +91,15 @@ pnpm tsc --watch
9191

9292
As described in the `README.md` file and `docs/`, this template repository comes with three scripts that can set up an existing or new repository.
9393

94+
Each follows roughly the same general flow:
95+
96+
1. `bin/index.ts` uses `bin/mode.ts` determines which of the three setup scripts to run
97+
2. `readOptions` parses in options from local files, Git commands, npm APIs, and/or files on disk
98+
3. `runOrRestore` wraps the setup script's main logic in a friendly prompt wrapper
99+
4. The setup script wraps each portion of its main logic with `withSpinner`
100+
- Each step of setup logic is generally imported from within `src/steps`
101+
5. A call to `outro` summarizes the results for the user
102+
94103
> **Warning**
95104
> Each setup script overrides many files in the directory they're run in.
96105
> Make sure to save any changes you want to preserve before running them.

.github/workflows/lint-package.yml renamed to .github/workflows/lint-package-json.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ jobs:
44
steps:
55
- uses: actions/checkout@v3
66
- uses: ./.github/actions/prepare
7-
- run: pnpm lint:package
7+
- run: pnpm lint:package-json
88

9-
name: Lint Package
9+
name: Lint Package JSON
1010

1111
on:
1212
pull_request: ~

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ First make sure you have the following installed:
4040
- [Node.js](https://nodejs.org)
4141
- [pnpm](https://pnpm.io)
4242

43-
This repository comes with two scripts to set up an existing or new repository with tooling.
43+
This repository comes with three script forms to set up an existing or new repository with tooling.
4444
Use the corresponding docs page to get started:
4545

46-
- [Initializing from the template](./docs/InitializationFromTemplate.md): creating a new repository with the [_Use this template_](https://github.com/JoshuaKGoldberg/template-typescript-node-package/generate) button on GitHub _(recommended)_
47-
- [Initializing from the terminal](./docs/InitializationFromTerminal.md): creating a new repository locally on the command-line
48-
- [Migrating an existing repository](./docs/Migration.md): adding this template's tooling on top of an existing repository
46+
- [Creating from the terminal](./docs/Creation.md): creating a new repository locally on the command-line _(recommended)_
47+
- [Initializing from the template](./docs/Initialization.md): creating a new repository with the [_Use this template_](https://github.com/JoshuaKGoldberg/template-typescript-node-package/generate) button on GitHub
48+
- [Migrating an existing repository](./docs/Migrate.md): adding this template's tooling on top of an existing repository
4949

5050
## Explainer
5151

cspell.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"contributorsrc",
1616
"conventionalcommits",
1717
"execa",
18+
"joshuakgoldberg",
1819
"knip",
1920
"lcov",
2021
"markdownlintignore",

docs/Creation.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Creating from the Terminal
2+
3+
You can run `npx template-typescript-node-package` in your terminal to interactively create a new repository:
4+
5+
```shell
6+
npx template-typescript-node-package
7+
```
8+
9+
Then, go through the following two steps to set up required repository tooling on GitHub:
10+
11+
1. Create two tokens in [repository secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) _(unless you chose to opt out of releases)_:
12+
- `ACCESS_TOKEN`: A [GitHub PAT](https://github.com/settings/tokens/new) with _repo_ and _workflow_ permissions
13+
- `NPM_TOKEN`: An [npm access token](https://docs.npmjs.com/creating-and-viewing-access-tokens/) with _Automation_ permissions
14+
2. Install two GitHub apps:
15+
- [Codecov](https://github.com/marketplace/codecov) _(unless you chose to opt out of tests)_
16+
- [Renovate](https://github.com/marketplace/renovate) _(unless you chose to opt out of renovate)_
17+
18+
Your new repository will then be ready for development!
19+
Hooray! 🥳
20+
21+
## Options
22+
23+
You can explicitly provide some or all of the options the script would prompt for as command-line flags.
24+
See [Options.md](./Options.md).
25+
26+
For example, running the creation script and skipping all APIs:
27+
28+
```shell
29+
npx template-typescript-node-package --mode create --skip-contributors-data --skip-github-api
30+
```

docs/FAQs.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FAQs
22

3-
## Can I use <insert tool here&gt with this template?
3+
## Can I use _(insert tool here)_ with this template?
44

55
Yes!
66
After you set up a repository, you can substitute in any tools you'd like.
@@ -20,3 +20,15 @@ This repository is meant to serve as a starter that includes all the general too
2020
Each of the included tools exists for a good reason and provides real value.
2121

2222
If you don't want to use any particular tool, you can always remove it manually.
23+
24+
### Which tools can't I remove?
25+
26+
The following pieces of this template's tooling don't have options to be removed:
27+
28+
- Linting with ESLint and `pnpm run lint`
29+
- GitHub repository metadata such as the code of conduct and issue templates
30+
- Prettier and `pnpm run format`
31+
- tsup and `pnpm run build`
32+
- TypeScript and `pnpm run tsc`
33+
34+
If you have a strong desire to add an `--exclude-*` flag for any of them, please do [file a feature request](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues/new?assignees=&labels=type%3A+feature&projects=&template=03-feature.yml&title=%F0%9F%9A%80+Feature%3A+%3Cshort+description+of+the+feature%3E).

docs/Initialization.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Initializing from the Template
2+
3+
As an alternative to [creating with `npx template-typescript-node-package`](./Creation.md), the [_Use this template_](https://github.com/JoshuaKGoldberg/template-typescript-node-package/generate) button on GitHub can be used to quickly create a new repository from the template.
4+
You can set up the new repository locally by cloning it and installing packages:
5+
6+
```shell
7+
git clone https://github.com/YourUsername/YourRepositoryName
8+
cd YourRepositoryName
9+
pnpm i
10+
```
11+
12+
> 💡 If you don't want to clone it locally, you can always [develop in a codespace](https://docs.github.com/en/codespaces/developing-in-codespaces/developing-in-a-codespace) instead.
13+
14+
Once the repository's packages are installed, you can run `pnpm run initialize` to fill out your repository's details and install necessary packages.
15+
It will then remove itself and uninstall dependencies only used for initialization.
16+
17+
```shell
18+
pnpm run initialize
19+
```
20+
21+
Then, go through the following two steps to set up required repository tooling on GitHub:
22+
23+
1. Create two tokens in [repository secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) _(unless you chose to opt out of releases)_:
24+
- `ACCESS_TOKEN`: A [GitHub PAT](https://github.com/settings/tokens/new) with _repo_ and _workflow_ permissions
25+
- `NPM_TOKEN`: An [npm access token](https://docs.npmjs.com/creating-and-viewing-access-tokens/) with _Automation_ permissions
26+
2. Install two GitHub apps:
27+
- [Codecov](https://github.com/marketplace/codecov) _(unless you chose to opt out of tests)_
28+
- [Renovate](https://github.com/marketplace/renovate) _(unless you chose to opt out of renovate)_
29+
30+
Your new repository will then be ready for development!
31+
Hooray! 🥳
32+
33+
## Options
34+
35+
You can explicitly provide some or all of the options the script would prompt for as command-line flags.
36+
See [Options.md](./Options.md).
37+
38+
`pnpm run initialize` will set `--mode` to `initialize`.
39+
40+
For example, running the initialization script and skipping all APIs:
41+
42+
```shell
43+
pnpm run initialize --skip-contributors-data --skip-github-api
44+
```

docs/InitializationFromTemplate.md

-58
This file was deleted.

docs/InitializationFromTerminal.md

-49
This file was deleted.

docs/Migration.md

+6-41
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Migrating an Existing Repository
22

3-
If you have an existing repository that you'd like to give the files from this repository, you can run `npx template-typescript-node-package` in it to "hydrate" its tooling with this template's.
3+
If you have an existing repository that you'd like to give the files from this repository, you can run `npx template-typescript-node-package` in it to "migrate" its tooling to this template's.
44

55
```shell
66
npx template-typescript-node-package
@@ -11,48 +11,13 @@ npx template-typescript-node-package
1111
> You'll want to review each of the changes.
1212
> There will almost certainly be some incorrect changes you'll need to fix.
1313
14-
## Values
14+
## Options
1515

16-
Repository settings will be auto-filled from the repository's files if possible, but can be provided manually as well:
16+
You can explicitly provide some or all of the options the script would prompt for as command-line flags.
17+
See [Options.md](./Options.md).
1718

18-
- `--author` _(`string`)_: e.g. `"Josh Goldberg"`
19-
- `--description` _(`string`)_: e.g. `"A quickstart-friendly TypeScript template with comprehensive formatting, linting, releases, testing, and other great tooling built-in. ✨"`
20-
- `--email` _(`string`)_: e.g. `"[email protected]"`
21-
- `--funding` _(`string`, optional)_: e.g. `"JoshuaKGoldberg"`
22-
- `--owner` _(`string`)_: e.g. `"JoshuaKGoldberg"`
23-
- `--repository` _(`string`)_: e.g. `"template-typescript-node-package"`
24-
- `--title` _(`string`)_: e.g. `"Template TypeScript Node Package"`
25-
26-
For example, providing a `funding` value different from the `author`:
27-
28-
```shell
29-
npx template-typescript-node-package --funding MyOrganization
30-
```
31-
32-
The migration script by default will include all the features in this template.
33-
You can disable some of them on the command-line:
34-
35-
- `releases` _(`boolean`)_: Whether to include automated package publishing
36-
- `unitTests` _(`boolean`)_: Whether to include unit tests with code coverage tracking
37-
38-
```shell
39-
npx template-typescript-node-package --releases false --unitTests false
40-
```
41-
42-
After the migration script finishes aligning your repository's contents to the templates, it will call the [Initialization](./Initialization.md) script as well.
43-
It will forward any values you provided or it inferred from the repository.
44-
45-
### Skipping API Calls
46-
47-
You can prevent the migration script from making some network-based changes using any or all of the following CLI flags:
48-
49-
- `--skip-contributors` _(`boolean`)_: Skips detecting existing contributors with [`all-contributors-for-repository`](https://github.com/JoshuaKGoldberg/all-contributors-for-repository)
50-
- `--skip-github-api` _(`boolean`)_: Skips calling to GitHub APIs
51-
- `--skip-install` _(`boolean`)_: Skips installing all the new template packages with `pnpm`
19+
For example, running the migration script and skipping all APIs:
5220

5321
```shell
54-
npx template-typescript-node-package --skip-github-api --skip-install
22+
npx template-typescript-node-package --mode migrate --skip-contributors-data --skip-github-api
5523
```
56-
57-
> Tip: the `--skip-github-api` flag will cause all changes to be limited to your local repository.
58-
> That means you can test out the script with `npx template-typescript-node-package --skip-github-api`, then `git add -A; git reset --hard HEAD` to completely reset all changes.

0 commit comments

Comments
 (0)