@reddoorla/maintenance 0.6.3 → 0.6.5
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/bin.js +84 -8
- package/dist/cli/bin.js.map +1 -1
- package/dist/index.js +84 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/bin.js
CHANGED
|
@@ -1516,11 +1516,83 @@ function removeInterfaceBlock(source) {
|
|
|
1516
1516
|
out = out.slice(0, match.index) + out.slice(endIdx);
|
|
1517
1517
|
}
|
|
1518
1518
|
}
|
|
1519
|
+
function findStringEnd(source, openIdx) {
|
|
1520
|
+
const quote = source[openIdx];
|
|
1521
|
+
let i = openIdx + 1;
|
|
1522
|
+
while (i < source.length) {
|
|
1523
|
+
const ch = source[i];
|
|
1524
|
+
if (ch === "\\") {
|
|
1525
|
+
i += 2;
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
if (ch === quote) return i;
|
|
1529
|
+
i++;
|
|
1530
|
+
}
|
|
1531
|
+
return -1;
|
|
1532
|
+
}
|
|
1533
|
+
function maskStringLiterals(source) {
|
|
1534
|
+
const strings = [];
|
|
1535
|
+
let out = "";
|
|
1536
|
+
let i = 0;
|
|
1537
|
+
while (i < source.length) {
|
|
1538
|
+
const ch = source[i];
|
|
1539
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
1540
|
+
const closeIdx = findStringEnd(source, i);
|
|
1541
|
+
if (closeIdx === -1) {
|
|
1542
|
+
out += source.slice(i);
|
|
1543
|
+
break;
|
|
1544
|
+
}
|
|
1545
|
+
const literal = source.slice(i, closeIdx + 1);
|
|
1546
|
+
out += `__RDMNT_STR_${strings.length}__`;
|
|
1547
|
+
strings.push(literal);
|
|
1548
|
+
i = closeIdx + 1;
|
|
1549
|
+
} else {
|
|
1550
|
+
out += ch;
|
|
1551
|
+
i++;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
return {
|
|
1555
|
+
masked: out,
|
|
1556
|
+
restore: (s) => s.replace(/__RDMNT_STR_(\d+)__/g, (_full, idx) => strings[Number(idx)] ?? "")
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
var PROPS_DECL = /let\s*\{([^}]*)\}\s*(?::\s*\{([^}]*)\})?\s*=\s*\$props\(\)\s*;?/;
|
|
1560
|
+
function injectRestIntoProps(scriptBody) {
|
|
1561
|
+
const match = scriptBody.match(PROPS_DECL);
|
|
1562
|
+
if (!match) return scriptBody;
|
|
1563
|
+
const destructured = match[1] ?? "";
|
|
1564
|
+
if (/\.\.\.\s*\w+/.test(destructured)) return scriptBody;
|
|
1565
|
+
const trimmed = destructured.trim();
|
|
1566
|
+
const newDestructured = trimmed === "" ? " ...rest " : ` ${trimmed}, ...rest `;
|
|
1567
|
+
let replacement;
|
|
1568
|
+
if (match[2] !== void 0) {
|
|
1569
|
+
const typeBody = match[2];
|
|
1570
|
+
const hasIndexSig = /\[\s*key\s*:\s*string\s*\]\s*:/.test(typeBody);
|
|
1571
|
+
const newTypeBody = hasIndexSig ? typeBody : `${typeBody.trimEnd().replace(/;?\s*$/, "")}; [key: string]: unknown `;
|
|
1572
|
+
replacement = `let {${newDestructured}}: {${newTypeBody}} = $props();`;
|
|
1573
|
+
} else {
|
|
1574
|
+
replacement = `let {${newDestructured}} = $props();`;
|
|
1575
|
+
}
|
|
1576
|
+
return scriptBody.replace(PROPS_DECL, replacement);
|
|
1577
|
+
}
|
|
1578
|
+
var SCRIPT_BLOCK3 = /<script\b([^>]*)>([\s\S]*?)<\/script>/;
|
|
1579
|
+
var HAS_PROPS_CALL = /\$props\(\s*\)/;
|
|
1519
1580
|
function removeDollarRestProps(source) {
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1581
|
+
const next = removeInterfaceBlock(source);
|
|
1582
|
+
const scriptMatch = next.match(SCRIPT_BLOCK3);
|
|
1583
|
+
if (!scriptMatch) return next;
|
|
1584
|
+
if (!HAS_PROPS_CALL.test(scriptMatch[2] ?? "")) {
|
|
1585
|
+
return next;
|
|
1586
|
+
}
|
|
1587
|
+
const scriptInner = scriptMatch[2] ?? "";
|
|
1588
|
+
const { masked, restore } = maskStringLiterals(scriptInner);
|
|
1589
|
+
let processed = injectRestIntoProps(masked);
|
|
1590
|
+
processed = processed.replace(/\$\$restProps/g, "rest");
|
|
1591
|
+
const restoredInner = restore(processed);
|
|
1592
|
+
const newScriptBlock = scriptMatch[0].replace(scriptInner, () => restoredInner);
|
|
1593
|
+
const before = next.slice(0, scriptMatch.index);
|
|
1594
|
+
const after = next.slice(scriptMatch.index + scriptMatch[0].length);
|
|
1595
|
+
return before.replace(/\$\$restProps/g, "rest") + newScriptBlock + after.replace(/\$\$restProps/g, "rest");
|
|
1524
1596
|
}
|
|
1525
1597
|
|
|
1526
1598
|
// src/recipes/svelte-5/codemods/state-effect-sync.ts
|
|
@@ -1536,12 +1608,12 @@ function stateEffectSyncToDerived(source) {
|
|
|
1536
1608
|
var PROPS_DESTRUCTURE = /let\s*\{([\s\S]*?)\}(\s*:\s*\{([\s\S]*?)\})?\s*=\s*\$props\(\)/;
|
|
1537
1609
|
var DOLLAR_PROPS_CLASS = /\$\$props\.class\b/g;
|
|
1538
1610
|
var DOLLAR_PROPS_ANY = /\$\$props\b/;
|
|
1539
|
-
var
|
|
1611
|
+
var SCRIPT_BLOCK4 = /<script\b[^>]*>[\s\S]*?<\/script>/g;
|
|
1540
1612
|
var MIGRATION_TASK = /^<!--\s*@migration-task[\s\S]*?-->\s*\n?/gm;
|
|
1541
1613
|
var IDENT = "className";
|
|
1542
1614
|
function maskScripts(source) {
|
|
1543
1615
|
const blocks = [];
|
|
1544
|
-
const masked = source.replace(
|
|
1616
|
+
const masked = source.replace(SCRIPT_BLOCK4, (m) => {
|
|
1545
1617
|
blocks.push(m);
|
|
1546
1618
|
return `__SCRIPT_${blocks.length - 1}__`;
|
|
1547
1619
|
});
|
|
@@ -1581,7 +1653,7 @@ function dollarPropsClass(source) {
|
|
|
1581
1653
|
}
|
|
1582
1654
|
|
|
1583
1655
|
// src/recipes/svelte-5/codemods/legacy-reactive.ts
|
|
1584
|
-
var
|
|
1656
|
+
var SCRIPT_BLOCK5 = /<script\b([^>]*)>([\s\S]*?)<\/script>/g;
|
|
1585
1657
|
var SIMPLE_REACTIVE = /^([ \t]*)\$:\s*(\w+)\s*=\s*([^;\n]+);?[ \t]*$/gm;
|
|
1586
1658
|
var BLOCK_REACTIVE_HEAD = /(^|\n)([ \t]*)\$:\s*\{/g;
|
|
1587
1659
|
function findMatchingClose(source, openIdx) {
|
|
@@ -1618,6 +1690,7 @@ function findStringClose(source, openIdx) {
|
|
|
1618
1690
|
}
|
|
1619
1691
|
return -1;
|
|
1620
1692
|
}
|
|
1693
|
+
var MIGRATION_MARKER = "// @migration-task: $effect won't trigger UI updates on plain `let` bindings \u2014 refine mutated locals to $state or split into per-variable $derived.";
|
|
1621
1694
|
function transformBlocks(body) {
|
|
1622
1695
|
const out = [];
|
|
1623
1696
|
let last = 0;
|
|
@@ -1633,6 +1706,8 @@ function transformBlocks(body) {
|
|
|
1633
1706
|
out.push(body.slice(last, m.index));
|
|
1634
1707
|
out.push(leadingNewline);
|
|
1635
1708
|
const blockBody = body.slice(openBraceIdx + 1, closeBraceIdx);
|
|
1709
|
+
out.push(`${indent}${MIGRATION_MARKER}
|
|
1710
|
+
`);
|
|
1636
1711
|
out.push(`${indent}$effect(() => {${blockBody}});`);
|
|
1637
1712
|
last = closeBraceIdx + 1;
|
|
1638
1713
|
BLOCK_REACTIVE_HEAD.lastIndex = last;
|
|
@@ -1646,7 +1721,7 @@ function transformSimple(body) {
|
|
|
1646
1721
|
});
|
|
1647
1722
|
}
|
|
1648
1723
|
function legacyReactiveToRunes(source) {
|
|
1649
|
-
return source.replace(
|
|
1724
|
+
return source.replace(SCRIPT_BLOCK5, (full, _attrs, body) => {
|
|
1650
1725
|
let next = transformBlocks(body);
|
|
1651
1726
|
next = transformSimple(next);
|
|
1652
1727
|
if (next === body) return full;
|
|
@@ -1934,6 +2009,7 @@ async function convertToPnpm(site, opts = {}) {
|
|
|
1934
2009
|
await writePackageJson(pkgPath, next);
|
|
1935
2010
|
const pkgSha = await commit(site.path, "chore(pnpm): pin packageManager + rewrite npm scripts");
|
|
1936
2011
|
if (pkgSha) shas.push(pkgSha);
|
|
2012
|
+
await rm3(join14(site.path, "node_modules"), { recursive: true, force: true });
|
|
1937
2013
|
const installResult = await spawn2("pnpm", ["install"], {
|
|
1938
2014
|
cwd: site.path,
|
|
1939
2015
|
streaming: true
|