Skip to content

Commit 9e768be

Browse files
committed
feat: improved TUI!!
1 parent cb4cc7b commit 9e768be

23 files changed

Lines changed: 1231 additions & 959 deletions

File tree

build.ts

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,17 @@ import {
99
rmSync,
1010
writeFileSync,
1111
} from "fs";
12-
import {configure, getConfig, logger, LogLevel} from "./src/utils/logger";
13-
import {getTheme} from "./src/utils/themes";
12+
import {logger} from "./src/utils/console/logger";
13+
import {getTheme, themeManager} from "./src/utils/console/themes";
1414

1515
// Read version from package.json
1616
const packageJson = JSON.parse(readFileSync("package.json", "utf-8"));
1717
const version = packageJson.version;
1818

19-
configure({
20-
level: LogLevel.TRACE,
21-
});
22-
2319
async function main() {
2420
const startTime = Date.now();
2521

26-
logger.format.header("Building Axogen CLI and Library");
22+
logger.header("Building Axogen CLI and Library");
2723
console.log(); // Add some spacing
2824

2925
setupDirectories();
@@ -49,12 +45,13 @@ async function main() {
4945

5046
const duration = Date.now() - startTime;
5147
console.log(); // Add spacing before final summary
52-
logger.success(`Build completed in ${duration}ms`);
48+
logger.success(`Build completed <muted>[${duration}ms]</muted>`);
5349

5450
console.log(); // Add spacing
55-
logger.format.divider("Next Steps");
56-
logger.info(`Run ${logger.text.command("./bin/axogen --version")} to test`);
57-
logger.info("Library built with tsup for better IDE support!");
51+
logger.divider("Next Steps");
52+
logger.info(`Run <secondary>./bin/axogen --version</secondary> to test`);
53+
logger.divider();
54+
console.log(); // Add spacing
5855
}
5956

6057
function setupDirectories() {
@@ -101,7 +98,7 @@ async function typeCheck() {
10198
// Fallback: if tsc not available, warn but continue
10299
logger.warn("TypeScript compiler not found, skipping type check");
103100
logger.info(
104-
`Install typescript globally: ${logger.text.command("bun add -g typescript")}`
101+
`Install typescript globally: <secondary>bun add -g typescript</secondary>`
105102
);
106103
}
107104
}
@@ -185,7 +182,7 @@ async function buildLibraryWithTsup() {
185182
return true;
186183
} catch (error) {
187184
logger.warn("tsup not available, falling back to bun build");
188-
logger.info(`Install tsup: ${logger.text.command("bun add -D tsup")}`);
185+
logger.info(`Install tsup: <secondary>bun add -D tsup</secondary>`);
189186

190187
// Fallback to original bun build method
191188
return await buildLibraryFallback();
@@ -242,14 +239,13 @@ async function generateTypes() {
242239
} catch (error) {
243240
logger.warn("Could not generate TypeScript declarations");
244241
logger.info(
245-
`Install typescript: ${logger.text.command("bun add -D typescript")}`
242+
`Install typescript: <secondary>bun add -D typescript</secondary>`
246243
);
247244
}
248245
}
249246

250247
function handleBuildFailure(result: Bun.BuildOutput) {
251-
const config = getConfig();
252-
const theme = getTheme(config.theme);
248+
const theme = themeManager.theme;
253249

254250
if (result.logs.length > 0) {
255251
// Group logs by level
@@ -262,7 +258,7 @@ function handleBuildFailure(result: Bun.BuildOutput) {
262258
warnings.length > 0 && `${warnings.length} warnings`,
263259
].filter(Boolean);
264260

265-
const subtitle = `${logger.text.muted("Found:")} ${result.logs.length} build issue${result.logs.length !== 1 ? "s" : ""} ${logger.text.muted(summaryParts.join(" • "))}`;
261+
const subtitle = `<muted>Found:</muted> ${result.logs.length} build issue${result.logs.length !== 1 ? "s" : ""} <muted>${summaryParts.join(" • ")}</muted>`;
266262

267263
// Map logs to items
268264
const items = result.logs.map((log) => {
@@ -272,25 +268,23 @@ function handleBuildFailure(result: Bun.BuildOutput) {
272268

273269
return {
274270
level: log.level,
275-
icon: "•",
276271
key: location,
277272
description: log.message,
278273
extra: log.name,
279274
};
280275
});
281276

282277
logger.logIssues({
283-
title: "Build failed!",
284-
titleIcon: "✗",
278+
title: "✗ Build failed!",
285279
subtitle,
286280
levels: {
287-
error: {color: theme.colors.error, icon: "❌"},
288-
warning: {color: theme.colors.warning, icon: "⚠️"},
281+
error: {color: "error"},
282+
warning: {color: "warning"},
289283
},
290284
items,
291285
footer: "Fix these issues and rebuild",
292286
footerIcon: "!",
293-
footerIconColor: theme.colors.warning,
287+
footerIconColor: "warning",
294288
});
295289
} else {
296290
// No specific logs, just show generic error
@@ -311,7 +305,7 @@ ${builtCode}`;
311305
writeFileSync("bin/axogen", executableContent);
312306
chmodSync("bin/axogen", "755");
313307

314-
logger.file("Executable created at bin/axogen");
308+
logger.file("Executable created", "bin/axogen");
315309
}
316310

317311
function cleanup() {

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"@types/js-yaml": "^4.0.9",
8282
"@types/papaparse": "^5.3.16",
8383
"ansis": "^4.1.0",
84+
"chalk": "^5.4.1",
8485
"commander": "^14.0.0",
8586
"cson": "^8.4.0",
8687
"fast-xml-parser": "^5.2.5",

src/cli-helpers/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
isAdvancedCommand,
1313
isGroupCommand,
1414
} from "./zod_helpers.ts";
15-
import {logger} from "../utils/logger.ts";
15+
import {logger} from "../utils/console/logger.ts";
1616

1717
export function buildDynamicCommands(
1818
cli: Command,

src/cli-helpers/commands/generate.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Command} from "commander";
22
import type {ZodAxogenConfig} from "../../config/types";
33
import {targetGenerator} from "../../generators";
4-
import {logger} from "../../utils/logger.ts";
4+
import {logger} from "../../utils/console/logger.ts";
55

66
export function createGenerateCommand(config: ZodAxogenConfig): Command {
77
return new Command("generate")
@@ -13,24 +13,27 @@ export function createGenerateCommand(config: ZodAxogenConfig): Command {
1313
"Show what would be generated without writing files"
1414
)
1515
.action(async (options) => {
16+
console.log();
1617
logger.start("Generating configuration files...");
1718

1819
if (!config.targets || Object.keys(config.targets).length === 0) {
1920
logger.info("No targets defined in config");
2021
return;
2122
}
2223

24+
const startTime = Date.now();
25+
2326
// Determine which targets to generate
2427
const targetsToGenerate = options.target
2528
? {[options.target]: config.targets[options.target]}
2629
: config.targets;
2730

2831
if (options.target && !config.targets[options.target]) {
29-
logger.error(`Target "${options.target}" not found`);
32+
logger.error(`Target "${options.target}" not found`);
3033
console.log();
3134
logger.info("Available targets:");
3235
Object.keys(config.targets).forEach((name) =>
33-
logger.format.bullet(name, 1)
36+
logger.bullet(name, 1)
3437
);
3538
process.exit(1);
3639
}
@@ -46,37 +49,40 @@ export function createGenerateCommand(config: ZodAxogenConfig): Command {
4649
);
4750

4851
console.log();
49-
console.log(logger.text.success("Results:"));
52+
logger.success("Results:");
5053

5154
results.forEach((result) => {
5255
if (result.success) {
5356
if (options.dryRun) {
5457
logger.file(
55-
`Would generate ${logger.text.file(result.name)} at ${logger.text.muted(result.path)}`
58+
`Would generate <b>${result.name}</b>`,
59+
result.path
5660
);
5761
} else {
5862
logger.file(
59-
`Generated ${logger.text.file(result.name)} at ${logger.text.muted(result.path)}`
63+
`Generated <b>${result.name}</b>`,
64+
result.path
6065
);
6166
}
6267
} else {
63-
logger.error(
64-
`${logger.text.normal("Failed to generate")} ${logger.text.error(result.name)}: ${logger.text.error(result.error || "Unknown error")}`
68+
logger.logF(
69+
`<error>✗</error> Failed to generate <b>${result.name}</b>: <error>${result.error || "Unknown error"}</error>`
6570
);
6671
}
6772
});
6873

6974
const successCount = results.filter((r) => r.success).length;
7075
const errorCount = results.length - successCount;
76+
const duration = (Date.now() - startTime).toFixed(2);
7177

7278
console.log(); // Add spacing before summary
7379
if (errorCount === 0) {
74-
logger.success(
75-
`${logger.text.normal("Generation complete!")} ${logger.text.success(`(${successCount} file${successCount !== 1 ? "s" : ""})`)}`
80+
logger.logF(
81+
`<success>Generation complete!</success> <muted>${successCount} file${successCount !== 1 ? "s" : ""}</muted> <subtle>[${duration}ms]</subtle>`
7682
);
7783
} else {
78-
logger.warn(
79-
`Generation complete with errors! ${successCount} success, ${errorCount} failed`
84+
logger.logF(
85+
`<warning>Generation complete with errors!</warning> <muted>${successCount} success, ${errorCount} failed</muted> <subtle>[${duration}ms]</subtle>`
8086
);
8187
}
8288

0 commit comments

Comments
 (0)