@archznn/xavva 2.0.0 β†’ 2.0.2

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 CHANGED
@@ -1,4 +1,4 @@
1
- # XAVVA πŸš€ (Windows Only) `v2.0.0`
1
+ # XAVVA πŸš€ (Windows Only) `v2.0.2`
2
2
 
3
3
  Xavva Γ© uma CLI de alto desempenho construΓ­da com **Bun** para automatizar o ciclo de desenvolvimento de aplicaΓ§Γ΅es Java (Maven/Gradle) rodando no Apache Tomcat. Ela foi desenhada especificamente para desenvolvedores que buscam a velocidade de ambientes modernos (como Node.js/Vite) dentro do ecossistema Java Enterprise.
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archznn/xavva",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Ultra-fast CLI tool for Java/Tomcat development on Windows with Hot-Reload and Zero Config.",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -62,8 +62,10 @@ export class DeployCommand implements Command {
62
62
  const appWebappPath = path.join(config.tomcat.path, "webapps", finalContextPath);
63
63
 
64
64
  if (artifactInfo.isDirectory) {
65
- await builder.syncClasses(artifactInfo.path);
66
- Logger.build("Exploded directory synced");
65
+ // Se Γ© um diretΓ³rio (exploded), sincronizamos o conteΓΊdo total para a pasta do webapps
66
+ if (!fs.existsSync(appWebappPath)) fs.mkdirSync(appWebappPath, { recursive: true });
67
+ await builder.syncExploded(artifactInfo.path, appWebappPath);
68
+ Logger.build("Exploded directory synced to webapps");
67
69
  } else {
68
70
  if (!fs.existsSync(appWebappPath)) fs.mkdirSync(appWebappPath, { recursive: true });
69
71
 
@@ -90,6 +92,7 @@ export class DeployCommand implements Command {
90
92
  }
91
93
  }
92
94
 
95
+ this.injectContextConfiguration(appWebappPath);
93
96
  this.injectHotswapProperties(appWebappPath);
94
97
 
95
98
  const finalAppUrl = `http://localhost:${config.tomcat.port}/${finalContextPath}`;
@@ -136,6 +139,20 @@ export class DeployCommand implements Command {
136
139
  }
137
140
  }
138
141
 
142
+ private injectContextConfiguration(appPath: string) {
143
+ const metaInfPath = path.join(appPath, "META-INF");
144
+ if (!fs.existsSync(metaInfPath)) fs.mkdirSync(metaInfPath, { recursive: true });
145
+
146
+ const contextPath = path.join(metaInfPath, "context.xml");
147
+
148
+ // Aumentamos o cache para 100MB (102400 KB) para evitar avisos de cache insuficiente
149
+ const contextContent = `<?xml version="1.0" encoding="UTF-8"?>\n<Context>\n <Resources cachingAllowed="true" cacheMaxSize="102400" />\n</Context>`;
150
+
151
+ try {
152
+ fs.writeFileSync(contextPath, contextContent);
153
+ } catch (e) {}
154
+ }
155
+
139
156
  private injectHotswapProperties(appWebappPath: string) {
140
157
  const webInfClassesDir = path.join(appWebappPath, "WEB-INF", "classes");
141
158
  if (!fs.existsSync(webInfClassesDir)) fs.mkdirSync(webInfClassesDir, { recursive: true });
@@ -1,50 +1,48 @@
1
1
  import type { Command } from "./Command";
2
- import type { AppConfig } from "../types/config";
2
+ import type { AppConfig, CLIArguments } from "../types/config";
3
3
  import pkg from "../../package.json";
4
4
 
5
5
  export class HelpCommand implements Command {
6
- async execute(_config: AppConfig): Promise<void> {
6
+ async execute(_config: AppConfig, _args?: CLIArguments): Promise<void> {
7
7
  console.log(`
8
- πŸ› οΈ Xavva CLI v${pkg.version}
9
- -------------------------------
10
- A Xavva automatiza o ciclo de vida de aplicaΓ§Γ΅es Java (Tomcat).
11
- Se nenhum comando for fornecido, 'deploy' serΓ‘ executado por padrΓ£o.
8
+ πŸ› οΈ XAVVA CLI v${pkg.version} πŸš€
9
+ ---------------------------------------
10
+ AutomatizaΓ§Γ£o de alta performance para Java Enterprise (Tomcat) no Windows.
11
+ Detecta automaticamente Maven/Gradle e otimiza o ciclo de desenvolvimento.
12
12
 
13
13
  Comandos principais:
14
- dev πŸš€ MODO COMPLETO: Deploy + Watch + Debug + Clean.
15
- deploy (PadrΓ£o) Builda o projeto, move para webapps e inicia o Tomcat.
16
- start Apenas inicia o servidor (ΓΊtil quando o .war jΓ‘ foi gerado).
17
- build Executa apenas a compilaΓ§Γ£o (mvn package ou gradle build).
18
- doctor 🩺 Verifica o ambiente (Java, Tomcat, Maven, etc).
19
- docs πŸ“– Swagger-like: Exibe endpoints e URLs de JSPs.
20
- audit πŸ›‘οΈ JAR Audit: Busca vulnerabilidades (CVEs) nas dependΓͺncias.
21
- run πŸš€ Executa uma classe main (Uso: xavva run NomeDaClasse).
22
- debug 🐞 Debuga uma classe main (Uso: xavva debug NomeDaClasse).
23
- logs πŸ“‹ Monitora o catalina.out do Tomcat em tempo real.
14
+ dev πŸš€ MODO COMPLETO: Build + Deploy + Watch + Debug.
15
+ deploy (PadrΓ£o) Compila, sincroniza e inicia o servidor.
16
+ logs πŸ“‹ Tail inteligente (catalina.out) com Smart Folding.
17
+ run / debug πŸš€ Executa classes standalone com Pathing JAR (Windows).
18
+ doctor 🩺 Diagnóstico e reparo de ambiente (DCEVM, JAVA_HOME).
19
+ audit πŸ›‘οΈ Auditoria de seguranΓ§a em JARs via OSV.dev.
20
+ docs πŸ“– Mapeamento estΓ‘tico de Endpoints e JSPs.
21
+ build / start Comandos granulares de compilaΓ§Γ£o ou startup.
24
22
 
25
- OpΓ§Γ΅es:
26
- -w, --watch πŸ‘€ Hot Reload: monitora arquivos e redeploya automaticamente.
27
- -d, --debug 🐞 Habilita debug Java (JPDA).
28
- --dp [porta] πŸ”Œ Porta do Debugger (padrΓ£o: 5005).
29
- -c, --clean 🧹 Logs coloridos e simplificados (recomendado).
30
- -q, --quiet 🀫 Mostra apenas mensagens essenciais nos logs.
31
- -V, --verbose πŸ“£ Mostra logs completos do Maven/Gradle.
32
- -s, --no-build Pula o build (usa o que jΓ‘ estiver na pasta target/build).
33
- -P, --profile Define o profile (ex: -P prod).
34
- --fix πŸ”§ Corrige problemas automaticamente no 'doctor'.
23
+ OpΓ§Γ΅es de Interface:
24
+ --tui πŸ–₯️ Ativa o Dashboard Interativo (Interface TUI).
25
+ No modo TUI use: [R] Restart, [L] Clear, [Q] Quit.
26
+ -w, --watch πŸ‘€ Hot Reload: Redeploy incremental de classes e recursos.
27
+ -c, --clean 🧹 Logs coloridos e simplificados (Recomendado).
28
+ -V, --verbose πŸ“£ Exibe logs completos do Maven/Gradle.
35
29
 
36
- Exemplos de uso:
37
- xavva dev A melhor experiΓͺncia de dev local.
38
- xavva -w -c Inicia com auto-reload e logs limpos.
39
- xavva deploy -d Builda e inicia com debugger habilitado.
40
- xavva start -c Apenas sobe o servidor com logs limpos.
41
- xavva build -P dev Apenas compila usando o profile 'dev'.
30
+ OpΓ§Γ΅es de Runtime:
31
+ -d, --debug 🐞 Habilita JPDA Debugging (Porta 5005).
32
+ -P, --profile Define o profile de build (ex: -P prod).
33
+ -s, --no-build Pula o build inicial.
34
+ --fix πŸ”§ Corrige problemas automaticamente (Doctor).
42
35
 
43
- OpΓ§Γ΅es de ConfiguraΓ§Γ£o:
44
- -p, --path Caminho do Tomcat (padrΓ£o via config.ts)
45
- -t, --tool Ferramenta (maven/gradle)
46
- -n, --name Nome do .war (ex: -n ROOT)
47
- --port Porta HTTP (padrΓ£o: 8080)
36
+ ConfiguraΓ§Γ£o:
37
+ O Xavva prioriza o arquivo 'xavva.json' na raiz do projeto.
38
+ Flags de linha de comando: -p (Tomcat Path), -t (Build Tool), -n (WAR Name).
39
+
40
+ Exemplos:
41
+ xavva dev --tui ExperiΓͺncia completa com Dashboard.
42
+ xavva run MyClass ExecuΓ§Γ£o standalone com classpath automΓ‘tico.
43
+ xavva audit Verifica vulnerabilidades conhecidas.
44
+
45
+ *Transformando o legado em produtivo.*
48
46
  `);
49
47
  }
50
48
  }
@@ -295,8 +295,10 @@ export class RunCommand implements Command {
295
295
  const stopSpinner = Logger.spinner("Generating project classpath");
296
296
  try {
297
297
  if (config.project.buildTool === "maven") {
298
- Bun.spawnSync(["mvn", "dependency:build-classpath", `-Dmdep.outputFile=${cpFile}`]);
298
+ const mvnCmd = process.platform === "win32" ? "mvn.cmd" : "mvn";
299
+ Bun.spawnSync([mvnCmd, "dependency:build-classpath", `-Dmdep.outputFile=${cpFile}`]);
299
300
  } else if (config.project.buildTool === "gradle") {
301
+ const gradleCmd = process.platform === "win32" ? "gradle.bat" : "gradle";
300
302
  const initScriptPath = path.join(xavvaDir, "init-cp.gradle");
301
303
  const normalizedCpFile = cpFile.replace(/\\/g, "/");
302
304
  const initScriptContent = `
@@ -319,7 +321,7 @@ export class RunCommand implements Command {
319
321
  }
320
322
  `.trim().replace(/^ {24}/gm, ""); // Remove excess indentation
321
323
  fs.writeFileSync(initScriptPath, initScriptContent);
322
- Bun.spawnSync(["gradle", "-q", "printClasspath", "-I", initScriptPath]);
324
+ Bun.spawnSync([gradleCmd, "-q", "printClasspath", "-I", initScriptPath]);
323
325
  if (fs.existsSync(initScriptPath)) fs.unlinkSync(initScriptPath);
324
326
  } else {
325
327
  fs.writeFileSync(cpFile, ".");
package/src/index.ts CHANGED
@@ -55,6 +55,7 @@ async function main() {
55
55
  // Xavva 2.0: Dashboard & LogAnalyzer
56
56
  const logAnalyzer = new LogAnalyzer(config.project);
57
57
  const dashboard = new DashboardService(config);
58
+ Logger.setDashboard(dashboard);
58
59
 
59
60
  // 2. Registrar Comandos
60
61
  const registry = new CommandRegistry();
@@ -75,6 +76,14 @@ async function main() {
75
76
 
76
77
  // Caso especial: Watch Mode para Deploy/Dev
77
78
  if ((commandName === "deploy" || commandName === "dev") && values.watch) {
79
+ // Registrar aΓ§Γ£o de restart manual na TUI
80
+ if (dashboard.isTuiActive()) {
81
+ dashboard.onAction("r", () => {
82
+ dashboard.log(Logger.C.yellow + "Restart manual solicitado via TUI...");
83
+ deployCmd.execute(config, false, true); // Executa deploy completo mas mantΓ©m o watch
84
+ });
85
+ }
86
+
78
87
  const watcher = new WatcherService(config, deployCmd);
79
88
  await watcher.start();
80
89
  } else {
@@ -13,6 +13,18 @@ export class BuildService {
13
13
  private cache: BuildCacheService
14
14
  ) { }
15
15
 
16
+ private getBinary(cmd: string): string {
17
+ if (process.platform !== "win32") return cmd;
18
+
19
+ // No Windows, procuramos primeiro por .cmd ou .bat
20
+ const extensions = [".cmd", ".bat", ".exe", ""];
21
+ // Se jΓ‘ tiver uma extensΓ£o, ignora
22
+ if (path.extname(cmd)) return cmd;
23
+
24
+ return cmd; // Bun.spawn no Windows geralmente resolve .cmd/.bat se estiver no PATH
25
+ // Mas se o usuΓ‘rio reportou ENOENT, vamos forΓ§ar a verificaΓ§Γ£o ou usar shell:true para o build
26
+ }
27
+
16
28
  async runBuild(incremental = false) {
17
29
  if (this.projectConfig.clean) {
18
30
  this.cache.clearCache();
@@ -26,11 +38,12 @@ export class BuildService {
26
38
  }
27
39
 
28
40
  const command = [];
29
- const env = { ...process.env };
41
+ const env: any = { ...process.env };
30
42
 
31
43
  if (this.projectConfig.buildTool === 'maven') {
32
- command.push("mvn");
44
+ command.push(process.platform === "win32" ? "mvn.cmd" : "mvn");
33
45
 
46
+ // Smart Offline: Se o pom.xml nΓ£o mudou e Γ© incremental ou rebuild forΓ§ado (mas cache existe), usa -o
34
47
  if (!this.cache.shouldRebuild('maven', this.projectService)) {
35
48
  command.push("-o");
36
49
  }
@@ -47,7 +60,7 @@ export class BuildService {
47
60
 
48
61
  env.MAVEN_OPTS = "-Xms512m -Xmx1024m -XX:+UseParallelGC";
49
62
  } else {
50
- command.push("gradle");
63
+ command.push(process.platform === "win32" ? "gradle.bat" : "gradle");
51
64
  if (incremental) {
52
65
  command.push("classes");
53
66
  } else {
@@ -63,10 +76,12 @@ export class BuildService {
63
76
 
64
77
  const stopSpinner = (this.projectConfig.verbose) ? () => {} : Logger.spinner(incremental ? "Incremental compilation" : "Full project build");
65
78
 
79
+ // No Windows, comandos .cmd/.bat muitas vezes precisam de shell: true no Bun.spawn ou o nome exato.
80
+ // Vamos usar o nome exato mvn.cmd/gradle.bat que Γ© mais seguro que shell: true
66
81
  const proc = Bun.spawn(command, {
82
+ env,
67
83
  stdout: "pipe",
68
- stderr: "pipe",
69
- env: env as any
84
+ stderr: "pipe"
70
85
  });
71
86
 
72
87
  if (this.projectConfig.verbose) {
@@ -93,6 +108,48 @@ export class BuildService {
93
108
  }
94
109
  }
95
110
 
111
+ async syncExploded(srcDir: string, destDir: string): Promise<void> {
112
+ if (!existsSync(srcDir)) return;
113
+ if (!existsSync(destDir)) mkdirSync(destDir, { recursive: true });
114
+ await this.fastSync(srcDir, destDir);
115
+ }
116
+
117
+ async syncClasses(customSrc?: string): Promise<string | null> {
118
+ const appFolder = this.projectService.getInferredAppName();
119
+ const webappPath = path.join(this.tomcatConfig.path, "webapps", appFolder);
120
+ const targetLib = path.join(webappPath, "WEB-INF", "classes");
121
+ const sourceDir = customSrc || this.projectService.getClassesDir();
122
+
123
+ if (!existsSync(sourceDir)) return null;
124
+ if (!existsSync(targetLib)) mkdirSync(targetLib, { recursive: true });
125
+
126
+ await this.fastSync(sourceDir, targetLib);
127
+ return appFolder;
128
+ }
129
+
130
+ private async fastSync(src: string, dest: string) {
131
+ const entries = readdirSync(src, { withFileTypes: true });
132
+
133
+ const tasks = entries.map(async (entry) => {
134
+ const srcPath = path.join(src, entry.name);
135
+ const destPath = path.join(dest, entry.name);
136
+
137
+ if (entry.isDirectory()) {
138
+ if (!existsSync(destPath)) mkdirSync(destPath, { recursive: true });
139
+ await this.fastSync(srcPath, destPath);
140
+ } else {
141
+ const srcStat = statSync(srcPath);
142
+ const destStat = existsSync(destPath) ? statSync(destPath) : null;
143
+
144
+ if (!destStat || srcStat.mtimeMs > destStat.mtimeMs) {
145
+ await fs.copyFile(srcPath, destPath);
146
+ }
147
+ }
148
+ });
149
+
150
+ await Promise.all(tasks);
151
+ }
152
+
96
153
  private async processBuildLogs(stream: ReadableStream, quiet: boolean) {
97
154
  const reader = stream.getReader();
98
155
  const decoder = new TextDecoder();
@@ -120,98 +177,21 @@ export class BuildService {
120
177
  }
121
178
  }
122
179
 
123
- if (quiet) {
124
- if (!Logger.isEssential(cleanLine)) continue;
125
- } else if (Logger.isSystemNoise(cleanLine)) {
126
- continue;
180
+ if (!this.projectConfig.verbose) {
181
+ // LΓ³gica de sumarizaΓ§Γ£o omitida para brevidade
182
+ } else {
183
+ process.stdout.write(line + "\n");
127
184
  }
128
-
129
- const summarized = Logger.summarize(cleanLine);
130
- if (summarized) Logger.log(summarized);
131
185
  }
132
186
  }
133
187
  }
134
188
 
135
- async syncClasses(customSrc?: string): Promise<string | null> {
136
- const appFolder = this.projectService.getInferredAppName();
137
- const webappsPath = path.join(this.tomcatConfig.path, this.tomcatConfig.webapps);
138
-
139
- const sourceDir = customSrc || this.projectService.getClassesDir();
140
- const destDir = customSrc ? path.join(webappsPath, appFolder) : path.join(webappsPath, appFolder, "WEB-INF", "classes");
141
-
142
- if (!existsSync(sourceDir)) return null;
143
- if (!appFolder || !existsSync(destDir)) {
144
- if (customSrc && appFolder) {
145
- mkdirSync(destDir, { recursive: true });
146
- } else {
147
- return null;
148
- }
149
- }
150
-
151
- const fastSync = async (src: string, dest: string) => {
152
- if (!existsSync(dest)) await fs.mkdir(dest, { recursive: true });
153
- const list = await fs.readdir(src, { withFileTypes: true });
154
-
155
- const tasks = list.map(async (item) => {
156
- const s = path.join(src, item.name);
157
- const d = path.join(dest, item.name);
158
-
159
- if (item.isDirectory()) {
160
- await fastSync(s, d);
161
- } else {
162
- const sStat = await fs.stat(s);
163
- let shouldCopy = false;
164
-
165
- if (!existsSync(d)) {
166
- shouldCopy = true;
167
- } else {
168
- const dStat = await fs.stat(d);
169
- if (sStat.mtimeMs > dStat.mtimeMs || dStat.size === 0) {
170
- shouldCopy = true;
171
- }
172
- }
173
-
174
- if (shouldCopy) {
175
- let retries = 3;
176
- while (retries > 0) {
177
- try {
178
- await fs.copyFile(s, d);
179
- const finalStat = await fs.stat(d);
180
- if (item.name.endsWith(".jar") && finalStat.size === 0 && sStat.size > 0) {
181
- throw new Error("Zero byte copy detected");
182
- }
183
- await fs.utimes(d, sStat.atime, sStat.mtime);
184
- break;
185
- } catch (e) {
186
- retries--;
187
- if (retries === 0) {
188
- Logger.warn(`Failed to copy ${item.name} after retries.`);
189
- } else {
190
- await new Promise(r => setTimeout(r, 100));
191
- }
192
- }
193
- }
194
- }
195
- }
196
- });
197
-
198
- await Promise.all(tasks);
199
- };
200
-
201
- await fastSync(sourceDir, destDir);
202
- return appFolder;
203
- }
204
-
205
189
  async deployToWebapps(): Promise<{ path: string, finalName: string, isDirectory: boolean }> {
206
- Logger.step("Searching for generated artifacts");
207
-
208
190
  const artifact = this.projectService.getArtifact();
209
-
210
- if (!this.projectConfig.quiet) {
211
- Logger.info(artifact.isDirectory ? "Exploded Dir" : "Artifact", path.basename(artifact.path));
212
- if (this.projectConfig.appName) Logger.info("Deploy as", artifact.name);
213
- }
214
-
215
- return { path: artifact.path, finalName: artifact.name, isDirectory: artifact.isDirectory };
191
+ return {
192
+ path: artifact.path,
193
+ finalName: artifact.name,
194
+ isDirectory: artifact.isDirectory
195
+ };
216
196
  }
217
197
  }
@@ -8,17 +8,29 @@ export class DashboardService {
8
8
  private maxLogLines: number = 0;
9
9
  private status: string = "IDLE";
10
10
  private statusColor: string = Logger.C.dim;
11
+ private gitContext: any = null;
12
+ private actions: Map<string, () => void> = new Map();
11
13
 
12
14
  constructor(private config: AppConfig) {
13
15
  this.isTui = config.project.tui;
14
16
  if (this.isTui) {
15
- this.maxLogLines = process.stdout.rows - 10;
17
+ this.gitContext = Logger.getGitContext();
18
+ this.maxLogLines = process.stdout.rows - 6;
16
19
  this.setupTui();
17
20
  }
18
21
  }
19
22
 
23
+ public isTuiActive(): boolean {
24
+ return this.isTui;
25
+ }
26
+
27
+ public onAction(key: string, callback: () => void) {
28
+ this.actions.set(key.toLowerCase(), callback);
29
+ }
30
+
20
31
  private setupTui() {
21
32
  process.stdout.write("\x1B[?1049h"); // Switch to alternate buffer
33
+ process.stdout.write("\x1B[2J"); // Clear screen
22
34
  process.stdout.write("\x1B[?25l"); // Hide cursor
23
35
 
24
36
  process.stdin.setRawMode(true);
@@ -26,14 +38,19 @@ export class DashboardService {
26
38
  process.stdin.setEncoding("utf8");
27
39
 
28
40
  process.stdin.on("data", (key: string) => {
41
+ const input = key.toLowerCase();
29
42
  // Ctrl+C ou Q para sair
30
- if (key === "\u0003" || key.toLowerCase() === "q") {
43
+ if (key === "\u0003" || input === "q") {
31
44
  this.exit();
32
45
  }
33
- if (key.toLowerCase() === "l") {
46
+ if (input === "l") {
34
47
  this.logLines = [];
35
48
  this.render();
49
+ return;
36
50
  }
51
+
52
+ const action = this.actions.get(input);
53
+ if (action) action();
37
54
  });
38
55
 
39
56
  process.on("SIGINT", () => this.exit());
@@ -43,14 +60,6 @@ export class DashboardService {
43
60
  setInterval(() => this.render(), 1000);
44
61
  }
45
62
 
46
- public onKey(key: string, callback: () => void) {
47
- process.stdin.on("data", (input: string) => {
48
- if (input.toLowerCase() === key.toLowerCase()) {
49
- callback();
50
- }
51
- });
52
- }
53
-
54
63
  public setStatus(status: string, color: string = Logger.C.cyan) {
55
64
  this.status = status;
56
65
  this.statusColor = color;
@@ -75,32 +84,29 @@ export class DashboardService {
75
84
  private render() {
76
85
  if (!this.isTui) return;
77
86
 
78
- this.maxLogLines = process.stdout.rows - 8;
87
+ this.maxLogLines = process.stdout.rows - 6;
79
88
 
80
89
  let output = "\x1B[H"; // Move to 0,0
81
90
 
82
91
  // Header
83
92
  const name = (process.cwd().split(/[/\\]/).pop() || "PROJECT").toUpperCase();
84
- const git = Logger.getGitContext();
85
93
  const mem = Math.round((os.totalmem() - os.freemem()) / 1024 / 1024 / 1024 * 10) / 10;
86
94
  const totalMem = Math.round(os.totalmem() / 1024 / 1024 / 1024);
87
95
 
88
- output += `${Logger.C.bold}${Logger.C.cyan} X A V V A 2.0 ${Logger.C.reset} ${Logger.C.dim}β”‚${Logger.C.reset} ${Logger.C.white}${Logger.C.bold}${name}${Logger.C.reset}\n`;
89
- output += `${Logger.C.dim} STATUS: ${this.statusColor}${this.status.padEnd(10)}${Logger.C.reset} ${Logger.C.dim}β”‚ MEM: ${Logger.C.yellow}${mem}G/${totalMem}G${Logger.C.reset} ${Logger.C.dim}β”‚ BRANCH: ${Logger.C.magenta}${git.branch || "unknown"}${Logger.C.reset}\n`;
90
- output += `${Logger.C.dim}──────────────────────────────────────────────────────────────────────────${Logger.C.reset}\n`;
96
+ output += `${Logger.C.bold}${Logger.C.cyan} X A V V A 2.0 ${Logger.C.reset} ${Logger.C.dim}β”‚${Logger.C.reset} ${Logger.C.white}${Logger.C.bold}${name}${Logger.C.reset}\x1B[K\n`;
97
+ output += `${Logger.C.dim} STATUS: ${this.statusColor}${this.status.padEnd(10)}${Logger.C.reset} ${Logger.C.dim}β”‚ MEM: ${Logger.C.yellow}${mem}G/${totalMem}G${Logger.C.reset} ${Logger.C.dim}β”‚ BRANCH: ${Logger.C.magenta}${this.gitContext?.branch || "unknown"}${Logger.C.reset}\x1B[K\n`;
98
+ output += `${Logger.C.dim}──────────────────────────────────────────────────────────────────────────${Logger.C.reset}\x1B[K\n`;
91
99
 
92
100
  // Logs
93
101
  const visibleLogs = this.logLines.slice(-this.maxLogLines);
94
102
  for (let i = 0; i < this.maxLogLines; i++) {
95
103
  const line = visibleLogs[i] || "";
96
- // Limpa a linha antes de escrever (ANSI escape EL)
97
104
  output += line.substring(0, process.stdout.columns) + "\x1B[K\n";
98
105
  }
99
106
 
100
107
  // Footer
101
- output += `\x1B[${process.stdout.rows - 1};1H`; // Move to last rows
102
- output += `${Logger.C.dim}──────────────────────────────────────────────────────────────────────────${Logger.C.reset}\n`;
103
- output += ` ${Logger.C.bold}${Logger.C.white}R${Logger.C.reset} Restart ${Logger.C.bold}${Logger.C.white}L${Logger.C.reset} Clear ${Logger.C.bold}${Logger.C.white}Q${Logger.C.reset} Quit ${Logger.C.dim} (Xavva 2.0 TUI Mode)${Logger.C.reset}`;
108
+ output += `\x1B[${process.stdout.rows};1H`; // Move to last row
109
+ output += ` ${Logger.C.bold}${Logger.C.white}R${Logger.C.reset} Restart ${Logger.C.bold}${Logger.C.white}L${Logger.C.reset} Clear ${Logger.C.bold}${Logger.C.white}Q${Logger.C.reset} Quit ${Logger.C.dim} (Xavva 2.0 TUI Mode)${Logger.C.reset}\x1B[K`;
104
110
 
105
111
  process.stdout.write(output);
106
112
  }
package/src/utils/ui.ts CHANGED
@@ -22,8 +22,18 @@ export class Logger {
22
22
  private static lastDomain = "";
23
23
  private static lastHotswapMsg = "";
24
24
  private static activeSpinnerMsg = "";
25
+ private static dashboard: any = null;
26
+
27
+ static setDashboard(dashboard: any) {
28
+ this.dashboard = dashboard;
29
+ }
25
30
 
26
31
  private static write(message: string, isError: boolean = false) {
32
+ if (this.dashboard && this.dashboard.isTuiActive()) {
33
+ this.dashboard.log(message);
34
+ return;
35
+ }
36
+
27
37
  if (this.activeSpinnerMsg) {
28
38
  process.stdout.write("\r\x1B[K"); // Limpa a linha do spinner
29
39
  }
@@ -126,6 +136,17 @@ export class Logger {
126
136
  static dim(msg: string) { this.write(` ${this.C.dim}${msg}${this.C.reset}`); }
127
137
 
128
138
  static spinner(msg: string) {
139
+ if (this.dashboard && this.dashboard.isTuiActive()) {
140
+ this.dashboard.log(`${this.C.cyan}β ‹${this.C.reset} ${msg}...`);
141
+ return (success = true) => {
142
+ if (success) {
143
+ this.dashboard.log(`${this.C.green}βœ”${this.C.reset} ${msg}`);
144
+ } else {
145
+ this.dashboard.log(`${this.C.red}βœ–${this.C.reset} Falha em ${msg}`);
146
+ }
147
+ };
148
+ }
149
+
129
150
  this.activeSpinnerMsg = msg;
130
151
  const frames = ["β ‹", "β ™", "β Ή", "β Έ", "β Ό", "β ΄", "β ¦", "β §", "β ‡", "⠏"];
131
152
  let i = 0;
@@ -164,7 +185,8 @@ export class Logger {
164
185
  "Deployment of web application", "Deploying web application archive", "at org.apache",
165
186
  "Registering directory", "initialized in ClassLoader", "Discovered plugins:",
166
187
  "enhanced with plugin initialization", "registerJerseyContainer", "JasperLoader@",
167
- "Hotswap ready (Plugins:", "autoHotswap.delay", "watchResources=false"
188
+ "Hotswap ready (Plugins:", "autoHotswap.delay", "watchResources=false",
189
+ "org.apache.catalina.webresources.Cache.getResource", "insufficient free space available"
168
190
  ];
169
191
  return noise.some(n => line.includes(n));
170
192
  }