@reliverse/dler 1.5.6 → 1.6.0

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
 
@@ -242,9 +242,9 @@ libslist: {
242
242
  - `// dler-replace-line` tells dler to grab the contents of `../../types.ts` and inject them directly in place of your command definition.
243
243
 
244
244
  ```ts
245
- export * from "../../types.js"; // dler-replace-line
245
+ export * from "../../types"; // dler-replace-line
246
246
  // or:
247
- export type { specificTypeName1, specificTypeName2 } from "../../types.js"; // dler-replace-line
247
+ export type { specificTypeName1, specificTypeName2 } from "../../types"; // dler-replace-line
248
248
  ```
249
249
 
250
250
  - more magic commands coming soon...
@@ -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
 
@@ -324,7 +374,7 @@ params are optional and comma-separated.
324
374
 
325
375
  **usage examples:**
326
376
 
327
- - `export * from "../../types.js"; // dler-replace-line` — injects file contents at this line (hooked=true by default)
377
+ - `export * from "../../types"; // dler-replace-line` — injects file contents at this line (hooked=true by default)
328
378
  - `// @ts-expect-error dler-remove-comment` — removes just this comment (hooked=true by default)
329
379
  - `// dler-remove-line` — removes this line (hooked=true by default)
330
380
  - `// dler-remove-file` — deletes this file (hooked=true by default)
@@ -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.6.0";
3
3
  export async function showStartPrompt(isDev) {
4
4
  await startPrompt({
5
5
  titleColor: "inverse",
package/bin/init/init.js CHANGED
@@ -161,6 +161,7 @@ export default defineConfig({
161
161
  },
162
162
  },
163
163
  // Build setup
164
+ transpileFailOnWarn: ${DEFAULT_CONFIG.transpileFailOnWarn},
164
165
  transpileEsbuild: "${DEFAULT_CONFIG.transpileEsbuild}",
165
166
  transpileFormat: "${DEFAULT_CONFIG.transpileFormat}",
166
167
  transpileMinify: ${DEFAULT_CONFIG.transpileMinify},
@@ -170,6 +171,26 @@ export default defineConfig({
170
171
  transpileStub: ${DEFAULT_CONFIG.transpileStub},
171
172
  transpileTarget: "${DEFAULT_CONFIG.transpileTarget}",
172
173
  transpileWatch: ${DEFAULT_CONFIG.transpileWatch},
174
+ transpileAlias: {},
175
+ transpileEntries: [],
176
+ transpileExternals: [],
177
+ transpileClean: true,
178
+ transpileParallel: false,
179
+ transpileReplace: {},
180
+ transpileRollup: {
181
+ alias: {},
182
+ commonjs: {},
183
+ dts: {},
184
+ esbuild: {},
185
+ json: {},
186
+ replace: {},
187
+ resolve: {},
188
+ },
189
+ transpileShowOutLog: false,
190
+ transpileStubOptions: {
191
+ jiti: {},
192
+ },
193
+ transpileWatchOptions: undefined,
173
194
  });
174
195
  `;
175
196
  return configTemplate;
@@ -55,6 +55,7 @@ export const DEFAULT_CONFIG = {
55
55
  }
56
56
  },
57
57
  // Build setup
58
+ transpileFailOnWarn: false,
58
59
  transpileEsbuild: "es2023",
59
60
  transpileFormat: "esm",
60
61
  transpileMinify: true,
@@ -601,7 +601,7 @@ async function library_performCommonBuildSteps(params) {
601
601
  await convertImportsAliasToRelative({
602
602
  targetDir: outDirBin,
603
603
  aliasToReplace: ALIAS_PREFIX_TO_CONVERT,
604
- pathExtFilter: "js"
604
+ pathExtFilter: "js-ts-none"
605
605
  });
606
606
  if (isJsr) {
607
607
  relinka(
@@ -610,7 +610,7 @@ async function library_performCommonBuildSteps(params) {
610
610
  );
611
611
  await convertImportsExt({
612
612
  targetDir: outDirBin,
613
- extFrom: "js",
613
+ extFrom: "none",
614
614
  extTo: "ts"
615
615
  });
616
616
  }
@@ -378,7 +378,7 @@ async function regular_performCommonBuildSteps({
378
378
  await convertImportsAliasToRelative({
379
379
  targetDir: outDirBin,
380
380
  aliasToReplace: ALIAS_PREFIX_TO_CONVERT,
381
- pathExtFilter: "js"
381
+ pathExtFilter: "js-ts-none"
382
382
  });
383
383
  if (isJsr) {
384
384
  relinka(
@@ -387,7 +387,7 @@ async function regular_performCommonBuildSteps({
387
387
  );
388
388
  await convertImportsExt({
389
389
  targetDir: outDirBin,
390
- extFrom: "js",
390
+ extFrom: "none",
391
391
  extTo: "ts"
392
392
  });
393
393
  }
@@ -80,7 +80,7 @@ async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _tran
80
80
  ...Module.builtinModules,
81
81
  ...Module.builtinModules.map((m) => `node:${m}`)
82
82
  ],
83
- failOnWarn: true,
83
+ transpileFailOnWarn: true,
84
84
  name: (pkg?.name || "").split("/").pop() || "default",
85
85
  outDir,
86
86
  parallel: false,
@@ -312,10 +312,10 @@ ${entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.b
312
312
  `Build is done with some warnings:
313
313
  ${[...ctx.warnings].map((msg) => `- ${msg}`).join("\n")}`
314
314
  );
315
- if (ctx.options.failOnWarn) {
315
+ if (ctx.options.transpileFailOnWarn) {
316
316
  relinka(
317
317
  "error",
318
- "Exiting with code (1). You can change this behavior by setting `failOnWarn: false` ."
318
+ "Exiting with code (1). You can change this behavior by setting `transpileFailOnWarn: false` ."
319
319
  );
320
320
  process.exit(1);
321
321
  }
@@ -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>;
@@ -8,8 +8,3 @@ export declare const copyFileExecutor: (spell: Spell, filePath: string) => Promi
8
8
  export declare const moveFileExecutor: (spell: Spell, filePath: string) => Promise<SpellResult>;
9
9
  export declare const transformContentExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
10
10
  export declare const insertAtExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
11
- export declare const replaceRangeExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
12
- export declare const transformLineExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
13
- export declare const insertBeforeExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
14
- export declare const insertAfterExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
15
- export declare const conditionalExecuteExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
@@ -1,6 +1,5 @@
1
1
  import path from "@reliverse/pathkit";
2
2
  import * as fs from "./spell-filesystem.js";
3
- import { executeSpell } from "./spell-mod.js";
4
3
  export const replaceLineExecutor = async (spell, filePath, content) => {
5
4
  if (!spell.lineNumber) {
6
5
  return {
@@ -236,38 +235,6 @@ export const transformContentExecutor = async (spell, filePath, content) => {
236
235
  }
237
236
  );
238
237
  break;
239
- case "update-dependencies":
240
- if (filePath.endsWith("package.json")) {
241
- const pkg = JSON.parse(content);
242
- let newDeps = { ...pkg.dependencies };
243
- if (newDeps.pathe) {
244
- const { ...rest } = newDeps;
245
- newDeps = rest;
246
- }
247
- let newDevDeps = { ...pkg.devDependencies };
248
- if (newDevDeps.pathe) {
249
- const { ...rest } = newDevDeps;
250
- newDevDeps = rest;
251
- }
252
- newDeps["@reliverse/pathkit"] = "latest";
253
- const newPkg = {
254
- ...pkg,
255
- dependencies: newDeps,
256
- devDependencies: newDevDeps
257
- };
258
- newContent = JSON.stringify(newPkg, null, 2);
259
- } else {
260
- return {
261
- spell,
262
- file: filePath,
263
- success: false,
264
- message: "update-dependencies can only be used on package.json"
265
- };
266
- }
267
- break;
268
- case "update-imports":
269
- newContent = content.replace(/from\s+['"]pathe['"]/g, 'from "@reliverse/pathkit"').replace(/from\s+['"]@unjs\/pathe['"]/g, 'from "@reliverse/pathkit"');
270
- break;
271
238
  default:
272
239
  return {
273
240
  spell,
@@ -338,257 +305,3 @@ export const insertAtExecutor = async (spell, filePath, content) => {
338
305
  };
339
306
  }
340
307
  };
341
- export const replaceRangeExecutor = async (spell, filePath, content) => {
342
- if (!spell.lineNumber || !spell.params.startLine || !spell.params.endLine) {
343
- return {
344
- spell,
345
- file: filePath,
346
- success: false,
347
- message: "Line numbers not provided"
348
- };
349
- }
350
- if (!spell.value) {
351
- return {
352
- spell,
353
- file: filePath,
354
- success: false,
355
- message: "Target file not specified"
356
- };
357
- }
358
- const includeFilePath = path.resolve(path.dirname(filePath), spell.value);
359
- try {
360
- const includeContent = await fs.readFile(includeFilePath);
361
- const lines = content.split("\n");
362
- const start = spell.params.startLine - 1;
363
- const end = spell.params.endLine;
364
- const originalLines = lines.slice(start, end);
365
- lines.splice(start, end - start, ...includeContent.trim().split("\n"));
366
- const newContent = lines.join("\n");
367
- await fs.writeFile(filePath, newContent);
368
- return {
369
- spell,
370
- file: filePath,
371
- success: true,
372
- message: `Lines ${spell.params.startLine}-${spell.params.endLine} replaced with content from ${includeFilePath}`,
373
- changes: {
374
- before: originalLines.join("\n"),
375
- after: includeContent.trim()
376
- },
377
- details: {
378
- linesAffected: Array.from(
379
- { length: end - start },
380
- (_, i) => start + i + 1
381
- )
382
- }
383
- };
384
- } catch (error) {
385
- return {
386
- spell,
387
- file: filePath,
388
- success: false,
389
- message: `Failed to replace range: ${error}`
390
- };
391
- }
392
- };
393
- export const transformLineExecutor = async (spell, filePath, content) => {
394
- if (!spell.lineNumber) {
395
- return {
396
- spell,
397
- file: filePath,
398
- success: false,
399
- message: "Line number not provided"
400
- };
401
- }
402
- if (!spell.value) {
403
- return {
404
- spell,
405
- file: filePath,
406
- success: false,
407
- message: "Transformation not specified"
408
- };
409
- }
410
- try {
411
- const lines = content.split("\n");
412
- const originalLine = lines[spell.lineNumber - 1];
413
- const transformCode = spell.value;
414
- const transformFn = new Function("line", transformCode);
415
- const transformedLine = transformFn(originalLine);
416
- lines[spell.lineNumber - 1] = transformedLine;
417
- const newContent = lines.join("\n");
418
- await fs.writeFile(filePath, newContent);
419
- return {
420
- spell,
421
- file: filePath,
422
- success: true,
423
- message: "Line transformed",
424
- changes: {
425
- before: originalLine ?? "",
426
- after: transformedLine
427
- },
428
- details: {
429
- linesAffected: [spell.lineNumber]
430
- }
431
- };
432
- } catch (error) {
433
- return {
434
- spell,
435
- file: filePath,
436
- success: false,
437
- message: `Failed to transform line: ${error}`
438
- };
439
- }
440
- };
441
- export const insertBeforeExecutor = async (spell, filePath, content) => {
442
- if (!spell.lineNumber) {
443
- return {
444
- spell,
445
- file: filePath,
446
- success: false,
447
- message: "Line number not provided"
448
- };
449
- }
450
- if (!spell.value) {
451
- return {
452
- spell,
453
- file: filePath,
454
- success: false,
455
- message: "Content to insert not specified"
456
- };
457
- }
458
- try {
459
- const lines = content.split("\n");
460
- const insertContent = spell.value.split("\n");
461
- const lineNumber = spell.lineNumber;
462
- lines.splice(lineNumber - 1, 0, ...insertContent);
463
- const newContent = lines.join("\n");
464
- await fs.writeFile(filePath, newContent);
465
- return {
466
- spell,
467
- file: filePath,
468
- success: true,
469
- message: "Content inserted before line",
470
- changes: {
471
- before: "",
472
- after: insertContent.join("\n")
473
- },
474
- details: {
475
- linesAffected: Array.from(
476
- { length: insertContent.length },
477
- (_, i) => lineNumber + i
478
- )
479
- }
480
- };
481
- } catch (error) {
482
- return {
483
- spell,
484
- file: filePath,
485
- success: false,
486
- message: `Failed to insert content: ${error}`
487
- };
488
- }
489
- };
490
- export const insertAfterExecutor = async (spell, filePath, content) => {
491
- if (!spell.lineNumber) {
492
- return {
493
- spell,
494
- file: filePath,
495
- success: false,
496
- message: "Line number not provided"
497
- };
498
- }
499
- if (!spell.value) {
500
- return {
501
- spell,
502
- file: filePath,
503
- success: false,
504
- message: "Content to insert not specified"
505
- };
506
- }
507
- try {
508
- const lines = content.split("\n");
509
- const insertContent = spell.value.split("\n");
510
- const lineNumber = spell.lineNumber;
511
- lines.splice(lineNumber, 0, ...insertContent);
512
- const newContent = lines.join("\n");
513
- await fs.writeFile(filePath, newContent);
514
- return {
515
- spell,
516
- file: filePath,
517
- success: true,
518
- message: "Content inserted after line",
519
- changes: {
520
- before: "",
521
- after: insertContent.join("\n")
522
- },
523
- details: {
524
- linesAffected: Array.from(
525
- { length: insertContent.length },
526
- (_, i) => lineNumber + i + 1
527
- )
528
- }
529
- };
530
- } catch (error) {
531
- return {
532
- spell,
533
- file: filePath,
534
- success: false,
535
- message: `Failed to insert content: ${error}`
536
- };
537
- }
538
- };
539
- export const conditionalExecuteExecutor = async (spell, filePath, content) => {
540
- if (!spell.params.condition) {
541
- return {
542
- spell,
543
- file: filePath,
544
- success: false,
545
- message: "Condition not provided"
546
- };
547
- }
548
- try {
549
- const conditionFn = new Function(
550
- "content",
551
- "filePath",
552
- spell.params.condition
553
- );
554
- const shouldExecute = conditionFn(content, filePath);
555
- if (!shouldExecute) {
556
- return {
557
- spell,
558
- file: filePath,
559
- success: true,
560
- message: "Condition not met, skipping execution"
561
- };
562
- }
563
- if (!spell.dependsOn?.length) {
564
- return {
565
- spell,
566
- file: filePath,
567
- success: false,
568
- message: "No dependent spells specified"
569
- };
570
- }
571
- const results = [];
572
- for (const dependentSpell of spell.dependsOn) {
573
- const result = await executeSpell(dependentSpell, filePath, content);
574
- results.push(result);
575
- }
576
- const allSuccessful = results.every((r) => r.success);
577
- return {
578
- spell,
579
- file: filePath,
580
- success: allSuccessful,
581
- message: allSuccessful ? "All dependent spells executed successfully" : "Some dependent spells failed",
582
- details: {
583
- filesAffected: results.map((r) => r.file)
584
- }
585
- };
586
- } catch (error) {
587
- return {
588
- spell,
589
- file: filePath,
590
- success: false,
591
- message: `Failed to execute condition: ${error}`
592
- };
593
- }
594
- };
@@ -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[]>;
@@ -1,7 +1,7 @@
1
- const SPELL_REGEX = /dler-([a-z-]+)-(?:"([^"]+)")?-?(?:{([^}]+)})?/;
1
+ const SPELL_REGEX = /<dler-([a-z-]+)-(?:"([^"]+)")?-?(?:{([^}]+)})?>/;
2
2
  export const parseParams = (paramsStr) => {
3
3
  const defaultParams = {
4
- hooked: true
4
+ hooked: false
5
5
  };
6
6
  if (!paramsStr) return defaultParams;
7
7
  const params = { ...defaultParams };
@@ -1,18 +1,6 @@
1
- export type SpellType = "replace-line" | "replace-range" | "rename-file" | "remove-comment" | "remove-line" | "remove-file" | "transform-content" | "transform-line" | "copy-file" | "move-file" | "insert-at" | "insert-before" | "insert-after" | "conditional-execute";
1
+ export type SpellType = "replace-line" | "rename-file" | "remove-comment" | "remove-line" | "remove-file" | "transform-content" | "copy-file" | "move-file" | "insert-at";
2
2
  export type SpellParams = {
3
- /** Whether the spell should be executed manually (true) or automatically at postbuild (false) */
4
3
  hooked: boolean;
5
- /** Line number to start the operation (for range operations) */
6
- startLine?: number;
7
- /** Line number to end the operation (for range operations) */
8
- endLine?: number;
9
- /** Condition to check before executing the spell */
10
- condition?: string;
11
- /** Whether to skip the spell if the target file doesn't exist */
12
- skipIfMissing?: boolean;
13
- /** Whether to create the target directory if it doesn't exist */
14
- createDir?: boolean;
15
- /** Custom parameters for specific spell types */
16
4
  [key: string]: any;
17
5
  };
18
6
  export type Spell = {
@@ -22,25 +10,17 @@ export type Spell = {
22
10
  lineNumber?: number;
23
11
  fullMatch?: string;
24
12
  fileName?: string;
25
- /** Optional array of spells that must be executed before this one */
26
- dependsOn?: Spell[];
27
13
  };
28
14
  export type SpellExecutionOptions = {
29
15
  spells?: (SpellType | "all")[];
30
16
  files?: string[];
31
17
  dryRun?: boolean;
32
- /** Whether to show detailed changes in the output */
33
- showChanges?: boolean;
34
- /** Whether to validate spell parameters before execution */
35
- validate?: boolean;
36
18
  };
37
19
  export type FileOperation = {
38
20
  type: "read" | "write" | "rename" | "remove" | "copy" | "move";
39
21
  sourcePath: string;
40
22
  targetPath?: string;
41
23
  content?: string;
42
- /** Whether to create parent directories if they don't exist */
43
- createDir?: boolean;
44
24
  };
45
25
  export type SpellResult = {
46
26
  spell: Spell;
@@ -51,10 +31,4 @@ export type SpellResult = {
51
31
  before: string;
52
32
  after: string;
53
33
  };
54
- /** Detailed information about the changes made */
55
- details?: {
56
- linesAffected?: number[];
57
- filesAffected?: string[];
58
- validationErrors?: string[];
59
- };
60
34
  };
@@ -1,47 +1,47 @@
1
- export type { LibraryBuildOptions } from "./sdk-impl/build/build-library.js";
2
- export { library_buildLibrary } from "./sdk-impl/build/build-library.js";
3
- export { regular_buildJsrDist, regular_buildNpmDist, } from "./sdk-impl/build/build-regular.js";
4
- export { autoPreset } from "./sdk-impl/build/bundlers/unified/auto.js";
5
- export { unifiedBuild } from "./sdk-impl/build/bundlers/unified/build.js";
6
- export { copyBuild } from "./sdk-impl/build/bundlers/unified/copy/copy.js";
7
- export { mkdistBuild } from "./sdk-impl/build/bundlers/unified/mkdist/mkdist.js";
8
- export { rollupBuild } from "./sdk-impl/build/bundlers/unified/rollup/build.js";
9
- export { getRollupOptions } from "./sdk-impl/build/bundlers/unified/rollup/config.js";
10
- export { cjsPlugin, fixCJSExportTypePlugin, } from "./sdk-impl/build/bundlers/unified/rollup/plugins/cjs.js";
11
- export { esbuild } from "./sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.js";
12
- export { JSONPlugin } from "./sdk-impl/build/bundlers/unified/rollup/plugins/json.js";
13
- export { rawPlugin } from "./sdk-impl/build/bundlers/unified/rollup/plugins/raw.js";
14
- export { getShebang, makeExecutable, removeShebangPlugin, shebangPlugin, } from "./sdk-impl/build/bundlers/unified/rollup/plugins/shebang.js";
15
- export { rollupStub } from "./sdk-impl/build/bundlers/unified/rollup/stub.js";
16
- export { DEFAULT_EXTENSIONS, getChunkFilename, resolveAliases, } from "./sdk-impl/build/bundlers/unified/rollup/utils.js";
17
- export { rollupWatch } from "./sdk-impl/build/bundlers/unified/rollup/watch.js";
18
- export { typesBuild } from "./sdk-impl/build/bundlers/unified/untyped/index.js";
19
- export { arrayIncludes, dumpObject, extractExportFilenames, getpkg, inferPkgExternals, listRecursively, removeExtension, resolvePreset, rmdir, symlink, warn, withTrailingSlash, } from "./sdk-impl/build/bundlers/unified/utils.js";
20
- export { validateDependencies, validatePackage, } from "./sdk-impl/build/bundlers/unified/validate.js";
21
- export { processLibraryFlow, libraries_buildPublish, } from "./sdk-impl/library-flow.js";
22
- export { library_publishLibrary } from "./sdk-impl/pub/pub-library.js";
23
- export { regular_pubToJsr, regular_pubToNpm, } from "./sdk-impl/pub/pub-regular.js";
24
- export { processRegularFlow } from "./sdk-impl/regular-flow.js";
25
- export { replaceLineExecutor, renameFileExecutor, removeCommentExecutor, removeLineExecutor, removeFileExecutor, copyFileExecutor, moveFileExecutor, transformContentExecutor, insertAtExecutor, } from "./sdk-impl/spell/spell-executors.js";
26
- export { fileExists, readFile, writeFile, removeFile, renameFile, copyFile, findFiles, } from "./sdk-impl/spell/spell-filesystem.js";
27
- export { executeSpell, processFile, spells, } from "./sdk-impl/spell/spell-mod.js";
28
- export { parseParams, parseSpellFromComment, extractSpellsFromFile, } from "./sdk-impl/spell/spell-parser.js";
29
- export type { SpellType, SpellParams, Spell, SpellExecutionOptions, FileOperation, SpellResult, } from "./sdk-impl/spell/spell-types.js";
30
- export { useAggregator } from "./sdk-impl/utils/tools/tools-agg.js";
31
- export { printUsage } from "./sdk-impl/utils/tools/tools-impl.js";
32
- export { getBunSourcemapOption, getUnifiedSourcemapOption, renameEntryFile, } from "./sdk-impl/utils/utils-build.js";
33
- export { removeDistFolders } from "./sdk-impl/utils/utils-clean.js";
34
- export { PROJECT_ROOT, CONCURRENCY_DEFAULT, tsconfigJson, cliDomainDocs, validExtensions, SHOW_VERBOSE, } from "./sdk-impl/utils/utils-consts.js";
35
- export { validateDevCwd, withWorkingDirectory, } from "./sdk-impl/utils/utils-cwd.js";
36
- export { filterDeps } from "./sdk-impl/utils/utils-deps.js";
37
- export { determineDistName } from "./sdk-impl/utils/utils-determine.js";
38
- export { handleDlerError } from "./sdk-impl/utils/utils-error.js";
39
- export { copyRootFile, getDirectorySize, outDirBinFilesCount, deleteSpecificFiles, readFileSafe, writeFileSafe, } from "./sdk-impl/utils/utils-fs.js";
40
- export { finalizeBuildPub } from "./sdk-impl/utils/finalize.js";
41
- export { createJsrJSON, renameTsxFiles, } from "./sdk-impl/utils/utils-jsr-json.js";
42
- export { extractPackageName } from "./sdk-impl/utils/utils-misc.js";
43
- export { createPerfTimer, getElapsedPerfTime, pausePerfTimer, resumePerfTimer, } from "./sdk-impl/utils/utils-perf.js";
44
- export { library_createPackageJSON } from "./sdk-impl/utils/utils-pkg-json-libs.js";
45
- export { regular_createPackageJSON } from "./sdk-impl/utils/utils-pkg-json-reg.js";
46
- export { createTSConfig } from "./sdk-impl/utils/utils-tsconfig.js";
47
- export type { CopyHooks, MkdistHooks, RollupBuildEntry, RollupBuildOptions, RollupHooks, UntypedHooks, UntypedOutput, BaseBuildEntry, BuildHooks, } from "./sdk-types.js";
1
+ export type { LibraryBuildOptions } from "./sdk-impl/build/build-library";
2
+ export { library_buildLibrary } from "./sdk-impl/build/build-library";
3
+ export { regular_buildJsrDist, regular_buildNpmDist, } from "./sdk-impl/build/build-regular";
4
+ export { autoPreset } from "./sdk-impl/build/bundlers/unified/auto";
5
+ export { unifiedBuild } from "./sdk-impl/build/bundlers/unified/build";
6
+ export { copyBuild } from "./sdk-impl/build/bundlers/unified/copy/copy";
7
+ export { mkdistBuild } from "./sdk-impl/build/bundlers/unified/mkdist/mkdist";
8
+ export { rollupBuild } from "./sdk-impl/build/bundlers/unified/rollup/build";
9
+ export { getRollupOptions } from "./sdk-impl/build/bundlers/unified/rollup/config";
10
+ export { cjsPlugin, fixCJSExportTypePlugin, } from "./sdk-impl/build/bundlers/unified/rollup/plugins/cjs";
11
+ export { esbuild } from "./sdk-impl/build/bundlers/unified/rollup/plugins/esbuild";
12
+ export { JSONPlugin } from "./sdk-impl/build/bundlers/unified/rollup/plugins/json";
13
+ export { rawPlugin } from "./sdk-impl/build/bundlers/unified/rollup/plugins/raw";
14
+ export { getShebang, makeExecutable, removeShebangPlugin, shebangPlugin, } from "./sdk-impl/build/bundlers/unified/rollup/plugins/shebang";
15
+ export { rollupStub } from "./sdk-impl/build/bundlers/unified/rollup/stub";
16
+ export { DEFAULT_EXTENSIONS, getChunkFilename, resolveAliases, } from "./sdk-impl/build/bundlers/unified/rollup/utils";
17
+ export { rollupWatch } from "./sdk-impl/build/bundlers/unified/rollup/watch";
18
+ export { typesBuild } from "./sdk-impl/build/bundlers/unified/untyped/index";
19
+ export { arrayIncludes, dumpObject, extractExportFilenames, getpkg, inferPkgExternals, listRecursively, removeExtension, resolvePreset, rmdir, symlink, warn, withTrailingSlash, } from "./sdk-impl/build/bundlers/unified/utils";
20
+ export { validateDependencies, validatePackage, } from "./sdk-impl/build/bundlers/unified/validate";
21
+ export { processLibraryFlow, libraries_buildPublish, } from "./sdk-impl/library-flow";
22
+ export { library_publishLibrary } from "./sdk-impl/pub/pub-library";
23
+ export { regular_pubToJsr, regular_pubToNpm, } from "./sdk-impl/pub/pub-regular";
24
+ export { processRegularFlow } from "./sdk-impl/regular-flow";
25
+ export { replaceLineExecutor, renameFileExecutor, removeCommentExecutor, removeLineExecutor, removeFileExecutor, copyFileExecutor, moveFileExecutor, transformContentExecutor, insertAtExecutor, } from "./sdk-impl/spell/spell-executors";
26
+ export { fileExists, readFile, writeFile, removeFile, renameFile, copyFile, findFiles, } from "./sdk-impl/spell/spell-filesystem";
27
+ export { executeSpell, processFile, spells, } from "./sdk-impl/spell/spell-mod";
28
+ export { parseParams, parseSpellFromComment, extractSpellsFromFile, } from "./sdk-impl/spell/spell-parser";
29
+ export type { SpellType, SpellParams, Spell, SpellExecutionOptions, FileOperation, SpellResult, } from "./sdk-impl/spell/spell-types";
30
+ export { useAggregator } from "./sdk-impl/utils/tools/tools-agg";
31
+ export { printUsage } from "./sdk-impl/utils/tools/tools-impl";
32
+ export { getBunSourcemapOption, getUnifiedSourcemapOption, renameEntryFile, } from "./sdk-impl/utils/utils-build";
33
+ export { removeDistFolders } from "./sdk-impl/utils/utils-clean";
34
+ export { PROJECT_ROOT, CONCURRENCY_DEFAULT, tsconfigJson, cliDomainDocs, validExtensions, SHOW_VERBOSE, } from "./sdk-impl/utils/utils-consts";
35
+ export { validateDevCwd, withWorkingDirectory, } from "./sdk-impl/utils/utils-cwd";
36
+ export { filterDeps } from "./sdk-impl/utils/utils-deps";
37
+ export { determineDistName } from "./sdk-impl/utils/utils-determine";
38
+ export { handleDlerError } from "./sdk-impl/utils/utils-error";
39
+ export { copyRootFile, getDirectorySize, outDirBinFilesCount, deleteSpecificFiles, readFileSafe, writeFileSafe, } from "./sdk-impl/utils/utils-fs";
40
+ export { finalizeBuildPub } from "./sdk-impl/utils/finalize";
41
+ export { createJsrJSON, renameTsxFiles, } from "./sdk-impl/utils/utils-jsr-json";
42
+ export { extractPackageName } from "./sdk-impl/utils/utils-misc";
43
+ export { createPerfTimer, getElapsedPerfTime, pausePerfTimer, resumePerfTimer, } from "./sdk-impl/utils/utils-perf";
44
+ export { library_createPackageJSON } from "./sdk-impl/utils/utils-pkg-json-libs";
45
+ export { regular_createPackageJSON } from "./sdk-impl/utils/utils-pkg-json-reg";
46
+ export { createTSConfig } from "./sdk-impl/utils/utils-tsconfig";
47
+ export type { CopyHooks, MkdistHooks, RollupBuildEntry, RollupBuildOptions, RollupHooks, UntypedHooks, UntypedOutput, BaseBuildEntry, BuildHooks, } from "./sdk-types";
@@ -323,6 +323,13 @@ export type BuildPublishConfig = {
323
323
  jsr: string[];
324
324
  }>;
325
325
  };
326
+ /**
327
+ * When `true`, fails the build if warnings are detected.
328
+ * Use with caution, as it may lead to inconsistent published versions.
329
+ *
330
+ * @default false
331
+ */
332
+ transpileFailOnWarn: boolean;
326
333
  /**
327
334
  * The transpileTarget runtime environment for the built package.
328
335
  *
@@ -709,7 +716,7 @@ export type BuildOptions = {
709
716
  /**
710
717
  * Terminate the build process when a warning appears
711
718
  */
712
- failOnWarn?: boolean;
719
+ transpileFailOnWarn?: boolean;
713
720
  /**
714
721
  * Whether the current build is for a library.
715
722
  */
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@reliverse/bleump": "^1.1.4",
4
- "@reliverse/pathkit": "^1.1.6",
4
+ "@reliverse/pathkit": "^1.2.0",
5
5
  "@reliverse/reglob": "^1.0.0",
6
6
  "@reliverse/relico": "^1.1.2",
7
- "@reliverse/relifso": "^1.3.0",
7
+ "@reliverse/relifso": "^1.3.1",
8
8
  "@reliverse/relinka": "^1.4.7",
9
9
  "@reliverse/rempts": "^1.7.12",
10
10
  "@rollup/plugin-alias": "^5.1.1",
@@ -16,7 +16,7 @@
16
16
  "chalk": "^5.4.1",
17
17
  "defu": "^6.1.4",
18
18
  "esbuild": "^0.25.4",
19
- "execa": "^9.5.3",
19
+ "execa": "^9.6.0",
20
20
  "fix-dts-default-cjs-exports": "^1.0.1",
21
21
  "glob": "^11.0.2",
22
22
  "hookable": "^5.5.3",
@@ -34,14 +34,15 @@
34
34
  "scule": "^1.3.0",
35
35
  "tinyglobby": "^0.2.14",
36
36
  "ts-morph": "^26.0.0",
37
- "untyped": "^2.0.0"
37
+ "untyped": "^2.0.0",
38
+ "vue-sfc-transformer": "^0.1.16"
38
39
  },
39
40
  "description": "@reliverse/dler is a flexible, unified, and fully automated bundler for typescript and javascript projects, as well as an npm and jsr publishing tool. dler is not only a bundler, it also tries to serve as the most powerful codemod toolkit for js/ts.",
40
41
  "homepage": "https://docs.reliverse.org",
41
42
  "license": "MIT",
42
43
  "name": "@reliverse/dler",
43
44
  "type": "module",
44
- "version": "1.5.6",
45
+ "version": "1.6.0",
45
46
  "keywords": [
46
47
  "reliverse",
47
48
  "cli",