Skip to content

Commit 791332d

Browse files
feat: add hydration script for existing repos (#441)
## PR Checklist - [x] Addresses an existing open issue: fixes #374 - [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 Adds the script as a `bin` command you can run with `npx template-typescript-node-package`. Which bumps up a few dependencies from `devDependency` to `dependency`. This has the nice side effect of standardizing formatting for an assortment of files. Hence the large _Files changed_ count outside of the new `src/hydrate/` directory. Things I've intentionally not done here, so they can be filed as followup issues: * Filling in unit test coverage * Running [`all-contributors-for-repository`](https://github.com/JoshuaKGoldberg/all-contributors-for-repository) to fill in the `.all-contributorsrc` * Removing existing image badges from the README.md * Removing existing `CODE_OF_CONDUCT.md` * Use the GitHub API to set up labels and other repo settings * Run `pnpm run lint --fix` * CLI flag for hydration to just refresh files locally * Getting hydration to the point where it doesn't make changes in this repo _(is that possible?)_ * A copy&pastable script to run in a repo to update it to the latest tooling (migrations?!)
1 parent 3ee08b7 commit 791332d

Some content is hidden

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

62 files changed

+2507
-111
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ module.exports = {
7979
},
8080
},
8181
{
82+
extends: ["plugin:yml/standard", "plugin:yml/prettier"],
8283
files: ["**/*.{yml,yaml}"],
8384
parser: "yaml-eslint-parser",
84-
extends: ["plugin:yml/standard", "plugin:yml/prettier"],
8585
rules: {
8686
"yml/file-extension": ["error", { extension: "yml" }],
8787
"yml/sort-keys": [

.github/CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ representative at an online or offline event.
6060

6161
Instances of abusive, harassing, or otherwise unacceptable behavior may be
6262
reported to the community leaders responsible for enforcement at
63-
git@joshuakgoldberg.com.
63+
npm@joshuakgoldberg.com.
6464
All complaints will be reviewed and investigated promptly and fairly.
6565

6666
All community leaders are obligated to respect the privacy and security of the

.github/DEVELOPMENT.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,38 @@ Calls to `console.log`, `console.warn`, and other console methods will cause a t
6767
This repository includes a [VS Code launch configuration](https://code.visualstudio.com/docs/editor/debugging) for debugging unit tests.
6868
To launch it, open a test file, then run _Debug Current Test File_ from the VS Code Debug panel (or press F5).
6969

70+
## The Hydration Script
71+
72+
This template's "hydration" script is located in `src/hydrate/`.
73+
It needs to be [built](#building) before it can be run.
74+
75+
Be warned that running the hydration script in a repository -including this one- will modify that repository.
76+
To test out the script, you may want to create a new test repository to run on:
77+
78+
```shell
79+
cd ..
80+
mkdir temp
81+
cd temp
82+
echo node_modules > .gitignore
83+
git init
84+
npm init --yes
85+
```
86+
87+
Then, in that directory, you can directly call the hydration script:
88+
89+
```shell
90+
node ../template-typescript-node-package -- description "Hooray, trying things out locally."
91+
```
92+
93+
Along with the hydration script itself, end-to-end tests are removed on package setup.
94+
95+
## The Setup Script
96+
97+
This template's "setup" script is located in `script/`.
98+
7099
### Testing the Setup Script
71100

72-
In addition to unit tests, this template also includes an "end-to-end" test for `script/setup.js`.
101+
This template source includes an "end-to-end" test for `script/setup.js`.
73102
You can run it locally on the command-line:
74103

75104
```shell
@@ -81,4 +110,4 @@ That end-to-end test executes `script/setup-test-e2e.js`, which:
81110
1. Runs the setup script using `--skip-api`
82111
2. Checks that the local repository's files were changed correctly (e.g. removed setup-only files)
83112

84-
As with the setup script itself, end-to-end tests are removed on package setup.
113+
Along with the setup script itself, end-to-end tests are removed on package setup.

.github/actions/prepare/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
description: Prepares the repo for a typical CI job
22

33
name: Prepare
4+
45
runs:
56
steps:
67
- uses: pnpm/action-setup@v2

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ name: Build
1111

1212
on:
1313
pull_request: ~
14-
1514
push:
1615
branches:
1716
- main

.github/workflows/compliance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
- uses: mtfoley/pr-compliance-action@main
66
with:
77
body-auto-close: false
8-
ignore-authors: |
8+
ignore-authors: |-
99
allcontributors
1010
allcontributors[bot]
1111
renovate

.github/workflows/hydrate.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
jobs:
2+
hydrate:
3+
runs-on: ubuntu-latest
4+
steps:
5+
- uses: actions/checkout@v3
6+
- uses: ./.github/actions/prepare
7+
- run: pnpm run build
8+
- run: pnpm run setup:test
9+
10+
name: Test Hydrate Script
11+
12+
on:
13+
pull_request: ~
14+
15+
push:
16+
branches:
17+
- main

.github/workflows/knip.yml renamed to .github/workflows/lint-knip.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
jobs:
2-
knip:
2+
lint_knip:
33
runs-on: ubuntu-latest
44
steps:
55
- uses: actions/checkout@v3
@@ -10,7 +10,6 @@ name: Lint Knip
1010

1111
on:
1212
pull_request: ~
13-
1413
push:
1514
branches:
1615
- main

.github/workflows/markdown.yml renamed to .github/workflows/lint-markdown.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
jobs:
2-
markdown:
2+
lint_markdown:
33
runs-on: ubuntu-latest
44
steps:
55
- uses: actions/checkout@v3
@@ -10,7 +10,6 @@ name: Lint Markdown
1010

1111
on:
1212
pull_request: ~
13-
1413
push:
1514
branches:
1615
- main

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
jobs:
2-
package:
2+
lint_package:
33
runs-on: ubuntu-latest
44
steps:
55
- uses: actions/checkout@v3
@@ -10,7 +10,6 @@ name: Lint Package
1010

1111
on:
1212
pull_request: ~
13-
1413
push:
1514
branches:
1615
- main

0 commit comments

Comments
 (0)