@reliverse/dler 1.2.2 → 1.2.3
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.
- package/README.md +126 -61
- package/bin/app/build/cmd.js +17 -0
- package/bin/app/deps/impl/types.js +0 -0
- package/bin/app/libs/cmd.js +0 -0
- package/bin/app/mono/cmd.js +0 -0
- package/bin/app/pub/cmd.js +17 -0
- package/bin/app/relifso/cmd.js +5 -0
- package/bin/app/relifso/impl/types.js +0 -0
- package/bin/app/relinka/cmd.js +0 -0
- package/bin/{cli/args/init/cmd → app/rempts/impl}/index.js +2 -1
- package/bin/app/spell/cmd.js +0 -0
- package/bin/app/split/cmd.js +0 -0
- package/bin/{cli/args/tools/index.js → app/tools/cmd.js} +1 -1
- package/bin/cli.js +101 -1
- package/bin/init.js +18 -2
- package/bin/libs/cfg/cfg-default.js +1 -0
- package/bin/libs/sdk/sdk-impl/build/build-library.js +57 -25
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist.js +3 -1
- package/bin/mod.js +7 -39
- package/package.json +6 -7
- package/bin/cli/args/deps/deps-mod.js +0 -48
- package/bin/cli/args/init/libs/reinit/reinit-mod.js +0 -5
- package/bin/cli/args/init/types.js +0 -1
- package/bin/cli/args/spell/spell-mod.js +0 -44
- package/bin/cli/args/split/split-mod.js +0 -26
- /package/bin/{cli/args/agg/agg-mod.js → app/agg/cmd.js} +0 -0
- /package/bin/{cli/args/conv/conv-mod.js → app/auth/cmd.js} +0 -0
- /package/bin/{cli/args/deps/types.js → app/cmds.js} +0 -0
- /package/bin/{cli/args → app}/conv/README.md +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl/types.js → app/conv/cmd.js} +0 -0
- /package/bin/{cli/args/mono/mono-mod.js → app/deps/cmd.js} +0 -0
- /package/bin/{cli/args/deps → app/deps/impl}/analyzer.js +0 -0
- /package/bin/{cli/args/deps → app/deps/impl}/filesystem.js +0 -0
- /package/bin/{cli/args/deps → app/deps/impl}/formatter.js +0 -0
- /package/bin/{cli/args/deps → app/deps/impl}/parser.js +0 -0
- /package/bin/{cli/args → app}/inject/README.md +0 -0
- /package/bin/{cli/args/inject/inject-mod.js → app/inject/cmd.js} +0 -0
- /package/bin/{cli/args/inject → app/inject/impl}/arg-ts-expect-error.txt +0 -0
- /package/bin/{cli/args/inject → app/inject/impl}/inject-mod.txt +0 -0
- /package/bin/{cli/args/inject → app/inject/impl}/reinject.config.js +0 -0
- /package/bin/{cli/args/inject → app/inject/impl}/ts-expect-error.txt +0 -0
- /package/bin/{cli/args/merger → app/merge}/README.md +0 -0
- /package/bin/{cli/args/merger/merger-mod.txt → app/merge/cmd.txt} +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/const.js +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/reinit-mod.txt +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-gitignore.js +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-license.js +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-readme.js +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/utils.js +0 -0
- /package/bin/{cli/args/init → app/rempts}/README.md +0 -0
- /package/bin/{cli/args/init/init-mod.txt → app/rempts/cmd.txt} +0 -0
- /package/bin/{cli/args → app}/split/README.md +0 -0
- /package/bin/{cli/args/split/split-impl.js → app/split/impl.js} +0 -0
- /package/bin/{cli/args/tools/tools-impl.js → app/tools/impl.js} +0 -0
- /package/bin/{tools.txt → app/tools/tools.txt} +0 -0
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# dler (prev. relidler) • reliverse bundler
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> @reliverse/dler (`/ˈdiː.lər/`, dealer) is a flexible, unified, and fully automated bundler for typescript and javascript projects, as well as an npm and jsr publishing tool. dler is not only a bundler, it also tries to serve as the most powerful codemod toolkit for js/ts.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[sponsor](https://github.com/sponsors/blefnk) — [discord](https://discord.gg/pb8ukbwpsj) — [repo](https://github.com/reliverse/dler) — [npm](https://npmjs.com/@reliverse/dler) — [docs](https://docs.reliverse.org/reliverse/dler)
|
|
6
6
|
|
|
7
7
|
## features
|
|
8
8
|
|
|
9
|
-
- 😘 replacement for `unbuild`
|
|
9
|
+
- 😘 replacement for `unjs/unbuild`
|
|
10
10
|
- ⚡ `dler` works via cli and sdk
|
|
11
11
|
- 📦 automated npm/jsr publishing
|
|
12
12
|
- ✅ ensures reliable js/ts builds
|
|
@@ -122,77 +122,41 @@ bun dev # bun src/mod.ts --dev
|
|
|
122
122
|
dler [build|pub] # if installed globally
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
absolutely! here’s your improved section, now listing all available spell types:
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
125
|
## 🔌 plugins
|
|
130
126
|
|
|
131
|
-
dler ships with a flexible plugin system and **
|
|
132
|
-
|
|
133
|
-
### 1. `magic-spells-dler-plugin`
|
|
134
|
-
|
|
135
|
-
**available spell types:**
|
|
136
|
-
|
|
137
|
-
- `replace-line` — injects contents from one file into another
|
|
138
|
-
- `rename-file` — renames the current file
|
|
139
|
-
- `remove-comment` — removes a specific comment from code
|
|
140
|
-
- `remove-line` — removes a specific line from code
|
|
141
|
-
- `remove-file` — deletes the current file
|
|
142
|
-
- `transform-content` — applies a transformation to the file content
|
|
143
|
-
- `copy-file` — copies the current file to a new location
|
|
144
|
-
- `move-file` — moves the current file to a new location
|
|
145
|
-
- `insert-at` — inserts content at a specific position in the file
|
|
146
|
-
|
|
147
|
-
**params:**
|
|
148
|
-
|
|
149
|
-
params are optional and comma-separated.
|
|
127
|
+
dler ships with a flexible plugin system and **15 built-in plugins** (from [@reliverse/addons](https://reliverse.org/addons)).
|
|
150
128
|
|
|
151
|
-
|
|
129
|
+
feel free to create your own plugins. plugins can be implemented as built-in directly in `src/app/plugin-name/impl/*` and then imported from `src/app/plugin-name/cmd.ts`; or implemented in your own library and then imported from `src/app/plugin-name/cmd.ts`.
|
|
152
130
|
|
|
153
|
-
|
|
154
|
-
- `false`: dler handles the spell automatically at postbuild
|
|
155
|
-
- `true`: disables default behavior, so you can trigger the spell yourself (e.g. from your own cli function)
|
|
156
|
-
|
|
157
|
-
more params coming soon...
|
|
131
|
+
### 1. `agg`
|
|
158
132
|
|
|
159
|
-
|
|
133
|
+
generates aggregator file with content like `import { getsomething } from "./utils.js"`.
|
|
160
134
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
- `// <dler-remove-file-{hooked=false}>` — deletes this file
|
|
165
|
-
- `// <dler-rename-file-"tsconfig.json"-{hooked=false}>` — renames this file (runs at postbuild because `hooked=false`)
|
|
166
|
-
|
|
167
|
-
**using `hooked=true`:**
|
|
135
|
+
```bash
|
|
136
|
+
dler agg ...
|
|
137
|
+
```
|
|
168
138
|
|
|
169
|
-
|
|
139
|
+
### 2. `auth`
|
|
170
140
|
|
|
171
|
-
|
|
141
|
+
best friend of auth+db libs like [better-auth](https://better-auth.com) and [drizzle-orm](https://orm.drizzle.team).
|
|
172
142
|
|
|
173
|
-
|
|
143
|
+
```bash
|
|
144
|
+
dler auth better-auth generate
|
|
145
|
+
```
|
|
174
146
|
|
|
175
|
-
|
|
176
|
-
- `dler spell --trigger all`
|
|
177
|
-
- `dler spell`
|
|
147
|
+
### 3. `build`
|
|
178
148
|
|
|
179
|
-
|
|
149
|
+
since dler is fully modular, build command is separated for its own build-in plugin as well.
|
|
180
150
|
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
// await dler.spell({}) // means all spells and all files
|
|
184
|
-
// spell: ["all"] // means all spells
|
|
185
|
-
// spell: [] // means all spells
|
|
186
|
-
// files: [] // means all files
|
|
151
|
+
```bash
|
|
152
|
+
dler build ...
|
|
187
153
|
```
|
|
188
154
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
here’s an extended and improved section for your readme, keeping your lowercase style and adding clarity, options, and a bit more detail:
|
|
155
|
+
### 4. `conv`
|
|
192
156
|
|
|
193
|
-
|
|
157
|
+
not yet documented.
|
|
194
158
|
|
|
195
|
-
###
|
|
159
|
+
### 5. `deps`
|
|
196
160
|
|
|
197
161
|
finds missing dependencies in your project by scanning your code for imports and comparing them to your `package.json`.
|
|
198
162
|
|
|
@@ -239,7 +203,11 @@ dler deps --all --directory ./src --include-builtins
|
|
|
239
203
|
missing dependencies are shown only once, even if used in multiple files.
|
|
240
204
|
deep imports like `dep/some/file` or `@org/dep/some/thing` are always resolved to their root package.
|
|
241
205
|
|
|
242
|
-
###
|
|
206
|
+
### 6. `inject`
|
|
207
|
+
|
|
208
|
+
not yet documented.
|
|
209
|
+
|
|
210
|
+
### 7. `libs`
|
|
243
211
|
|
|
244
212
|
builds and publishes specific subdirectories of your main project as standalone packages.
|
|
245
213
|
|
|
@@ -275,9 +243,106 @@ libslist: {
|
|
|
275
243
|
|
|
276
244
|
- more magic commands coming soon...
|
|
277
245
|
|
|
278
|
-
|
|
246
|
+
### 8. `merge`
|
|
247
|
+
|
|
248
|
+
not yet documented.
|
|
249
|
+
|
|
250
|
+
### 9. `mono`
|
|
251
|
+
|
|
252
|
+
not yet documented.
|
|
253
|
+
|
|
254
|
+
### 10. `pub`
|
|
255
|
+
|
|
256
|
+
pub command is separated for its own build-in plugin as well.
|
|
257
|
+
|
|
258
|
+
it already calls build command by itself, so you don't need to run `dler build` separately.
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
dler pub ...
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### 11. `relifso`
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
dler relifso init ...
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 12. `relinka`
|
|
271
|
+
|
|
272
|
+
@reliverse/relinka's best friend. learn more in its [docs](https://github.com/reliverse/relinka).
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
dler relinka --console-to-relinka
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### 13. `rempts`
|
|
279
|
+
|
|
280
|
+
@reliverse/rempts's best friend. learn more in its [docs](https://github.com/reliverse/rempts).
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
dler rempts init --cmd my-cmd-1
|
|
284
|
+
dler rempts init --cmds
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### 14. `spell`
|
|
288
|
+
|
|
289
|
+
**available spell types:**
|
|
290
|
+
|
|
291
|
+
- `replace-line` — injects contents from one file into another
|
|
292
|
+
- `rename-file` — renames the current file
|
|
293
|
+
- `remove-comment` — removes a specific comment from code
|
|
294
|
+
- `remove-line` — removes a specific line from code
|
|
295
|
+
- `remove-file` — deletes the current file
|
|
296
|
+
- `transform-content` — applies a transformation to the file content
|
|
297
|
+
- `copy-file` — copies the current file to a new location
|
|
298
|
+
- `move-file` — moves the current file to a new location
|
|
299
|
+
- `insert-at` — inserts content at a specific position in the file
|
|
300
|
+
|
|
301
|
+
**params:**
|
|
302
|
+
|
|
303
|
+
params are optional and comma-separated.
|
|
304
|
+
|
|
305
|
+
currently, only the first param is supported:
|
|
306
|
+
|
|
307
|
+
- `hooked` (boolean, default: `false`)
|
|
308
|
+
- `false`: dler handles the spell automatically at postbuild
|
|
309
|
+
- `true`: disables default behavior, so you can trigger the spell yourself (e.g. from your own cli function)
|
|
310
|
+
|
|
311
|
+
more params coming soon...
|
|
312
|
+
|
|
313
|
+
**usage examples:**
|
|
314
|
+
|
|
315
|
+
- `export * from "../../types.js"; // <dler-replace-line-{hooked=false}>` — injects file contents at this line
|
|
316
|
+
- `// @ts-expect-error <dler-remove-comment-{hooked=false}>` — removes just this comment
|
|
317
|
+
- `// <dler-remove-line-{hooked=false}>` — removes this line
|
|
318
|
+
- `// <dler-remove-file-{hooked=false}>` — deletes this file
|
|
319
|
+
- `// <dler-rename-file-"tsconfig.json"-{hooked=false}>` — renames this file (runs at postbuild because `hooked=false`)
|
|
320
|
+
|
|
321
|
+
**using `hooked=true`:**
|
|
322
|
+
|
|
323
|
+
- `// <dler-rename-file-"tsconfig.json"-{hooked=true}>` — renames the file, but only when you trigger it yourself (hooked from your side)
|
|
324
|
+
|
|
325
|
+
**triggering spells:**
|
|
326
|
+
|
|
327
|
+
from dler’s cli:
|
|
328
|
+
|
|
329
|
+
- `dler spell --trigger rename-file,... --files tsconfig.json,...`
|
|
330
|
+
- `dler spell --trigger all`
|
|
331
|
+
- `dler spell`
|
|
332
|
+
|
|
333
|
+
from your own code:
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
await dler.spell({ spells: ["rename-file"], files: [] });
|
|
337
|
+
// await dler.spell({}) // means all spells and all files
|
|
338
|
+
// spell: ["all"] // means all spells
|
|
339
|
+
// spell: [] // means all spells
|
|
340
|
+
// files: [] // means all files
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
p.s. [see how rse cli uses hooked=true](https://github.com/reliverse/rse/blob/main/src/postbuild.ts)
|
|
279
344
|
|
|
280
|
-
###
|
|
345
|
+
### 15. `tools`
|
|
281
346
|
|
|
282
347
|
lets you run standalone dler features directly from the cli:
|
|
283
348
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineArgs, defineCommand } from "@reliverse/rempts";
|
|
2
|
+
import { dlerBuild } from "../../cli.js";
|
|
3
|
+
export default defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "build",
|
|
6
|
+
description: "Build the project"
|
|
7
|
+
},
|
|
8
|
+
args: defineArgs({
|
|
9
|
+
dev: {
|
|
10
|
+
type: "boolean",
|
|
11
|
+
description: "Runs the CLI in dev mode"
|
|
12
|
+
}
|
|
13
|
+
}),
|
|
14
|
+
async run({ args }) {
|
|
15
|
+
await dlerBuild(args.dev);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineArgs, defineCommand } from "@reliverse/rempts";
|
|
2
|
+
import { dlerPub } from "../../cli.js";
|
|
3
|
+
export default defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "build",
|
|
6
|
+
description: "Build the project"
|
|
7
|
+
},
|
|
8
|
+
args: defineArgs({
|
|
9
|
+
dev: {
|
|
10
|
+
type: "boolean",
|
|
11
|
+
description: "Runs the CLI in dev mode"
|
|
12
|
+
}
|
|
13
|
+
}),
|
|
14
|
+
async run({ args }) {
|
|
15
|
+
await dlerPub(args.dev);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FILE_TYPES } from "./impl/const.js";
|
|
2
|
+
export { gitignoreTemplate } from "./impl/templates/t-gitignore.js";
|
|
3
|
+
export { licenseTemplate } from "./impl/templates/t-license.js";
|
|
4
|
+
export { readmeTemplate } from "./impl/templates/t-readme.js";
|
|
5
|
+
export { escapeMarkdownCodeBlocks } from "./impl/utils.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { relinka } from "@reliverse/relinka";
|
|
2
2
|
import { defineCommand } from "@reliverse/rempts";
|
|
3
3
|
import path from "pathe";
|
|
4
|
-
import { printUsage, useAggregator } from "./
|
|
4
|
+
import { printUsage, useAggregator } from "./impl.js";
|
|
5
5
|
const TOOLS = ["agg"];
|
|
6
6
|
export default defineCommand({
|
|
7
7
|
meta: {
|
package/bin/cli.js
CHANGED
|
@@ -10,7 +10,107 @@ import { handleDlerError } from "./libs/sdk/sdk-impl/utils/utils-error.js";
|
|
|
10
10
|
import { finalizeBuild } from "./libs/sdk/sdk-impl/utils/utils-info.js";
|
|
11
11
|
import { createPerfTimer } from "./libs/sdk/sdk-impl/utils/utils-perf.js";
|
|
12
12
|
import { loadConfig } from "./load.js";
|
|
13
|
-
export async function
|
|
13
|
+
export async function dlerBuild(isDev) {
|
|
14
|
+
const timer = createPerfTimer();
|
|
15
|
+
try {
|
|
16
|
+
const config = await loadConfig();
|
|
17
|
+
if (isDev) {
|
|
18
|
+
config.commonPubPause = true;
|
|
19
|
+
config.bumpDisable = true;
|
|
20
|
+
relinka(
|
|
21
|
+
"log",
|
|
22
|
+
"Development mode: Publishing paused and version bumping disabled."
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (config.logsFreshFile) {
|
|
26
|
+
await fs.remove(path.join(PROJECT_ROOT, config.logsFileName));
|
|
27
|
+
}
|
|
28
|
+
await removeDistFolders(
|
|
29
|
+
config.distNpmDirName,
|
|
30
|
+
config.distJsrDirName,
|
|
31
|
+
config.libsDirDist,
|
|
32
|
+
config.libsList
|
|
33
|
+
);
|
|
34
|
+
if (!config.bumpDisable) {
|
|
35
|
+
await bumpHandler(
|
|
36
|
+
config.bumpMode,
|
|
37
|
+
config.bumpDisable,
|
|
38
|
+
config.commonPubPause,
|
|
39
|
+
config.bumpFilter
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
await processRegularFlow(
|
|
43
|
+
timer,
|
|
44
|
+
isDev,
|
|
45
|
+
config.coreIsCLI,
|
|
46
|
+
config.libsActMode,
|
|
47
|
+
config.commonPubRegistry,
|
|
48
|
+
config.coreEntrySrcDir,
|
|
49
|
+
config.distNpmDirName,
|
|
50
|
+
config.distNpmBuilder,
|
|
51
|
+
config.coreEntryFile,
|
|
52
|
+
config.distJsrDryRun,
|
|
53
|
+
config.distJsrFailOnWarn,
|
|
54
|
+
config.commonPubPause,
|
|
55
|
+
config.distJsrDirName,
|
|
56
|
+
config.distJsrBuilder,
|
|
57
|
+
config.transpileTarget,
|
|
58
|
+
config.transpileFormat,
|
|
59
|
+
config.transpileSplitting,
|
|
60
|
+
config.transpileMinify,
|
|
61
|
+
config.transpileSourcemap,
|
|
62
|
+
config.transpilePublicPath,
|
|
63
|
+
config.distJsrAllowDirty,
|
|
64
|
+
config.distJsrSlowTypes,
|
|
65
|
+
config.distNpmOutFilesExt,
|
|
66
|
+
config.rmDepsMode,
|
|
67
|
+
config.transpileStub,
|
|
68
|
+
config.transpileWatch,
|
|
69
|
+
config.distJsrGenTsconfig,
|
|
70
|
+
config.coreDeclarations,
|
|
71
|
+
{ coreDescription: config.coreDescription }
|
|
72
|
+
);
|
|
73
|
+
await processLibraryFlow(
|
|
74
|
+
timer,
|
|
75
|
+
isDev,
|
|
76
|
+
config.libsActMode,
|
|
77
|
+
config.libsList,
|
|
78
|
+
config.distJsrDryRun,
|
|
79
|
+
config.distJsrFailOnWarn,
|
|
80
|
+
config.libsDirDist,
|
|
81
|
+
config.libsDirSrc,
|
|
82
|
+
config.commonPubPause,
|
|
83
|
+
config.commonPubRegistry,
|
|
84
|
+
config.distNpmOutFilesExt,
|
|
85
|
+
config.distNpmBuilder,
|
|
86
|
+
config.coreEntrySrcDir,
|
|
87
|
+
config.rmDepsMode,
|
|
88
|
+
config.rmDepsPatterns,
|
|
89
|
+
config.transpileEsbuild,
|
|
90
|
+
config.transpileTarget,
|
|
91
|
+
config.transpileFormat,
|
|
92
|
+
config.transpileSplitting,
|
|
93
|
+
config.transpileSourcemap,
|
|
94
|
+
config.transpilePublicPath,
|
|
95
|
+
config.distJsrBuilder,
|
|
96
|
+
config.transpileStub,
|
|
97
|
+
config.transpileWatch,
|
|
98
|
+
config.distJsrOutFilesExt
|
|
99
|
+
);
|
|
100
|
+
await finalizeBuild(
|
|
101
|
+
timer,
|
|
102
|
+
config.commonPubPause,
|
|
103
|
+
config.libsList,
|
|
104
|
+
config.distNpmDirName,
|
|
105
|
+
config.distJsrDirName,
|
|
106
|
+
config.libsDirDist,
|
|
107
|
+
isDev
|
|
108
|
+
);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
handleDlerError(error, timer);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export async function dlerPub(isDev) {
|
|
14
114
|
const timer = createPerfTimer();
|
|
15
115
|
try {
|
|
16
116
|
const config = await loadConfig();
|
package/bin/init.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { relinka } from "@reliverse/relinka";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import path from "pathe";
|
|
4
|
+
import { readPackageJSON } from "pkg-types";
|
|
4
5
|
import { DEFAULT_CONFIG } from "./libs/cfg/cfg-default.js";
|
|
5
6
|
const CONFIG_FILENAME = ".config/dler.ts";
|
|
6
7
|
export async function initDlerConfig(isDev) {
|
|
@@ -10,7 +11,15 @@ export async function initDlerConfig(isDev) {
|
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
try {
|
|
13
|
-
|
|
14
|
+
let pkgDescription = void 0;
|
|
15
|
+
try {
|
|
16
|
+
const pkg = await readPackageJSON();
|
|
17
|
+
if (pkg && typeof pkg.description === "string" && pkg.description.trim()) {
|
|
18
|
+
pkgDescription = pkg.description.trim();
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
const configContent = generateConfig(isDev, pkgDescription);
|
|
14
23
|
await fs.outputFile(configPath, configContent, "utf-8");
|
|
15
24
|
relinka("success", `Config was created at ${configPath}`);
|
|
16
25
|
relinka("log", "Edit this file to customize build and publish settings");
|
|
@@ -29,7 +38,7 @@ export async function initDlerConfig(isDev) {
|
|
|
29
38
|
process.exit(1);
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
|
-
function generateConfig(isDev) {
|
|
41
|
+
function generateConfig(isDev, pkgDescription) {
|
|
33
42
|
const importDefineConfigStatement = isDev ? `import { defineConfig } from "./libs/cfg/cfg-mod.js";` : `import { defineConfig } from "@reliverse/dler-cfg";`;
|
|
34
43
|
const verboseValue = getValue(isDev, true, DEFAULT_CONFIG.commonVerbose);
|
|
35
44
|
const isCLIValue = getValue(isDev, true, DEFAULT_CONFIG.coreIsCLI);
|
|
@@ -48,6 +57,12 @@ function generateConfig(isDev) {
|
|
|
48
57
|
false,
|
|
49
58
|
DEFAULT_CONFIG.coreDeclarations
|
|
50
59
|
);
|
|
60
|
+
const coreDescriptionValue = getValue(
|
|
61
|
+
isDev,
|
|
62
|
+
// TODO: remove `description` from dler's `package.json` when ensured that whole dler's codebase can optionally read dler.ts' `coreDescription`
|
|
63
|
+
"dler (prev. relidler) is a flexible, unified, and fully automated bundler for TypeScript and JavaScript projects, as well as an NPM and JSR publishing tool.",
|
|
64
|
+
pkgDescription || DEFAULT_CONFIG.coreDescription
|
|
65
|
+
);
|
|
51
66
|
const libsActModeValue = getValue(
|
|
52
67
|
isDev,
|
|
53
68
|
"main-and-libs",
|
|
@@ -100,6 +115,7 @@ export default defineConfig({
|
|
|
100
115
|
|
|
101
116
|
// Core configuration
|
|
102
117
|
coreDeclarations: ${coreDeclarationsValue},
|
|
118
|
+
coreDescription: ${JSON.stringify(coreDescriptionValue)},
|
|
103
119
|
coreEntryFile: "${DEFAULT_CONFIG.coreEntryFile}",
|
|
104
120
|
coreEntrySrcDir: "${DEFAULT_CONFIG.coreEntrySrcDir}",
|
|
105
121
|
coreIsCLI: ${isCLIValue},
|
|
@@ -145,20 +145,28 @@ async function library_buildJsrDist(options) {
|
|
|
145
145
|
outputDirRootResolved,
|
|
146
146
|
BIN_DIR_NAME
|
|
147
147
|
);
|
|
148
|
-
const
|
|
148
|
+
const { libSpecificSrcDir, libDirName } = await determineNpmSourceDirectory(
|
|
149
|
+
libName,
|
|
150
|
+
libMainFile,
|
|
151
|
+
libSourceDirResolved,
|
|
152
|
+
libsList,
|
|
153
|
+
"jsr"
|
|
154
|
+
);
|
|
155
|
+
const bundlerEntryPoint = distJsrBuilder === "jsr" ? libSpecificSrcDir : entryFilePathResolved;
|
|
149
156
|
const libConfig = libsList[libName];
|
|
150
157
|
const libDeclarations = libConfig?.libDeclarations ?? false;
|
|
151
158
|
const buildParams = {
|
|
152
159
|
targetType,
|
|
153
160
|
builder: distJsrBuilder,
|
|
154
|
-
libSourceDir:
|
|
161
|
+
libSourceDir: libSpecificSrcDir,
|
|
155
162
|
entryFilePath: bundlerEntryPoint,
|
|
156
163
|
outputDirRoot: outputDirRootResolved,
|
|
157
164
|
outputDirBin: outputDirBinResolved,
|
|
158
165
|
libDeclarations,
|
|
159
166
|
distJsrOutFilesExt,
|
|
160
|
-
options
|
|
161
|
-
|
|
167
|
+
options,
|
|
168
|
+
libDirName
|
|
169
|
+
// Pass determined libDirName
|
|
162
170
|
};
|
|
163
171
|
await buildDistributionTarget(buildParams);
|
|
164
172
|
relinka(
|
|
@@ -304,21 +312,36 @@ async function buildDistributionTarget(params) {
|
|
|
304
312
|
unifiedBundlerOutExt
|
|
305
313
|
};
|
|
306
314
|
await library_bundleWithBuilder(bundleRequest);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
315
|
+
if (await fs.pathExists(outputDirBin)) {
|
|
316
|
+
const files = await fs.readdir(outputDirBin);
|
|
317
|
+
if (files.length > 0) {
|
|
318
|
+
await library_performCommonBuildSteps({
|
|
319
|
+
coreEntryFileName: path.basename(libMainFile),
|
|
320
|
+
outDirRoot: outputDirRoot,
|
|
321
|
+
outDirBin: outputDirBin,
|
|
322
|
+
isJsr,
|
|
323
|
+
libName,
|
|
324
|
+
libsList,
|
|
325
|
+
rmDepsMode,
|
|
326
|
+
rmDepsPatterns,
|
|
327
|
+
unifiedBundlerOutExt,
|
|
328
|
+
distJsrOutFilesExt,
|
|
329
|
+
deleteFiles: isJsr,
|
|
330
|
+
// Only delete files for JSR builds
|
|
331
|
+
libDirName
|
|
332
|
+
});
|
|
333
|
+
} else {
|
|
334
|
+
relinka(
|
|
335
|
+
"warn",
|
|
336
|
+
`${logPrefix} No files found in ${outputDirBin} after bundling`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
relinka(
|
|
341
|
+
"warn",
|
|
342
|
+
`${logPrefix} Output directory ${outputDirBin} does not exist after bundling`
|
|
343
|
+
);
|
|
344
|
+
}
|
|
322
345
|
relinka("log", `${logPrefix} Completed build target processing.`);
|
|
323
346
|
}
|
|
324
347
|
async function library_bundleWithBuilder(params) {
|
|
@@ -494,19 +517,26 @@ async function library_bundleUsingUnified(entryPoint, outDirBin, builder, source
|
|
|
494
517
|
);
|
|
495
518
|
validatedExt = "js";
|
|
496
519
|
}
|
|
497
|
-
|
|
498
|
-
const outDirRelative = path.relative(rootDir, outDirBin);
|
|
520
|
+
await ensuredir(outDirBin);
|
|
499
521
|
const unifiedBuildConfig = {
|
|
500
522
|
clean: false,
|
|
501
523
|
declaration: libDeclarations ? "compatible" : false,
|
|
502
524
|
entries: [
|
|
503
525
|
{
|
|
504
526
|
builder,
|
|
505
|
-
input:
|
|
506
|
-
outDir:
|
|
507
|
-
|
|
527
|
+
input: entryPoint,
|
|
528
|
+
outDir: outDirBin,
|
|
529
|
+
// Explicitly set the output directory
|
|
530
|
+
rootDir: sourceDirContext,
|
|
531
|
+
ext: validatedExt,
|
|
532
|
+
...builder === "mkdist" && {
|
|
533
|
+
cleanDist: true
|
|
534
|
+
// Clean the output directory before building
|
|
535
|
+
}
|
|
508
536
|
}
|
|
509
537
|
],
|
|
538
|
+
outDir: outDirBin,
|
|
539
|
+
rootDir: sourceDirContext,
|
|
510
540
|
rollup: {
|
|
511
541
|
emitCJS: false,
|
|
512
542
|
esbuild: {
|
|
@@ -519,7 +549,9 @@ async function library_bundleUsingUnified(entryPoint, outDirBin, builder, source
|
|
|
519
549
|
}
|
|
520
550
|
},
|
|
521
551
|
hooks: {},
|
|
522
|
-
stub: transpileStub
|
|
552
|
+
stub: transpileStub,
|
|
553
|
+
transpileWatch: false
|
|
554
|
+
// Not supported by mkdist
|
|
523
555
|
};
|
|
524
556
|
try {
|
|
525
557
|
await unifiedBuild(rootDir, unifiedBuildConfig, outDirBin);
|
|
@@ -2,6 +2,7 @@ import { relinka } from "@reliverse/relinka";
|
|
|
2
2
|
import { mkdist } from "mkdist";
|
|
3
3
|
import { relative } from "pathe";
|
|
4
4
|
import {
|
|
5
|
+
ensuredir,
|
|
5
6
|
rmdir,
|
|
6
7
|
symlink,
|
|
7
8
|
warn
|
|
@@ -13,12 +14,13 @@ export async function mkdistBuild(ctx) {
|
|
|
13
14
|
await ctx.hooks.callHook("mkdist:entries", ctx, entries);
|
|
14
15
|
for (const entry of entries) {
|
|
15
16
|
const distDir = entry.outDir || entry.input;
|
|
17
|
+
await ensuredir(distDir);
|
|
16
18
|
if (ctx.options.transpileStub) {
|
|
17
19
|
await rmdir(distDir);
|
|
18
20
|
await symlink(entry.input, distDir);
|
|
19
21
|
} else {
|
|
20
22
|
const mkdistOptions = {
|
|
21
|
-
cleanDist:
|
|
23
|
+
cleanDist: true,
|
|
22
24
|
distDir,
|
|
23
25
|
rootDir: ctx.options.rootDir,
|
|
24
26
|
srcDir: entry.input,
|
package/bin/mod.js
CHANGED
|
@@ -1,46 +1,14 @@
|
|
|
1
|
-
import { defineCommand,
|
|
2
|
-
import { dler } from "./cli.js";
|
|
1
|
+
import { runMain, defineCommand, defineArgs } from "@reliverse/rempts";
|
|
3
2
|
import { initDlerConfig } from "./init.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
meta: {
|
|
7
|
-
name: "dler",
|
|
8
|
-
version: "1.2.0",
|
|
9
|
-
description: "dler CLI https://docs.reliverse.org"
|
|
10
|
-
},
|
|
11
|
-
args: {
|
|
3
|
+
const main = defineCommand({
|
|
4
|
+
args: defineArgs({
|
|
12
5
|
dev: {
|
|
13
6
|
type: "boolean",
|
|
14
7
|
description: "Runs the CLI in dev mode"
|
|
15
8
|
}
|
|
16
|
-
},
|
|
17
|
-
async
|
|
18
|
-
|
|
19
|
-
await validateDevCwd(isDev, ["dler"], "dler", "reliverse");
|
|
20
|
-
await initDlerConfig(isDev);
|
|
21
|
-
await dler(isDev);
|
|
9
|
+
}),
|
|
10
|
+
async onCmdInit({ args }) {
|
|
11
|
+
await initDlerConfig(args.dev);
|
|
22
12
|
}
|
|
23
13
|
});
|
|
24
|
-
await runMain(
|
|
25
|
-
fileBasedCmds: {
|
|
26
|
-
enable: true,
|
|
27
|
-
// Enables file-based subcommand detection.
|
|
28
|
-
cmdsRootPath: "src/cli/args"
|
|
29
|
-
// Directory to scan for subcommands.
|
|
30
|
-
},
|
|
31
|
-
alias: {
|
|
32
|
-
v: "verbose"
|
|
33
|
-
// Maps shorthand flag -v to --verbose.
|
|
34
|
-
},
|
|
35
|
-
strict: false,
|
|
36
|
-
// Do not throw errors for unknown flags.
|
|
37
|
-
warnOnUnknown: false,
|
|
38
|
-
// Warn when encountering unknown flags.
|
|
39
|
-
negatedBoolean: true
|
|
40
|
-
// Support for negated booleans (e.g., --no-verbose).
|
|
41
|
-
// unknown: (flagName) => {
|
|
42
|
-
// relinka("warn", "Unknown flag encountered:", flagName);
|
|
43
|
-
// return false;
|
|
44
|
-
// },
|
|
45
|
-
// TODO: unknownErrorMsg: "An unhandled error occurred, please report it at https://github.com/reliverse/dler"
|
|
46
|
-
});
|
|
14
|
+
await runMain(main);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@reliverse/relico": "^1.1.
|
|
4
|
-
"@reliverse/relinka": "^1.4.
|
|
5
|
-
"@reliverse/rempts": "^1.
|
|
3
|
+
"@reliverse/relico": "^1.1.2",
|
|
4
|
+
"@reliverse/relinka": "^1.4.5",
|
|
5
|
+
"@reliverse/rempts": "^1.7.4",
|
|
6
6
|
"@rollup/plugin-alias": "^5.1.1",
|
|
7
7
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
8
8
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"@rollup/pluginutils": "^5.1.4",
|
|
12
12
|
"bun": "^1.2.13",
|
|
13
13
|
"chalk": "^5.4.1",
|
|
14
|
-
"commander": "^13.1.0",
|
|
15
14
|
"defu": "^6.1.4",
|
|
16
15
|
"esbuild": "^0.25.4",
|
|
17
16
|
"execa": "^9.5.3",
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
"license": "MIT",
|
|
42
41
|
"name": "@reliverse/dler",
|
|
43
42
|
"type": "module",
|
|
44
|
-
"version": "1.2.
|
|
43
|
+
"version": "1.2.3",
|
|
45
44
|
"keywords": [
|
|
46
45
|
"reliverse",
|
|
47
46
|
"cli",
|
|
@@ -67,12 +66,12 @@
|
|
|
67
66
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
68
67
|
"@types/bun": "^1.2.13",
|
|
69
68
|
"@types/fs-extra": "^11.0.4",
|
|
70
|
-
"@types/node": "^22.15.
|
|
69
|
+
"@types/node": "^22.15.18",
|
|
71
70
|
"@types/semver": "^7.7.0",
|
|
72
71
|
"eslint": "^9.26.0",
|
|
73
72
|
"eslint-plugin-no-relative-import-paths": "^1.6.1",
|
|
74
73
|
"eslint-plugin-perfectionist": "^4.13.0",
|
|
75
|
-
"knip": "^5.
|
|
74
|
+
"knip": "^5.56.0",
|
|
76
75
|
"typescript": "^5.8.3",
|
|
77
76
|
"typescript-eslint": "^8.32.1"
|
|
78
77
|
},
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { re } from "@reliverse/relico";
|
|
2
|
-
import { Command } from "commander";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { analyzeDependencies } from "./analyzer.js";
|
|
5
|
-
import { formatOutput } from "./formatter.js";
|
|
6
|
-
export const createCli = () => {
|
|
7
|
-
const program = new Command();
|
|
8
|
-
program.name("deps").description("Find dependencies used but not listed in package.json").version("1.0.0").option(
|
|
9
|
-
"-d, --directory <path>",
|
|
10
|
-
"directory to scan (defaults to current directory)",
|
|
11
|
-
"."
|
|
12
|
-
).option(
|
|
13
|
-
"-a, --all",
|
|
14
|
-
"show all dependencies (both listed and not listed)",
|
|
15
|
-
false
|
|
16
|
-
).option("-i, --ignore <patterns>", "comma-separated patterns to ignore", "").option("-j, --json", "output in JSON format", false).option(
|
|
17
|
-
"-b, --include-builtins",
|
|
18
|
-
"include Node.js built-in modules in the output",
|
|
19
|
-
false
|
|
20
|
-
).action(async (cmdOptions) => {
|
|
21
|
-
try {
|
|
22
|
-
const directory = path.resolve(cmdOptions.directory);
|
|
23
|
-
const ignorePatterns = cmdOptions.ignore ? cmdOptions.ignore.split(",") : [];
|
|
24
|
-
const options = {
|
|
25
|
-
directory,
|
|
26
|
-
showAll: cmdOptions.all,
|
|
27
|
-
ignorePatterns,
|
|
28
|
-
json: cmdOptions.json,
|
|
29
|
-
includeBuiltins: cmdOptions.includeBuiltins
|
|
30
|
-
};
|
|
31
|
-
console.log(re.gray(`Scanning directory: ${directory}`));
|
|
32
|
-
const result = await analyzeDependencies(options);
|
|
33
|
-
const output = formatOutput(result, options);
|
|
34
|
-
console.log(output);
|
|
35
|
-
if (result.missingDependencies.length > 0) {
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error("Error:", error);
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return program;
|
|
44
|
-
};
|
|
45
|
-
const cli = createCli();
|
|
46
|
-
if (require.main === module) {
|
|
47
|
-
cli.parse(process.argv);
|
|
48
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { FILE_TYPES } from "./reint-impl/const.js";
|
|
2
|
-
export { gitignoreTemplate } from "./reint-impl/templates/t-gitignore.js";
|
|
3
|
-
export { licenseTemplate } from "./reint-impl/templates/t-license.js";
|
|
4
|
-
export { readmeTemplate } from "./reint-impl/templates/t-readme.js";
|
|
5
|
-
export { escapeMarkdownCodeBlocks } from "./reint-impl/utils.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./libs/reinit/reint-impl/types.js";
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { spells } from "../../../libs/sdk/sdk-impl/spell/spell-mod.js";
|
|
3
|
-
export const createCli = () => {
|
|
4
|
-
const program = new Command();
|
|
5
|
-
program.name("dler-spells").description("Execute magic spells in your codebase").version("1.0.0");
|
|
6
|
-
program.command("trigger").description("Trigger magic spells").option(
|
|
7
|
-
"--spells <spells>",
|
|
8
|
-
'Comma-separated list of spells to execute (or "all")',
|
|
9
|
-
"all"
|
|
10
|
-
).option(
|
|
11
|
-
"--files <files>",
|
|
12
|
-
"Comma-separated list of files to process (or all if not specified)"
|
|
13
|
-
).option("--dry-run", "Preview changes without applying them", false).action(async (options) => {
|
|
14
|
-
const requestedSpells = options.spells ? options.spells.split(",") : ["all"];
|
|
15
|
-
const files = options.files ? options.files.split(",") : [];
|
|
16
|
-
console.log(`Triggering spells: ${requestedSpells.join(", ")}`);
|
|
17
|
-
if (files.length) {
|
|
18
|
-
console.log(`On files: ${files.join(", ")}`);
|
|
19
|
-
} else {
|
|
20
|
-
console.log("On all files");
|
|
21
|
-
}
|
|
22
|
-
if (options.dryRun) {
|
|
23
|
-
console.log("DRY RUN - No changes will be applied");
|
|
24
|
-
}
|
|
25
|
-
const results = await spells({
|
|
26
|
-
spells: requestedSpells,
|
|
27
|
-
files,
|
|
28
|
-
dryRun: options.dryRun
|
|
29
|
-
});
|
|
30
|
-
console.log("\nResults:");
|
|
31
|
-
for (const result of results) {
|
|
32
|
-
const status = result.success ? "\u2713" : "\u2717";
|
|
33
|
-
console.log(
|
|
34
|
-
`${status} ${result.file}: ${result.spell.type} - ${result.message}`
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return program;
|
|
39
|
-
};
|
|
40
|
-
const cli = createCli();
|
|
41
|
-
async function main() {
|
|
42
|
-
cli.parse(process.argv);
|
|
43
|
-
}
|
|
44
|
-
await main();
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import {
|
|
3
|
-
getAllSourceFiles,
|
|
4
|
-
parseCommandLineArgs,
|
|
5
|
-
splitLargeFileByLines,
|
|
6
|
-
splitLargeFunctions
|
|
7
|
-
} from "./split-impl.js";
|
|
8
|
-
async function main() {
|
|
9
|
-
const { directory, fileLineThreshold, funcLineThreshold } = parseCommandLineArgs();
|
|
10
|
-
const allFiles = getAllSourceFiles(directory);
|
|
11
|
-
for (const filePath of allFiles) {
|
|
12
|
-
const lineCount = fs.readFileSync(filePath, "utf8").split("\n").length;
|
|
13
|
-
if (lineCount > fileLineThreshold) {
|
|
14
|
-
const newSplits = splitLargeFileByLines(filePath, fileLineThreshold);
|
|
15
|
-
newSplits.forEach((splitFilePath) => {
|
|
16
|
-
splitLargeFunctions(splitFilePath, funcLineThreshold);
|
|
17
|
-
});
|
|
18
|
-
} else {
|
|
19
|
-
splitLargeFunctions(filePath, funcLineThreshold);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
main().catch((err) => {
|
|
24
|
-
console.error(err);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-gitignore.js
RENAMED
|
File without changes
|
/package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-license.js
RENAMED
|
File without changes
|
/package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-readme.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|