@adamhl8/configs 0.35.0 → 0.36.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 {};
@@ -0,0 +1,4 @@
1
+ node_modules/
2
+ dist/
3
+ .terraform
4
+ .terraform.lock.hcl
@@ -14,6 +14,7 @@ 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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamhl8/configs",
3
- "version": "0.35.0",
3
+ "version": "0.36.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/"