@buenojs/bueno 0.8.4 → 0.8.6
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 +264 -17
- package/dist/cli/{index.js → bin.js} +413 -332
- package/dist/container/index.js +273 -0
- package/dist/context/index.js +219 -0
- package/dist/database/index.js +493 -0
- package/dist/frontend/index.js +7697 -0
- package/dist/graphql/index.js +2156 -0
- package/dist/health/index.js +364 -0
- package/dist/i18n/index.js +345 -0
- package/dist/index.js +9694 -5047
- package/dist/jobs/index.js +819 -0
- package/dist/lock/index.js +367 -0
- package/dist/logger/index.js +281 -0
- package/dist/metrics/index.js +289 -0
- package/dist/middleware/index.js +77 -0
- package/dist/migrations/index.js +571 -0
- package/dist/modules/index.js +3411 -0
- package/dist/notification/index.js +484 -0
- package/dist/observability/index.js +331 -0
- package/dist/openapi/index.js +795 -0
- package/dist/orm/index.js +1356 -0
- package/dist/router/index.js +886 -0
- package/dist/rpc/index.js +691 -0
- package/dist/schema/index.js +400 -0
- package/dist/telemetry/index.js +595 -0
- package/dist/template/index.js +640 -0
- package/dist/templates/index.js +640 -0
- package/dist/testing/index.js +1111 -0
- package/dist/types/index.js +60 -0
- package/llms.txt +231 -0
- package/package.json +125 -27
- package/src/cache/index.ts +2 -1
- package/src/cli/ARCHITECTURE.md +3 -3
- package/src/cli/bin.ts +2 -2
- package/src/cli/commands/build.ts +183 -165
- package/src/cli/commands/dev.ts +96 -89
- package/src/cli/commands/generate.ts +142 -111
- package/src/cli/commands/help.ts +20 -16
- package/src/cli/commands/index.ts +3 -6
- package/src/cli/commands/migration.ts +124 -105
- package/src/cli/commands/new.ts +294 -232
- package/src/cli/commands/start.ts +81 -79
- package/src/cli/core/args.ts +68 -50
- package/src/cli/core/console.ts +89 -95
- package/src/cli/core/index.ts +4 -4
- package/src/cli/core/prompt.ts +65 -62
- package/src/cli/core/spinner.ts +23 -20
- package/src/cli/index.ts +46 -38
- package/src/cli/templates/database/index.ts +37 -18
- package/src/cli/templates/database/mysql.ts +3 -3
- package/src/cli/templates/database/none.ts +2 -2
- package/src/cli/templates/database/postgresql.ts +3 -3
- package/src/cli/templates/database/sqlite.ts +3 -3
- package/src/cli/templates/deploy.ts +29 -26
- package/src/cli/templates/docker.ts +41 -30
- package/src/cli/templates/frontend/index.ts +33 -15
- package/src/cli/templates/frontend/none.ts +2 -2
- package/src/cli/templates/frontend/react.ts +18 -18
- package/src/cli/templates/frontend/solid.ts +15 -15
- package/src/cli/templates/frontend/svelte.ts +17 -17
- package/src/cli/templates/frontend/vue.ts +15 -15
- package/src/cli/templates/generators/index.ts +29 -29
- package/src/cli/templates/generators/types.ts +21 -21
- package/src/cli/templates/index.ts +6 -6
- package/src/cli/templates/project/api.ts +37 -36
- package/src/cli/templates/project/default.ts +25 -25
- package/src/cli/templates/project/fullstack.ts +28 -26
- package/src/cli/templates/project/index.ts +55 -16
- package/src/cli/templates/project/minimal.ts +17 -12
- package/src/cli/templates/project/types.ts +10 -5
- package/src/cli/templates/project/website.ts +15 -15
- package/src/cli/utils/fs.ts +55 -41
- package/src/cli/utils/index.ts +3 -3
- package/src/cli/utils/strings.ts +47 -33
- package/src/cli/utils/version.ts +14 -8
- package/src/config/env-validation.ts +100 -0
- package/src/config/env.ts +169 -41
- package/src/config/index.ts +28 -20
- package/src/config/loader.ts +25 -16
- package/src/config/merge.ts +21 -10
- package/src/config/types.ts +566 -25
- package/src/config/validation.ts +215 -7
- package/src/container/forward-ref.ts +22 -22
- package/src/container/index.ts +34 -12
- package/src/context/index.ts +11 -1
- package/src/database/index.ts +7 -190
- package/src/database/orm/builder.ts +457 -0
- package/src/database/orm/casts/index.ts +130 -0
- package/src/database/orm/casts/types.ts +25 -0
- package/src/database/orm/compiler.ts +304 -0
- package/src/database/orm/hooks/index.ts +114 -0
- package/src/database/orm/index.ts +61 -0
- package/src/database/orm/model-registry.ts +59 -0
- package/src/database/orm/model.ts +821 -0
- package/src/database/orm/relationships/base.ts +146 -0
- package/src/database/orm/relationships/belongs-to-many.ts +179 -0
- package/src/database/orm/relationships/belongs-to.ts +56 -0
- package/src/database/orm/relationships/has-many.ts +45 -0
- package/src/database/orm/relationships/has-one.ts +41 -0
- package/src/database/orm/relationships/index.ts +11 -0
- package/src/database/orm/scopes/index.ts +55 -0
- package/src/events/__tests__/event-system.test.ts +235 -0
- package/src/events/config.ts +238 -0
- package/src/events/example-usage.ts +185 -0
- package/src/events/index.ts +278 -0
- package/src/events/manager.ts +385 -0
- package/src/events/registry.ts +182 -0
- package/src/events/types.ts +124 -0
- package/src/frontend/api-routes.ts +65 -23
- package/src/frontend/bundler.ts +76 -34
- package/src/frontend/console-client.ts +2 -2
- package/src/frontend/console-stream.ts +94 -38
- package/src/frontend/dev-server.ts +94 -46
- package/src/frontend/file-router.ts +61 -19
- package/src/frontend/frameworks/index.ts +37 -10
- package/src/frontend/frameworks/react.ts +10 -8
- package/src/frontend/frameworks/solid.ts +11 -9
- package/src/frontend/frameworks/svelte.ts +15 -9
- package/src/frontend/frameworks/vue.ts +13 -11
- package/src/frontend/hmr-client.ts +12 -10
- package/src/frontend/hmr.ts +146 -103
- package/src/frontend/index.ts +14 -5
- package/src/frontend/islands.ts +41 -22
- package/src/frontend/isr.ts +59 -37
- package/src/frontend/layout.ts +36 -21
- package/src/frontend/ssr/react.ts +74 -27
- package/src/frontend/ssr/solid.ts +54 -20
- package/src/frontend/ssr/svelte.ts +48 -14
- package/src/frontend/ssr/vue.ts +50 -18
- package/src/frontend/ssr.ts +83 -39
- package/src/frontend/types.ts +91 -56
- package/src/graphql/built-in-engine.ts +598 -0
- package/src/graphql/context-builder.ts +110 -0
- package/src/graphql/decorators.ts +358 -0
- package/src/graphql/execution-pipeline.ts +227 -0
- package/src/graphql/graphql-module.ts +563 -0
- package/src/graphql/index.ts +101 -0
- package/src/graphql/metadata.ts +237 -0
- package/src/graphql/schema-builder.ts +319 -0
- package/src/graphql/subscription-handler.ts +283 -0
- package/src/graphql/types.ts +324 -0
- package/src/health/index.ts +21 -9
- package/src/i18n/engine.ts +305 -0
- package/src/i18n/index.ts +38 -0
- package/src/i18n/loader.ts +218 -0
- package/src/i18n/middleware.ts +164 -0
- package/src/i18n/negotiator.ts +162 -0
- package/src/i18n/types.ts +158 -0
- package/src/index.ts +182 -27
- package/src/jobs/drivers/memory.ts +315 -0
- package/src/jobs/drivers/redis.ts +459 -0
- package/src/jobs/index.ts +30 -0
- package/src/jobs/queue.ts +281 -0
- package/src/jobs/types.ts +295 -0
- package/src/jobs/worker.ts +380 -0
- package/src/logger/index.ts +1 -3
- package/src/logger/transports/index.ts +62 -22
- package/src/metrics/index.ts +25 -16
- package/src/migrations/index.ts +9 -0
- package/src/modules/filters.ts +13 -17
- package/src/modules/guards.ts +49 -26
- package/src/modules/index.ts +457 -299
- package/src/modules/interceptors.ts +58 -20
- package/src/modules/lazy.ts +11 -19
- package/src/modules/lifecycle.ts +15 -7
- package/src/modules/metadata.ts +15 -5
- package/src/modules/pipes.ts +94 -72
- package/src/notification/channels/base.ts +68 -0
- package/src/notification/channels/email.ts +105 -0
- package/src/notification/channels/push.ts +104 -0
- package/src/notification/channels/sms.ts +105 -0
- package/src/notification/channels/whatsapp.ts +104 -0
- package/src/notification/index.ts +48 -0
- package/src/notification/service.ts +354 -0
- package/src/notification/types.ts +344 -0
- package/src/observability/__tests__/observability.test.ts +483 -0
- package/src/observability/breadcrumbs.ts +114 -0
- package/src/observability/index.ts +136 -0
- package/src/observability/interceptor.ts +85 -0
- package/src/observability/service.ts +303 -0
- package/src/observability/trace.ts +37 -0
- package/src/observability/types.ts +196 -0
- package/src/openapi/__tests__/decorators.test.ts +335 -0
- package/src/openapi/__tests__/document-builder.test.ts +285 -0
- package/src/openapi/__tests__/route-scanner.test.ts +334 -0
- package/src/openapi/__tests__/schema-generator.test.ts +275 -0
- package/src/openapi/decorators.ts +328 -0
- package/src/openapi/document-builder.ts +274 -0
- package/src/openapi/index.ts +112 -0
- package/src/openapi/metadata.ts +112 -0
- package/src/openapi/route-scanner.ts +289 -0
- package/src/openapi/schema-generator.ts +256 -0
- package/src/openapi/swagger-module.ts +166 -0
- package/src/openapi/types.ts +398 -0
- package/src/orm/index.ts +10 -0
- package/src/rpc/index.ts +3 -1
- package/src/schema/index.ts +9 -0
- package/src/security/index.ts +15 -6
- package/src/ssg/index.ts +9 -8
- package/src/telemetry/index.ts +76 -22
- package/src/template/index.ts +7 -0
- package/src/templates/engine.ts +224 -0
- package/src/templates/index.ts +9 -0
- package/src/templates/loader.ts +331 -0
- package/src/templates/renderers/markdown.ts +212 -0
- package/src/templates/renderers/simple.ts +269 -0
- package/src/templates/types.ts +154 -0
- package/src/testing/index.ts +100 -27
- package/src/types/optional-deps.d.ts +347 -187
- package/src/validation/index.ts +92 -2
- package/src/validation/schemas.ts +536 -0
- package/tests/integration/cli.test.ts +19 -19
- package/tests/integration/fullstack.test.ts +4 -4
- package/tests/unit/cli.test.ts +1 -1
- package/tests/unit/database.test.ts +2 -72
- package/tests/unit/env-validation.test.ts +166 -0
- package/tests/unit/events.test.ts +910 -0
- package/tests/unit/graphql.test.ts +991 -0
- package/tests/unit/i18n.test.ts +455 -0
- package/tests/unit/jobs.test.ts +493 -0
- package/tests/unit/notification.test.ts +988 -0
- package/tests/unit/observability.test.ts +453 -0
- package/tests/unit/orm/builder.test.ts +323 -0
- package/tests/unit/orm/casts.test.ts +179 -0
- package/tests/unit/orm/compiler.test.ts +220 -0
- package/tests/unit/orm/eager-loading.test.ts +285 -0
- package/tests/unit/orm/hooks.test.ts +191 -0
- package/tests/unit/orm/model.test.ts +373 -0
- package/tests/unit/orm/relationships.test.ts +303 -0
- package/tests/unit/orm/scopes.test.ts +74 -0
- package/tests/unit/templates-simple.test.ts +53 -0
- package/tests/unit/templates.test.ts +454 -0
- package/tests/unit/validation.test.ts +18 -24
- package/tsconfig.json +11 -3
package/src/cli/core/console.ts
CHANGED
|
@@ -7,44 +7,47 @@
|
|
|
7
7
|
|
|
8
8
|
// ANSI color codes
|
|
9
9
|
const COLORS = {
|
|
10
|
-
reset:
|
|
11
|
-
bold:
|
|
12
|
-
dim:
|
|
13
|
-
italic:
|
|
14
|
-
underline:
|
|
15
|
-
|
|
10
|
+
reset: "\x1b[0m",
|
|
11
|
+
bold: "\x1b[1m",
|
|
12
|
+
dim: "\x1b[2m",
|
|
13
|
+
italic: "\x1b[3m",
|
|
14
|
+
underline: "\x1b[4m",
|
|
15
|
+
|
|
16
16
|
// Foreground colors
|
|
17
|
-
black:
|
|
18
|
-
red:
|
|
19
|
-
green:
|
|
20
|
-
yellow:
|
|
21
|
-
blue:
|
|
22
|
-
magenta:
|
|
23
|
-
cyan:
|
|
24
|
-
white:
|
|
25
|
-
|
|
17
|
+
black: "\x1b[30m",
|
|
18
|
+
red: "\x1b[31m",
|
|
19
|
+
green: "\x1b[32m",
|
|
20
|
+
yellow: "\x1b[33m",
|
|
21
|
+
blue: "\x1b[34m",
|
|
22
|
+
magenta: "\x1b[35m",
|
|
23
|
+
cyan: "\x1b[36m",
|
|
24
|
+
white: "\x1b[37m",
|
|
25
|
+
|
|
26
26
|
// Bright foreground colors
|
|
27
|
-
brightRed:
|
|
28
|
-
brightGreen:
|
|
29
|
-
brightYellow:
|
|
30
|
-
brightBlue:
|
|
31
|
-
brightMagenta:
|
|
32
|
-
brightCyan:
|
|
33
|
-
brightWhite:
|
|
34
|
-
|
|
27
|
+
brightRed: "\x1b[91m",
|
|
28
|
+
brightGreen: "\x1b[92m",
|
|
29
|
+
brightYellow: "\x1b[93m",
|
|
30
|
+
brightBlue: "\x1b[94m",
|
|
31
|
+
brightMagenta: "\x1b[95m",
|
|
32
|
+
brightCyan: "\x1b[96m",
|
|
33
|
+
brightWhite: "\x1b[97m",
|
|
34
|
+
|
|
35
35
|
// Background colors
|
|
36
|
-
bgBlack:
|
|
37
|
-
bgRed:
|
|
38
|
-
bgGreen:
|
|
39
|
-
bgYellow:
|
|
40
|
-
bgBlue:
|
|
41
|
-
bgMagenta:
|
|
42
|
-
bgCyan:
|
|
43
|
-
bgWhite:
|
|
36
|
+
bgBlack: "\x1b[40m",
|
|
37
|
+
bgRed: "\x1b[41m",
|
|
38
|
+
bgGreen: "\x1b[42m",
|
|
39
|
+
bgYellow: "\x1b[43m",
|
|
40
|
+
bgBlue: "\x1b[44m",
|
|
41
|
+
bgMagenta: "\x1b[45m",
|
|
42
|
+
bgCyan: "\x1b[46m",
|
|
43
|
+
bgWhite: "\x1b[47m",
|
|
44
44
|
} as const;
|
|
45
45
|
|
|
46
46
|
// Check if colors should be disabled
|
|
47
|
-
let colorEnabled =
|
|
47
|
+
let colorEnabled =
|
|
48
|
+
!process.env.NO_COLOR &&
|
|
49
|
+
process.env.BUENO_NO_COLOR !== "true" &&
|
|
50
|
+
process.stdout.isTTY;
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
53
|
* Enable or disable colored output
|
|
@@ -72,22 +75,22 @@ function colorize(text: string, color: keyof typeof COLORS): string {
|
|
|
72
75
|
* Color helper functions
|
|
73
76
|
*/
|
|
74
77
|
export const colors = {
|
|
75
|
-
red: (text: string) => colorize(text,
|
|
76
|
-
green: (text: string) => colorize(text,
|
|
77
|
-
yellow: (text: string) => colorize(text,
|
|
78
|
-
blue: (text: string) => colorize(text,
|
|
79
|
-
magenta: (text: string) => colorize(text,
|
|
80
|
-
cyan: (text: string) => colorize(text,
|
|
81
|
-
white: (text: string) => colorize(text,
|
|
82
|
-
brightRed: (text: string) => colorize(text,
|
|
83
|
-
brightGreen: (text: string) => colorize(text,
|
|
84
|
-
brightYellow: (text: string) => colorize(text,
|
|
85
|
-
brightBlue: (text: string) => colorize(text,
|
|
86
|
-
brightCyan: (text: string) => colorize(text,
|
|
87
|
-
dim: (text: string) => colorize(text,
|
|
88
|
-
bold: (text: string) => colorize(text,
|
|
89
|
-
underline: (text: string) => colorize(text,
|
|
90
|
-
italic: (text: string) => colorize(text,
|
|
78
|
+
red: (text: string) => colorize(text, "red"),
|
|
79
|
+
green: (text: string) => colorize(text, "green"),
|
|
80
|
+
yellow: (text: string) => colorize(text, "yellow"),
|
|
81
|
+
blue: (text: string) => colorize(text, "blue"),
|
|
82
|
+
magenta: (text: string) => colorize(text, "magenta"),
|
|
83
|
+
cyan: (text: string) => colorize(text, "cyan"),
|
|
84
|
+
white: (text: string) => colorize(text, "white"),
|
|
85
|
+
brightRed: (text: string) => colorize(text, "brightRed"),
|
|
86
|
+
brightGreen: (text: string) => colorize(text, "brightGreen"),
|
|
87
|
+
brightYellow: (text: string) => colorize(text, "brightYellow"),
|
|
88
|
+
brightBlue: (text: string) => colorize(text, "brightBlue"),
|
|
89
|
+
brightCyan: (text: string) => colorize(text, "brightCyan"),
|
|
90
|
+
dim: (text: string) => colorize(text, "dim"),
|
|
91
|
+
bold: (text: string) => colorize(text, "bold"),
|
|
92
|
+
underline: (text: string) => colorize(text, "underline"),
|
|
93
|
+
italic: (text: string) => colorize(text, "italic"),
|
|
91
94
|
};
|
|
92
95
|
|
|
93
96
|
/**
|
|
@@ -105,36 +108,36 @@ export const cliConsole = {
|
|
|
105
108
|
* Log an info message
|
|
106
109
|
*/
|
|
107
110
|
info(message: string, ...args: unknown[]): void {
|
|
108
|
-
globalThis.console.log(colors.cyan(
|
|
111
|
+
globalThis.console.log(colors.cyan("ℹ"), message, ...args);
|
|
109
112
|
},
|
|
110
113
|
|
|
111
114
|
/**
|
|
112
115
|
* Log a success message
|
|
113
116
|
*/
|
|
114
117
|
success(message: string, ...args: unknown[]): void {
|
|
115
|
-
globalThis.console.log(colors.green(
|
|
118
|
+
globalThis.console.log(colors.green("✓"), message, ...args);
|
|
116
119
|
},
|
|
117
120
|
|
|
118
121
|
/**
|
|
119
122
|
* Log a warning message
|
|
120
123
|
*/
|
|
121
124
|
warn(message: string, ...args: unknown[]): void {
|
|
122
|
-
globalThis.console.log(colors.yellow(
|
|
125
|
+
globalThis.console.log(colors.yellow("⚠"), message, ...args);
|
|
123
126
|
},
|
|
124
127
|
|
|
125
128
|
/**
|
|
126
129
|
* Log an error message
|
|
127
130
|
*/
|
|
128
131
|
error(message: string, ...args: unknown[]): void {
|
|
129
|
-
globalThis.console.error(colors.red(
|
|
132
|
+
globalThis.console.error(colors.red("✗"), message, ...args);
|
|
130
133
|
},
|
|
131
134
|
|
|
132
135
|
/**
|
|
133
136
|
* Log a debug message (only in verbose mode)
|
|
134
137
|
*/
|
|
135
138
|
debug(message: string, ...args: unknown[]): void {
|
|
136
|
-
if (process.env.BUENO_VERBOSE ===
|
|
137
|
-
globalThis.console.log(colors.dim(
|
|
139
|
+
if (process.env.BUENO_VERBOSE === "true") {
|
|
140
|
+
globalThis.console.log(colors.dim("⋯"), colors.dim(message), ...args);
|
|
138
141
|
}
|
|
139
142
|
},
|
|
140
143
|
|
|
@@ -166,7 +169,7 @@ export const cliConsole = {
|
|
|
166
169
|
* Clear the console
|
|
167
170
|
*/
|
|
168
171
|
clear(): void {
|
|
169
|
-
process.stdout.write(
|
|
172
|
+
process.stdout.write("\x1b[2J\x1b[0f");
|
|
170
173
|
},
|
|
171
174
|
};
|
|
172
175
|
|
|
@@ -184,30 +187,22 @@ export function formatTable(
|
|
|
184
187
|
return Math.max(h.length, maxRowWidth);
|
|
185
188
|
});
|
|
186
189
|
|
|
187
|
-
const pad =
|
|
190
|
+
const pad = " ".repeat(padding);
|
|
188
191
|
|
|
189
192
|
// Header
|
|
190
|
-
const headerLine = headers
|
|
191
|
-
.map((h, i) => h.padEnd(widths[i] ?? 0))
|
|
192
|
-
.join(pad);
|
|
193
|
+
const headerLine = headers.map((h, i) => h.padEnd(widths[i] ?? 0)).join(pad);
|
|
193
194
|
|
|
194
195
|
// Separator
|
|
195
|
-
const separator = widths
|
|
196
|
-
.map((w) => '─'.repeat(w))
|
|
197
|
-
.join(pad);
|
|
196
|
+
const separator = widths.map((w) => "─".repeat(w)).join(pad);
|
|
198
197
|
|
|
199
198
|
// Rows
|
|
200
199
|
const rowLines = rows.map((row) =>
|
|
201
|
-
row
|
|
202
|
-
.map((cell, i) => (cell ?? '').padEnd(widths[i] ?? 0))
|
|
203
|
-
.join(pad)
|
|
200
|
+
row.map((cell, i) => (cell ?? "").padEnd(widths[i] ?? 0)).join(pad),
|
|
204
201
|
);
|
|
205
202
|
|
|
206
|
-
return [
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
...rowLines,
|
|
210
|
-
].join('\n');
|
|
203
|
+
return [colors.bold(headerLine), colors.dim(separator), ...rowLines].join(
|
|
204
|
+
"\n",
|
|
205
|
+
);
|
|
211
206
|
}
|
|
212
207
|
|
|
213
208
|
/**
|
|
@@ -228,10 +223,12 @@ export function formatList(
|
|
|
228
223
|
items: string[],
|
|
229
224
|
options: { bullet?: string; indent?: number } = {},
|
|
230
225
|
): string {
|
|
231
|
-
const bullet = options.bullet ??
|
|
232
|
-
const indent =
|
|
226
|
+
const bullet = options.bullet ?? "•";
|
|
227
|
+
const indent = " ".repeat(options.indent ?? 2);
|
|
233
228
|
|
|
234
|
-
return items
|
|
229
|
+
return items
|
|
230
|
+
.map((item) => `${indent}${colors.cyan(bullet)} ${item}`)
|
|
231
|
+
.join("\n");
|
|
235
232
|
}
|
|
236
233
|
|
|
237
234
|
/**
|
|
@@ -252,15 +249,11 @@ export interface TreeNode {
|
|
|
252
249
|
children?: TreeNode[];
|
|
253
250
|
}
|
|
254
251
|
|
|
255
|
-
export function formatTree(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
isLast = true,
|
|
259
|
-
): string {
|
|
260
|
-
const connector = isLast ? '└── ' : '├── ';
|
|
261
|
-
const childPrefix = isLast ? ' ' : '│ ';
|
|
252
|
+
export function formatTree(node: TreeNode, prefix = "", isLast = true): string {
|
|
253
|
+
const connector = isLast ? "└── " : "├── ";
|
|
254
|
+
const childPrefix = isLast ? " " : "│ ";
|
|
262
255
|
|
|
263
|
-
let result = prefix + connector + node.label +
|
|
256
|
+
let result = prefix + connector + node.label + "\n";
|
|
264
257
|
|
|
265
258
|
if (node.children) {
|
|
266
259
|
for (let i = 0; i < node.children.length; i++) {
|
|
@@ -288,7 +281,7 @@ export function printTree(node: TreeNode): void {
|
|
|
288
281
|
const child = node.children[i];
|
|
289
282
|
if (child) {
|
|
290
283
|
globalThis.console.log(
|
|
291
|
-
formatTree(child,
|
|
284
|
+
formatTree(child, "", i === node.children.length - 1),
|
|
292
285
|
);
|
|
293
286
|
}
|
|
294
287
|
}
|
|
@@ -299,7 +292,7 @@ export function printTree(node: TreeNode): void {
|
|
|
299
292
|
* Format file size
|
|
300
293
|
*/
|
|
301
294
|
export function formatSize(bytes: number): string {
|
|
302
|
-
const units = [
|
|
295
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
303
296
|
let size = bytes;
|
|
304
297
|
let unitIndex = 0;
|
|
305
298
|
|
|
@@ -325,7 +318,7 @@ export function formatDuration(ms: number): string {
|
|
|
325
318
|
*/
|
|
326
319
|
export function formatPath(path: string, baseDir?: string): string {
|
|
327
320
|
if (baseDir && path.startsWith(baseDir)) {
|
|
328
|
-
return
|
|
321
|
+
return "." + path.slice(baseDir.length);
|
|
329
322
|
}
|
|
330
323
|
return path;
|
|
331
324
|
}
|
|
@@ -336,14 +329,15 @@ export function formatPath(path: string, baseDir?: string): string {
|
|
|
336
329
|
export function highlightCode(code: string): string {
|
|
337
330
|
// Simple syntax highlighting for TypeScript
|
|
338
331
|
return code
|
|
339
|
-
.replace(
|
|
340
|
-
(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
.replace(
|
|
344
|
-
(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
.replace(
|
|
348
|
-
|
|
349
|
-
|
|
332
|
+
.replace(
|
|
333
|
+
/\b(import|export|from|const|let|var|function|class|interface|type|async|await|return|if|else|for|while|switch|case|break|continue|new|this|extends|implements)\b/g,
|
|
334
|
+
(match) => colors.magenta(match),
|
|
335
|
+
)
|
|
336
|
+
.replace(
|
|
337
|
+
/\b(string|number|boolean|void|any|unknown|never|null|undefined|true|false)\b/g,
|
|
338
|
+
(match) => colors.yellow(match),
|
|
339
|
+
)
|
|
340
|
+
.replace(/'([^']*)'|"([^"]*)"|`([^`]*)`/g, (match) => colors.green(match))
|
|
341
|
+
.replace(/\/\/.*$/gm, (match) => colors.dim(match))
|
|
342
|
+
.replace(/\/\*[\s\S]*?\*\//g, (match) => colors.dim(match));
|
|
343
|
+
}
|
package/src/cli/core/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ export {
|
|
|
14
14
|
type ParsedArgs,
|
|
15
15
|
type OptionDefinition,
|
|
16
16
|
type CommandDefinition,
|
|
17
|
-
} from
|
|
17
|
+
} from "./args";
|
|
18
18
|
|
|
19
19
|
export {
|
|
20
20
|
setColorEnabled,
|
|
@@ -32,7 +32,7 @@ export {
|
|
|
32
32
|
formatPath,
|
|
33
33
|
highlightCode,
|
|
34
34
|
type TreeNode,
|
|
35
|
-
} from
|
|
35
|
+
} from "./console";
|
|
36
36
|
|
|
37
37
|
export {
|
|
38
38
|
isInteractive,
|
|
@@ -46,7 +46,7 @@ export {
|
|
|
46
46
|
type SelectOptions,
|
|
47
47
|
type ConfirmOptions,
|
|
48
48
|
type MultiSelectOptions,
|
|
49
|
-
} from
|
|
49
|
+
} from "./prompt";
|
|
50
50
|
|
|
51
51
|
export {
|
|
52
52
|
Spinner,
|
|
@@ -57,4 +57,4 @@ export {
|
|
|
57
57
|
type SpinnerOptions,
|
|
58
58
|
type ProgressBarOptions,
|
|
59
59
|
type TaskOptions,
|
|
60
|
-
} from
|
|
60
|
+
} from "./spinner";
|