@reliverse/dler 1.2.6 → 1.3.1

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.
Files changed (148) hide show
  1. package/README.md +43 -36
  2. package/bin/addons.d.ts +1 -0
  3. package/bin/addons.js +83 -0
  4. package/bin/app/agg/cmd.d.ts +35 -0
  5. package/bin/app/agg/cmd.js +49 -0
  6. package/bin/app/agg/impl.d.ts +36 -0
  7. package/bin/app/{tools → agg}/impl.js +1 -2
  8. package/bin/app/build/cmd.d.ts +7 -0
  9. package/bin/app/build/cmd.js +3 -1
  10. package/bin/app/cmds.d.ts +100 -0
  11. package/bin/app/cmds.js +11 -2
  12. package/bin/app/conv/cmd.d.ts +0 -0
  13. package/bin/app/deps/cmd.d.ts +28 -0
  14. package/bin/app/deps/cmd.js +62 -0
  15. package/bin/app/deps/impl/analyzer.d.ts +2 -0
  16. package/bin/app/deps/impl/analyzer.js +1 -1
  17. package/bin/app/deps/impl/filesystem.d.ts +4 -0
  18. package/bin/app/deps/impl/filesystem.js +2 -4
  19. package/bin/app/deps/impl/formatter.d.ts +2 -0
  20. package/bin/app/deps/impl/formatter.js +2 -2
  21. package/bin/app/deps/impl/parser.d.ts +5 -0
  22. package/bin/app/deps/impl/types.d.ts +21 -0
  23. package/bin/app/inject/README.md +3 -12
  24. package/bin/app/inject/cmd.d.ts +12 -0
  25. package/bin/app/inject/cmd.js +2 -2
  26. package/bin/app/inject/expect/cmd.d.ts +20 -0
  27. package/bin/app/inject/expect/impl.d.ts +5 -0
  28. package/bin/app/libs/cmd.d.ts +0 -0
  29. package/bin/app/merge/cmd.txt +1 -1
  30. package/bin/app/mono/cmd.d.ts +0 -0
  31. package/bin/app/pub/cmd.d.ts +7 -0
  32. package/bin/app/pub/cmd.js +3 -1
  33. package/bin/app/relifso/cmd.d.ts +12 -0
  34. package/bin/app/relifso/cmd.js +2 -2
  35. package/bin/app/relifso/init/cmd.d.ts +36 -0
  36. package/bin/app/relifso/init/impl/const.d.ts +34 -0
  37. package/bin/app/relifso/init/impl/const.js +1 -1
  38. package/bin/app/relifso/init/impl/mod.d.ts +17 -0
  39. package/bin/app/relifso/init/impl/templates/t-gitignore.d.ts +1 -0
  40. package/bin/app/relifso/init/impl/templates/t-license.d.ts +1 -0
  41. package/bin/app/relifso/init/impl/templates/t-readme.d.ts +1 -0
  42. package/bin/app/relifso/init/impl/types.d.ts +41 -0
  43. package/bin/app/relifso/init/impl/utils.d.ts +5 -0
  44. package/bin/app/relinka/cmd.d.ts +0 -0
  45. package/bin/app/rempts/init/cmd/cmd.d.ts +14 -0
  46. package/bin/app/rempts/init/cmd/cmd.js +3 -1
  47. package/bin/app/rempts/init/cmds/cmd.d.ts +19 -0
  48. package/bin/app/rempts/migrate/cmd.d.ts +14 -0
  49. package/bin/app/rempts/migrate/impl/commander.d.ts +4 -0
  50. package/bin/app/spell/cmd.d.ts +18 -0
  51. package/bin/app/spell/cmd.js +51 -0
  52. package/bin/app/split/cmd.d.ts +11 -0
  53. package/bin/app/split/impl.d.ts +25 -0
  54. package/bin/default.d.ts +5 -0
  55. package/bin/{libs/cfg/cfg-default.js → default.js} +6 -4
  56. package/bin/dler.d.ts +1 -0
  57. package/bin/dler.js +60 -0
  58. package/bin/impl.d.ts +10 -0
  59. package/bin/{cli.js → impl.js} +15 -27
  60. package/bin/info.d.ts +2 -0
  61. package/bin/info.js +21 -0
  62. package/bin/init.d.ts +1 -0
  63. package/bin/init.js +20 -27
  64. package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +51 -0
  65. package/bin/libs/sdk/sdk-impl/build/build-library.js +45 -66
  66. package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +26 -0
  67. package/bin/libs/sdk/sdk-impl/build/build-regular.js +28 -18
  68. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.d.ts +2 -0
  69. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.js +8 -3
  70. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.d.ts +5 -0
  71. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +12 -7
  72. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/copy.d.ts +2 -0
  73. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/copy.js +2 -1
  74. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/types.d.ts +9 -0
  75. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist.d.ts +2 -0
  76. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist.js +22 -6
  77. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/types.d.ts +15 -0
  78. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.d.ts +2 -0
  79. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.js +2 -1
  80. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.d.ts +2 -0
  81. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/cjs.d.ts +4 -0
  82. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.d.ts +13 -0
  83. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/json.d.ts +3 -0
  84. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/raw.d.ts +8 -0
  85. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/shebang.d.ts +5 -0
  86. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/stub.d.ts +2 -0
  87. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/types.d.ts +95 -0
  88. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/utils.d.ts +5 -0
  89. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.d.ts +2 -0
  90. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/types.d.ts +176 -0
  91. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/index.d.ts +2 -0
  92. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/index.js +2 -2
  93. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/types.d.ts +23 -0
  94. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.d.ts +20 -0
  95. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/validate.d.ts +4 -0
  96. package/bin/libs/sdk/sdk-impl/library-flow.d.ts +11 -0
  97. package/bin/libs/sdk/sdk-impl/library-flow.js +6 -1
  98. package/bin/libs/sdk/sdk-impl/pub/pub-library.d.ts +5 -0
  99. package/bin/libs/sdk/sdk-impl/pub/pub-library.js +6 -16
  100. package/bin/libs/sdk/sdk-impl/pub/pub-regular.d.ts +9 -0
  101. package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +12 -10
  102. package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +12 -0
  103. package/bin/libs/sdk/sdk-impl/regular-flow.js +45 -51
  104. package/bin/libs/sdk/sdk-impl/spell/spell-executors.d.ts +10 -0
  105. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.d.ts +7 -0
  106. package/bin/libs/sdk/sdk-impl/spell/spell-mod.d.ts +4 -0
  107. package/bin/libs/sdk/sdk-impl/spell/spell-parser.d.ts +4 -0
  108. package/bin/libs/sdk/sdk-impl/spell/spell-types.d.ts +34 -0
  109. package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.d.ts +14 -0
  110. package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.js +8 -6
  111. package/bin/libs/sdk/sdk-impl/utils/tools/tools-impl.d.ts +4 -0
  112. package/bin/libs/sdk/sdk-impl/utils/utils-build.d.ts +28 -0
  113. package/bin/libs/sdk/sdk-impl/utils/utils-build.js +3 -3
  114. package/bin/libs/sdk/sdk-impl/utils/utils-bump.d.ts +9 -0
  115. package/bin/libs/sdk/sdk-impl/utils/utils-bump.js +5 -7
  116. package/bin/libs/sdk/sdk-impl/utils/utils-clean.d.ts +5 -0
  117. package/bin/libs/sdk/sdk-impl/utils/utils-consts.d.ts +9 -0
  118. package/bin/libs/sdk/sdk-impl/utils/utils-cwd.d.ts +10 -0
  119. package/bin/libs/sdk/sdk-impl/utils/utils-deps.d.ts +5 -0
  120. package/bin/libs/sdk/sdk-impl/utils/utils-determine.d.ts +12 -0
  121. package/bin/libs/sdk/sdk-impl/utils/utils-error.d.ts +5 -0
  122. package/bin/libs/sdk/sdk-impl/utils/utils-fs.d.ts +24 -0
  123. package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +4 -1
  124. package/bin/libs/sdk/sdk-impl/utils/utils-info.d.ts +6 -0
  125. package/bin/libs/sdk/sdk-impl/utils/utils-info.js +7 -14
  126. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.d.ts +8 -0
  127. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +2 -4
  128. package/bin/libs/sdk/sdk-impl/utils/utils-paths.d.ts +55 -0
  129. package/bin/libs/sdk/sdk-impl/utils/utils-paths.js +33 -24
  130. package/bin/libs/sdk/sdk-impl/utils/utils-perf.d.ts +9 -0
  131. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.d.ts +5 -0
  132. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.d.ts +8 -0
  133. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.js +36 -27
  134. package/bin/libs/sdk/sdk-impl/utils/utils-tsconfig.d.ts +4 -0
  135. package/bin/libs/sdk/sdk-mod.d.ts +56 -0
  136. package/bin/libs/sdk/sdk-mod.js +42 -9
  137. package/bin/libs/sdk/sdk-types.d.ts +469 -0
  138. package/bin/libs/sdk/sdk-types.js +0 -1
  139. package/bin/load.d.ts +6 -0
  140. package/bin/load.js +1 -1
  141. package/bin/mod.d.ts +48 -0
  142. package/bin/mod.js +4 -14
  143. package/bin/types.d.ts +469 -0
  144. package/package.json +5 -4
  145. package/bin/app/tools/cmd.js +0 -81
  146. package/bin/app/tools/tools.txt +0 -92
  147. package/bin/libs/cfg/cfg-mod.js +0 -4
  148. package/bin/libs/cfg/cfg-types.js +0 -1
@@ -3,7 +3,7 @@ import prettyMilliseconds from "pretty-ms";
3
3
  import { setBumpDisabled } from "./utils-bump.js";
4
4
  import { removeDistFolders } from "./utils-clean.js";
5
5
  import { getElapsedPerfTime } from "./utils-perf.js";
6
- export async function finalizeBuild(timer, commonPubPause, libsList, distNpmDirName, distJsrDirName, libsDirDist, isDev) {
6
+ export async function finalizeBuild(timer, commonPubPause, libsList, distNpmDirName, distJsrDirName, libsDirDist) {
7
7
  if (!commonPubPause) {
8
8
  await removeDistFolders(
9
9
  distNpmDirName,
@@ -19,24 +19,17 @@ export async function finalizeBuild(timer, commonPubPause, libsList, distNpmDirN
19
19
  });
20
20
  if (!commonPubPause) {
21
21
  relinka(
22
- "info",
22
+ "success",
23
23
  `\u{1F389} Build and publishing completed successfully (in ${transpileFormattedTime})`
24
24
  );
25
25
  } else {
26
26
  relinka(
27
- "info",
27
+ "success",
28
28
  `\u{1F389} Test build completed successfully (in ${transpileFormattedTime})`
29
29
  );
30
- if (!isDev) {
31
- relinka(
32
- "warn",
33
- "\u{1F4DD} Publish process is currently paused in your config file"
34
- );
35
- } else {
36
- relinka(
37
- "warn",
38
- "\u{1F4DD} Publish is paused, you're in dev mode (use `bun pub` to publish)"
39
- );
40
- }
30
+ relinka(
31
+ "info",
32
+ "\u{1F4DD} Publish process is currently paused in your config file"
33
+ );
41
34
  }
42
35
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generates a jsr.json configuration file for JSR distributions.
3
+ */
4
+ export declare function createJsrJSON(outDirRoot: string, isLib: boolean, libName?: string, pkgDescription?: string): Promise<void>;
5
+ /**
6
+ * Renames .tsx files by replacing the .tsx extension with -tsx.txt.
7
+ */
8
+ export declare function renameTsxFiles(dir: string): Promise<void>;
@@ -5,16 +5,14 @@ import path from "pathe";
5
5
  import { readPackageJSON } from "pkg-types";
6
6
  import { glob } from "tinyglobby";
7
7
  import { cliDomainDocs, CONCURRENCY_DEFAULT } from "./utils-consts.js";
8
- export async function createJsrJSON(outDirRoot, isLib, libName = "unknown-lib-name", libDescription = "unknown-lib-description", coreDescription) {
8
+ export async function createJsrJSON(outDirRoot, isLib, libName = "unknown-lib-name", pkgDescription = "unknown-lib-description") {
9
9
  relinka("verbose", `Creating jsr.json configuration (isLib: ${isLib})`);
10
10
  const originalPkg = await readPackageJSON();
11
11
  let { description, name } = originalPkg;
12
12
  const { author, license, version } = originalPkg;
13
13
  if (isLib) {
14
14
  name = libName;
15
- description = libDescription;
16
- } else {
17
- description = coreDescription || description;
15
+ description = pkgDescription;
18
16
  }
19
17
  const pkgHomepage = cliDomainDocs;
20
18
  const jsrConfig = {
@@ -0,0 +1,55 @@
1
+ import type { LibConfig } from "../../sdk-types.js";
2
+ /** Represents the type classification of an import path. */
3
+ type ImportType = "absolute" | "alias" | "bare" | "dynamic" | "module" | "relative";
4
+ /** Represents the result of processing a single file. */
5
+ export type FileResult = {
6
+ filePath: string;
7
+ message: string;
8
+ success: boolean;
9
+ };
10
+ /** Options for the `convertImportPaths` function. */
11
+ export type ConvertImportPathsOptions = {
12
+ baseDir: string;
13
+ fromType: ImportType;
14
+ toType: ImportType;
15
+ libsList: Record<string, LibConfig>;
16
+ aliasPrefix?: string;
17
+ currentLibName?: string;
18
+ distJsrDryRun?: boolean;
19
+ fileExtensions?: string[];
20
+ generateSourceMap?: boolean;
21
+ strip?: string[];
22
+ urlMap?: Record<string, string>;
23
+ };
24
+ /** Options for the `convertImportExtensionsJsToTs` function. */
25
+ export type ConvertImportExtensionsOptions = {
26
+ dirPath: string;
27
+ distJsrDryRun?: boolean;
28
+ fileExtensions?: string[];
29
+ generateSourceMap?: boolean;
30
+ };
31
+ /**
32
+ * Extracts the package name (or scoped package name) from a potential bare import path.
33
+ * Returns null if the path is relative, absolute, or empty.
34
+ * @param importPath - The import path string.
35
+ * @returns The package name (e.g., "react", "@scope/pkg") or null.
36
+ */
37
+ export declare function extractPackageName(importPath: string | undefined): null | string;
38
+ /**
39
+ * Recursively searches for files in a directory and converts import path formats
40
+ * (e.g., relative to alias, absolute to module) based on specified types.
41
+ *
42
+ * @param options - Configuration defining the directory, conversion types, libraries, etc.
43
+ * @returns A promise resolving to an array of FileResult objects, one for each processed file.
44
+ */
45
+ export declare function convertImportPaths(options: ConvertImportPathsOptions): Promise<FileResult[]>;
46
+ /**
47
+ * Recursively searches for files in a directory and changes import paths
48
+ * ending in `.js` to end in `.ts`.
49
+ *
50
+ * @param options - Configuration defining the directory and processing options.
51
+ * @returns A promise resolving to an array of FileResult objects, one for each processed file.
52
+ */
53
+ export declare function convertImportExtensionsJsToTs(options: ConvertImportExtensionsOptions): Promise<FileResult[]>;
54
+ export declare function normalizeQuotes(str: string): string;
55
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { relinka } from "@reliverse/relinka";
2
- import fs from "fs-extra";
2
+ import { readFile, writeFile, readdir, stat } from "fs-extra";
3
3
  import MagicString from "magic-string";
4
4
  import pMap from "p-map";
5
5
  import path from "pathe";
@@ -283,18 +283,27 @@ function convertSingleImportPath(fromType, toType, importPath, options) {
283
283
  let processedPath = convertedPath;
284
284
  for (const stripSegment of fullOptions.strip) {
285
285
  const normalizedStripSegment = stripSegment.endsWith("/") ? stripSegment : `${stripSegment}/`;
286
- if (processedPath.startsWith(normalizedStripSegment)) {
287
- processedPath = processedPath.slice(normalizedStripSegment.length);
286
+ const leadingMatch = processedPath.match(/^((\.\.\/|\.\/)+)/);
287
+ const leading = leadingMatch ? leadingMatch[0] : "";
288
+ const afterLeading = processedPath.slice(leading.length);
289
+ if (afterLeading.startsWith(normalizedStripSegment)) {
290
+ processedPath = leading + afterLeading.slice(normalizedStripSegment.length);
288
291
  }
289
292
  }
290
293
  convertedPath = processedPath;
294
+ if (convertedPath.startsWith(".") && fullOptions.sourceFile && !convertedPath.startsWith("./node_modules")) {
295
+ const importingFileDir = path.dirname(fullOptions.sourceFile);
296
+ const absoluteTarget = path.resolve(importingFileDir, convertedPath);
297
+ const minimalRelative = path.relative(importingFileDir, absoluteTarget).replace(/\\/g, "/");
298
+ convertedPath = minimalRelative.startsWith(".") || minimalRelative.startsWith("/") ? minimalRelative : `./${minimalRelative}`;
299
+ }
291
300
  }
292
301
  return convertedPath;
293
302
  }
294
303
  async function processFileContent(filePath, processLogic, options) {
295
304
  const { distJsrDryRun = false, generateSourceMap = false } = options;
296
305
  try {
297
- const originalContent = await fs.readFile(filePath, "utf-8");
306
+ const originalContent = await readFile(filePath, "utf-8");
298
307
  const s = new MagicString(originalContent);
299
308
  const changesMade = await processLogic(originalContent, s);
300
309
  if (!changesMade) {
@@ -323,9 +332,9 @@ async function processFileContent(filePath, processLogic, options) {
323
332
  });
324
333
  }
325
334
  if (!distJsrDryRun) {
326
- await fs.writeFile(filePath, newContent, "utf-8");
335
+ await writeFile(filePath, newContent, "utf-8");
327
336
  if (map) {
328
- await fs.writeFile(`${filePath}.map`, map.toString(), "utf-8");
337
+ await writeFile(`${filePath}.map`, map.toString(), "utf-8");
329
338
  }
330
339
  }
331
340
  const message = `Processed ${path.basename(filePath)}${distJsrDryRun ? " (dry run)" : ""}${map ? " + sourcemap" : ""}`;
@@ -342,7 +351,7 @@ async function processFileContent(filePath, processLogic, options) {
342
351
  async function processDirectoryRecursively(dirPath, fileExtensions, fileProcessor, concurrency) {
343
352
  let results = [];
344
353
  try {
345
- const entries = await fs.readdir(dirPath, { withFileTypes: true });
354
+ const entries = await readdir(dirPath, { withFileTypes: true });
346
355
  const filesToProcess = [];
347
356
  const directoriesToRecurse = [];
348
357
  for (const entry of entries) {
@@ -384,11 +393,9 @@ async function transformImportPathsLogic(content, s, options) {
384
393
  const converterOptions = {
385
394
  ...conversionArgs,
386
395
  sourceFile: filePath,
387
- // Pass the absolute file path
396
+ // absolute file path
388
397
  strip: conversionArgs.strip ?? [],
389
- // Provide default empty array
390
398
  urlMap: conversionArgs.urlMap ?? {}
391
- // Provide default empty object
392
399
  };
393
400
  for (const match of content.matchAll(STATIC_IMPORT_REGEX)) {
394
401
  const fullMatch = match[0];
@@ -534,7 +541,7 @@ export async function convertImportPaths(options) {
534
541
  );
535
542
  }
536
543
  try {
537
- const stats = await fs.stat(baseDir);
544
+ const stats = await stat(baseDir);
538
545
  if (!stats.isDirectory()) {
539
546
  throw new Error(`Specified baseDir is not a directory: ${baseDir}`);
540
547
  }
@@ -544,33 +551,36 @@ export async function convertImportPaths(options) {
544
551
  }
545
552
  throw error;
546
553
  }
547
- relinka(
548
- "log",
549
- `Starting import path conversion (${fromType} -> ${toType}) in directory: ${baseDir}`
550
- );
551
554
  if (distJsrDryRun) {
552
- relinka("log", "Dry run mode enabled: No files will be modified.");
555
+ relinka(
556
+ "log",
557
+ "[path conversion] Dry run mode enabled: No files will be modified."
558
+ );
559
+ } else {
560
+ relinka(
561
+ "log",
562
+ `Starting import path conversion (${fromType} -> ${toType}) in directory: ${baseDir}`
563
+ );
553
564
  }
554
565
  const fileProcessor = async (filePath) => {
555
566
  return processFileContent(
556
567
  filePath,
557
568
  (content, s) => transformImportPathsLogic(content, s, {
558
- // Pass necessary context for the transformation
559
569
  fromType,
560
570
  toType,
561
571
  filePath,
562
- // Pass the absolute file path
572
+ // absolute file path
563
573
  aliasPrefix: rawAliasPrefix,
564
- // Pass raw prefix, normalization happens inside
574
+ // raw prefix, normalization happens inside
565
575
  baseDir,
566
- // Pass the resolved absolute baseDir
576
+ // resolved absolute baseDir
567
577
  currentLibName,
568
578
  libsList,
569
579
  strip,
570
580
  urlMap
571
581
  }),
572
582
  { distJsrDryRun, generateSourceMap }
573
- // Pass options for file writing
583
+ // file writing options
574
584
  );
575
585
  };
576
586
  const results = await processDirectoryRecursively(
@@ -605,7 +615,7 @@ export async function convertImportExtensionsJsToTs(options) {
605
615
  }
606
616
  const absoluteDirPath = path.resolve(CWD, rawDirPath);
607
617
  try {
608
- const stats = await fs.stat(absoluteDirPath);
618
+ const stats = await stat(absoluteDirPath);
609
619
  if (!stats.isDirectory()) {
610
620
  throw new Error(
611
621
  `Specified dirPath is not a directory: ${absoluteDirPath}`
@@ -628,9 +638,8 @@ export async function convertImportExtensionsJsToTs(options) {
628
638
  return processFileContent(
629
639
  filePath,
630
640
  transformJsToTsExtensionLogic,
631
- // Pass the dedicated logic function
632
641
  { distJsrDryRun, generateSourceMap }
633
- // Pass options for file writing
642
+ // file writing options
634
643
  );
635
644
  };
636
645
  const results = await processDirectoryRecursively(
@@ -0,0 +1,9 @@
1
+ export type PerfTimer = {
2
+ pausedAt: null | number;
3
+ pausedDuration: number;
4
+ startTime: number;
5
+ };
6
+ export declare function createPerfTimer(): PerfTimer;
7
+ export declare function getElapsedPerfTime(timer: PerfTimer): number;
8
+ export declare function pausePerfTimer(timer: PerfTimer): void;
9
+ export declare function resumePerfTimer(timer: PerfTimer): void;
@@ -0,0 +1,5 @@
1
+ import type { ExcludeMode, LibConfig, NpmOutExt } from "../../sdk-types.js";
2
+ /**
3
+ * Creates a package.json for a lib distribution.
4
+ */
5
+ export declare function library_createPackageJSON(libName: string, outDirRoot: string, isJsr: boolean, libsList: Record<string, LibConfig>, rmDepsMode: ExcludeMode, rmDepsPatterns: string[], unifiedBundlerOutExt: NpmOutExt): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import type { ExcludeMode, NpmOutExt } from "../../sdk-types.js";
2
+ /**
3
+ * Creates a package.json for the main distribution.
4
+ */
5
+ export declare function regular_createPackageJSON(outDirRoot: string, isJsr: boolean, coreIsCLI: {
6
+ enabled: boolean;
7
+ scripts: Record<string, string>;
8
+ }, unifiedBundlerOutExt: NpmOutExt, rmDepsMode: ExcludeMode, rmDepsPatterns: string[], coreDescription: string, coreBuildOutDir?: string): Promise<void>;
@@ -6,7 +6,7 @@ import {
6
6
  readPackageJSON
7
7
  } from "pkg-types";
8
8
  import { cliDomainDocs } from "./utils-consts.js";
9
- export async function regular_createPackageJSON(outDirRoot, isJsr, coreIsCLI, unifiedBundlerOutExt, rmDepsMode, rmDepsPatterns, coreDescription) {
9
+ export async function regular_createPackageJSON(outDirRoot, isJsr, coreIsCLI, unifiedBundlerOutExt, rmDepsMode, rmDepsPatterns, coreDescription, coreBuildOutDir = "bin") {
10
10
  relinka(
11
11
  "log",
12
12
  `Generating distribution package.json and tsconfig.json (isJsr=${isJsr})...`
@@ -17,19 +17,23 @@ export async function regular_createPackageJSON(outDirRoot, isJsr, coreIsCLI, un
17
17
  );
18
18
  const originalPkg = await readPackageJSON();
19
19
  const packageName = originalPkg.name || "";
20
- const cliCommandName = packageName.startsWith("@") ? packageName.split("/").pop() || "cli" : packageName;
21
20
  relinka(
22
21
  "verbose",
23
- `Package name: "${packageName}", CLI command name: "${cliCommandName}", coreIsCLI: ${coreIsCLI}`
22
+ `Package name: "${packageName}", CLI enabled: ${coreIsCLI.enabled}, scripts: ${JSON.stringify(coreIsCLI.scripts)}`
24
23
  );
25
- const outDirBin = path.join(outDirRoot, "bin");
24
+ const outDirBin = path.join(outDirRoot, coreBuildOutDir);
26
25
  const outExt = unifiedBundlerOutExt || "js";
27
26
  if (isJsr) {
28
- const binEntry = coreIsCLI ? { [cliCommandName]: "bin/mod.ts" } : void 0;
29
- if (coreIsCLI) {
27
+ const binEntry = coreIsCLI.enabled ? Object.fromEntries(
28
+ Object.entries(coreIsCLI.scripts).map(([name, script]) => [
29
+ name,
30
+ `${coreBuildOutDir}/${path.basename(script)}`
31
+ ])
32
+ ) : void 0;
33
+ if (coreIsCLI.enabled) {
30
34
  relinka(
31
35
  "verbose",
32
- `Adding CLI bin entry for JSR: { "${cliCommandName}": "bin/mod.ts" }`
36
+ `Adding CLI bin entries for JSR: ${JSON.stringify(binEntry)}`
33
37
  );
34
38
  }
35
39
  const jsrPkg = definePackageJSON({
@@ -50,24 +54,29 @@ export async function regular_createPackageJSON(outDirRoot, isJsr, coreIsCLI, un
50
54
  rmDepsPatterns
51
55
  ),
52
56
  exports: {
53
- ".": "./bin/mod.ts"
57
+ ".": `./${coreBuildOutDir}/mod.ts`
54
58
  }
55
59
  });
56
60
  await fs.writeJSON(path.join(outDirRoot, "package.json"), jsrPkg, {
57
61
  spaces: 2
58
62
  });
59
- if (coreIsCLI) {
63
+ if (coreIsCLI.enabled) {
60
64
  relinka(
61
65
  "verbose",
62
- `JSR package.json created with CLI bin entry: ${JSON.stringify(jsrPkg.bin)}`
66
+ `JSR package.json created with CLI bin entries: ${JSON.stringify(jsrPkg.bin)}`
63
67
  );
64
68
  }
65
69
  } else {
66
- const binEntry = coreIsCLI ? { [cliCommandName]: `bin/mod.${outExt}` } : void 0;
67
- if (coreIsCLI) {
70
+ const binEntry = coreIsCLI.enabled ? Object.fromEntries(
71
+ Object.entries(coreIsCLI.scripts).map(([name, script]) => [
72
+ name,
73
+ `${coreBuildOutDir}/${path.basename(script).replace(/\.ts$/, `.${outExt}`)}`
74
+ ])
75
+ ) : void 0;
76
+ if (coreIsCLI.enabled) {
68
77
  relinka(
69
78
  "verbose",
70
- `Adding CLI bin entry for NPM: { "${cliCommandName}": "bin/mod.${outExt}" }`
79
+ `Adding CLI bin entries for NPM: ${JSON.stringify(binEntry)}`
71
80
  );
72
81
  }
73
82
  const npmPkg = definePackageJSON({
@@ -88,20 +97,20 @@ export async function regular_createPackageJSON(outDirRoot, isJsr, coreIsCLI, un
88
97
  rmDepsPatterns
89
98
  ),
90
99
  exports: {
91
- ".": `./bin/mod.${outExt}`
100
+ ".": `./${coreBuildOutDir}/mod.${outExt}`
92
101
  },
93
- files: ["bin", "package.json", "README.md", "LICENSE"],
94
- main: `./bin/mod.${outExt}`,
95
- module: `./bin/mod.${outExt}`,
102
+ files: [coreBuildOutDir, "package.json", "README.md", "LICENSE"],
103
+ main: `./${coreBuildOutDir}/mod.${outExt}`,
104
+ module: `./${coreBuildOutDir}/mod.${outExt}`,
96
105
  publishConfig: { access: "public" }
97
106
  });
98
107
  await fs.writeJSON(path.join(outDirRoot, "package.json"), npmPkg, {
99
108
  spaces: 2
100
109
  });
101
- if (coreIsCLI) {
110
+ if (coreIsCLI.enabled) {
102
111
  relinka(
103
112
  "verbose",
104
- `NPM package.json created with CLI bin entry: ${JSON.stringify(npmPkg.bin)}`
113
+ `NPM package.json created with CLI bin entries: ${JSON.stringify(npmPkg.bin)}`
105
114
  );
106
115
  }
107
116
  }
@@ -122,21 +131,21 @@ async function regular_createCommonPackageFields(coreIsCLI, coreDescription) {
122
131
  type: "module",
123
132
  version
124
133
  };
125
- if (coreIsCLI) {
134
+ if (coreIsCLI.enabled) {
126
135
  relinka(
127
136
  "verbose",
128
- "coreIsCLI is true, adding CLI-specific fields to common package fields"
137
+ "coreIsCLI is enabled, adding CLI-specific fields to common package fields"
129
138
  );
130
139
  if (commonPkg.keywords) {
131
- const cliCommandName = name?.startsWith("@") ? name.split("/").pop() || "cli" : name || "dler";
140
+ const cliKeywords = Object.keys(coreIsCLI.scripts);
132
141
  relinka(
133
142
  "verbose",
134
- `Adding CLI keywords to existing keywords, CLI command name: "${cliCommandName}"`
143
+ `Adding CLI keywords to existing keywords: ${JSON.stringify(cliKeywords)}`
135
144
  );
136
145
  commonPkg.keywords = [
137
146
  .../* @__PURE__ */ new Set([
138
147
  "cli",
139
- cliCommandName,
148
+ ...cliKeywords,
140
149
  "command-line",
141
150
  ...commonPkg.keywords
142
151
  ])
@@ -146,12 +155,12 @@ async function regular_createCommonPackageFields(coreIsCLI, coreDescription) {
146
155
  `Updated keywords: ${JSON.stringify(commonPkg.keywords)}`
147
156
  );
148
157
  } else if (name) {
149
- const cliCommandName = name.startsWith("@") ? name.split("/").pop() || "cli" : name;
158
+ const cliKeywords = Object.keys(coreIsCLI.scripts);
150
159
  relinka(
151
160
  "verbose",
152
- `Setting new CLI keywords, CLI command name: "${cliCommandName}"`
161
+ `Setting new CLI keywords: ${JSON.stringify(cliKeywords)}`
153
162
  );
154
- commonPkg.keywords = ["cli", "command-line", cliCommandName];
163
+ commonPkg.keywords = ["cli", "command-line", ...cliKeywords];
155
164
  relinka("verbose", `Set keywords: ${JSON.stringify(commonPkg.keywords)}`);
156
165
  }
157
166
  } else {
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Creates a tsconfig.json file for the distribution.
3
+ */
4
+ export declare function createTSConfig(outDirRoot: string, allowImportingTsExtensions: boolean): Promise<void>;
@@ -0,0 +1,56 @@
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 type { CopyBuildEntry, CopyHooks, } from "./sdk-impl/build/bundlers/unified/copy/types.js";
8
+ export { mkdistBuild } from "./sdk-impl/build/bundlers/unified/mkdist/mkdist.js";
9
+ export type { MkdistBuildEntry, MkdistHooks, } from "./sdk-impl/build/bundlers/unified/mkdist/types.js";
10
+ export { rollupBuild } from "./sdk-impl/build/bundlers/unified/rollup/build.js";
11
+ export { getRollupOptions } from "./sdk-impl/build/bundlers/unified/rollup/config.js";
12
+ export { cjsPlugin, fixCJSExportTypePlugin, } from "./sdk-impl/build/bundlers/unified/rollup/plugins/cjs.js";
13
+ export type { EsbuildOptions } from "./sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.js";
14
+ export { esbuild } from "./sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.js";
15
+ export { JSONPlugin } from "./sdk-impl/build/bundlers/unified/rollup/plugins/json.js";
16
+ export { rawPlugin } from "./sdk-impl/build/bundlers/unified/rollup/plugins/raw.js";
17
+ export { getShebang, makeExecutable, removeShebangPlugin, shebangPlugin, } from "./sdk-impl/build/bundlers/unified/rollup/plugins/shebang.js";
18
+ export { rollupStub } from "./sdk-impl/build/bundlers/unified/rollup/stub.js";
19
+ export type { RollupBuildEntry, RollupBuildOptions, RollupHooks, RollupOptions, } from "./sdk-impl/build/bundlers/unified/rollup/types.js";
20
+ export { DEFAULT_EXTENSIONS, getChunkFilename, resolveAliases, } from "./sdk-impl/build/bundlers/unified/rollup/utils.js";
21
+ export { rollupWatch } from "./sdk-impl/build/bundlers/unified/rollup/watch.js";
22
+ export type { BaseBuildEntry, BuildContext, BuildEntry, BuildHooks, BuildOptions, BuildPreset, UnifiedBuildConfig, } from "./sdk-impl/build/bundlers/unified/types.js";
23
+ export { defineBuildConfig, definePreset, } from "./sdk-impl/build/bundlers/unified/types.js";
24
+ export { typesBuild } from "./sdk-impl/build/bundlers/unified/untyped/index.js";
25
+ export type { UntypedBuildEntry, UntypedHooks, UntypedOutput, UntypedOutputs, } from "./sdk-impl/build/bundlers/unified/untyped/types.js";
26
+ export { arrayIncludes, dumpObject, ensuredir, extractExportFilenames, getpkg, inferPkgExternals, listRecursively, removeExtension, resolvePreset, rmdir, symlink, warn, withTrailingSlash, } from "./sdk-impl/build/bundlers/unified/utils.js";
27
+ export { validateDependencies, validatePackage, } from "./sdk-impl/build/bundlers/unified/validate.js";
28
+ export { processLibraryFlow, libraries_buildPublish, } from "./sdk-impl/library-flow.js";
29
+ export { library_publishLibrary } from "./sdk-impl/pub/pub-library.js";
30
+ export { regular_pubToJsr, regular_pubToNpm, } from "./sdk-impl/pub/pub-regular.js";
31
+ export { processRegularFlow } from "./sdk-impl/regular-flow.js";
32
+ export { replaceLineExecutor, renameFileExecutor, removeCommentExecutor, removeLineExecutor, removeFileExecutor, copyFileExecutor, moveFileExecutor, transformContentExecutor, insertAtExecutor, } from "./sdk-impl/spell/spell-executors.js";
33
+ export { fileExists, readFile, writeFile, removeFile, renameFile, copyFile, findFiles, } from "./sdk-impl/spell/spell-filesystem.js";
34
+ export { executeSpell, processFile, spells, } from "./sdk-impl/spell/spell-mod.js";
35
+ export { parseParams, parseSpellFromComment, extractSpellsFromFile, } from "./sdk-impl/spell/spell-parser.js";
36
+ export type { SpellType, SpellParams, Spell, SpellExecutionOptions, FileOperation, SpellResult, } from "./sdk-impl/spell/spell-types.js";
37
+ export { useAggregator } from "./sdk-impl/utils/tools/tools-agg.js";
38
+ export { printUsage } from "./sdk-impl/utils/tools/tools-impl.js";
39
+ export { getBunSourcemapOption, getUnifiedSourcemapOption, renameEntryFile, } from "./sdk-impl/utils/utils-build.js";
40
+ export { bumpHandler, setBumpDisabled } from "./sdk-impl/utils/utils-bump.js";
41
+ export { removeDistFolders } from "./sdk-impl/utils/utils-clean.js";
42
+ export { PROJECT_ROOT, CONCURRENCY_DEFAULT, tsconfigJson, cliDomainDocs, validExtensions, SHOW_VERBOSE, } from "./sdk-impl/utils/utils-consts.js";
43
+ export { validateDevCwd, withWorkingDirectory, } from "./sdk-impl/utils/utils-cwd.js";
44
+ export { filterDeps } from "./sdk-impl/utils/utils-deps.js";
45
+ export { determineDistName } from "./sdk-impl/utils/utils-determine.js";
46
+ export { handleDlerError } from "./sdk-impl/utils/utils-error.js";
47
+ export { copyRootFile, getDirectorySize, outDirBinFilesCount, deleteSpecificFiles, readFileSafe, writeFileSafe, } from "./sdk-impl/utils/utils-fs.js";
48
+ export { finalizeBuild } from "./sdk-impl/utils/utils-info.js";
49
+ export { createJsrJSON, renameTsxFiles, } from "./sdk-impl/utils/utils-jsr-json.js";
50
+ export type { FileResult, ConvertImportPathsOptions, ConvertImportExtensionsOptions, } from "./sdk-impl/utils/utils-paths.js";
51
+ export { extractPackageName, convertImportPaths, convertImportExtensionsJsToTs, normalizeQuotes, } from "./sdk-impl/utils/utils-paths.js";
52
+ export type { PerfTimer } from "./sdk-impl/utils/utils-perf.js";
53
+ export { createPerfTimer, getElapsedPerfTime, pausePerfTimer, resumePerfTimer, } from "./sdk-impl/utils/utils-perf.js";
54
+ export { library_createPackageJSON } from "./sdk-impl/utils/utils-pkg-json-libs.js";
55
+ export { regular_createPackageJSON } from "./sdk-impl/utils/utils-pkg-json-reg.js";
56
+ export { createTSConfig } from "./sdk-impl/utils/utils-tsconfig.js";
@@ -4,7 +4,7 @@ export {
4
4
  regular_buildNpmDist
5
5
  } from "./sdk-impl/build/build-regular.js";
6
6
  export { autoPreset } from "./sdk-impl/build/bundlers/unified/auto.js";
7
- export { build } from "./sdk-impl/build/bundlers/unified/build.js";
7
+ export { unifiedBuild } from "./sdk-impl/build/bundlers/unified/build.js";
8
8
  export { copyBuild } from "./sdk-impl/build/bundlers/unified/copy/copy.js";
9
9
  export { mkdistBuild } from "./sdk-impl/build/bundlers/unified/mkdist/mkdist.js";
10
10
  export { rollupBuild } from "./sdk-impl/build/bundlers/unified/rollup/build.js";
@@ -53,13 +53,46 @@ export {
53
53
  validateDependencies,
54
54
  validatePackage
55
55
  } from "./sdk-impl/build/bundlers/unified/validate.js";
56
- export { processLibraryFlow } from "./sdk-impl/library-flow.js";
56
+ export {
57
+ processLibraryFlow,
58
+ libraries_buildPublish
59
+ } from "./sdk-impl/library-flow.js";
57
60
  export { library_publishLibrary } from "./sdk-impl/pub/pub-library.js";
58
61
  export {
59
62
  regular_pubToJsr,
60
63
  regular_pubToNpm
61
64
  } from "./sdk-impl/pub/pub-regular.js";
62
65
  export { processRegularFlow } from "./sdk-impl/regular-flow.js";
66
+ export {
67
+ replaceLineExecutor,
68
+ renameFileExecutor,
69
+ removeCommentExecutor,
70
+ removeLineExecutor,
71
+ removeFileExecutor,
72
+ copyFileExecutor,
73
+ moveFileExecutor,
74
+ transformContentExecutor,
75
+ insertAtExecutor
76
+ } from "./sdk-impl/spell/spell-executors.js";
77
+ export {
78
+ fileExists,
79
+ readFile,
80
+ writeFile,
81
+ removeFile,
82
+ renameFile,
83
+ copyFile,
84
+ findFiles
85
+ } from "./sdk-impl/spell/spell-filesystem.js";
86
+ export {
87
+ executeSpell,
88
+ processFile,
89
+ spells
90
+ } from "./sdk-impl/spell/spell-mod.js";
91
+ export {
92
+ parseParams,
93
+ parseSpellFromComment,
94
+ extractSpellsFromFile
95
+ } from "./sdk-impl/spell/spell-parser.js";
63
96
  export { useAggregator } from "./sdk-impl/utils/tools/tools-agg.js";
64
97
  export { printUsage } from "./sdk-impl/utils/tools/tools-impl.js";
65
98
  export {
@@ -70,12 +103,12 @@ export {
70
103
  export { bumpHandler, setBumpDisabled } from "./sdk-impl/utils/utils-bump.js";
71
104
  export { removeDistFolders } from "./sdk-impl/utils/utils-clean.js";
72
105
  export {
73
- cliDomainDocs,
74
- CONCURRENCY_DEFAULT,
75
106
  PROJECT_ROOT,
76
- SHOW_VERBOSE,
107
+ CONCURRENCY_DEFAULT,
77
108
  tsconfigJson,
78
- validExtensions
109
+ cliDomainDocs,
110
+ validExtensions,
111
+ SHOW_VERBOSE
79
112
  } from "./sdk-impl/utils/utils-consts.js";
80
113
  export {
81
114
  validateDevCwd,
@@ -86,9 +119,9 @@ export { determineDistName } from "./sdk-impl/utils/utils-determine.js";
86
119
  export { handleDlerError } from "./sdk-impl/utils/utils-error.js";
87
120
  export {
88
121
  copyRootFile,
89
- deleteSpecificFiles,
90
122
  getDirectorySize,
91
123
  outDirBinFilesCount,
124
+ deleteSpecificFiles,
92
125
  readFileSafe,
93
126
  writeFileSafe
94
127
  } from "./sdk-impl/utils/utils-fs.js";
@@ -98,9 +131,9 @@ export {
98
131
  renameTsxFiles
99
132
  } from "./sdk-impl/utils/utils-jsr-json.js";
100
133
  export {
101
- convertImportExtensionsJsToTs,
102
- convertImportPaths,
103
134
  extractPackageName,
135
+ convertImportPaths,
136
+ convertImportExtensionsJsToTs,
104
137
  normalizeQuotes
105
138
  } from "./sdk-impl/utils/utils-paths.js";
106
139
  export {