@reliverse/dler 1.7.90 → 1.7.92

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.
@@ -29,7 +29,7 @@ export default defineCommand({
29
29
  }
30
30
  if (libNames.length === 1) {
31
31
  const argv = process.argv;
32
- const initIndex = argv.findIndex((arg) => arg === "--init");
32
+ const initIndex = argv.indexOf("--init");
33
33
  if (initIndex !== -1 && initIndex + 1 < argv.length) {
34
34
  const additionalArgs = [];
35
35
  for (let i = initIndex + 2; i < argv.length; i++) {
@@ -46,7 +46,7 @@ export default defineCommand({
46
46
  }
47
47
  if (cmdNames.length === 1) {
48
48
  const argv = process.argv;
49
- const initIndex = argv.findIndex((arg) => arg === "--init");
49
+ const initIndex = argv.indexOf("--init");
50
50
  if (initIndex !== -1 && initIndex + 1 < argv.length) {
51
51
  const additionalArgs = [];
52
52
  for (let i = initIndex + 2; i < argv.length; i++) {
@@ -0,0 +1,23 @@
1
+ declare const _default: import("@reliverse/rempts").Command<{
2
+ "to-catalog": {
3
+ type: "boolean";
4
+ description: string;
5
+ };
6
+ "from-catalog": {
7
+ type: "boolean";
8
+ description: string;
9
+ };
10
+ "remove-catalog": {
11
+ type: "boolean";
12
+ description: string;
13
+ };
14
+ "dry-run": {
15
+ type: "boolean";
16
+ description: string;
17
+ };
18
+ interactive: {
19
+ type: "boolean";
20
+ description: string;
21
+ };
22
+ }>;
23
+ export default _default;
@@ -0,0 +1,604 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
+ import { relinka } from "@reliverse/relinka";
4
+ import { defineArgs, defineCommand, multiselectPrompt } from "@reliverse/rempts";
5
+ import { readPackageJSON } from "pkg-types";
6
+ import semver from "semver";
7
+ import { glob } from "tinyglobby";
8
+ import { isCatalogSupported } from "../../../libs/sdk/sdk-impl/utils/pm/pm-catalog.js";
9
+ import { detectPackageManager } from "../../../libs/sdk/sdk-impl/utils/pm/pm-detect.js";
10
+ function isCatalogReference(versionSpec) {
11
+ return versionSpec.startsWith("catalog:");
12
+ }
13
+ function isWorkspaceDependency(versionSpec) {
14
+ return versionSpec.startsWith("workspace:");
15
+ }
16
+ function isNpmAlias(versionSpec) {
17
+ return versionSpec.startsWith("npm:");
18
+ }
19
+ function shouldSkipDependency(versionSpec) {
20
+ return isNpmAlias(versionSpec) || isWorkspaceDependency(versionSpec) || isCatalogReference(versionSpec) || versionSpec.startsWith("git+") || versionSpec.startsWith("file:") || versionSpec.startsWith("link:") || versionSpec.startsWith("http:") || versionSpec.startsWith("https:");
21
+ }
22
+ async function findWorkspacePackageJsons(cwd) {
23
+ const root = await readPackageJSON(cwd);
24
+ const ws = root.workspaces;
25
+ let patterns = [];
26
+ if (Array.isArray(ws)) {
27
+ patterns = ws;
28
+ } else if (ws && Array.isArray(ws.packages)) {
29
+ patterns = ws.packages;
30
+ }
31
+ if (!patterns.length) return [];
32
+ const dirs = await glob(patterns, {
33
+ cwd,
34
+ onlyDirectories: true,
35
+ absolute: true,
36
+ ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**"]
37
+ });
38
+ const pkgJsonPaths = [];
39
+ for (const dir of dirs) {
40
+ const pj = path.join(dir, "package.json");
41
+ if (await fs.pathExists(pj)) pkgJsonPaths.push(pj);
42
+ }
43
+ return pkgJsonPaths;
44
+ }
45
+ async function isMonorepo(cwd) {
46
+ try {
47
+ const root = await readPackageJSON(cwd);
48
+ const ws = root.workspaces;
49
+ if (Array.isArray(ws) && ws.length > 0) {
50
+ return true;
51
+ }
52
+ if (ws && Array.isArray(ws.packages) && ws.packages.length > 0) {
53
+ return true;
54
+ }
55
+ return false;
56
+ } catch {
57
+ return false;
58
+ }
59
+ }
60
+ function extractDependencies(packageJson, packageJsonPath) {
61
+ const dependencies = [];
62
+ const deps = packageJson.dependencies || {};
63
+ for (const [name, version] of Object.entries(deps)) {
64
+ if (typeof version === "string" && !shouldSkipDependency(version)) {
65
+ dependencies.push({
66
+ name,
67
+ version,
68
+ locations: /* @__PURE__ */ new Set(["dependencies"]),
69
+ packageJsonPath
70
+ });
71
+ }
72
+ }
73
+ const devDeps = packageJson.devDependencies || {};
74
+ for (const [name, version] of Object.entries(devDeps)) {
75
+ if (typeof version === "string" && !shouldSkipDependency(version)) {
76
+ const existing = dependencies.find((d) => d.name === name);
77
+ if (existing) {
78
+ existing.locations.add("devDependencies");
79
+ if (existing.locations.has("dependencies")) {
80
+ existing.version = deps[name] || existing.version;
81
+ }
82
+ } else {
83
+ dependencies.push({
84
+ name,
85
+ version,
86
+ locations: /* @__PURE__ */ new Set(["devDependencies"]),
87
+ packageJsonPath
88
+ });
89
+ }
90
+ }
91
+ }
92
+ return dependencies;
93
+ }
94
+ function mergeToCatalog(existingCatalog, newDependencies) {
95
+ const result = {
96
+ added: [],
97
+ bumped: [],
98
+ skipped: []
99
+ };
100
+ for (const dep of newDependencies) {
101
+ const existingVersion = existingCatalog[dep.name];
102
+ if (!existingVersion) {
103
+ existingCatalog[dep.name] = dep.version;
104
+ result.added.push(dep);
105
+ } else {
106
+ try {
107
+ const cleanExisting = existingVersion.replace(/^[\^~]/, "");
108
+ const cleanNew = dep.version.replace(/^[\^~]/, "");
109
+ if (semver.valid(cleanExisting) && semver.valid(cleanNew)) {
110
+ if (semver.gt(cleanNew, cleanExisting)) {
111
+ existingCatalog[dep.name] = dep.version;
112
+ result.bumped.push({ ...dep, oldVersion: existingVersion });
113
+ } else {
114
+ result.skipped.push(dep);
115
+ }
116
+ } else {
117
+ result.skipped.push(dep);
118
+ }
119
+ } catch {
120
+ result.skipped.push(dep);
121
+ }
122
+ }
123
+ }
124
+ return result;
125
+ }
126
+ async function replaceDependenciesWithCatalogRefs(packageJsonPath, dependenciesToReplace) {
127
+ try {
128
+ const packageJsonContent = await fs.readFile(packageJsonPath, "utf8");
129
+ const packageJson = JSON.parse(packageJsonContent);
130
+ let replacedCount = 0;
131
+ for (const dep of dependenciesToReplace) {
132
+ for (const location of dep.locations) {
133
+ if (location === "dependencies" && packageJson.dependencies?.[dep.name]) {
134
+ packageJson.dependencies[dep.name] = "catalog:";
135
+ replacedCount++;
136
+ } else if (location === "devDependencies" && packageJson.devDependencies?.[dep.name]) {
137
+ packageJson.devDependencies[dep.name] = "catalog:";
138
+ replacedCount++;
139
+ }
140
+ }
141
+ }
142
+ if (replacedCount > 0) {
143
+ await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf8");
144
+ }
145
+ return replacedCount;
146
+ } catch (error) {
147
+ relinka(
148
+ "warn",
149
+ `Failed to update ${packageJsonPath}: ${error instanceof Error ? error.message : String(error)}`
150
+ );
151
+ return 0;
152
+ }
153
+ }
154
+ async function restoreCatalogReferences(packageJsonPath, catalog) {
155
+ try {
156
+ const packageJsonContent = await fs.readFile(packageJsonPath, "utf8");
157
+ const packageJson = JSON.parse(packageJsonContent);
158
+ let restoredCount = 0;
159
+ const deps = packageJson.dependencies || {};
160
+ for (const [name, version] of Object.entries(deps)) {
161
+ if (typeof version === "string" && isCatalogReference(version)) {
162
+ const catalogVersion = catalog[name];
163
+ if (catalogVersion && packageJson.dependencies) {
164
+ packageJson.dependencies[name] = catalogVersion;
165
+ restoredCount++;
166
+ } else {
167
+ relinka("warn", `No catalog entry found for dependency: ${name} in ${packageJsonPath}`);
168
+ }
169
+ }
170
+ }
171
+ const devDeps = packageJson.devDependencies || {};
172
+ for (const [name, version] of Object.entries(devDeps)) {
173
+ if (typeof version === "string" && isCatalogReference(version)) {
174
+ const catalogVersion = catalog[name];
175
+ if (catalogVersion && packageJson.devDependencies) {
176
+ packageJson.devDependencies[name] = catalogVersion;
177
+ restoredCount++;
178
+ } else {
179
+ relinka(
180
+ "warn",
181
+ `No catalog entry found for devDependency: ${name} in ${packageJsonPath}`
182
+ );
183
+ }
184
+ }
185
+ }
186
+ if (restoredCount > 0) {
187
+ await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf8");
188
+ }
189
+ return restoredCount;
190
+ } catch (error) {
191
+ relinka(
192
+ "warn",
193
+ `Failed to restore ${packageJsonPath}: ${error instanceof Error ? error.message : String(error)}`
194
+ );
195
+ return 0;
196
+ }
197
+ }
198
+ async function updateRootWithCatalog(rootPackageJsonPath, catalog) {
199
+ try {
200
+ const packageJsonContent = await fs.readFile(rootPackageJsonPath, "utf8");
201
+ const packageJson = JSON.parse(packageJsonContent);
202
+ if (!packageJson.workspaces) {
203
+ packageJson.workspaces = {};
204
+ }
205
+ if (Array.isArray(packageJson.workspaces)) {
206
+ packageJson.workspaces = { packages: packageJson.workspaces };
207
+ }
208
+ packageJson.workspaces.catalog = catalog;
209
+ await fs.writeFile(rootPackageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf8");
210
+ } catch (error) {
211
+ throw new Error(
212
+ `Failed to update root package.json: ${error instanceof Error ? error.message : String(error)}`
213
+ );
214
+ }
215
+ }
216
+ async function removeCatalogFromRoot(rootPackageJsonPath) {
217
+ try {
218
+ const packageJsonContent = await fs.readFile(rootPackageJsonPath, "utf8");
219
+ const packageJson = JSON.parse(packageJsonContent);
220
+ if (packageJson.workspaces && !Array.isArray(packageJson.workspaces) && packageJson.workspaces.catalog) {
221
+ delete packageJson.workspaces.catalog;
222
+ if (Object.keys(packageJson.workspaces).length === 0 || Object.keys(packageJson.workspaces).length === 1 && packageJson.workspaces.packages) {
223
+ if (!packageJson.workspaces.packages) {
224
+ delete packageJson.workspaces;
225
+ }
226
+ }
227
+ }
228
+ if (packageJson.catalog) {
229
+ delete packageJson.catalog;
230
+ }
231
+ await fs.writeFile(rootPackageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf8");
232
+ } catch (error) {
233
+ throw new Error(
234
+ `Failed to remove catalog from root package.json: ${error instanceof Error ? error.message : String(error)}`
235
+ );
236
+ }
237
+ }
238
+ async function migrateToCatalog(rootPath, dryRun = false, interactive = false) {
239
+ const results = [];
240
+ const workspacePaths = await findWorkspacePackageJsons(rootPath);
241
+ if (workspacePaths.length === 0) {
242
+ throw new Error("No workspace packages found. This command requires a monorepo setup.");
243
+ }
244
+ relinka("log", `Found ${workspacePaths.length} workspace packages`);
245
+ const allDependencies = [];
246
+ for (const workspacePath of workspacePaths) {
247
+ try {
248
+ const packageJsonContent = await fs.readFile(workspacePath, "utf8");
249
+ const packageJson = JSON.parse(packageJsonContent);
250
+ const deps = extractDependencies(packageJson, workspacePath);
251
+ allDependencies.push(...deps);
252
+ } catch (error) {
253
+ relinka(
254
+ "warn",
255
+ `Failed to read ${workspacePath}: ${error instanceof Error ? error.message : String(error)}`
256
+ );
257
+ }
258
+ }
259
+ if (allDependencies.length === 0) {
260
+ relinka("log", "No dependencies found to migrate to catalog");
261
+ return results;
262
+ }
263
+ relinka("log", `Found ${allDependencies.length} total dependency entries across workspaces`);
264
+ const rootPackageJsonPath = path.resolve(rootPath, "package.json");
265
+ let existingCatalog = {};
266
+ try {
267
+ const rootPackageJson = await readPackageJSON(rootPath);
268
+ existingCatalog = rootPackageJson.workspaces?.catalog || {};
269
+ } catch (error) {
270
+ relinka(
271
+ "warn",
272
+ `Failed to read root package.json: ${error instanceof Error ? error.message : String(error)}`
273
+ );
274
+ }
275
+ const mergeResult = mergeToCatalog(existingCatalog, allDependencies);
276
+ relinka("log", `Catalog merge summary:`);
277
+ relinka("log", ` - ${mergeResult.added.length} new dependencies added`);
278
+ relinka("log", ` - ${mergeResult.bumped.length} dependencies bumped to newer versions`);
279
+ relinka(
280
+ "log",
281
+ ` - ${mergeResult.skipped.length} dependencies skipped (already up-to-date or incompatible)`
282
+ );
283
+ let dependenciesToMigrate = allDependencies;
284
+ if (interactive && allDependencies.length > 0) {
285
+ const selectedPackages = await multiselectPrompt({
286
+ title: "Select dependencies to migrate to catalog",
287
+ options: [
288
+ { label: "Migrate all dependencies", value: "all" },
289
+ { label: "Cancel migration", value: "cancel" },
290
+ ...Array.from(new Set(allDependencies.map((d) => d.name))).map((name) => ({
291
+ label: name,
292
+ value: name
293
+ }))
294
+ ]
295
+ });
296
+ if (selectedPackages.includes("cancel")) {
297
+ relinka("log", "Migration cancelled");
298
+ return results;
299
+ }
300
+ if (!selectedPackages.includes("all")) {
301
+ dependenciesToMigrate = allDependencies.filter((dep) => selectedPackages.includes(dep.name));
302
+ }
303
+ }
304
+ if (dryRun) {
305
+ relinka("log", "Dry run mode - no changes were made");
306
+ relinka("log", "Would migrate the following dependencies to catalog:");
307
+ const uniqueDeps = Array.from(new Set(dependenciesToMigrate.map((d) => d.name)));
308
+ for (const depName of uniqueDeps) {
309
+ const catalogVersion = existingCatalog[depName];
310
+ relinka("log", ` ${depName}: ${catalogVersion || "new entry"}`);
311
+ }
312
+ return results;
313
+ }
314
+ await updateRootWithCatalog(rootPackageJsonPath, existingCatalog);
315
+ const workspaceResults = /* @__PURE__ */ new Map();
316
+ for (const dep of dependenciesToMigrate) {
317
+ if (!workspaceResults.has(dep.packageJsonPath)) {
318
+ workspaceResults.set(dep.packageJsonPath, []);
319
+ }
320
+ workspaceResults.get(dep.packageJsonPath).push(dep);
321
+ }
322
+ for (const [packagePath, deps] of workspaceResults.entries()) {
323
+ const replacedCount = await replaceDependenciesWithCatalogRefs(packagePath, deps);
324
+ if (replacedCount > 0) {
325
+ relinka("log", `Updated ${replacedCount} dependencies in ${packagePath}`);
326
+ for (const dep of deps) {
327
+ results.push({
328
+ package: dep.name,
329
+ action: "replaced-with-catalog",
330
+ oldVersion: dep.version,
331
+ newVersion: "catalog:",
332
+ location: Array.from(dep.locations).join(", "),
333
+ packageJsonPath: packagePath
334
+ });
335
+ }
336
+ }
337
+ }
338
+ for (const dep of mergeResult.added) {
339
+ results.push({
340
+ package: dep.name,
341
+ action: "added-to-catalog",
342
+ newVersion: dep.version,
343
+ location: "catalog"
344
+ });
345
+ }
346
+ for (const dep of mergeResult.bumped) {
347
+ results.push({
348
+ package: dep.name,
349
+ action: "version-bumped",
350
+ oldVersion: dep.oldVersion,
351
+ newVersion: dep.version,
352
+ location: "catalog"
353
+ });
354
+ }
355
+ return results;
356
+ }
357
+ async function migrateFromCatalog(rootPath, removeCatalog = false, dryRun = false, interactive = false) {
358
+ const results = [];
359
+ const rootPackageJson = await readPackageJSON(rootPath);
360
+ const catalog = rootPackageJson.workspaces?.catalog || {};
361
+ if (Object.keys(catalog).length === 0) {
362
+ relinka("warn", "No workspaces.catalog found in root package.json");
363
+ return results;
364
+ }
365
+ relinka("log", `Found catalog with ${Object.keys(catalog).length} entries`);
366
+ const workspacePaths = await findWorkspacePackageJsons(rootPath);
367
+ if (workspacePaths.length === 0) {
368
+ relinka("warn", "No workspace packages found");
369
+ return results;
370
+ }
371
+ const packagesWithCatalogRefs = [];
372
+ for (const workspacePath of workspacePaths) {
373
+ try {
374
+ const packageJsonContent = await fs.readFile(workspacePath, "utf8");
375
+ const packageJson = JSON.parse(packageJsonContent);
376
+ const catalogRefs = [];
377
+ const deps = packageJson.dependencies || {};
378
+ for (const [name, version] of Object.entries(deps)) {
379
+ if (typeof version === "string" && isCatalogReference(version)) {
380
+ catalogRefs.push(name);
381
+ }
382
+ }
383
+ const devDeps = packageJson.devDependencies || {};
384
+ for (const [name, version] of Object.entries(devDeps)) {
385
+ if (typeof version === "string" && isCatalogReference(version)) {
386
+ catalogRefs.push(name);
387
+ }
388
+ }
389
+ if (catalogRefs.length > 0) {
390
+ packagesWithCatalogRefs.push({
391
+ path: workspacePath,
392
+ catalogRefs: [...new Set(catalogRefs)]
393
+ // Remove duplicates
394
+ });
395
+ }
396
+ } catch (error) {
397
+ relinka(
398
+ "warn",
399
+ `Failed to read ${workspacePath}: ${error instanceof Error ? error.message : String(error)}`
400
+ );
401
+ }
402
+ }
403
+ if (packagesWithCatalogRefs.length === 0) {
404
+ relinka("log", "No catalog references found in workspace packages");
405
+ if (removeCatalog && !dryRun) {
406
+ const rootPackageJsonPath = path.resolve(rootPath, "package.json");
407
+ await removeCatalogFromRoot(rootPackageJsonPath);
408
+ relinka("log", "Removed catalog from root package.json");
409
+ }
410
+ return results;
411
+ }
412
+ const totalCatalogRefs = packagesWithCatalogRefs.reduce(
413
+ (sum, pkg) => sum + pkg.catalogRefs.length,
414
+ 0
415
+ );
416
+ relinka(
417
+ "log",
418
+ `Found ${totalCatalogRefs} catalog references across ${packagesWithCatalogRefs.length} packages`
419
+ );
420
+ let packagesToProcess = packagesWithCatalogRefs;
421
+ if (interactive && packagesWithCatalogRefs.length > 0) {
422
+ const allCatalogRefs = Array.from(
423
+ new Set(packagesWithCatalogRefs.flatMap((p) => p.catalogRefs))
424
+ );
425
+ const selectedPackages = await multiselectPrompt({
426
+ title: "Select dependencies to restore from catalog",
427
+ options: [
428
+ { label: "Restore all catalog references", value: "all" },
429
+ { label: "Cancel restoration", value: "cancel" },
430
+ ...allCatalogRefs.map((name) => ({
431
+ label: `${name} (${catalog[name] || "missing in catalog"})`,
432
+ value: name,
433
+ disabled: !catalog[name]
434
+ }))
435
+ ]
436
+ });
437
+ if (selectedPackages.includes("cancel")) {
438
+ relinka("log", "Restoration cancelled");
439
+ return results;
440
+ }
441
+ if (!selectedPackages.includes("all")) {
442
+ packagesToProcess = packagesWithCatalogRefs.map((pkg) => ({
443
+ ...pkg,
444
+ catalogRefs: pkg.catalogRefs.filter((ref) => selectedPackages.includes(ref))
445
+ })).filter((pkg) => pkg.catalogRefs.length > 0);
446
+ }
447
+ }
448
+ if (dryRun) {
449
+ relinka("log", "Dry run mode - no changes were made");
450
+ relinka("log", "Would restore the following catalog references:");
451
+ for (const pkg of packagesToProcess) {
452
+ relinka("log", ` ${pkg.path}:`);
453
+ for (const ref of pkg.catalogRefs) {
454
+ const catalogVersion = catalog[ref];
455
+ relinka("log", ` ${ref}: catalog: \u2192 ${catalogVersion || "MISSING"}`);
456
+ }
457
+ }
458
+ if (removeCatalog) {
459
+ relinka("log", "Would also remove workspaces.catalog from root package.json");
460
+ }
461
+ return results;
462
+ }
463
+ for (const pkg of packagesToProcess) {
464
+ const restoredCount = await restoreCatalogReferences(pkg.path, catalog);
465
+ if (restoredCount > 0) {
466
+ relinka("log", `Restored ${restoredCount} catalog references in ${pkg.path}`);
467
+ for (const ref of pkg.catalogRefs) {
468
+ if (catalog[ref]) {
469
+ results.push({
470
+ package: ref,
471
+ action: "restored-from-catalog",
472
+ oldVersion: "catalog:",
473
+ newVersion: catalog[ref],
474
+ location: "dependencies/devDependencies",
475
+ packageJsonPath: pkg.path
476
+ });
477
+ }
478
+ }
479
+ }
480
+ }
481
+ if (removeCatalog) {
482
+ const rootPackageJsonPath = path.resolve(rootPath, "package.json");
483
+ await removeCatalogFromRoot(rootPackageJsonPath);
484
+ relinka("log", "Removed workspaces.catalog from root package.json");
485
+ }
486
+ return results;
487
+ }
488
+ function displayMigrationResults(results) {
489
+ if (results.length === 0) {
490
+ relinka("log", "No changes were made");
491
+ return;
492
+ }
493
+ const byAction = results.reduce(
494
+ (acc, result) => {
495
+ if (!acc[result.action]) acc[result.action] = [];
496
+ acc[result.action].push(result);
497
+ return acc;
498
+ },
499
+ {}
500
+ );
501
+ for (const [action, actionResults] of Object.entries(byAction)) {
502
+ relinka("log", `
503
+ ${action.replace(/-/g, " ")} (${actionResults.length}):`);
504
+ for (const result of actionResults) {
505
+ let message = ` ${result.package}`;
506
+ if (result.oldVersion && result.newVersion) {
507
+ message += `: ${result.oldVersion} \u2192 ${result.newVersion}`;
508
+ } else if (result.newVersion) {
509
+ message += `: ${result.newVersion}`;
510
+ }
511
+ if (result.packageJsonPath) {
512
+ message += ` (${result.packageJsonPath})`;
513
+ }
514
+ relinka("log", message);
515
+ }
516
+ }
517
+ relinka("success", `Migration completed: ${results.length} changes made`);
518
+ }
519
+ export default defineCommand({
520
+ meta: {
521
+ name: "migrate",
522
+ description: "Migrate dependencies between workspace packages and workspaces.catalog"
523
+ },
524
+ args: defineArgs({
525
+ "to-catalog": {
526
+ type: "boolean",
527
+ description: "Migrate workspace dependencies to workspaces.catalog and replace with catalog references"
528
+ },
529
+ "from-catalog": {
530
+ type: "boolean",
531
+ description: "Restore catalog references to actual versions from workspaces.catalog"
532
+ },
533
+ "remove-catalog": {
534
+ type: "boolean",
535
+ description: "Remove workspaces.catalog from root package.json after restoring (only with --from-catalog)"
536
+ },
537
+ "dry-run": {
538
+ type: "boolean",
539
+ description: "Preview changes without making modifications"
540
+ },
541
+ interactive: {
542
+ type: "boolean",
543
+ description: "Interactively select dependencies to migrate"
544
+ }
545
+ }),
546
+ async run({ args }) {
547
+ try {
548
+ if (!args["to-catalog"] && !args["from-catalog"]) {
549
+ relinka("error", "Must specify either --to-catalog or --from-catalog");
550
+ return process.exit(1);
551
+ }
552
+ if (args["to-catalog"] && args["from-catalog"]) {
553
+ relinka("error", "Cannot specify both --to-catalog and --from-catalog");
554
+ return process.exit(1);
555
+ }
556
+ if (args["remove-catalog"] && !args["from-catalog"]) {
557
+ relinka("error", "--remove-catalog can only be used with --from-catalog");
558
+ return process.exit(1);
559
+ }
560
+ const cwd = process.cwd();
561
+ const packageJsonPath = path.resolve(cwd, "package.json");
562
+ if (!await fs.pathExists(packageJsonPath)) {
563
+ relinka("error", "No package.json found in current directory");
564
+ return process.exit(1);
565
+ }
566
+ if (!await isMonorepo(cwd)) {
567
+ relinka("error", "This command requires a monorepo with workspace configuration");
568
+ return process.exit(1);
569
+ }
570
+ const packageManager = await detectPackageManager(cwd);
571
+ if (!packageManager) {
572
+ relinka("warn", "Could not detect package manager");
573
+ } else if (!isCatalogSupported(packageManager)) {
574
+ relinka(
575
+ "warn",
576
+ `Catalogs may not be fully supported by ${packageManager.name}. Only Bun has full catalog support.`
577
+ );
578
+ }
579
+ let results = [];
580
+ if (args["to-catalog"]) {
581
+ relinka("log", "Migrating workspace dependencies to catalog...");
582
+ results = await migrateToCatalog(cwd, !!args["dry-run"], !!args.interactive);
583
+ } else if (args["from-catalog"]) {
584
+ relinka("log", "Restoring dependencies from catalog...");
585
+ results = await migrateFromCatalog(
586
+ cwd,
587
+ !!args["remove-catalog"],
588
+ !!args["dry-run"],
589
+ !!args.interactive
590
+ );
591
+ }
592
+ displayMigrationResults(results);
593
+ if (args["dry-run"]) {
594
+ relinka("info", "This was a dry run - no actual changes were made");
595
+ }
596
+ } catch (error) {
597
+ relinka(
598
+ "error",
599
+ `Migration failed: ${error instanceof Error ? error.message : String(error)}`
600
+ );
601
+ process.exit(1);
602
+ }
603
+ }
604
+ });
package/bin/cli.js CHANGED
@@ -9,7 +9,7 @@ let isDev = process.env.DLER_DEV_MODE === "true";
9
9
  const main = defineCommand({
10
10
  meta: {
11
11
  name: "dler",
12
- version: "1.7.90",
12
+ version: "1.7.92",
13
13
  description: `Displays dler's command menu.
14
14
  To see ALL available commands and arguments, run: 'dler --help' (or 'dler <command> --help')
15
15
  Available menu commands: ${MENU_CMDS.join(", ")}`
@@ -1,5 +1,5 @@
1
1
  import { endPrompt, startPrompt } from "@reliverse/rempts";
2
- const version = "1.7.90";
2
+ const version = "1.7.92";
3
3
  export async function showStartPrompt(isDev) {
4
4
  await startPrompt({
5
5
  titleColor: "inverse",
package/package.json CHANGED
@@ -52,7 +52,7 @@
52
52
  "license": "MIT",
53
53
  "name": "@reliverse/dler",
54
54
  "type": "module",
55
- "version": "1.7.90",
55
+ "version": "1.7.92",
56
56
  "keywords": [
57
57
  "reliverse",
58
58
  "cli",