@reliverse/dler 1.7.26 → 1.7.28

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 (136) hide show
  1. package/README.md +7 -3
  2. package/bin/app/agg/cmd.d.ts +5 -2
  3. package/bin/app/agg/cmd.js +56 -20
  4. package/bin/app/agg/impl.js +1 -0
  5. package/bin/app/build/cmd.js +5 -10
  6. package/bin/app/build/impl.d.ts +6 -3
  7. package/bin/app/build/impl.js +20 -28
  8. package/bin/app/build/postbuild.d.ts +1 -0
  9. package/bin/app/build/postbuild.js +109 -0
  10. package/bin/app/build/ppb-utils.d.ts +16 -0
  11. package/bin/app/build/ppb-utils.js +99 -0
  12. package/bin/app/build/prebuild.d.ts +2 -0
  13. package/bin/app/build/prebuild.js +112 -0
  14. package/bin/app/check/cmd.d.ts +8 -0
  15. package/bin/app/check/cmd.js +63 -53
  16. package/bin/app/magic/cmd.d.ts +4 -0
  17. package/bin/app/magic/cmd.js +37 -26
  18. package/bin/app/pub/cmd.js +2 -9
  19. package/bin/app/pub/impl.js +17 -71
  20. package/bin/app/remdn/cmd.d.ts +35 -0
  21. package/bin/app/remdn/cmd.js +732 -0
  22. package/bin/cli.js +36 -25
  23. package/bin/libs/cfg/{constants.d.ts → cfg-impl/cfg-consts.d.ts} +15 -11
  24. package/bin/libs/cfg/{constants.js → cfg-impl/cfg-consts.js} +16 -0
  25. package/bin/libs/cfg/{types.d.ts → cfg-impl/cfg-types.d.ts} +58 -0
  26. package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-define.d.ts +10 -10
  27. package/bin/libs/cfg/cfg-mod.d.ts +24 -24
  28. package/bin/libs/cfg/cfg-mod.js +35 -21
  29. package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +1 -1
  30. package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +1 -1
  31. package/bin/libs/sdk/sdk-impl/build/build-regular.js +1 -17
  32. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.d.ts +1 -1
  33. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.d.ts +1 -1
  34. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/copy-mod.d.ts +1 -1
  35. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loader.d.ts +1 -1
  36. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/js.d.ts +1 -1
  37. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/loaders-mod.d.ts +1 -1
  38. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/postcss.d.ts +1 -1
  39. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.d.ts +1 -1
  40. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.d.ts +1 -1
  41. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.d.ts +1 -1
  42. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +1 -1
  43. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/dts.d.ts +1 -1
  44. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/vue-dts.d.ts +1 -1
  45. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-mod.d.ts +1 -1
  46. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.d.ts +1 -1
  47. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.d.ts +1 -1
  48. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/cjs.d.ts +1 -1
  49. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.d.ts +1 -1
  50. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/stub.d.ts +1 -1
  51. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/utils.d.ts +1 -1
  52. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.d.ts +1 -1
  53. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/untyped-mod.d.ts +1 -1
  54. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.d.ts +1 -1
  55. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/validate.d.ts +1 -1
  56. package/bin/libs/sdk/sdk-impl/config/default.js +18 -1
  57. package/bin/libs/sdk/sdk-impl/config/info.js +1 -1
  58. package/bin/libs/sdk/sdk-impl/config/init.js +16 -0
  59. package/bin/libs/sdk/sdk-impl/config/types.d.ts +71 -0
  60. package/bin/libs/sdk/sdk-impl/library-flow.d.ts +14 -7
  61. package/bin/libs/sdk/sdk-impl/library-flow.js +61 -13
  62. package/bin/libs/sdk/sdk-impl/pub/pub-library.d.ts +1 -1
  63. package/bin/libs/sdk/sdk-impl/pub/pub-regular.d.ts +1 -1
  64. package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +7 -3
  65. package/bin/libs/sdk/sdk-impl/regular-flow.js +42 -19
  66. package/bin/libs/sdk/sdk-impl/rules/reliverse/dler-config-health/dler-config-health.d.ts +1 -1
  67. package/bin/libs/sdk/sdk-impl/rules/reliverse/file-extensions/file-extensions.d.ts +1 -1
  68. package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/deps-mod.d.ts +1 -1
  69. package/bin/libs/sdk/sdk-impl/rules/reliverse/no-dynamic-imports/no-dynamic-imports.d.ts +8 -2
  70. package/bin/libs/sdk/sdk-impl/rules/reliverse/no-dynamic-imports/no-dynamic-imports.js +50 -2
  71. package/bin/libs/sdk/sdk-impl/rules/reliverse/no-index-files/no-index-files.d.ts +1 -1
  72. package/bin/libs/sdk/sdk-impl/rules/reliverse/package-json-health/package-json-health.d.ts +1 -1
  73. package/bin/libs/sdk/sdk-impl/rules/reliverse/path-extensions/path-extensions.d.ts +1 -1
  74. package/bin/libs/sdk/sdk-impl/rules/reliverse/self-include/self-include.d.ts +1 -1
  75. package/bin/libs/sdk/sdk-impl/rules/reliverse/tsconfig-health/tsconfig-health.d.ts +1 -1
  76. package/bin/libs/sdk/sdk-impl/rules/rules-mod.d.ts +1 -1
  77. package/bin/libs/sdk/sdk-impl/rules/rules-utils.d.ts +0 -1
  78. package/bin/libs/sdk/sdk-impl/rules/rules-utils.js +1 -8
  79. package/bin/libs/sdk/{sdk-types.d.ts → sdk-impl/sdk-types.d.ts} +1 -1
  80. package/bin/libs/sdk/sdk-impl/utils/finalize.d.ts +6 -2
  81. package/bin/libs/sdk/sdk-impl/utils/finalize.js +25 -17
  82. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.d.ts +1 -1
  83. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.js +2 -2
  84. package/bin/libs/sdk/sdk-impl/utils/utils-fs.d.ts +1 -36
  85. package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +6 -113
  86. package/bin/libs/sdk/sdk-impl/utils/utils-perf.d.ts +1 -1
  87. package/bin/libs/sdk/sdk-impl/utils/utils-security.d.ts +0 -1
  88. package/bin/libs/sdk/sdk-impl/utils/utils-security.js +0 -8
  89. package/bin/libs/sdk/sdk-mod.d.ts +16 -11
  90. package/bin/libs/sdk/sdk-mod.js +52 -7
  91. package/package.json +5 -4
  92. /package/bin/libs/cfg/{rse/rse-impl/rse-types.js → cfg-impl/cfg-types.js} +0 -0
  93. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-biome.d.ts +0 -0
  94. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-biome.js +0 -0
  95. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-comments.d.ts +0 -0
  96. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-comments.js +0 -0
  97. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-consts.d.ts +0 -0
  98. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-consts.js +0 -0
  99. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-content.d.ts +0 -0
  100. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-content.js +0 -0
  101. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-core.d.ts +0 -0
  102. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-core.js +0 -0
  103. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-create.d.ts +0 -0
  104. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-create.js +0 -0
  105. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-def-utils.d.ts +0 -0
  106. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-def-utils.js +0 -0
  107. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-default.d.ts +0 -0
  108. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-default.js +0 -0
  109. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-define.js +0 -0
  110. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-detect.d.ts +0 -0
  111. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-detect.js +0 -0
  112. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-gen-cfg.d.ts +0 -0
  113. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-gen-cfg.js +0 -0
  114. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-migrate.d.ts +0 -0
  115. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-migrate.js +0 -0
  116. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-path.d.ts +0 -0
  117. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-path.js +0 -0
  118. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-prompts.d.ts +0 -0
  119. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-prompts.js +0 -0
  120. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-read.d.ts +0 -0
  121. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-read.js +0 -0
  122. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-repair.d.ts +0 -0
  123. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-repair.js +0 -0
  124. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-schema.d.ts +0 -0
  125. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-schema.js +0 -0
  126. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-types.d.ts +0 -0
  127. /package/bin/libs/cfg/{types.js → cfg-impl/rse-config/rse-impl/rse-types.js} +0 -0
  128. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-unstable.d.ts +0 -0
  129. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-unstable.js +0 -0
  130. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-update.d.ts +0 -0
  131. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-update.js +0 -0
  132. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-utils.d.ts +0 -0
  133. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-impl/rse-utils.js +0 -0
  134. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-mod.d.ts +0 -0
  135. /package/bin/libs/cfg/{rse → cfg-impl/rse-config}/rse-mod.js +0 -0
  136. /package/bin/libs/sdk/{sdk-types.js → sdk-impl/sdk-types.js} +0 -0
package/README.md CHANGED
@@ -127,7 +127,7 @@ if you run just `dler` — it will display a list of commands which you can laun
127
127
 
128
128
  ## **available commands**
129
129
 
130
- [agg](#1-agg) [build](#2-build) [check](#3-check) [conv](#4-conv) [copy](#6-copy) [init](#7-init) [inject](#8-inject) [libs](#9-libs) [merge](#10-merge) [migrate](#11-migrate) [pub](#12-pub) [rempts](#13-rempts) [rename](#14-rename) [spell](#15-spell) [split](#16-split) [pack](#17-pack) [unpack](#18-unpack)
130
+ [agg](#1-agg) [build](#2-build) [check](#3-check) [conv](#4-conv) [copy](#6-copy) [init](#7-init) [inject](#8-inject) [libs](#9-libs) [merge](#10-merge) [migrate](#11-migrate) [pub](#12-pub) [rempts](#13-rempts) [rename](#14-rename) [spell](#15-magic) [split](#16-split) [pack](#17-pack) [unpack](#18-unpack)
131
131
 
132
132
  ### 1. `agg`
133
133
 
@@ -601,7 +601,7 @@ bun dler rempts --init cmd1 cmd2
601
601
  bun dler rename ...
602
602
  ```
603
603
 
604
- ### 15. `spell`
604
+ ### 15. `magic`
605
605
 
606
606
  > Contributors: Please check the [docs/cmds/SPELLS.md](./docs/cmds/SPELLS.md) file for more technical details.
607
607
 
@@ -820,12 +820,16 @@ special thanks to the project that inspired `@reliverse/dler`:
820
820
 
821
821
  ## contributors
822
822
 
823
- ### scripts
823
+ ### helper scripts
824
824
 
825
825
  - `libs:pack`: Creates two templates, `cfg` and `sdk`, based on dist-libs directory structure (using **dler pack** command).
826
826
  - `libs:unpack`: Creates a project structure using all templates from the `cfg` and `sdk` templates (using **dler unpack** command).
827
827
  - `libs:example`: Since `libs:unpack`'s serves as a dist-libs mock, then `libs:example` helps easily test dler's features like `resolveAllCrossLibs()`.
828
828
 
829
+ ### notes
830
+
831
+ `<src | dist-npm | dist-jsr>/libs/<lib-name>/<files live here>` === `dist-libs/<lib-name>/<jsr | npm>/bin/<files live here>`
832
+
829
833
  ## support
830
834
 
831
835
  - if dler saves you time and effort, please consider supporting its development: [github sponsors](https://github.com/sponsors/blefnk);
@@ -10,7 +10,6 @@ declare const _default: import("@reliverse/rempts").Command<{
10
10
  input: {
11
11
  description: string;
12
12
  type: "string";
13
- required: true;
14
13
  };
15
14
  named: {
16
15
  description: string;
@@ -20,7 +19,6 @@ declare const _default: import("@reliverse/rempts").Command<{
20
19
  out: {
21
20
  description: string;
22
21
  type: "string";
23
- required: true;
24
22
  };
25
23
  recursive: {
26
24
  description: string;
@@ -69,5 +67,10 @@ declare const _default: import("@reliverse/rempts").Command<{
69
67
  description: string;
70
68
  type: "string";
71
69
  };
70
+ nonInteractive: {
71
+ description: string;
72
+ type: "boolean";
73
+ default: false;
74
+ };
72
75
  }>;
73
76
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import path from "@reliverse/pathkit";
2
- import { defineArgs, defineCommand } from "@reliverse/rempts";
2
+ import { defineArgs, defineCommand, inputPrompt } from "@reliverse/rempts";
3
3
  import { useAggregator } from "./impl.js";
4
4
  export default defineCommand({
5
5
  args: defineArgs({
@@ -13,8 +13,7 @@ export default defineCommand({
13
13
  },
14
14
  input: {
15
15
  description: "Directory containing .ts/.js files (--input <directory>)",
16
- type: "string",
17
- required: true
16
+ type: "string"
18
17
  },
19
18
  named: {
20
19
  description: "Parse each file for named exports (function/class/const/let)",
@@ -23,8 +22,7 @@ export default defineCommand({
23
22
  },
24
23
  out: {
25
24
  description: "Output aggregator file path (--out <fileName>)",
26
- type: "string",
27
- required: true
25
+ type: "string"
28
26
  },
29
27
  recursive: {
30
28
  description: "Recursively scan subdirectories (default true) (false means only scan the files in the current directory and not subdirectories)",
@@ -72,25 +70,63 @@ export default defineCommand({
72
70
  typesOut: {
73
71
  description: "Output file path for types (used when separateTypesFile is true)",
74
72
  type: "string"
73
+ },
74
+ nonInteractive: {
75
+ description: "Disable interactive prompts and require all arguments to be provided via flags",
76
+ type: "boolean",
77
+ default: false
75
78
  }
76
79
  }),
77
80
  async run({ args }) {
81
+ const resolvedArgs = { ...args };
82
+ if (!args.nonInteractive) {
83
+ if (!args.input) {
84
+ resolvedArgs.input = await inputPrompt({
85
+ title: "Enter input directory containing .ts/.js files:",
86
+ defaultValue: ""
87
+ });
88
+ }
89
+ if (!args.out) {
90
+ resolvedArgs.out = await inputPrompt({
91
+ title: "Enter output aggregator file path:",
92
+ defaultValue: ""
93
+ });
94
+ }
95
+ if (args.separateTypesFile && !args.typesOut) {
96
+ resolvedArgs.typesOut = await inputPrompt({
97
+ title: "Enter output file path for types:",
98
+ defaultValue: resolvedArgs.out.replace(/\.(ts|js)$/, ".types.$1")
99
+ });
100
+ }
101
+ } else {
102
+ if (!args.input) {
103
+ throw new Error("Missing required argument: --input");
104
+ }
105
+ if (!args.out) {
106
+ throw new Error("Missing required argument: --out");
107
+ }
108
+ if (args.separateTypesFile && !args.typesOut) {
109
+ throw new Error(
110
+ "Missing required argument: --typesOut (required when --separateTypesFile is true)"
111
+ );
112
+ }
113
+ }
78
114
  await useAggregator({
79
- inputDir: path.resolve(args.input),
80
- isRecursive: !!args.recursive,
81
- outFile: path.resolve(args.out),
82
- stripPrefix: args.strip ? path.resolve(args.strip) : "",
83
- useImport: !!args.imports,
84
- useNamed: !!args.named,
85
- sortLines: !!args.sort,
86
- headerComment: args.header || "",
87
- verbose: !!args.verbose,
88
- includeInternal: !!args.includeInternal,
89
- internalMarker: args.internalMarker,
90
- overrideFile: !!args.override,
91
- fileExtensions: args.extensions.split(",").map((ext) => ext.trim()),
92
- separateTypesFile: !!args.separateTypesFile,
93
- typesOutFile: args.typesOut ? path.resolve(args.typesOut) : void 0
115
+ inputDir: path.resolve(resolvedArgs.input),
116
+ isRecursive: !!resolvedArgs.recursive,
117
+ outFile: path.resolve(resolvedArgs.out),
118
+ stripPrefix: resolvedArgs.strip ? path.resolve(resolvedArgs.strip) : "",
119
+ useImport: !!resolvedArgs.imports,
120
+ useNamed: !!resolvedArgs.named,
121
+ sortLines: !!resolvedArgs.sort,
122
+ headerComment: resolvedArgs.header || "",
123
+ verbose: !!resolvedArgs.verbose,
124
+ includeInternal: !!resolvedArgs.includeInternal,
125
+ internalMarker: resolvedArgs.internalMarker,
126
+ overrideFile: !!resolvedArgs.override,
127
+ fileExtensions: resolvedArgs.extensions.split(",").map((ext) => ext.trim()),
128
+ separateTypesFile: !!resolvedArgs.separateTypesFile,
129
+ typesOutFile: resolvedArgs.typesOut ? path.resolve(resolvedArgs.typesOut) : void 0
94
130
  });
95
131
  }
96
132
  });
@@ -163,6 +163,7 @@ function buildPathRelative(filePath, inputDir, stripPrefix) {
163
163
  if (!resolved.startsWith("./") && !resolved.startsWith("../")) {
164
164
  resolved = `./${resolved}`;
165
165
  }
166
+ resolved = resolved.replace(/\/+/g, "/");
166
167
  return resolved;
167
168
  }
168
169
  async function collectFiles(dir, exts, recursive, ignoreDirs, verbose, includeInternal, internalMarker, outFile) {
@@ -1,12 +1,12 @@
1
1
  import { defineArgs, defineCommand } from "@reliverse/rempts";
2
- import { dlerPub } from "../pub/impl.js";
2
+ import { dlerBuild } from "./impl.js";
3
3
  import { ensureDlerConfig } from "../../libs/sdk/sdk-impl/config/init.js";
4
4
  import { getConfigDler } from "../../libs/sdk/sdk-impl/config/load.js";
5
- import { removeDistFolders } from "../../libs/sdk/sdk-mod.js";
5
+ import { finalizeBuild } from "../../libs/sdk/sdk-mod.js";
6
6
  export default defineCommand({
7
7
  meta: {
8
8
  name: "build",
9
- description: "Build the project"
9
+ description: "Build the project (without publishing)"
10
10
  },
11
11
  args: defineArgs({
12
12
  dev: {
@@ -17,12 +17,7 @@ export default defineCommand({
17
17
  async run({ args }) {
18
18
  await ensureDlerConfig(args.dev);
19
19
  const config = await getConfigDler();
20
- await removeDistFolders(
21
- config.distNpmDirName,
22
- config.distJsrDirName,
23
- config.libsDirDist,
24
- config.libsList
25
- );
26
- await dlerPub(args.dev, config);
20
+ const { timer } = await dlerBuild(args.dev, config);
21
+ await finalizeBuild(timer, false, "build");
27
22
  }
28
23
  });
@@ -1,7 +1,10 @@
1
1
  import type { DlerConfig } from "../../libs/sdk/sdk-impl/config/types.js";
2
2
  /**
3
- * Main entry point for the dler build and publish process.
4
- * Handles building and publishing for both main project and libraries.
3
+ * Main entry point for the dler build process.
4
+ * Handles building for both main project and libraries.
5
5
  * @see `src/app/pub/impl.ts` for pub main function implementation.
6
6
  */
7
- export declare function dlerBuild(isDev: boolean, config?: DlerConfig): Promise<void>;
7
+ export declare function dlerBuild(isDev: boolean, config?: DlerConfig): Promise<{
8
+ timer: any;
9
+ effectiveConfig: any;
10
+ } | undefined>;
@@ -1,14 +1,14 @@
1
- import { bumpHandler, isBumpDisabled, setBumpDisabledValueTo } from "@reliverse/bleump";
2
1
  import path from "@reliverse/pathkit";
3
2
  import fs from "@reliverse/relifso";
4
3
  import { getConfigDler } from "../../libs/sdk/sdk-impl/config/load.js";
5
- import { processLibraryFlow } from "../../libs/sdk/sdk-impl/library-flow.js";
6
- import { processRegularFlow } from "../../libs/sdk/sdk-impl/regular-flow.js";
7
- import { finalizeBuildPub } from "../../libs/sdk/sdk-impl/utils/finalize.js";
4
+ import { library_buildFlow } from "../../libs/sdk/sdk-impl/library-flow.js";
5
+ import { regular_buildFlow } from "../../libs/sdk/sdk-impl/regular-flow.js";
8
6
  import { removeDistFolders } from "../../libs/sdk/sdk-impl/utils/utils-clean.js";
9
7
  import { PROJECT_ROOT } from "../../libs/sdk/sdk-impl/utils/utils-consts.js";
10
8
  import { handleDlerError } from "../../libs/sdk/sdk-impl/utils/utils-error-cwd.js";
11
9
  import { createPerfTimer } from "../../libs/sdk/sdk-impl/utils/utils-perf.js";
10
+ import { dlerPostBuild } from "./postbuild.js";
11
+ import { dlerPreBuild } from "./prebuild.js";
12
12
  export async function dlerBuild(isDev, config) {
13
13
  const timer = createPerfTimer();
14
14
  let effectiveConfig = config;
@@ -25,30 +25,22 @@ export async function dlerBuild(isDev, config) {
25
25
  effectiveConfig.libsDirDist,
26
26
  effectiveConfig.libsList
27
27
  );
28
- try {
29
- const bumpIsDisabled = await isBumpDisabled();
30
- if (!bumpIsDisabled && !effectiveConfig.commonPubPause) {
31
- await bumpHandler(
32
- effectiveConfig.bumpMode,
33
- false,
34
- effectiveConfig.bumpFilter,
35
- effectiveConfig.bumpSet
36
- );
37
- await setBumpDisabledValueTo(true);
38
- }
39
- } catch {
40
- throw new Error("[.config/dler.ts] Failed to set bumpDisable to true");
41
- }
42
- await processRegularFlow(timer, isDev, effectiveConfig);
43
- await processLibraryFlow(timer, isDev, effectiveConfig);
44
- await finalizeBuildPub(
45
- timer,
46
- effectiveConfig.commonPubPause,
47
- effectiveConfig.libsList,
48
- effectiveConfig.distNpmDirName,
49
- effectiveConfig.distJsrDirName,
50
- effectiveConfig.libsDirDist
51
- );
28
+ await dlerPreBuild(effectiveConfig);
29
+ const tempDirs = {
30
+ npm: "dist-tmp/tmp-npm",
31
+ jsr: "dist-tmp/tmp-jsr",
32
+ libs: "dist-tmp/tmp-libs"
33
+ };
34
+ const tempConfig = {
35
+ ...effectiveConfig,
36
+ coreEntrySrcDir: tempDirs.npm,
37
+ libsDirSrc: tempDirs.libs
38
+ };
39
+ await regular_buildFlow(timer, isDev, tempConfig);
40
+ await library_buildFlow(timer, isDev, tempConfig);
41
+ await dlerPostBuild(isDev);
42
+ await fs.remove(path.join(PROJECT_ROOT, "dist-tmp"));
43
+ return { timer, effectiveConfig };
52
44
  } catch (error) {
53
45
  handleDlerError(error);
54
46
  }
@@ -0,0 +1 @@
1
+ export declare function dlerPostBuild(isDev: boolean): Promise<void>;
@@ -0,0 +1,109 @@
1
+ import path, { convertImportsAliasToRelative } from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
+ import { relinka } from "@reliverse/relinka";
4
+ import { runCmd } from "@reliverse/rempts";
5
+ import { glob } from "tinyglobby";
6
+ import { getCheckCmd } from "../cmds.js";
7
+ import { getConfigDler } from "../../libs/sdk/sdk-impl/config/load.js";
8
+ import { applyMagicSpells } from "../../libs/sdk/sdk-impl/magic/ms-apply.js";
9
+ import { resolveAllCrossLibs } from "../../libs/sdk/sdk-impl/utils/resolve-cross-libs.js";
10
+ import { PROJECT_ROOT } from "../../libs/sdk/sdk-impl/utils/utils-consts.js";
11
+ import { directoryExists, executeDlerHooks } from "./ppb-utils.js";
12
+ const DIST_DIRECTORIES = ["dist-npm", "dist-jsr"];
13
+ const ALIAS_TO_REPLACE = "~";
14
+ const createPostBuildToolRunner = () => ({
15
+ "dler-check": {
16
+ name: "Dler Check",
17
+ async run() {
18
+ const checkCmd = await getCheckCmd();
19
+ await runCmd(checkCmd, ["--no-exit", "--no-progress"]);
20
+ }
21
+ }
22
+ });
23
+ async function processDistDirectory(dir, alias) {
24
+ try {
25
+ const binDir = path.join(dir, "bin");
26
+ if (await directoryExists(binDir)) {
27
+ await convertImportsAliasToRelative({
28
+ targetDir: binDir,
29
+ aliasToReplace: alias,
30
+ pathExtFilter: "js-ts-none"
31
+ });
32
+ }
33
+ } catch (error) {
34
+ const errorMessage = error instanceof Error ? error.message : String(error);
35
+ throw error;
36
+ }
37
+ }
38
+ async function processDistDirectories() {
39
+ for (const dir of DIST_DIRECTORIES) {
40
+ relinka("log", `[processDistDirectory] ${dir}`);
41
+ await processDistDirectory(dir, ALIAS_TO_REPLACE);
42
+ }
43
+ }
44
+ async function copyNonBuildFiles(srcDir, distDir, preExtensions, templatesDir) {
45
+ try {
46
+ const files = await glob("**/*", {
47
+ cwd: srcDir,
48
+ onlyFiles: true
49
+ });
50
+ for (const file of files) {
51
+ const ext = path.extname(file).slice(1);
52
+ const isInTemplatesDir = file.startsWith(templatesDir);
53
+ if (isInTemplatesDir || !preExtensions.includes(ext)) {
54
+ const srcPath = path.join(srcDir, file);
55
+ const destPath = path.join(distDir, file);
56
+ await fs.ensureDir(path.dirname(destPath));
57
+ await fs.copy(srcPath, destPath);
58
+ }
59
+ }
60
+ } catch (error) {
61
+ relinka(
62
+ "error",
63
+ `Error copying non-build files: ${error instanceof Error ? error.message : String(error)}`
64
+ );
65
+ throw error;
66
+ }
67
+ }
68
+ export async function dlerPostBuild(isDev) {
69
+ relinka("info", "\u2014 \u2014 \u2014 dlerPostBuild \u2014 \u2014 \u2014");
70
+ const config = await getConfigDler();
71
+ await resolveAllCrossLibs();
72
+ if (config.commonPubRegistry === "npm" || config.commonPubRegistry === "npm-jsr") {
73
+ await copyNonBuildFiles(
74
+ path.join(PROJECT_ROOT, config.coreEntrySrcDir),
75
+ path.join(PROJECT_ROOT, config.distNpmDirName),
76
+ config.buildPreExtensions,
77
+ config.buildTemplatesDir
78
+ );
79
+ }
80
+ if (config.commonPubRegistry === "jsr" || config.commonPubRegistry === "npm-jsr") {
81
+ await copyNonBuildFiles(
82
+ path.join(PROJECT_ROOT, config.coreEntrySrcDir),
83
+ path.join(PROJECT_ROOT, config.distJsrDirName),
84
+ config.buildPreExtensions,
85
+ config.buildTemplatesDir
86
+ );
87
+ }
88
+ if (config.libsActMode === "libs-only" || config.libsActMode === "main-and-libs") {
89
+ await copyNonBuildFiles(
90
+ path.join(PROJECT_ROOT, config.libsDirSrc),
91
+ path.join(PROJECT_ROOT, config.libsDirDist),
92
+ config.buildPreExtensions,
93
+ config.buildTemplatesDir
94
+ );
95
+ }
96
+ if (isDev) {
97
+ await applyMagicSpells(["dist-jsr", "dist-npm", "dist-libs"]);
98
+ }
99
+ await processDistDirectories();
100
+ await executeDlerHooks(config?.hooksAfterBuild ?? [], "post-build");
101
+ if (config?.runAfterBuild?.length) {
102
+ const tools = createPostBuildToolRunner();
103
+ const availableTools = config.runAfterBuild.filter((toolName) => toolName in tools).map((toolName) => ({ toolName, ...tools[toolName] }));
104
+ for (const { name, run } of availableTools) {
105
+ relinka("log", `Running ${name}...`);
106
+ await run();
107
+ }
108
+ }
109
+ }
@@ -0,0 +1,16 @@
1
+ export type PackageManager = "bun" | "npm" | "yarn" | "pnpm";
2
+ export declare function getPackageManager(): Promise<PackageManager>;
3
+ /**
4
+ * Checks if a command is available in the system or package.json
5
+ * First checks package.json dependencies, then falls back to global command detection
6
+ */
7
+ export declare function isCommandAvailable(command: string): Promise<boolean>;
8
+ /**
9
+ * Executes a shell command using the appropriate method based on the environment
10
+ */
11
+ export declare function executeCommand(command: string): Promise<void>;
12
+ export declare function directoryExists(dirPath: string): Promise<boolean>;
13
+ /**
14
+ * Executes hooks with consistent error handling and logging
15
+ */
16
+ export declare function executeDlerHooks(hooks: (() => Promise<void>)[], phase: "pre-build" | "post-build"): Promise<void>;
@@ -0,0 +1,99 @@
1
+ import fs from "@reliverse/relifso";
2
+ import { relinka } from "@reliverse/relinka";
3
+ import { selectPrompt } from "@reliverse/rempts";
4
+ import { $ } from "bun";
5
+ import { execa } from "execa";
6
+ import { lookpath } from "lookpath";
7
+ import { readPackageJSON } from "pkg-types";
8
+ const COMMAND_TO_PACKAGE = {
9
+ tsc: "typescript",
10
+ eslint: "eslint",
11
+ biome: "@biomejs/biome",
12
+ knip: "knip"
13
+ };
14
+ let selectedPackageManager = null;
15
+ export async function getPackageManager() {
16
+ if (selectedPackageManager) return selectedPackageManager;
17
+ if (process.versions.bun) {
18
+ selectedPackageManager = "bun";
19
+ return selectedPackageManager;
20
+ }
21
+ const result = await selectPrompt({
22
+ title: "Select package manager to use for running tools:",
23
+ options: [
24
+ { label: "npm", value: "npm" },
25
+ { label: "yarn", value: "yarn" },
26
+ { label: "pnpm", value: "pnpm" }
27
+ ]
28
+ });
29
+ selectedPackageManager = result;
30
+ return selectedPackageManager;
31
+ }
32
+ async function isCommandInPackageJson(command) {
33
+ try {
34
+ const packageJson = await readPackageJSON();
35
+ const packageName = COMMAND_TO_PACKAGE[command];
36
+ if (!packageName) return false;
37
+ return packageName in (packageJson.dependencies || {}) || packageName in (packageJson.devDependencies || {});
38
+ } catch (error) {
39
+ return false;
40
+ }
41
+ }
42
+ export async function isCommandAvailable(command) {
43
+ const packageName = COMMAND_TO_PACKAGE[command];
44
+ if (!packageName) return false;
45
+ if (await isCommandInPackageJson(command)) {
46
+ relinka("verbose", `[dlerPreBuild] Package "${packageName}" found in package.json`);
47
+ return true;
48
+ }
49
+ relinka(
50
+ "warn",
51
+ `[dlerPreBuild] Package "${packageName}" not found in package.json. Consider installing it as a dependency.`
52
+ );
53
+ return await lookpath(command) !== void 0;
54
+ }
55
+ export async function executeCommand(command) {
56
+ const [firstWord, ...rest] = command.split(" ").filter(Boolean);
57
+ if (!firstWord) return;
58
+ const pkgManagers = ["bun", "yarn", "pnpm", "npm"];
59
+ const isPkgManager = pkgManagers.includes(firstWord);
60
+ const cmd = isPkgManager ? rest[0] : firstWord;
61
+ const args = isPkgManager ? rest.slice(1) : rest;
62
+ if (!cmd) return;
63
+ const packageName = COMMAND_TO_PACKAGE[cmd];
64
+ if (packageName && await isCommandInPackageJson(cmd)) {
65
+ const pkgManager = isPkgManager ? firstWord : await getPackageManager();
66
+ if (process.versions.bun) {
67
+ await $`${pkgManager} ${cmd} ${args.join(" ")}`;
68
+ } else {
69
+ await execa(pkgManager, [cmd, ...args], { stdio: "inherit" });
70
+ }
71
+ return;
72
+ }
73
+ if (process.versions.bun) {
74
+ await $`${cmd} ${args.join(" ")}`;
75
+ } else {
76
+ await execa(cmd, args, { stdio: "inherit" });
77
+ }
78
+ }
79
+ export async function directoryExists(dirPath) {
80
+ try {
81
+ return (await fs.stat(dirPath)).isDirectory();
82
+ } catch (error) {
83
+ if (error.code === "ENOENT") return false;
84
+ throw error;
85
+ }
86
+ }
87
+ export async function executeDlerHooks(hooks, phase) {
88
+ if (!hooks.length) return;
89
+ relinka("log", `[dlerPreBuild] Running ${phase} hooks...`);
90
+ for (const hook of hooks) {
91
+ try {
92
+ await hook();
93
+ } catch (error) {
94
+ const message = error instanceof Error ? error.message : String(error);
95
+ relinka("error", `[dlerPreBuild] Error in ${phase} hook: ${message}`);
96
+ throw error;
97
+ }
98
+ }
99
+ }
@@ -0,0 +1,2 @@
1
+ import type { DlerConfig } from "../../libs/sdk/sdk-impl/config/types.js";
2
+ export declare function dlerPreBuild(config: DlerConfig): Promise<void>;
@@ -0,0 +1,112 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
+ import { relinka } from "@reliverse/relinka";
4
+ import { runCmd } from "@reliverse/rempts";
5
+ import { glob } from "tinyglobby";
6
+ import { getCheckCmd } from "../cmds.js";
7
+ import { PROJECT_ROOT } from "../../libs/sdk/sdk-impl/utils/utils-consts.js";
8
+ import { executeCommand, executeDlerHooks, isCommandAvailable } from "./ppb-utils.js";
9
+ const createToolRunner = () => ({
10
+ tsc: {
11
+ name: "TypeScript compiler",
12
+ run: () => executeCommand("tsc --noEmit")
13
+ },
14
+ eslint: {
15
+ name: "ESLint",
16
+ run: () => executeCommand("eslint --cache --fix .")
17
+ },
18
+ biome: {
19
+ name: "Biome",
20
+ run: () => executeCommand("biome check --fix --unsafe .")
21
+ },
22
+ knip: {
23
+ name: "Knip",
24
+ run: () => executeCommand("knip")
25
+ },
26
+ "dler-check": {
27
+ name: "Dler Check",
28
+ async run() {
29
+ const checkCmd = await getCheckCmd();
30
+ await runCmd(checkCmd, ["--no-exit", "--no-progress"]);
31
+ }
32
+ }
33
+ });
34
+ async function copyFilesToTempDir(srcDir, tempDir, extensions, excludeDir) {
35
+ try {
36
+ await fs.ensureDir(tempDir);
37
+ const files = await glob("**/*", {
38
+ cwd: srcDir,
39
+ ignore: [`**/${excludeDir}/**`],
40
+ onlyFiles: true
41
+ });
42
+ for (const file of files) {
43
+ const ext = path.extname(file).slice(1);
44
+ if (extensions.includes(ext)) {
45
+ const srcPath = path.join(srcDir, file);
46
+ const destPath = path.join(tempDir, file);
47
+ await fs.ensureDir(path.dirname(destPath));
48
+ await fs.copy(srcPath, destPath);
49
+ }
50
+ }
51
+ } catch (error) {
52
+ relinka(
53
+ "error",
54
+ `Error copying files to temp directory: ${error instanceof Error ? error.message : String(error)}`
55
+ );
56
+ throw error;
57
+ }
58
+ }
59
+ export async function dlerPreBuild(config) {
60
+ relinka("info", "\u2014 \u2014 \u2014 dlerPreBuild \u2014 \u2014 \u2014");
61
+ await executeDlerHooks(config?.hooksBeforeBuild ?? [], "pre-build");
62
+ const tempDirs = {
63
+ npm: path.join(PROJECT_ROOT, "dist-tmp", "tmp-npm"),
64
+ jsr: path.join(PROJECT_ROOT, "dist-tmp", "tmp-jsr"),
65
+ libs: path.join(PROJECT_ROOT, "dist-tmp", "tmp-libs")
66
+ };
67
+ for (const dir of Object.values(tempDirs)) {
68
+ await fs.remove(dir);
69
+ }
70
+ if (config.commonPubRegistry === "npm" || config.commonPubRegistry === "npm-jsr") {
71
+ await copyFilesToTempDir(
72
+ path.join(PROJECT_ROOT, config.coreEntrySrcDir),
73
+ tempDirs.npm,
74
+ config.buildPreExtensions,
75
+ config.buildTemplatesDir
76
+ );
77
+ }
78
+ if (config.commonPubRegistry === "jsr" || config.commonPubRegistry === "npm-jsr") {
79
+ await copyFilesToTempDir(
80
+ path.join(PROJECT_ROOT, config.coreEntrySrcDir),
81
+ tempDirs.jsr,
82
+ config.buildPreExtensions,
83
+ config.buildTemplatesDir
84
+ );
85
+ }
86
+ if (config.libsActMode === "libs-only" || config.libsActMode === "main-and-libs") {
87
+ await copyFilesToTempDir(
88
+ path.join(PROJECT_ROOT, config.libsDirSrc),
89
+ tempDirs.libs,
90
+ config.buildPreExtensions,
91
+ config.buildTemplatesDir
92
+ );
93
+ }
94
+ if (!config?.runBeforeBuild?.length) return;
95
+ const tools = createToolRunner();
96
+ const availableTools = await Promise.all(
97
+ config.runBeforeBuild.map(async (toolName) => {
98
+ const tool = tools[toolName];
99
+ if (!tool) return null;
100
+ if (toolName === "dler-check") {
101
+ return { toolName, ...tool };
102
+ }
103
+ const isAvailable = await isCommandAvailable(toolName);
104
+ return isAvailable ? { toolName, ...tool } : null;
105
+ })
106
+ );
107
+ const commandsToRun = availableTools.filter(Boolean);
108
+ for (const { name, run } of commandsToRun) {
109
+ relinka("log", `Running ${name}...`);
110
+ await run();
111
+ }
112
+ }
@@ -15,6 +15,14 @@ declare const _default: import("@reliverse/rempts").Command<{
15
15
  type: "boolean";
16
16
  description: string;
17
17
  };
18
+ "no-exit": {
19
+ type: "boolean";
20
+ description: string;
21
+ };
22
+ "no-progress": {
23
+ type: "boolean";
24
+ description: string;
25
+ };
18
26
  deps: {
19
27
  type: "boolean";
20
28
  description: string;