web-architect-cli 1.1.1 → 1.1.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/bin/build.js +47 -20
- package/package.json +1 -1
package/bin/build.js
CHANGED
|
@@ -4,7 +4,6 @@ const path = require('path');
|
|
|
4
4
|
const { execSync } = require('child_process');
|
|
5
5
|
|
|
6
6
|
const IS_WINDOWS = process.platform === 'win32';
|
|
7
|
-
|
|
8
7
|
const currentDirName = path.basename(path.resolve(__dirname));
|
|
9
8
|
|
|
10
9
|
const CONFIG = {
|
|
@@ -19,13 +18,15 @@ const CONFIG = {
|
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
let isBuilding = false;
|
|
21
|
+
let blockWatchEvents = false;
|
|
22
22
|
|
|
23
23
|
function gerarZip() {
|
|
24
|
-
if (isBuilding) return;
|
|
24
|
+
if (isBuilding || blockWatchEvents) return;
|
|
25
|
+
|
|
25
26
|
isBuilding = true;
|
|
27
|
+
blockWatchEvents = true;
|
|
26
28
|
|
|
27
|
-
console.
|
|
28
|
-
console.log(`🖥️ Sistema detectado: ${IS_WINDOWS ? 'WINDOWS' : 'LINUX/MAC'}`);
|
|
29
|
+
console.log(`\n🖥️ Sistema detectado: ${IS_WINDOWS ? 'WINDOWS' : 'LINUX/MAC'}`);
|
|
29
30
|
console.log('🚀 [Build] Iniciando processo...');
|
|
30
31
|
|
|
31
32
|
if (fs.existsSync('verify.js')) {
|
|
@@ -33,7 +34,7 @@ function gerarZip() {
|
|
|
33
34
|
execSync('node verify.js', { stdio: 'inherit' });
|
|
34
35
|
} catch (e) {
|
|
35
36
|
console.log('❌ Build cancelado: Erro na verificação.');
|
|
36
|
-
|
|
37
|
+
finalizarProcesso();
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -51,10 +52,20 @@ function gerarZip() {
|
|
|
51
52
|
|
|
52
53
|
} catch (error) {
|
|
53
54
|
console.error('❌ Erro Fatal:', error);
|
|
54
|
-
|
|
55
|
+
finalizarProcesso();
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
function finalizarProcesso() {
|
|
60
|
+
isBuilding = false;
|
|
61
|
+
|
|
62
|
+
console.log('🛡️ Ignorando eventos pós-build por 3s...');
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
blockWatchEvents = false;
|
|
65
|
+
console.log('👀 Monitoramento reativado.');
|
|
66
|
+
}, 3000);
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
function buildLinux() {
|
|
59
70
|
console.log('🐧 [Linux] Ajustando permissões...');
|
|
60
71
|
|
|
@@ -70,11 +81,10 @@ function buildLinux() {
|
|
|
70
81
|
const cmd = `zip -r "${CONFIG.NOME_ZIP}" "${CONFIG.ENTRY_FILE}" "${CONFIG.SOURCE_DIR}"`;
|
|
71
82
|
execSync(cmd, { stdio: 'inherit' });
|
|
72
83
|
|
|
73
|
-
console.log(`✅ [Sucesso] Arquivo '${CONFIG.NOME_ZIP}' criado
|
|
74
|
-
|
|
84
|
+
console.log(`✅ [Sucesso] Arquivo '${CONFIG.NOME_ZIP}' criado!`);
|
|
85
|
+
finalizarProcesso();
|
|
75
86
|
}
|
|
76
87
|
|
|
77
|
-
|
|
78
88
|
function buildWindows() {
|
|
79
89
|
console.log('🪟 [Windows] Compactando com Archiver...');
|
|
80
90
|
|
|
@@ -84,7 +94,7 @@ function buildWindows() {
|
|
|
84
94
|
output.on('close', function() {
|
|
85
95
|
const size = (archive.pointer() / 1024).toFixed(2);
|
|
86
96
|
console.log(`✅ [Sucesso] '${CONFIG.NOME_ZIP}' criado (${size} KB)`);
|
|
87
|
-
|
|
97
|
+
finalizarProcesso();
|
|
88
98
|
});
|
|
89
99
|
|
|
90
100
|
archive.on('error', function(err) {
|
|
@@ -94,11 +104,7 @@ function buildWindows() {
|
|
|
94
104
|
archive.pipe(output);
|
|
95
105
|
|
|
96
106
|
if (fs.existsSync(CONFIG.ENTRY_FILE)) {
|
|
97
|
-
archive.file(CONFIG.ENTRY_FILE, {
|
|
98
|
-
name: CONFIG.ENTRY_FILE,
|
|
99
|
-
mode: 0o777,
|
|
100
|
-
date: new Date()
|
|
101
|
-
});
|
|
107
|
+
archive.file(CONFIG.ENTRY_FILE, { name: CONFIG.ENTRY_FILE, mode: 0o777, date: new Date() });
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
if (fs.existsSync(CONFIG.SOURCE_DIR)) {
|
|
@@ -119,18 +125,39 @@ gerarZip();
|
|
|
119
125
|
|
|
120
126
|
if (CONFIG.MODO_AUTOMATICO) {
|
|
121
127
|
console.log('\n👀 Monitorando alterações...');
|
|
122
|
-
|
|
128
|
+
|
|
129
|
+
let debounceTimer;
|
|
130
|
+
let pendingChanges = new Set();
|
|
123
131
|
|
|
124
132
|
const paths = CONFIG.ITENS.map(i => i.path).filter(p => fs.existsSync(p));
|
|
125
133
|
|
|
126
134
|
paths.forEach(p => {
|
|
127
135
|
fs.watch(p, { recursive: true }, (evt, filename) => {
|
|
136
|
+
|
|
137
|
+
if (blockWatchEvents || isBuilding) return;
|
|
138
|
+
|
|
128
139
|
if (filename && !filename.includes('.zip') && !filename.includes('.tmp')) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
|
|
141
|
+
pendingChanges.add(filename);
|
|
142
|
+
clearTimeout(debounceTimer);
|
|
143
|
+
|
|
144
|
+
debounceTimer = setTimeout(() => {
|
|
145
|
+
if (blockWatchEvents || isBuilding) return;
|
|
146
|
+
|
|
147
|
+
console.clear();
|
|
148
|
+
console.log('━'.repeat(50));
|
|
149
|
+
console.log(`📝 DETECTADAS ${pendingChanges.size} ALTERAÇÕES (Usuário):`);
|
|
150
|
+
console.log('━'.repeat(50));
|
|
151
|
+
|
|
152
|
+
pendingChanges.forEach(file => {
|
|
153
|
+
console.log(` • ${file}`);
|
|
154
|
+
});
|
|
155
|
+
console.log('━'.repeat(50));
|
|
156
|
+
|
|
157
|
+
pendingChanges.clear();
|
|
132
158
|
gerarZip();
|
|
133
|
-
|
|
159
|
+
|
|
160
|
+
}, 1500);
|
|
134
161
|
}
|
|
135
162
|
});
|
|
136
163
|
});
|