-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwelcome.ts
More file actions
84 lines (76 loc) · 3.61 KB
/
Copy pathwelcome.ts
File metadata and controls
84 lines (76 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { existsSync } from "node:fs";
import { getSnapshotPath } from "../cache/snapshot.js";
import { theme } from "./output.js";
const SYMBOL_LOGO = [
" ╷ ╱╲",
" ╭──────┼──────╱ ╲",
" ╭─╯ ●─────╯ ╱",
" ╱ ╱│ ╱",
"│ ╱ │ ╭────╯",
"│ ╱ │╱╱",
" ╲__╱ ╱│",
" ╲____╱ │",
" ╵"
];
const WIDE_WORDMARK = [
"██████╗ ███████╗██╗ ██╗███╗ ███╗ █████╗ ██████╗",
"██╔══██╗██╔════╝██║ ██║████╗ ████║██╔══██╗██╔══██╗",
"██║ ██║█████╗ ██║ ██║██╔████╔██║███████║██████╔╝",
"██║ ██║██╔══╝ ╚██╗ ██╔╝██║╚██╔╝██║██╔══██║██╔═══╝",
"██████╔╝███████╗ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║██║",
"╚═════╝ ╚══════╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝"
];
const WIDE_PANEL_WIDTH = 76;
const COMPACT_PANEL_WIDTH = 48;
const WIDE_TERMINAL_MINIMUM = 72;
export function printWelcome(projectRoot: string): void {
const hasSnapshot = existsSync(getSnapshotPath(projectRoot));
const status = hasSnapshot ? "Project snapshot found." : "No project analyzed yet.";
console.log(renderWelcomeBrandPanel(process.stdout.columns ?? 80));
console.log(" Understand Any Codebase.");
console.log(`\n ${theme.gray}──────────────────────────────────────────${theme.reset}\n`);
console.log(` ${status}\n`);
console.log(" Start with:\n");
printCommand("devmap init");
printCommand("devmap analyze");
console.log("\n Popular commands:\n");
printCommand("devmap analyze", "scan current project");
printCommand("devmap explain", "explain architecture");
printCommand('devmap ask "..."', "ask your codebase");
printCommand("devmap docs", "generate documentation");
printCommand("devmap onboard", "generate onboarding guide");
console.log("");
}
export function renderWelcomeBrandPanel(terminalWidth: number): string {
const isWide = terminalWidth >= WIDE_TERMINAL_MINIMUM;
const panelWidth = Math.max(
28,
Math.min(
terminalWidth,
isWide ? WIDE_PANEL_WIDTH : COMPACT_PANEL_WIDTH
)
);
const contentWidth = panelWidth - 4;
const wordmark = isWide ? WIDE_WORDMARK : ["DEVMAP"];
const content = [
...SYMBOL_LOGO,
"",
...wordmark
];
const top = `╭${"─".repeat(panelWidth - 2)}╮`;
const bottom = `╰${"─".repeat(panelWidth - 2)}╯`;
const rows = content.map((line) => {
const visibleLine = line.slice(0, contentWidth);
const leftPadding = Math.floor((contentWidth - visibleLine.length) / 2);
const rightPadding = contentWidth - visibleLine.length - leftPadding;
return `│ ${" ".repeat(leftPadding)}${visibleLine}${" ".repeat(rightPadding)} │`;
});
return [top, ...rows, bottom]
.map((line) => `${theme.aqua}${line}${theme.reset}`)
.join("\n");
}
function printCommand(command: string, description?: string): void {
const padded = command.padEnd(22);
const suffix = description ? ` ${theme.gray}${description}${theme.reset}` : "";
console.log(` ${theme.aqua}${padded}${theme.reset}${suffix}`);
}