@reliverse/dler 1.6.5 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +92 -10
  2. package/bin/app/build/cmd.js +1 -1
  3. package/bin/app/build/impl.js +1 -1
  4. package/bin/app/check/cmd.d.ts +0 -3
  5. package/bin/app/check/cmd.js +68 -351
  6. package/bin/app/cmds.d.ts +21 -437
  7. package/bin/app/cmds.js +38 -22
  8. package/bin/app/deps/cmd.js +2 -2
  9. package/bin/app/migrate/cmd.d.ts +12 -2
  10. package/bin/app/migrate/cmd.js +105 -58
  11. package/bin/app/migrate/codemods/anything-to-bun.d.ts +5 -0
  12. package/bin/app/migrate/codemods/anything-to-bun.js +597 -0
  13. package/bin/app/migrate/codemods/fs-to-relifso.d.ts +8 -0
  14. package/bin/app/migrate/codemods/fs-to-relifso.js +179 -0
  15. package/bin/app/migrate/codemods/path-to-pathkit.d.ts +8 -0
  16. package/bin/app/migrate/codemods/{lib-pathe-pathkit.js → path-to-pathkit.js} +22 -111
  17. package/bin/app/pub/cmd.js +1 -1
  18. package/bin/app/rempts/cmd/cmd.js +10 -3
  19. package/bin/cli.js +14 -4
  20. package/bin/libs/sdk/sdk-impl/build/build-library.js +23 -19
  21. package/bin/libs/sdk/sdk-impl/build/build-regular.js +13 -13
  22. package/bin/libs/sdk/sdk-impl/check/check-consts.d.ts +29 -0
  23. package/bin/libs/sdk/sdk-impl/check/check-consts.js +48 -0
  24. package/bin/libs/sdk/sdk-impl/check/check-mod.d.ts +2 -0
  25. package/bin/libs/sdk/sdk-impl/check/check-mod.js +87 -0
  26. package/bin/libs/sdk/sdk-impl/check/check-utils.d.ts +5 -0
  27. package/bin/libs/sdk/sdk-impl/check/check-utils.js +56 -0
  28. package/bin/libs/sdk/sdk-impl/check/rules/dler-config-health.d.ts +2 -0
  29. package/bin/libs/sdk/sdk-impl/check/rules/dler-config-health.js +37 -0
  30. package/bin/libs/sdk/sdk-impl/check/rules/file-extensions.d.ts +2 -0
  31. package/bin/libs/sdk/sdk-impl/check/rules/file-extensions.js +69 -0
  32. package/bin/{app/deps/impl/wrapper.d.ts → libs/sdk/sdk-impl/check/rules/missing-deps.d.ts} +1 -1
  33. package/bin/{app/deps/impl/wrapper.js → libs/sdk/sdk-impl/check/rules/missing-deps.js} +2 -2
  34. package/bin/libs/sdk/sdk-impl/check/rules/package-json-health.d.ts +2 -0
  35. package/bin/libs/sdk/sdk-impl/check/rules/package-json-health.js +67 -0
  36. package/bin/libs/sdk/sdk-impl/check/rules/path-extensions.d.ts +2 -0
  37. package/bin/libs/sdk/sdk-impl/check/rules/path-extensions.js +93 -0
  38. package/bin/libs/sdk/sdk-impl/check/rules/self-include.d.ts +2 -0
  39. package/bin/libs/sdk/sdk-impl/check/rules/self-include.js +98 -0
  40. package/bin/libs/sdk/sdk-impl/check/rules/tsconfig-health.d.ts +2 -0
  41. package/bin/libs/sdk/sdk-impl/check/rules/tsconfig-health.js +35 -0
  42. package/bin/libs/sdk/{default.d.ts → sdk-impl/config/default.d.ts} +1 -1
  43. package/bin/libs/sdk/{default.js → sdk-impl/config/default.js} +15 -5
  44. package/bin/libs/sdk/sdk-impl/config/define.d.ts +2 -0
  45. package/bin/libs/sdk/sdk-impl/config/define.js +4 -0
  46. package/bin/{init → libs/sdk/sdk-impl/config}/info.js +1 -1
  47. package/bin/{init → libs/sdk/sdk-impl/config}/init.js +9 -8
  48. package/bin/{init → libs/sdk/sdk-impl/config}/load.d.ts +2 -1
  49. package/bin/{init → libs/sdk/sdk-impl/config}/load.js +15 -6
  50. package/bin/libs/sdk/sdk-impl/library-flow.d.ts +1 -1
  51. package/bin/libs/sdk/sdk-impl/library-flow.js +3 -3
  52. package/bin/libs/sdk/sdk-impl/spell/spell-executors.js +1 -1
  53. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.d.ts +1 -1
  54. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +7 -1
  55. package/bin/libs/sdk/sdk-impl/utils/utils-build.d.ts +8 -2
  56. package/bin/libs/sdk/sdk-impl/utils/utils-build.js +5 -5
  57. package/bin/libs/sdk/sdk-impl/utils/utils-deps.js +55 -15
  58. package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +20 -8
  59. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.d.ts +2 -1
  60. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +15 -4
  61. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.d.ts +5 -0
  62. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.js +98 -29
  63. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.js +12 -5
  64. package/bin/libs/sdk/sdk-types.d.ts +67 -33
  65. package/bin/mod.d.ts +1 -2
  66. package/bin/mod.js +1 -4
  67. package/package.json +1 -1
  68. package/bin/app/migrate/codemods/lib-pathe-pathkit.d.ts +0 -9
  69. /package/bin/app/migrate/codemods/{ts-module-resolution.d.ts → module-resolution.d.ts} +0 -0
  70. /package/bin/app/migrate/codemods/{ts-module-resolution.js → module-resolution.js} +0 -0
  71. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/analyzer.d.ts +0 -0
  72. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/analyzer.js +0 -0
  73. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/deps-types.d.ts +0 -0
  74. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/deps-types.js +0 -0
  75. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/filesystem.d.ts +0 -0
  76. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/filesystem.js +0 -0
  77. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/formatter.d.ts +0 -0
  78. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/formatter.js +0 -0
  79. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/parser.d.ts +0 -0
  80. /package/bin/{app/deps/impl → libs/sdk/sdk-impl/check/rules/deps}/parser.js +0 -0
  81. /package/bin/{init → libs/sdk/sdk-impl/config}/info.d.ts +0 -0
  82. /package/bin/{init → libs/sdk/sdk-impl/config}/init.d.ts +0 -0
@@ -0,0 +1,179 @@
1
+ import { existsSync } from "node:fs";
2
+ import { readFile, writeFile, readdir, stat } from "node:fs/promises";
3
+ import { join, extname } from "node:path";
4
+ async function getAllTsFiles(dir) {
5
+ const files = [];
6
+ try {
7
+ const entries = await readdir(dir);
8
+ for (const entry of entries) {
9
+ const fullPath = join(dir, entry);
10
+ const stats = await stat(fullPath);
11
+ if (stats.isDirectory() && !entry.startsWith(".") && entry !== "node_modules") {
12
+ const subFiles = await getAllTsFiles(fullPath);
13
+ files.push(...subFiles);
14
+ } else if (stats.isFile()) {
15
+ const ext = extname(entry);
16
+ if ([".ts", ".tsx", ".js", ".jsx", ".vue", ".svelte"].includes(ext)) {
17
+ files.push(fullPath);
18
+ }
19
+ }
20
+ }
21
+ } catch {
22
+ }
23
+ return files;
24
+ }
25
+ export async function migrateFsToRelifso(dryRun = false) {
26
+ const results = [];
27
+ const files = await getAllTsFiles(".");
28
+ for (const file of files) {
29
+ try {
30
+ const content = await readFile(file, "utf-8");
31
+ let modified = content;
32
+ const changes = [];
33
+ const nodeFsImportRegex = /import\s+(?:(\{[^}]*\})|(\w+))\s+from\s+["']node:fs["']/g;
34
+ if (nodeFsImportRegex.test(content)) {
35
+ modified = modified.replace(
36
+ nodeFsImportRegex,
37
+ (match, namedExports, defaultExport) => {
38
+ if (namedExports) {
39
+ return `import ${namedExports} from "@reliverse/relifso"`;
40
+ }
41
+ return `import ${defaultExport} from "@reliverse/relifso"`;
42
+ }
43
+ );
44
+ changes.push("Updated node:fs imports to @reliverse/relifso");
45
+ }
46
+ const nodeFsPromisesImportRegex = /import\s+(?:(\{[^}]*\})|(\w+))\s+from\s+["']node:fs\/promises["']/g;
47
+ if (nodeFsPromisesImportRegex.test(content)) {
48
+ modified = modified.replace(
49
+ nodeFsPromisesImportRegex,
50
+ (match, namedExports, defaultExport) => {
51
+ if (namedExports) {
52
+ return `import ${namedExports} from "@reliverse/relifso"`;
53
+ }
54
+ return `import ${defaultExport} from "@reliverse/relifso"`;
55
+ }
56
+ );
57
+ changes.push("Updated node:fs/promises imports to @reliverse/relifso");
58
+ }
59
+ const fsExtraImportRegex = /import\s+(?:(\{[^}]*\})|(\w+))\s+from\s+["']fs-extra["']/g;
60
+ if (fsExtraImportRegex.test(content)) {
61
+ modified = modified.replace(
62
+ fsExtraImportRegex,
63
+ (match, namedExports, defaultExport) => {
64
+ if (namedExports) {
65
+ return `import ${namedExports} from "@reliverse/relifso"`;
66
+ }
67
+ return `import ${defaultExport} from "@reliverse/relifso"`;
68
+ }
69
+ );
70
+ changes.push("Updated fs-extra imports to @reliverse/relifso");
71
+ }
72
+ const nodeFsRequireRegex = /require\s*\(\s*["']node:fs["']\s*\)/g;
73
+ if (nodeFsRequireRegex.test(content)) {
74
+ modified = modified.replace(
75
+ nodeFsRequireRegex,
76
+ 'require("@reliverse/relifso")'
77
+ );
78
+ changes.push("Updated node:fs require to @reliverse/relifso");
79
+ }
80
+ const nodeFsPromisesRequireRegex = /require\s*\(\s*["']node:fs\/promises["']\s*\)/g;
81
+ if (nodeFsPromisesRequireRegex.test(content)) {
82
+ modified = modified.replace(
83
+ nodeFsPromisesRequireRegex,
84
+ 'require("@reliverse/relifso")'
85
+ );
86
+ changes.push("Updated node:fs/promises require to @reliverse/relifso");
87
+ }
88
+ const fsExtraRequireRegex = /require\s*\(\s*["']fs-extra["']\s*\)/g;
89
+ if (fsExtraRequireRegex.test(content)) {
90
+ modified = modified.replace(
91
+ fsExtraRequireRegex,
92
+ 'require("@reliverse/relifso")'
93
+ );
94
+ changes.push("Updated fs-extra require to @reliverse/relifso");
95
+ }
96
+ if (changes.length > 0) {
97
+ if (!dryRun) {
98
+ await writeFile(file, modified, "utf-8");
99
+ }
100
+ results.push({
101
+ file,
102
+ success: true,
103
+ message: `${changes.length} change(s) made`,
104
+ changes
105
+ });
106
+ }
107
+ } catch (error) {
108
+ results.push({
109
+ file,
110
+ success: false,
111
+ message: `Failed to process: ${error instanceof Error ? error.message : String(error)}`
112
+ });
113
+ }
114
+ }
115
+ await updatePackageJson(results, dryRun, {
116
+ remove: ["fs-extra"],
117
+ add: { "@reliverse/relifso": "^latest" }
118
+ });
119
+ return results;
120
+ }
121
+ async function updatePackageJson(results, dryRun, config) {
122
+ try {
123
+ const packageJsonPath = "./package.json";
124
+ if (existsSync(packageJsonPath)) {
125
+ const packageContent = await readFile(packageJsonPath, "utf-8");
126
+ const packageJson = JSON.parse(packageContent);
127
+ let packageChanged = false;
128
+ const packageChanges = [];
129
+ for (const pkg of config.remove) {
130
+ if (packageJson.dependencies?.[pkg]) {
131
+ packageJson.dependencies = Object.fromEntries(
132
+ Object.entries(packageJson.dependencies).filter(
133
+ ([key]) => key !== pkg
134
+ )
135
+ );
136
+ packageChanged = true;
137
+ packageChanges.push(`Removed ${pkg} from dependencies`);
138
+ }
139
+ if (packageJson.devDependencies?.[pkg]) {
140
+ packageJson.devDependencies = Object.fromEntries(
141
+ Object.entries(packageJson.devDependencies).filter(
142
+ ([key]) => key !== pkg
143
+ )
144
+ );
145
+ packageChanged = true;
146
+ packageChanges.push(`Removed ${pkg} from devDependencies`);
147
+ }
148
+ }
149
+ for (const [pkg, version] of Object.entries(config.add)) {
150
+ if (packageChanged && !packageJson.dependencies?.[pkg]) {
151
+ if (!packageJson.dependencies) packageJson.dependencies = {};
152
+ packageJson.dependencies[pkg] = version;
153
+ packageChanges.push(`Added ${pkg} to dependencies`);
154
+ }
155
+ }
156
+ if (packageChanged) {
157
+ if (!dryRun) {
158
+ await writeFile(
159
+ packageJsonPath,
160
+ JSON.stringify(packageJson, null, 2) + "\n",
161
+ "utf-8"
162
+ );
163
+ }
164
+ results.push({
165
+ file: packageJsonPath,
166
+ success: true,
167
+ message: `${packageChanges.length} change(s) made`,
168
+ changes: packageChanges
169
+ });
170
+ }
171
+ }
172
+ } catch (error) {
173
+ results.push({
174
+ file: "./package.json",
175
+ success: false,
176
+ message: `Failed to update package.json: ${error instanceof Error ? error.message : String(error)}`
177
+ });
178
+ }
179
+ }
@@ -0,0 +1,8 @@
1
+ type MigrationResult = {
2
+ file: string;
3
+ success: boolean;
4
+ message: string;
5
+ changes?: string[];
6
+ };
7
+ export declare function migratePathToPathkit(dryRun?: boolean): Promise<MigrationResult[]>;
8
+ export {};
@@ -22,7 +22,7 @@ async function getAllTsFiles(dir) {
22
22
  }
23
23
  return files;
24
24
  }
25
- export async function migratePatheToPathkit(dryRun = false) {
25
+ export async function migratePathToPathkit(dryRun = false) {
26
26
  const results = [];
27
27
  const files = await getAllTsFiles(".");
28
28
  for (const file of files) {
@@ -46,6 +46,19 @@ export async function migratePatheToPathkit(dryRun = false) {
46
46
  );
47
47
  changes.push("Updated pathe/utils imports to @reliverse/pathkit");
48
48
  }
49
+ const nodePathImportRegex = /import\s+(?:(\{[^}]*\})|(\w+))\s+from\s+["']node:path["']/g;
50
+ if (nodePathImportRegex.test(content)) {
51
+ modified = modified.replace(
52
+ nodePathImportRegex,
53
+ (match, namedExports, defaultExport) => {
54
+ if (namedExports) {
55
+ return `import ${namedExports} from "@reliverse/pathkit"`;
56
+ }
57
+ return `import ${defaultExport} from "@reliverse/pathkit"`;
58
+ }
59
+ );
60
+ changes.push("Updated node:path imports to @reliverse/pathkit");
61
+ }
49
62
  const patheRequireRegex = /require\s*\(\s*["']pathe["']\s*\)/g;
50
63
  if (patheRequireRegex.test(content)) {
51
64
  modified = modified.replace(
@@ -62,115 +75,13 @@ export async function migratePatheToPathkit(dryRun = false) {
62
75
  );
63
76
  changes.push("Updated pathe/utils require to @reliverse/pathkit");
64
77
  }
65
- if (changes.length > 0) {
66
- if (!dryRun) {
67
- await writeFile(file, modified, "utf-8");
68
- }
69
- results.push({
70
- file,
71
- success: true,
72
- message: `${changes.length} change(s) made`,
73
- changes
74
- });
75
- }
76
- } catch (error) {
77
- results.push({
78
- file,
79
- success: false,
80
- message: `Failed to process: ${error instanceof Error ? error.message : String(error)}`
81
- });
82
- }
83
- }
84
- await updatePackageJson(results, dryRun, {
85
- remove: ["pathe"],
86
- add: { "@reliverse/pathkit": "^latest" }
87
- });
88
- return results;
89
- }
90
- export async function migratePathkitToPathe(dryRun = false) {
91
- const results = [];
92
- const files = await getAllTsFiles(".");
93
- for (const file of files) {
94
- try {
95
- const content = await readFile(file, "utf-8");
96
- let modified = content;
97
- const changes = [];
98
- const pathkitImportRegex = /from\s+["']@reliverse\/pathkit["']/g;
99
- if (pathkitImportRegex.test(content)) {
100
- const advancedFeatures = [
101
- "getFileImportsExports",
102
- "convertImportPaths",
103
- "convertImportExtensionsJsToTs",
104
- "normalizeAliases",
105
- "resolveAlias",
106
- "reverseResolveAlias",
107
- "normalizeQuotes"
108
- ];
109
- const usesAdvancedFeatures = advancedFeatures.some(
110
- (feature) => content.includes(feature)
78
+ const nodePathRequireRegex = /require\s*\(\s*["']node:path["']\s*\)/g;
79
+ if (nodePathRequireRegex.test(content)) {
80
+ modified = modified.replace(
81
+ nodePathRequireRegex,
82
+ 'require("@reliverse/pathkit")'
111
83
  );
112
- if (usesAdvancedFeatures) {
113
- changes.push(
114
- "\u26A0\uFE0F File uses advanced pathkit features - manual review needed"
115
- );
116
- results.push({
117
- file,
118
- success: false,
119
- message: "Contains advanced pathkit features not available in pathe",
120
- changes
121
- });
122
- continue;
123
- }
124
- const utilsPattern = /import\s*\{([^}]+)\}\s*from\s*["']@reliverse\/pathkit["']/g;
125
- const utilsMatch = utilsPattern.exec(content);
126
- if (utilsMatch?.[1]) {
127
- const imports = utilsMatch[1].split(",").map((s) => s.trim());
128
- const coreImports = imports.filter(
129
- (imp) => ![
130
- "filename",
131
- "normalizeAliases",
132
- "resolveAlias",
133
- "reverseResolveAlias"
134
- ].includes(imp.replace(/\s+as\s+\w+/, ""))
135
- );
136
- const utilImports = imports.filter(
137
- (imp) => [
138
- "filename",
139
- "normalizeAliases",
140
- "resolveAlias",
141
- "reverseResolveAlias"
142
- ].includes(imp.replace(/\s+as\s+\w+/, ""))
143
- );
144
- if (coreImports.length > 0 && utilImports.length > 0) {
145
- const coreImportStatement = `import { ${coreImports.join(", ")} } from "pathe";`;
146
- const utilImportStatement = `import { ${utilImports.join(", ")} } from "pathe/utils";`;
147
- modified = modified.replace(
148
- utilsMatch[0],
149
- `${coreImportStatement}
150
- ${utilImportStatement}`
151
- );
152
- changes.push(
153
- "Split pathkit imports into pathe core and pathe/utils"
154
- );
155
- } else if (utilImports.length > 0) {
156
- modified = modified.replace(
157
- pathkitImportRegex,
158
- 'from "pathe/utils"'
159
- );
160
- changes.push("Updated pathkit utils imports to pathe/utils");
161
- } else {
162
- modified = modified.replace(pathkitImportRegex, 'from "pathe"');
163
- changes.push("Updated pathkit imports to pathe");
164
- }
165
- } else {
166
- modified = modified.replace(pathkitImportRegex, 'from "pathe"');
167
- changes.push("Updated pathkit imports to pathe");
168
- }
169
- }
170
- const pathkitRequireRegex = /require\s*\(\s*["']@reliverse\/pathkit["']\s*\)/g;
171
- if (pathkitRequireRegex.test(content)) {
172
- modified = modified.replace(pathkitRequireRegex, 'require("pathe")');
173
- changes.push("Updated pathkit require to pathe");
84
+ changes.push("Updated node:path require to @reliverse/pathkit");
174
85
  }
175
86
  if (changes.length > 0) {
176
87
  if (!dryRun) {
@@ -192,8 +103,8 @@ ${utilImportStatement}`
192
103
  }
193
104
  }
194
105
  await updatePackageJson(results, dryRun, {
195
- remove: ["@reliverse/pathkit"],
196
- add: { pathe: "^latest" }
106
+ remove: ["pathe"],
107
+ add: { "@reliverse/pathkit": "^latest" }
197
108
  });
198
109
  return results;
199
110
  }
@@ -1,6 +1,6 @@
1
1
  import { defineArgs, defineCommand } from "@reliverse/rempts";
2
2
  import { dlerPub } from "../build/impl.js";
3
- import { ensureDlerConfig } from "../../init/init.js";
3
+ import { ensureDlerConfig } from "../../libs/sdk/sdk-impl/config/init.js";
4
4
  export default defineCommand({
5
5
  meta: {
6
6
  name: "build",
@@ -26,6 +26,13 @@ export default defineCommand({
26
26
  }
27
27
  }),
28
28
  async run({ args }) {
29
+ if (!args.init || args.init === "true" || args.init === "false") {
30
+ relinka(
31
+ "error",
32
+ "Please provide at least one command name to initialize"
33
+ );
34
+ return;
35
+ }
29
36
  let cmdNames = [];
30
37
  if (Array.isArray(args.init)) {
31
38
  cmdNames = args.init;
@@ -52,7 +59,7 @@ export default defineCommand({
52
59
  }
53
60
  }
54
61
  if (cmdNames.length === 0) {
55
- relinka("error", "\u274C No command names provided");
62
+ relinka("error", "No command names provided");
56
63
  return;
57
64
  }
58
65
  let cmdsRoot = args.customCmdsRoot;
@@ -79,7 +86,7 @@ export default defineCommand({
79
86
  if (await fs.pathExists(filePath) && !args.overwrite) {
80
87
  relinka(
81
88
  "warn",
82
- `\u274C Command "${cmdName}" already exists. Use --overwrite to overwrite.`
89
+ `Command "${cmdName}" already exists. Use --overwrite to overwrite.`
83
90
  );
84
91
  continue;
85
92
  }
@@ -124,7 +131,7 @@ async function handleDlerConfig() {
124
131
  }
125
132
  }
126
133
  } else {
127
- relinka("warn", `\u274C ${scriptPath} doesn't use @reliverse/rempts`);
134
+ relinka("warn", `${scriptPath} doesn't use @reliverse/rempts`);
128
135
  cmdsRoot = "src/app";
129
136
  }
130
137
  } else {
package/bin/cli.js CHANGED
@@ -5,12 +5,22 @@ import {
5
5
  defineArgs,
6
6
  selectPrompt,
7
7
  showUsage,
8
- runCmd
8
+ runCmd as remptsRunCmd
9
9
  } from "@reliverse/rempts";
10
10
  import { promptAggCommand } from "./app/agg/run.js";
11
11
  import { getCmdBuild, getCmdPub } from "./app/cmds.js";
12
- import { showEndPrompt, showStartPrompt } from "./init/info.js";
12
+ import {
13
+ showEndPrompt,
14
+ showStartPrompt
15
+ } from "./libs/sdk/sdk-impl/config/info.js";
13
16
  const INTERACTIVE_CMDS = ["agg", "build", "pub"];
17
+ async function runCmd(cmdPromise, args) {
18
+ const cmd = await cmdPromise;
19
+ if (!cmd || typeof cmd !== "object" || !cmd.meta || !cmd.run) {
20
+ throw new Error("Invalid command module: missing required properties");
21
+ }
22
+ return remptsRunCmd(cmd, args);
23
+ }
14
24
  const main = defineCommand({
15
25
  meta: {
16
26
  name: "dler",
@@ -48,10 +58,10 @@ Available interactive commands: ${INTERACTIVE_CMDS.join(", ")}`
48
58
  await promptAggCommand();
49
59
  }
50
60
  if (cmdToRun === "build") {
51
- await runCmd(await getCmdBuild(), [`--dev=${args.dev}`]);
61
+ await runCmd(getCmdBuild(), [`--dev=${args.dev}`]);
52
62
  }
53
63
  if (cmdToRun === "pub") {
54
- await runCmd(await getCmdPub(), [`--dev=${args.dev}`]);
64
+ await runCmd(getCmdPub(), [`--dev=${args.dev}`]);
55
65
  }
56
66
  relinka("log", " ");
57
67
  await showEndPrompt();
@@ -13,8 +13,7 @@ import prettyMilliseconds from "pretty-ms";
13
13
  import { unifiedBuild } from "./bundlers/unified/build.js";
14
14
  import {
15
15
  getBunSourcemapOption,
16
- getUnifiedSourcemapOption,
17
- renameEntryFile
16
+ getUnifiedSourcemapOption
18
17
  } from "../utils/utils-build.js";
19
18
  import { removeLogInternalCalls } from "../utils/utils-clean.js";
20
19
  import {
@@ -37,7 +36,6 @@ import { getElapsedPerfTime } from "../utils/utils-perf.js";
37
36
  import { library_createPackageJSON } from "../utils/utils-pkg-json-libs.js";
38
37
  const BIN_DIR_NAME = "bin";
39
38
  const REPLACEMENT_MARKER = "// dler-replace-me";
40
- const FILES_TO_COPY_ROOT = ["README.md", "LICENSE"];
41
39
  const TYPES_REPLACEMENT_PATH = "src/types.ts";
42
40
  const ALIAS_PREFIX_TO_CONVERT = "~";
43
41
  export async function library_buildLibrary(options) {
@@ -168,6 +166,8 @@ async function library_buildJsrDist(options) {
168
166
  await createJsrJSON(
169
167
  outputDirRootResolved,
170
168
  true,
169
+ options.libsList,
170
+ options,
171
171
  libName,
172
172
  libConfig?.libDescription ?? ""
173
173
  );
@@ -374,7 +374,16 @@ async function library_bundleUsingJsrCopy(srcDir, destDir, libName) {
374
374
  );
375
375
  await fs.ensureDir(destDir);
376
376
  try {
377
- await fs.copy(srcDir, destDir, { overwrite: true });
377
+ const files = await fs.readdir(srcDir, { withFileTypes: true });
378
+ for (const file of files) {
379
+ const srcPath = path.join(srcDir, file.name);
380
+ const destPath = path.join(destDir, file.name);
381
+ if (file.isDirectory()) {
382
+ await fs.copy(srcPath, destPath, { overwrite: true });
383
+ } else {
384
+ await fs.copy(srcPath, destPath, { overwrite: true });
385
+ }
386
+ }
378
387
  relinka(
379
388
  "success",
380
389
  `[JSR Copy:${libName}] Completed copying library source from ${srcDir} to ${destDir}`
@@ -558,7 +567,7 @@ async function library_performCommonBuildSteps(params) {
558
567
  const logPrefix = `[Common:${targetType}:${libName}]`;
559
568
  relinka(
560
569
  "verbose",
561
- `${logPrefix} Performing common steps in ${outputDirRoot}`
570
+ `${logPrefix} Performing common steps in ${outputDirRoot}. Entry file: ${coreEntryFileName}. ${isJsr ? `JSR out files ext: ${distJsrOutFilesExt}` : `NPM out files ext: ${unifiedBundlerOutExt}`}`
562
571
  );
563
572
  await library_createPackageJSON(
564
573
  libName,
@@ -578,10 +587,17 @@ async function library_performCommonBuildSteps(params) {
578
587
  `${logPrefix} Deleted specific files from ${outDirBin}.`
579
588
  );
580
589
  }
581
- await copyRootFile(outputDirRoot, FILES_TO_COPY_ROOT);
590
+ const filesToCopy = isJsr ? config.publishArtifacts?.["dist-libs"]?.[libName]?.jsr || config.publishArtifacts?.["dist-jsr"] || ["jsr.json"] : config.publishArtifacts?.["dist-libs"]?.[libName]?.npm || config.publishArtifacts?.["dist-npm"] || [];
591
+ const globalFiles = config.publishArtifacts?.global || [
592
+ "package.json",
593
+ "README.md",
594
+ "LICENSE"
595
+ ];
596
+ const allFilesToCopy = [.../* @__PURE__ */ new Set([...globalFiles, ...filesToCopy])];
597
+ await copyRootFile(outputDirRoot, allFilesToCopy);
582
598
  relinka(
583
599
  "verbose",
584
- `${logPrefix} Copied root files (${FILES_TO_COPY_ROOT.join(", ")}) to ${outputDirRoot}`
600
+ `${logPrefix} Copied root files (${allFilesToCopy.join(", ")}) to ${outputDirRoot}`
585
601
  );
586
602
  const stripSegments = libDirName ? [`libs/${libDirName}`] : [];
587
603
  relinka(
@@ -619,14 +635,6 @@ async function library_performCommonBuildSteps(params) {
619
635
  extTo: "ts"
620
636
  });
621
637
  }
622
- relinka("verbose", `${logPrefix} Renaming entry file in ${outDirBin}.`);
623
- await renameEntryFile(
624
- isJsr,
625
- outDirBin,
626
- coreEntryFileName,
627
- unifiedBundlerOutExt,
628
- distJsrOutFilesExt
629
- );
630
638
  relinka("verbose", `${logPrefix} Completed common build steps.`);
631
639
  }
632
640
  async function determineNpmSourceDirectory(libName, mainFile, coreEntrySrcDirResolved, libsList, distName) {
@@ -729,10 +737,6 @@ async function preBuildReplacements(config) {
729
737
  const { librarySrcDir, replacementFilePath, replacementMarker } = config;
730
738
  const replacedFiles = [];
731
739
  if (!await fs.pathExists(replacementFilePath)) {
732
- relinka(
733
- "warn",
734
- `Replacement content file not found: ${replacementFilePath}. Skipping pre-build replacements.`
735
- );
736
740
  return [];
737
741
  }
738
742
  if (!await fs.pathExists(librarySrcDir)) {
@@ -9,8 +9,7 @@ import prettyMilliseconds from "pretty-ms";
9
9
  import { unifiedBuild } from "./bundlers/unified/build.js";
10
10
  import {
11
11
  getBunSourcemapOption,
12
- getUnifiedSourcemapOption,
13
- renameEntryFile
12
+ getUnifiedSourcemapOption
14
13
  } from "../utils/utils-build.js";
15
14
  import { removeLogInternalCalls } from "../utils/utils-clean.js";
16
15
  import {
@@ -78,6 +77,11 @@ export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrc
78
77
  outDirRoot,
79
78
  false,
80
79
  // isLib
80
+ {},
81
+ // libsList (empty for regular builds)
82
+ config,
83
+ void 0,
84
+ // libName (not needed for regular builds)
81
85
  config.coreDescription
82
86
  );
83
87
  const duration = getElapsedPerfTime(timer);
@@ -409,24 +413,20 @@ async function regular_performCommonBuildSteps({
409
413
  coreDescription,
410
414
  coreBuildOutDir
411
415
  );
412
- await copyRootFile(outDirRoot, ["README.md", "LICENSE"]);
416
+ await copyRootFile(
417
+ outDirRoot,
418
+ config.publishArtifacts?.global || ["README.md", "LICENSE"]
419
+ );
413
420
  if (isJsr && coreIsCLI.enabled) {
414
- await copyRootFile(outDirRoot, [
421
+ const jsrFiles = config.publishArtifacts?.["dist-jsr"] || [
415
422
  ".gitignore",
416
423
  ".config/rse.ts",
417
424
  ".config/rse.jsonc",
418
425
  "drizzle.config.ts",
419
426
  "schema.json"
420
- ]);
427
+ ];
428
+ await copyRootFile(outDirRoot, jsrFiles);
421
429
  }
422
- relinka("verbose", `Renaming entry file in ${outDirBin}.`);
423
- await renameEntryFile(
424
- isJsr,
425
- outDirBin,
426
- config.coreEntryFile,
427
- unifiedBundlerOutExt,
428
- config.distJsrOutFilesExt
429
- );
430
430
  }
431
431
  async function regular_createTsconfig(outDirRoot) {
432
432
  const tsconfigPath = path.join(outDirRoot, "tsconfig.json");
@@ -0,0 +1,29 @@
1
+ export declare const ALLOWED_FILE_EXTENSIONS: {
2
+ readonly src: string[];
3
+ readonly "dist-npm": string[];
4
+ readonly "dist-jsr": string[];
5
+ readonly "dist-libs/npm": string[];
6
+ readonly "dist-libs/jsr": string[];
7
+ };
8
+ export declare const STRICT_FILE_EXTENSIONS: {
9
+ readonly src: string[];
10
+ readonly "dist-npm": string[];
11
+ readonly "dist-jsr": string[];
12
+ readonly "dist-libs/npm": string[];
13
+ readonly "dist-libs/jsr": string[];
14
+ };
15
+ export declare const ALLOWED_IMPORT_EXTENSIONS: {
16
+ readonly src: string[];
17
+ readonly "dist-npm": string[];
18
+ readonly "dist-jsr": string[];
19
+ readonly "dist-libs/npm": string[];
20
+ readonly "dist-libs/jsr": string[];
21
+ };
22
+ export declare const STRICT_IMPORT_EXTENSIONS: {
23
+ readonly src: string[];
24
+ readonly "dist-npm": string[];
25
+ readonly "dist-jsr": string[];
26
+ readonly "dist-libs/npm": string[];
27
+ readonly "dist-libs/jsr": string[];
28
+ };
29
+ export type AllowedFileExtensionsType = keyof typeof ALLOWED_FILE_EXTENSIONS;
@@ -0,0 +1,48 @@
1
+ export const ALLOWED_FILE_EXTENSIONS = {
2
+ src: ["", ".ts", ".css", ".json"],
3
+ // ✅ .ts files allowed in src
4
+ "dist-npm": ["", ".js", ".css", ".json"],
5
+ // ❌ no .ts files in npm dist
6
+ "dist-jsr": ["", ".ts", ".css", ".json"],
7
+ // ✅ .ts files allowed in jsr dist
8
+ "dist-libs/npm": ["", ".js", ".css", ".json"],
9
+ // ❌ no .ts files in npm libs
10
+ "dist-libs/jsr": ["", ".ts", ".css", ".json"]
11
+ // ✅ .ts files allowed in jsr libs
12
+ };
13
+ export const STRICT_FILE_EXTENSIONS = {
14
+ src: [".ts", ".css", ".json"],
15
+ // ✅ .ts files required in src
16
+ "dist-npm": [".js", ".css", ".json"],
17
+ // ❌ no .ts files in npm dist
18
+ "dist-jsr": [".ts", ".css", ".json"],
19
+ // ✅ .ts files required in jsr dist
20
+ "dist-libs/npm": [".js", ".css", ".json"],
21
+ // ❌ no .ts files in npm libs
22
+ "dist-libs/jsr": [".ts", ".css", ".json"]
23
+ // ✅ .ts files required in jsr libs
24
+ };
25
+ export const ALLOWED_IMPORT_EXTENSIONS = {
26
+ src: ["", ".js", ".css", ".json"],
27
+ // ❌ no .ts imports (use .js)
28
+ "dist-npm": ["", ".js", ".css", ".json"],
29
+ // ❌ no .ts imports
30
+ "dist-jsr": ["", ".ts", ".css", ".json"],
31
+ // ✅ .ts imports allowed
32
+ "dist-libs/npm": ["", ".js", ".css", ".json"],
33
+ // ❌ no .ts imports
34
+ "dist-libs/jsr": ["", ".ts", ".css", ".json"]
35
+ // ✅ .ts imports allowed
36
+ };
37
+ export const STRICT_IMPORT_EXTENSIONS = {
38
+ src: [".js", ".css", ".json"],
39
+ // ❌ no .ts imports, no empty
40
+ "dist-npm": [".js", ".css", ".json"],
41
+ // ❌ no .ts imports
42
+ "dist-jsr": [".ts", ".css", ".json"],
43
+ // ✅ .ts imports required
44
+ "dist-libs/npm": [".js", ".css", ".json"],
45
+ // ❌ no .ts imports
46
+ "dist-libs/jsr": [".ts", ".css", ".json"]
47
+ // ✅ .ts imports required
48
+ };
@@ -0,0 +1,2 @@
1
+ import type { CheckResult } from "../../sdk-types.js";
2
+ export declare function displayCheckResults(checkType: string, directory: string, result: CheckResult): void;