@kernlang/cli 3.2.3 → 3.3.4
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/dist/cli.js +28 -16
- package/dist/cli.js.map +1 -1
- package/dist/commands/apply.d.ts +14 -0
- package/dist/commands/apply.js +167 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/compile.js +57 -9
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/gaps.d.ts +1 -0
- package/dist/commands/gaps.js +178 -0
- package/dist/commands/gaps.js.map +1 -0
- package/dist/commands/migrate-class-body.d.ts +50 -0
- package/dist/commands/migrate-class-body.js +453 -0
- package/dist/commands/migrate-class-body.js.map +1 -0
- package/dist/commands/migrate.d.ts +80 -0
- package/dist/commands/migrate.js +586 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/review.d.ts +9 -0
- package/dist/commands/review.js +290 -26
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/transpile.js +9 -2
- package/dist/commands/transpile.js.map +1 -1
- package/dist/remote-repo.d.ts +21 -0
- package/dist/remote-repo.js +167 -0
- package/dist/remote-repo.js.map +1 -0
- package/dist/review-baseline.d.ts +27 -0
- package/dist/review-baseline.js +120 -0
- package/dist/review-baseline.js.map +1 -0
- package/dist/shared.d.ts +23 -2
- package/dist/shared.js +155 -8
- package/dist/shared.js.map +1 -1
- package/package.json +14 -13
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `kern migrate <migration> [dir]` - in-place migrations of .kern sources.
|
|
3
|
+
*
|
|
4
|
+
* `literal-const`
|
|
5
|
+
* Detects `const name=X ... handler <<< <single-line const expression> >>>`
|
|
6
|
+
* and rewrites to `const name=X ... value=...`. Primitive literals use the
|
|
7
|
+
* compact `value=42` form; strings and expressions use `value={{ ... }}` so
|
|
8
|
+
* generated TypeScript stays byte-equivalent to the original handler body.
|
|
9
|
+
*
|
|
10
|
+
* `fn-expr`
|
|
11
|
+
* Detects `fn name=X ... handler <<< <single-line function body> >>>` and
|
|
12
|
+
* rewrites to `fn name=X ... expr={{ ... }}`. The compiler emits the expr
|
|
13
|
+
* body verbatim inside the function, matching the original handler output.
|
|
14
|
+
*
|
|
15
|
+
* Dry-run by default; `--write` commits edits.
|
|
16
|
+
*/
|
|
17
|
+
import { isInlineSafeExpression, isInlineSafeLiteral } from '@kernlang/core';
|
|
18
|
+
import { mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'fs';
|
|
19
|
+
import { tmpdir } from 'os';
|
|
20
|
+
import { extname, join, relative, resolve } from 'path';
|
|
21
|
+
import { hasFlag, loadConfig, loadTemplates, parseFlagOrNext, transpileAndWrite } from '../shared.js';
|
|
22
|
+
const SKIP_DIRS = new Set([
|
|
23
|
+
'node_modules',
|
|
24
|
+
'dist',
|
|
25
|
+
'build',
|
|
26
|
+
'.git',
|
|
27
|
+
'coverage',
|
|
28
|
+
'.next',
|
|
29
|
+
'.turbo',
|
|
30
|
+
'.vercel',
|
|
31
|
+
'generated',
|
|
32
|
+
]);
|
|
33
|
+
function walkKern(root, out) {
|
|
34
|
+
let entries;
|
|
35
|
+
try {
|
|
36
|
+
entries = readdirSync(root);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
if (SKIP_DIRS.has(entry))
|
|
43
|
+
continue;
|
|
44
|
+
const full = join(root, entry);
|
|
45
|
+
let stat;
|
|
46
|
+
try {
|
|
47
|
+
stat = statSync(full);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (stat.isDirectory()) {
|
|
53
|
+
walkKern(full, out);
|
|
54
|
+
}
|
|
55
|
+
else if (stat.isFile() && extname(entry) === '.kern') {
|
|
56
|
+
out.push(full);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Line-based migration: matches the exact shape emitted by historical
|
|
62
|
+
* importers and by hand-written audiofacets files:
|
|
63
|
+
*
|
|
64
|
+
* const name=X type=T [more props] <- header, no trailing handler attr
|
|
65
|
+
* handler <<<
|
|
66
|
+
* <single literal line>
|
|
67
|
+
* >>>
|
|
68
|
+
*
|
|
69
|
+
* Indentation is tolerated (any whitespace), but the handler MUST be
|
|
70
|
+
* single-line content sandwiched by `<<<` and `>>>` with no other children.
|
|
71
|
+
* If the const header already contains `value=`, the handler is left alone.
|
|
72
|
+
*/
|
|
73
|
+
function rewriteLiteralConsts(source) {
|
|
74
|
+
const lines = source.split('\n');
|
|
75
|
+
const hits = [];
|
|
76
|
+
const out = [];
|
|
77
|
+
let i = 0;
|
|
78
|
+
while (i < lines.length) {
|
|
79
|
+
const line = lines[i];
|
|
80
|
+
// Header: must start with 'const ' (possibly preceded by whitespace),
|
|
81
|
+
// contain name=, and NOT already carry a value= attribute.
|
|
82
|
+
const headerMatch = line.match(/^(\s*)const\s+(.*)$/);
|
|
83
|
+
if (!headerMatch) {
|
|
84
|
+
out.push(line);
|
|
85
|
+
i++;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const headerIndent = headerMatch[1];
|
|
89
|
+
const headerRest = headerMatch[2];
|
|
90
|
+
// Skip if already has value= to avoid double-migration.
|
|
91
|
+
if (/\bvalue=/.test(headerRest)) {
|
|
92
|
+
out.push(line);
|
|
93
|
+
i++;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
// Require name= somewhere in the header so we don't misfire on other
|
|
97
|
+
// `const` occurrences (there shouldn't be any at column 0 in .kern, but
|
|
98
|
+
// being strict avoids future surprises).
|
|
99
|
+
if (!/\bname=/.test(headerRest)) {
|
|
100
|
+
out.push(line);
|
|
101
|
+
i++;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
// Skip headers with inline `#` or `//` comments. The KERN parser strips
|
|
105
|
+
// them (see parser-core.ts stripLineComment), so appending `value=...`
|
|
106
|
+
// after a comment would put the value *inside* the comment and the
|
|
107
|
+
// migration would silently delete the handler without preserving it.
|
|
108
|
+
if (/(?:^|\s)(?:#|\/\/)/.test(headerRest)) {
|
|
109
|
+
out.push(line);
|
|
110
|
+
i++;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
// Look ahead for the handler block:
|
|
114
|
+
// line i+1: <deeper-indent> handler <<<
|
|
115
|
+
// line i+2: <deeper-indent> <literal>
|
|
116
|
+
// line i+3: <deeper-indent> >>>
|
|
117
|
+
const openLine = lines[i + 1];
|
|
118
|
+
const bodyLine = lines[i + 2];
|
|
119
|
+
const closeLine = lines[i + 3];
|
|
120
|
+
if (openLine === undefined || bodyLine === undefined || closeLine === undefined) {
|
|
121
|
+
out.push(line);
|
|
122
|
+
i++;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const openMatch = openLine.match(/^(\s+)handler\s*<<<\s*$/);
|
|
126
|
+
const closeMatch = closeLine.match(/^\s+>>>\s*$/);
|
|
127
|
+
if (!openMatch || !closeMatch) {
|
|
128
|
+
out.push(line);
|
|
129
|
+
i++;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
// Require the handler to be a CHILD of the const — its indent must be
|
|
133
|
+
// strictly deeper than the const header's. Otherwise a sibling handler
|
|
134
|
+
// block would be swallowed when the const itself is indented.
|
|
135
|
+
if (openMatch[1].length <= headerIndent.length) {
|
|
136
|
+
out.push(line);
|
|
137
|
+
i++;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
// Body must be a single line of pure literal content, deeper indent than
|
|
141
|
+
// the `handler` line, single token. Reject multi-line handlers.
|
|
142
|
+
const openIndent = openMatch[1];
|
|
143
|
+
const bodyMatch = bodyLine.match(/^(\s+)(.*)$/);
|
|
144
|
+
if (!bodyMatch || bodyMatch[1].length <= openIndent.length) {
|
|
145
|
+
out.push(line);
|
|
146
|
+
i++;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const bodyText = bodyMatch[2];
|
|
150
|
+
// Two-tier: prefer the bare `value=<literal>` form for pure primitives
|
|
151
|
+
// (cleaner output); fall back to `value={{ <expr> }}` for anything else
|
|
152
|
+
// that's a single-line, non-empty, non-closing-delimiter body. The
|
|
153
|
+
// compiled TS is byte-identical to the original handler form either way
|
|
154
|
+
// because both paths route through the same codegen branch in
|
|
155
|
+
// codegen/type-system.ts:generateConst.
|
|
156
|
+
let valueAttr;
|
|
157
|
+
let rendered;
|
|
158
|
+
if (isInlineSafeLiteral(bodyText)) {
|
|
159
|
+
const lit = bodyText.trim();
|
|
160
|
+
valueAttr = `value=${lit}`;
|
|
161
|
+
rendered = lit;
|
|
162
|
+
}
|
|
163
|
+
else if (isInlineSafeExpression(bodyText)) {
|
|
164
|
+
const expr = bodyText.trim();
|
|
165
|
+
valueAttr = `value={{ ${expr} }}`;
|
|
166
|
+
rendered = expr;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
out.push(line);
|
|
170
|
+
i++;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
// Preserve trailing attributes after name=... so export=false etc. stay.
|
|
174
|
+
const rewrittenHeader = `${headerIndent}const ${headerRest.trimEnd()} ${valueAttr}`;
|
|
175
|
+
hits.push({ headerLine: i + 1, literal: rendered, valueAttr });
|
|
176
|
+
out.push(rewrittenHeader);
|
|
177
|
+
i += 4; // skip handler <<<, body, >>>
|
|
178
|
+
}
|
|
179
|
+
return { hits, output: out.join('\n') };
|
|
180
|
+
}
|
|
181
|
+
// -- fn-expr ----------------------------------------------------------------
|
|
182
|
+
/**
|
|
183
|
+
* Line-based migration for single-line `fn` handler bodies. Matches:
|
|
184
|
+
*
|
|
185
|
+
* [indent]fn name=X [props...] <- header, no handler= attr, no expr= attr
|
|
186
|
+
* [deeper] handler <<<
|
|
187
|
+
* [deeper] <single body line> <- preserved verbatim (incl. `return`, `;`)
|
|
188
|
+
* [deeper] >>>
|
|
189
|
+
*
|
|
190
|
+
* Rewrites to `fn name=X ... expr={{ <body> }}`. The codegen in
|
|
191
|
+
* generateFunction emits the expr verbatim inside the function body, so the
|
|
192
|
+
* compiled TypeScript is byte-identical to the handler form.
|
|
193
|
+
*
|
|
194
|
+
* Shares the same safety guards as rewriteLiteralConsts:
|
|
195
|
+
* - handler must be a child of the fn (strictly deeper indent),
|
|
196
|
+
* - no `}}` in the body (would close the expr block early),
|
|
197
|
+
* - header must not already carry expr= or handler=,
|
|
198
|
+
* - header must not contain an inline `#` or `//` comment,
|
|
199
|
+
* - body must not be empty after trim,
|
|
200
|
+
* - handler must have exactly ONE body line (no multi-line blocks).
|
|
201
|
+
*/
|
|
202
|
+
function rewriteFnExpr(source) {
|
|
203
|
+
const lines = source.split('\n');
|
|
204
|
+
const hits = [];
|
|
205
|
+
const out = [];
|
|
206
|
+
let i = 0;
|
|
207
|
+
while (i < lines.length) {
|
|
208
|
+
const line = lines[i];
|
|
209
|
+
const headerMatch = line.match(/^(\s*)fn\s+(.*)$/);
|
|
210
|
+
if (!headerMatch) {
|
|
211
|
+
out.push(line);
|
|
212
|
+
i++;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const headerIndent = headerMatch[1];
|
|
216
|
+
const headerRest = headerMatch[2];
|
|
217
|
+
if (/\bexpr=/.test(headerRest) || /\bhandler=/.test(headerRest)) {
|
|
218
|
+
out.push(line);
|
|
219
|
+
i++;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (!/\bname=/.test(headerRest)) {
|
|
223
|
+
out.push(line);
|
|
224
|
+
i++;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (/(?:^|\s)(?:#|\/\/)/.test(headerRest)) {
|
|
228
|
+
out.push(line);
|
|
229
|
+
i++;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const openLine = lines[i + 1];
|
|
233
|
+
const bodyLine = lines[i + 2];
|
|
234
|
+
const closeLine = lines[i + 3];
|
|
235
|
+
if (openLine === undefined || bodyLine === undefined || closeLine === undefined) {
|
|
236
|
+
out.push(line);
|
|
237
|
+
i++;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
const openMatch = openLine.match(/^(\s+)handler\s*<<<\s*$/);
|
|
241
|
+
const closeMatch = closeLine.match(/^\s+>>>\s*$/);
|
|
242
|
+
if (!openMatch || !closeMatch) {
|
|
243
|
+
out.push(line);
|
|
244
|
+
i++;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (openMatch[1].length <= headerIndent.length) {
|
|
248
|
+
out.push(line);
|
|
249
|
+
i++;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const openIndent = openMatch[1];
|
|
253
|
+
const bodyMatch = bodyLine.match(/^(\s+)(.*)$/);
|
|
254
|
+
if (!bodyMatch || bodyMatch[1].length <= openIndent.length) {
|
|
255
|
+
out.push(line);
|
|
256
|
+
i++;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
const bodyText = bodyMatch[2];
|
|
260
|
+
if (!isInlineSafeExpression(bodyText)) {
|
|
261
|
+
out.push(line);
|
|
262
|
+
i++;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
const body = bodyText.trim();
|
|
266
|
+
const valueAttr = `expr={{ ${body} }}`;
|
|
267
|
+
const rewritten = `${headerIndent}fn ${headerRest.trimEnd()} ${valueAttr}`;
|
|
268
|
+
hits.push({ headerLine: i + 1, literal: body, valueAttr });
|
|
269
|
+
out.push(rewritten);
|
|
270
|
+
i += 4;
|
|
271
|
+
}
|
|
272
|
+
return { hits, output: out.join('\n') };
|
|
273
|
+
}
|
|
274
|
+
import { rewriteClassBodies } from './migrate-class-body.js';
|
|
275
|
+
export const MIGRATIONS = {
|
|
276
|
+
'literal-const': {
|
|
277
|
+
name: 'literal-const',
|
|
278
|
+
category: 'migratable',
|
|
279
|
+
summary: 'Inline single-line const handler bodies as `value=` attributes',
|
|
280
|
+
rewrite: rewriteLiteralConsts,
|
|
281
|
+
},
|
|
282
|
+
'fn-expr': {
|
|
283
|
+
name: 'fn-expr',
|
|
284
|
+
category: 'migratable',
|
|
285
|
+
summary: 'Inline single-line fn handler bodies as `expr={{ ... }}` attributes',
|
|
286
|
+
rewrite: rewriteFnExpr,
|
|
287
|
+
},
|
|
288
|
+
'class-body': {
|
|
289
|
+
name: 'class-body',
|
|
290
|
+
category: 'migratable',
|
|
291
|
+
summary: 'Convert `const X type=any handler<<<class X{...}>>>` to a `class` node',
|
|
292
|
+
rewrite: rewriteClassBodies,
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
/** Stable iteration order for help + list output. */
|
|
296
|
+
function migrationList() {
|
|
297
|
+
return Object.values(MIGRATIONS).sort((a, b) => a.name.localeCompare(b.name));
|
|
298
|
+
}
|
|
299
|
+
function formatHuman(report, rootDir) {
|
|
300
|
+
const lines = [];
|
|
301
|
+
lines.push(`kern migrate ${report.migration} - scanned ${report.scannedFiles} .kern files in ${relative(process.cwd(), rootDir) || '.'}`);
|
|
302
|
+
if (report.totalHits === 0) {
|
|
303
|
+
lines.push('No migration candidates found.');
|
|
304
|
+
return `${lines.join('\n')}\n`;
|
|
305
|
+
}
|
|
306
|
+
for (const file of report.files) {
|
|
307
|
+
if (file.hits === 0)
|
|
308
|
+
continue;
|
|
309
|
+
const rel = relative(rootDir, file.file) || file.file;
|
|
310
|
+
lines.push(` ${rel} (${file.hits} hit${file.hits === 1 ? '' : 's'})`);
|
|
311
|
+
for (const rewrite of file.rewrites.slice(0, 5)) {
|
|
312
|
+
lines.push(` -> ${rewrite}`);
|
|
313
|
+
}
|
|
314
|
+
if (file.rewrites.length > 5) {
|
|
315
|
+
lines.push(` ... ${file.rewrites.length - 5} more`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const action = report.mode === 'write' ? 'applied' : 'would apply';
|
|
319
|
+
lines.push('');
|
|
320
|
+
lines.push(`${action}: ${report.totalHits} hits across ${report.changedFiles} files`);
|
|
321
|
+
if (report.mode === 'dry-run') {
|
|
322
|
+
lines.push('(dry-run - re-run with --write to commit)');
|
|
323
|
+
}
|
|
324
|
+
return `${lines.join('\n')}\n`;
|
|
325
|
+
}
|
|
326
|
+
// ── --verify helpers ──────────────────────────────────────────────────────
|
|
327
|
+
// Bake the whole "compile pre, apply migration, compile post, diff, revert
|
|
328
|
+
// on drift" operator dance into a single flag. Without this, users ship
|
|
329
|
+
// class-body / literal-const changes and have to stage a git worktree,
|
|
330
|
+
// recompile twice, and pray the byte-clean check is empty. Now they
|
|
331
|
+
// just run `kern migrate <name> --write --verify`.
|
|
332
|
+
/** Compile every `.kern` file under rootDir into outDir, matching how the
|
|
333
|
+
* standard `kern compile` command invokes transpile. `--no-gaps` suppresses
|
|
334
|
+
* writes to `.kern-gaps/` so a verify run doesn't pollute the user's state.
|
|
335
|
+
*/
|
|
336
|
+
function compileAllKernInto(rootDir, files, outDir) {
|
|
337
|
+
// Force target='auto' so each file picks its own target from AST content.
|
|
338
|
+
// Verification needs to be stable and deterministic — `nextjs` default
|
|
339
|
+
// from plain `loadConfig()` emits a `page.tsx` wrapper even for pure
|
|
340
|
+
// const-only files, which doesn't match what `kern compile <file>`
|
|
341
|
+
// produces in normal CLI use.
|
|
342
|
+
const cfg = { ...loadConfig(), target: 'auto' };
|
|
343
|
+
// Load any configured templates the user's `kern compile` would register —
|
|
344
|
+
// without this, verify compile fails with "No template registered..." on
|
|
345
|
+
// projects that use template nodes even though their normal build works.
|
|
346
|
+
try {
|
|
347
|
+
loadTemplates(cfg);
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
// Template loading failures are surfaced during normal compile as well;
|
|
351
|
+
// don't hard-stop verify here — per-file transpile will report them.
|
|
352
|
+
}
|
|
353
|
+
const failures = [];
|
|
354
|
+
for (const file of files) {
|
|
355
|
+
try {
|
|
356
|
+
transpileAndWrite(file, cfg, ['--no-gaps'], outDir, rootDir);
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
failures.push(`${file}: ${err.message}`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return { failures };
|
|
363
|
+
}
|
|
364
|
+
/** Recursively walk `dir`, returning paths relative to `dir`. */
|
|
365
|
+
function listRel(dir, base = dir, out = []) {
|
|
366
|
+
let entries;
|
|
367
|
+
try {
|
|
368
|
+
entries = readdirSync(dir);
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
return out;
|
|
372
|
+
}
|
|
373
|
+
for (const entry of entries) {
|
|
374
|
+
const full = join(dir, entry);
|
|
375
|
+
let s;
|
|
376
|
+
try {
|
|
377
|
+
s = statSync(full);
|
|
378
|
+
}
|
|
379
|
+
catch {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (s.isDirectory())
|
|
383
|
+
listRel(full, base, out);
|
|
384
|
+
else if (s.isFile())
|
|
385
|
+
out.push(relative(base, full));
|
|
386
|
+
}
|
|
387
|
+
return out;
|
|
388
|
+
}
|
|
389
|
+
function collectDriftBetween(beforeDir, afterDir) {
|
|
390
|
+
const beforeFiles = new Set(listRel(beforeDir));
|
|
391
|
+
const afterFiles = new Set(listRel(afterDir));
|
|
392
|
+
const drift = [];
|
|
393
|
+
for (const rel of beforeFiles) {
|
|
394
|
+
if (!afterFiles.has(rel)) {
|
|
395
|
+
drift.push({ file: rel, reason: 'missing-in-after' });
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
try {
|
|
399
|
+
const a = readFileSync(join(beforeDir, rel), 'utf-8');
|
|
400
|
+
const b = readFileSync(join(afterDir, rel), 'utf-8');
|
|
401
|
+
if (a !== b)
|
|
402
|
+
drift.push({ file: rel, reason: 'content' });
|
|
403
|
+
}
|
|
404
|
+
catch {
|
|
405
|
+
drift.push({ file: rel, reason: 'content' });
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
for (const rel of afterFiles) {
|
|
409
|
+
if (!beforeFiles.has(rel))
|
|
410
|
+
drift.push({ file: rel, reason: 'missing-in-before' });
|
|
411
|
+
}
|
|
412
|
+
return drift;
|
|
413
|
+
}
|
|
414
|
+
function cleanupTmp(dir) {
|
|
415
|
+
if (!dir)
|
|
416
|
+
return;
|
|
417
|
+
try {
|
|
418
|
+
rmSync(dir, { recursive: true, force: true });
|
|
419
|
+
}
|
|
420
|
+
catch {
|
|
421
|
+
// Best-effort cleanup — ignore
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function printUsage() {
|
|
425
|
+
process.stderr.write('Usage: kern migrate <migration|list> [dir] [--write] [--verify] [--json]\n');
|
|
426
|
+
process.stderr.write('Migrations:\n');
|
|
427
|
+
const padTo = migrationList().reduce((m, d) => Math.max(m, d.name.length), 0);
|
|
428
|
+
for (const def of migrationList()) {
|
|
429
|
+
process.stderr.write(` ${def.name.padEnd(padTo)} [${def.category}] ${def.summary}\n`);
|
|
430
|
+
}
|
|
431
|
+
process.stderr.write('\nList programmatically:\n');
|
|
432
|
+
process.stderr.write(' kern migrate list [--json] # print the registry\n');
|
|
433
|
+
}
|
|
434
|
+
function runMigrateList(json) {
|
|
435
|
+
const entries = migrationList().map((d) => ({
|
|
436
|
+
name: d.name,
|
|
437
|
+
category: d.category,
|
|
438
|
+
summary: d.summary,
|
|
439
|
+
}));
|
|
440
|
+
if (json) {
|
|
441
|
+
process.stdout.write(`${JSON.stringify(entries, null, 2)}\n`);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
const padTo = entries.reduce((m, d) => Math.max(m, d.name.length), 0);
|
|
445
|
+
for (const entry of entries) {
|
|
446
|
+
process.stdout.write(`${entry.name.padEnd(padTo)} [${entry.category}] ${entry.summary}\n`);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
export function runMigrate(args) {
|
|
450
|
+
const sub = args[1];
|
|
451
|
+
const json = hasFlag(args, '--json');
|
|
452
|
+
if (!sub || sub.startsWith('--')) {
|
|
453
|
+
printUsage();
|
|
454
|
+
process.exit(1);
|
|
455
|
+
}
|
|
456
|
+
if (sub === 'list') {
|
|
457
|
+
runMigrateList(json);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const def = MIGRATIONS[sub];
|
|
461
|
+
if (!def) {
|
|
462
|
+
process.stderr.write(`Unknown migration: ${sub}\n`);
|
|
463
|
+
printUsage();
|
|
464
|
+
process.exit(1);
|
|
465
|
+
}
|
|
466
|
+
const rootArg = args.slice(2).find((a) => !a.startsWith('--'));
|
|
467
|
+
const rootDir = resolve(parseFlagOrNext(args, '--root') ?? rootArg ?? process.cwd());
|
|
468
|
+
const write = hasFlag(args, '--write');
|
|
469
|
+
const verify = hasFlag(args, '--verify');
|
|
470
|
+
// --verify implies --write (no point verifying a dry-run).
|
|
471
|
+
const effectiveWrite = write || verify;
|
|
472
|
+
const files = [];
|
|
473
|
+
walkKern(rootDir, files);
|
|
474
|
+
// Verify pre-compile: snapshot originals + emit BEFORE build against the
|
|
475
|
+
// current (pre-migration) .kern sources. Runs before we touch anything on
|
|
476
|
+
// disk so rollback is guaranteed.
|
|
477
|
+
const snapshot = new Map();
|
|
478
|
+
let beforeDir;
|
|
479
|
+
let compileFailed = false;
|
|
480
|
+
if (verify) {
|
|
481
|
+
for (const file of files) {
|
|
482
|
+
try {
|
|
483
|
+
snapshot.set(file, readFileSync(file, 'utf-8'));
|
|
484
|
+
}
|
|
485
|
+
catch {
|
|
486
|
+
// Best-effort — files we can't read we won't migrate either.
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
beforeDir = mkdtempSync(join(tmpdir(), 'kern-verify-before-'));
|
|
490
|
+
const { failures } = compileAllKernInto(rootDir, files, beforeDir);
|
|
491
|
+
if (failures.length > 0) {
|
|
492
|
+
process.stderr.write(`✗ ${sub}: pre-migration compile failed on ${failures.length} file(s):\n`);
|
|
493
|
+
for (const f of failures.slice(0, 3))
|
|
494
|
+
process.stderr.write(` ${f}\n`);
|
|
495
|
+
cleanupTmp(beforeDir);
|
|
496
|
+
compileFailed = true;
|
|
497
|
+
process.exit(1);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
const fileReports = [];
|
|
501
|
+
let totalHits = 0;
|
|
502
|
+
let changedFiles = 0;
|
|
503
|
+
const touchedFiles = [];
|
|
504
|
+
for (const file of files) {
|
|
505
|
+
let source;
|
|
506
|
+
try {
|
|
507
|
+
source = readFileSync(file, 'utf-8');
|
|
508
|
+
}
|
|
509
|
+
catch {
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
const result = def.rewrite(source);
|
|
513
|
+
fileReports.push({
|
|
514
|
+
file,
|
|
515
|
+
hits: result.hits.length,
|
|
516
|
+
rewrites: result.hits.map((h) => h.valueAttr),
|
|
517
|
+
literals: result.hits.map((h) => h.literal),
|
|
518
|
+
});
|
|
519
|
+
if (result.hits.length > 0) {
|
|
520
|
+
totalHits += result.hits.length;
|
|
521
|
+
changedFiles++;
|
|
522
|
+
if (effectiveWrite && result.output !== source) {
|
|
523
|
+
writeFileSync(file, result.output);
|
|
524
|
+
touchedFiles.push(file);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
// Verify post-compile: emit AFTER build against migrated sources, diff
|
|
529
|
+
// tree-wise, roll back on drift.
|
|
530
|
+
if (verify && !compileFailed) {
|
|
531
|
+
const afterDir = mkdtempSync(join(tmpdir(), 'kern-verify-after-'));
|
|
532
|
+
const { failures } = compileAllKernInto(rootDir, files, afterDir);
|
|
533
|
+
if (failures.length > 0) {
|
|
534
|
+
process.stderr.write(`✗ ${sub}: post-migration compile failed — rolling back\n`);
|
|
535
|
+
for (const [file, original] of snapshot)
|
|
536
|
+
writeFileSync(file, original);
|
|
537
|
+
cleanupTmp(beforeDir);
|
|
538
|
+
cleanupTmp(afterDir);
|
|
539
|
+
process.exit(1);
|
|
540
|
+
}
|
|
541
|
+
const drift = collectDriftBetween(beforeDir, afterDir);
|
|
542
|
+
cleanupTmp(beforeDir);
|
|
543
|
+
cleanupTmp(afterDir);
|
|
544
|
+
if (drift.length === 0) {
|
|
545
|
+
// stderr so `kern migrate ... --verify --json` still emits parseable
|
|
546
|
+
// JSON on stdout (the banner is status output, not report output).
|
|
547
|
+
process.stderr.write(`✓ ${sub}: verified byte-clean (${files.length} .kern files compiled pre/post, ${touchedFiles.length} rewritten, 0 TS drift)\n`);
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
process.stderr.write(`✗ ${sub}: ${drift.length} file(s) drifted in compiled TS — rolling back migration.\n`);
|
|
551
|
+
const preview = drift
|
|
552
|
+
.slice(0, 5)
|
|
553
|
+
.map((d) => ` ${d.file} (${d.reason})`)
|
|
554
|
+
.join('\n');
|
|
555
|
+
process.stderr.write(`${preview}\n`);
|
|
556
|
+
if (drift.length > 5)
|
|
557
|
+
process.stderr.write(` ...and ${drift.length - 5} more\n`);
|
|
558
|
+
for (const [file, original] of snapshot)
|
|
559
|
+
writeFileSync(file, original);
|
|
560
|
+
process.stderr.write(`Restored ${snapshot.size} .kern file(s) to pre-migration state.\n`);
|
|
561
|
+
process.exit(1);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
const report = {
|
|
565
|
+
migration: def.name,
|
|
566
|
+
category: def.category,
|
|
567
|
+
scannedFiles: files.length,
|
|
568
|
+
changedFiles,
|
|
569
|
+
totalHits,
|
|
570
|
+
files: fileReports,
|
|
571
|
+
mode: effectiveWrite ? 'write' : 'dry-run',
|
|
572
|
+
};
|
|
573
|
+
if (json) {
|
|
574
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
process.stdout.write(formatHuman(report, rootDir));
|
|
578
|
+
}
|
|
579
|
+
// Exported for unit tests.
|
|
580
|
+
export const __test__ = {
|
|
581
|
+
isInlineSafeLiteral,
|
|
582
|
+
isInlineSafeExpression,
|
|
583
|
+
rewriteLiteralConsts,
|
|
584
|
+
rewriteFnExpr,
|
|
585
|
+
};
|
|
586
|
+
//# sourceMappingURL=mig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AAK,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,2BAA2B;AAC3B,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,mBAAmB;IACnB,sBAAsB;IACtB,oBAAoB;IACpB,aAAa;CACd,CAAC"}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pick a safe default diff base for bare `kern review` inside a git repo.
|
|
3
|
+
* Tries `origin/main`, then `origin/master`, then `HEAD~1`, returning the
|
|
4
|
+
* first ref that `git rev-parse --verify` accepts. Returns undefined when
|
|
5
|
+
* not in a git repo or no suitable ref exists (e.g. single-commit repo).
|
|
6
|
+
*
|
|
7
|
+
* Exported for testability.
|
|
8
|
+
*/
|
|
9
|
+
export declare function detectAutoDiffBase(cwd?: string): string | undefined;
|
|
1
10
|
export declare function runReview(args: string[]): Promise<void>;
|