@reliverse/dler 1.5.6 → 1.5.7

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/README.md CHANGED
@@ -127,7 +127,7 @@ if you run just `dler` — it will display a list of plugins which you can launc
127
127
 
128
128
  ## **available plugins**
129
129
 
130
- [agg](#1-agg), [build](#2-build), [conv](#3-conv), [deps](#4-deps), [inject](#5-inject), [libs](#6-libs), [merge](#7-merge), [mono](#8-mono), [pub](#9-pub), [relifso](#10-relifso), [relinka](#11-relinka), [rempts](#12-rempts), [spell](#13-spell), [split](#14-split).
130
+ [agg](#1-agg), [build](#2-build), [conv](#3-conv), [deps](#4-deps), [inject](#5-inject), [libs](#6-libs), [merge](#7-merge), [migrate](#8-migrate), [mono](#9-mono), [pub](#10-pub), [relifso](#11-relifso), [relinka](#12-relinka), [rempts](#13-rempts), [spell](#14-spell), [split](#15-split).
131
131
 
132
132
  ### 1. `agg`
133
133
 
@@ -253,11 +253,61 @@ libslist: {
253
253
 
254
254
  not yet documented.
255
255
 
256
- ### 8. `mono`
256
+ ### 8. `migrate`
257
+
258
+ helps migrate between different libraries and module resolution strategies. currently supports:
259
+
260
+ - `pathe-to-pathkit`: migrate from pathe to pathkit library
261
+ - `pathkit-to-pathe`: migrate from pathkit to pathe library
262
+ - `module-resolution`: migrate between module resolution strategies
263
+
264
+ **module resolution targets:**
265
+
266
+ - `nodenext`: adds `.js` extensions to imports and updates tsconfig
267
+ - `bundler`: removes extensions from imports and updates tsconfig
268
+
269
+ **usage examples:**
270
+
271
+ ```bash
272
+ # Migrate from pathe to pathkit
273
+ dler migrate --lib pathe-to-pathkit
274
+
275
+ # Migrate to nodenext module resolution
276
+ dler migrate --lib module-resolution --target nodenext
277
+
278
+ # Migrate to bundler module resolution
279
+ dler migrate --lib module-resolution --target bundler
280
+
281
+ # Preview changes without applying them
282
+ dler migrate --lib module-resolution --target nodenext --dryRun
283
+ ```
284
+
285
+ **what it does:**
286
+
287
+ - updates import statements in your code
288
+ - modifies tsconfig.json settings
289
+ - updates package.json type field
290
+ - provides a dry run option to preview changes
291
+ - handles both relative and alias imports
292
+ - supports both .ts and .tsx files
293
+
294
+ **next steps after migration:**
295
+
296
+ - for pathe-to-pathkit:
297
+ 1. run 'bun install' to install @reliverse/pathkit
298
+ 2. test your application
299
+ 3. consider using advanced pathkit features
300
+
301
+ - for module-resolution:
302
+ 1. test your application
303
+ 2. ensure your build tools support the new module resolution
304
+ 3. review any warnings in the migration output
305
+
306
+ ### 9. `mono`
257
307
 
258
308
  not yet documented.
259
309
 
260
- ### 9. `pub`
310
+ ### 10. `pub`
261
311
 
262
312
  pub command is separated for its own build-in plugin as well.
263
313
 
@@ -267,13 +317,13 @@ it already calls build command by itself, so you don't need to run `dler build`
267
317
  dler pub ...
268
318
  ```
269
319
 
270
- ### 10. `relifso`
320
+ ### 11. `relifso`
271
321
 
272
322
  ```bash
273
323
  dler relifso init ...
274
324
  ```
275
325
 
276
- ### 11. `relinka`
326
+ ### 12. `relinka`
277
327
 
278
328
  @reliverse/relinka's best friend. learn more in its [docs](https://github.com/reliverse/relinka).
279
329
 
@@ -281,7 +331,7 @@ dler relifso init ...
281
331
  dler relinka --console-to-relinka
282
332
  ```
283
333
 
284
- ### 12. `rempts`
334
+ ### 13. `rempts`
285
335
 
286
336
  @reliverse/rempts's best friend. learn more in its [docs](https://github.com/reliverse/rempts).
287
337
 
@@ -290,7 +340,7 @@ dler rempts init --cmd my-cmd-1
290
340
  dler rempts init --cmds
291
341
  ```
292
342
 
293
- ### 13. `spell`
343
+ ### 14. `spell`
294
344
 
295
345
  **available spell types:**
296
346
 
@@ -359,7 +409,7 @@ files: [] // means all files
359
409
 
360
410
  p.s. [see how rse cli uses hooked=true](https://github.com/reliverse/rse/blob/main/src/postbuild.ts)
361
411
 
362
- ### 14. `split`
412
+ ### 15. `split`
363
413
 
364
414
  splits your code/text file into multiple files.
365
415
 
package/bin/app/cmds.d.ts CHANGED
@@ -195,3 +195,19 @@ export declare function cmdRelifsoRename(): Promise<import("@reliverse/rempts").
195
195
  default: false;
196
196
  };
197
197
  }>>;
198
+ export declare function cmdMigrate(): Promise<import("@reliverse/rempts").Command<{
199
+ lib: {
200
+ type: "string";
201
+ description: string;
202
+ };
203
+ target: {
204
+ type: "string";
205
+ description: string;
206
+ default: string;
207
+ };
208
+ dryRun: {
209
+ type: "boolean";
210
+ description: string;
211
+ default: false;
212
+ };
213
+ }>>;
package/bin/app/cmds.js CHANGED
@@ -16,3 +16,6 @@ export async function cmdPub() {
16
16
  export async function cmdRelifsoRename() {
17
17
  return (await import("./relifso/rename/cmd.js")).default;
18
18
  }
19
+ export async function cmdMigrate() {
20
+ return (await import("./migrate/cmd.js")).default;
21
+ }
@@ -1,2 +1,2 @@
1
- import type { DependencyResult, FinderOptions } from "./deps-types.js";
1
+ import type { DependencyResult, FinderOptions } from "./deps-types";
2
2
  export declare const analyzeDependencies: (options: FinderOptions) => Promise<DependencyResult>;
@@ -1,4 +1,4 @@
1
- import type { PackageJson } from "./deps-types.js";
1
+ import type { PackageJson } from "./deps-types";
2
2
  export declare const findSourceFiles: (directory: string, ignorePatterns: string[]) => Promise<string[]>;
3
3
  export declare const readFile: (filePath: string) => Promise<string>;
4
4
  export declare const readPackageJson: (directory: string) => Promise<PackageJson>;
@@ -1,2 +1,2 @@
1
- import type { DependencyResult, FinderOptions } from "./deps-types.js";
1
+ import type { DependencyResult, FinderOptions } from "./deps-types";
2
2
  export declare const formatOutput: (result: DependencyResult, options: FinderOptions) => string;
@@ -1,4 +1,4 @@
1
- import type { PackageJson } from "./deps-types.js";
1
+ import type { PackageJson } from "./deps-types";
2
2
  export declare const extractPackageNames: (fileContent: string) => Set<string>;
3
3
  export declare const normalizePackageName: (importPath: string) => string | null;
4
4
  export declare const getListedDependencies: (packageJson: PackageJson) => Set<string>;
@@ -3,6 +3,11 @@ declare const _default: import("@reliverse/rempts").Command<{
3
3
  type: "string";
4
4
  description: string;
5
5
  };
6
+ target: {
7
+ type: "string";
8
+ description: string;
9
+ default: string;
10
+ };
6
11
  dryRun: {
7
12
  type: "boolean";
8
13
  description: string;
@@ -3,6 +3,7 @@ import {
3
3
  migratePatheToPathkit,
4
4
  migratePathkitToPathe
5
5
  } from "./codemods/lib-pathe-pathkit.js";
6
+ import { migrateModuleResolution } from "./codemods/ts-module-resolution.js";
6
7
  export default defineCommand({
7
8
  meta: {
8
9
  name: "migrate",
@@ -12,7 +13,12 @@ export default defineCommand({
12
13
  args: defineArgs({
13
14
  lib: {
14
15
  type: "string",
15
- description: "The migration to perform (pathe-to-pathkit | pathkit-to-pathe)"
16
+ description: "The migration to perform (pathe-to-pathkit | pathkit-to-pathe | module-resolution)"
17
+ },
18
+ target: {
19
+ type: "string",
20
+ description: "Target for module resolution migration (nodenext | bundler)",
21
+ default: "nodenext"
16
22
  },
17
23
  dryRun: {
18
24
  type: "boolean",
@@ -28,11 +34,25 @@ export default defineCommand({
28
34
  } else if (args.lib === "pathkit-to-pathe") {
29
35
  console.log("Migrating from pathkit to pathe...");
30
36
  results = await migratePathkitToPathe(args.dryRun);
37
+ } else if (args.lib === "module-resolution") {
38
+ if (!["nodenext", "bundler"].includes(args.target)) {
39
+ console.error(`Invalid target: ${args.target}`);
40
+ console.log("Available targets:");
41
+ console.log(" - nodenext");
42
+ console.log(" - bundler");
43
+ return;
44
+ }
45
+ console.log(`Migrating to ${args.target} module resolution...`);
46
+ results = await migrateModuleResolution(
47
+ args.target,
48
+ args.dryRun
49
+ );
31
50
  } else {
32
51
  console.error(`Unknown migration: ${args.lib}`);
33
52
  console.log("Available migrations:");
34
53
  console.log(" - pathe-to-pathkit");
35
54
  console.log(" - pathkit-to-pathe");
55
+ console.log(" - module-resolution");
36
56
  return;
37
57
  }
38
58
  console.log("\nMigration Results:");
@@ -80,12 +100,21 @@ Summary: ${successCount} files updated, ${errorCount} errors, ${warningCount} wa
80
100
  "3. \u26A0\uFE0F Review files with warnings - they may need manual updates"
81
101
  );
82
102
  }
83
- } else {
84
- console.error(`Unknown migration: ${args.lib}`);
85
- console.log("Available migrations:");
86
- console.log(" - pathe-to-pathkit");
87
- console.log(" - pathkit-to-pathe");
88
- return;
103
+ } else if (args.lib === "module-resolution") {
104
+ console.log("Next steps:");
105
+ console.log("1. Test your application");
106
+ if (args.target === "nodenext") {
107
+ console.log(
108
+ "2. Ensure your build tools support .js extensions in imports"
109
+ );
110
+ } else if (args.target === "bundler") {
111
+ console.log("2. Ensure your bundler is configured correctly");
112
+ }
113
+ if (warningCount > 0) {
114
+ console.log(
115
+ "3. \u26A0\uFE0F Review files with warnings - they may need manual updates"
116
+ );
117
+ }
89
118
  }
90
119
  }
91
120
  }
@@ -151,7 +151,7 @@ async function updateImportExtensions(targetResolution, dryRun = false) {
151
151
  const content = await readFile(file, "utf-8");
152
152
  const analysis = getFileImportsExports(content, {
153
153
  kind: "import",
154
- pathTypes: ["relative", "absolute"]
154
+ pathTypes: ["relative", "absolute", "alias"]
155
155
  });
156
156
  if (analysis.length === 0) continue;
157
157
  let modified = content;
@@ -159,7 +159,7 @@ async function updateImportExtensions(targetResolution, dryRun = false) {
159
159
  let hasChanges = false;
160
160
  for (const imp of analysis) {
161
161
  if (!imp.source) continue;
162
- const isRelativeOrAbsolute = imp.pathType === "relative" || imp.pathType === "absolute";
162
+ const isRelativeOrAbsolute = imp.pathType === "relative" || imp.pathType === "absolute" || imp.pathType === "alias";
163
163
  if (!isRelativeOrAbsolute) continue;
164
164
  if (targetResolution === "nodenext") {
165
165
  if (imp.source.endsWith(".ts") || imp.source.endsWith(".tsx")) {
@@ -1,4 +1,4 @@
1
- import type { FileType, InitFileRequest, InitFileResult, ReinitUserConfig } from "./init-types.js";
1
+ import type { FileType, InitFileRequest, InitFileResult, ReinitUserConfig } from "./init-types";
2
2
  /**
3
3
  * Creates a file from scratch, including parent directories,
4
4
  * basing the file content on the fileType.
@@ -1,4 +1,4 @@
1
- import type { DEST_FILE_EXISTS_BEHAVIOURS, FILE_TYPES, INIT_BEHAVIOURS } from "./init-const.js";
1
+ import type { DEST_FILE_EXISTS_BEHAVIOURS, FILE_TYPES, INIT_BEHAVIOURS } from "./init-const";
2
2
  export type FileType = (typeof FILE_TYPES)[number]["type"];
3
3
  export type InitBehaviour = (typeof INIT_BEHAVIOURS)[number];
4
4
  export type DestFileExistsBehaviour = (typeof DEST_FILE_EXISTS_BEHAVIOURS)[number];
@@ -71,7 +71,7 @@ function generateExports(cmdDirs) {
71
71
  const imports = cmdDirs.map((dir) => {
72
72
  const funcName = `getCmd${dir.split(/[/\\]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}`;
73
73
  return `export async function ${funcName}() {
74
- return (await import("./${dir}/cmd.js")).default;
74
+ return (await import("./${dir}/cmd")).default;
75
75
  }`;
76
76
  });
77
77
  return `// Generated command exports - DO NOT EDIT
package/bin/init/info.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { endPrompt, startPrompt } from "@reliverse/rempts";
2
- const version = "1.5.6";
2
+ const version = "1.5.7";
3
3
  export async function showStartPrompt(isDev) {
4
4
  await startPrompt({
5
5
  titleColor: "inverse",
@@ -11,11 +11,7 @@ import { esbuild } from "./plugins/esbuild.js";
11
11
  import { JSONPlugin } from "./plugins/json.js";
12
12
  import { rawPlugin } from "./plugins/raw.js";
13
13
  import { shebangPlugin } from "./plugins/shebang.js";
14
- import {
15
- DEFAULT_EXTENSIONS,
16
- getChunkFilename,
17
- resolveAliases
18
- } from "./utils.js";
14
+ import { DEFAULT_EXTENSIONS, getChunkFilename, resolveAliases } from "./utils.js";
19
15
  const replaceModule = await import("@rollup/plugin-replace");
20
16
  const replace = replaceModule.default || replaceModule;
21
17
  const aliasModule = await import("@rollup/plugin-alias");
@@ -1,11 +1,6 @@
1
1
  import { resolve } from "@reliverse/pathkit";
2
2
  import { existsSync } from "node:fs";
3
- import {
4
- arrayIncludes,
5
- extractExportFilenames,
6
- getpkg,
7
- warn
8
- } from "./utils.js";
3
+ import { arrayIncludes, extractExportFilenames, getpkg, warn } from "./utils.js";
9
4
  export function validateDependencies(ctx) {
10
5
  const usedDependencies = /* @__PURE__ */ new Set();
11
6
  const unusedDependencies = new Set(
@@ -1,4 +1,4 @@
1
- import type { Spell, SpellResult } from "./spell-types.js";
1
+ import type { Spell, SpellResult } from "./spell-types";
2
2
  export declare const replaceLineExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
3
3
  export declare const renameFileExecutor: (spell: Spell, filePath: string) => Promise<SpellResult>;
4
4
  export declare const removeCommentExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
@@ -1,4 +1,4 @@
1
- import type { Spell, SpellExecutionOptions, SpellResult } from "./spell-types.js";
1
+ import type { Spell, SpellExecutionOptions, SpellResult } from "./spell-types";
2
2
  export declare const executeSpell: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
3
3
  export declare const processFile: (filePath: string, options?: SpellExecutionOptions) => Promise<SpellResult[]>;
4
4
  export declare const spells: (options?: SpellExecutionOptions) => Promise<SpellResult[]>;
@@ -1,4 +1,4 @@
1
- import type { Spell, SpellParams } from "./spell-types.js";
1
+ import type { Spell, SpellParams } from "./spell-types";
2
2
  export declare const parseParams: (paramsStr: string | undefined) => SpellParams;
3
3
  export declare const parseSpellFromComment: (line: string, lineNumber: number, fileName: string) => Spell | null;
4
4
  export declare const extractSpellsFromFile: (filePath: string, content: string) => Promise<Spell[]>;
package/package.json CHANGED
@@ -41,7 +41,7 @@
41
41
  "license": "MIT",
42
42
  "name": "@reliverse/dler",
43
43
  "type": "module",
44
- "version": "1.5.6",
44
+ "version": "1.5.7",
45
45
  "keywords": [
46
46
  "reliverse",
47
47
  "cli",