@reliverse/dler 1.7.7 → 1.7.9

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 (109) hide show
  1. package/LICENSES +1 -0
  2. package/README.md +1 -1
  3. package/bin/app/agg/impl.js +9 -25
  4. package/bin/app/agg/run.js +1 -6
  5. package/bin/app/build/impl.js +3 -17
  6. package/bin/app/check/cmd.js +3 -12
  7. package/bin/app/conv/cmd.js +7 -25
  8. package/bin/app/copy/cmd.js +2 -7
  9. package/bin/app/init/cmd.js +1 -5
  10. package/bin/app/init/init-const.js +2 -11
  11. package/bin/app/init/init-impl.js +9 -30
  12. package/bin/app/init/{templates/t-readme.d.ts → init-tmpl.d.ts} +2 -0
  13. package/bin/app/init/{templates/t-readme.js → init-tmpl.js} +27 -0
  14. package/bin/app/inject/impl.js +4 -7
  15. package/bin/app/libs/cmd.js +4 -13
  16. package/bin/app/merge/cmd.js +8 -28
  17. package/bin/app/migrate/cmd.js +11 -44
  18. package/bin/app/migrate/codemods/anything-bun.js +13 -34
  19. package/bin/app/migrate/codemods/commander-rempts.js +4 -12
  20. package/bin/app/migrate/codemods/console-relinka.js +12 -27
  21. package/bin/app/migrate/codemods/fs-relifso.js +20 -43
  22. package/bin/app/migrate/codemods/nodenext-bundler.js +6 -14
  23. package/bin/app/migrate/codemods/path-pathkit.js +16 -42
  24. package/bin/app/migrate/codemods/readdir-glob.js +11 -22
  25. package/bin/app/mkdist/cmd.d.ts +83 -0
  26. package/bin/app/mkdist/cmd.js +121 -0
  27. package/bin/app/rempts/cmd.js +13 -35
  28. package/bin/app/rename/cmd.js +6 -15
  29. package/bin/app/spell/cmd.js +1 -3
  30. package/bin/app/split/cmd.js +1 -5
  31. package/bin/app/split/impl.js +1 -6
  32. package/bin/libs/sdk/sdk-impl/build/build-library.js +36 -123
  33. package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +2 -2
  34. package/bin/libs/sdk/sdk-impl/build/build-regular.js +28 -66
  35. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.js +4 -16
  36. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.d.ts +1 -1
  37. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +97 -89
  38. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/{copy.js → copy-mod.js} +4 -18
  39. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loader.d.ts +4 -0
  40. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loader.js +26 -0
  41. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/js.d.ts +2 -0
  42. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/js.js +49 -0
  43. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/loaders-mod.d.ts +12 -0
  44. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/loaders-mod.js +30 -0
  45. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/postcss.d.ts +3 -0
  46. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/postcss.js +28 -0
  47. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.d.ts +2 -0
  48. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.js +31 -0
  49. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.d.ts +17 -0
  50. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.js +145 -0
  51. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.d.ts +8 -0
  52. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +133 -0
  53. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/dts.d.ts +11 -0
  54. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/dts.js +94 -0
  55. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/fs.d.ts +1 -0
  56. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/fs.js +15 -0
  57. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/vue-dts.d.ts +3 -0
  58. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/vue-dts.js +175 -0
  59. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/{mkdist.js → mkdist-mod.js} +5 -19
  60. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.js +2 -7
  61. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.js +2 -9
  62. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/stub.js +8 -26
  63. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/utils.js +1 -4
  64. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.js +1 -4
  65. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/{index.js → untyped-mod.js} +8 -22
  66. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.js +3 -11
  67. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/validate.js +4 -15
  68. package/bin/libs/sdk/sdk-impl/cfg/default.js +1 -9
  69. package/bin/libs/sdk/sdk-impl/cfg/info.js +1 -1
  70. package/bin/libs/sdk/sdk-impl/cfg/init.js +4 -16
  71. package/bin/libs/sdk/sdk-impl/cfg/load.js +1 -4
  72. package/bin/libs/sdk/sdk-impl/library-flow.js +3 -11
  73. package/bin/libs/sdk/sdk-impl/pub/pub-library.js +5 -22
  74. package/bin/libs/sdk/sdk-impl/pub/pub-regular.d.ts +2 -2
  75. package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +3 -6
  76. package/bin/libs/sdk/sdk-impl/regular-flow.js +8 -26
  77. package/bin/libs/sdk/sdk-impl/rules/reliverse/file-extensions/file-extensions.js +1 -5
  78. package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/analyzer.js +2 -9
  79. package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/formatter.js +8 -20
  80. package/bin/libs/sdk/sdk-impl/rules/reliverse/package-json-health/package-json-health.js +1 -7
  81. package/bin/libs/sdk/sdk-impl/rules/reliverse/path-extensions/path-extensions.js +2 -5
  82. package/bin/libs/sdk/sdk-impl/rules/reliverse/self-include/self-include.js +3 -8
  83. package/bin/libs/sdk/sdk-impl/rules/rules-mod.js +4 -14
  84. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +4 -8
  85. package/bin/libs/sdk/sdk-impl/spell/spell-parser.js +1 -3
  86. package/bin/libs/sdk/sdk-impl/utils/finalize.js +3 -14
  87. package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.js +5 -16
  88. package/bin/libs/sdk/sdk-impl/utils/utils-build.js +3 -11
  89. package/bin/libs/sdk/sdk-impl/utils/utils-clean.js +2 -5
  90. package/bin/libs/sdk/sdk-impl/utils/utils-consts.js +1 -8
  91. package/bin/libs/sdk/sdk-impl/utils/utils-cwd.js +1 -4
  92. package/bin/libs/sdk/sdk-impl/utils/utils-deps.js +14 -25
  93. package/bin/libs/sdk/sdk-impl/utils/utils-error.js +1 -5
  94. package/bin/libs/sdk/sdk-impl/utils/utils-fs.d.ts +14 -0
  95. package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +145 -37
  96. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +2 -7
  97. package/bin/libs/sdk/sdk-impl/utils/utils-package-json-libraries.js +32 -86
  98. package/bin/libs/sdk/sdk-impl/utils/utils-package-json-regular.js +13 -61
  99. package/bin/libs/sdk/sdk-mod.d.ts +3 -3
  100. package/bin/libs/sdk/sdk-mod.js +3 -3
  101. package/bin/libs/sdk/sdk-types.d.ts +76 -12
  102. package/package.json +8 -3
  103. package/bin/app/init/templates/t-gitignore.d.ts +0 -1
  104. package/bin/app/init/templates/t-gitignore.js +0 -9
  105. package/bin/app/init/templates/t-license.d.ts +0 -1
  106. package/bin/app/init/templates/t-license.js +0 -18
  107. /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/{copy.d.ts → copy-mod.d.ts} +0 -0
  108. /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/{mkdist.d.ts → mkdist-mod.d.ts} +0 -0
  109. /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/{index.d.ts → untyped-mod.d.ts} +0 -0
@@ -27,7 +27,7 @@ export async function migrateReaddirToGlob(dryRun = false) {
27
27
  const files = await getAllTsFiles(".");
28
28
  for (const file of files) {
29
29
  try {
30
- const content = await readFile(file, "utf-8");
30
+ const content = await readFile(file, "utf8");
31
31
  let modified = content;
32
32
  const changes = [];
33
33
  if (!content.includes("import") || !content.includes("globby")) {
@@ -37,7 +37,7 @@ export async function migrateReaddirToGlob(dryRun = false) {
37
37
  }
38
38
  const readdirRegex = /(?:await\s+)?(?:fs\.)?readdir(?:Sync)?\s*\(\s*([^)]+)\s*\)/g;
39
39
  if (readdirRegex.test(content)) {
40
- modified = modified.replace(readdirRegex, (match, targetDir) => {
40
+ modified = modified.replace(readdirRegex, (_match, targetDir) => {
41
41
  const cleanTargetDir = targetDir.replace(/["']/g, "").trim();
42
42
  return `await globby("*", { cwd: ${cleanTargetDir}, onlyFiles: false })`;
43
43
  });
@@ -45,18 +45,15 @@ export async function migrateReaddirToGlob(dryRun = false) {
45
45
  }
46
46
  const promisesReaddirRegex = /(?:await\s+)?fs\.promises\.readdir\s*\(\s*([^)]+)\s*\)/g;
47
47
  if (promisesReaddirRegex.test(content)) {
48
- modified = modified.replace(
49
- promisesReaddirRegex,
50
- (match, targetDir) => {
51
- const cleanTargetDir = targetDir.replace(/["']/g, "").trim();
52
- return `await globby("*", { cwd: ${cleanTargetDir}, onlyFiles: false })`;
53
- }
54
- );
48
+ modified = modified.replace(promisesReaddirRegex, (_match, targetDir) => {
49
+ const cleanTargetDir = targetDir.replace(/["']/g, "").trim();
50
+ return `await globby("*", { cwd: ${cleanTargetDir}, onlyFiles: false })`;
51
+ });
55
52
  changes.push("Converted fs.promises.readdir to globby");
56
53
  }
57
54
  if (changes.length > 0) {
58
55
  if (!dryRun) {
59
- await writeFile(file, modified, "utf-8");
56
+ await writeFile(file, modified, "utf8");
60
57
  }
61
58
  results.push({
62
59
  file,
@@ -82,7 +79,7 @@ async function updatePackageJson(results, dryRun, config) {
82
79
  try {
83
80
  const packageJsonPath = "./package.json";
84
81
  if (existsSync(packageJsonPath)) {
85
- const packageContent = await readFile(packageJsonPath, "utf-8");
82
+ const packageContent = await readFile(packageJsonPath, "utf8");
86
83
  const packageJson = JSON.parse(packageContent);
87
84
  let packageChanged = false;
88
85
  const packageChanges = [];
@@ -90,18 +87,14 @@ async function updatePackageJson(results, dryRun, config) {
90
87
  for (const pkg of config.remove) {
91
88
  if (packageJson.dependencies?.[pkg]) {
92
89
  packageJson.dependencies = Object.fromEntries(
93
- Object.entries(packageJson.dependencies).filter(
94
- ([key]) => key !== pkg
95
- )
90
+ Object.entries(packageJson.dependencies).filter(([key]) => key !== pkg)
96
91
  );
97
92
  packageChanged = true;
98
93
  packageChanges.push(`Removed ${pkg} from dependencies`);
99
94
  }
100
95
  if (packageJson.devDependencies?.[pkg]) {
101
96
  packageJson.devDependencies = Object.fromEntries(
102
- Object.entries(packageJson.devDependencies).filter(
103
- ([key]) => key !== pkg
104
- )
97
+ Object.entries(packageJson.devDependencies).filter(([key]) => key !== pkg)
105
98
  );
106
99
  packageChanged = true;
107
100
  packageChanges.push(`Removed ${pkg} from devDependencies`);
@@ -119,11 +112,7 @@ async function updatePackageJson(results, dryRun, config) {
119
112
  }
120
113
  }
121
114
  if (packageChanged && !dryRun) {
122
- await writeFile(
123
- packageJsonPath,
124
- JSON.stringify(packageJson, null, 2),
125
- "utf-8"
126
- );
115
+ await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
127
116
  }
128
117
  if (packageChanges.length > 0) {
129
118
  results.push({
@@ -0,0 +1,83 @@
1
+ declare const _default: import("@reliverse/rempts").Command<{
2
+ mkdistOnly: {
3
+ type: "boolean";
4
+ description: string;
5
+ default: true;
6
+ };
7
+ dev: {
8
+ type: "boolean";
9
+ description: string;
10
+ };
11
+ dir: {
12
+ type: "positional";
13
+ description: string;
14
+ default: string;
15
+ };
16
+ cwd: {
17
+ type: "string";
18
+ description: string;
19
+ };
20
+ src: {
21
+ type: "string";
22
+ description: string;
23
+ default: string;
24
+ };
25
+ dist: {
26
+ type: "string";
27
+ description: string;
28
+ default: string;
29
+ };
30
+ clean: {
31
+ type: "boolean";
32
+ description: string;
33
+ default: true;
34
+ };
35
+ pattern: {
36
+ type: "string";
37
+ description: string;
38
+ default: string;
39
+ };
40
+ format: {
41
+ type: "string";
42
+ description: string;
43
+ };
44
+ declaration: {
45
+ type: "boolean";
46
+ description: string;
47
+ default: false;
48
+ };
49
+ ext: {
50
+ type: "string";
51
+ description: string;
52
+ };
53
+ jsx: {
54
+ type: "string";
55
+ description: string;
56
+ };
57
+ jsxFactory: {
58
+ type: "string";
59
+ description: string;
60
+ };
61
+ jsxFragment: {
62
+ type: "string";
63
+ description: string;
64
+ };
65
+ loaders: {
66
+ type: "string";
67
+ description: string;
68
+ };
69
+ minify: {
70
+ type: "boolean";
71
+ description: string;
72
+ default: false;
73
+ };
74
+ target: {
75
+ type: "string";
76
+ description: string;
77
+ };
78
+ dontBuildCopyInstead: {
79
+ type: "string";
80
+ description: string;
81
+ };
82
+ }>;
83
+ export default _default;
@@ -0,0 +1,121 @@
1
+ import { resolve } from "@reliverse/pathkit";
2
+ import { defineArgs, defineCommand } from "@reliverse/rempts";
3
+ import { dlerBuild } from "../build/impl.js";
4
+ import { mkdist } from "../../libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js";
5
+ import { ensureDlerConfig } from "../../libs/sdk/sdk-impl/cfg/init.js";
6
+ export default defineCommand({
7
+ meta: {
8
+ name: "mkdist",
9
+ description: "Build the project using mkdist"
10
+ },
11
+ args: defineArgs({
12
+ mkdistOnly: {
13
+ type: "boolean",
14
+ description: "Only run mkdist",
15
+ default: true
16
+ },
17
+ dev: {
18
+ type: "boolean",
19
+ description: "Runs the CLI in dev mode"
20
+ },
21
+ dir: {
22
+ type: "positional",
23
+ description: "Project root directory",
24
+ default: "."
25
+ },
26
+ cwd: {
27
+ type: "string",
28
+ description: "Current working directory"
29
+ },
30
+ src: {
31
+ type: "string",
32
+ description: "Source directory relative to project root directory",
33
+ default: "src"
34
+ },
35
+ dist: {
36
+ type: "string",
37
+ description: "Destination directory relative to project root directory",
38
+ default: "dist"
39
+ },
40
+ clean: {
41
+ type: "boolean",
42
+ description: "Clean the destination directory",
43
+ default: true
44
+ },
45
+ pattern: {
46
+ type: "string",
47
+ description: "Pattern includes or excludes files (default: '**')",
48
+ default: "**"
49
+ },
50
+ format: {
51
+ type: "string",
52
+ description: "File format (cjs|esm)"
53
+ },
54
+ declaration: {
55
+ type: "boolean",
56
+ description: "Generate type declaration file",
57
+ default: false
58
+ // alias: ["d"],
59
+ },
60
+ ext: {
61
+ type: "string",
62
+ description: "File extension (mjs|js|ts)"
63
+ // valueHint: "mjs|js|ts",
64
+ },
65
+ jsx: {
66
+ type: "string",
67
+ description: "Specify which JSX runtime to use (transform|preserve|automatic)"
68
+ },
69
+ jsxFactory: {
70
+ type: "string",
71
+ description: "JSX factory (h|React.createElement)"
72
+ },
73
+ jsxFragment: {
74
+ type: "string",
75
+ description: "JSX fragment (Fragment|React.Fragment)"
76
+ },
77
+ loaders: {
78
+ type: "string",
79
+ description: "Loaders (js|vue|sass)"
80
+ },
81
+ minify: {
82
+ type: "boolean",
83
+ description: "Minify output files",
84
+ default: false
85
+ },
86
+ target: {
87
+ type: "string",
88
+ description: "Target environment (esbuild)"
89
+ },
90
+ dontBuildCopyInstead: {
91
+ type: "string",
92
+ description: "Don't build copy instead of (glob patterns, e.g. '**/*.json') (default: ['**/templates/**'])"
93
+ }
94
+ }),
95
+ async run({ args }) {
96
+ if (args.mkdistOnly) {
97
+ const { writtenFiles } = await mkdist({
98
+ rootDir: resolve(args.cwd || process.cwd(), args.dir),
99
+ srcDir: args.src,
100
+ distDir: args.dist,
101
+ cleanDist: args.clean,
102
+ format: args.format,
103
+ pattern: args.pattern,
104
+ ext: args.ext,
105
+ declaration: args.declaration,
106
+ loaders: args.loaders?.split(","),
107
+ esbuild: {
108
+ jsx: args.jsx,
109
+ jsxFactory: args.jsxFactory,
110
+ jsxFragment: args.jsxFragment,
111
+ minify: args.minify,
112
+ target: args.target
113
+ }
114
+ });
115
+ console.log(writtenFiles.map((f) => `- ${f}`).join("\n"));
116
+ process.exit(0);
117
+ }
118
+ await ensureDlerConfig(args.dev);
119
+ await dlerBuild(args.dev);
120
+ }
121
+ });
@@ -79,23 +79,17 @@ export default defineCommand({
79
79
  } else {
80
80
  cmdsRoot = path.resolve(cmdsRoot);
81
81
  }
82
- relinka(
83
- "info",
84
- `\u{1F680} Creating ${cmdNames.length} command(s): ${cmdNames.join(", ")}`
85
- );
82
+ relinka("info", `\u{1F680} Creating ${cmdNames.length} command(s): ${cmdNames.join(", ")}`);
86
83
  for (const cmdName of cmdNames) {
87
84
  const dirPath = path.join(cmdsRoot, cmdName);
88
85
  const filePath = path.join(dirPath, "cmd.ts");
89
86
  if (await fs.pathExists(filePath) && !args.overwrite) {
90
- relinka(
91
- "warn",
92
- `Command "${cmdName}" already exists. Use --overwrite to overwrite.`
93
- );
87
+ relinka("warn", `Command "${cmdName}" already exists. Use --overwrite to overwrite.`);
94
88
  continue;
95
89
  }
96
90
  await fs.ensureDir(dirPath);
97
91
  const content = generateCommandTemplate(cmdName);
98
- await fs.writeFile(filePath, content, "utf-8");
92
+ await fs.writeFile(filePath, content, "utf8");
99
93
  relinka("log", `\u2705 Created new command: ${filePath}`);
100
94
  }
101
95
  if (cliFilePath) {
@@ -118,42 +112,30 @@ export default defineCommand({
118
112
  return;
119
113
  }
120
114
  if (await fs.pathExists(outPath2) && !args.overwrite) {
121
- relinka(
122
- "warn",
123
- `\u274C File "${outPath2}" already exists. Use --overwrite to overwrite.`
124
- );
115
+ relinka("warn", `\u274C File "${outPath2}" already exists. Use --overwrite to overwrite.`);
125
116
  return;
126
117
  }
127
118
  const exports2 = generateExports(cmdDirs2);
128
119
  await fs.ensureDir(path.dirname(outPath2));
129
- await fs.writeFile(outPath2, exports2, "utf-8");
120
+ await fs.writeFile(outPath2, exports2, "utf8");
130
121
  relinka("success", `\u2705 Generated command exports at: ${outPath2}`);
131
- relinka(
132
- "log",
133
- `Found ${cmdDirs2.length} command(s): ${cmdDirs2.join(", ")}`
134
- );
122
+ relinka("log", `Found ${cmdDirs2.length} command(s): ${cmdDirs2.join(", ")}`);
135
123
  return;
136
124
  }
137
125
  const root = path.resolve("src/app");
138
126
  const outPath = path.resolve(args.outFile ?? "src/app/cmds.ts");
139
127
  if (await fs.pathExists(outPath) && !args.overwrite) {
140
- relinka(
141
- "warn",
142
- `\u274C File "${outPath}" already exists. Use --overwrite to overwrite.`
143
- );
128
+ relinka("warn", `\u274C File "${outPath}" already exists. Use --overwrite to overwrite.`);
144
129
  return;
145
130
  }
146
131
  const cmdDirs = (args.cmdDirs ?? []).length > 0 ? args.cmdDirs ?? [] : await findCommandDirs(root);
147
132
  if (cmdDirs.length === 0) {
148
- relinka(
149
- "warn",
150
- "No command directories found with cmd.ts or cmd.js files."
151
- );
133
+ relinka("warn", "No command directories found with cmd.ts or cmd.js files.");
152
134
  return;
153
135
  }
154
136
  const exports = generateExports(cmdDirs);
155
137
  await fs.ensureDir(path.dirname(outPath));
156
- await fs.writeFile(outPath, exports, "utf-8");
138
+ await fs.writeFile(outPath, exports, "utf8");
157
139
  relinka("success", `\u2705 Generated command exports at: ${outPath}`);
158
140
  relinka("log", `Found ${cmdDirs.length} command(s): ${cmdDirs.join(", ")}`);
159
141
  if (didInit) {
@@ -197,12 +179,10 @@ async function handleDlerConfig() {
197
179
  const firstScript = Object.values(coreIsCLI.scripts)[0];
198
180
  const scriptPath = path.resolve(firstScript);
199
181
  if (await fs.pathExists(scriptPath)) {
200
- const content = await fs.readFile(scriptPath, "utf-8");
182
+ const content = await fs.readFile(scriptPath, "utf8");
201
183
  if (content.includes("@reliverse/rempts")) {
202
184
  if (content.includes("runMain")) {
203
- const cmdsRootMatch = content.match(
204
- /cmdsRootPath:\s*["']([^"']+)["']/
205
- );
185
+ const cmdsRootMatch = content.match(/cmdsRootPath:\s*["']([^"']+)["']/);
206
186
  if (cmdsRootMatch?.[1]) {
207
187
  cmdsRoot = path.resolve(cmdsRootMatch[1]);
208
188
  }
@@ -226,7 +206,7 @@ async function ensureCliFile(filePath) {
226
206
  const resolvedPath = path.resolve(filePath);
227
207
  if (!await fs.pathExists(resolvedPath)) {
228
208
  await fs.ensureDir(path.dirname(resolvedPath));
229
- await fs.writeFile(resolvedPath, cliTemplate, "utf-8");
209
+ await fs.writeFile(resolvedPath, cliTemplate, "utf8");
230
210
  relinka("log", `\u2705 Created CLI entry file: ${resolvedPath}`);
231
211
  return resolvedPath;
232
212
  }
@@ -262,9 +242,7 @@ function generateExports(cmdDirs) {
262
242
  ""
263
243
  ];
264
244
  for (const dir of cmdDirs) {
265
- const funcName = "get" + dir.split(/[/\\]/).map(
266
- (part) => part.charAt(0).toUpperCase() + part.slice(1).replace(/[^a-zA-Z0-9]/g, "")
267
- ).join("") + "Cmd";
245
+ const funcName = "get" + dir.split(/[/\\]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1).replace(/[^a-zA-Z0-9]/g, "")).join("") + "Cmd";
268
246
  lines.push(
269
247
  `export const ${funcName} = async (): Promise<Command> => loadCommand("${dir}");`,
270
248
  ""
@@ -24,7 +24,7 @@ function isCommonJSFile(content) {
24
24
  async function getAllFilesAsync(dir, baseDir = dir, recursive = true) {
25
25
  let fileList = [];
26
26
  const entries = await readdir(dir, {
27
- encoding: "utf-8",
27
+ encoding: "utf8",
28
28
  withFileTypes: true
29
29
  });
30
30
  for (const entry of entries) {
@@ -45,10 +45,8 @@ async function prepareCLIFiles(revert = false, recursive = true, useDtsTxtForPre
45
45
  const configPath = ".config/dler.ts";
46
46
  let srcDir = "src";
47
47
  if (existsSync(configPath)) {
48
- const configContent = readFileSync(configPath, "utf-8");
49
- const configMatch = configContent.match(
50
- /coreEntrySrcDir:\s*["']([^"']+)["']/
51
- );
48
+ const configContent = readFileSync(configPath, "utf8");
49
+ const configMatch = configContent.match(/coreEntrySrcDir:\s*["']([^"']+)["']/);
52
50
  srcDir = configMatch?.[1] ?? srcDir;
53
51
  }
54
52
  if (!existsSync(srcDir)) {
@@ -99,7 +97,7 @@ async function prepareCLIFiles(revert = false, recursive = true, useDtsTxtForPre
99
97
  await safeRename(fullPath, newName);
100
98
  renamedCount++;
101
99
  } else if (fileName.endsWith(".js") && !fileName.endsWith(".cjs")) {
102
- const content = readFileSync(fullPath, "utf-8");
100
+ const content = readFileSync(fullPath, "utf8");
103
101
  if (isCommonJSFile(content)) {
104
102
  const newName = join(dir, `${baseName}.cjs`);
105
103
  relinka("log", `Renaming ${fullPath} to ${newName}`);
@@ -109,10 +107,7 @@ async function prepareCLIFiles(revert = false, recursive = true, useDtsTxtForPre
109
107
  }
110
108
  }
111
109
  }
112
- relinka(
113
- "log",
114
- `CLI file preparation completed. Renamed ${renamedCount} files.`
115
- );
110
+ relinka("log", `CLI file preparation completed. Renamed ${renamedCount} files.`);
116
111
  }
117
112
  export default defineCommand({
118
113
  meta: {
@@ -162,11 +157,7 @@ export default defineCommand({
162
157
  } = args;
163
158
  if (prepareMyCLI === true) {
164
159
  try {
165
- await prepareCLIFiles(
166
- revert === true,
167
- recursive,
168
- useDtsTxtForPrepareMyCLI
169
- );
160
+ await prepareCLIFiles(revert === true, recursive, useDtsTxtForPrepareMyCLI);
170
161
  relinka("log", "Successfully prepared CLI files");
171
162
  } catch (error) {
172
163
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -41,9 +41,7 @@ export default defineCommand({
41
41
  console.log("\nResults:");
42
42
  for (const result of results) {
43
43
  const status = result.success ? "\u2713" : "\u2717";
44
- console.log(
45
- `${status} ${result.file}: ${result.spell.type} - ${result.message}`
46
- );
44
+ console.log(`${status} ${result.file}: ${result.spell.type} - ${result.message}`);
47
45
  }
48
46
  }
49
47
  });
@@ -1,10 +1,6 @@
1
1
  import fs from "@reliverse/relifso";
2
2
  import { defineArgs, defineCommand } from "@reliverse/rempts";
3
- import {
4
- getAllSourceFiles,
5
- splitLargeFileByLines,
6
- splitLargeFunctions
7
- } from "./impl.js";
3
+ import { getAllSourceFiles, splitLargeFileByLines, splitLargeFunctions } from "./impl.js";
8
4
  export default defineCommand({
9
5
  args: defineArgs({
10
6
  directory: {
@@ -43,12 +43,7 @@ export function splitLargeFileByLines(filePath, threshold) {
43
43
  }
44
44
  export function splitLargeFunctions(filePath, funcLineThreshold) {
45
45
  const sourceCode = fs.readFileSync(filePath, "utf8");
46
- const sourceFile = ts.createSourceFile(
47
- filePath,
48
- sourceCode,
49
- ts.ScriptTarget.ESNext,
50
- true
51
- );
46
+ const sourceFile = ts.createSourceFile(filePath, sourceCode, ts.ScriptTarget.ESNext, true);
52
47
  let newSource = sourceCode;
53
48
  const getLineOfPosition = (pos) => {
54
49
  return sourceFile.getLineAndCharacterOfPosition(pos).line;