@adamhl8/configs 0.35.0 → 0.37.0
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
CHANGED
|
@@ -139,6 +139,21 @@ extends:
|
|
|
139
139
|
|
|
140
140
|
`lefthook install` (the base justfile's `prepare` recipe runs it) sets up the hooks.
|
|
141
141
|
|
|
142
|
+
### gitignore
|
|
143
|
+
|
|
144
|
+
git has no include mechanism for `.gitignore`, so shared entries are synced into the project's `.gitignore`. The base justfile's `prepare` recipe runs the `adamhl8-gitignore` bin, which keeps the shared list at the top of the file above a marker line: the first run prepends it, later runs replace everything above the marker with the current shared list, so changes propagate on package updates:
|
|
145
|
+
|
|
146
|
+
```gitignore
|
|
147
|
+
node_modules/
|
|
148
|
+
dist/
|
|
149
|
+
# The above patterns are managed by @adamhl8/configs. Anything manually added above this line will be replaced.
|
|
150
|
+
|
|
151
|
+
# project-specific entries go below the marker
|
|
152
|
+
.env.local
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Everything below the marker is left untouched. The sync can also be run manually by running `adamhl8-gitignore`.
|
|
156
|
+
|
|
142
157
|
## GitHub Actions
|
|
143
158
|
|
|
144
159
|
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.
|
|
@@ -213,6 +228,6 @@ Configure these on each repo that uses the workflows (Settings -> Secrets and va
|
|
|
213
228
|
|
|
214
229
|
## Notes
|
|
215
230
|
|
|
216
|
-
The `prepare` script is `"prepare": "just prepare"`, which runs the base justfile's `prepare` recipe (`lefthook install`).
|
|
231
|
+
The `prepare` script is `"prepare": "just prepare"`, which runs the base justfile's `prepare` recipe (`lefthook install` and the `.gitignore` sync).
|
|
217
232
|
|
|
218
233
|
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,19 @@
|
|
|
1
|
+
#!/usr/bin/env nub
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/adamhl8-gitignore/index.ts
|
|
5
|
+
const GITIGNORE_BASE_PATH = path.resolve(import.meta.dirname, "../configs/gitignore.base");
|
|
6
|
+
const END_MARKER = "# The above patterns are managed by @adamhl8/configs. Anything manually added above this line will be replaced.";
|
|
7
|
+
/** Rebuilds the managed region above the marker, keeping what's below it (the whole file when there's no marker). */
|
|
8
|
+
const mergeGitignore = (currentContent, blockBody) => {
|
|
9
|
+
const block = [blockBody, END_MARKER].filter(Boolean).join("\n");
|
|
10
|
+
const existingContent = (currentContent.split(END_MARKER).at(-1) ?? "").trim();
|
|
11
|
+
return existingContent ? `${block}\n\n${existingContent}\n` : `${block}\n`;
|
|
12
|
+
};
|
|
13
|
+
const gitignorePath = ".gitignore";
|
|
14
|
+
const blockBody = fs.readFileSync(GITIGNORE_BASE_PATH, "utf8").trim();
|
|
15
|
+
const currentContent = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, "utf8") : "";
|
|
16
|
+
const merged = mergeGitignore(currentContent, blockBody);
|
|
17
|
+
if (merged !== currentContent) fs.writeFileSync(gitignorePath, merged);
|
|
18
|
+
//#endregion
|
|
19
|
+
export {};
|
|
@@ -14,13 +14,13 @@ run-when(cmd, condition) := f"if {{condition}}; then echo {{style("command", cmd
|
|
|
14
14
|
prepare: _prepare
|
|
15
15
|
_prepare:
|
|
16
16
|
lefthook install
|
|
17
|
+
adamhl8-gitignore
|
|
17
18
|
|
|
18
19
|
bump-deps: _bump-deps
|
|
19
20
|
_bump-deps:
|
|
20
21
|
nub update -L
|
|
21
|
-
rm -f lock
|
|
22
|
+
rm -f nub.lock
|
|
22
23
|
nub i --no-frozen-lockfile
|
|
23
|
-
oxfmt lock.yaml
|
|
24
24
|
|
|
25
25
|
tofu-check: _tofu-check
|
|
26
26
|
_tofu-check:
|
|
@@ -2,15 +2,24 @@ data "local_file" "package_json" {
|
|
|
2
2
|
filename = "${path.root}/package.json"
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
data "github_user" "current" {
|
|
6
|
+
username = ""
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
locals {
|
|
6
10
|
package_json = jsondecode(data.local_file.package_json.content)
|
|
11
|
+
repo_url = "github.com/${data.github_user.current.login}/${var.repo_name}"
|
|
12
|
+
# a homepage pointing at the repo itself is redundant
|
|
13
|
+
homepage_url = try(strcontains(local.package_json.homepage, local.repo_url) ? null : local.package_json.homepage, null)
|
|
7
14
|
}
|
|
8
15
|
|
|
16
|
+
|
|
17
|
+
|
|
9
18
|
resource "github_repository" "current" {
|
|
10
19
|
name = var.repo_name
|
|
11
20
|
description = local.package_json.description
|
|
12
21
|
visibility = var.repo_settings.visibility
|
|
13
|
-
homepage_url =
|
|
22
|
+
homepage_url = local.homepage_url
|
|
14
23
|
topics = try(local.package_json.keywords, [])
|
|
15
24
|
|
|
16
25
|
allow_merge_commit = false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamhl8/configs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "My shared configs for TS projects",
|
|
5
5
|
"homepage": "https://github.com/adamhl8/configs",
|
|
6
6
|
"bugs": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"url": "git+https://github.com/adamhl8/configs.git"
|
|
18
18
|
},
|
|
19
19
|
"bin": {
|
|
20
|
-
"adamhl8-cliff": "./dist/adamhl8-cliff/index"
|
|
20
|
+
"adamhl8-cliff": "./dist/adamhl8-cliff/index",
|
|
21
|
+
"adamhl8-gitignore": "./dist/adamhl8-gitignore/index"
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
23
24
|
"./dist/"
|
|
@@ -120,5 +121,12 @@
|
|
|
120
121
|
"vitest": {
|
|
121
122
|
"optional": true
|
|
122
123
|
}
|
|
124
|
+
},
|
|
125
|
+
"devEngines": {
|
|
126
|
+
"packageManager": {
|
|
127
|
+
"name": "nub",
|
|
128
|
+
"version": "^0.4.4",
|
|
129
|
+
"onFail": "warn"
|
|
130
|
+
}
|
|
123
131
|
}
|
|
124
132
|
}
|