@nifrajs/cli 5.7.0 → 5.9.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/CHANGELOG.md +150 -0
- package/dist/agent-files.d.ts +0 -22
- package/dist/agent-files.d.ts.map +1 -1
- package/dist/agent-files.js +3 -1
- package/dist/agent-files.js.map +1 -1
- package/dist/assure-hydration.d.ts.map +1 -1
- package/dist/assure-hydration.js +2 -10
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +3 -3
- package/dist/assure.js.map +1 -1
- package/dist/check-scan.d.ts +2 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +54 -86
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts +3 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +20 -23
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +42 -13
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +20 -30
- package/dist/command-catalog.js.map +1 -1
- package/dist/config-target.js +1 -1
- package/dist/config-target.js.map +1 -1
- package/dist/db-child.js +3 -10
- package/dist/db-child.js.map +1 -1
- package/dist/db-config.d.ts +2 -0
- package/dist/db-config.d.ts.map +1 -1
- package/dist/db-config.js +2 -0
- package/dist/db-config.js.map +1 -1
- package/dist/doctor.d.ts +14 -3
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +91 -6
- package/dist/doctor.js.map +1 -1
- package/dist/frontend-guidance.d.ts +19 -0
- package/dist/frontend-guidance.d.ts.map +1 -1
- package/dist/frontend-guidance.js +267 -23
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/hand-built-manifest.d.ts.map +1 -1
- package/dist/hand-built-manifest.js +1 -1
- package/dist/hand-built-manifest.js.map +1 -1
- package/dist/internal/control-character.d.ts +3 -0
- package/dist/internal/control-character.d.ts.map +1 -0
- package/dist/internal/control-character.js +10 -0
- package/dist/internal/control-character.js.map +1 -0
- package/dist/internal/escape-regexp.d.ts +3 -0
- package/dist/internal/escape-regexp.d.ts.map +1 -0
- package/dist/internal/escape-regexp.js +5 -0
- package/dist/internal/escape-regexp.js.map +1 -0
- package/dist/internal/line-at.d.ts +3 -0
- package/dist/internal/line-at.d.ts.map +1 -0
- package/dist/internal/line-at.js +5 -0
- package/dist/internal/line-at.js.map +1 -0
- package/dist/internal/nifra-project.d.ts.map +1 -1
- package/dist/internal/nifra-project.js +35 -41
- package/dist/internal/nifra-project.js.map +1 -1
- package/dist/internal/posix-path.d.ts +3 -0
- package/dist/internal/posix-path.d.ts.map +1 -0
- package/dist/internal/posix-path.js +5 -0
- package/dist/internal/posix-path.js.map +1 -0
- package/dist/internal/project-specifiers.d.ts.map +1 -1
- package/dist/internal/project-specifiers.js +3 -10
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/realpath-or-self.d.ts +3 -0
- package/dist/internal/realpath-or-self.d.ts.map +1 -0
- package/dist/internal/realpath-or-self.js +11 -0
- package/dist/internal/realpath-or-self.js.map +1 -0
- package/dist/internal/record.d.ts +3 -0
- package/dist/internal/record.d.ts.map +1 -0
- package/dist/internal/record.js +5 -0
- package/dist/internal/record.js.map +1 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +28 -25
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/introspect.d.ts +0 -22
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +11 -151
- package/dist/introspect.js.map +1 -1
- package/dist/levels-tool.d.ts +2 -0
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +54 -64
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +6 -1
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js.map +1 -1
- package/dist/local-cli.d.ts +7 -0
- package/dist/local-cli.d.ts.map +1 -1
- package/dist/local-cli.js +13 -0
- package/dist/local-cli.js.map +1 -1
- package/dist/mcp-docs-tools.d.ts +1 -1
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +46 -3
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.d.ts +1 -1
- package/dist/mcp-http.js +2 -2
- package/dist/mcp-io.d.ts +16 -0
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +63 -0
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-isolate.d.ts.map +1 -1
- package/dist/mcp-isolate.js +2 -1
- package/dist/mcp-isolate.js.map +1 -1
- package/dist/mcp-project-child.d.ts.map +1 -1
- package/dist/mcp-project-child.js +5 -12
- package/dist/mcp-project-child.js.map +1 -1
- package/dist/mcp-render.d.ts.map +1 -1
- package/dist/mcp-render.js +9 -51
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-root.js +1 -1
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-run.d.ts.map +1 -1
- package/dist/mcp-run.js +3 -46
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp-ws.d.ts.map +1 -1
- package/dist/mcp-ws.js +2 -18
- package/dist/mcp-ws.js.map +1 -1
- package/dist/migrate-layout.d.ts.map +1 -1
- package/dist/migrate-layout.js +36 -57
- package/dist/migrate-layout.js.map +1 -1
- package/dist/output-schemas.d.ts.map +1 -1
- package/dist/output-schemas.js +7 -7
- package/dist/output-schemas.js.map +1 -1
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +1 -2
- package/dist/port.js.map +1 -1
- package/dist/ppr-read-fix.js +2 -2
- package/dist/ppr-read-fix.js.map +1 -1
- package/dist/recipes/5.8.0.d.ts +9 -0
- package/dist/recipes/5.8.0.d.ts.map +1 -0
- package/dist/recipes/5.8.0.js +20 -0
- package/dist/recipes/5.8.0.js.map +1 -0
- package/dist/recipes/5.9.0.d.ts +10 -0
- package/dist/recipes/5.9.0.d.ts.map +1 -0
- package/dist/recipes/5.9.0.js +41 -0
- package/dist/recipes/5.9.0.js.map +1 -0
- package/dist/recipes/index.d.ts +5 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +4 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +9 -13
- package/dist/review.js.map +1 -1
- package/dist/rules/contract-visibility.d.ts.map +1 -1
- package/dist/rules/contract-visibility.js +3 -9
- package/dist/rules/contract-visibility.js.map +1 -1
- package/dist/rules/data-guard.d.ts.map +1 -1
- package/dist/rules/data-guard.js +3 -10
- package/dist/rules/data-guard.js.map +1 -1
- package/dist/rules/pages.d.ts.map +1 -1
- package/dist/rules/pages.js +41 -58
- package/dist/rules/pages.js.map +1 -1
- package/dist/rules/routes.d.ts.map +1 -1
- package/dist/rules/routes.js +20 -27
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +206 -313
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/zones.d.ts.map +1 -1
- package/dist/rules/zones.js +3 -10
- package/dist/rules/zones.js.map +1 -1
- package/dist/runtime-differences.d.ts +62 -0
- package/dist/runtime-differences.d.ts.map +1 -0
- package/dist/runtime-differences.js +222 -0
- package/dist/runtime-differences.js.map +1 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +43 -43
- package/dist/sdk.js.map +1 -1
- package/dist/smoke.d.ts.map +1 -1
- package/dist/smoke.js +4 -12
- package/dist/smoke.js.map +1 -1
- package/dist/source-rewrites.d.ts +27 -0
- package/dist/source-rewrites.d.ts.map +1 -0
- package/dist/source-rewrites.js +402 -0
- package/dist/source-rewrites.js.map +1 -0
- package/dist/stylex-migrate.d.ts.map +1 -1
- package/dist/stylex-migrate.js +1 -1
- package/dist/stylex-migrate.js.map +1 -1
- package/dist/symptom-search.d.ts +5 -0
- package/dist/symptom-search.d.ts.map +1 -0
- package/dist/symptom-search.js +21 -0
- package/dist/symptom-search.js.map +1 -0
- package/dist/upgrade.d.ts +28 -3
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +153 -64
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +5 -3
- package/dist/verification-plan.js.map +1 -1
- package/docs/examples.json +32 -2
- package/docs/llms-full.txt +749 -95
- package/docs/types.json +300 -61
- package/package.json +11 -11
- package/src/agent-files.ts +4 -1
- package/src/assure-hydration.ts +2 -9
- package/src/assure.ts +3 -4
- package/src/check-scan.ts +65 -82
- package/src/check.ts +25 -23
- package/src/cli.ts +61 -13
- package/src/command-catalog.ts +22 -32
- package/src/config-target.ts +1 -1
- package/src/db-child.ts +3 -10
- package/src/db-config.ts +4 -0
- package/src/doctor.ts +128 -12
- package/src/frontend-guidance.ts +344 -25
- package/src/hand-built-manifest.ts +1 -2
- package/src/internal/control-character.ts +8 -0
- package/src/internal/escape-regexp.ts +4 -0
- package/src/internal/line-at.ts +4 -0
- package/src/internal/nifra-project.ts +39 -35
- package/src/internal/posix-path.ts +4 -0
- package/src/internal/project-specifiers.ts +3 -10
- package/src/internal/realpath-or-self.ts +10 -0
- package/src/internal/record.ts +4 -0
- package/src/internal/source-facts.ts +39 -29
- package/src/introspect.ts +16 -156
- package/src/levels-tool.ts +71 -78
- package/src/load.ts +6 -1
- package/src/local-cli.ts +12 -0
- package/src/mcp-docs-tools.ts +51 -3
- package/src/mcp-http.ts +2 -2
- package/src/mcp-io.ts +77 -0
- package/src/mcp-isolate.ts +2 -3
- package/src/mcp-project-child.ts +5 -14
- package/src/mcp-render.ts +11 -59
- package/src/mcp-root.ts +1 -1
- package/src/mcp-run.ts +5 -54
- package/src/mcp-ws.ts +2 -19
- package/src/migrate-layout.ts +52 -72
- package/src/output-schemas.ts +7 -8
- package/src/port.ts +1 -4
- package/src/ppr-read-fix.ts +2 -2
- package/src/recipes/5.8.0.ts +21 -0
- package/src/recipes/5.9.0.ts +42 -0
- package/src/recipes/index.ts +9 -0
- package/src/review.ts +12 -15
- package/src/rules/contract-visibility.ts +3 -8
- package/src/rules/data-guard.ts +3 -10
- package/src/rules/pages.ts +47 -58
- package/src/rules/routes.ts +21 -27
- package/src/rules/security.ts +224 -255
- package/src/rules/zones.ts +3 -10
- package/src/runtime-differences.ts +302 -0
- package/src/sdk.ts +55 -58
- package/src/smoke.ts +4 -13
- package/src/source-rewrites.ts +463 -0
- package/src/stylex-migrate.ts +1 -3
- package/src/symptom-search.ts +27 -0
- package/src/upgrade.ts +194 -74
- package/src/verification-plan.ts +10 -4
package/dist/migrate-layout.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* a moved name at runtime, a helper both halves need, a loader with no output schema, an import no
|
|
26
26
|
* specifier reaches after the moves, a specifier that names nothing) instead of guessing.
|
|
27
27
|
*/
|
|
28
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync,
|
|
28
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmdirSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
29
29
|
import { builtinModules } from "node:module";
|
|
30
30
|
import { dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
31
31
|
import { BACKEND_ROUTE_EXPORTS } from "@nifrajs/web/route-manifest";
|
|
@@ -33,8 +33,11 @@ import { parseZoneConfig } from "@nifrajs/web/zones";
|
|
|
33
33
|
import { BACKEND_APP_FILE, CONFIG_FILE, FRAMEWORK_FILE, retiredRootFiles } from "./app-files.js";
|
|
34
34
|
import { codeUnitOrder } from "./internal/code-unit-order.js";
|
|
35
35
|
import { configPathReader } from "./internal/config-paths.js";
|
|
36
|
+
import { escapeRegExp } from "./internal/escape-regexp.js";
|
|
36
37
|
import { createKindProbe, hasWebConfig } from "./internal/nifra-project.js";
|
|
38
|
+
import { toPosix } from "./internal/posix-path.js";
|
|
37
39
|
import { createSpecifierResolver, isFile } from "./internal/project-specifiers.js";
|
|
40
|
+
import { realpathOrSelf } from "./internal/realpath-or-self.js";
|
|
38
41
|
import { importTypeScript } from "./internal/typescript-import.js";
|
|
39
42
|
import { planOutputSchemas } from "./output-schemas.js";
|
|
40
43
|
import { missingOutputSchemas } from "./rules/data-guard.js";
|
|
@@ -96,7 +99,6 @@ const SUBJECT_EXTENSIONS = [
|
|
|
96
99
|
".svelte",
|
|
97
100
|
".vue",
|
|
98
101
|
];
|
|
99
|
-
const toPosix = (path) => path.replaceAll("\\", "/");
|
|
100
102
|
/** A specifier without its `?query` or `#hash`; a leading `#` names a package.json import. Cut by
|
|
101
103
|
* index, since `/[?#].*$/` retries from every `#` and is quadratic on a long run of them. */
|
|
102
104
|
const withoutQuery = (specifier) => {
|
|
@@ -325,7 +327,6 @@ function filterExportList(ts, sf, node, keep) {
|
|
|
325
327
|
const leading = node.getFullText(sf).slice(0, node.getStart(sf) - node.getFullStart());
|
|
326
328
|
return `${leading}export ${node.isTypeOnly ? "type " : ""}{ ${kept.join(", ")} }${from}${terminatorOf(sf, node)}`;
|
|
327
329
|
}
|
|
328
|
-
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
329
330
|
const joinStatements = (texts) => {
|
|
330
331
|
const body = texts.join("").replace(/^\s*\n/, "");
|
|
331
332
|
return body.endsWith("\n") ? body : `${body}\n`;
|
|
@@ -845,6 +846,13 @@ function scriptBlocks(source) {
|
|
|
845
846
|
}
|
|
846
847
|
return blocks;
|
|
847
848
|
}
|
|
849
|
+
/** `text` with every edit made, last offset first so the ones before it still point where they did. */
|
|
850
|
+
function applyEdits(text, edits) {
|
|
851
|
+
let out = text;
|
|
852
|
+
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
853
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
854
|
+
return out;
|
|
855
|
+
}
|
|
848
856
|
/** The path argument of `mock.module("./x", ...)` or a vitest/jest twin, when it is a literal. */
|
|
849
857
|
function mockedSpecifier(ts, node) {
|
|
850
858
|
const callee = node.expression;
|
|
@@ -1258,10 +1266,7 @@ function rebaseOwnPaths(ts, from, to, text, locate) {
|
|
|
1258
1266
|
followed.push([declaration.initializer.getStart(sf), declaration.initializer.getEnd()]);
|
|
1259
1267
|
}
|
|
1260
1268
|
const unfollowed = [...text.matchAll(new RegExp(SELF_LOCATION.source, "g"))].find((match) => !followed.some(([start, end]) => start <= match.index && match.index < end))?.[0];
|
|
1261
|
-
|
|
1262
|
-
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
1263
|
-
next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);
|
|
1264
|
-
return { text: next, unfollowed };
|
|
1269
|
+
return { text: applyEdits(text, edits), unfollowed };
|
|
1265
1270
|
}
|
|
1266
1271
|
/** Rewrite one relative specifier from `from`'s new location to `target`'s new location, keeping the
|
|
1267
1272
|
* author's style: extension kept when written, dropped when not, `/index` collapsed when it was. */
|
|
@@ -1397,10 +1402,7 @@ function redirectMovedImports(ts, file, text, splitOf) {
|
|
|
1397
1402
|
ts.forEachChild(node, visit);
|
|
1398
1403
|
};
|
|
1399
1404
|
visit(sf);
|
|
1400
|
-
|
|
1401
|
-
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
1402
|
-
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
1403
|
-
return { text: out, issues, redirects };
|
|
1405
|
+
return { text: applyEdits(text, edits), issues, redirects };
|
|
1404
1406
|
}
|
|
1405
1407
|
/**
|
|
1406
1408
|
* The exports code reads from what `import()` loads: off the awaited module (`(await import(x)).a`),
|
|
@@ -1456,7 +1458,7 @@ function dynamicReads(ts, sf, call) {
|
|
|
1456
1458
|
function workspacePattern(glob) {
|
|
1457
1459
|
const source = glob
|
|
1458
1460
|
.replace(/^\.\//, "")
|
|
1459
|
-
.replace(
|
|
1461
|
+
.replace(/(?<!\/)\/+$/, "")
|
|
1460
1462
|
.split("/")
|
|
1461
1463
|
.map((segment) => segment === "**"
|
|
1462
1464
|
? "(?:[^/]+/)*?[^/]*"
|
|
@@ -1642,35 +1644,30 @@ function rewriteImports(ts, file, text, rewrite) {
|
|
|
1642
1644
|
visit(sf);
|
|
1643
1645
|
};
|
|
1644
1646
|
const edits = [];
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
}
|
|
1649
|
-
else if (file.endsWith(".css")) {
|
|
1650
|
-
for (const match of text.matchAll(/(@import\s+(?:url\()?["'])([^"']+)["']/g)) {
|
|
1647
|
+
// A match's group 2 is the specifier; group 1 is everything before it.
|
|
1648
|
+
const rewriteMatches = (pattern) => {
|
|
1649
|
+
for (const match of text.matchAll(pattern)) {
|
|
1651
1650
|
const next = rewrite(match[2] ?? "");
|
|
1652
1651
|
if (next !== undefined) {
|
|
1653
1652
|
const start = (match.index ?? 0) + (match[1] ?? "").length;
|
|
1654
1653
|
edits.push({ start, end: start + (match[2] ?? "").length, text: next });
|
|
1655
1654
|
}
|
|
1656
1655
|
}
|
|
1656
|
+
};
|
|
1657
|
+
if (/\.(?:svelte|vue)$/.test(file)) {
|
|
1658
|
+
for (const block of scriptBlocks(text))
|
|
1659
|
+
replace(text.slice(block.start, block.end), block.start, edits, ts.ScriptKind.TS);
|
|
1660
|
+
}
|
|
1661
|
+
else if (file.endsWith(".css")) {
|
|
1662
|
+
rewriteMatches(/(@import\s+(?:url\()?["'])([^"']+)["']/g);
|
|
1657
1663
|
}
|
|
1658
1664
|
else if (file.endsWith(".mdx")) {
|
|
1659
|
-
|
|
1660
|
-
const next = rewrite(match[2] ?? "");
|
|
1661
|
-
if (next !== undefined) {
|
|
1662
|
-
const start = (match.index ?? 0) + (match[1] ?? "").length;
|
|
1663
|
-
edits.push({ start, end: start + (match[2] ?? "").length, text: next });
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1665
|
+
rewriteMatches(/^((?:import|export)\s[^\n]*?from\s+["'])([^"']+)["']/gm);
|
|
1666
1666
|
}
|
|
1667
1667
|
else if (/\.[cm]?[jt]sx?$/.test(file)) {
|
|
1668
1668
|
replace(text, 0, edits, file.endsWith("x") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
|
|
1669
1669
|
}
|
|
1670
|
-
|
|
1671
|
-
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
1672
|
-
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
1673
|
-
return out;
|
|
1670
|
+
return applyEdits(text, edits);
|
|
1674
1671
|
}
|
|
1675
1672
|
/** `ServerOnly` imported from `@nifrajs/web` becomes `BackendOnly`, along with every use of it. */
|
|
1676
1673
|
function renameRetiredTypes(ts, file, text) {
|
|
@@ -1718,10 +1715,7 @@ function renameRetiredTypes(ts, file, text) {
|
|
|
1718
1715
|
else if (/\.[cm]?[jt]sx?$/.test(file)) {
|
|
1719
1716
|
scan(text, 0, file.endsWith("x") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
|
|
1720
1717
|
}
|
|
1721
|
-
|
|
1722
|
-
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
1723
|
-
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
1724
|
-
return out;
|
|
1718
|
+
return applyEdits(text, edits);
|
|
1725
1719
|
}
|
|
1726
1720
|
// ---------------------------------------------------------------------------------------------------
|
|
1727
1721
|
// The migration
|
|
@@ -1937,14 +1931,7 @@ export async function migrateLayout(appRoot, options = {}) {
|
|
|
1937
1931
|
const resolver = createSpecifierResolver({
|
|
1938
1932
|
moduleExists: (path) => knownPaths.has(path) || isFile(path),
|
|
1939
1933
|
});
|
|
1940
|
-
const realRoot = (
|
|
1941
|
-
try {
|
|
1942
|
-
return realpathSync(root);
|
|
1943
|
-
}
|
|
1944
|
-
catch {
|
|
1945
|
-
return root;
|
|
1946
|
-
}
|
|
1947
|
-
})();
|
|
1934
|
+
const realRoot = realpathOrSelf(root);
|
|
1948
1935
|
/** An app file as the migration names it, from a path the resolver found (real, or as planned). */
|
|
1949
1936
|
const appFile = (path) => {
|
|
1950
1937
|
if (path === undefined)
|
|
@@ -2405,10 +2392,7 @@ export async function migrateLayout(appRoot, options = {}) {
|
|
|
2405
2392
|
}
|
|
2406
2393
|
if (edits.length === 0)
|
|
2407
2394
|
continue;
|
|
2408
|
-
|
|
2409
|
-
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
2410
|
-
updated = updated.slice(0, edit.start) + edit.text + updated.slice(edit.end);
|
|
2411
|
-
final.set(at, updated);
|
|
2395
|
+
final.set(at, applyEdits(text, edits));
|
|
2412
2396
|
if (!moveMap.has(file) && !rewritten.includes(file))
|
|
2413
2397
|
rewritten.push(file);
|
|
2414
2398
|
}
|
|
@@ -2434,10 +2418,7 @@ export async function migrateLayout(appRoot, options = {}) {
|
|
|
2434
2418
|
}
|
|
2435
2419
|
if (edits.length === 0)
|
|
2436
2420
|
continue;
|
|
2437
|
-
|
|
2438
|
-
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
2439
|
-
updated = updated.slice(0, edit.start) + edit.text + updated.slice(edit.end);
|
|
2440
|
-
final.set(at, updated);
|
|
2421
|
+
final.set(at, applyEdits(text, edits));
|
|
2441
2422
|
if (!moveMap.has(configFile) && !rewritten.includes(configFile))
|
|
2442
2423
|
rewritten.push(configFile);
|
|
2443
2424
|
}
|
|
@@ -2835,7 +2816,10 @@ const matchers = new Map();
|
|
|
2835
2816
|
function matches(pattern, file) {
|
|
2836
2817
|
let match = matchers.get(pattern);
|
|
2837
2818
|
if (match === undefined) {
|
|
2838
|
-
let spec = pattern
|
|
2819
|
+
let spec = pattern
|
|
2820
|
+
.replaceAll("\\", "/")
|
|
2821
|
+
.replace(/^\.\//, "")
|
|
2822
|
+
.replace(/(?<!\/)\/+$/, "");
|
|
2839
2823
|
if (spec === "" || spec === ".")
|
|
2840
2824
|
match = () => true;
|
|
2841
2825
|
else if (!/[*?]/.test(spec)) {
|
|
@@ -2948,9 +2932,7 @@ function followTsconfigs(ts, root, moves, layout) {
|
|
|
2948
2932
|
}
|
|
2949
2933
|
own.set(key, lists);
|
|
2950
2934
|
}
|
|
2951
|
-
let updated = text;
|
|
2952
|
-
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
2953
|
-
updated = updated.slice(0, edit.start) + edit.text + updated.slice(edit.end);
|
|
2935
|
+
let updated = applyEdits(text, edits);
|
|
2954
2936
|
const changes = [];
|
|
2955
2937
|
if (edits.length > 0)
|
|
2956
2938
|
changes.push(`${edits.length} file path(s) follow their moved files`);
|
|
@@ -3295,10 +3277,7 @@ function rewritePackagePaths(ts, text, moves) {
|
|
|
3295
3277
|
if (PACKAGE_PATH_FIELDS.has(property.name.text))
|
|
3296
3278
|
visit(property.initializer, property.name.text);
|
|
3297
3279
|
}
|
|
3298
|
-
|
|
3299
|
-
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
3300
|
-
next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);
|
|
3301
|
-
return { text: next, count };
|
|
3280
|
+
return { text: applyEdits(text, edits), count };
|
|
3302
3281
|
}
|
|
3303
3282
|
/** Tailwind `content` globs that matched a moved file at its old path and match nothing at its new one. */
|
|
3304
3283
|
function staleContentGlobs(ts, text, moves) {
|