@nodeve/checks 0.1.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.
Files changed (44) hide show
  1. package/README.md +64 -0
  2. package/dist/bin/build-helper-manifest.d.ts +3 -0
  3. package/dist/bin/build-helper-manifest.d.ts.map +1 -0
  4. package/dist/bin/build-helper-manifest.js +272 -0
  5. package/dist/bin/build-helper-manifest.js.map +1 -0
  6. package/dist/bin/build-lib-names.d.ts +3 -0
  7. package/dist/bin/build-lib-names.d.ts.map +1 -0
  8. package/dist/bin/build-lib-names.js +48 -0
  9. package/dist/bin/build-lib-names.js.map +1 -0
  10. package/dist/bin/catalog.d.ts +3 -0
  11. package/dist/bin/catalog.d.ts.map +1 -0
  12. package/dist/bin/catalog.js +139 -0
  13. package/dist/bin/catalog.js.map +1 -0
  14. package/dist/bin/doc-tokens.d.ts +3 -0
  15. package/dist/bin/doc-tokens.d.ts.map +1 -0
  16. package/dist/bin/doc-tokens.js +69 -0
  17. package/dist/bin/doc-tokens.js.map +1 -0
  18. package/dist/bin/helper-collisions.d.ts +3 -0
  19. package/dist/bin/helper-collisions.d.ts.map +1 -0
  20. package/dist/bin/helper-collisions.js +95 -0
  21. package/dist/bin/helper-collisions.js.map +1 -0
  22. package/dist/bin/inline-dupes.d.ts +3 -0
  23. package/dist/bin/inline-dupes.d.ts.map +1 -0
  24. package/dist/bin/inline-dupes.js +79 -0
  25. package/dist/bin/inline-dupes.js.map +1 -0
  26. package/dist/bin/page-size.d.ts +3 -0
  27. package/dist/bin/page-size.d.ts.map +1 -0
  28. package/dist/bin/page-size.js +52 -0
  29. package/dist/bin/page-size.js.map +1 -0
  30. package/dist/bin/reshape.d.ts +3 -0
  31. package/dist/bin/reshape.d.ts.map +1 -0
  32. package/dist/bin/reshape.js +149 -0
  33. package/dist/bin/reshape.js.map +1 -0
  34. package/dist/lib/config.d.ts +81 -0
  35. package/dist/lib/config.d.ts.map +1 -0
  36. package/dist/lib/config.js +75 -0
  37. package/dist/lib/config.js.map +1 -0
  38. package/dist/lib/repo.d.ts +13 -0
  39. package/dist/lib/repo.d.ts.map +1 -0
  40. package/dist/lib/repo.js +21 -0
  41. package/dist/lib/repo.js.map +1 -0
  42. package/lefthook.checks.yml +44 -0
  43. package/nodeve.checks.example.js +65 -0
  44. package/package.json +46 -0
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @nodeve/checks
2
+
3
+ Org-wide commit-gate checks and helper-index generators, shared across nodeve
4
+ repos. Each check ships as a published bin that reads an optional per-repo
5
+ `nodeve.checks.js` and derives the repo root from git — so it behaves the same
6
+ whatever directory the hook runner invokes it from. Wiring is via lefthook.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ pnpm add -D @nodeve/checks # or: bun add -d @nodeve/checks
12
+ ```
13
+
14
+ Extend the shared lefthook config from your `lefthook.yml`:
15
+
16
+ ```yaml
17
+ extends:
18
+ - node_modules/@nodeve/checks/lefthook.checks.yml
19
+ ```
20
+
21
+ Then activate hooks once per clone with `lefthook install` (familiar/nodeve do
22
+ this from their `prepare` script).
23
+
24
+ ## Configure
25
+
26
+ Copy `node_modules/@nodeve/checks/nodeve.checks.example.js` to your repo root as
27
+ `nodeve.checks.js` and trim to taste. Every section is optional; omitted keys
28
+ fall back to org defaults. See the example for the full shape.
29
+
30
+ ## Checks
31
+
32
+ | Bin | What it gates | Default |
33
+ | --- | --- | --- |
34
+ | `nodeve-check-doc-tokens` | markdown over a line/token budget | on (`CLAUDE.md`, `guide/`, `docs/`) |
35
+ | `nodeve-check-reshape` | callbacks that reproduce their input shape (no-op / pick / clone) | on (`apps/`, `packages/`) |
36
+ | `nodeve-check-inline-dupes` | non-exported top-level names declared in 2+ files | on (`apps/`) |
37
+ | `nodeve-check-helper-collisions` | local helpers that fuzzily match a dependency export | on (needs lib-names index) |
38
+ | `nodeve-check-page-size` | files over a per-glob line budget | **opt-in** (no rules → no-op) |
39
+ | `nodeve-check-catalog` | dependency versions not single-sourced from a workspace catalog | on (a workspace must declare a catalog) |
40
+
41
+ `catalog` works with both pnpm (catalog in `pnpm-workspace.yaml`) and Bun
42
+ (catalog in `package.json#workspaces`) — it auto-detects whichever the repo uses.
43
+ A workspace is **required** to declare a catalog: a repo with none fails the gate,
44
+ since the point is keeping versions aligned. Every dependency (deps, devDeps, and
45
+ peers alike) must reference `catalog:` rather than a literal pin. Opt a repo out
46
+ deliberately with `catalog: { enforce: false }`.
47
+
48
+ All blocking checks accept `--warn` (report-only, exit 0); `doc-tokens` accepts
49
+ `--report` to list the whole backlog without failing. Pass explicit paths to
50
+ scope a run (lefthook passes `{staged_files}`).
51
+
52
+ ## Generators
53
+
54
+ - `nodeve-build-lib-names` — writes the committed lib-names index that
55
+ `helper-collisions` matches against (regenerate after dependency bumps). The
56
+ index is committed so the gate never needs the libs installed at check time.
57
+ - `nodeve-build-helper-manifest` — **opt-in**; writes a greppable index of the
58
+ public export surface of the configured packages. Grep it before adding a
59
+ generic helper.
60
+
61
+ ## Notes for Bun repos
62
+
63
+ The bins are plain Node ESM and run under Node from `node_modules/.bin`. lefthook
64
+ in a Bun workspace still finds them on PATH; no `bunx` prefix is needed.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=build-helper-manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-helper-manifest.d.ts","sourceRoot":"","sources":["../../src/bin/build-helper-manifest.ts"],"names":[],"mappings":""}
@@ -0,0 +1,272 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Generate a single greppable index of the public helper surface of the
4
+ * configured packages (`helperManifest.packages` → `helperManifest.output`).
5
+ * Grep this file before adding a generic helper, instead of blind-sweeping
6
+ * `packages/`. Deterministic — no LLM, no embeddings.
7
+ *
8
+ * Source of truth is each package's `exports` map — every subpath barrel, not
9
+ * just the root one. For every value export we resolve the declaration's
10
+ * signature + first JSDoc line, plus each module's top-level doc comment as a
11
+ * one-line intro above its block. Type-only exports and Svelte component
12
+ * internals are out of scope.
13
+ *
14
+ * No-op unless a repo lists packages. Run: `nodeve-build-helper-manifest`.
15
+ */
16
+ import { trimText } from '@nodeve/text/trim';
17
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
18
+ import { dirname, join, relative } from 'node:path';
19
+ import ts from 'typescript';
20
+ import { loadConfig } from '../lib/config.js';
21
+ import { repoRoot } from '../lib/repo.js';
22
+ const root = repoRoot();
23
+ const cfg = (await loadConfig(root)).helperManifest;
24
+ if (cfg.packages.length === 0)
25
+ process.exit(0);
26
+ const OUTPUT = join(root, cfg.output);
27
+ /** Leading JSDoc block of a node as a single capped line. */
28
+ function jsDocSummary(node) {
29
+ const docs = node.jsDoc;
30
+ const comment = docs?.[docs.length - 1]?.comment;
31
+ if (!comment)
32
+ return '';
33
+ const text = typeof comment === 'string' ? comment : comment.map((c) => c.text).join('');
34
+ return trimText(text, { max: 120, ellipsis: '...' });
35
+ }
36
+ const moduleDocCache = new Map();
37
+ /**
38
+ * The file's top-level doc comment as a single capped line, or ''. Distinguished
39
+ * from a declaration's own JSDoc by a blank-line gap or a leading import — TS only
40
+ * attaches JSDoc to an adjacent declaration, so an orphaned top comment is module
41
+ * intent worth surfacing once per file.
42
+ */
43
+ function moduleDocOf(sourcePath) {
44
+ if (sourcePath.endsWith('.svelte'))
45
+ return '';
46
+ const cached = moduleDocCache.get(sourcePath);
47
+ if (cached !== undefined)
48
+ return cached;
49
+ const text = readFileSync(sourcePath, 'utf8');
50
+ const range = ts.getLeadingCommentRanges(text, 0)?.[0];
51
+ let doc = '';
52
+ if (range) {
53
+ const after = text.slice(range.end);
54
+ const rest = after.trimStart();
55
+ const blankAfter = /^\n\s*\n/.test(after); // not adjacent to the next declaration
56
+ const importFirst = rest.startsWith('import ') || rest.startsWith('import{');
57
+ if (blankAfter || importFirst) {
58
+ const body = text
59
+ .slice(range.pos, range.end)
60
+ .replace(/^\/\*\*?/, '')
61
+ .replace(/\*\/\s*$/, '')
62
+ .replace(/^[ \t]*\*[ \t]?/gm, '')
63
+ .replace(/^[ \t]*\/\/[ \t]?/gm, '');
64
+ doc = trimText(body, { max: 140, ellipsis: '...' });
65
+ }
66
+ }
67
+ moduleDocCache.set(sourcePath, doc);
68
+ return doc;
69
+ }
70
+ function fnSignature(name, params, returnType, source) {
71
+ const args = params.map((p) => p.getText(source).replace(/\s+/g, ' ')).join(', ');
72
+ const ret = returnType ? `: ${returnType.getText(source).replace(/\s+/g, ' ')}` : '';
73
+ return `${name}(${args})${ret}`;
74
+ }
75
+ /** Map every top-level declared name in a source file to its kind/signature/summary. */
76
+ function declarationsOf(sourcePath) {
77
+ const out = new Map();
78
+ const text = readFileSync(sourcePath, 'utf8');
79
+ const source = ts.createSourceFile(sourcePath, text, ts.ScriptTarget.Latest, true);
80
+ for (const stmt of source.statements) {
81
+ if (ts.isFunctionDeclaration(stmt) && stmt.name) {
82
+ const name = stmt.name.text;
83
+ if (out.has(name))
84
+ continue; // first overload signature wins
85
+ out.set(name, {
86
+ kind: 'fn',
87
+ signature: fnSignature(name, stmt.parameters, stmt.type, source),
88
+ summary: jsDocSummary(stmt),
89
+ });
90
+ }
91
+ else if (ts.isVariableStatement(stmt)) {
92
+ const summary = jsDocSummary(stmt);
93
+ for (const decl of stmt.declarationList.declarations) {
94
+ if (!ts.isIdentifier(decl.name))
95
+ continue;
96
+ const name = decl.name.text;
97
+ const init = decl.initializer;
98
+ if (init && (ts.isArrowFunction(init) || ts.isFunctionExpression(init))) {
99
+ out.set(name, {
100
+ kind: 'fn',
101
+ signature: fnSignature(name, init.parameters, init.type, source),
102
+ summary,
103
+ });
104
+ }
105
+ else {
106
+ const typeText = decl.type ? `: ${decl.type.getText(source).replace(/\s+/g, ' ')}` : '';
107
+ out.set(name, { kind: 'const', signature: `${name}${typeText}`, summary });
108
+ }
109
+ }
110
+ }
111
+ else if (ts.isClassDeclaration(stmt) && stmt.name) {
112
+ out.set(stmt.name.text, {
113
+ kind: 'class',
114
+ signature: stmt.name.text,
115
+ summary: jsDocSummary(stmt),
116
+ });
117
+ }
118
+ }
119
+ return out;
120
+ }
121
+ /** Resolve a barrel module specifier to an on-disk source path. */
122
+ function resolveSource(barrelDir, spec) {
123
+ const base = join(barrelDir, spec);
124
+ const candidates = [
125
+ base,
126
+ base.replace(/\.js$/, '.ts'),
127
+ `${base}.ts`,
128
+ `${base}.svelte`,
129
+ join(base, 'index.ts'),
130
+ ];
131
+ return candidates.find((c) => existsSync(c)) ?? null;
132
+ }
133
+ /** Parse a barrel's `export { … } from './…'` declarations into re-export records. */
134
+ function reExportsOf(barrelPath) {
135
+ const text = readFileSync(barrelPath, 'utf8');
136
+ const source = ts.createSourceFile(barrelPath, text, ts.ScriptTarget.Latest, true);
137
+ const out = [];
138
+ for (const stmt of source.statements) {
139
+ if (!ts.isExportDeclaration(stmt) || !stmt.moduleSpecifier)
140
+ continue;
141
+ if (!ts.isStringLiteral(stmt.moduleSpecifier))
142
+ continue;
143
+ const module = stmt.moduleSpecifier.text;
144
+ const clause = stmt.exportClause;
145
+ if (!clause || !ts.isNamedExports(clause))
146
+ continue; // skip `export * from`
147
+ for (const el of clause.elements) {
148
+ out.push({
149
+ exportedName: el.name.text,
150
+ localName: el.propertyName?.text ?? el.name.text,
151
+ module,
152
+ typeOnly: stmt.isTypeOnly || el.isTypeOnly,
153
+ });
154
+ }
155
+ }
156
+ return out;
157
+ }
158
+ /** Resolve an `exports` target (string, or conditional object) to a single file path. */
159
+ function exportTarget(value) {
160
+ if (typeof value === 'string')
161
+ return value;
162
+ if (value && typeof value === 'object') {
163
+ const o = value;
164
+ const pick = o.default ?? o.svelte ?? o.types;
165
+ return typeof pick === 'string' ? pick : null;
166
+ }
167
+ return null;
168
+ }
169
+ /** Every subpath barrel a package publicly exposes via its `exports` map. */
170
+ function barrelsOf(pkgDir) {
171
+ const pkg = JSON.parse(readFileSync(join(pkgDir, 'package.json'), 'utf8'));
172
+ const out = [];
173
+ for (const [key, value] of Object.entries(pkg.exports ?? {})) {
174
+ if (key.includes('*'))
175
+ continue; // wildcard pass-throughs aren't barrels
176
+ const target = exportTarget(value);
177
+ if (!target?.endsWith('.ts'))
178
+ continue; // skip .css and the like
179
+ out.push({
180
+ importPath: pkg.name + (key === '.' ? '' : key.slice(1)),
181
+ barrelPath: join(pkgDir, target),
182
+ });
183
+ }
184
+ return out;
185
+ }
186
+ function collect() {
187
+ const entries = [];
188
+ const declCache = new Map();
189
+ const declsFor = (p) => {
190
+ if (!declCache.has(p))
191
+ declCache.set(p, declarationsOf(p));
192
+ return declCache.get(p);
193
+ };
194
+ for (const pkgRel of cfg.packages) {
195
+ const pkgDir = join(root, pkgRel);
196
+ for (const barrel of barrelsOf(pkgDir)) {
197
+ if (!existsSync(barrel.barrelPath))
198
+ continue;
199
+ const barrelDir = dirname(barrel.barrelPath);
200
+ for (const re of reExportsOf(barrel.barrelPath)) {
201
+ if (re.typeOnly)
202
+ continue; // types are out of scope for v1
203
+ const sourcePath = resolveSource(barrelDir, re.module);
204
+ if (!sourcePath)
205
+ continue;
206
+ const file = relative(pkgDir, sourcePath);
207
+ if (sourcePath.endsWith('.svelte')) {
208
+ entries.push({
209
+ importPath: barrel.importPath,
210
+ file,
211
+ srcPath: sourcePath,
212
+ symbol: re.exportedName,
213
+ kind: 'component',
214
+ signature: re.exportedName,
215
+ summary: '',
216
+ });
217
+ continue;
218
+ }
219
+ const decl = declsFor(sourcePath).get(re.localName);
220
+ if (!decl)
221
+ continue;
222
+ entries.push({
223
+ importPath: barrel.importPath,
224
+ file,
225
+ srcPath: sourcePath,
226
+ symbol: re.exportedName,
227
+ ...decl,
228
+ });
229
+ }
230
+ }
231
+ }
232
+ return entries.sort((a, b) => a.importPath.localeCompare(b.importPath) ||
233
+ a.file.localeCompare(b.file) ||
234
+ a.symbol.localeCompare(b.symbol));
235
+ }
236
+ function render(entries) {
237
+ const packages = new Set(entries.map((e) => e.importPath.split('/').slice(0, 2).join('/')));
238
+ const lines = [
239
+ '# Helper manifest — public surface of the configured packages',
240
+ '#',
241
+ '# GENERATED by `nodeve-build-helper-manifest`. Do not edit.',
242
+ '# Grep this file before adding a generic helper. One self-contained line per symbol:',
243
+ '# <import-path> · <kind> · <signature> — <summary> [src/file]',
244
+ "# A `# src/file — …` line above a block is that module's top-level doc.",
245
+ `# ${entries.length} symbols across ${packages.size} packages.`,
246
+ '',
247
+ ];
248
+ let importPath = '';
249
+ let file = '';
250
+ for (const e of entries) {
251
+ if (e.importPath !== importPath) {
252
+ importPath = e.importPath;
253
+ file = '';
254
+ lines.push(`## ${importPath}`);
255
+ }
256
+ if (e.file !== file) {
257
+ file = e.file;
258
+ const moduleDoc = moduleDocOf(e.srcPath);
259
+ if (moduleDoc)
260
+ lines.push(`# ${file} — ${moduleDoc}`);
261
+ }
262
+ const summary = e.summary ? ` — ${e.summary}` : '';
263
+ lines.push(`${e.importPath} · ${e.kind} · ${e.signature}${summary} [${e.file}]`);
264
+ }
265
+ lines.push('');
266
+ return lines.join('\n');
267
+ }
268
+ const entries = collect();
269
+ mkdirSync(dirname(OUTPUT), { recursive: true });
270
+ writeFileSync(OUTPUT, render(entries));
271
+ console.log(`Wrote ${entries.length} symbols to ${relative(root, OUTPUT)}`);
272
+ //# sourceMappingURL=build-helper-manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-helper-manifest.js","sourceRoot":"","sources":["../../src/bin/build-helper-manifest.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,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CAAC;QACrD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,SAAS,GAAG,OAAO,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;IACvF,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC;AAC1B,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAChD,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvC,OAAO,CAAC,GAAG,CAAC,SAAS,OAAO,CAAC,MAAM,eAAe,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=build-lib-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-lib-names.d.ts","sourceRoot":"","sources":["../../src/bin/build-lib-names.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Generate the committed lib-names index that `helper-collisions` matches local
4
+ * helpers against (path from `helperCollisions.libNamesPath`).
5
+ *
6
+ * WHY committed + generated: resolving the libs HERE, not at check time, means
7
+ * the commit gate has no runtime dependency on the libs being installed/
8
+ * resolvable. Regenerate after dependency bumps so the index tracks new/removed
9
+ * exports.
10
+ *
11
+ * Resolves each lib from the CWD's module graph; libs not installed are skipped
12
+ * and logged. Run from the consumer repo root: `nodeve-build-lib-names`.
13
+ */
14
+ import { mkdirSync, writeFileSync } from 'node:fs';
15
+ import { dirname, join, relative } from 'node:path';
16
+ import { loadConfig } from '../lib/config.js';
17
+ import { repoRoot } from '../lib/repo.js';
18
+ const root = repoRoot();
19
+ const cfg = (await loadConfig(root)).helperCollisions;
20
+ const output = join(root, cfg.libNamesPath);
21
+ const names = {};
22
+ const skipped = [];
23
+ for (const lib of cfg.libs) {
24
+ try {
25
+ const mod = (await import(lib));
26
+ const fns = Object.keys(mod)
27
+ .filter((k) => typeof mod[k] === 'function')
28
+ .sort();
29
+ if (fns.length)
30
+ names[lib] = fns;
31
+ else
32
+ skipped.push(`${lib} (no function exports)`);
33
+ }
34
+ catch {
35
+ skipped.push(lib);
36
+ }
37
+ }
38
+ const out = {
39
+ $generatedBy: 'nodeve-build-lib-names',
40
+ libs: Object.keys(names),
41
+ names,
42
+ };
43
+ mkdirSync(dirname(output), { recursive: true });
44
+ writeFileSync(output, JSON.stringify(out, null, '\t') + '\n');
45
+ const total = Object.values(names).flat().length;
46
+ console.log(`Wrote ${total} names from ${Object.keys(names).join(', ') || '(none)'} to ${relative(root, output)}` +
47
+ (skipped.length ? `\nSkipped (not installed): ${skipped.join(', ')}` : ''));
48
+ //# sourceMappingURL=build-lib-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-lib-names.js","sourceRoot":"","sources":["../../src/bin/build-lib-names.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAC;AACxB,MAAM,GAAG,GAAG,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC;AACtD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC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I,EAAE,MAAM,CAAC,EAAE;IACpG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,8BAA8B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC3E,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/bin/catalog.ts"],"names":[],"mappings":""}
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Commit gate (opt-in): every dependency version must be single-sourced through
4
+ * a workspace catalog. No workspace package may pin a literal version — each
5
+ * dependency must reference the default `catalog` or a named `catalogs.<group>`
6
+ * with the `catalog:` protocol (a `workspace:*` reference to a sibling is fine
7
+ * too). Two breaches fail the commit:
8
+ *
9
+ * 1. A package pins a literal version (e.g. "yaml": "^2.9.0"). It must read
10
+ * "catalog:" (or "catalog:<group>") so the version lives once, centrally.
11
+ * 2. A package references a catalog group that doesn't exist, or — for the
12
+ * default catalog — a name the catalog doesn't define (a typo that wouldn't
13
+ * resolve).
14
+ *
15
+ * One purpose, two layouts: the catalog lives in `pnpm-workspace.yaml` (pnpm) or
16
+ * in the root `package.json#workspaces` (Bun). This auto-detects whichever the
17
+ * repo uses, so it gates familiar (bun), nodeve, and platform (pnpm) alike.
18
+ *
19
+ * On by default. A workspace is REQUIRED to declare a catalog — a workspace with
20
+ * no catalog at all fails, since the whole point is keeping versions aligned.
21
+ * Set `catalog.enforce: false` in nodeve.checks.js to deliberately opt a repo out.
22
+ */
23
+ import { existsSync, readFileSync } from 'node:fs';
24
+ import { dirname, join } from 'node:path';
25
+ import { parse as parseYaml } from 'yaml';
26
+ import { loadConfig, parseArgs } from '../lib/config.js';
27
+ import { gitFiles, repoRoot } from '../lib/repo.js';
28
+ /**
29
+ * Resolve the workspace definition from whichever manifest the repo uses:
30
+ * `pnpm-workspace.yaml` (pnpm) takes precedence, else the root
31
+ * `package.json#workspaces` (Bun, where `workspaces` may be a bare array of
32
+ * globs or an object carrying the catalogs).
33
+ */
34
+ function readWorkspace(root) {
35
+ const pnpm = join(root, 'pnpm-workspace.yaml');
36
+ if (existsSync(pnpm)) {
37
+ const ws = parseYaml(readFileSync(pnpm, 'utf8')) ?? {};
38
+ return {
39
+ packages: ws.packages ?? [],
40
+ catalog: ws.catalog ?? {},
41
+ catalogs: ws.catalogs ?? {},
42
+ };
43
+ }
44
+ const pkgPath = join(root, 'package.json');
45
+ if (existsSync(pkgPath)) {
46
+ const ws = JSON.parse(readFileSync(pkgPath, 'utf8')).workspaces;
47
+ if (Array.isArray(ws))
48
+ return { packages: ws, catalog: {}, catalogs: {} };
49
+ if (ws && typeof ws === 'object') {
50
+ return {
51
+ packages: ws.packages ?? [],
52
+ catalog: ws.catalog ?? {},
53
+ catalogs: ws.catalogs ?? {},
54
+ };
55
+ }
56
+ }
57
+ return null;
58
+ }
59
+ const root = repoRoot();
60
+ const cfg = (await loadConfig(root)).catalog;
61
+ const { verbose } = parseArgs(process.argv.slice(2));
62
+ if (!cfg.enforce)
63
+ process.exit(0);
64
+ const ws = readWorkspace(root);
65
+ if (!ws) {
66
+ if (verbose)
67
+ console.log('catalog: no workspace manifest found — nothing to enforce');
68
+ process.exit(0);
69
+ }
70
+ // A workspace must declare a catalog — alignment is the point, so "no catalog"
71
+ // is itself a failure, not a free pass. Opt a repo out deliberately with
72
+ // `catalog.enforce: false` rather than by omitting the catalog.
73
+ if (Object.keys(ws.catalog).length === 0 && Object.keys(ws.catalogs).length === 0) {
74
+ console.error('\n✖ this workspace declares no catalog.\n\n' +
75
+ ' Every workspace must single-source its dependency versions through a\n' +
76
+ ' catalog. Add a `catalog:` block to pnpm-workspace.yaml (or\n' +
77
+ ' `workspaces.catalog` in package.json for Bun), move your versions into\n' +
78
+ ' it, and reference them with "catalog:".\n\n' +
79
+ ' To deliberately opt out, set `catalog: { enforce: false }` in nodeve.checks.js.\n');
80
+ process.exit(1);
81
+ }
82
+ // Mirror the workspace globs (their `*` matches `/` in git pathspecs, same as
83
+ // pnpm/bun resolution) and their `!` negations, so the guard sees exactly the
84
+ // set the package manager installs — no more, no less.
85
+ const positives = ws.packages.filter((p) => !p.startsWith('!'));
86
+ const negatives = ws.packages
87
+ .filter((p) => p.startsWith('!'))
88
+ .map((p) => p.slice(1).replace(/\/\*+$/, ''));
89
+ const manifests = gitFiles(root, positives.map((p) => `${p}/package.json`)).filter((manifest) => {
90
+ const dir = dirname(manifest);
91
+ return !negatives.some((n) => dir === n || dir.startsWith(n + '/'));
92
+ });
93
+ const DEP_FIELDS = [
94
+ 'dependencies',
95
+ 'devDependencies',
96
+ 'peerDependencies',
97
+ 'optionalDependencies',
98
+ ];
99
+ const ALLOWLIST = new Set(cfg.allowlist);
100
+ const errors = [];
101
+ for (const manifest of manifests) {
102
+ const pkg = JSON.parse(readFileSync(join(root, manifest), 'utf8'));
103
+ for (const field of DEP_FIELDS) {
104
+ const deps = pkg[field] ?? {};
105
+ for (const [name, version] of Object.entries(deps)) {
106
+ if (ALLOWLIST.has(`${manifest}::${name}`))
107
+ continue;
108
+ // Local references, not version pins — single-sourcing doesn't apply.
109
+ if (/^(workspace|link|file):/.test(version))
110
+ continue;
111
+ if (!version.startsWith('catalog:')) {
112
+ // Rule 1: literal version pin — every dependency must go through a catalog.
113
+ errors.push(`${manifest}: "${name}": "${version}" — pin it in a root catalog and use "catalog:" (or "catalog:<group>")`);
114
+ continue;
115
+ }
116
+ // Rule 2: the referenced catalog must actually define this dependency.
117
+ const group = version.slice('catalog:'.length); // "" → the default catalog
118
+ const table = group === '' ? ws.catalog : ws.catalogs[group];
119
+ if (!table) {
120
+ errors.push(`${manifest}: "${name}": "${version}" — no catalog group named "${group}" in the workspace`);
121
+ }
122
+ else if (!(name in table)) {
123
+ const where = group === '' ? 'the default catalog' : `catalog "${group}"`;
124
+ errors.push(`${manifest}: "${name}": "${version}" — ${where} does not define "${name}"`);
125
+ }
126
+ }
127
+ }
128
+ }
129
+ if (errors.length === 0) {
130
+ if (verbose)
131
+ console.log('catalog: clean');
132
+ process.exit(0);
133
+ }
134
+ console.error('\n✖ every dependency version must be single-sourced from a workspace catalog:\n');
135
+ for (const e of errors)
136
+ console.error(` ${e}`);
137
+ console.error('\n Add the version to the catalog (pnpm-workspace.yaml or package.json#workspaces),\n reference it with "catalog:", then reinstall.\n');
138
+ process.exit(1);
139
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/bin/catalog.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AASpD;;;;;GAKG;AACH,SAAS,aAAa,CAAC,IAAY;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IAC/C,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,EAAE,GAAG,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QACvD,OAAO;YACN,QAAQ,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE;YAC3B,OAAO,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE;YACzB,QAAQ,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE;SAC3B,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,IAA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