@reliverse/dler 1.3.6 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/bin/app/agg/cmd.d.ts +34 -0
  2. package/bin/app/agg/cmd.js +44 -3
  3. package/bin/app/agg/impl.d.ts +2 -1
  4. package/bin/app/agg/impl.js +94 -33
  5. package/bin/app/cmds.d.ts +34 -0
  6. package/bin/app/deps/cmd.js +1 -1
  7. package/bin/app/deps/impl/filesystem.js +1 -1
  8. package/bin/app/deps/impl/formatter.js +0 -1
  9. package/bin/app/inject/expect/impl.js +2 -2
  10. package/bin/app/merge/cmd.d.ts +44 -0
  11. package/bin/app/merge/{cmd.txt → cmd.js} +79 -141
  12. package/bin/app/migrate/cmd.d.ts +0 -0
  13. package/bin/app/migrate/cmd.js +0 -0
  14. package/bin/app/relifso/cmd.js +1 -1
  15. package/bin/app/relifso/init/cmd.js +1 -1
  16. package/bin/app/relifso/init/impl/mod.js +2 -2
  17. package/bin/app/relifso/init/impl/templates/t-license.js +0 -4
  18. package/bin/app/relifso/init/impl/templates/t-readme.js +0 -18
  19. package/bin/app/rempts/init/cmd/cmd.js +2 -4
  20. package/bin/app/rempts/init/cmds/cmd.js +2 -2
  21. package/bin/app/rempts/migrate/cmd.js +1 -1
  22. package/bin/app/rempts/migrate/impl/commander.js +0 -1
  23. package/bin/app/split/cmd.d.ts +21 -3
  24. package/bin/app/split/cmd.js +41 -0
  25. package/bin/app/split/impl.d.ts +0 -7
  26. package/bin/app/split/impl.js +2 -23
  27. package/bin/impl.js +8 -4
  28. package/bin/init.js +2 -11
  29. package/bin/libs/sdk/sdk-impl/build/build-library.js +38 -22
  30. package/bin/libs/sdk/sdk-impl/build/build-regular.js +40 -25
  31. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.js +1 -1
  32. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +1 -2
  33. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/copy.js +1 -1
  34. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist.js +1 -1
  35. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.js +1 -1
  36. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.js +1 -1
  37. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/cjs.js +0 -1
  38. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.js +1 -1
  39. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/shebang.js +1 -1
  40. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/stub.js +7 -1
  41. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.js +1 -1
  42. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/index.js +1 -1
  43. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.d.ts +0 -1
  44. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.js +3 -5
  45. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/validate.js +1 -1
  46. package/bin/libs/sdk/sdk-impl/library-flow.d.ts +2 -2
  47. package/bin/libs/sdk/sdk-impl/library-flow.js +8 -6
  48. package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +1 -1
  49. package/bin/libs/sdk/sdk-impl/spell/spell-executors.js +1 -1
  50. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +2 -2
  51. package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.js +2 -2
  52. package/bin/libs/sdk/sdk-impl/utils/utils-build.js +2 -2
  53. package/bin/libs/sdk/sdk-impl/utils/utils-bump.d.ts +8 -2
  54. package/bin/libs/sdk/sdk-impl/utils/utils-bump.js +21 -209
  55. package/bin/libs/sdk/sdk-impl/utils/utils-clean.d.ts +6 -0
  56. package/bin/libs/sdk/sdk-impl/utils/utils-clean.js +34 -2
  57. package/bin/libs/sdk/sdk-impl/utils/utils-consts.js +1 -1
  58. package/bin/libs/sdk/sdk-impl/utils/utils-deps.js +1 -1
  59. package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +2 -2
  60. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +2 -2
  61. package/bin/libs/sdk/sdk-impl/utils/utils-misc.d.ts +7 -0
  62. package/bin/libs/sdk/sdk-impl/utils/utils-misc.js +7 -0
  63. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.js +2 -2
  64. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.js +2 -2
  65. package/bin/libs/sdk/sdk-impl/utils/utils-tsconfig.js +2 -2
  66. package/bin/libs/sdk/sdk-mod.d.ts +2 -3
  67. package/bin/libs/sdk/sdk-mod.js +1 -7
  68. package/bin/libs/sdk/sdk-types.d.ts +1 -1
  69. package/bin/load.js +1 -1
  70. package/bin/types.d.ts +1 -1
  71. package/package.json +14 -16
  72. package/bin/libs/sdk/sdk-impl/utils/utils-paths.d.ts +0 -55
  73. package/bin/libs/sdk/sdk-impl/utils/utils-paths.js +0 -667
@@ -1,19 +1,8 @@
1
+ import path from "@reliverse/pathkit";
1
2
  import { glob } from "@reliverse/reglob";
2
- import { readFile, writeFile, ensureDir } from "fs-extra";
3
- import {
4
- defineCommand,
5
- runMain,
6
- inputPrompt,
7
- confirmPrompt,
8
- } from "@reliverse/rempts";
9
- import path from "@reliverse/repath";
10
-
11
- // ---------- constants ----------
12
-
13
- // always-ignored directories
14
- const DEFAULT_IGNORES = ["**/.git/**", "**/node_modules/**"] as const;
15
-
16
- // binary / media extensions (stored in a Set for O(1) lookups)
3
+ import fs from "@reliverse/relifso";
4
+ import { defineCommand, inputPrompt, confirmPrompt } from "@reliverse/rempts";
5
+ const DEFAULT_IGNORES = ["**/.git/**", "**/node_modules/**"];
17
6
  const BINARY_EXTS = [
18
7
  "png",
19
8
  "jpg",
@@ -45,12 +34,10 @@ const BINARY_EXTS = [
45
34
  "ttf",
46
35
  "eot",
47
36
  "class",
48
- "jar",
49
- ] as const;
50
- const BINARY_SET = new Set<string>(BINARY_EXTS);
51
-
52
- // known comment prefixes per extension
53
- const COMMENT_MAP: Record<string, string> = {
37
+ "jar"
38
+ ];
39
+ const BINARY_SET = new Set(BINARY_EXTS);
40
+ const COMMENT_MAP = {
54
41
  js: "// ",
55
42
  jsx: "// ",
56
43
  ts: "// ",
@@ -82,87 +69,55 @@ const COMMENT_MAP: Record<string, string> = {
82
69
  html: "<!-- ",
83
70
  htm: "<!-- ",
84
71
  xml: "<!-- ",
85
- md: "<!-- ",
72
+ md: "<!-- "
86
73
  };
87
-
88
74
  const DEFAULT_COMMENT = "// ";
89
- const DEFAULT_SEPARATOR_RAW = "\\n\\n"; // two newlines (escaped form)
90
-
91
- // ---------- helpers ----------
92
-
93
- const isBinaryExt = (file: string) => {
75
+ const DEFAULT_SEPARATOR_RAW = "\\n\\n";
76
+ const isBinaryExt = (file) => {
94
77
  const ext = path.extname(file).slice(1).toLowerCase();
95
78
  return BINARY_SET.has(ext);
96
79
  };
97
-
98
- const ensureTrailingNL = (s: string) => (s.endsWith("\n") ? s : `${s}\n`);
99
-
100
- const parseCSV = (s: string) =>
101
- s
102
- .split(",")
103
- .map((t) => t.trim())
104
- .filter(Boolean);
105
-
106
- const unescape = (s: string) => s.replace(/\\n/g, "\n").replace(/\\t/g, "\t");
107
-
108
- // prompt wrappers that honour batch mode
109
- const maybePrompt = async <T>(
110
- batch: boolean,
111
- value: T | undefined,
112
- promptFn: () => Promise<T>,
113
- ): Promise<T | undefined> => {
114
- if (batch || value !== undefined) return value;
80
+ const ensureTrailingNL = (s) => s.endsWith("\n") ? s : `${s}
81
+ `;
82
+ const parseCSV = (s) => s.split(",").map((t) => t.trim()).filter(Boolean);
83
+ const unescape = (s) => s.replace(/\\n/g, "\n").replace(/\\t/g, " ");
84
+ const maybePrompt = async (batch, value, promptFn) => {
85
+ if (batch || value !== void 0) return value;
115
86
  return promptFn();
116
87
  };
117
-
118
- // collect and pre-filter files (dedup + binary skip early)
119
- const collectFiles = async (include: string[], extraIgnore: string[]) => {
88
+ const collectFiles = async (include, extraIgnore) => {
120
89
  const files = await glob(include, {
121
90
  ignore: [...DEFAULT_IGNORES, ...extraIgnore],
122
- absolute: true,
91
+ absolute: true
123
92
  });
124
93
  return [...new Set(files)].filter((f) => !isBinaryExt(f)).sort();
125
94
  };
126
-
127
- const readSections = async (
128
- files: string[],
129
- injectPath: boolean,
130
- getPrefix: (f: string) => string,
131
- ) => {
95
+ const readSections = async (files, injectPath, getPrefix) => {
132
96
  const cwd = process.cwd();
133
97
  const reads = files.map(async (f) => {
134
- const raw = (await readFile(f, "utf8")) as string;
98
+ const raw = await fs.readFile(f, "utf8");
135
99
  if (!injectPath) return raw;
136
100
  const rel = path.relative(cwd, f);
137
101
  return `${ensureTrailingNL(raw)}${getPrefix(f)}${rel}`;
138
102
  });
139
103
  return Promise.all(reads);
140
104
  };
141
-
142
- const writeResult = async (
143
- sections: string[],
144
- separator: string,
145
- toFile: string | undefined,
146
- toStdout: boolean,
147
- ) => {
148
- const content = `${sections.join(separator)}\n`;
105
+ const writeResult = async (sections, separator, toFile, toStdout) => {
106
+ const content = `${sections.join(separator)}
107
+ `;
149
108
  if (toStdout || !toFile) {
150
109
  process.stdout.write(content);
151
110
  return;
152
111
  }
153
112
  const dir = path.dirname(toFile);
154
- if (dir && dir !== ".") await ensureDir(dir);
155
- await writeFile(toFile, content, "utf8");
113
+ if (dir && dir !== ".") await fs.ensureDir(dir);
114
+ await fs.writeFile(toFile, content, "utf8");
156
115
  };
157
-
158
- // ---------- command ----------
159
-
160
- const cmd = defineCommand({
116
+ export default defineCommand({
161
117
  meta: {
162
118
  name: "remege",
163
119
  version: "1.0.0",
164
- description:
165
- "Merge text files with optional commented path footer, skips binaries/media, built for CI & interactive use.",
120
+ description: "Merge text files with optional commented path footer, skips binaries/media, built for CI & interactive use."
166
121
  },
167
122
  args: {
168
123
  in: { type: "array", description: "Input glob patterns" },
@@ -171,136 +126,119 @@ const cmd = defineCommand({
171
126
  format: {
172
127
  type: "string",
173
128
  default: "txt",
174
- description: "Fallback extension when output path is omitted",
129
+ description: "Fallback extension when output path is omitted"
175
130
  },
176
131
  stdout: { type: "boolean", description: "Print to stdout" },
177
132
  noPath: {
178
133
  type: "boolean",
179
- description: "Don't inject relative path below each file",
134
+ description: "Don't inject relative path below each file"
180
135
  },
181
136
  separator: {
182
137
  type: "string",
183
- description: `Custom separator (default ${DEFAULT_SEPARATOR_RAW})`,
138
+ description: `Custom separator (default ${DEFAULT_SEPARATOR_RAW})`
184
139
  },
185
140
  comment: {
186
141
  type: "string",
187
- description: "Custom comment prefix (e.g. '# ')",
142
+ description: "Custom comment prefix (e.g. '# ')"
188
143
  },
189
144
  forceComment: {
190
145
  type: "boolean",
191
- description: "Force custom comment prefix for all file types",
146
+ description: "Force custom comment prefix for all file types"
192
147
  },
193
148
  batch: {
194
149
  type: "boolean",
195
- description: "Disable interactive prompts (CI/non-interactive mode)",
196
- },
150
+ description: "Disable interactive prompts (CI/non-interactive mode)"
151
+ }
197
152
  },
198
153
  async run({ args }) {
199
154
  const batch = Boolean(args.batch);
200
-
201
- // ----- include patterns -----
202
155
  let include = args.in ?? [];
203
156
  if (include.length === 0) {
204
- const raw = await maybePrompt(batch, undefined, () =>
205
- inputPrompt({
157
+ const raw = await maybePrompt(
158
+ batch,
159
+ void 0,
160
+ () => inputPrompt({
206
161
  title: "Input glob patterns (comma separated)",
207
- placeholder: "src/**/*.ts, !**/*.test.ts",
208
- }),
162
+ placeholder: "src/**/*.ts, !**/*.test.ts"
163
+ })
209
164
  );
210
- if (raw) include = parseCSV(raw as string);
165
+ if (raw) include = parseCSV(raw);
211
166
  }
212
167
  if (include.length === 0)
213
168
  throw new Error("No input patterns supplied and prompts disabled");
214
-
215
- // ----- ignore patterns -----
216
169
  let ignore = args.ignore ?? [];
217
170
  if (ignore.length === 0) {
218
- const raw = await maybePrompt(batch, undefined, () =>
219
- inputPrompt({
171
+ const raw = await maybePrompt(
172
+ batch,
173
+ void 0,
174
+ () => inputPrompt({
220
175
  title: "Ignore patterns (comma separated, blank for none)",
221
- placeholder: "**/*.d.ts",
222
- }),
176
+ placeholder: "**/*.d.ts"
177
+ })
223
178
  );
224
- if (raw) ignore = parseCSV(raw as string);
179
+ if (raw) ignore = parseCSV(raw);
225
180
  }
226
-
227
- // ----- comment settings -----
228
181
  let customComment = args.comment;
229
- if (customComment === undefined) {
230
- const want = await maybePrompt(batch, undefined, () =>
231
- confirmPrompt({
182
+ if (customComment === void 0) {
183
+ const want = await maybePrompt(
184
+ batch,
185
+ void 0,
186
+ () => confirmPrompt({
232
187
  title: "Provide custom comment prefix?",
233
- defaultValue: false,
234
- }),
188
+ defaultValue: false
189
+ })
235
190
  );
236
191
  if (want) {
237
- customComment = (await inputPrompt({
192
+ customComment = await inputPrompt({
238
193
  title: "Custom comment prefix (include trailing space if needed)",
239
- placeholder: "# ",
240
- })) as string;
194
+ placeholder: "# "
195
+ });
241
196
  }
242
197
  }
243
198
  const forceComment = args.forceComment ?? false;
244
-
245
- // ----- path footer toggle -----
246
- const injectPath = args.noPath ? false : true;
247
-
248
- // ----- separator -----
249
- const sepRaw =
250
- args.separator ??
251
- ((await maybePrompt(batch, undefined, () =>
252
- inputPrompt({
253
- title:
254
- "Separator between files (\\n for newline, blank → blank line)",
255
- placeholder: DEFAULT_SEPARATOR_RAW,
256
- }),
257
- )) as string | undefined) ??
258
- DEFAULT_SEPARATOR_RAW;
199
+ const injectPath = !args.noPath;
200
+ const sepRaw = args.separator ?? await maybePrompt(
201
+ batch,
202
+ void 0,
203
+ () => inputPrompt({
204
+ title: "Separator between files (\\n for newline, blank \u2192 blank line)",
205
+ placeholder: DEFAULT_SEPARATOR_RAW
206
+ })
207
+ ) ?? DEFAULT_SEPARATOR_RAW;
259
208
  const separator = unescape(sepRaw);
260
-
261
- // ----- output location / stdout -----
262
209
  let stdoutFlag = args.stdout ?? false;
263
210
  let outFile = args.out;
264
-
265
211
  if (!stdoutFlag && !outFile && !batch) {
266
212
  stdoutFlag = await confirmPrompt({
267
213
  title: "Print result to stdout?",
268
- defaultValue: false,
214
+ defaultValue: false
269
215
  });
270
216
  if (!stdoutFlag) {
271
- outFile = (await inputPrompt({
272
- title: "Output file path (blank merged.<ext>)",
273
- placeholder: "",
274
- })) as string;
217
+ outFile = await inputPrompt({
218
+ title: "Output file path (blank \u2192 merged.<ext>)",
219
+ placeholder: ""
220
+ });
275
221
  if (!outFile) {
276
- const ext = (await inputPrompt({
222
+ const ext = await inputPrompt({
277
223
  title: "File extension",
278
- placeholder: args.format,
279
- })) as string;
224
+ placeholder: args.format
225
+ });
280
226
  outFile = `merged.${(ext || args.format).replace(/^\./, "")}`;
281
227
  }
282
228
  }
283
229
  }
284
-
285
- // ----- gather files -----
286
230
  const files = await collectFiles(include, ignore);
287
231
  if (files.length === 0) {
288
232
  throw new Error(
289
- "No text files matched given patterns (binary/media files are skipped)",
233
+ "No text files matched given patterns (binary/media files are skipped)"
290
234
  );
291
235
  }
292
-
293
- // ----- comment prefix resolver -----
294
- const getPrefix = (filePath: string): string => {
236
+ const getPrefix = (filePath) => {
295
237
  if (forceComment && customComment) return customComment;
296
238
  const ext = path.extname(filePath).slice(1).toLowerCase();
297
239
  return COMMENT_MAP[ext] ?? customComment ?? DEFAULT_COMMENT;
298
240
  };
299
-
300
- // ----- read, merge, write -----
301
241
  const sections = await readSections(files, injectPath, getPrefix);
302
242
  await writeResult(sections, separator, outFile, stdoutFlag);
303
- },
243
+ }
304
244
  });
305
-
306
- await runMain(cmd);
File without changes
File without changes
@@ -3,7 +3,7 @@ import { defineCommand, runCmd, selectPrompt } from "@reliverse/rempts";
3
3
  import { cmdRelifsoInit } from "../cmds.js";
4
4
  export default defineCommand({
5
5
  meta: {
6
- name: "cli",
6
+ name: "relifso",
7
7
  description: "Runs the Relifso helper interactive menu (displays list of available commands)"
8
8
  },
9
9
  args: {
@@ -8,7 +8,7 @@ import { FILE_TYPES } from "./impl/const.js";
8
8
  import { initFile, initFiles } from "./impl/mod.js";
9
9
  export default defineCommand({
10
10
  meta: {
11
- name: "relifso",
11
+ name: "init",
12
12
  version: "1.0.0",
13
13
  description: "relifso helper utils"
14
14
  },
@@ -1,8 +1,8 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
1
3
  import { relinka } from "@reliverse/relinka";
2
4
  import { selectPrompt } from "@reliverse/rempts";
3
- import fs from "fs-extra";
4
5
  import pMap from "p-map";
5
- import path from "pathe";
6
6
  import { FILE_TYPES } from "./const.js";
7
7
  import { gitignoreTemplate } from "./templates/t-gitignore.js";
8
8
  import { licenseTemplate } from "./templates/t-license.js";
@@ -1,17 +1,13 @@
1
1
  export const licenseTemplate = `# MIT License
2
-
3
2
  Copyright (c) Nazar Kornienko (blefnk), Reliverse
4
-
5
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
4
  of this software and associated documentation files (the "Software"), to deal
7
5
  in the Software without restriction, including without limitation the rights
8
6
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
7
  copies of the Software, and to permit persons to whom the Software is
10
8
  furnished to do so, subject to the following conditions:
11
-
12
9
  The above copyright notice and this permission notice shall be included in all
13
10
  copies or substantial portions of the Software.
14
-
15
11
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
12
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
13
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -1,35 +1,25 @@
1
1
  export const readmeTemplate = `# \u{1F680} Project Name
2
-
3
2
  Welcome! This project was bootstrapped with [@reliverse/reinit](https://www.npmjs.com/package/@reliverse/reinit).
4
3
  It's already got the basics \u2014 now it's your turn to make it awesome \u2728
5
-
6
4
  ## \u{1F527} Tech Stack
7
-
8
5
  - \u2699\uFE0F Framework: _<Add your framework here>_
9
6
  - \u{1F6E0}\uFE0F Tools: _<Add your tooling, CLIs, etc>_
10
7
  - \u{1F9EA} Tests: _<Vitest, Jest, or something else?>_
11
8
  - \u{1F9E0} Linting: _ESLint, Biome, etc_
12
9
  - \u{1F310} Deployment: _<Vercel, Netlify, Railway?>_
13
-
14
10
  ## \u{1F680} Getting Started
15
-
16
11
  Clone the repo and install dependencies:
17
-
18
12
  '''bash
19
13
  bun install
20
14
  bun dev
21
15
  '''
22
-
23
16
  Or if you're using another package manager:
24
-
25
17
  '''bash
26
18
  npm install && npm run dev
27
19
  # or
28
20
  pnpm i && pnpm dev
29
21
  '''
30
-
31
22
  ## \u{1F5C2}\uFE0F Project Structure
32
-
33
23
  '''bash
34
24
  src/
35
25
  \u251C\u2500\u2500 components/
@@ -37,23 +27,15 @@ src/
37
27
  \u251C\u2500\u2500 lib/
38
28
  \u2514\u2500\u2500 styles/
39
29
  '''
40
-
41
30
  Feel free to tweak the structure to your liking.
42
-
43
31
  ## \u{1F9E9} Customize it
44
-
45
32
  This project is just a starting point. You can add:
46
-
47
33
  - \u{1F9D9}\u200D\u2642\uFE0F Your own components and UI
48
34
  - \u{1F4E6} APIs, auth, i18n, analytics, whatever you need
49
35
  - \u{1F916} AI integrations using [Reliverse CLI](https://www.npmjs.com/package/@reliverse/rse)
50
-
51
36
  ## \u{1FAF6} Credits
52
-
53
37
  Made with \u2764\uFE0F using [@reliverse/reinit](https://reliverse.org)
54
38
  Need help? [Join the Discord](https://discord.gg/Pb8uKbwpsJ)
55
-
56
39
  ## \u{1F4C4} License
57
-
58
40
  MIT \xA9 YourNameHere
59
41
  `;
@@ -1,7 +1,7 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
1
3
  import { relinka } from "@reliverse/relinka";
2
4
  import { defineCommand } from "@reliverse/rempts";
3
- import fs from "fs-extra";
4
- import path from "pathe";
5
5
  export default defineCommand({
6
6
  meta: {
7
7
  name: "init",
@@ -44,9 +44,7 @@ export default defineCommand({
44
44
  });
45
45
  function generateCommandTemplate(cmdName) {
46
46
  return `import { relinka } from "@reliverse/relinka";
47
-
48
47
  import { defineCommand } from "@reliverse/rempts";
49
-
50
48
  export default defineCommand({
51
49
  meta: {
52
50
  name: "${cmdName}",
@@ -1,7 +1,7 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
1
3
  import { relinka } from "@reliverse/relinka";
2
4
  import { defineCommand } from "@reliverse/rempts";
3
- import fs from "fs-extra";
4
- import path from "pathe";
5
5
  export default defineCommand({
6
6
  meta: {
7
7
  name: "cmds",
@@ -1,5 +1,5 @@
1
+ import fs from "@reliverse/relifso";
1
2
  import { defineCommand, defineArgs, confirmPrompt } from "@reliverse/rempts";
2
- import fs from "fs-extra";
3
3
  import { commanderToRempts } from "./impl/commander.js";
4
4
  export default defineCommand({
5
5
  args: defineArgs({
@@ -100,7 +100,6 @@ ${argsProperties}
100
100
  ${actionBodyText}
101
101
  },
102
102
  });
103
-
104
103
  // Add runMain at the end of the file
105
104
  await runMain(${varDecl.getName()});
106
105
  `;
@@ -1,11 +1,29 @@
1
1
  /**
2
- * This script:
2
+ * This addon:
3
3
  * 1) Reads all *.ts or *.js files from a directory.
4
4
  * 2) Splits files larger than a specified line threshold.
5
5
  * 3) Splits functions larger than a specified line threshold into smaller helpers.
6
6
  *
7
7
  * Usage:
8
- * bun src/split-large-files.ts --dir ./example --file-threshold 30 --func-threshold 20
8
+ * bun dev split --dir ./example --file-threshold 30 --func-threshold 20
9
9
  *
10
- * Warning: This script is experimental and might break code. A more stable version will be available in the future.
10
+ * Warning: This addon is experimental and might break code. A more stable version will be available in the future.
11
11
  */
12
+ declare const _default: import("@reliverse/rempts").Command<{
13
+ directory: {
14
+ type: "string";
15
+ description: string;
16
+ required: true;
17
+ };
18
+ fileLineThreshold: {
19
+ type: "number";
20
+ description: string;
21
+ required: true;
22
+ };
23
+ funcLineThreshold: {
24
+ type: "number";
25
+ description: string;
26
+ required: true;
27
+ };
28
+ }>;
29
+ export default _default;
@@ -0,0 +1,41 @@
1
+ import fs from "@reliverse/relifso";
2
+ import { defineArgs, defineCommand } from "@reliverse/rempts";
3
+ import {
4
+ getAllSourceFiles,
5
+ splitLargeFileByLines,
6
+ splitLargeFunctions
7
+ } from "./impl.js";
8
+ export default defineCommand({
9
+ args: defineArgs({
10
+ directory: {
11
+ type: "string",
12
+ description: "The directory to split",
13
+ required: true
14
+ },
15
+ fileLineThreshold: {
16
+ type: "number",
17
+ description: "The line threshold for splitting files",
18
+ required: true
19
+ },
20
+ funcLineThreshold: {
21
+ type: "number",
22
+ description: "The line threshold for splitting functions",
23
+ required: true
24
+ }
25
+ }),
26
+ async run({ args }) {
27
+ const { directory, fileLineThreshold, funcLineThreshold } = args;
28
+ const allFiles = getAllSourceFiles(directory);
29
+ for (const filePath of allFiles) {
30
+ const lineCount = fs.readFileSync(filePath, "utf8").split("\n").length;
31
+ if (lineCount > fileLineThreshold) {
32
+ const newSplits = splitLargeFileByLines(filePath, fileLineThreshold);
33
+ newSplits.forEach((splitFilePath) => {
34
+ splitLargeFunctions(splitFilePath, funcLineThreshold);
35
+ });
36
+ } else {
37
+ splitLargeFunctions(filePath, funcLineThreshold);
38
+ }
39
+ }
40
+ }
41
+ });
@@ -1,9 +1,3 @@
1
- type SplitOptions = {
2
- directory: string;
3
- fileLineThreshold: number;
4
- funcLineThreshold: number;
5
- };
6
- export declare function parseCommandLineArgs(): SplitOptions;
7
1
  /**
8
2
  * 1) Reads all *.ts or *.js files from the given directory (recursively).
9
3
  * 2) Returns their file paths.
@@ -22,4 +16,3 @@ export declare function splitLargeFileByLines(filePath: string, threshold: numbe
22
16
  * - Currently this is naive. It basically splits the function body roughly in the middle.
23
17
  */
24
18
  export declare function splitLargeFunctions(filePath: string, funcLineThreshold: number): void;
25
- export {};
@@ -1,26 +1,6 @@
1
- import fs from "fs-extra";
2
- import path from "pathe";
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
3
  import ts from "typescript";
4
- export function parseCommandLineArgs() {
5
- const args = process.argv.slice(2);
6
- let directory = ".";
7
- let fileLineThreshold = 300;
8
- let funcLineThreshold = 50;
9
- for (let i = 0; i < args.length; i++) {
10
- const arg = args[i];
11
- if (arg === "--dir" && args[i + 1]) {
12
- directory = args[i + 1] ?? ".";
13
- i++;
14
- } else if (arg === "--file-threshold" && args[i + 1]) {
15
- fileLineThreshold = Number(args[i + 1]);
16
- i++;
17
- } else if (arg === "--func-threshold" && args[i + 1]) {
18
- funcLineThreshold = Number(args[i + 1]);
19
- i++;
20
- }
21
- }
22
- return { directory, fileLineThreshold, funcLineThreshold };
23
- }
24
4
  export function getAllSourceFiles(dir) {
25
5
  const results = [];
26
6
  function searchDirectory(directory) {
@@ -106,7 +86,6 @@ export function splitLargeFunctions(filePath, funcLineThreshold) {
106
86
  // Original function was split automatically
107
87
  ${bodyText.slice(0, midIndex)}
108
88
  }
109
-
110
89
  function ${helperFunctionName}() {
111
90
  // auto-generated second half
112
91
  ${bodyText.slice(midIndex)}
package/bin/impl.js CHANGED
@@ -1,5 +1,5 @@
1
- import fs from "fs-extra";
2
- import path from "pathe";
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
3
  import { processLibraryFlow } from "./libs/sdk/sdk-impl/library-flow.js";
4
4
  import { processRegularFlow } from "./libs/sdk/sdk-impl/regular-flow.js";
5
5
  import { bumpHandler } from "./libs/sdk/sdk-impl/utils/utils-bump.js";
@@ -90,7 +90,9 @@ export async function dlerBuild(isDev) {
90
90
  config.distJsrBuilder,
91
91
  config.transpileStub,
92
92
  config.transpileWatch,
93
- config.distJsrOutFilesExt
93
+ config.distJsrOutFilesExt,
94
+ config.distJsrAllowDirty,
95
+ config.distJsrSlowTypes
94
96
  );
95
97
  await finalizeBuild(
96
98
  timer,
@@ -184,7 +186,9 @@ export async function dlerPub(isDev) {
184
186
  config.distJsrBuilder,
185
187
  config.transpileStub,
186
188
  config.transpileWatch,
187
- config.distJsrOutFilesExt
189
+ config.distJsrOutFilesExt,
190
+ config.distJsrAllowDirty,
191
+ config.distJsrSlowTypes
188
192
  );
189
193
  await finalizeBuild(
190
194
  timer,