@theholocron/astromech 5.0.0-alpha.60 → 5.0.0-alpha.600

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,132 @@
1
+ /**
2
+ * One entry of the task manifest: a registry task by name, with the options that change how it is generated and
3
+ * run.
4
+ */
5
+ interface TaskEntry {
6
+ /** Registry task name — `verification.unitTests`, `sourceQuality.staticAnalysis`, `delivery.build`, … */
7
+ name: string;
8
+ /**
9
+ * Emit a `.github/workflows/<name>.yml` thin caller and include the task
10
+ * in `holocron run ci`. Default `true`.
11
+ */
12
+ ci?: boolean;
13
+ /**
14
+ * Sentinel posts this task's check, so no Actions workflow does (`process-sentinel-and-actions-roles`, #2263). No thin
15
+ * caller is written, but the task stays in the manifest: `holocron run ci` runs it locally, and with `required: true` the
16
+ * `ci` aggregate still waits for a check named `<id> / ...`, which Sentinel's check supplies. Unlike `ci: false`, which
17
+ * also takes the task out of `holocron run ci`. Default `false`.
18
+ */
19
+ sentinel?: boolean;
20
+ /**
21
+ * Write a `"<name>": "holocron run <name>"` script to `package.json` and
22
+ * let `holocron run <name>` resolve the task. Default `true`.
23
+ * `false` → `holocron run <name>` prints "CI-only task" and exits 0.
24
+ */
25
+ local?: boolean;
26
+ /**
27
+ * The task's CI check context (from `WORKFLOW_CHECK_CONTEXTS`) is a
28
+ * required status check in branch protection (`astromech.requiredChecks()`)
29
+ * and part of `holocron run ci`'s default run.
30
+ */
31
+ required?: boolean;
32
+ /** Per-repo overrides on the same channel the reusable workflow reads. */
33
+ with?: Record<string, unknown>;
34
+ /** Extra `on.push.paths` entries for the generated CI workflow. */
35
+ paths?: string[];
36
+ /**
37
+ * Per-repo additions to this task's generated `turbo.json` entry — a
38
+ * separate channel from `with:` (that's the reusable *workflow's* inputs;
39
+ * this is local turbo cache config, unrelated). No-op for a task with no
40
+ * {@link TurboTaskConfig} in the registry (nothing to add to).
41
+ */
42
+ turbo?: {
43
+ /** Extra env vars turbo hashes into this task's cache key, appended to the registry default (empty when the task has none). */
44
+ passThroughEnv?: string[];
45
+ /**
46
+ * Extra input globs appended to the registry default's `inputs`
47
+ * (holocron#845) — for a package whose layout the registry's
48
+ * `"src/**"` default doesn't cover (e.g. a flat-layout package with
49
+ * no `src/` directory at all). Appended, not replaced: the
50
+ * registry's other inputs (`package.json`, `tsdown.config.ts`, …)
51
+ * stay tracked without needing to be repeated here.
52
+ */
53
+ inputs?: string[];
54
+ /**
55
+ * Extra tasks this one waits for, appended to the registry default's
56
+ * `dependsOn` — for a build the package does not list as a dependency
57
+ * but its task loads anyway (e.g. `staticAnalysis` loading the root
58
+ * ESLint config, which imports a package of the workspace). Turbo
59
+ * syntax: `"<package>#<task>"`, `"^<task>"`.
60
+ */
61
+ dependsOn?: string[];
62
+ };
63
+ }
64
+ /** A task is either its bare name (all defaults) or an entry object. */
65
+ type TaskConfigItem = string | TaskEntry;
66
+ /** The part of `holocron.config` that holds the task manifest and the switches around it. */
67
+ interface TasksConfig {
68
+ /** The manifest. */
69
+ tasks?: TaskConfigItem[];
70
+ /** Opt out of the `package.json` script writes. Default `true`. */
71
+ syncScripts?: boolean;
72
+ /**
73
+ * The command the synced `"holocron"` `package.json` script runs. Default
74
+ * `"holocron"` (the installed bin). The source repo overrides it to run
75
+ * its own build, e.g. `"node cli/cli/dist/cli.mjs"`.
76
+ */
77
+ holocronScript?: string;
78
+ /**
79
+ * Required status-check contexts not backed by a task — codecov gates,
80
+ * a bundle-build check, … Appended to `astromech.requiredChecks()` after the
81
+ * `required`-task contexts. (`DCO` is prepended by `holocron setup` itself.)
82
+ */
83
+ extraRequiredChecks?: string[];
84
+ /**
85
+ * Settings of the repo's CI as a whole. Left out, everything is as it was: the Actions poller posts the `ci` aggregate.
86
+ * Read at the **head** ref by Sentinel, so a commit carries both the files that run for it and the word that says who
87
+ * posts (spec `process-sentinel-posts-ci`, SPEC-0099).
88
+ */
89
+ ci?: CiConfig;
90
+ /**
91
+ * Git hooks `holocron setup` installs. `true` / `{ prePush: true }` writes
92
+ * `.husky/pre-push` (runs `holocron run ci`); `false` / `{ prePush: false }`
93
+ * opts out. Omitted → on for `protection: "strict"` repos, off otherwise.
94
+ * When enabled, `packageScripts()` also emits `prepare: "husky"`.
95
+ */
96
+ hooks?: boolean | {
97
+ prePush?: boolean;
98
+ };
99
+ }
100
+ /**
101
+ * Who posts the required `ci / Required checks` check: the Actions poller (`ci.yml`), Sentinel from webhooks, or nobody
102
+ * (`"none"`: there is no aggregate and the ruleset requires each check on its own).
103
+ */
104
+ type CiAggregatePoster = "actions" | "sentinel" | "none";
105
+ /** Who may satisfy the required `ci / Required checks` context: one GitHub App, by its integration id. */
106
+ interface CiPin {
107
+ /**
108
+ * The numeric id of the GitHub App (the ruleset's `integration_id`) whose check runs may satisfy
109
+ * `ci / Required checks`. For Sentinel's production App, use its App id (the one `githubApps` and
110
+ * `SENTINEL_GITHUB_APP_ID` hold); a dev instance has another id and does not count. Setting it changes who can merge,
111
+ * so turn it on only once the outage runbook's bypass is settled (spec `process-sentinel-posts-ci`, phase 10).
112
+ */
113
+ integrationId: number;
114
+ }
115
+ /** The `ci` block of the manifest. */
116
+ interface CiConfig {
117
+ /**
118
+ * Who posts `ci / Required checks`. `"actions"` (the default) keeps the thin caller `ci.ci.yml` and the reusable that
119
+ * polls; `"sentinel"` writes neither, because Sentinel posts the check under that name for a commit whose own config
120
+ * says so; `"none"` writes neither and the ruleset requires every check on its own (`requiredChecks()` lists them), so
121
+ * nothing is posted under that name. Each commit has at most one poster: the setting and the generated files change
122
+ * together in one pull request, which `probe generated check` enforces.
123
+ */
124
+ aggregate?: CiAggregatePoster;
125
+ /**
126
+ * Opt in to pinning the required `ci / Required checks` context to one GitHub App. Off when omitted: the ruleset names
127
+ * the context only, so any app (or a workflow) can satisfy it. `holocron setup` writes `integration_id` on that one
128
+ * entry of a `strict` repo's ruleset; `holocron doctor repo` compares it. Other required checks are never pinned.
129
+ */
130
+ pin?: CiPin;
131
+ }
132
+ export { TaskEntry as a, TaskConfigItem as i, CiConfig as n, TasksConfig as o, CiPin as r, CiAggregatePoster as t };
@@ -0,0 +1,126 @@
1
+ import { FetchLatest } from "@theholocron/pkg-utils";
2
+ /**
3
+ * Read the repo's current Node.js major from `.nvmrc`, `.node-version`, then `package.json` `engines.node`.
4
+ *
5
+ * @param cwd - The repo root.
6
+ * @param readFile - Reads a file as text; throws when absent.
7
+ * @returns The major, or `null` when no pin is found.
8
+ */
9
+ export declare function detectNodeMajor(cwd: string, readFile: (path: string) => string): number | null;
10
+ /**
11
+ * Resolve a package's `latest` dist-tag from the npm registry.
12
+ *
13
+ * Never throws: a network failure, timeout, or non-2xx response resolves to `null`.
14
+ */
15
+ export declare const fetchLatestFromNpm: FetchLatest;
16
+ /**
17
+ * Rewrite `FROM node:N` (any tag suffix is kept) in a Dockerfile.
18
+ *
19
+ * @param content - The raw Dockerfile text.
20
+ * @param from - The major being replaced.
21
+ * @param to - The major to pin.
22
+ * @returns The new text, or `null` when nothing changed.
23
+ */
24
+ export declare function patchDockerfile(content: string, from: number, to: number): string | null;
25
+ /**
26
+ * Rewrite the Node.js pins in a `package.json`: `engines.node` (`>=N` / `>=N.0.0`) and an exact
27
+ * `@types/node` range (`^N.0.0`). `catalog:` pins are left alone.
28
+ *
29
+ * @param content - The raw `package.json` text.
30
+ * @param from - The major being replaced.
31
+ * @param to - The major to pin.
32
+ * @returns The new text, or `null` when nothing changed (or the JSON is unparseable).
33
+ */
34
+ export declare function patchPackageJson(content: string, from: number, to: number): string | null;
35
+ /**
36
+ * Rewrite a `.nvmrc` / `.node-version` file holding `N` or `N.x.y`.
37
+ *
38
+ * @param content - The raw file text.
39
+ * @param from - The major being replaced.
40
+ * @param to - The major to pin.
41
+ * @returns `"<to>\n"`, or `null` when the file pins a different major.
42
+ */
43
+ export declare function patchPinFile(content: string, from: number, to: number): string | null;
44
+ /**
45
+ * Rewrite the `nodejs N` line in an asdf `.tool-versions` file.
46
+ *
47
+ * @param content - The raw file text.
48
+ * @param from - The major being replaced.
49
+ * @param to - The major to pin.
50
+ * @returns The new text, or `null` when nothing changed.
51
+ */
52
+ export declare function patchToolVersions(content: string, from: number, to: number): string | null;
53
+ /**
54
+ * Rewrite `node-version: N` (bare, single- or double-quoted) in a YAML file such as a GitHub Actions workflow.
55
+ *
56
+ * @param content - The raw YAML text.
57
+ * @param from - The major being replaced.
58
+ * @param to - The major to pin.
59
+ * @returns The new text, or `null` when nothing changed.
60
+ */
61
+ export declare function patchYaml(content: string, from: number, to: number): string | null;
62
+ /** One kind of file that pins the Node.js major. */
63
+ interface NodePinPattern {
64
+ /** True when this pattern applies to the file's basename. */
65
+ matches: (filename: string) => boolean;
66
+ /** The new content, or `null` when nothing in the file changed. */
67
+ patch: (content: string, from: number, to: number) => string | null;
68
+ }
69
+ /** Structured-logging sink for `runUpgradeNode`; any pino-style logger fits. */
70
+ interface UpgradeNodeLogger {
71
+ /** Records a per-file debug line. */
72
+ debug(obj: Record<string, unknown>, msg?: string): void;
73
+ /** Records the start and the outcome of a run. */
74
+ info(obj: Record<string, unknown>, msg?: string): void;
75
+ /** Records a run that could not proceed. */
76
+ warn(obj: Record<string, unknown>, msg?: string): void;
77
+ }
78
+ /** Input to `runUpgradeNode`. */
79
+ interface RunUpgradeNodeInput {
80
+ /** Target Node.js major version (e.g., 22). */
81
+ to: number;
82
+ /** Source major version. Auto-detected from .nvmrc / engines.node when omitted. */
83
+ from?: number;
84
+ /** Working directory (repo root). Defaults to process.cwd(). */
85
+ cwd?: string;
86
+ /** Print what would change without writing anything. */
87
+ dryRun?: boolean;
88
+ /**
89
+ * Extra file paths (relative to cwd) to scan in addition to the normal walk. Use for non-conventional
90
+ * locations not covered by the pattern registry (e.g., a `.tool-versions` in a subdirectory).
91
+ */
92
+ extra?: string[];
93
+ /** Writes one line of progress output. Defaults to `console.log`. */
94
+ print?: (line: string) => void;
95
+ /** Structured-logging sink. Defaults to a no-op. */
96
+ logger?: UpgradeNodeLogger;
97
+ /** Injectable for testing. */
98
+ readFile?: (path: string) => string;
99
+ /** Injectable for testing. */
100
+ writeFile?: (path: string, content: string) => void;
101
+ /** Injectable for testing; lists every file under `dir`, skipping build and VCS folders by default. */
102
+ walkFiles?: (dir: string) => string[];
103
+ }
104
+ /** How a run ended: files written, nothing written because of `dryRun`, or a failure. */
105
+ type UpgradeNodeStatus = "ok" | "fail" | "dry-run";
106
+ /** What `runUpgradeNode` did. */
107
+ interface UpgradeNodeReport {
108
+ /** How the run ended. */
109
+ status: UpgradeNodeStatus;
110
+ /** Repo-relative paths that were (or, in dry-run, would be) patched. */
111
+ updated: readonly string[];
112
+ /** Why the run failed; set only when `status` is `"fail"`. */
113
+ message?: string;
114
+ }
115
+ /**
116
+ * Scan a repo and rewrite every Node.js version pin (`engines.node`, `@types/node`, `.nvmrc`,
117
+ * `.node-version`, workflow `node-version:`, Dockerfile `FROM node:`, `.tool-versions`) from one major to
118
+ * another. The current major is auto-detected when `from` is omitted.
119
+ *
120
+ * Never throws: an unreadable tree or an undetectable version resolves to `{ status: "fail", message }`.
121
+ *
122
+ * @param input - Target major, optional source major, and injectable I/O.
123
+ * @returns The status and the repo-relative paths that were (or, in dry-run, would be) patched.
124
+ */
125
+ export declare function runUpgradeNode(input: RunUpgradeNodeInput): Promise<UpgradeNodeReport>;
126
+ export type { NodePinPattern, RunUpgradeNodeInput, UpgradeNodeLogger, UpgradeNodeReport, UpgradeNodeStatus };
@@ -0,0 +1,283 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import { basename, join, resolve, sep } from "node:path";
3
+ import { stringifyJson } from "@theholocron/json-utils";
4
+ import { walkFilesSync } from "@theholocron/fs-utils";
5
+ import { errorMessage } from "@theholocron/misc-utils";
6
+ // src/upgrade/detect-node-major/detect-node-major.ts
7
+ /**
8
+ * Read the repo's current Node.js major from `.nvmrc`, `.node-version`, then `package.json` `engines.node`.
9
+ *
10
+ * @param cwd - The repo root.
11
+ * @param readFile - Reads a file as text; throws when absent.
12
+ * @returns The major, or `null` when no pin is found.
13
+ */
14
+ function detectNodeMajor(cwd, readFile) {
15
+ for (const name of [".nvmrc", ".node-version"]) try {
16
+ const major = parseInt(readFile(join(cwd, name)).trim(), 10);
17
+ if (!isNaN(major)) return major;
18
+ } catch {}
19
+ try {
20
+ const node = JSON.parse(readFile(join(cwd, "package.json"))).engines?.node;
21
+ if (node) {
22
+ const m = node.match(/(\d+)/);
23
+ if (m) return parseInt(m[1], 10);
24
+ }
25
+ } catch {}
26
+ return null;
27
+ }
28
+ // src/upgrade/fetch-latest-from-npm/fetch-latest-from-npm.ts
29
+ const FETCH_TIMEOUT_MS = 4e3;
30
+ /**
31
+ * Resolve a package's `latest` dist-tag from the npm registry.
32
+ *
33
+ * Never throws: a network failure, timeout, or non-2xx response resolves to `null`.
34
+ */
35
+ const fetchLatestFromNpm = async (pkg) => {
36
+ try {
37
+ const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkg)}`, {
38
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
39
+ headers: { accept: "application/vnd.npm.install-v1+json" }
40
+ });
41
+ if (!res.ok) return null;
42
+ return (await res.json())["dist-tags"]?.["latest"] ?? null;
43
+ } catch {
44
+ return null;
45
+ }
46
+ };
47
+ // src/upgrade/patch-dockerfile/patch-dockerfile.ts
48
+ /**
49
+ * Rewrite `FROM node:N` (any tag suffix is kept) in a Dockerfile.
50
+ *
51
+ * @param content - The raw Dockerfile text.
52
+ * @param from - The major being replaced.
53
+ * @param to - The major to pin.
54
+ * @returns The new text, or `null` when nothing changed.
55
+ */
56
+ function patchDockerfile(content, from, to) {
57
+ const updated = content.replace(/^(FROM\s+node:)(\d+)/gm, (match, prefix, ver) => ver === String(from) ? `${prefix}${to}` : match);
58
+ return updated !== content ? updated : null;
59
+ }
60
+ // src/upgrade/patch-package-json/patch-package-json.ts
61
+ /**
62
+ * Rewrite the Node.js pins in a `package.json`: `engines.node` (`>=N` / `>=N.0.0`) and an exact
63
+ * `@types/node` range (`^N.0.0`). `catalog:` pins are left alone.
64
+ *
65
+ * @param content - The raw `package.json` text.
66
+ * @param from - The major being replaced.
67
+ * @param to - The major to pin.
68
+ * @returns The new text, or `null` when nothing changed (or the JSON is unparseable).
69
+ */
70
+ function patchPackageJson(content, from, to) {
71
+ let pkg;
72
+ try {
73
+ pkg = JSON.parse(content);
74
+ } catch {
75
+ return null;
76
+ }
77
+ let changed = false;
78
+ const engines = pkg.engines;
79
+ if (engines?.node && /^>=\d+(?:\.0\.0)?$/.test(engines.node)) {
80
+ if (parseInt(engines.node.match(/\d+/)[0], 10) === from) {
81
+ engines.node = `>=${to}.0.0`;
82
+ changed = true;
83
+ }
84
+ }
85
+ for (const field of ["devDependencies", "dependencies"]) {
86
+ const deps = pkg[field];
87
+ if (!deps?.["@types/node"]) continue;
88
+ if (deps["@types/node"] === `^${from}.0.0`) {
89
+ deps["@types/node"] = `^${to}.0.0`;
90
+ changed = true;
91
+ }
92
+ }
93
+ return changed ? stringifyJson(pkg, { like: content }) : null;
94
+ }
95
+ // src/upgrade/patch-pin-file/patch-pin-file.ts
96
+ /**
97
+ * Rewrite a `.nvmrc` / `.node-version` file holding `N` or `N.x.y`.
98
+ *
99
+ * @param content - The raw file text.
100
+ * @param from - The major being replaced.
101
+ * @param to - The major to pin.
102
+ * @returns `"<to>\n"`, or `null` when the file pins a different major.
103
+ */
104
+ function patchPinFile(content, from, to) {
105
+ const trimmed = content.trim();
106
+ if (trimmed === String(from) || trimmed.startsWith(`${from}.`)) return `${to}\n`;
107
+ return null;
108
+ }
109
+ // src/upgrade/patch-tool-versions/patch-tool-versions.ts
110
+ /**
111
+ * Rewrite the `nodejs N` line in an asdf `.tool-versions` file.
112
+ *
113
+ * @param content - The raw file text.
114
+ * @param from - The major being replaced.
115
+ * @param to - The major to pin.
116
+ * @returns The new text, or `null` when nothing changed.
117
+ */
118
+ function patchToolVersions(content, from, to) {
119
+ const updated = content.replace(/^(nodejs\s+)(\d+)/gm, (match, prefix, ver) => ver === String(from) ? `${prefix}${to}` : match);
120
+ return updated !== content ? updated : null;
121
+ }
122
+ // src/upgrade/patch-yaml/patch-yaml.ts
123
+ /**
124
+ * Rewrite `node-version: N` (bare, single- or double-quoted) in a YAML file such as a GitHub Actions workflow.
125
+ *
126
+ * @param content - The raw YAML text.
127
+ * @param from - The major being replaced.
128
+ * @param to - The major to pin.
129
+ * @returns The new text, or `null` when nothing changed.
130
+ */
131
+ function patchYaml(content, from, to) {
132
+ const updated = content.replace(/node-version:\s+['"]?(\d+)['"]?/g, (match, ver) => ver === String(from) ? match.replace(String(from), String(to)) : match);
133
+ return updated !== content ? updated : null;
134
+ }
135
+ // src/upgrade/upgrade-node/upgrade-node.ts
136
+ /** Directories skipped when walking the repo tree. */
137
+ const SKIP_DIRS = [
138
+ "node_modules",
139
+ ".git",
140
+ "dist",
141
+ "coverage",
142
+ "build",
143
+ ".turbo",
144
+ ".next",
145
+ "out"
146
+ ];
147
+ /**
148
+ * The registry of files that pin a Node.js major. To cover a new file type, add an entry here: a `matches`
149
+ * predicate on the basename and a `patch` function.
150
+ */
151
+ const PATTERNS = [
152
+ {
153
+ matches: (n) => n === "package.json",
154
+ patch: patchPackageJson
155
+ },
156
+ {
157
+ matches: (n) => n.endsWith(".yml") || n.endsWith(".yaml"),
158
+ patch: patchYaml
159
+ },
160
+ {
161
+ matches: (n) => n === ".nvmrc" || n === ".node-version",
162
+ patch: patchPinFile
163
+ },
164
+ {
165
+ matches: (n) => n === "Dockerfile" || n.startsWith("Dockerfile."),
166
+ patch: patchDockerfile
167
+ },
168
+ {
169
+ matches: (n) => n === ".tool-versions",
170
+ patch: patchToolVersions
171
+ }
172
+ ];
173
+ const noopLogger = {
174
+ debug() {},
175
+ info() {},
176
+ warn() {}
177
+ };
178
+ const defaultWalkFiles = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS });
179
+ /**
180
+ * Scan a repo and rewrite every Node.js version pin (`engines.node`, `@types/node`, `.nvmrc`,
181
+ * `.node-version`, workflow `node-version:`, Dockerfile `FROM node:`, `.tool-versions`) from one major to
182
+ * another. The current major is auto-detected when `from` is omitted.
183
+ *
184
+ * Never throws: an unreadable tree or an undetectable version resolves to `{ status: "fail", message }`.
185
+ *
186
+ * @param input - Target major, optional source major, and injectable I/O.
187
+ * @returns The status and the repo-relative paths that were (or, in dry-run, would be) patched.
188
+ */
189
+ async function runUpgradeNode(input) {
190
+ const print = input.print ?? ((line) => console.log(line));
191
+ const logger = input.logger ?? noopLogger;
192
+ const cwd = input.cwd ?? process.cwd();
193
+ const { to, dryRun = false, extra = [] } = input;
194
+ const _readFile = input.readFile ?? ((p) => readFileSync(p, "utf8"));
195
+ const _writeFile = input.writeFile ?? ((p, c) => writeFileSync(p, c));
196
+ const _walkFiles = input.walkFiles ?? defaultWalkFiles;
197
+ let walked;
198
+ try {
199
+ walked = _walkFiles(cwd);
200
+ } catch (error) {
201
+ const message = `could not read ${cwd}: ${errorMessage(error)}`;
202
+ logger.warn({
203
+ to,
204
+ reason: message
205
+ }, "upgrade node: done");
206
+ return {
207
+ status: "fail",
208
+ updated: [],
209
+ message
210
+ };
211
+ }
212
+ const from = input.from ?? detectNodeMajor(cwd, _readFile);
213
+ if (from === null) {
214
+ const message = "could not detect current Node version — pass --from <major>";
215
+ logger.warn({
216
+ to,
217
+ reason: message
218
+ }, "upgrade node: done");
219
+ return {
220
+ status: "fail",
221
+ updated: [],
222
+ message
223
+ };
224
+ }
225
+ logger.info({
226
+ from,
227
+ to,
228
+ dryRun: dryRun || void 0
229
+ }, "upgrade node: start");
230
+ if (from === to) {
231
+ print(`Already at Node.js ${to} — nothing to do.`);
232
+ logger.info({
233
+ from,
234
+ to,
235
+ updated: 0,
236
+ status: "ok"
237
+ }, "upgrade node: done");
238
+ return {
239
+ status: "ok",
240
+ updated: []
241
+ };
242
+ }
243
+ print(`Upgrading Node.js ${from} → ${to}${dryRun ? " (dry-run)" : ""}…`);
244
+ const updated = [];
245
+ const root = resolve(cwd);
246
+ const scanned = [...walked, ...extra.map((p) => join(cwd, p))];
247
+ for (const abs of scanned) {
248
+ const name = basename(abs);
249
+ const pattern = PATTERNS.find((p) => p.matches(name));
250
+ if (!pattern) continue;
251
+ let content;
252
+ try {
253
+ content = _readFile(abs);
254
+ } catch {
255
+ continue;
256
+ }
257
+ const patched = pattern.patch(content, from, to);
258
+ if (patched === null) continue;
259
+ const absolute = resolve(abs);
260
+ const rel = absolute.startsWith(root + sep) ? absolute.slice(root.length + 1) : abs;
261
+ if (!dryRun) _writeFile(abs, patched);
262
+ print(` ${dryRun ? "~" : "✓"} ${rel}`);
263
+ logger.debug({
264
+ file: rel,
265
+ from,
266
+ to
267
+ }, "upgrade node: patched");
268
+ updated.push(rel);
269
+ }
270
+ if (updated.length === 0) print(` · no files contained Node.js ${from} pins`);
271
+ const status = dryRun ? "dry-run" : "ok";
272
+ logger.info({
273
+ from,
274
+ to,
275
+ updated: updated.length,
276
+ status
277
+ }, "upgrade node: done");
278
+ return {
279
+ status,
280
+ updated
281
+ };
282
+ }
283
+ export { detectNodeMajor, fetchLatestFromNpm, patchDockerfile, patchPackageJson, patchPinFile, patchToolVersions, patchYaml, runUpgradeNode };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@theholocron/astromech",
3
- "version": "5.0.0-alpha.60",
4
- "description": "The Holocron task runner — one task manifest drives `holocron run`, `holocron ci`, the CI workflows, package.json scripts, linters, and required checks.",
3
+ "version": "5.0.0-alpha.600",
4
+ "description": "The Holocron task runner — one task manifest drives `holocron run`, `holocron run ci`, the CI workflows, package.json scripts, linters, and required checks.",
5
5
  "keywords": [
6
6
  "ci",
7
7
  "holocron",
@@ -10,12 +10,12 @@
10
10
  "theholocron",
11
11
  "turbo"
12
12
  ],
13
- "homepage": "https://github.com/theholocron/holocron/tree/main/packages/astromech#readme",
13
+ "homepage": "https://docs.theholocron.dev/holocron/astromech/",
14
14
  "bugs": "https://github.com/theholocron/holocron/issues",
15
15
  "repository": {
16
16
  "type": "git",
17
17
  "url": "git+https://github.com/theholocron/holocron.git",
18
- "directory": "packages/astromech"
18
+ "directory": "cli/astromech"
19
19
  },
20
20
  "license": "MIT",
21
21
  "author": "Newton Koumantzelis",
@@ -31,29 +31,55 @@
31
31
  "types": "./dist/config/index.d.mts",
32
32
  "import": "./dist/config/index.mjs",
33
33
  "default": "./dist/config/index.mjs"
34
+ },
35
+ "./lint": {
36
+ "types": "./dist/lint/index.d.mts",
37
+ "import": "./dist/lint/index.mjs",
38
+ "default": "./dist/lint/index.mjs"
39
+ },
40
+ "./repo-validation": {
41
+ "types": "./dist/repo-validation/index.d.mts",
42
+ "import": "./dist/repo-validation/index.mjs",
43
+ "default": "./dist/repo-validation/index.mjs"
44
+ },
45
+ "./upgrade": {
46
+ "types": "./dist/upgrade/index.d.mts",
47
+ "import": "./dist/upgrade/index.mjs",
48
+ "default": "./dist/upgrade/index.mjs"
34
49
  }
35
50
  },
36
51
  "files": [
37
52
  "dist"
38
53
  ],
39
54
  "dependencies": {
40
- "@theholocron/datapad": "5.0.0-alpha.60"
55
+ "@commitlint/lint": "^21.3.0",
56
+ "@commitlint/load": "^21.3.0",
57
+ "@commitlint/types": "^21.3.0",
58
+ "@theholocron/datapad": "5.0.0-alpha.600",
59
+ "@theholocron/fs-utils": "^1.17.0-alpha.9",
60
+ "@theholocron/json-utils": "^1.17.0-alpha.9",
61
+ "@theholocron/misc-utils": "^1.17.0-alpha.9",
62
+ "@theholocron/pkg-utils": "^1.17.0-alpha.9"
41
63
  },
42
64
  "devDependencies": {
43
- "@theholocron/eslint-config": "^8.4.5",
44
- "@theholocron/tsconfig": "^8.4.5",
45
- "@theholocron/tsdown-config": "^8.4.5",
46
- "@theholocron/vitest-config": "^8.4.5",
65
+ "@commitlint/config-conventional": "^21.3.0",
47
66
  "@types/node": "^26",
48
- "@vitest/coverage-v8": "^4.1.11",
49
- "@vitest/eslint-plugin": "^1.6.27",
50
- "eslint": "^10.8.1",
51
- "eslint-plugin-n": "^18.3.0",
52
- "globals": "^17.11.0",
53
- "tsdown": "^0.22.14",
54
- "typescript": "^5.9.3",
55
- "vitest": "^4.1.11",
56
- "@theholocron/rollup-plugin-transform-template": "5.0.0-alpha.60"
67
+ "@vitest/coverage-v8": "^5.1.2",
68
+ "@vitest/eslint-plugin": "^1.6.28",
69
+ "eslint": "^10.16.0",
70
+ "eslint-plugin-n": "^18.6.0",
71
+ "globals": "^17.14.0",
72
+ "prettier": "^3.10.1",
73
+ "tsdown": "^0.23.7",
74
+ "typescript": "^6.0.3",
75
+ "vitest": "^5.1.2",
76
+ "@theholocron/ci": "1.0.0",
77
+ "@theholocron/commitlint-config": "^8.9.0-alpha.25",
78
+ "@theholocron/eslint-config": "^8.9.0-alpha.25",
79
+ "@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.25",
80
+ "@theholocron/tsconfig": "^8.9.0-alpha.25",
81
+ "@theholocron/tsdown-config": "^8.9.0-alpha.25",
82
+ "@theholocron/vitest-config": "^8.9.0-alpha.25"
57
83
  },
58
84
  "engines": {
59
85
  "node": ">=22"
@@ -62,10 +88,10 @@
62
88
  "access": "public"
63
89
  },
64
90
  "scripts": {
65
- "delivery.build": "tsdown",
66
- "sourceQuality.staticAnalysis": "eslint .",
91
+ "build": "tsdown",
92
+ "lint:code": "eslint .",
93
+ "test:unit": "vitest run --coverage",
67
94
  "test:watch": "vitest",
68
- "verification.typeSafety": "tsc --noEmit",
69
- "verification.unitTests": "vitest run"
95
+ "typecheck": "tsc --noEmit"
70
96
  }
71
97
  }
@@ -1,11 +0,0 @@
1
- //#region src/config/schema.ts
2
- /** Normalise a `TaskConfigItem` to a full {@link TaskEntry} with defaults applied. */
3
- function normalizeTaskEntry(item) {
4
- return {
5
- ci: true,
6
- local: true,
7
- ...typeof item === "string" ? { name: item } : item
8
- };
9
- }
10
- //#endregion
11
- export { normalizeTaskEntry as t };