runtime-pin-check 0.0.0-stage → 0.1.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.
@@ -0,0 +1,96 @@
1
+ import { C as Constraint, R as Runtime, S as Source, b as CompareOptions, F as Finding, c as Scope } from './types-Dgq4vv3C.js';
2
+ export { A as AliasResolver, d as ConstraintKind, e as FindingCode, a as Severity, f as SourceRef } from './types-Dgq4vv3C.js';
3
+
4
+ /** True for `latest`, `node`, `stable` and the like: pins that move by themselves. */
5
+ declare function isFloatingAlias(alias: string): boolean;
6
+ /**
7
+ * Parses the raw text of one pin for a runtime.
8
+ *
9
+ * @example
10
+ * parseConstraint('v22', 'node') // { kind: 'partial', version: '22' }
11
+ * parseConstraint('>=20 <23', 'node') // { kind: 'range', range: '>=20.0.0 <23.0.0-0' }
12
+ * parseConstraint('>=3.10,<3.14', 'python') // { kind: 'range', range: '>=3.10.0 <3.14.0-0' }
13
+ * parseConstraint('go1.24.4', 'go') // { kind: 'exact', version: '1.24.4' }
14
+ * parseConstraint('lts/iron', 'node') // { kind: 'alias', alias: 'lts/iron' }
15
+ */
16
+ declare function parseConstraint(raw: string, runtime: Runtime): Constraint;
17
+ /**
18
+ * The constraint of a Docker image tag: the version part only (`22-alpine` → partial 22,
19
+ * `22.11.0-bookworm-slim` → exact, `lts-alpine` → alias lts). A missing tag or a variant-only tag
20
+ * (`slim`, `alpine`) means `latest`. A digest (`@sha256:…`) is ignored.
21
+ */
22
+ declare function dockerTagConstraint(tag: string | undefined, runtime: Runtime): Constraint;
23
+ /**
24
+ * The semver range a constraint allows, for comparison (`partial 22` → `>=22.0.0 <23.0.0-0`).
25
+ * Aliases and unknown constraints have none and return undefined.
26
+ */
27
+ declare function toRange(c: Constraint): string | undefined;
28
+ /** Human-readable form of a constraint for messages (`22`, `>=20 <23`, `lts/iron`). */
29
+ declare function describeConstraint(c: Constraint): string;
30
+
31
+ /**
32
+ * True for a repo-level CI or tool file that applies to every project root: anything under
33
+ * `.github/` (any letter case: `.GitHub/` exists in the wild), `.gitlab-ci.yml`, and root-level
34
+ * version files (`.nvmrc`, `.tool-versions`, `mise.toml` …). Root manifests and Dockerfiles belong
35
+ * to the repo-root project only.
36
+ */
37
+ declare function isSharedFile(file: string): boolean;
38
+ /**
39
+ * The project roots a source applies to. After `bindSources` this is `source.boundTo` (`[]` for an
40
+ * UNBOUND source). Without binding it falls back to the pre-A12 rule: the deepest containing root,
41
+ * or every root for a shared CI/tool file (only the `workingDirectory` root when a step sets one).
42
+ *
43
+ * @param roots - Project roots from `findProjectRoots` (relative, `.` = repo root).
44
+ */
45
+ declare function scopesOf(source: Source, roots: readonly string[]): string[];
46
+ /** Groups sources by project root and runtime, in a stable order. */
47
+ declare function groupByScope(sources: readonly Source[], roots: readonly string[]): Scope[];
48
+ /**
49
+ * Compares the sources of every project root and runtime and returns the findings, most severe
50
+ * first. A finding that several roots share (a root-level file against another) is reported once
51
+ * with every root in `scopes`.
52
+ *
53
+ * Rules (docs/TASKS.md A10): a pin (exact/partial/resolved alias) outside a range source →
54
+ * OUTSIDE_RANGE, one per (pin, range) pair since each is a separate fix; pins that cannot all hold,
55
+ * or ranges with nothing in common → ONE VERSION_CONFLICT per runtime and scope listing every pin
56
+ * (and every range) grouped by version; agreeing pins written at different precision → ONE
57
+ * PRECISION_MISMATCH per runtime and scope. CI matrix entries are checked only against ranges. `latest`/`node`/`stable` → FLOATING_ALIAS and are not compared;
58
+ * text the extractor could not parse → UNPARSEABLE. Scopes with a single source produce nothing.
59
+ * Sources bound by `bindSources` are grouped by `boundTo`; UNBOUND ones (`boundTo: []`) only get
60
+ * UNPARSEABLE / FLOATING_ALIAS findings, with no scope (docs/TASKS.md A12).
61
+ *
62
+ * @param sources - Every source found in the repo.
63
+ * @param roots - Project roots (relative, `.` = repo root); defaults to the repo root only.
64
+ */
65
+ declare function compareSources(sources: readonly Source[], roots?: readonly string[], options?: CompareOptions): Finding[];
66
+
67
+ /** Directories never entered: dependencies, VCS data, build output, virtualenvs. */
68
+ declare const IGNORED_DIRS: ReadonlySet<string>;
69
+ /** Files whose presence makes a directory a project root. */
70
+ declare const ROOT_MARKERS: ReadonlySet<string>;
71
+ /** Options of `scanFiles` / `walkFiles`. */
72
+ interface ScanOptions {
73
+ /** Also scan fixture folders (`FIXTURE_DIR`; default false). */
74
+ includeFixtures?: boolean;
75
+ /**
76
+ * Extra paths to skip, as globs relative to the scanned directory: `*` and `?` stay inside one
77
+ * path segment, `**` crosses segments. A pattern without `/` matches a file or directory name at
78
+ * any depth (`examples`, `*.Dockerfile`); a pattern with `/` matches the whole relative path
79
+ * (`docs/**`, `services/legacy`). A matching directory is skipped with everything under it.
80
+ */
81
+ exclude?: readonly string[];
82
+ }
83
+ /** The files `scanFiles` keeps (fixtures and `exclude` matches left out unless asked for). */
84
+ declare function walkFiles(dir: string, options?: ScanOptions): Promise<string[]>;
85
+ /**
86
+ * The project roots of a repo: `.` (the repo root, always) plus every directory that contains a
87
+ * `package.json`, `pyproject.toml` or `go.mod` outside the `IGNORED_DIRS`. Relative paths with
88
+ * '/' separators, sorted.
89
+ *
90
+ * @param files - Optional result of `walkFiles(dir)`, to avoid walking twice.
91
+ */
92
+ declare function findProjectRoots(dir: string, files?: readonly string[]): Promise<string[]>;
93
+ /** The project roots implied by a list of relative file paths (see `findProjectRoots`). */
94
+ declare function projectRootsOf(files: readonly string[]): string[];
95
+
96
+ export { CompareOptions, Constraint, Finding, IGNORED_DIRS, ROOT_MARKERS, Runtime, Scope, Source, compareSources, describeConstraint, dockerTagConstraint, findProjectRoots, groupByScope, isFloatingAlias, isSharedFile, parseConstraint, projectRootsOf, scopesOf, toRange, walkFiles };
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ import {
2
+ IGNORED_DIRS,
3
+ ROOT_MARKERS,
4
+ compareSources,
5
+ describeConstraint,
6
+ dockerTagConstraint,
7
+ findProjectRoots,
8
+ groupByScope,
9
+ isFloatingAlias,
10
+ isSharedFile,
11
+ parseConstraint,
12
+ projectRootsOf,
13
+ scopesOf,
14
+ toRange,
15
+ walkFiles
16
+ } from "./chunk-TRO76P2I.js";
17
+ export {
18
+ IGNORED_DIRS,
19
+ ROOT_MARKERS,
20
+ compareSources,
21
+ describeConstraint,
22
+ dockerTagConstraint,
23
+ findProjectRoots,
24
+ groupByScope,
25
+ isFloatingAlias,
26
+ isSharedFile,
27
+ parseConstraint,
28
+ projectRootsOf,
29
+ scopesOf,
30
+ toRange,
31
+ walkFiles
32
+ };
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Shared shapes of runtime-pin-check (docs/TASKS.md, Domain model). Extractors build `Source`s,
3
+ * `compare.ts` turns them into `Finding`s. Changes here need a ruling: other tasks build on them.
4
+ */
5
+ /** The runtimes this tool compares. */
6
+ type Runtime = 'node' | 'python' | 'go';
7
+ /** How serious a finding is. */
8
+ type Severity = 'error' | 'warning' | 'info';
9
+ /**
10
+ * A pinned version, normalised from the raw text of a source.
11
+ * - `exact`: one release, e.g. `22.11.0`.
12
+ * - `partial`: a version prefix, e.g. `22` or `22.11`: any release with that prefix.
13
+ * - `range`: a semver range, e.g. `>=20 <23` or `^22`, already converted to semver syntax.
14
+ * - `alias`: a name resolved elsewhere, e.g. `lts/*`, `lts/iron`, `latest`, `node`, `stable`.
15
+ * - `unknown`: text the parser could not interpret; it yields an UNPARSEABLE finding.
16
+ */
17
+ type Constraint = {
18
+ kind: 'exact';
19
+ version: string;
20
+ } | {
21
+ kind: 'partial';
22
+ version: string;
23
+ } | {
24
+ kind: 'range';
25
+ range: string;
26
+ } | {
27
+ kind: 'alias';
28
+ alias: string;
29
+ } | {
30
+ kind: 'unknown';
31
+ reason: string;
32
+ };
33
+ type ConstraintKind = Constraint['kind'];
34
+ /** One place in the repo that pins a runtime version. */
35
+ interface Source {
36
+ runtime: Runtime;
37
+ /** Path relative to the scanned directory, with '/' separators (e.g. `packages/a/.nvmrc`). */
38
+ file: string;
39
+ /** 1-based line of the value. */
40
+ line: number;
41
+ /** 1-based column of the value, when the extractor knows it. */
42
+ column?: number;
43
+ /** The value exactly as written in the file (e.g. `v22`, `>=20 <23`, `22-alpine`). */
44
+ raw: string;
45
+ /** Extractor id, e.g. `nvmrc`, `engines`, `dockerfile`, `setup-node`. */
46
+ kind: string;
47
+ constraint: Constraint;
48
+ /**
49
+ * A CI matrix entry: a deliberate multi-version test. Compared only against range sources,
50
+ * never against other pins (docs/TASKS.md, Extractors).
51
+ */
52
+ matrix?: boolean;
53
+ /**
54
+ * For a CI step that sets `working-directory`: the project root it applies to (relative path,
55
+ * `.` for the repo root). Without it, a root-level CI/tool file applies to every project root.
56
+ */
57
+ workingDirectory?: string;
58
+ /**
59
+ * Repo-relative paths that the same CI step or job names (`cache-dependency-path`,
60
+ * `node-version-file`, `python-version-file`, `go-version-file`, the `working-directory` of the
61
+ * job's steps). Set by extractors; used to bind a root CI source to the sub-projects it builds
62
+ * (docs/TASKS.md A12).
63
+ */
64
+ paths?: string[];
65
+ /**
66
+ * Project roots this source belongs to, as decided by `bindSources` (docs/TASKS.md A12).
67
+ * `[]` means UNBOUND: not tied to any project, so it is never compared with other pins.
68
+ * Absent until `bindSources` runs.
69
+ */
70
+ boundTo?: string[];
71
+ }
72
+ /**
73
+ * A file the tool could not (fully) read: a YAML, TOML or JSON syntax error. Not a finding: a broken
74
+ * file has no runtime to compare. Reported in `--json` (`diagnostics`), in the text report and as a
75
+ * GitHub `::warning`; it never changes the exit code (docs/TASKS.md constraint 9: no silent skips).
76
+ */
77
+ interface Diagnostic {
78
+ /** Repo-relative path with `/` separators. */
79
+ file: string;
80
+ /** 1-based line of the error. */
81
+ line: number;
82
+ /** 1-based column of the error, when the parser knows it. */
83
+ column?: number;
84
+ /** English explanation including what was and was not read. */
85
+ message: string;
86
+ }
87
+ /** Stable machine codes of every finding. */
88
+ type FindingCode = 'VERSION_CONFLICT' | 'OUTSIDE_RANGE' | 'PRECISION_MISMATCH' | 'EOL_RUNTIME' | 'EOL_SOON' | 'FLOATING_ALIAS' | 'UNPARSEABLE';
89
+ /** A source as cited by a finding. */
90
+ interface SourceRef {
91
+ file: string;
92
+ line: number;
93
+ raw: string;
94
+ constraint: Constraint;
95
+ }
96
+ /** One problem, with every source involved. */
97
+ interface Finding {
98
+ code: FindingCode;
99
+ severity: Severity;
100
+ runtime: Runtime;
101
+ /** Every source involved, in a stable order (file, then line). */
102
+ sources: SourceRef[];
103
+ /** Project roots (relative paths, `.` = repo root) where this finding applies. */
104
+ scopes: string[];
105
+ /** English explanation naming the files and lines. */
106
+ message: string;
107
+ }
108
+ /**
109
+ * Resolves an alias such as `lts/iron` or `lts/*` to a semver range, or returns undefined when it
110
+ * cannot. Supplied by the EOL snapshot (rpc-eol); comparison works without it.
111
+ */
112
+ type AliasResolver = (runtime: Runtime, alias: string) => string | undefined;
113
+ /** Options of `compareSources`. */
114
+ interface CompareOptions {
115
+ resolveAlias?: AliasResolver;
116
+ }
117
+ /** The sources of one runtime in one project root, as `compareSources` grouped them. */
118
+ interface Scope {
119
+ root: string;
120
+ runtime: Runtime;
121
+ sources: Source[];
122
+ }
123
+
124
+ export type { AliasResolver as A, Constraint as C, Diagnostic as D, Finding as F, Runtime as R, Source as S, Severity as a, CompareOptions as b, Scope as c, ConstraintKind as d, FindingCode as e, SourceRef as f };
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "runtime-pin-check",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Find Node, Python and Go version pins that disagree across a repo's files, with file and line.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=22"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "bin": {
14
+ "runtime-pin-check": "dist/cli.js"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "sideEffects": false,
26
+ "scripts": {
27
+ "typecheck": "tsc --noEmit",
28
+ "test": "vitest run",
29
+ "build": "tsup",
30
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
31
+ },
32
+ "keywords": [
33
+ "node-version",
34
+ "nvmrc",
35
+ "engines",
36
+ "python-version",
37
+ "go-version",
38
+ "ci",
39
+ "monorepo"
40
+ ],
41
+ "dependencies": {
42
+ "semver": "7.7.2",
43
+ "smol-toml": "1.9.1",
44
+ "yaml": "2.9.1"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "22.20.5",
48
+ "@types/semver": "7.7.0",
49
+ "tsup": "8.5.0",
50
+ "typescript": "5.9.3",
51
+ "vitest": "3.2.4"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/Mammost1/runtime-pin-check.git"
56
+ },
57
+ "homepage": "https://github.com/Mammost1/runtime-pin-check#readme",
58
+ "bugs": {
59
+ "url": "https://github.com/Mammost1/runtime-pin-check/issues"
60
+ }
61
+ }