web-architect-cli 1.0.9 → 1.1.1

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
@@ -237,8 +237,6 @@ npm run commit
237
237
 
238
238
 
239
239
 
240
-
241
-
242
240
  ## 🛠 Comandos do Projeto (Scripts)
243
241
 
244
242
  Dentro da pasta do projeto criado, você pode usar:
package/bin/build.js ADDED
@@ -0,0 +1,137 @@
1
+ const fs = require('fs');
2
+ const archiver = require('archiver');
3
+ const path = require('path');
4
+ const { execSync } = require('child_process');
5
+
6
+ const IS_WINDOWS = process.platform === 'win32';
7
+
8
+ const currentDirName = path.basename(path.resolve(__dirname));
9
+
10
+ const CONFIG = {
11
+ MODO_AUTOMATICO: true,
12
+ NOME_ZIP: `${currentDirName}.zip`,
13
+ ENTRY_FILE: 'index.jsp',
14
+ SOURCE_DIR: 'src',
15
+ ITENS: [
16
+ { type: 'file', path: 'index.jsp' },
17
+ { type: 'directory', path: 'src/' }
18
+ ]
19
+ };
20
+
21
+ let isBuilding = false;
22
+
23
+ function gerarZip() {
24
+ if (isBuilding) return;
25
+ isBuilding = true;
26
+
27
+ console.clear();
28
+ console.log(`🖥️ Sistema detectado: ${IS_WINDOWS ? 'WINDOWS' : 'LINUX/MAC'}`);
29
+ console.log('🚀 [Build] Iniciando processo...');
30
+
31
+ if (fs.existsSync('verify.js')) {
32
+ try {
33
+ execSync('node verify.js', { stdio: 'inherit' });
34
+ } catch (e) {
35
+ console.log('❌ Build cancelado: Erro na verificação.');
36
+ isBuilding = false;
37
+ return;
38
+ }
39
+ }
40
+
41
+ try {
42
+ if (fs.existsSync(CONFIG.NOME_ZIP)) {
43
+ fs.unlinkSync(CONFIG.NOME_ZIP);
44
+ }
45
+
46
+ if (IS_WINDOWS) {
47
+ buildWindows();
48
+ } else {
49
+ buildLinux();
50
+ }
51
+
52
+ } catch (error) {
53
+ console.error('❌ Erro Fatal:', error);
54
+ isBuilding = false;
55
+ }
56
+ }
57
+
58
+ function buildLinux() {
59
+ console.log('🐧 [Linux] Ajustando permissões...');
60
+
61
+ if (fs.existsSync(CONFIG.SOURCE_DIR)) {
62
+ execSync(`chmod -R 777 "${CONFIG.SOURCE_DIR}"`);
63
+ }
64
+ if (fs.existsSync(CONFIG.ENTRY_FILE)) {
65
+ execSync(`chmod 777 "${CONFIG.ENTRY_FILE}"`);
66
+ }
67
+
68
+ console.log('📦 [Linux] Compactando com ZIP nativo...');
69
+
70
+ const cmd = `zip -r "${CONFIG.NOME_ZIP}" "${CONFIG.ENTRY_FILE}" "${CONFIG.SOURCE_DIR}"`;
71
+ execSync(cmd, { stdio: 'inherit' });
72
+
73
+ console.log(`✅ [Sucesso] Arquivo '${CONFIG.NOME_ZIP}' criado com permissões!`);
74
+ isBuilding = false;
75
+ }
76
+
77
+
78
+ function buildWindows() {
79
+ console.log('🪟 [Windows] Compactando com Archiver...');
80
+
81
+ const output = fs.createWriteStream(path.join(__dirname, CONFIG.NOME_ZIP));
82
+ const archive = archiver('zip', { zlib: { level: 9 } });
83
+
84
+ output.on('close', function() {
85
+ const size = (archive.pointer() / 1024).toFixed(2);
86
+ console.log(`✅ [Sucesso] '${CONFIG.NOME_ZIP}' criado (${size} KB)`);
87
+ isBuilding = false;
88
+ });
89
+
90
+ archive.on('error', function(err) {
91
+ throw err;
92
+ });
93
+
94
+ archive.pipe(output);
95
+
96
+ 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
+ });
102
+ }
103
+
104
+ if (fs.existsSync(CONFIG.SOURCE_DIR)) {
105
+ archive.glob('**/*', {
106
+ cwd: CONFIG.SOURCE_DIR,
107
+ ignore: ['.DS_Store', 'Thumbs.db']
108
+ }, {
109
+ prefix: CONFIG.SOURCE_DIR,
110
+ mode: 0o777,
111
+ date: new Date()
112
+ });
113
+ }
114
+
115
+ archive.finalize();
116
+ }
117
+
118
+ gerarZip();
119
+
120
+ if (CONFIG.MODO_AUTOMATICO) {
121
+ console.log('\n👀 Monitorando alterações...');
122
+ let debounce;
123
+
124
+ const paths = CONFIG.ITENS.map(i => i.path).filter(p => fs.existsSync(p));
125
+
126
+ paths.forEach(p => {
127
+ fs.watch(p, { recursive: true }, (evt, filename) => {
128
+ if (filename && !filename.includes('.zip') && !filename.includes('.tmp')) {
129
+ clearTimeout(debounce);
130
+ debounce = setTimeout(() => {
131
+ console.log(`📝 Alteração: ${filename}`);
132
+ gerarZip();
133
+ }, 500);
134
+ }
135
+ });
136
+ });
137
+ }
package/bin/index.js CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // ==========================================
4
+ // 0. FIX PARA WINDOWS (Emojis & UTF-8)
5
+ // ==========================================
3
6
  if (process.platform === "win32") {
4
7
  try {
5
8
  require("child_process").execSync("chcp 65001", { stdio: 'ignore' });
@@ -86,6 +89,7 @@ try {
86
89
  } else {
87
90
  console.log(\` [2] (Opção igual a 1 pois são poucos arquivos)\`);
88
91
  }
92
+
89
93
  console.log(' [3] Manual (Digitar sua própria mensagem)');
90
94
 
91
95
  rl.question('\\n👉 Escolha (1-3): ', (msgOpcao) => {
@@ -110,6 +114,7 @@ function executarCommit(tipo, titulo, corpo) {
110
114
  const msgFinal = \`\${tipo}: \${titulo}\`;
111
115
  console.log('\\n⏳ Executando git add .');
112
116
  execSync('git add .');
117
+
113
118
  console.log(\`⏳ Commitando: "\${msgFinal}"\`);
114
119
  try {
115
120
  if (corpo) {
@@ -126,7 +131,48 @@ function executarCommit(tipo, titulo, corpo) {
126
131
  `;
127
132
 
128
133
  // ==========================================
129
- // 2. SCRIPT DE VERIFICAÇÃO INTERATIVA (NOVO)
134
+ // 2. CONFIGURAÇÃO ESLINT (FLAT CONFIG - V9+)
135
+ // ==========================================
136
+ const CONTEUDO_ESLINT = `const config = [
137
+ {
138
+ ignores: ["node_modules/**", "build.js", "commit.js", "verify.js", "*.zip", "src/assets/js/tailwindcss.js"]
139
+ },
140
+ {
141
+ files: ["src/**/*.js"],
142
+ languageOptions: {
143
+ ecmaVersion: 2021,
144
+ sourceType: "module",
145
+ globals: {
146
+ window: "readonly",
147
+ document: "readonly",
148
+ console: "readonly",
149
+ alert: "readonly",
150
+ setTimeout: "readonly",
151
+ clearTimeout: "readonly",
152
+ setInterval: "readonly",
153
+ clearInterval: "readonly",
154
+ fetch: "readonly",
155
+ $: "readonly",
156
+ jQuery: "readonly"
157
+ }
158
+ },
159
+ rules: {
160
+ "no-unused-vars": "warn",
161
+ "no-console": "off",
162
+ "eqeqeq": "warn",
163
+ "curly": "error",
164
+ "no-eval": "error",
165
+ "no-implied-eval": "error",
166
+ "no-alert": "warn"
167
+ }
168
+ }
169
+ ];
170
+
171
+ module.exports = config;
172
+ `;
173
+
174
+ // ==========================================
175
+ // 3. SCRIPT DE VERIFICAÇÃO (COMPATÍVEL V9)
130
176
  // ==========================================
131
177
  const CONTEUDO_VERIFY_JS = `const { ESLint } = require("eslint");
132
178
  const fs = require('fs');
@@ -157,23 +203,22 @@ async function verificarCodigo() {
157
203
  const nomeArquivo = result.filePath.split('src')[1] || result.filePath;
158
204
 
159
205
  console.log(\`\\n--------------------------------------------------\`);
160
- console.log(\`⚠️ Problemas encontrados em: src\${nomeArquivo}\`);
206
+ console.log(\`⚠️ Problemas encontrados em: ...src\${nomeArquivo}\`);
161
207
  console.log(\`--------------------------------------------------\`);
162
208
 
163
209
  result.messages.forEach(msg => {
164
- console.log(\` 🔴 [Linha \${msg.line}] \${msg.message} (\${msg.ruleId})\`);
210
+ const gravidade = msg.severity === 2 ? '🔴' : '🟡';
211
+ console.log(\` \${gravidade} [Linha \${msg.line}] \${msg.message} (\${msg.ruleId})\`);
165
212
  try {
166
213
  const fileContent = fs.readFileSync(result.filePath, 'utf-8').split('\\n');
167
214
  if (fileContent[msg.line - 1]) {
168
- console.log(\` Como está: "\${fileContent[msg.line - 1].trim()}"\`);
215
+ console.log(\` Trecho: "\${fileContent[msg.line - 1].trim()}"\`);
169
216
  }
170
217
  } catch(e) {}
171
218
  });
172
219
 
173
220
  if (result.output && result.output !== result.source) {
174
- console.log(\`\\n✨ O sistema pode corrigir isso automaticamente (Formatação/Segurança/Boas Práticas).\`);
175
- console.log(\` (Isso aplicará as correções recomendadas pelo padrão do projeto)\`);
176
-
221
+ console.log(\`\\n✨ Correção automática disponível.\`);
177
222
  const resposta = await question('👉 Deseja aplicar as correções neste arquivo? (s/n): ');
178
223
 
179
224
  if (resposta.toLowerCase() === 's') {
@@ -182,8 +227,6 @@ async function verificarCodigo() {
182
227
  } else {
183
228
  console.log('⏭️ Ignorando alterações.');
184
229
  }
185
- } else {
186
- console.log('\\nℹ️ Esses erros precisam de correção manual.');
187
230
  }
188
231
  }
189
232
 
@@ -198,32 +241,7 @@ verificarCodigo().catch((error) => {
198
241
  `;
199
242
 
200
243
  // ==========================================
201
- // 3. CONFIGURAÇÃO ESLINT
202
- // ==========================================
203
- const CONTEUDO_ESLINT = `module.exports = {
204
- "env": {
205
- "browser": true,
206
- "es2021": true,
207
- "jquery": true
208
- },
209
- "extends": "eslint:recommended",
210
- "parserOptions": {
211
- "ecmaVersion": 12,
212
- "sourceType": "module"
213
- },
214
- "rules": {
215
- "no-unused-vars": "warn",
216
- "no-console": "off",
217
- "eqeqeq": "warn",
218
- "curly": "error",
219
- "no-eval": "error",
220
- "no-implied-eval": "error",
221
- "no-alert": "warn"
222
- }
223
- };`;
224
-
225
- // ==========================================
226
- // 4. TEMPLATE WEB
244
+ // 4. TEMPLATE DE BUILD (COM VERIFICAÇÃO)
227
245
  // ==========================================
228
246
  const CONTEUDO_BUILD_JS = `const fs = require('fs');
229
247
  const archiver = require('archiver');
@@ -244,14 +262,15 @@ let isBuilding = false;
244
262
  function gerarZip() {
245
263
  if (isBuilding) return;
246
264
  isBuilding = true;
247
-
265
+
248
266
  try {
249
267
  execSync('node verify.js', { stdio: 'inherit' });
250
268
  } catch (e) {
251
- console.log('❌ Build cancelado durante a verificação.');
269
+ console.log('❌ Build cancelado: Erro na verificação do código.');
252
270
  isBuilding = false;
253
271
  return;
254
272
  }
273
+ // -----------------------------
255
274
 
256
275
  console.log('📦 [Build] Compactando arquivos...');
257
276
 
@@ -290,7 +309,6 @@ if (CONFIG.MODO_AUTOMATICO) {
290
309
 
291
310
  pathsToWatch.forEach(targetPath => {
292
311
  fs.watch(targetPath, { recursive: true }, (eventType, filename) => {
293
- // Ignora o proprio zip e arquivos temporarios para evitar loop
294
312
  if (filename && !filename.includes(CONFIG.NOME_ZIP) && !filename.includes('.tmp')) {
295
313
  clearTimeout(debounceTimeout);
296
314
  debounceTimeout = setTimeout(() => {
@@ -303,6 +321,9 @@ if (CONFIG.MODO_AUTOMATICO) {
303
321
  }
304
322
  `;
305
323
 
324
+ // ==========================================
325
+ // 5. TEMPLATES ESTÁTICOS
326
+ // ==========================================
306
327
  const CONTEUDO_INDEX_JSP = `<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored ="false"%>
307
328
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
308
329
  <%@ page import="java.util.*" %>
@@ -365,9 +386,8 @@ function criarArquivo(caminho, conteudo) {
365
386
  }
366
387
 
367
388
  // ==========================================
368
- // 5. FUNÇÕES DE CRIAÇÃO
389
+ // 6. FUNÇÕES GERADORAS DE PROJETO
369
390
  // ==========================================
370
-
371
391
  function criarProjetoHTML5(raiz, nomeProjeto) {
372
392
  const pastas = [
373
393
  'src/assets/css',
@@ -384,13 +404,10 @@ function criarProjetoHTML5(raiz, nomeProjeto) {
384
404
 
385
405
  criarArquivo(path.join(raiz, 'index.jsp'), CONTEUDO_INDEX_JSP);
386
406
  criarArquivo(path.join(raiz, 'index.html'), CONTEUDO_INDEX_HTML);
387
-
388
- criarArquivo(path.join(raiz, 'build.js'), CONTEUDO_BUILD_JS);
407
+ //criarArquivo(path.join(raiz, 'build.js'), CONTEUDO_BUILD_JS);
389
408
  criarArquivo(path.join(raiz, 'commit.js'), CONTEUDO_COMMIT_JS);
390
-
391
- criarArquivo(path.join(raiz, 'verify.js'), CONTEUDO_VERIFY_JS);
392
- criarArquivo(path.join(raiz, '.eslintrc.js'), CONTEUDO_ESLINT);
393
-
409
+ criarArquivo(path.join(raiz, 'verify.js'), CONTEUDO_VERIFY_JS);
410
+ criarArquivo(path.join(raiz, 'eslint.config.js'), CONTEUDO_ESLINT);
394
411
  criarArquivo(path.join(raiz, '.gitignore'), CONTEUDO_GITIGNORE_HTML);
395
412
  criarArquivo(path.join(raiz, '.gitattributes'), CONTEUDO_GITATTRIBUTES);
396
413
  criarArquivo(path.join(raiz, 'README.md'), `# ${nomeProjeto}\n\nProjeto Web (HTML5/JSP) gerado automaticamente.`);
@@ -420,13 +437,23 @@ function criarProjetoHTML5(raiz, nomeProjeto) {
420
437
  logPasso('📄', `Tailwind copiado.`);
421
438
  }
422
439
 
440
+ const origemBuild = path.join(__dirname, 'build.js');
441
+ const destinoBuild = path.join(raiz, 'build.js');
442
+
443
+ if (fs.existsSync(origemBuild)) {
444
+ fs.copyFileSync(origemBuild, destinoBuild);
445
+ console.log('📄 Arquivo build.js (Híbrido) copiado com sucesso.');
446
+ } else {
447
+ console.error('❌ ERRO: O arquivo build.js não foi encontrado na pasta do gerador!');
448
+ criarArquivo(path.join(raiz, 'build.js'), '// ERRO: modelo-build.js não encontrado.');
449
+ }
450
+
423
451
  console.log(`\n⚙️ CONFIGURANDO AMBIENTE WEB...`);
424
452
  try {
425
453
  logPasso('Git', 'Inicializando repositório...');
426
454
  execSync('git init', { cwd: raiz, stdio: 'ignore' });
427
455
 
428
- logPasso('NPM', 'Instalando dependências (ESLint, etc)...');
429
-
456
+ logPasso('NPM', 'Instalando dependências (ESLint V9)...');
430
457
  execSync('npm install archiver eslint', { cwd: raiz, stdio: 'ignore' });
431
458
 
432
459
  } catch (e) { console.error('Erro na configuração:', e.message); }
@@ -492,7 +519,7 @@ function criarProjetoJava(raiz, nomeProjeto) {
492
519
  }
493
520
 
494
521
  // ==========================================
495
- // MENU PRINCIPAL
522
+ // 7. MENU PRINCIPAL
496
523
  // ==========================================
497
524
  function iniciar() {
498
525
  console.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-architect-cli",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+https://github.com/jtandrelevicius2/web-architect-cli.git"
17
+ "url": ""
18
18
  },
19
19
  "author": "Jeferson Tiago Alves Andrelevicius",
20
20
  "license": "ISC",
21
21
  "bugs": {
22
- "url": "https://github.com/jtandrelevicius2/web-architect-cli/issues"
22
+ "url": ""
23
23
  },
24
- "homepage": "https://github.com/jtandrelevicius2/web-architect-cli#readme"
24
+ "homepage": ""
25
25
  }