@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/index.js
CHANGED
|
@@ -1242,11 +1242,83 @@ function removeInterfaceBlock(source) {
|
|
|
1242
1242
|
out = out.slice(0, match.index) + out.slice(endIdx);
|
|
1243
1243
|
}
|
|
1244
1244
|
}
|
|
1245
|
+
function findStringEnd(source, openIdx) {
|
|
1246
|
+
const quote = source[openIdx];
|
|
1247
|
+
let i = openIdx + 1;
|
|
1248
|
+
while (i < source.length) {
|
|
1249
|
+
const ch = source[i];
|
|
1250
|
+
if (ch === "\\") {
|
|
1251
|
+
i += 2;
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
if (ch === quote) return i;
|
|
1255
|
+
i++;
|
|
1256
|
+
}
|
|
1257
|
+
return -1;
|
|
1258
|
+
}
|
|
1259
|
+
function maskStringLiterals(source) {
|
|
1260
|
+
const strings = [];
|
|
1261
|
+
let out = "";
|
|
1262
|
+
let i = 0;
|
|
1263
|
+
while (i < source.length) {
|
|
1264
|
+
const ch = source[i];
|
|
1265
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
1266
|
+
const closeIdx = findStringEnd(source, i);
|
|
1267
|
+
if (closeIdx === -1) {
|
|
1268
|
+
out += source.slice(i);
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1271
|
+
const literal = source.slice(i, closeIdx + 1);
|
|
1272
|
+
out += `__RDMNT_STR_${strings.length}__`;
|
|
1273
|
+
strings.push(literal);
|
|
1274
|
+
i = closeIdx + 1;
|
|
1275
|
+
} else {
|
|
1276
|
+
out += ch;
|
|
1277
|
+
i++;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return {
|
|
1281
|
+
masked: out,
|
|
1282
|
+
restore: (s) => s.replace(/__RDMNT_STR_(\d+)__/g, (_full, idx) => strings[Number(idx)] ?? "")
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
var PROPS_DECL = /let\s*\{([^}]*)\}\s*(?::\s*\{([^}]*)\})?\s*=\s*\$props\(\)\s*;?/;
|
|
1286
|
+
function injectRestIntoProps(scriptBody) {
|
|
1287
|
+
const match = scriptBody.match(PROPS_DECL);
|
|
1288
|
+
if (!match) return scriptBody;
|
|
1289
|
+
const destructured = match[1] ?? "";
|
|
1290
|
+
if (/\.\.\.\s*\w+/.test(destructured)) return scriptBody;
|
|
1291
|
+
const trimmed = destructured.trim();
|
|
1292
|
+
const newDestructured = trimmed === "" ? " ...rest " : ` ${trimmed}, ...rest `;
|
|
1293
|
+
let replacement;
|
|
1294
|
+
if (match[2] !== void 0) {
|
|
1295
|
+
const typeBody = match[2];
|
|
1296
|
+
const hasIndexSig = /\[\s*key\s*:\s*string\s*\]\s*:/.test(typeBody);
|
|
1297
|
+
const newTypeBody = hasIndexSig ? typeBody : `${typeBody.trimEnd().replace(/;?\s*$/, "")}; [key: string]: unknown `;
|
|
1298
|
+
replacement = `let {${newDestructured}}: {${newTypeBody}} = $props();`;
|
|
1299
|
+
} else {
|
|
1300
|
+
replacement = `let {${newDestructured}} = $props();`;
|
|
1301
|
+
}
|
|
1302
|
+
return scriptBody.replace(PROPS_DECL, replacement);
|
|
1303
|
+
}
|
|
1304
|
+
var SCRIPT_BLOCK3 = /<script\b([^>]*)>([\s\S]*?)<\/script>/;
|
|
1305
|
+
var HAS_PROPS_CALL = /\$props\(\s*\)/;
|
|
1245
1306
|
function removeDollarRestProps(source) {
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1307
|
+
const next = removeInterfaceBlock(source);
|
|
1308
|
+
const scriptMatch = next.match(SCRIPT_BLOCK3);
|
|
1309
|
+
if (!scriptMatch) return next;
|
|
1310
|
+
if (!HAS_PROPS_CALL.test(scriptMatch[2] ?? "")) {
|
|
1311
|
+
return next;
|
|
1312
|
+
}
|
|
1313
|
+
const scriptInner = scriptMatch[2] ?? "";
|
|
1314
|
+
const { masked, restore } = maskStringLiterals(scriptInner);
|
|
1315
|
+
let processed = injectRestIntoProps(masked);
|
|
1316
|
+
processed = processed.replace(/\$\$restProps/g, "rest");
|
|
1317
|
+
const restoredInner = restore(processed);
|
|
1318
|
+
const newScriptBlock = scriptMatch[0].replace(scriptInner, () => restoredInner);
|
|
1319
|
+
const before = next.slice(0, scriptMatch.index);
|
|
1320
|
+
const after = next.slice(scriptMatch.index + scriptMatch[0].length);
|
|
1321
|
+
return before.replace(/\$\$restProps/g, "rest") + newScriptBlock + after.replace(/\$\$restProps/g, "rest");
|
|
1250
1322
|
}
|
|
1251
1323
|
|
|
1252
1324
|
// src/recipes/svelte-5/codemods/state-effect-sync.ts
|
|
@@ -1262,12 +1334,12 @@ function stateEffectSyncToDerived(source) {
|
|
|
1262
1334
|
var PROPS_DESTRUCTURE = /let\s*\{([\s\S]*?)\}(\s*:\s*\{([\s\S]*?)\})?\s*=\s*\$props\(\)/;
|
|
1263
1335
|
var DOLLAR_PROPS_CLASS = /\$\$props\.class\b/g;
|
|
1264
1336
|
var DOLLAR_PROPS_ANY = /\$\$props\b/;
|
|
1265
|
-
var
|
|
1337
|
+
var SCRIPT_BLOCK4 = /<script\b[^>]*>[\s\S]*?<\/script>/g;
|
|
1266
1338
|
var MIGRATION_TASK = /^<!--\s*@migration-task[\s\S]*?-->\s*\n?/gm;
|
|
1267
1339
|
var IDENT = "className";
|
|
1268
1340
|
function maskScripts(source) {
|
|
1269
1341
|
const blocks = [];
|
|
1270
|
-
const masked = source.replace(
|
|
1342
|
+
const masked = source.replace(SCRIPT_BLOCK4, (m) => {
|
|
1271
1343
|
blocks.push(m);
|
|
1272
1344
|
return `__SCRIPT_${blocks.length - 1}__`;
|
|
1273
1345
|
});
|
|
@@ -1307,7 +1379,7 @@ function dollarPropsClass(source) {
|
|
|
1307
1379
|
}
|
|
1308
1380
|
|
|
1309
1381
|
// src/recipes/svelte-5/codemods/legacy-reactive.ts
|
|
1310
|
-
var
|
|
1382
|
+
var SCRIPT_BLOCK5 = /<script\b([^>]*)>([\s\S]*?)<\/script>/g;
|
|
1311
1383
|
var SIMPLE_REACTIVE = /^([ \t]*)\$:\s*(\w+)\s*=\s*([^;\n]+);?[ \t]*$/gm;
|
|
1312
1384
|
var BLOCK_REACTIVE_HEAD = /(^|\n)([ \t]*)\$:\s*\{/g;
|
|
1313
1385
|
function findMatchingClose(source, openIdx) {
|
|
@@ -1344,6 +1416,7 @@ function findStringClose(source, openIdx) {
|
|
|
1344
1416
|
}
|
|
1345
1417
|
return -1;
|
|
1346
1418
|
}
|
|
1419
|
+
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.";
|
|
1347
1420
|
function transformBlocks(body) {
|
|
1348
1421
|
const out = [];
|
|
1349
1422
|
let last = 0;
|
|
@@ -1359,6 +1432,8 @@ function transformBlocks(body) {
|
|
|
1359
1432
|
out.push(body.slice(last, m.index));
|
|
1360
1433
|
out.push(leadingNewline);
|
|
1361
1434
|
const blockBody = body.slice(openBraceIdx + 1, closeBraceIdx);
|
|
1435
|
+
out.push(`${indent}${MIGRATION_MARKER}
|
|
1436
|
+
`);
|
|
1362
1437
|
out.push(`${indent}$effect(() => {${blockBody}});`);
|
|
1363
1438
|
last = closeBraceIdx + 1;
|
|
1364
1439
|
BLOCK_REACTIVE_HEAD.lastIndex = last;
|
|
@@ -1372,7 +1447,7 @@ function transformSimple(body) {
|
|
|
1372
1447
|
});
|
|
1373
1448
|
}
|
|
1374
1449
|
function legacyReactiveToRunes(source) {
|
|
1375
|
-
return source.replace(
|
|
1450
|
+
return source.replace(SCRIPT_BLOCK5, (full, _attrs, body) => {
|
|
1376
1451
|
let next = transformBlocks(body);
|
|
1377
1452
|
next = transformSimple(next);
|
|
1378
1453
|
if (next === body) return full;
|
|
@@ -1659,6 +1734,7 @@ async function convertToPnpm(site, opts = {}) {
|
|
|
1659
1734
|
await writePackageJson(pkgPath, next);
|
|
1660
1735
|
const pkgSha = await commit(site.path, "chore(pnpm): pin packageManager + rewrite npm scripts");
|
|
1661
1736
|
if (pkgSha) shas.push(pkgSha);
|
|
1737
|
+
await rm3(join13(site.path, "node_modules"), { recursive: true, force: true });
|
|
1662
1738
|
const installResult = await spawn2("pnpm", ["install"], {
|
|
1663
1739
|
cwd: site.path,
|
|
1664
1740
|
streaming: true
|