@reliverse/dler 2.2.17 → 2.3.1
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 +190 -55
- package/dist/cli.js +5 -2
- package/dist/cmds/biome/cmd.d.ts +5 -1
- package/dist/cmds/biome/cmd.js +20 -29
- package/dist/cmds/biome/impl.js +26 -21
- package/dist/cmds/build/cmd.d.ts +91 -1
- package/dist/cmds/build/cmd.js +289 -580
- package/dist/cmds/clean/cmd.d.ts +14 -1
- package/dist/cmds/clean/cmd.js +61 -112
- package/dist/cmds/clean/impl.js +61 -76
- package/dist/cmds/clean/presets.js +2 -9
- package/dist/cmds/init/cmd.d.ts +9 -0
- package/dist/cmds/init/cmd.js +87 -0
- package/dist/cmds/publish/cmd.d.ts +32 -1
- package/dist/cmds/publish/cmd.js +125 -165
- package/dist/cmds/senv/cmd.d.ts +7 -1
- package/dist/cmds/senv/cmd.js +41 -80
- package/dist/cmds/test/cmd.d.ts +9 -0
- package/dist/cmds/test/cmd.js +157 -0
- package/dist/cmds/tsc/cache.d.ts +2 -2
- package/dist/cmds/tsc/cache.js +37 -19
- package/dist/cmds/tsc/cmd.d.ts +14 -1
- package/dist/cmds/tsc/cmd.js +44 -80
- package/dist/cmds/tsc/impl.js +42 -92
- package/dist/cmds/update/cmd.d.ts +11 -1
- package/dist/cmds/update/cmd.js +57 -81
- package/dist/cmds/update/impl.js +16 -30
- package/dist/cmds/update/utils.js +116 -82
- package/dist/mod.d.ts +3 -0
- package/dist/mod.js +6 -0
- package/dist/utils/find-entry.d.ts +1 -0
- package/dist/utils/find-entry.js +46 -0
- package/package.json +53 -30
- package/src/cli.ts +9 -0
- package/LICENSE +0 -21
- /package/dist/{cmds/const.d.ts → const.d.ts} +0 -0
- /package/dist/{cmds/const.js → const.js} +0 -0
package/dist/cmds/build/cmd.js
CHANGED
|
@@ -8,679 +8,310 @@ import {
|
|
|
8
8
|
replaceExportsInPackages
|
|
9
9
|
} from "@reliverse/helpers";
|
|
10
10
|
import { logger } from "@reliverse/relinka";
|
|
11
|
-
import {
|
|
11
|
+
import { defineCommand, option } from "@reliverse/rempts-core";
|
|
12
|
+
import { type } from "arktype";
|
|
12
13
|
export default defineCommand({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
examples: [
|
|
17
|
-
"dler build",
|
|
18
|
-
'dler build --filter "@reliverse/rempts,@reliverse/build"',
|
|
19
|
-
'dler build --filter "@reliverse/dler-*"',
|
|
20
|
-
'dler build --ignore "@reliverse/*"',
|
|
21
|
-
'dler build --ignore "@reliverse/relico" --ignore "@reliverse/dler-v1"',
|
|
22
|
-
'dler build --ignore "@reliverse/relico @reliverse/dler-v1"',
|
|
23
|
-
"dler build --cwd /path/to/monorepo",
|
|
24
|
-
"dler build --cwd /path/to/monorepo --ignore @reliverse/*",
|
|
25
|
-
"dler build --concurrency 8",
|
|
26
|
-
"dler build --concurrency 2 --stopOnError",
|
|
27
|
-
"dler build --ignore @reliverse/* --concurrency 6 --stopOnError",
|
|
28
|
-
"dler build --verbose",
|
|
29
|
-
"dler build --verbose --ignore @reliverse/*",
|
|
30
|
-
"dler build --verbose --concurrency 2 --stopOnError",
|
|
31
|
-
"dler build --watch",
|
|
32
|
-
"dler build --watch --verbose",
|
|
33
|
-
"dler build --target node --format cjs",
|
|
34
|
-
"dler build --minify --sourcemap linked",
|
|
35
|
-
"dler build --target browser --format esm --splitting false",
|
|
36
|
-
"dler build --external react --external react-dom",
|
|
37
|
-
"dler build --watch --target browser --minify --sourcemap inline",
|
|
38
|
-
"dler build --production",
|
|
39
|
-
"dler build --dev",
|
|
40
|
-
"dler build --bytecode --format cjs --target bun",
|
|
41
|
-
"dler build --minifyWhitespace --minifySyntax --minifyIdentifiers",
|
|
42
|
-
"dler build --drop console.log --drop debugger",
|
|
43
|
-
`dler build --env PUBLIC_* --define '{"__VERSION__":"1.0.0"}'`,
|
|
44
|
-
"dler build --banner 'use client' --footer '// built with dler'",
|
|
45
|
-
"dler build --entryNaming '[dir]/[name].[ext]' --chunkNaming '[name]-[hash].[ext]'",
|
|
46
|
-
"dler build --compile --production",
|
|
47
|
-
"dler build --noCache --verbose",
|
|
48
|
-
"dler build --packages external --external 'react*'",
|
|
49
|
-
"dler build --publicPath /assets/ --root ./src",
|
|
50
|
-
"",
|
|
51
|
-
"# Standalone Executable Examples:",
|
|
52
|
-
"dler build --compile --production --target bun",
|
|
53
|
-
"dler build --compile --target node --format cjs --minify",
|
|
54
|
-
"dler build --compile --bytecode --format cjs --target bun",
|
|
55
|
-
"dler build --compile --windowsIcon app.ico --windowsTitle 'My App'",
|
|
56
|
-
"dler build --compile --production --env inline --drop console.log",
|
|
57
|
-
"",
|
|
58
|
-
"# Note: --compile generates executables alongside bundles",
|
|
59
|
-
"# For Bun executables, use --target bun --format cjs --bytecode for best performance",
|
|
60
|
-
"# For Node executables, use --target node --format cjs",
|
|
61
|
-
"",
|
|
62
|
-
"# Preset Examples:",
|
|
63
|
-
"dler build --production # Optimized for production",
|
|
64
|
-
"dler build --dev # Development mode with watch",
|
|
65
|
-
"dler build --library # Library build (external deps)",
|
|
66
|
-
"dler build --react # React app with JSX support",
|
|
67
|
-
"dler build --node # Node.js server build",
|
|
68
|
-
"dler build --monorepo # Monorepo optimized build",
|
|
69
|
-
"",
|
|
70
|
-
"# Bundler Examples:",
|
|
71
|
-
"dler build --bundler mkdist # Use mkdist bundler (default for libraries)",
|
|
72
|
-
"dler build --bundler bun # Use Bun bundler (default for apps)",
|
|
73
|
-
"dler build --bundler mkdist --kind library",
|
|
74
|
-
"dler build --bundler bun --kind library",
|
|
75
|
-
"",
|
|
76
|
-
"# Note: mkdist preserves file structure and is ideal for libraries",
|
|
77
|
-
"# bun bundles dependencies and is ideal for applications",
|
|
78
|
-
"",
|
|
79
|
-
"# New Bun bundler features:",
|
|
80
|
-
"dler build --noBundle --target node",
|
|
81
|
-
"dler build --reactFastRefresh --watch",
|
|
82
|
-
"dler build --noClearScreen --watch",
|
|
83
|
-
"dler build --windowsHideConsole --windowsIcon app.ico --compile",
|
|
84
|
-
"dler build --app --serverComponents",
|
|
85
|
-
"dler build --debugDumpServerFiles --debugNoMinify",
|
|
86
|
-
"",
|
|
87
|
-
"# Enhanced Features:",
|
|
88
|
-
"dler build --bundleAnalyzer --performanceMonitoring",
|
|
89
|
-
"dler build --generateTypes --typeCheck",
|
|
90
|
-
"dler build --macros --sideEffects false",
|
|
91
|
-
`dler build --bundleSizeLimit 1048576 --performanceBudget '{"maxBundleSize":1048576}'`,
|
|
92
|
-
"dler build --imageOptimization --fontOptimization --cssOptimization",
|
|
93
|
-
"dler build --svgAsReact --cssModules --workerSupport",
|
|
94
|
-
"dler build --plugins 'react-refresh,typescript-declarations,bundle-analyzer'",
|
|
95
|
-
"",
|
|
96
|
-
"# Frontend App Examples:",
|
|
97
|
-
"dler build --devServer --watch --open --reactFastRefresh",
|
|
98
|
-
"dler build --production --html --cssChunking --bundleAnalyzer",
|
|
99
|
-
"dler build --target browser --format esm --html --cssChunking --svgAsReact",
|
|
100
|
-
"dler build --devServer --port 8080 --open --cssModules",
|
|
101
|
-
"dler build --html --publicAssets static --cssChunking --imageOptimization",
|
|
102
|
-
"",
|
|
103
|
-
"# Full-stack App Examples:",
|
|
104
|
-
"dler build --target browser --format esm --html --assets public --workerSupport",
|
|
105
|
-
"dler build --devServer --watch --target browser --html --performanceMonitoring",
|
|
106
|
-
"",
|
|
107
|
-
"# Library Examples:",
|
|
108
|
-
"dler build --library --generateTypes --typeCheck",
|
|
109
|
-
"dler build --target bun --format esm --generateTypes --bundleAnalyzer",
|
|
110
|
-
"dler build --target node --format cjs --generateTypes --sideEffects false",
|
|
111
|
-
"",
|
|
112
|
-
"# Configuration Examples:",
|
|
113
|
-
"# Create dler.ts in your monorepo root:",
|
|
114
|
-
"# export default {",
|
|
115
|
-
"# build: {",
|
|
116
|
-
"# global: { target: 'bun', format: 'esm' },",
|
|
117
|
-
"# packages: { 'my-package': { minify: true, generateTypes: true } },",
|
|
118
|
-
"# patterns: [{ pattern: 'apps/*', config: { target: 'browser', html: true, bundleAnalyzer: true } }]",
|
|
119
|
-
"# }",
|
|
120
|
-
"# }",
|
|
121
|
-
"",
|
|
122
|
-
"# Note: Configuration is only supported via dler.ts",
|
|
123
|
-
"# package.json build fields are not supported",
|
|
124
|
-
"",
|
|
125
|
-
"# Config Discovery Examples:",
|
|
126
|
-
"dler build --maxConfigDepth 5",
|
|
127
|
-
"",
|
|
128
|
-
"# TSConfig Validation Examples:",
|
|
129
|
-
"dler build --validateTsconfig",
|
|
130
|
-
"dler build --strictTsconfig",
|
|
131
|
-
"dler build --validateTsconfig --verbose",
|
|
132
|
-
"dler build --noValidateTsconfig",
|
|
133
|
-
"",
|
|
134
|
-
"# Note: --validateTsconfig checks tsconfig.json for common issues",
|
|
135
|
-
"# Use --strictTsconfig to make validation errors fatal",
|
|
136
|
-
"",
|
|
137
|
-
"# DTS Provider Examples:",
|
|
138
|
-
"dler build --dtsProvider dts-bundle-generator",
|
|
139
|
-
"dler build --dtsProvider api-extractor",
|
|
140
|
-
"dler build --dtsProvider typescript",
|
|
141
|
-
"dler build --dtsProvider mkdist",
|
|
142
|
-
"dler build --generateTypes --dtsProvider dts-bundle-generator",
|
|
143
|
-
"",
|
|
144
|
-
"# Note: dts-bundle-generator is the default provider for better bundling",
|
|
145
|
-
"# mkdist provider offers VFS-based processing with automatic relative import resolution",
|
|
146
|
-
"# Use --dtsProvider to override the default provider",
|
|
147
|
-
"",
|
|
148
|
-
"# Go Build Examples:",
|
|
149
|
-
"dler build --go-provider xgo",
|
|
150
|
-
"dler build --go-provider native",
|
|
151
|
-
"dler build --go-targets linux/amd64",
|
|
152
|
-
"dler build --go-targets 'linux/amd64,windows/amd64,darwin/arm64'",
|
|
153
|
-
"dler build --go-output-dir release",
|
|
154
|
-
"dler build --go-output-name my-binary",
|
|
155
|
-
"dler build --go-build-mode c-shared",
|
|
156
|
-
"dler build --go-ldflags '-s -w -X main.version=1.0.0'",
|
|
157
|
-
"dler build --go-main-file main.go",
|
|
158
|
-
"dler build --go-version 1.21.0",
|
|
159
|
-
"dler build --go-enable",
|
|
160
|
-
"",
|
|
161
|
-
"# Note: Go build is auto-detected if .go files exist in the package",
|
|
162
|
-
"# Use --go-enable to explicitly enable, or configure in dler.ts",
|
|
163
|
-
"# Use --go-provider xgo for cross-compilation (requires xgo installed)",
|
|
164
|
-
"# Use --go-provider native for native builds (limited cross-compilation)",
|
|
165
|
-
"",
|
|
166
|
-
"# Build Type Selection Examples:",
|
|
167
|
-
"dler build --go-only",
|
|
168
|
-
"dler build --ts-only",
|
|
169
|
-
"dler build --go-only --go-targets linux/amd64",
|
|
170
|
-
"dler build --ts-only --target node --format cjs",
|
|
171
|
-
"",
|
|
172
|
-
"# Note: --go-only skips TypeScript builds and only builds Go binaries",
|
|
173
|
-
"# Note: --ts-only skips Go builds and only builds TypeScript/JavaScript",
|
|
174
|
-
"# Note: --go-only and --ts-only cannot be used together"
|
|
175
|
-
]
|
|
176
|
-
},
|
|
177
|
-
args: defineArgs({
|
|
178
|
-
ignore: {
|
|
179
|
-
type: "string",
|
|
14
|
+
description: "Build all workspace packages using configurable bundler (mkdist for libraries, bun for apps) with dler.ts configuration. Auto-detects frontend apps and libraries. Supports presets: --production, --dev, --library, --react, --node, --monorepo.",
|
|
15
|
+
options: {
|
|
16
|
+
ignore: option(type("string | undefined"), {
|
|
180
17
|
description: "Package(s) to ignore (supports wildcards like @reliverse/*)"
|
|
181
|
-
},
|
|
182
|
-
filter: {
|
|
183
|
-
type: "string",
|
|
18
|
+
}),
|
|
19
|
+
filter: option(type("string | undefined"), {
|
|
184
20
|
description: "Package(s) to include (supports wildcards and comma-separated values like '@reliverse/rempts,@reliverse/build'). Takes precedence over --ignore when both are provided."
|
|
185
|
-
},
|
|
186
|
-
cwd: {
|
|
187
|
-
type: "string",
|
|
21
|
+
}),
|
|
22
|
+
cwd: option(type("string | undefined"), {
|
|
188
23
|
description: "Working directory (monorepo root)"
|
|
189
|
-
},
|
|
190
|
-
concurrency: {
|
|
191
|
-
type: "number",
|
|
24
|
+
}),
|
|
25
|
+
concurrency: option(type("number | undefined"), {
|
|
192
26
|
description: "Number of packages to build concurrently (default: 5)"
|
|
193
|
-
},
|
|
194
|
-
stopOnError: {
|
|
195
|
-
type: "boolean",
|
|
27
|
+
}),
|
|
28
|
+
stopOnError: option(type("boolean | undefined"), {
|
|
196
29
|
description: "Stop on first error instead of collecting all errors (default: false)"
|
|
197
|
-
},
|
|
198
|
-
verbose: {
|
|
199
|
-
type: "boolean",
|
|
30
|
+
}),
|
|
31
|
+
verbose: option(type("boolean | undefined"), {
|
|
200
32
|
description: "Verbose mode (default: false)"
|
|
201
|
-
},
|
|
202
|
-
watch: {
|
|
203
|
-
type: "boolean",
|
|
33
|
+
}),
|
|
34
|
+
watch: option(type("boolean | undefined"), {
|
|
204
35
|
description: "Watch mode for hot rebuild (default: false)"
|
|
205
|
-
},
|
|
206
|
-
bundler: {
|
|
207
|
-
type: "string",
|
|
36
|
+
}),
|
|
37
|
+
bundler: option(type("string | undefined"), {
|
|
208
38
|
description: "Bundler to use: bun (fast, bundles deps) or mkdist (preserves structure, default for libraries)"
|
|
209
|
-
},
|
|
210
|
-
target: {
|
|
211
|
-
type: "string",
|
|
39
|
+
}),
|
|
40
|
+
target: option(type("string | undefined"), {
|
|
212
41
|
description: "Build target: browser, bun, or node (default: bun)"
|
|
213
|
-
},
|
|
214
|
-
format: {
|
|
215
|
-
type: "string",
|
|
42
|
+
}),
|
|
43
|
+
format: option(type("string | undefined"), {
|
|
216
44
|
description: "Output format: esm, cjs, or iife (default: esm)"
|
|
217
|
-
},
|
|
218
|
-
minify: {
|
|
219
|
-
type: "boolean",
|
|
45
|
+
}),
|
|
46
|
+
minify: option(type("boolean | undefined"), {
|
|
220
47
|
description: "Enable all minification options (default: false)"
|
|
221
|
-
},
|
|
222
|
-
minifyWhitespace: {
|
|
223
|
-
type: "boolean",
|
|
48
|
+
}),
|
|
49
|
+
minifyWhitespace: option(type("boolean | undefined"), {
|
|
224
50
|
description: "Minify whitespace (default: false)"
|
|
225
|
-
},
|
|
226
|
-
minifySyntax: {
|
|
227
|
-
type: "boolean",
|
|
51
|
+
}),
|
|
52
|
+
minifySyntax: option(type("boolean | undefined"), {
|
|
228
53
|
description: "Minify syntax and inline constants (default: false)"
|
|
229
|
-
},
|
|
230
|
-
minifyIdentifiers: {
|
|
231
|
-
type: "boolean",
|
|
54
|
+
}),
|
|
55
|
+
minifyIdentifiers: option(type("boolean | undefined"), {
|
|
232
56
|
description: "Minify variable and function identifiers (default: false)"
|
|
233
|
-
},
|
|
234
|
-
sourcemap: {
|
|
235
|
-
type: "string",
|
|
57
|
+
}),
|
|
58
|
+
sourcemap: option(type("string | undefined"), {
|
|
236
59
|
description: "Sourcemap option: none, linked, inline, or external (default: none)"
|
|
237
|
-
},
|
|
238
|
-
splitting: {
|
|
239
|
-
type: "boolean",
|
|
60
|
+
}),
|
|
61
|
+
splitting: option(type("boolean | undefined"), {
|
|
240
62
|
description: "Enable code splitting (default: true)"
|
|
241
|
-
},
|
|
242
|
-
external: {
|
|
243
|
-
type: "string",
|
|
63
|
+
}),
|
|
64
|
+
external: option(type("string | undefined"), {
|
|
244
65
|
description: "External packages to exclude from bundle (supports wildcards)"
|
|
245
|
-
},
|
|
246
|
-
bytecode: {
|
|
247
|
-
type: "boolean",
|
|
66
|
+
}),
|
|
67
|
+
bytecode: option(type("boolean | undefined"), {
|
|
248
68
|
description: "Generate bytecode for faster cold starts (requires format: cjs, target: bun)"
|
|
249
|
-
},
|
|
250
|
-
drop: {
|
|
251
|
-
type: "string",
|
|
69
|
+
}),
|
|
70
|
+
drop: option(type("string | undefined"), {
|
|
252
71
|
description: "Drop function calls (e.g., 'console.log', 'debugger')"
|
|
253
|
-
},
|
|
254
|
-
packages: {
|
|
255
|
-
type: "string",
|
|
72
|
+
}),
|
|
73
|
+
packages: option(type("string | undefined"), {
|
|
256
74
|
description: "How to handle dependencies: bundle or external (default: bundle)"
|
|
257
|
-
},
|
|
258
|
-
publicPath: {
|
|
259
|
-
type: "string",
|
|
75
|
+
}),
|
|
76
|
+
publicPath: option(type("string | undefined"), {
|
|
260
77
|
description: "Prefix for import paths in bundled code"
|
|
261
|
-
},
|
|
262
|
-
root: {
|
|
263
|
-
type: "string",
|
|
78
|
+
}),
|
|
79
|
+
root: option(type("string | undefined"), {
|
|
264
80
|
description: "Project root for resolving relative paths"
|
|
265
|
-
},
|
|
266
|
-
define: {
|
|
267
|
-
type: "string",
|
|
81
|
+
}),
|
|
82
|
+
define: option(type("string | undefined"), {
|
|
268
83
|
description: `Define global constants (JSON format, e.g., '{"__VERSION__":"1.0.0"}')`
|
|
269
|
-
},
|
|
270
|
-
naming: {
|
|
271
|
-
type: "string",
|
|
84
|
+
}),
|
|
85
|
+
naming: option(type("string | undefined"), {
|
|
272
86
|
description: "Customize output file naming (JSON format)"
|
|
273
|
-
},
|
|
274
|
-
env: {
|
|
275
|
-
type: "string",
|
|
87
|
+
}),
|
|
88
|
+
env: option(type("string | undefined"), {
|
|
276
89
|
description: "Environment variable handling: inline, disable, or prefix like PUBLIC_*"
|
|
277
|
-
},
|
|
278
|
-
banner: {
|
|
279
|
-
type: "string",
|
|
90
|
+
}),
|
|
91
|
+
banner: option(type("string | undefined"), {
|
|
280
92
|
description: "Add banner to bundled code (e.g., 'use client')"
|
|
281
|
-
},
|
|
282
|
-
footer: {
|
|
283
|
-
type: "string",
|
|
93
|
+
}),
|
|
94
|
+
footer: option(type("string | undefined"), {
|
|
284
95
|
description: "Add footer to bundled code"
|
|
285
|
-
},
|
|
286
|
-
conditions: {
|
|
287
|
-
type: "string",
|
|
96
|
+
}),
|
|
97
|
+
conditions: option(type("string | undefined"), {
|
|
288
98
|
description: "Package.json exports conditions for import resolution"
|
|
289
|
-
},
|
|
290
|
-
loader: {
|
|
291
|
-
type: "string",
|
|
99
|
+
}),
|
|
100
|
+
loader: option(type("string | undefined"), {
|
|
292
101
|
description: "Custom loaders for file extensions (JSON format)"
|
|
293
|
-
},
|
|
294
|
-
ignoreDCEAnnotations: {
|
|
295
|
-
type: "boolean",
|
|
102
|
+
}),
|
|
103
|
+
ignoreDCEAnnotations: option(type("boolean | undefined"), {
|
|
296
104
|
description: "Ignore dead code elimination annotations"
|
|
297
|
-
},
|
|
298
|
-
emitDCEAnnotations: {
|
|
299
|
-
type: "boolean",
|
|
105
|
+
}),
|
|
106
|
+
emitDCEAnnotations: option(type("boolean | undefined"), {
|
|
300
107
|
description: "Force emit dead code elimination annotations"
|
|
301
|
-
},
|
|
302
|
-
throw: {
|
|
303
|
-
type: "boolean",
|
|
108
|
+
}),
|
|
109
|
+
throw: option(type("boolean | undefined"), {
|
|
304
110
|
description: "Throw on build errors instead of returning success: false"
|
|
305
|
-
},
|
|
306
|
-
production: {
|
|
307
|
-
type: "boolean",
|
|
111
|
+
}),
|
|
112
|
+
production: option(type("boolean | undefined"), {
|
|
308
113
|
description: "Enable production mode (minify=true, sourcemap=none, env=inline)"
|
|
309
|
-
},
|
|
310
|
-
dev: {
|
|
311
|
-
type: "boolean",
|
|
114
|
+
}),
|
|
115
|
+
dev: option(type("boolean | undefined"), {
|
|
312
116
|
description: "Enable development mode (watch=true, sourcemap=linked, env=disable)"
|
|
313
|
-
},
|
|
314
|
-
library: {
|
|
315
|
-
type: "boolean",
|
|
117
|
+
}),
|
|
118
|
+
library: option(type("boolean | undefined"), {
|
|
316
119
|
description: "Enable library mode (packages=external, bundler=mkdist, generateTypes=true)"
|
|
317
|
-
},
|
|
318
|
-
react: {
|
|
319
|
-
type: "boolean",
|
|
120
|
+
}),
|
|
121
|
+
react: option(type("boolean | undefined"), {
|
|
320
122
|
description: "Enable React preset (jsx=automatic, target=browser)"
|
|
321
|
-
},
|
|
322
|
-
node: {
|
|
323
|
-
type: "boolean",
|
|
123
|
+
}),
|
|
124
|
+
node: option(type("boolean | undefined"), {
|
|
324
125
|
description: "Enable Node preset (target=node, format=cjs)"
|
|
325
|
-
},
|
|
326
|
-
monorepo: {
|
|
327
|
-
type: "boolean",
|
|
126
|
+
}),
|
|
127
|
+
monorepo: option(type("boolean | undefined"), {
|
|
328
128
|
description: "Enable monorepo preset (concurrency=auto, validateTsconfig=true)"
|
|
329
|
-
},
|
|
330
|
-
compile: {
|
|
331
|
-
type: "boolean",
|
|
129
|
+
}),
|
|
130
|
+
compile: option(type("boolean | undefined"), {
|
|
332
131
|
description: "Generate standalone executable (default: false)"
|
|
333
|
-
},
|
|
334
|
-
allowPrivateBuild: {
|
|
335
|
-
type: "string",
|
|
132
|
+
}),
|
|
133
|
+
allowPrivateBuild: option(type("string | undefined"), {
|
|
336
134
|
description: "Allow building packages with private: true in package.json. Can be a package name pattern or comma-separated patterns (e.g., '@reliverse/*')"
|
|
337
|
-
},
|
|
338
|
-
replaceExports: {
|
|
339
|
-
type: "boolean",
|
|
135
|
+
}),
|
|
136
|
+
replaceExports: option(type("boolean | undefined"), {
|
|
340
137
|
description: "Replace exports from ./dist/*.js to ./src/*.ts after build (default: false)"
|
|
341
|
-
},
|
|
342
|
-
replaceExportsIgnorePackages: {
|
|
343
|
-
type: "string",
|
|
138
|
+
}),
|
|
139
|
+
replaceExportsIgnorePackages: option(type("string | undefined"), {
|
|
344
140
|
description: "Packages to ignore when replacing exports (supports glob patterns like @reliverse/*)"
|
|
345
|
-
},
|
|
346
|
-
loggerClearInternals: {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
loggerClearInternalsIgnorePackages: {
|
|
350
|
-
type: "string",
|
|
141
|
+
}),
|
|
142
|
+
loggerClearInternals: option(type("boolean | undefined"), {
|
|
143
|
+
}),
|
|
144
|
+
loggerClearInternalsIgnorePackages: option(type("string | undefined"), {
|
|
351
145
|
description: "Packages to ignore when clearing logger internals (supports glob patterns like @reliverse/*)"
|
|
352
|
-
},
|
|
353
|
-
cache: {
|
|
354
|
-
type: "boolean",
|
|
146
|
+
}),
|
|
147
|
+
cache: option(type("boolean | undefined"), {
|
|
355
148
|
description: "Enable build cache (default: true)"
|
|
356
|
-
},
|
|
357
|
-
noCache: {
|
|
358
|
-
type: "boolean",
|
|
149
|
+
}),
|
|
150
|
+
noCache: option(type("boolean | undefined"), {
|
|
359
151
|
description: "Disable build cache (default: false)"
|
|
360
|
-
},
|
|
361
|
-
generateTypes: {
|
|
362
|
-
type: "boolean",
|
|
152
|
+
}),
|
|
153
|
+
generateTypes: option(type("boolean | undefined"), {
|
|
363
154
|
description: "Generate TypeScript declaration files (default: false)"
|
|
364
|
-
},
|
|
365
|
-
typeCheck: {
|
|
366
|
-
type: "boolean",
|
|
155
|
+
}),
|
|
156
|
+
typeCheck: option(type("boolean | undefined"), {
|
|
367
157
|
description: "Run type checking during build (default: false)"
|
|
368
|
-
},
|
|
369
|
-
validateTsconfig: {
|
|
370
|
-
type: "boolean",
|
|
158
|
+
}),
|
|
159
|
+
validateTsconfig: option(type("boolean | undefined"), {
|
|
371
160
|
description: "Validate tsconfig.json for common issues (default: true)"
|
|
372
|
-
},
|
|
373
|
-
strictTsconfig: {
|
|
374
|
-
type: "boolean",
|
|
161
|
+
}),
|
|
162
|
+
strictTsconfig: option(type("boolean | undefined"), {
|
|
375
163
|
description: "Make tsconfig validation errors fatal (default: false)"
|
|
376
|
-
},
|
|
377
|
-
dtsProvider: {
|
|
378
|
-
type: "string",
|
|
164
|
+
}),
|
|
165
|
+
dtsProvider: option(type("string | undefined"), {
|
|
379
166
|
description: "DTS generation provider: dts-bundle-generator, api-extractor, typescript, or mkdist (default: dts-bundle-generator)"
|
|
380
|
-
},
|
|
381
|
-
maxConfigDepth: {
|
|
382
|
-
type: "number",
|
|
167
|
+
}),
|
|
168
|
+
maxConfigDepth: option(type("number | undefined"), {
|
|
383
169
|
description: "Maximum depth to search for dler.ts config files (default: 3)"
|
|
384
|
-
},
|
|
385
|
-
entryNaming: {
|
|
386
|
-
type: "string",
|
|
170
|
+
}),
|
|
171
|
+
entryNaming: option(type("string | undefined"), {
|
|
387
172
|
description: "Naming pattern for entry files (e.g., '[dir]/[name].[ext]')"
|
|
388
|
-
},
|
|
389
|
-
chunkNaming: {
|
|
390
|
-
type: "string",
|
|
173
|
+
}),
|
|
174
|
+
chunkNaming: option(type("string | undefined"), {
|
|
391
175
|
description: "Naming pattern for chunk files (e.g., '[name]-[hash].[ext]')"
|
|
392
|
-
},
|
|
393
|
-
assetNaming: {
|
|
394
|
-
type: "string",
|
|
176
|
+
}),
|
|
177
|
+
assetNaming: option(type("string | undefined"), {
|
|
395
178
|
description: "Naming pattern for asset files (e.g., '[name]-[hash].[ext]')"
|
|
396
|
-
},
|
|
397
|
-
noBundle: {
|
|
398
|
-
type: "boolean",
|
|
179
|
+
}),
|
|
180
|
+
noBundle: option(type("boolean | undefined"), {
|
|
399
181
|
description: "Disable bundling (transpile only) (default: false)"
|
|
400
|
-
},
|
|
401
|
-
reactFastRefresh: {
|
|
402
|
-
type: "boolean",
|
|
182
|
+
}),
|
|
183
|
+
reactFastRefresh: option(type("boolean | undefined"), {
|
|
403
184
|
description: "Enable React Fast Refresh (default: false)"
|
|
404
|
-
},
|
|
405
|
-
noClearScreen: {
|
|
406
|
-
type: "boolean",
|
|
185
|
+
}),
|
|
186
|
+
noClearScreen: option(type("boolean | undefined"), {
|
|
407
187
|
description: "Don't clear screen in watch mode (default: false)"
|
|
408
|
-
},
|
|
409
|
-
|
|
410
|
-
type: "boolean",
|
|
411
|
-
description: "Hide console window on Windows (default: false)"
|
|
412
|
-
},
|
|
413
|
-
windowsIcon: {
|
|
414
|
-
type: "string",
|
|
415
|
-
description: "Path to Windows icon file (.ico) for executable"
|
|
416
|
-
},
|
|
417
|
-
windowsTitle: {
|
|
418
|
-
type: "string",
|
|
419
|
-
description: "Windows executable title"
|
|
420
|
-
},
|
|
421
|
-
app: {
|
|
422
|
-
type: "boolean",
|
|
188
|
+
}),
|
|
189
|
+
app: option(type("boolean | undefined"), {
|
|
423
190
|
description: "Enable app mode (default: false)"
|
|
424
|
-
},
|
|
425
|
-
serverComponents: {
|
|
426
|
-
type: "boolean",
|
|
191
|
+
}),
|
|
192
|
+
serverComponents: option(type("boolean | undefined"), {
|
|
427
193
|
description: "Enable server components support (default: false)"
|
|
428
|
-
},
|
|
429
|
-
debugDumpServerFiles: {
|
|
430
|
-
type: "boolean",
|
|
194
|
+
}),
|
|
195
|
+
debugDumpServerFiles: option(type("boolean | undefined"), {
|
|
431
196
|
description: "Dump server files for debugging (default: false)"
|
|
432
|
-
},
|
|
433
|
-
debugNoMinify: {
|
|
434
|
-
type: "boolean",
|
|
197
|
+
}),
|
|
198
|
+
debugNoMinify: option(type("boolean | undefined"), {
|
|
435
199
|
description: "Disable minification for debugging (default: false)"
|
|
436
|
-
},
|
|
437
|
-
bundleAnalyzer: {
|
|
438
|
-
type: "boolean",
|
|
200
|
+
}),
|
|
201
|
+
bundleAnalyzer: option(type("boolean | undefined"), {
|
|
439
202
|
description: "Enable bundle analyzer (default: false)"
|
|
440
|
-
},
|
|
441
|
-
performanceMonitoring: {
|
|
442
|
-
type: "boolean",
|
|
203
|
+
}),
|
|
204
|
+
performanceMonitoring: option(type("boolean | undefined"), {
|
|
443
205
|
description: "Enable performance monitoring (default: false)"
|
|
444
|
-
},
|
|
445
|
-
bundleSizeLimit: {
|
|
446
|
-
type: "number",
|
|
206
|
+
}),
|
|
207
|
+
bundleSizeLimit: option(type("number | undefined"), {
|
|
447
208
|
description: "Maximum bundle size in bytes (default: unlimited)"
|
|
448
|
-
},
|
|
449
|
-
performanceBudget: {
|
|
450
|
-
type: "string",
|
|
209
|
+
}),
|
|
210
|
+
performanceBudget: option(type("string | undefined"), {
|
|
451
211
|
description: `Performance budget configuration (JSON format, e.g., '{"maxBundleSize":1048576}')`
|
|
452
|
-
},
|
|
453
|
-
imageOptimization: {
|
|
454
|
-
type: "boolean",
|
|
212
|
+
}),
|
|
213
|
+
imageOptimization: option(type("boolean | undefined"), {
|
|
455
214
|
description: "Enable image optimization (default: false)"
|
|
456
|
-
},
|
|
457
|
-
fontOptimization: {
|
|
458
|
-
type: "boolean",
|
|
215
|
+
}),
|
|
216
|
+
fontOptimization: option(type("boolean | undefined"), {
|
|
459
217
|
description: "Enable font optimization (default: false)"
|
|
460
|
-
},
|
|
461
|
-
cssOptimization: {
|
|
462
|
-
type: "boolean",
|
|
218
|
+
}),
|
|
219
|
+
cssOptimization: option(type("boolean | undefined"), {
|
|
463
220
|
description: "Enable CSS optimization (default: false)"
|
|
464
|
-
},
|
|
465
|
-
svgAsReact: {
|
|
466
|
-
type: "boolean",
|
|
221
|
+
}),
|
|
222
|
+
svgAsReact: option(type("boolean | undefined"), {
|
|
467
223
|
description: "Convert SVG to React components (default: false)"
|
|
468
|
-
},
|
|
469
|
-
cssModules: {
|
|
470
|
-
type: "boolean",
|
|
224
|
+
}),
|
|
225
|
+
cssModules: option(type("boolean | undefined"), {
|
|
471
226
|
description: "Enable CSS modules (default: false)"
|
|
472
|
-
},
|
|
473
|
-
workerSupport: {
|
|
474
|
-
type: "boolean",
|
|
227
|
+
}),
|
|
228
|
+
workerSupport: option(type("boolean | undefined"), {
|
|
475
229
|
description: "Enable worker support (default: false)"
|
|
476
|
-
},
|
|
477
|
-
plugins: {
|
|
478
|
-
type: "string",
|
|
230
|
+
}),
|
|
231
|
+
plugins: option(type("string | undefined"), {
|
|
479
232
|
description: "Comma-separated list of plugins (e.g., 'react-refresh,typescript-declarations')"
|
|
480
|
-
},
|
|
481
|
-
macros: {
|
|
482
|
-
type: "boolean",
|
|
233
|
+
}),
|
|
234
|
+
macros: option(type("boolean | undefined"), {
|
|
483
235
|
description: "Enable Bun macros (default: false)"
|
|
484
|
-
},
|
|
485
|
-
sideEffects: {
|
|
486
|
-
type: "boolean",
|
|
236
|
+
}),
|
|
237
|
+
sideEffects: option(type("boolean | undefined"), {
|
|
487
238
|
description: "Mark package as side-effect free (default: false)"
|
|
488
|
-
},
|
|
489
|
-
devServer: {
|
|
490
|
-
type: "boolean",
|
|
239
|
+
}),
|
|
240
|
+
devServer: option(type("boolean | undefined"), {
|
|
491
241
|
description: "Enable development server (default: false)"
|
|
492
|
-
},
|
|
493
|
-
port: {
|
|
494
|
-
type: "number",
|
|
242
|
+
}),
|
|
243
|
+
port: option(type("number | undefined"), {
|
|
495
244
|
description: "Development server port (default: 3000)"
|
|
496
|
-
},
|
|
497
|
-
open: {
|
|
498
|
-
type: "boolean",
|
|
245
|
+
}),
|
|
246
|
+
open: option(type("boolean | undefined"), {
|
|
499
247
|
description: "Open browser on dev server start (default: false)"
|
|
500
|
-
},
|
|
501
|
-
html: {
|
|
502
|
-
type: "boolean",
|
|
248
|
+
}),
|
|
249
|
+
html: option(type("boolean | undefined"), {
|
|
503
250
|
description: "Generate HTML file (default: false)"
|
|
504
|
-
},
|
|
505
|
-
cssChunking: {
|
|
506
|
-
type: "boolean",
|
|
251
|
+
}),
|
|
252
|
+
cssChunking: option(type("boolean | undefined"), {
|
|
507
253
|
description: "Enable CSS chunking (default: false)"
|
|
508
|
-
},
|
|
509
|
-
publicAssets: {
|
|
510
|
-
type: "string",
|
|
254
|
+
}),
|
|
255
|
+
publicAssets: option(type("string | undefined"), {
|
|
511
256
|
description: "Public assets directory (default: 'public')"
|
|
512
|
-
},
|
|
513
|
-
assets: {
|
|
514
|
-
type: "string",
|
|
257
|
+
}),
|
|
258
|
+
assets: option(type("string | undefined"), {
|
|
515
259
|
description: "Assets directory (default: 'assets')"
|
|
516
|
-
},
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
description: "
|
|
524
|
-
},
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
description: "
|
|
528
|
-
},
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
goVersion: {
|
|
546
|
-
type: "string",
|
|
547
|
-
description: "Go version for xgo (default: 1.20.3)"
|
|
548
|
-
},
|
|
549
|
-
goOnly: {
|
|
550
|
-
type: "boolean",
|
|
551
|
-
description: "Skip TypeScript builds and only build Go binaries (default: false)"
|
|
552
|
-
},
|
|
553
|
-
tsOnly: {
|
|
554
|
-
type: "boolean",
|
|
555
|
-
description: "Skip Go builds and only build TypeScript/JavaScript (default: false)"
|
|
556
|
-
},
|
|
557
|
-
goEnable: {
|
|
558
|
-
type: "boolean",
|
|
559
|
-
description: "Enable Go build (default: auto-detect)"
|
|
560
|
-
}
|
|
561
|
-
}),
|
|
562
|
-
run: async ({ args }) => {
|
|
260
|
+
}),
|
|
261
|
+
kind: option(type("string | undefined"), {
|
|
262
|
+
description: "Package kind: app or library (default: auto-detect)"
|
|
263
|
+
}),
|
|
264
|
+
// CLI-specific options
|
|
265
|
+
entry: option(type("string | undefined"), {
|
|
266
|
+
short: "e",
|
|
267
|
+
description: "Entry file (defaults to auto-detect), supports comma-separated multiple entries"
|
|
268
|
+
}),
|
|
269
|
+
outdir: option(type("string | undefined"), {
|
|
270
|
+
short: "o",
|
|
271
|
+
description: "Output directory"
|
|
272
|
+
}),
|
|
273
|
+
outfile: option(type("string | undefined"), {
|
|
274
|
+
description: "Output filename (for single executable)"
|
|
275
|
+
}),
|
|
276
|
+
runtime: option(type("'bun'|'node' | undefined"), {
|
|
277
|
+
short: "r",
|
|
278
|
+
description: "Runtime target (for non-compiled builds)"
|
|
279
|
+
}),
|
|
280
|
+
targets: option(type("string | undefined"), {
|
|
281
|
+
short: "t",
|
|
282
|
+
description: "Target platforms for compilation (e.g., darwin-arm64,linux-x64,all,native)"
|
|
283
|
+
}),
|
|
284
|
+
compress: option(type("boolean | undefined"), {
|
|
285
|
+
description: "Compress multi-target builds into tar.gz files (default: false)"
|
|
286
|
+
})
|
|
287
|
+
},
|
|
288
|
+
handler: async ({ flags }) => {
|
|
563
289
|
try {
|
|
564
290
|
if (typeof process.versions.bun === "undefined") {
|
|
565
291
|
logger.error("\u274C This command requires Bun runtime. Sorry.");
|
|
566
292
|
process.exit(1);
|
|
567
293
|
}
|
|
568
|
-
|
|
569
|
-
logger.error(
|
|
570
|
-
"\u274C --go-only and --ts-only cannot be used together. Please use only one."
|
|
571
|
-
);
|
|
572
|
-
process.exit(1);
|
|
573
|
-
}
|
|
574
|
-
const goOptions = {};
|
|
575
|
-
if (args.goProvider) {
|
|
576
|
-
if (args.goProvider === "xgo" || args.goProvider === "native") {
|
|
577
|
-
goOptions.provider = args.goProvider;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
if (args.goTargets) {
|
|
581
|
-
goOptions.targets = args.goTargets;
|
|
582
|
-
}
|
|
583
|
-
if (args.goOutputDir) goOptions.outputDir = args.goOutputDir;
|
|
584
|
-
if (args.goOutputName) goOptions.outputName = args.goOutputName;
|
|
585
|
-
if (args.goBuildMode) {
|
|
586
|
-
if (args.goBuildMode === "c-shared" || args.goBuildMode === "c-archive" || args.goBuildMode === "exe") {
|
|
587
|
-
goOptions.buildMode = args.goBuildMode;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
if (args.goLdflags) goOptions.ldflags = args.goLdflags;
|
|
591
|
-
if (args.goMainFile) goOptions.mainFile = args.goMainFile;
|
|
592
|
-
if (args.goVersion) goOptions.goVersion = args.goVersion;
|
|
593
|
-
if (args.goEnable !== void 0) goOptions.enable = args.goEnable;
|
|
594
|
-
const buildOptionsInput = { ...args };
|
|
595
|
-
if (Object.keys(goOptions).length > 0) {
|
|
596
|
-
buildOptionsInput.go = goOptions;
|
|
597
|
-
}
|
|
598
|
-
const buildOptions = applyPresets(buildOptionsInput);
|
|
294
|
+
const buildOptions = applyPresets(flags);
|
|
599
295
|
validateAndExit(buildOptions);
|
|
600
|
-
|
|
296
|
+
if (flags.entry && flags.targets && !buildOptions.compile) {
|
|
297
|
+
buildOptions.compile = true;
|
|
298
|
+
}
|
|
299
|
+
const results = await runBuildOnAllPackages(flags.ignore, flags.cwd, {
|
|
601
300
|
...buildOptions,
|
|
602
|
-
allowPrivateBuild:
|
|
603
|
-
filter:
|
|
301
|
+
allowPrivateBuild: flags.allowPrivateBuild,
|
|
302
|
+
filter: flags.filter,
|
|
303
|
+
// Pass CLI-specific options to build
|
|
304
|
+
entry: flags.entry,
|
|
305
|
+
outdir: flags.outdir,
|
|
306
|
+
outfile: flags.outfile,
|
|
307
|
+
targets: flags.targets,
|
|
308
|
+
runtime: flags.runtime,
|
|
309
|
+
compress: flags.compress
|
|
604
310
|
});
|
|
605
311
|
if (results.hasErrors) {
|
|
606
312
|
process.exit(1);
|
|
607
313
|
}
|
|
608
|
-
|
|
609
|
-
if (shouldReplaceExports && !buildOptions.watch) {
|
|
610
|
-
if (args.verbose) {
|
|
611
|
-
logger.info(
|
|
612
|
-
"\n\u{1F4DD} Replacing exports from ./src/*.ts to ./dist/*.js after build..."
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
await replaceExportsInPackages({
|
|
616
|
-
direction: "ts-to-js",
|
|
617
|
-
cwd: args.cwd,
|
|
618
|
-
ignorePackages: args.replaceExportsIgnorePackages,
|
|
619
|
-
verbose: args.verbose
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
const shouldClearLoggerInternals = args.loggerClearInternals === true;
|
|
623
|
-
if (shouldClearLoggerInternals) {
|
|
624
|
-
if (buildOptions.watch) {
|
|
625
|
-
if (args.verbose) {
|
|
626
|
-
logger.warn(
|
|
627
|
-
"\n\u26A0\uFE0F --loggerClearInternals is not supported in watch mode (skipped)"
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
} else {
|
|
631
|
-
if (args.verbose) {
|
|
632
|
-
logger.info(
|
|
633
|
-
);
|
|
634
|
-
}
|
|
635
|
-
const allResults = results.results;
|
|
636
|
-
const successfulResults = allResults.filter(
|
|
637
|
-
(result) => result.success && !result.skipped
|
|
638
|
-
);
|
|
639
|
-
const packages = successfulResults.map((result) => ({
|
|
640
|
-
name: result.package.name,
|
|
641
|
-
outputDir: result.package.outputDir,
|
|
642
|
-
path: result.package.path
|
|
643
|
-
}));
|
|
644
|
-
if (args.verbose) {
|
|
645
|
-
logger.info(
|
|
646
|
-
` Found ${allResults.length} build result(s), ${successfulResults.length} successful package(s) to process`
|
|
647
|
-
);
|
|
648
|
-
}
|
|
649
|
-
if (packages.length > 0) {
|
|
650
|
-
const clearResult = await clearLoggerInternalsInPackages({
|
|
651
|
-
packages,
|
|
652
|
-
ignorePackages: args.loggerClearInternalsIgnorePackages,
|
|
653
|
-
verbose: args.verbose,
|
|
654
|
-
onLog: args.verbose ? (msg) => logger.info(msg) : void 0
|
|
655
|
-
});
|
|
656
|
-
if (args.verbose) {
|
|
657
|
-
logger.info(
|
|
658
|
-
`
|
|
659
|
-
\u2705 Logger internals cleared: Updated ${clearResult.updated} file(s), skipped ${clearResult.skipped} package(s)`
|
|
660
|
-
);
|
|
661
|
-
if (clearResult.files.length > 0 && clearResult.files.length <= 10) {
|
|
662
|
-
logger.info(
|
|
663
|
-
` Files updated: ${clearResult.files.join(", ")}`
|
|
664
|
-
);
|
|
665
|
-
} else if (clearResult.files.length > 10) {
|
|
666
|
-
logger.info(
|
|
667
|
-
` Files updated: ${clearResult.files.slice(0, 10).join(", ")} ... and ${clearResult.files.length - 10} more`
|
|
668
|
-
);
|
|
669
|
-
}
|
|
670
|
-
} else {
|
|
671
|
-
logger.info(
|
|
672
|
-
`\u2705 Logger internals cleared: ${clearResult.updated} file(s) updated`
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
} else {
|
|
676
|
-
if (args.verbose) {
|
|
677
|
-
logger.warn(
|
|
678
|
-
" \u26A0\uFE0F No successful packages found to process (all packages were skipped or failed)"
|
|
679
|
-
);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
314
|
+
await handlePostBuildOperations(flags, buildOptions, results);
|
|
684
315
|
logger.success("\n\u2705 All packages built successfully!");
|
|
685
316
|
} catch (error) {
|
|
686
317
|
logger.error("\n\u274C Build failed:");
|
|
@@ -693,3 +324,81 @@ export default defineCommand({
|
|
|
693
324
|
}
|
|
694
325
|
}
|
|
695
326
|
});
|
|
327
|
+
async function handlePostBuildOperations(flags, buildOptions, results) {
|
|
328
|
+
const shouldReplaceExports = flags.replaceExports === true;
|
|
329
|
+
if (shouldReplaceExports && !buildOptions.watch) {
|
|
330
|
+
if (flags.verbose) {
|
|
331
|
+
logger.info(
|
|
332
|
+
"\n\u{1F4DD} Replacing exports from ./src/*.ts to ./dist/*.js after build..."
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
await replaceExportsInPackages({
|
|
336
|
+
direction: "ts-to-js",
|
|
337
|
+
cwd: flags.cwd,
|
|
338
|
+
ignorePackages: flags.replaceExportsIgnorePackages,
|
|
339
|
+
verbose: flags.verbose
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
const shouldClearLoggerInternals = flags.loggerClearInternals === true;
|
|
343
|
+
if (shouldClearLoggerInternals) {
|
|
344
|
+
if (buildOptions.watch) {
|
|
345
|
+
if (flags.verbose) {
|
|
346
|
+
logger.warn(
|
|
347
|
+
"\n\u26A0\uFE0F --loggerClearInternals is not supported in watch mode (skipped)"
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
} else {
|
|
351
|
+
if (flags.verbose) {
|
|
352
|
+
logger.info(
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
const allResults = results.results;
|
|
356
|
+
const successfulResults = allResults.filter(
|
|
357
|
+
(result) => result.success && !result.skipped
|
|
358
|
+
);
|
|
359
|
+
const packages = successfulResults.map((result) => ({
|
|
360
|
+
name: result.package.name,
|
|
361
|
+
outputDir: result.package.outputDir,
|
|
362
|
+
path: result.package.path
|
|
363
|
+
}));
|
|
364
|
+
if (flags.verbose) {
|
|
365
|
+
logger.info(
|
|
366
|
+
` Found ${allResults.length} build result(s), ${successfulResults.length} successful package(s) to process`
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
if (packages.length > 0) {
|
|
370
|
+
const clearResult = await clearLoggerInternalsInPackages({
|
|
371
|
+
packages,
|
|
372
|
+
ignorePackages: flags.loggerClearInternalsIgnorePackages,
|
|
373
|
+
verbose: flags.verbose,
|
|
374
|
+
onLog: flags.verbose ? (msg) => logger.info(msg) : void 0
|
|
375
|
+
});
|
|
376
|
+
if (flags.verbose) {
|
|
377
|
+
logger.info(
|
|
378
|
+
`
|
|
379
|
+
\u2705 Logger internals cleared: Updated ${clearResult.updated} file(s), skipped ${clearResult.skipped} package(s)`
|
|
380
|
+
);
|
|
381
|
+
if (clearResult.files.length > 0 && clearResult.files.length <= 10) {
|
|
382
|
+
logger.info(
|
|
383
|
+
` Files updated: ${clearResult.files.join(", ")}`
|
|
384
|
+
);
|
|
385
|
+
} else if (clearResult.files.length > 10) {
|
|
386
|
+
logger.info(
|
|
387
|
+
` Files updated: ${clearResult.files.slice(0, 10).join(", ")} ... and ${clearResult.files.length - 10} more`
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
logger.info(
|
|
392
|
+
`\u2705 Logger internals cleared: ${clearResult.updated} file(s) updated`
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
} else {
|
|
396
|
+
if (flags.verbose) {
|
|
397
|
+
logger.warn(
|
|
398
|
+
" \u26A0\uFE0F No successful packages found to process (all packages were skipped or failed)"
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|