@archznn/xavva 2.3.0 → 2.5.0

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.
@@ -9,6 +9,11 @@ export class WatcherService {
9
9
  private pendingFullBuild = false;
10
10
  private coolingFiles = new Set<string>();
11
11
  private debounceTimer?: Timer;
12
+
13
+ // Rastreamento de arquivos modificados para build incremental inteligente
14
+ private modifiedFiles = new Set<string>();
15
+ private pendingFiles = new Set<string>(); // Arquivos modificados durante compilação
16
+ private hasPendingChanges = false;
12
17
 
13
18
  constructor(private config: AppConfig, private deployCmd: DeployCommand) {}
14
19
 
@@ -43,24 +48,57 @@ export class WatcherService {
43
48
  if (!isJava) return;
44
49
 
45
50
  Logger.watcher(filename, 'watch');
51
+
52
+ // Se estiver compilando, acumula na fila de pendentes
53
+ if (this.isDeploying) {
54
+ this.pendingFiles.add(filename);
55
+ this.hasPendingChanges = true;
56
+ return;
57
+ }
58
+
59
+ // Acumula arquivos modificados para o próximo build
60
+ this.modifiedFiles.add(filename);
61
+
46
62
  clearTimeout(this.debounceTimer);
47
63
 
48
64
  this.debounceTimer = setTimeout(() => {
49
- this.run(this.pendingFullBuild ? false : true);
65
+ const filesToCompile = [...this.modifiedFiles];
66
+ this.modifiedFiles.clear();
67
+ this.run(this.pendingFullBuild ? false : true, filesToCompile);
50
68
  this.pendingFullBuild = false;
51
69
  }, WATCHER_DEBOUNCE_MS);
52
70
  });
53
71
  }
54
72
 
55
- private async run(incremental = false) {
73
+ private async run(incremental = false, changedFiles?: string[]) {
56
74
  if (this.isDeploying) return;
57
75
  this.isDeploying = true;
76
+
58
77
  try {
59
- await this.deployCmd.execute(this.config, { watch: true, incremental });
78
+ // Passa os arquivos específicos que foram modificados
79
+ await this.deployCmd.execute(this.config, {
80
+ watch: true,
81
+ incremental,
82
+ changedFiles
83
+ });
60
84
  } catch (e) {
61
85
  // Error handled by command
62
86
  } finally {
63
87
  this.isDeploying = false;
88
+
89
+ // Se houve mudanças durante a compilação, processa imediatamente
90
+ if (this.hasPendingChanges) {
91
+ const pending = [...this.pendingFiles];
92
+ this.pendingFiles.clear();
93
+ this.hasPendingChanges = false;
94
+
95
+ Logger.watcher(`Processing ${pending.length} pending change(s)...`, 'warn');
96
+
97
+ // Pequeno delay para garantir que os arquivos foram salvos completamente
98
+ setTimeout(() => {
99
+ this.run(true, pending);
100
+ }, 100);
101
+ }
64
102
  }
65
103
  }
66
104
 
@@ -61,6 +61,7 @@ export interface CLIArguments {
61
61
  yes?: boolean;
62
62
  war?: boolean;
63
63
  cache?: boolean;
64
+ changedFiles?: string[];
64
65
  }
65
66
 
66
67
  export interface CommandContext {
@@ -79,7 +79,9 @@ export class ConfigManager {
79
79
  // Verificar se usar Tomcat embutido
80
80
  let tomcatPath = String(cliValues.path || xavvaJson.path || envTomcatPath || "");
81
81
  let useEmbedded = false;
82
- let embeddedVersion = String(cliValues["tomcat-version"] || xavvaJson.version || "10.1.52");
82
+ // Versão pode vir de: CLI flag > xavva.json tomcat.version > xavva.json version (legado) > padrão
83
+ const xavvaTomcatVersion = (xavvaJson as any).tomcat?.version;
84
+ let embeddedVersion = String(cliValues["tomcat-version"] || xavvaTomcatVersion || xavvaJson.version || "10.1.52");
83
85
 
84
86
  // Se não há Tomcat configurado ou não existe no path, usar embutido
85
87
  if (!tomcatPath || (!fs.existsSync(path.join(tomcatPath, "bin", "catalina.bat")) && isStart)) {
@@ -10,8 +10,8 @@ export const DEFAULT_DEBUG_PORT = 5005;
10
10
 
11
11
  // Timeouts (em milissegundos)
12
12
  export const TIMEOUT_SHUTDOWN_MS = 5000;
13
- export const WATCHER_DEBOUNCE_MS = 1000;
14
- export const WATCHER_COOLING_MS = 500;
13
+ export const WATCHER_DEBOUNCE_MS = 1500;
14
+ export const WATCHER_COOLING_MS = 1000;
15
15
  export const BROWSER_OPEN_DELAY_MS = 800;
16
16
  export const DEPLOY_HEALTH_CHECK_DELAY_MS = 1500;
17
17
  export const HOTSWAP_DELAY_MS = 500;