@adamhl8/configs 0.27.3 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -8
- package/dist/configs/justfile.base.just +42 -0
- package/dist/configs/knip.base.d.ts +1 -1
- package/dist/configs/knip.base.js +2 -1
- package/dist/configs/knip.base.js.map +1 -1
- package/dist/configs/lefthook.base.yaml +1 -1
- package/dist/configs/release-it.base.d.ts +1 -1
- package/dist/configs/release-it.base.js +1 -1
- package/dist/configs/release-it.base.js.map +1 -1
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -6,6 +6,26 @@ Configs (`tsconfig`, `oxfmt`, `oxlint`, etc.) I use across my projects.
|
|
|
6
6
|
nub add -D @adamhl8/configs
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
### just
|
|
10
|
+
|
|
11
|
+
Scripts live in a shared [`just`](https://github.com/casey/just) base justfile instead of being copied into every project's `package.json`. Your `justfile`:
|
|
12
|
+
|
|
13
|
+
```just
|
|
14
|
+
import "node_modules/@adamhl8/configs/dist/configs/justfile.base.just"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
It provides `lint`, `build`, `test`, `bump-deps`, `release`, `release-run`, and `prepare`. Run `just` to list them. `build` only runs `tsdown` if the project has a `tsdown.config.ts`, so projects without a build step can use it as-is.
|
|
18
|
+
|
|
19
|
+
The only script left in `package.json` is `prepare`, which hands off to just:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
"scripts": {
|
|
23
|
+
"prepare": "just prepare"
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The base justfile puts `node_modules/.bin` on `PATH`, so recipes can call package bins directly, just like `package.json` scripts.
|
|
28
|
+
|
|
9
29
|
### tsconfig
|
|
10
30
|
|
|
11
31
|
```json
|
|
@@ -98,7 +118,7 @@ adamhl8-cliff --bumped-version
|
|
|
98
118
|
|
|
99
119
|
### lefthook
|
|
100
120
|
|
|
101
|
-
`lefthook.base.yaml` runs `lint` on pre-commit and `commitlint` on commit-msg. Extend it from your `lefthook.yaml`:
|
|
121
|
+
`lefthook.base.yaml` runs `just lint` on pre-commit and `commitlint` on commit-msg. Extend it from your `lefthook.yaml`:
|
|
102
122
|
|
|
103
123
|
```yaml
|
|
104
124
|
# lefthook.yaml
|
|
@@ -106,13 +126,13 @@ extends:
|
|
|
106
126
|
- node_modules/@adamhl8/configs/dist/configs/lefthook.base.yaml
|
|
107
127
|
```
|
|
108
128
|
|
|
109
|
-
`lefthook install` (
|
|
129
|
+
`lefthook install` (the base justfile's `prepare` recipe runs it) sets up the hooks.
|
|
110
130
|
|
|
111
131
|
## GitHub Actions
|
|
112
132
|
|
|
113
|
-
This repo hosts three reusable workflows you can call from other projects instead of copy/pasting them. The calling project must use `nub
|
|
133
|
+
This repo hosts three reusable workflows you can call from other projects instead of copy/pasting them. The calling project must use `nub`, have a `justfile` that imports the base justfile (see [just](#just)), and have a commitlint config (e.g. via these configs). The workflows install just themselves.
|
|
114
134
|
|
|
115
|
-
- `ci.yml`: runs `
|
|
135
|
+
- `ci.yml`: runs `build` (build + lint) on pushes/PRs and lints commit messages with commitlint
|
|
116
136
|
- `update-deps.yml`: weekly `bump-deps` run that opens a dependency-update PR
|
|
117
137
|
- `release.yml`: manually dispatched release where git-cliff sets the version, then publishes to npm and cuts a GitHub release (commit and tag signed)
|
|
118
138
|
|
|
@@ -151,9 +171,9 @@ jobs:
|
|
|
151
171
|
|
|
152
172
|
### Release
|
|
153
173
|
|
|
154
|
-
Manually dispatched. git-cliff computes the next version from the commits, then `release-it` bumps `package.json`, regenerates the changelog, commits and tags (both SSH-signed), publishes to npm, and cuts a GitHub release. There is no automatic trigger, so run it when a release is ready (the `release`
|
|
174
|
+
Manually dispatched. git-cliff computes the next version from the commits, then `release-it` bumps `package.json`, regenerates the changelog, commits and tags (both SSH-signed), publishes to npm, and cuts a GitHub release. There is no automatic trigger, so run it when a release is ready (the `release` recipe just does `gh workflow run release.yml`). A dispatch with no releasable commits fails fast at release-it's `Version not changed`.
|
|
155
175
|
|
|
156
|
-
Needs the `NPM_CI_TOKEN` and `CI_SIGNING_KEY` secrets (see [Secrets](#secrets)). The
|
|
176
|
+
Needs the `NPM_CI_TOKEN` and `CI_SIGNING_KEY` secrets (see [Secrets](#secrets)). The workflow runs the base justfile's `release-run` recipe: `release-it --ci -i "$(adamhl8-cliff --bumped-version)"`.
|
|
157
177
|
|
|
158
178
|
```yaml
|
|
159
179
|
# .github/workflows/release.yml
|
|
@@ -182,6 +202,6 @@ Configure these on each repo that uses the workflows (Settings -> Secrets and va
|
|
|
182
202
|
|
|
183
203
|
## Notes
|
|
184
204
|
|
|
185
|
-
The `prepare` script
|
|
205
|
+
The `prepare` script is `"prepare": "just prepare"`, which runs the base justfile's `prepare` recipe (`lefthook install`).
|
|
186
206
|
|
|
187
|
-
nub installs `package.json` bin executables into the local `node_modules/.bin`. This means that we can run something like `adamhl8-
|
|
207
|
+
nub installs `package.json` bin executables into the local `node_modules/.bin`. This means that we can run something like `adamhl8-cliff` directly instead of doing `src/adamhl8-cliff/index.ts`. That's why this repo overrides the `prepare` recipe to also run `tsdown`. Those executables need to be available.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# user-defined functions are unstable as of just 1.52
|
|
2
|
+
set unstable
|
|
3
|
+
set default-list
|
|
4
|
+
set allow-duplicate-recipes
|
|
5
|
+
set lazy
|
|
6
|
+
|
|
7
|
+
export PATH := justfile_directory() + "/node_modules/.bin:" + env("PATH")
|
|
8
|
+
|
|
9
|
+
# runs cmd if the [ ] condition holds, echoing cmd only when it runs
|
|
10
|
+
run-when(cmd, condition) := f"if [ {{condition}} ]; then echo {{style("command", cmd)}}; {{cmd}}; fi"
|
|
11
|
+
|
|
12
|
+
current_repo := `basename -s .git $(git remote get-url origin)`
|
|
13
|
+
|
|
14
|
+
prepare:
|
|
15
|
+
lefthook install
|
|
16
|
+
@{{ run-when("tsdown", f"{{current_repo}} = configs") }}
|
|
17
|
+
|
|
18
|
+
bump-deps:
|
|
19
|
+
nub update -L
|
|
20
|
+
rm -f lock.yaml
|
|
21
|
+
nub i --no-frozen-lockfile
|
|
22
|
+
oxfmt lock.yaml
|
|
23
|
+
|
|
24
|
+
lint:
|
|
25
|
+
markdown-toc -i --bullets '-' --maxdepth 3 ./README.md
|
|
26
|
+
oxlint --fix --fix-suggestions --fix-dangerously
|
|
27
|
+
oxfmt
|
|
28
|
+
knip
|
|
29
|
+
@{{ run-when("just test", "-f vitest.config.ts") }}
|
|
30
|
+
|
|
31
|
+
build: lint
|
|
32
|
+
@{{ run-when("tsdown", "-f tsdown.config.ts") }}
|
|
33
|
+
|
|
34
|
+
test:
|
|
35
|
+
vitest run
|
|
36
|
+
|
|
37
|
+
release:
|
|
38
|
+
gh workflow run release.yml
|
|
39
|
+
|
|
40
|
+
[private]
|
|
41
|
+
release-run:
|
|
42
|
+
release-it --ci -i "$(adamhl8-cliff --bumped-version)"
|
|
@@ -5,7 +5,7 @@ import { KnipConfig } from "knip";
|
|
|
5
5
|
declare const knipConfig: OptionalMergeConfigFn<KnipConfig, {
|
|
6
6
|
readonly project: ["**/*"];
|
|
7
7
|
readonly entry: ["./src/index.ts"];
|
|
8
|
-
readonly ignoreBinaries: ["
|
|
8
|
+
readonly ignoreBinaries: ["just"];
|
|
9
9
|
readonly ignoreDependencies: ["@adamhl8/eslint-plugin-clean-modules"];
|
|
10
10
|
}>;
|
|
11
11
|
//#endregion
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createMergeConfigFn } from "../utils.js";
|
|
2
2
|
//#region src/configs/knip.base.ts
|
|
3
|
-
|
|
3
|
+
/** Knip sees `just` in the `prepare` script and the release-it hooks, but it isn't a package.json dependency */
|
|
4
|
+
const IGNORE_BINARIES = ["just"];
|
|
4
5
|
const knipConfig = createMergeConfigFn({
|
|
5
6
|
project: ["**/*"],
|
|
6
7
|
entry: ["./src/index.ts"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knip.base.js","names":[],"sources":["../../src/configs/knip.base.ts"],"sourcesContent":["import type { KnipConfig } from \"knip\"\n\nimport { createMergeConfigFn } from \"#/utils.ts\"\n\nexport const IGNORE_BINARIES = [\"
|
|
1
|
+
{"version":3,"file":"knip.base.js","names":[],"sources":["../../src/configs/knip.base.ts"],"sourcesContent":["import type { KnipConfig } from \"knip\"\n\nimport { createMergeConfigFn } from \"#/utils.ts\"\n\n/** Knip sees `just` in the `prepare` script and the release-it hooks, but it isn't a package.json dependency */\nexport const IGNORE_BINARIES = [\"just\"] as const satisfies string[]\n\n/**\n * - Knip resolves `@adamhl8/eslint-plugin-clean-modules` via the oxlint config, but we don't need to install it directly\n * in the consuming project, so it shows as unlisted\n */\nconst IGNORE_DEPENDENCIES = [\"@adamhl8/eslint-plugin-clean-modules\"] as const satisfies string[]\n\nconst baseConfig = {\n project: [\"**/*\"],\n entry: [\"./src/index.ts\"],\n ignoreBinaries: IGNORE_BINARIES,\n ignoreDependencies: IGNORE_DEPENDENCIES,\n} as const satisfies KnipConfig\n\nexport const knipConfig = createMergeConfigFn<KnipConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";;;AAKA,MAAa,kBAAkB,CAAC,MAAM;AAetC,MAAa,aAAa,oBAAmD;CAN3E,SAAS,CAAC,MAAM;CAChB,OAAO,CAAC,gBAAgB;CACxB,gBAAgB;CAChB,oBAAoB,CANO,sCAMW;AAGqC,CAAU"}
|
|
@@ -4,7 +4,7 @@ import { Config } from "release-it";
|
|
|
4
4
|
//#region src/configs/release-it.base.d.ts
|
|
5
5
|
declare const releaseItConfig: OptionalMergeConfigFn<Config, {
|
|
6
6
|
readonly hooks: {
|
|
7
|
-
readonly "before:init": "
|
|
7
|
+
readonly "before:init": "just build";
|
|
8
8
|
readonly "after:bump": ["adamhl8-cliff --tag ${version} -o", "nubx oxfmt CHANGELOG.md"];
|
|
9
9
|
};
|
|
10
10
|
readonly git: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createMergeConfigFn } from "../utils.js";
|
|
2
2
|
const releaseItConfig = createMergeConfigFn({
|
|
3
3
|
hooks: {
|
|
4
|
-
"before:init": "
|
|
4
|
+
"before:init": "just build",
|
|
5
5
|
"after:bump": ["adamhl8-cliff --tag ${version} -o", "nubx oxfmt CHANGELOG.md"]
|
|
6
6
|
},
|
|
7
7
|
git: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-it.base.js","names":[],"sources":["../../src/configs/release-it.base.ts"],"sourcesContent":["// oxlint-disable no-template-curly-in-string\nimport type { Config } from \"release-it\"\n\nimport { createMergeConfigFn } from \"#/utils.ts\"\n\nconst baseConfig = {\n hooks: {\n \"before:init\": \"
|
|
1
|
+
{"version":3,"file":"release-it.base.js","names":[],"sources":["../../src/configs/release-it.base.ts"],"sourcesContent":["// oxlint-disable no-template-curly-in-string\nimport type { Config } from \"release-it\"\n\nimport { createMergeConfigFn } from \"#/utils.ts\"\n\nconst baseConfig = {\n hooks: {\n \"before:init\": \"just build\",\n \"after:bump\": [\"adamhl8-cliff --tag ${version} -o\", \"nubx oxfmt CHANGELOG.md\"],\n },\n git: {\n commitMessage: \"release: ${version}\",\n tagName: \"${version}\",\n tagAnnotation: \"release ${version}\",\n addUntrackedFiles: true,\n },\n github: {\n release: true,\n releaseName: \"${version}\",\n releaseNotes: \"adamhl8-cliff --unreleased --tag ${version}\",\n },\n npm: {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion - release-it doesn't support nub directly yet\n publishPackageManager: \"nub\" as \"bun\",\n publishPath: \"\",\n publishArgs: [\"--no-git-checks\"],\n },\n} as const satisfies Config\n\nexport const releaseItConfig = createMergeConfigFn<Config, typeof baseConfig>(baseConfig)\n"],"mappings":";AA6BA,MAAa,kBAAkB,oBAA+C;CAvB5E,OAAO;EACL,eAAe;EACf,cAAc,CAAC,qCAAqC,yBAAyB;CAC/E;CACA,KAAK;EACH,eAAe;EACf,SAAS;EACT,eAAe;EACf,mBAAmB;CACrB;CACA,QAAQ;EACN,SAAS;EACT,aAAa;EACb,cAAc;CAChB;CACA,KAAK;EAEH,uBAAuB;EACvB,aAAa;EACb,aAAa,CAAC,iBAAiB;CACjC;AAG4E,CAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamhl8/configs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"homepage": "https://github.com/adamhl8/configs",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/adamhl8/configs/issues"
|
|
@@ -40,12 +40,7 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"bump-deps": "nub update -L && rm -f lock.yaml && nub i --no-frozen-lockfile && oxfmt lock.yaml",
|
|
45
|
-
"bundle": "nub run lint && tsdown",
|
|
46
|
-
"release": "gh workflow run release.yml",
|
|
47
|
-
"release:run": "release-it --ci -i \"$(adamhl8-cliff --bumped-version)\"",
|
|
48
|
-
"prepare": "lefthook install && tsdown"
|
|
43
|
+
"prepare": "just prepare"
|
|
49
44
|
},
|
|
50
45
|
"dependencies": {
|
|
51
46
|
"@adamhl8/eslint-plugin-clean-modules": "^0.1.3",
|
|
@@ -77,6 +72,7 @@
|
|
|
77
72
|
"@commitlint/cli": ">=21",
|
|
78
73
|
"@commitlint/config-conventional": ">=21",
|
|
79
74
|
"knip": ">=6",
|
|
75
|
+
"markdown-toc": ">=1",
|
|
80
76
|
"oxfmt": ">=0.50",
|
|
81
77
|
"oxlint": ">=1",
|
|
82
78
|
"oxlint-tsgolint": ">=0.24",
|
|
@@ -99,6 +95,9 @@
|
|
|
99
95
|
"knip": {
|
|
100
96
|
"optional": true
|
|
101
97
|
},
|
|
98
|
+
"markdown-toc": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
102
101
|
"oxfmt": {
|
|
103
102
|
"optional": true
|
|
104
103
|
},
|