tsdown-migrate 0.20.0 → 0.20.2
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/index.mjs
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { n as migratePackageJson, t as migrateTsupConfig } from "./tsup-config-Cc0of_k5.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { getCliCommand, parseNi, run } from "@antfu/ni";
|
|
4
|
+
import { green, greenBright, underline } from "ansis";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { glob } from "tinyglobby";
|
|
2
7
|
|
|
8
|
+
//#region src/index.ts
|
|
9
|
+
async function migrate({ dirs, dryRun }) {
|
|
10
|
+
if (dryRun) consola.info("Dry run enabled. No changes were made.");
|
|
11
|
+
else if (!await consola.prompt(`Before proceeding, review the migration guide at ${underline`https://tsdown.dev/guide/migrate-from-tsup`}, as this process will modify your files.\nUncommitted changes will be lost. Use the ${green`--dry-run`} flag to preview changes without applying them.\n\nContinue?`, { type: "confirm" })) {
|
|
12
|
+
consola.warn("Migration cancelled.");
|
|
13
|
+
process.exitCode = 1;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const baseCwd = process.cwd();
|
|
17
|
+
let cwds;
|
|
18
|
+
if (dirs?.length) {
|
|
19
|
+
cwds = await glob(dirs, {
|
|
20
|
+
cwd: baseCwd,
|
|
21
|
+
onlyDirectories: true,
|
|
22
|
+
absolute: true,
|
|
23
|
+
expandDirectories: false
|
|
24
|
+
});
|
|
25
|
+
if (cwds.length === 0) {
|
|
26
|
+
consola.error(`No directories matched: ${dirs.join(", ")}`);
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
} else cwds = [baseCwd];
|
|
31
|
+
let migratedAny = false;
|
|
32
|
+
try {
|
|
33
|
+
for (const dir of cwds) {
|
|
34
|
+
process.chdir(dir);
|
|
35
|
+
const dirLabel = greenBright(dir);
|
|
36
|
+
consola.info(`Processing ${dirLabel}`);
|
|
37
|
+
let migrated = await migratePackageJson(dryRun);
|
|
38
|
+
if (await migrateTsupConfig(dryRun)) migrated = true;
|
|
39
|
+
if (!migrated) {
|
|
40
|
+
consola.warn(`No migrations to apply in ${dirLabel}.`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
migratedAny = true;
|
|
44
|
+
}
|
|
45
|
+
} finally {
|
|
46
|
+
process.chdir(baseCwd);
|
|
47
|
+
}
|
|
48
|
+
if (!migratedAny) {
|
|
49
|
+
consola.error("No migration performed.");
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
consola.info("Migration completed. Installing dependencies...");
|
|
54
|
+
if (dryRun) consola.info("[dry-run] would run:", await getCliCommand(parseNi, []));
|
|
55
|
+
else {
|
|
56
|
+
await run(parseNi, [], { cwd: baseCwd });
|
|
57
|
+
consola.success("Dependencies installed.");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
3
62
|
export { migrate };
|
package/dist/run.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { i as version, r as name } from "./tsup-config-Cc0of_k5.mjs";
|
|
3
|
+
import { migrate } from "./index.mjs";
|
|
3
4
|
import process from "node:process";
|
|
4
5
|
import consola from "consola";
|
|
5
6
|
import { cac } from "cac";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getCliCommand, parseNi, run } from "@antfu/ni";
|
|
3
|
-
import { dim, green, greenBright, red, underline } from "ansis";
|
|
1
|
+
import { dim, green, red } from "ansis";
|
|
4
2
|
import consola from "consola";
|
|
5
|
-
import { glob } from "tinyglobby";
|
|
6
3
|
import { existsSync } from "node:fs";
|
|
7
4
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
8
5
|
import { createPatch, createTwoFilesPatch } from "diff";
|
|
@@ -23,7 +20,7 @@ function detectIndentation(jsonText) {
|
|
|
23
20
|
//#endregion
|
|
24
21
|
//#region package.json
|
|
25
22
|
var name = "tsdown-migrate";
|
|
26
|
-
var version = "0.20.
|
|
23
|
+
var version = "0.20.2";
|
|
27
24
|
|
|
28
25
|
//#endregion
|
|
29
26
|
//#region src/utils.ts
|
|
@@ -299,58 +296,4 @@ async function migrateTsupConfig(dryRun) {
|
|
|
299
296
|
}
|
|
300
297
|
|
|
301
298
|
//#endregion
|
|
302
|
-
|
|
303
|
-
async function migrate({ dirs, dryRun }) {
|
|
304
|
-
if (dryRun) consola.info("Dry run enabled. No changes were made.");
|
|
305
|
-
else if (!await consola.prompt(`Before proceeding, review the migration guide at ${underline`https://tsdown.dev/guide/migrate-from-tsup`}, as this process will modify your files.\nUncommitted changes will be lost. Use the ${green`--dry-run`} flag to preview changes without applying them.\n\nContinue?`, { type: "confirm" })) {
|
|
306
|
-
consola.warn("Migration cancelled.");
|
|
307
|
-
process.exitCode = 1;
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const baseCwd = process.cwd();
|
|
311
|
-
let cwds;
|
|
312
|
-
if (dirs?.length) {
|
|
313
|
-
cwds = await glob(dirs, {
|
|
314
|
-
cwd: baseCwd,
|
|
315
|
-
onlyDirectories: true,
|
|
316
|
-
absolute: true,
|
|
317
|
-
expandDirectories: false
|
|
318
|
-
});
|
|
319
|
-
if (cwds.length === 0) {
|
|
320
|
-
consola.error(`No directories matched: ${dirs.join(", ")}`);
|
|
321
|
-
process.exitCode = 1;
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
} else cwds = [baseCwd];
|
|
325
|
-
let migratedAny = false;
|
|
326
|
-
try {
|
|
327
|
-
for (const dir of cwds) {
|
|
328
|
-
process.chdir(dir);
|
|
329
|
-
const dirLabel = greenBright(dir);
|
|
330
|
-
consola.info(`Processing ${dirLabel}`);
|
|
331
|
-
let migrated = await migratePackageJson(dryRun);
|
|
332
|
-
if (await migrateTsupConfig(dryRun)) migrated = true;
|
|
333
|
-
if (!migrated) {
|
|
334
|
-
consola.warn(`No migrations to apply in ${dirLabel}.`);
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
migratedAny = true;
|
|
338
|
-
}
|
|
339
|
-
} finally {
|
|
340
|
-
process.chdir(baseCwd);
|
|
341
|
-
}
|
|
342
|
-
if (!migratedAny) {
|
|
343
|
-
consola.error("No migration performed.");
|
|
344
|
-
process.exitCode = 1;
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
consola.info("Migration completed. Installing dependencies...");
|
|
348
|
-
if (dryRun) consola.info("[dry-run] would run:", await getCliCommand(parseNi, []));
|
|
349
|
-
else {
|
|
350
|
-
await run(parseNi, [], { cwd: baseCwd });
|
|
351
|
-
consola.success("Dependencies installed.");
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
//#endregion
|
|
356
|
-
export { name as n, version as r, migrate as t };
|
|
299
|
+
export { version as i, migratePackageJson as n, name as r, migrateTsupConfig as t };
|