@nodeve/checks 0.1.1 → 0.2.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 +8 -0
- package/dist/bin/catalog.js +4 -46
- package/dist/bin/catalog.js.map +1 -1
- package/dist/bin/doc-tokens.js +2 -2
- package/dist/bin/require-deps.d.ts +3 -0
- package/dist/bin/require-deps.d.ts.map +1 -0
- package/dist/bin/require-deps.js +51 -0
- package/dist/bin/require-deps.js.map +1 -0
- package/dist/lib/config.d.ts +19 -2
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +11 -11
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/repo.d.ts +20 -0
- package/dist/lib/repo.d.ts.map +1 -1
- package/dist/lib/repo.js +42 -0
- package/dist/lib/repo.js.map +1 -1
- package/lefthook.checks.yml +6 -0
- package/nodeve.checks.example.js +24 -52
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -37,6 +37,14 @@ fall back to org defaults. See the example for the full shape.
|
|
|
37
37
|
| `nodeve-check-helper-collisions` | local helpers that fuzzily match a dependency export | on (needs lib-names index) |
|
|
38
38
|
| `nodeve-check-page-size` | files over a per-glob line budget | **opt-in** (no rules → no-op) |
|
|
39
39
|
| `nodeve-check-catalog` | dependency versions not single-sourced from a workspace catalog | on (a workspace must declare a catalog) |
|
|
40
|
+
| `nodeve-check-require-deps` | org-required deps missing from the workspace catalog | on (`remeda`; set `deps: []` to opt out) |
|
|
41
|
+
|
|
42
|
+
`require-deps` keeps the org's blessed libraries single-sourced and visibly
|
|
43
|
+
expected: it fails when the workspace catalog (default or a named group) doesn't
|
|
44
|
+
define a required name. It checks the catalog, not each package's deps — so it
|
|
45
|
+
doesn't force the dep on packages that don't use it, it just guarantees the
|
|
46
|
+
version is there to adopt with `catalog:`. Defaults to requiring `remeda`; set
|
|
47
|
+
`requireDeps: { deps: [] }` to opt out.
|
|
40
48
|
|
|
41
49
|
`catalog` works with both pnpm (catalog in `pnpm-workspace.yaml`) and Bun
|
|
42
50
|
(catalog in `package.json#workspaces`) — it auto-detects whichever the repo uses.
|
package/dist/bin/catalog.js
CHANGED
|
@@ -20,42 +20,10 @@
|
|
|
20
20
|
* no catalog at all fails, since the whole point is keeping versions aligned.
|
|
21
21
|
* Set `catalog.enforce: false` in nodeve.checks.js to deliberately opt a repo out.
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { parse as parseYaml } from 'yaml';
|
|
23
|
+
import { readFileSync } from 'node:fs';
|
|
24
|
+
import { join } from 'node:path';
|
|
26
25
|
import { loadConfig, parseArgs } from '../lib/config.js';
|
|
27
|
-
import {
|
|
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
|
-
}
|
|
26
|
+
import { readWorkspace, repoRoot, workspaceManifests } from '../lib/repo.js';
|
|
59
27
|
const root = repoRoot();
|
|
60
28
|
const cfg = (await loadConfig(root)).catalog;
|
|
61
29
|
const { verbose } = parseArgs(process.argv.slice(2));
|
|
@@ -79,17 +47,7 @@ if (Object.keys(ws.catalog).length === 0 && Object.keys(ws.catalogs).length ===
|
|
|
79
47
|
' To deliberately opt out, set `catalog: { enforce: false }` in nodeve.checks.js.\n');
|
|
80
48
|
process.exit(1);
|
|
81
49
|
}
|
|
82
|
-
|
|
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
|
-
});
|
|
50
|
+
const manifests = workspaceManifests(root, ws);
|
|
93
51
|
const DEP_FIELDS = [
|
|
94
52
|
'dependencies',
|
|
95
53
|
'devDependencies',
|
package/dist/bin/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/bin/catalog.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/bin/catalog.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,Y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CAAC;gBACZ,MAAM,CAAC,IAAI,CACV,GAAG,QAAQ,MAAM,IAAI,OAAO,OAAO,+BAA+B,KAAK,oBAAoB,CAC3F,CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,KAAK,GAAG,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,KAAK,GAAG,CAAC;gBAC1E,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,MAAM,IAAI,OAAO,OAAO,OAAO,KAAK,qBAAqB,IAAI,GAAG,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IACzB,IAAI,OAAO;QAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,iFAAiF,CAAC,CAAC;AACjG,KAAK,MAAM,CAAC,IAAI,MAAM;IAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAChD,OAAO,CAAC,KAAK,CACZ,yIAAyI,CACzI,CAAC;AACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/bin/doc-tokens.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* and differs, so this is a stable *proxy* for budgeting, not an exact count —
|
|
12
12
|
* good enough to catch bloat, consistent run-to-run.
|
|
13
13
|
*
|
|
14
|
-
* Scope: `docTokens.enforce`
|
|
15
|
-
*
|
|
14
|
+
* Scope: the `docTokens.enforce` pathspecs are what the gate fails on.
|
|
15
|
+
* `--report` lists every over-budget file without failing —
|
|
16
16
|
* the backlog worklist. Pass explicit paths to check only those (lefthook
|
|
17
17
|
* `{staged_files}`). Scoping is via `git ls-files` — gitignored paths are never
|
|
18
18
|
* measured unless passed explicitly.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-deps.d.ts","sourceRoot":"","sources":["../../src/bin/require-deps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Commit gate (on by default): the workspace catalog must define each
|
|
4
|
+
* org-required dependency. The org standardizes on `remeda` for functional
|
|
5
|
+
* helpers — rather than force every package to take the dep, we require it in the
|
|
6
|
+
* catalog so the blessed version is single-sourced and any package can adopt it
|
|
7
|
+
* with `catalog:`. Cataloguing it is the signal that its use is expected (and it
|
|
8
|
+
* pairs with helper-collisions, which flags inline reinventions of its exports).
|
|
9
|
+
*
|
|
10
|
+
* A dependency counts as satisfied if it's a key in the default catalog or any
|
|
11
|
+
* named `catalogs.<group>`. Configure the list via `requireDeps.deps` in
|
|
12
|
+
* nodeve.checks.js (default `['remeda']`); set `deps: []` to opt out.
|
|
13
|
+
*
|
|
14
|
+
* Workspace discovery is shared with the catalog gate (pnpm-workspace.yaml or
|
|
15
|
+
* package.json#workspaces), so it gates pnpm and Bun repos alike.
|
|
16
|
+
*/
|
|
17
|
+
import { loadConfig, parseArgs } from '../lib/config.js';
|
|
18
|
+
import { readWorkspace, repoRoot } from '../lib/repo.js';
|
|
19
|
+
const root = repoRoot();
|
|
20
|
+
const cfg = (await loadConfig(root)).requireDeps;
|
|
21
|
+
const { warn, verbose } = parseArgs(process.argv.slice(2));
|
|
22
|
+
if (cfg.deps.length === 0) {
|
|
23
|
+
if (verbose)
|
|
24
|
+
console.log('require-deps: no required deps configured — nothing to enforce');
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
const ws = readWorkspace(root);
|
|
28
|
+
if (!ws) {
|
|
29
|
+
if (verbose)
|
|
30
|
+
console.log('require-deps: no workspace manifest found — nothing to enforce');
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
// A dep is satisfied if any catalog (default or a named group) defines it.
|
|
34
|
+
const catalogued = new Set([
|
|
35
|
+
...Object.keys(ws.catalog),
|
|
36
|
+
...Object.values(ws.catalogs).flatMap((group) => Object.keys(group)),
|
|
37
|
+
]);
|
|
38
|
+
const missing = cfg.deps.filter((dep) => !catalogued.has(dep));
|
|
39
|
+
if (missing.length === 0) {
|
|
40
|
+
if (verbose)
|
|
41
|
+
console.log('require-deps: clean');
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
console.error('\n✖ the workspace catalog must define these org-required dependencies:\n');
|
|
45
|
+
for (const dep of missing)
|
|
46
|
+
console.error(` ${dep}`);
|
|
47
|
+
console.error(`\n Add them to the catalog (pnpm-workspace.yaml or package.json#workspaces), e.g.\n` +
|
|
48
|
+
` \`pnpm add -w ${missing.join(' ')}\`, so packages can adopt them with "catalog:".\n` +
|
|
49
|
+
' Set `requireDeps: { deps: [] }` in nodeve.checks.js to opt out.\n');
|
|
50
|
+
process.exit(warn ? 0 : 1);
|
|
51
|
+
//# sourceMappingURL=require-deps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-deps.js","sourceRoot":"","sources":["../../src/bin/require-deps.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAC;AACxB,MAAM,GAAG,GAAG,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC;AACjD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,IAAI,GAAG,CAA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AC,GAAG,CAAC,mDAAmD;IACvF,qEAAqE,CACtE,CAAC;AACF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type Budget = {
|
|
|
5
5
|
export type DocTokensConfig = {
|
|
6
6
|
maxLines: number;
|
|
7
7
|
maxTokens: number;
|
|
8
|
-
/**
|
|
8
|
+
/** Git pathspecs the gate FAILS on (and `--report` lists); `*` matches `/`. */
|
|
9
9
|
enforce: string[];
|
|
10
10
|
/** Per-file budget overrides, keyed by repo-root-relative path. */
|
|
11
11
|
overrides: Record<string, Partial<Budget>>;
|
|
@@ -59,6 +59,17 @@ export type HelperManifestConfig = {
|
|
|
59
59
|
/** Repo-root-relative output path. */
|
|
60
60
|
output: string;
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* On by default: the workspace catalog must define each listed dependency, so the
|
|
64
|
+
* version is blessed and ready to adopt with `catalog:` anywhere. The org
|
|
65
|
+
* standardizes on `remeda` for functional helpers — cataloguing it makes that
|
|
66
|
+
* expectation explicit without forcing every package to take the dep. Set
|
|
67
|
+
* `deps: []` to opt out.
|
|
68
|
+
*/
|
|
69
|
+
export type RequireDepsConfig = {
|
|
70
|
+
/** Bare package names the workspace catalog must define. */
|
|
71
|
+
deps: string[];
|
|
72
|
+
};
|
|
62
73
|
export type Config = {
|
|
63
74
|
docTokens: DocTokensConfig;
|
|
64
75
|
reshape: ReshapeConfig;
|
|
@@ -66,10 +77,16 @@ export type Config = {
|
|
|
66
77
|
helperCollisions: HelperCollisionsConfig;
|
|
67
78
|
pageSize: PageSizeConfig;
|
|
68
79
|
catalog: CatalogConfig;
|
|
80
|
+
requireDeps: RequireDepsConfig;
|
|
69
81
|
helperManifest: HelperManifestConfig;
|
|
70
82
|
};
|
|
71
83
|
export declare const DEFAULTS: Config;
|
|
72
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Load `nodeve.checks.*` from the repo root, deep-merging the user config over
|
|
86
|
+
* DEFAULTS. Nested records (e.g. `docTokens.overrides`) merge key-by-key; arrays
|
|
87
|
+
* (e.g. `docTokens.enforce`) are REPLACED wholesale, so a repo that sets `enforce`
|
|
88
|
+
* must restate the full list.
|
|
89
|
+
*/
|
|
73
90
|
export declare function loadConfig(root: string): Promise<Config>;
|
|
74
91
|
/** Shared CLI flag parsing — explicit paths plus the common toggles. */
|
|
75
92
|
export declare function parseArgs(argv: string[]): {
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,mFAAmF;IACnF,SAAS,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uDAAuD;IACvD,SAAS,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC,KAAK,EAAE,MAAM,EAAE,CAAC;I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,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAC1C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CACjB,CAOA"}
|
package/dist/lib/config.js
CHANGED
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
import { existsSync } from 'node:fs';
|
|
14
14
|
import { join } from 'node:path';
|
|
15
15
|
import { pathToFileURL } from 'node:url';
|
|
16
|
+
import { mergeDeep } from 'remeda';
|
|
16
17
|
export const DEFAULTS = {
|
|
17
18
|
docTokens: {
|
|
18
19
|
maxLines: 150,
|
|
19
20
|
maxTokens: 3000,
|
|
20
|
-
enforce: ['CLAUDE.md', 'guide/*.md', 'docs/*.md'],
|
|
21
|
+
enforce: ['CLAUDE.md', 'README.md', '*/README.md', 'guide/*.md', 'docs/*.md'],
|
|
21
22
|
overrides: {},
|
|
22
23
|
},
|
|
23
24
|
reshape: {
|
|
@@ -39,11 +40,18 @@ export const DEFAULTS = {
|
|
|
39
40
|
pageSize: { rules: [] },
|
|
40
41
|
// On by default: a workspace must declare a catalog (set enforce:false to opt out).
|
|
41
42
|
catalog: { enforce: true, allowlist: [] },
|
|
43
|
+
// On by default: the workspace catalog must define remeda (set deps:[] to opt out).
|
|
44
|
+
requireDeps: { deps: ['remeda'] },
|
|
42
45
|
// Opt-in: no packages → no-op.
|
|
43
46
|
helperManifest: { packages: [], output: '.nodeve/helper-manifest.txt' },
|
|
44
47
|
};
|
|
45
48
|
const CONFIG_FILES = ['nodeve.checks.js', 'nodeve.checks.mjs', 'nodeve.checks.config.js'];
|
|
46
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Load `nodeve.checks.*` from the repo root, deep-merging the user config over
|
|
51
|
+
* DEFAULTS. Nested records (e.g. `docTokens.overrides`) merge key-by-key; arrays
|
|
52
|
+
* (e.g. `docTokens.enforce`) are REPLACED wholesale, so a repo that sets `enforce`
|
|
53
|
+
* must restate the full list.
|
|
54
|
+
*/
|
|
47
55
|
export async function loadConfig(root) {
|
|
48
56
|
for (const name of CONFIG_FILES) {
|
|
49
57
|
const path = join(root, name);
|
|
@@ -51,15 +59,7 @@ export async function loadConfig(root) {
|
|
|
51
59
|
continue;
|
|
52
60
|
const mod = (await import(pathToFileURL(path).href));
|
|
53
61
|
const user = mod.default ?? mod;
|
|
54
|
-
return
|
|
55
|
-
docTokens: { ...DEFAULTS.docTokens, ...user.docTokens },
|
|
56
|
-
reshape: { ...DEFAULTS.reshape, ...user.reshape },
|
|
57
|
-
inlineDupes: { ...DEFAULTS.inlineDupes, ...user.inlineDupes },
|
|
58
|
-
helperCollisions: { ...DEFAULTS.helperCollisions, ...user.helperCollisions },
|
|
59
|
-
pageSize: { ...DEFAULTS.pageSize, ...user.pageSize },
|
|
60
|
-
catalog: { ...DEFAULTS.catalog, ...user.catalog },
|
|
61
|
-
helperManifest: { ...DEFAULTS.helperManifest, ...user.helperManifest },
|
|
62
|
-
};
|
|
62
|
+
return mergeDeep(DEFAULTS, user);
|
|
63
63
|
}
|
|
64
64
|
return DEFAULTS;
|
|
65
65
|
}
|
package/dist/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,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,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QAChC,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAsC,CAAC;QAC1F,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,IAAK,GAA2B,CAAC;QACzD,OAAO,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAW,CAAC;IAC5C,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,SAAS,CAAC,IAAc;IAMvC,OAAO;QACN,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC7B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;KACnC,CAAC;AACH,CAAC"}
|
package/dist/lib/repo.d.ts
CHANGED
|
@@ -10,4 +10,24 @@ export declare function repoRoot(): string;
|
|
|
10
10
|
* `[]` for an empty glob list — an unconfigured opt-in check then no-ops.
|
|
11
11
|
*/
|
|
12
12
|
export declare function gitFiles(root: string, globs: string[]): string[];
|
|
13
|
+
export type Catalog = Record<string, string>;
|
|
14
|
+
export type Workspace = {
|
|
15
|
+
packages: string[];
|
|
16
|
+
catalog: Catalog;
|
|
17
|
+
catalogs: Record<string, Catalog>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the workspace definition from whichever manifest the repo uses:
|
|
21
|
+
* `pnpm-workspace.yaml` (pnpm) takes precedence, else the root
|
|
22
|
+
* `package.json#workspaces` (Bun, where `workspaces` may be a bare array of
|
|
23
|
+
* globs or an object carrying the catalogs). Returns `null` when neither exists.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readWorkspace(root: string): Workspace | null;
|
|
26
|
+
/**
|
|
27
|
+
* Tracked `package.json` files for every workspace package, honoring the
|
|
28
|
+
* workspace globs' `!` negations — so callers see exactly the set the package
|
|
29
|
+
* manager installs. (Workspace `*` matches `/` in git pathspecs, same as
|
|
30
|
+
* pnpm/bun resolution.)
|
|
31
|
+
*/
|
|
32
|
+
export declare function workspaceManifests(root: string, ws: Workspace): string[];
|
|
13
33
|
//# sourceMappingURL=repo.d.ts.map
|
package/dist/lib/repo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/lib/repo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/lib/repo.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAIhE;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,SAAS,GAAG;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAe5D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,CAYxE"}
|
package/dist/lib/repo.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { parse as parseYaml } from 'yaml';
|
|
2
5
|
/**
|
|
3
6
|
* Absolute path to the enclosing git work tree. Every check resolves its scope
|
|
4
7
|
* and reads against this, so a check behaves the same no matter which cwd the
|
|
@@ -18,4 +21,43 @@ export function gitFiles(root, globs) {
|
|
|
18
21
|
const out = execFileSync('git', ['ls-files', ...globs], { cwd: root, encoding: 'utf8' });
|
|
19
22
|
return out.split('\n').filter(Boolean);
|
|
20
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the workspace definition from whichever manifest the repo uses:
|
|
26
|
+
* `pnpm-workspace.yaml` (pnpm) takes precedence, else the root
|
|
27
|
+
* `package.json#workspaces` (Bun, where `workspaces` may be a bare array of
|
|
28
|
+
* globs or an object carrying the catalogs). Returns `null` when neither exists.
|
|
29
|
+
*/
|
|
30
|
+
export function readWorkspace(root) {
|
|
31
|
+
const pnpm = join(root, 'pnpm-workspace.yaml');
|
|
32
|
+
if (existsSync(pnpm)) {
|
|
33
|
+
const ws = parseYaml(readFileSync(pnpm, 'utf8')) ?? {};
|
|
34
|
+
return { packages: ws.packages ?? [], catalog: ws.catalog ?? {}, catalogs: ws.catalogs ?? {} };
|
|
35
|
+
}
|
|
36
|
+
const pkgPath = join(root, 'package.json');
|
|
37
|
+
if (existsSync(pkgPath)) {
|
|
38
|
+
const ws = JSON.parse(readFileSync(pkgPath, 'utf8')).workspaces;
|
|
39
|
+
if (Array.isArray(ws))
|
|
40
|
+
return { packages: ws, catalog: {}, catalogs: {} };
|
|
41
|
+
if (ws && typeof ws === 'object') {
|
|
42
|
+
return { packages: ws.packages ?? [], catalog: ws.catalog ?? {}, catalogs: ws.catalogs ?? {} };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Tracked `package.json` files for every workspace package, honoring the
|
|
49
|
+
* workspace globs' `!` negations — so callers see exactly the set the package
|
|
50
|
+
* manager installs. (Workspace `*` matches `/` in git pathspecs, same as
|
|
51
|
+
* pnpm/bun resolution.)
|
|
52
|
+
*/
|
|
53
|
+
export function workspaceManifests(root, ws) {
|
|
54
|
+
const positives = ws.packages.filter((p) => !p.startsWith('!'));
|
|
55
|
+
const negatives = ws.packages
|
|
56
|
+
.filter((p) => p.startsWith('!'))
|
|
57
|
+
.map((p) => p.slice(1).replace(/\/\*+$/, ''));
|
|
58
|
+
return gitFiles(root, positives.map((p) => `${p}/package.json`)).filter((manifest) => {
|
|
59
|
+
const dir = dirname(manifest);
|
|
60
|
+
return !negatives.some((n) => dir === n || dir.startsWith(n + '/'));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
21
63
|
//# sourceMappingURL=repo.js.map
|
package/dist/lib/repo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../src/lib/repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../src/lib/repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,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;AAE1C;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACvB,OAAO,YAAY,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,iBAAiB,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,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in/nodeve-check-catalog
|
|
49
49
|
|
|
50
|
+
# Whole-tree property — the workspace catalog must define the org-required
|
|
51
|
+
# deps (remeda by default). No-ops where deps aren't configured.
|
|
52
|
+
- name: require-deps
|
|
53
|
+
glob: "{**/package.json,pnpm-workspace.yaml}"
|
|
54
|
+
run: node_modules/.bin/nodeve-check-require-deps
|
|
55
|
+
|
|
50
56
|
# Whole-tree relationships — scan the full configured scope, not just staged.
|
|
51
57
|
- name: inline-dupes
|
|
52
58
|
glob: "*.ts"
|
package/nodeve.checks.example.js
CHANGED
|
@@ -1,65 +1,37 @@
|
|
|
1
|
-
// Copy to your repo root as `nodeve.checks.js` and
|
|
2
|
-
// is optional
|
|
3
|
-
// @nodeve/checks
|
|
1
|
+
// Copy to your repo root as `nodeve.checks.js` and keep ONLY what you change.
|
|
2
|
+
// Every section is optional; omitted keys fall back to the org defaults baked
|
|
3
|
+
// into @nodeve/checks (see the `Config` type / `DEFAULTS` in the package for the
|
|
4
|
+
// authoritative values). The user config is deep-merged over those defaults:
|
|
5
|
+
// nested records merge key-by-key, but ARRAYS REPLACE — so if you set an array
|
|
6
|
+
// field (e.g. `docTokens.enforce`) you must restate the entries you want to keep,
|
|
7
|
+
// not just the ones you're adding.
|
|
8
|
+
//
|
|
9
|
+
// The blocks below are illustrative overrides, not the defaults. Delete any you
|
|
10
|
+
// don't need.
|
|
4
11
|
export default {
|
|
12
|
+
// Widen the enforced doc set (this array REPLACES the default list — the
|
|
13
|
+
// default is CLAUDE.md + READMEs + guide/ + docs/, restated here plus adr/):
|
|
5
14
|
docTokens: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// Globs the gate fails on (git pathspecs; `*` recurses).
|
|
9
|
-
enforce: ['CLAUDE.md', 'guide/*.md', 'docs/*.md'],
|
|
10
|
-
// Per-file budget overrides, keyed by repo-root-relative path.
|
|
15
|
+
enforce: ['CLAUDE.md', 'README.md', '*/README.md', 'guide/*.md', 'docs/*.md', 'adr/*.md'],
|
|
16
|
+
// Per-file budget bumps, keyed by repo-root-relative path (merges with defaults):
|
|
11
17
|
overrides: {
|
|
12
|
-
|
|
18
|
+
'CLAUDE.md': { maxTokens: 3500 },
|
|
13
19
|
},
|
|
14
20
|
},
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
18
|
-
// `relPath::kind::keys` — confirmed boundaries where the identical-shape
|
|
19
|
-
// reshape IS the point (kind ∈ identity|spread-clone|projection|passthrough).
|
|
20
|
-
allowlist: [],
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
inlineDupes: {
|
|
24
|
-
globs: ['apps/*.ts'],
|
|
25
|
-
// Bare names that legitimately recur across files.
|
|
26
|
-
allowlist: [],
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
helperCollisions: {
|
|
30
|
-
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
31
|
-
// Dependency surfaces you don't want reinvented inline.
|
|
32
|
-
libs: ['remeda'],
|
|
33
|
-
// Committed index, regenerated with `nodeve-build-lib-names`.
|
|
34
|
-
libNamesPath: '.nodeve/lib-names.json',
|
|
35
|
-
threshold: 0.8,
|
|
36
|
-
// `relPath::local→lib` — confirmed false positives.
|
|
37
|
-
allowlist: [],
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
// Opt-in: empty by default → the check no-ops. Each rule fails a file matching
|
|
41
|
-
// `glob` that exceeds `maxLines`.
|
|
22
|
+
// Opt in to a per-glob page-size budget (default: no rules → no-op):
|
|
42
23
|
pageSize: {
|
|
43
|
-
rules: [
|
|
44
|
-
// { glob: '*+page.svelte', maxLines: 280 },
|
|
45
|
-
],
|
|
24
|
+
rules: [{ glob: '*+page.svelte', maxLines: 280 }],
|
|
46
25
|
},
|
|
47
26
|
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// catalog
|
|
52
|
-
|
|
53
|
-
enforce: true,
|
|
54
|
-
// `manifest::name` — confirmed exceptions allowed to pin literally.
|
|
55
|
-
allowlist: [],
|
|
56
|
-
},
|
|
27
|
+
// Deliberately opt a repo out of the (default-on) catalog gate:
|
|
28
|
+
catalog: { enforce: false },
|
|
29
|
+
|
|
30
|
+
// Change the org-required catalog deps (default: ['remeda']; [] to opt out):
|
|
31
|
+
requireDeps: { deps: ['remeda'] },
|
|
57
32
|
|
|
58
|
-
// Opt
|
|
33
|
+
// Opt in to the helper-manifest index by listing package dirs to scan:
|
|
59
34
|
helperManifest: {
|
|
60
|
-
packages: [
|
|
61
|
-
// 'packages/utils', 'packages/server',
|
|
62
|
-
],
|
|
63
|
-
output: '.nodeve/helper-manifest.txt',
|
|
35
|
+
packages: ['packages/utils'],
|
|
64
36
|
},
|
|
65
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodeve/checks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Org-wide commit-gate checks (doc budgets, reshape/dup/helper smells, page size) and helper-index generators, driven by a per-repo config file and wired through lefthook.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -25,11 +25,13 @@
|
|
|
25
25
|
"nodeve-check-helper-collisions": "./dist/bin/helper-collisions.js",
|
|
26
26
|
"nodeve-check-page-size": "./dist/bin/page-size.js",
|
|
27
27
|
"nodeve-check-catalog": "./dist/bin/catalog.js",
|
|
28
|
+
"nodeve-check-require-deps": "./dist/bin/require-deps.js",
|
|
28
29
|
"nodeve-build-lib-names": "./dist/bin/build-lib-names.js",
|
|
29
30
|
"nodeve-build-helper-manifest": "./dist/bin/build-helper-manifest.js"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"js-tiktoken": "^1.0.0",
|
|
34
|
+
"remeda": "^2.0.0",
|
|
33
35
|
"typescript": "^5.5.0",
|
|
34
36
|
"yaml": "^2.5.0",
|
|
35
37
|
"@nodeve/text": "0.1.0"
|