web-architect-cli 1.0.7 → 1.0.9
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 +58 -11
- package/bin/index.js +305 -113
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
# 🏗️ Web Architect CLI
|
|
4
2
|
|
|
5
3
|
O **Web Architect CLI** é uma ferramenta de linha de comando desenvolvida para padronizar e acelerar a criação de projetos no ecossistema **Sankhya**.
|
|
@@ -16,12 +14,26 @@ Com um único comando, você pode gerar:
|
|
|
16
14
|
|
|
17
15
|
Para utilizar a ferramenta em qualquer lugar do seu sistema, instale globalmente via npm:
|
|
18
16
|
|
|
19
|
-
```bashnpm
|
|
17
|
+
```bashnpm
|
|
20
18
|
npm install -g web-architect-cli@latest
|
|
21
19
|
```
|
|
22
20
|
|
|
23
21
|
**Requisito:** É necessário ter o [Node.js](https://nodejs.org/) instalado.
|
|
24
22
|
|
|
23
|
+
### ⚠️ Usuários Windows (Erro de Permissão)
|
|
24
|
+
|
|
25
|
+
O Windows bloqueia scripts por padrão. Se ao instalar ou executar o comando você receber o erro em vermelho:
|
|
26
|
+
|
|
27
|
+
> *"cannot be loaded because running scripts is disabled on this system"*
|
|
28
|
+
|
|
29
|
+
Execute o comando abaixo no seu terminal **antes** de usar a ferramenta. Isso libera o uso de scripts **apenas nesta janela** (seguro):
|
|
30
|
+
|
|
31
|
+
PowerShell
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Set-ExecutionPolicy Bypass -Scope Process
|
|
35
|
+
```
|
|
36
|
+
|
|
25
37
|
## 🚀 Como Utilizar
|
|
26
38
|
|
|
27
39
|
Abra o terminal na pasta onde deseja criar o projeto e execute:
|
|
@@ -141,8 +153,6 @@ meu-evento-java/
|
|
|
141
153
|
|
|
142
154
|
## 💡 Casos de Uso (Workflows)
|
|
143
155
|
|
|
144
|
-
|
|
145
|
-
|
|
146
156
|
Aqui estão os cenários comuns onde o **Web Architect CLI** brilha:
|
|
147
157
|
|
|
148
158
|
### Caso A: Início Rápido de Dashboards (HTML/JSP)
|
|
@@ -191,13 +201,50 @@ Ao usar o comando `web-arch`, todos os projetos seguem a mesma árvore:
|
|
|
191
201
|
|
|
192
202
|
Isso facilita a manutenção cruzada: qualquer desenvolvedor sabe onde encontrar o código.
|
|
193
203
|
|
|
194
|
-
## 🛠 Comandos do Projeto (Scripts)
|
|
195
204
|
|
|
196
|
-
Dentro da pasta do projeto criado, você pode usar:
|
|
197
205
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
| `npm run build` | Gera o ZIP apenas uma vez e encerra. |
|
|
206
|
+
## 🤖 Assistente de Commit (Git)
|
|
207
|
+
|
|
208
|
+
Todos os projetos gerados (Web, Banco ou Java) já vêm configurados com um script de **Commit Semântico**. Isso garante que o histórico do seu projeto fique padronizado e profissional.
|
|
202
209
|
|
|
203
210
|
|
|
211
|
+
|
|
212
|
+
**Como usar:** Em vez de digitar os comandos do Git manualmente, basta rodar na raiz do projeto:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
npm run commit
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**O assistente interativo irá:**
|
|
219
|
+
|
|
220
|
+
1. Perguntar o **tipo** de alteração:
|
|
221
|
+
|
|
222
|
+
- `feat`: Nova funcionalidade.
|
|
223
|
+
|
|
224
|
+
- `fix`: Correção de bugs.
|
|
225
|
+
|
|
226
|
+
- `docs`: Alteração em documentação.
|
|
227
|
+
|
|
228
|
+
- `style`: Formatação, CSS, espaços.
|
|
229
|
+
|
|
230
|
+
- `refactor`: Melhoria de código sem mudar funcionalidade.
|
|
231
|
+
|
|
232
|
+
- `chore`: Alterações de build, configs, etc.
|
|
233
|
+
|
|
234
|
+
2. Pedir a **mensagem** do commit.
|
|
235
|
+
|
|
236
|
+
3. Executar automaticamente `git add .` e `git commit -m "tipo: mensagem"`.
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
## 🛠 Comandos do Projeto (Scripts)
|
|
243
|
+
|
|
244
|
+
Dentro da pasta do projeto criado, você pode usar:
|
|
245
|
+
|
|
246
|
+
| Comando | Ação |
|
|
247
|
+
|:---------------- |:-------------------------------------------------------------------------- |
|
|
248
|
+
| `npm run commit` | **(Todos)** Abre o assistente para realizar commits padronizados. |
|
|
249
|
+
| `npm start` | **(Web)** Inicia o modo Watch. Altera arquivo -> Gera ZIP automaticamente. |
|
|
250
|
+
| `npm run build` | **(Web)** Gera o ZIP do projeto uma única vez e encerra. |
|
package/bin/index.js
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
if (process.platform === "win32") {
|
|
4
4
|
try {
|
|
5
5
|
require("child_process").execSync("chcp 65001", { stdio: 'ignore' });
|
|
6
|
-
} catch (e) {
|
|
7
|
-
|
|
8
|
-
}
|
|
6
|
+
} catch (e) {}
|
|
9
7
|
}
|
|
8
|
+
|
|
10
9
|
const fs = require('fs');
|
|
11
10
|
const path = require('path');
|
|
12
11
|
const { execSync } = require('child_process');
|
|
@@ -18,54 +17,218 @@ const rl = readline.createInterface({
|
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
// ==========================================
|
|
21
|
-
//
|
|
20
|
+
// 1. SCRIPT DE COMMIT INTELIGENTE
|
|
22
21
|
// ==========================================
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
<%@ page import="java.util.*" %>
|
|
26
|
-
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
|
|
27
|
-
<%@ taglib prefix="snk" uri="/WEB-INF/tld/sankhyaUtil.tld" %>
|
|
28
|
-
<html>
|
|
29
|
-
<head>
|
|
30
|
-
<meta charset="UTF-8">
|
|
31
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
32
|
-
<title>Meu modelo</title>
|
|
33
|
-
<script src="\${BASE_FOLDER}/src/assets/js/tailwindcss.js"></script>
|
|
34
|
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
35
|
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
|
|
36
|
-
<link rel="stylesheet" href="\${BASE_FOLDER}/src/assets/css/style.css">
|
|
22
|
+
const CONTEUDO_COMMIT_JS = `const { execSync } = require('child_process');
|
|
23
|
+
const readline = require('readline');
|
|
37
24
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<header class="header"></header>
|
|
43
|
-
<main class="main"></main>
|
|
44
|
-
<script type="module" src="\${BASE_FOLDER}/src/main.js"></script>
|
|
45
|
-
</body>
|
|
46
|
-
</html>`;
|
|
25
|
+
const rl = readline.createInterface({
|
|
26
|
+
input: process.stdin,
|
|
27
|
+
output: process.stdout
|
|
28
|
+
});
|
|
47
29
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
30
|
+
console.clear();
|
|
31
|
+
console.log('=============================================');
|
|
32
|
+
console.log(' 🤖 SMART COMMIT - ANÁLISE DINÂMICA');
|
|
33
|
+
console.log('=============================================');
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const statusOutput = execSync('git status --porcelain').toString();
|
|
37
|
+
|
|
38
|
+
if (!statusOutput.trim()) {
|
|
39
|
+
console.log('⚠️ Nenhuma alteração detectada para commitar.');
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const linhas = statusOutput.split('\\n').filter(l => l.trim());
|
|
44
|
+
const arquivos = linhas.map(l => {
|
|
45
|
+
const tipo = l.substring(0, 2).trim();
|
|
46
|
+
const arquivo = l.substring(3).trim();
|
|
47
|
+
return { tipo, arquivo };
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const qtd = arquivos.length;
|
|
51
|
+
const nomesArquivos = arquivos.map(a => a.arquivo).join(', ');
|
|
52
|
+
|
|
53
|
+
let tituloSugerido = '';
|
|
54
|
+
let corpoSugerido = '';
|
|
55
|
+
|
|
56
|
+
if (qtd === 1) {
|
|
57
|
+
tituloSugerido = \`altera \${arquivos[0].arquivo}\`;
|
|
58
|
+
} else if (qtd <= 3) {
|
|
59
|
+
tituloSugerido = \`altera \${nomesArquivos}\`;
|
|
60
|
+
} else {
|
|
61
|
+
tituloSugerido = \`atualiza \${qtd} arquivos do projeto\`;
|
|
62
|
+
corpoSugerido = arquivos.map(a => \`- [\${a.tipo}] \${a.arquivo}\`).join('\\n');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.log(\`\\n📂 Alterações detectadas: \${qtd} arquivo(s)\`);
|
|
66
|
+
arquivos.forEach(a => console.log(\` \${a.tipo === '??' ? '➕' : '📝'} \${a.arquivo}\`));
|
|
67
|
+
console.log('---------------------------------------------');
|
|
68
|
+
|
|
69
|
+
console.log('Escolha o tipo de alteração:');
|
|
70
|
+
console.log(' [1] feat (Nova funcionalidade)');
|
|
71
|
+
console.log(' [2] fix (Correção de bug)');
|
|
72
|
+
console.log(' [3] style (Visual/Formatação)');
|
|
73
|
+
console.log(' [4] refactor (Melhoria de código)');
|
|
74
|
+
console.log(' [5] chore (Configs/Build)');
|
|
75
|
+
|
|
76
|
+
rl.question('\\n👉 Tipo (1-5): ', (tipoOpcao) => {
|
|
77
|
+
const mapTipos = { '1': 'feat', '2': 'fix', '3': 'style', '4': 'refactor', '5': 'chore' };
|
|
78
|
+
const tipo = mapTipos[tipoOpcao.trim()] || 'feat';
|
|
79
|
+
|
|
80
|
+
console.log('\\n---------------------------------------------');
|
|
81
|
+
console.log('📝 OPÇÕES DE MENSAGEM:');
|
|
82
|
+
console.log(\` [1] Automática (Resumida): "\${tipo}: \${tituloSugerido}"\`);
|
|
83
|
+
|
|
84
|
+
if (corpoSugerido) {
|
|
85
|
+
console.log(\` [2] Automática (Detalhada): "\${tipo}: \${tituloSugerido} (+ lista de arquivos na descrição)"\`);
|
|
86
|
+
} else {
|
|
87
|
+
console.log(\` [2] (Opção igual a 1 pois são poucos arquivos)\`);
|
|
88
|
+
}
|
|
89
|
+
console.log(' [3] Manual (Digitar sua própria mensagem)');
|
|
90
|
+
|
|
91
|
+
rl.question('\\n👉 Escolha (1-3): ', (msgOpcao) => {
|
|
92
|
+
if (msgOpcao.trim() === '3') {
|
|
93
|
+
rl.question('✍️ Digite a mensagem: ', (manualMsg) => {
|
|
94
|
+
executarCommit(tipo, manualMsg, '');
|
|
95
|
+
});
|
|
96
|
+
} else if (msgOpcao.trim() === '2' && corpoSugerido) {
|
|
97
|
+
executarCommit(tipo, tituloSugerido, corpoSugerido);
|
|
98
|
+
} else {
|
|
99
|
+
executarCommit(tipo, tituloSugerido, '');
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
} catch (e) {
|
|
105
|
+
console.error('Erro ao ler status do git:', e.message);
|
|
106
|
+
rl.close();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function executarCommit(tipo, titulo, corpo) {
|
|
110
|
+
const msgFinal = \`\${tipo}: \${titulo}\`;
|
|
111
|
+
console.log('\\n⏳ Executando git add .');
|
|
112
|
+
execSync('git add .');
|
|
113
|
+
console.log(\`⏳ Commitando: "\${msgFinal}"\`);
|
|
114
|
+
try {
|
|
115
|
+
if (corpo) {
|
|
116
|
+
execSync(\`git commit -m "\${msgFinal}" -m "\${corpo}"\`, { stdio: 'inherit' });
|
|
117
|
+
} else {
|
|
118
|
+
execSync(\`git commit -m "\${msgFinal}"\`, { stdio: 'inherit' });
|
|
119
|
+
}
|
|
120
|
+
console.log('✅ Commit realizado com sucesso!');
|
|
121
|
+
} catch (err) {
|
|
122
|
+
console.error('❌ Erro no commit.');
|
|
123
|
+
}
|
|
124
|
+
rl.close();
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
// ==========================================
|
|
129
|
+
// 2. SCRIPT DE VERIFICAÇÃO INTERATIVA (NOVO)
|
|
130
|
+
// ==========================================
|
|
131
|
+
const CONTEUDO_VERIFY_JS = `const { ESLint } = require("eslint");
|
|
132
|
+
const fs = require('fs');
|
|
133
|
+
const readline = require('readline');
|
|
65
134
|
|
|
135
|
+
async function verificarCodigo() {
|
|
136
|
+
console.log('\\n🔎 [Check] Iniciando análise de código e segurança...');
|
|
137
|
+
|
|
138
|
+
const eslint = new ESLint({ fix: true });
|
|
139
|
+
|
|
140
|
+
const results = await eslint.lintFiles(["src/**/*.js"]);
|
|
141
|
+
|
|
142
|
+
const arquivosComProblemas = results.filter(r => r.messages.length > 0);
|
|
143
|
+
|
|
144
|
+
if (arquivosComProblemas.length === 0) {
|
|
145
|
+
console.log('✅ [Check] Nenhum problema encontrado. Código limpo!');
|
|
146
|
+
process.exit(0);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const rl = readline.createInterface({
|
|
150
|
+
input: process.stdin,
|
|
151
|
+
output: process.stdout
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const question = (str) => new Promise(resolve => rl.question(str, resolve));
|
|
155
|
+
|
|
156
|
+
for (const result of arquivosComProblemas) {
|
|
157
|
+
const nomeArquivo = result.filePath.split('src')[1] || result.filePath;
|
|
158
|
+
|
|
159
|
+
console.log(\`\\n--------------------------------------------------\`);
|
|
160
|
+
console.log(\`⚠️ Problemas encontrados em: src\${nomeArquivo}\`);
|
|
161
|
+
console.log(\`--------------------------------------------------\`);
|
|
162
|
+
|
|
163
|
+
result.messages.forEach(msg => {
|
|
164
|
+
console.log(\` 🔴 [Linha \${msg.line}] \${msg.message} (\${msg.ruleId})\`);
|
|
165
|
+
try {
|
|
166
|
+
const fileContent = fs.readFileSync(result.filePath, 'utf-8').split('\\n');
|
|
167
|
+
if (fileContent[msg.line - 1]) {
|
|
168
|
+
console.log(\` Como está: "\${fileContent[msg.line - 1].trim()}"\`);
|
|
169
|
+
}
|
|
170
|
+
} catch(e) {}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
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
|
+
|
|
177
|
+
const resposta = await question('👉 Deseja aplicar as correções neste arquivo? (s/n): ');
|
|
178
|
+
|
|
179
|
+
if (resposta.toLowerCase() === 's') {
|
|
180
|
+
await ESLint.outputFixes([result]);
|
|
181
|
+
console.log('✅ Correções aplicadas!');
|
|
182
|
+
} else {
|
|
183
|
+
console.log('⏭️ Ignorando alterações.');
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
console.log('\\nℹ️ Esses erros precisam de correção manual.');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
console.log('\\n🏁 Verificação concluída.');
|
|
191
|
+
rl.close();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
verificarCodigo().catch((error) => {
|
|
195
|
+
console.error('Erro na verificação:', error);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
});
|
|
198
|
+
`;
|
|
199
|
+
|
|
200
|
+
// ==========================================
|
|
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
|
|
227
|
+
// ==========================================
|
|
66
228
|
const CONTEUDO_BUILD_JS = `const fs = require('fs');
|
|
67
229
|
const archiver = require('archiver');
|
|
68
230
|
const path = require('path');
|
|
231
|
+
const { execSync } = require('child_process');
|
|
69
232
|
|
|
70
233
|
const CONFIG = {
|
|
71
234
|
MODO_AUTOMATICO: true,
|
|
@@ -81,6 +244,15 @@ let isBuilding = false;
|
|
|
81
244
|
function gerarZip() {
|
|
82
245
|
if (isBuilding) return;
|
|
83
246
|
isBuilding = true;
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
execSync('node verify.js', { stdio: 'inherit' });
|
|
250
|
+
} catch (e) {
|
|
251
|
+
console.log('❌ Build cancelado durante a verificação.');
|
|
252
|
+
isBuilding = false;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
84
256
|
console.log('📦 [Build] Compactando arquivos...');
|
|
85
257
|
|
|
86
258
|
const output = fs.createWriteStream(path.join(__dirname, CONFIG.NOME_ZIP));
|
|
@@ -118,7 +290,8 @@ if (CONFIG.MODO_AUTOMATICO) {
|
|
|
118
290
|
|
|
119
291
|
pathsToWatch.forEach(targetPath => {
|
|
120
292
|
fs.watch(targetPath, { recursive: true }, (eventType, filename) => {
|
|
121
|
-
|
|
293
|
+
// Ignora o proprio zip e arquivos temporarios para evitar loop
|
|
294
|
+
if (filename && !filename.includes(CONFIG.NOME_ZIP) && !filename.includes('.tmp')) {
|
|
122
295
|
clearTimeout(debounceTimeout);
|
|
123
296
|
debounceTimeout = setTimeout(() => {
|
|
124
297
|
console.log(\`📝 Alteração detectada: \${filename}\`);
|
|
@@ -130,12 +303,51 @@ if (CONFIG.MODO_AUTOMATICO) {
|
|
|
130
303
|
}
|
|
131
304
|
`;
|
|
132
305
|
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
|
|
306
|
+
const CONTEUDO_INDEX_JSP = `<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored ="false"%>
|
|
307
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
308
|
+
<%@ page import="java.util.*" %>
|
|
309
|
+
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
|
|
310
|
+
<%@ taglib prefix="snk" uri="/WEB-INF/tld/sankhyaUtil.tld" %>
|
|
311
|
+
<html>
|
|
312
|
+
<head>
|
|
313
|
+
<meta charset="UTF-8">
|
|
314
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
315
|
+
<title>Meu modelo</title>
|
|
316
|
+
<script src="\${BASE_FOLDER}/src/assets/js/tailwindcss.js"></script>
|
|
317
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
318
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
|
|
319
|
+
<link rel="stylesheet" href="\${BASE_FOLDER}/src/assets/css/style.css">
|
|
320
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@jtandrelevicius/utils-js-library@latest/index.js"></script>
|
|
321
|
+
<snk:load/>
|
|
322
|
+
</head>
|
|
323
|
+
<body>
|
|
324
|
+
<header class="header"></header>
|
|
325
|
+
<main class="main"></main>
|
|
326
|
+
<script type="module" src="\${BASE_FOLDER}/src/main.js"></script>
|
|
327
|
+
</body>
|
|
328
|
+
</html>`;
|
|
329
|
+
|
|
330
|
+
const CONTEUDO_INDEX_HTML = `<!DOCTYPE html>
|
|
331
|
+
<html lang="pt-BR">
|
|
332
|
+
<head>
|
|
333
|
+
<meta charset="UTF-8">
|
|
334
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
335
|
+
<title>Meu modelo</title>
|
|
336
|
+
<script src="src/assets/js/tailwindcss.js"></script>
|
|
337
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
338
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
|
|
339
|
+
<link rel="stylesheet" href="./src/assets/css/style.css">
|
|
340
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@jtandrelevicius/utils-js-library@latest/index.js"></script>
|
|
341
|
+
<body>
|
|
342
|
+
<header class="header"></header>
|
|
343
|
+
<main class="main"></main>
|
|
344
|
+
<script type="module" src="src/main.js"></script>
|
|
345
|
+
</body>
|
|
346
|
+
</html>`;
|
|
347
|
+
|
|
136
348
|
const CONTEUDO_GITIGNORE_HTML = `node_modules/\n*.zip\n.DS_Store\n`;
|
|
137
|
-
const CONTEUDO_GITIGNORE_GERAL =
|
|
138
|
-
const CONTEUDO_GITIGNORE_JAVA = `
|
|
349
|
+
const CONTEUDO_GITIGNORE_GERAL = `node_modules/\n*.zip\n.DS_Store\n`;
|
|
350
|
+
const CONTEUDO_GITIGNORE_JAVA = `node_modules/\nout/\n.idea/workspace.xml\n.idea/usage.statistics.xml\n*.iws\n.DS_Store\n`;
|
|
139
351
|
const CONTEUDO_GITATTRIBUTES = `* text=auto`;
|
|
140
352
|
|
|
141
353
|
const logPasso = (emoji, msg) => console.log(`${emoji} ${msg}`);
|
|
@@ -153,10 +365,9 @@ function criarArquivo(caminho, conteudo) {
|
|
|
153
365
|
}
|
|
154
366
|
|
|
155
367
|
// ==========================================
|
|
156
|
-
// FUNÇÕES DE CRIAÇÃO
|
|
368
|
+
// 5. FUNÇÕES DE CRIAÇÃO
|
|
157
369
|
// ==========================================
|
|
158
370
|
|
|
159
|
-
// --- MODELO 1: HTML5 (Web) ---
|
|
160
371
|
function criarProjetoHTML5(raiz, nomeProjeto) {
|
|
161
372
|
const pastas = [
|
|
162
373
|
'src/assets/css',
|
|
@@ -173,7 +384,13 @@ function criarProjetoHTML5(raiz, nomeProjeto) {
|
|
|
173
384
|
|
|
174
385
|
criarArquivo(path.join(raiz, 'index.jsp'), CONTEUDO_INDEX_JSP);
|
|
175
386
|
criarArquivo(path.join(raiz, 'index.html'), CONTEUDO_INDEX_HTML);
|
|
387
|
+
|
|
176
388
|
criarArquivo(path.join(raiz, 'build.js'), CONTEUDO_BUILD_JS);
|
|
389
|
+
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
|
+
|
|
177
394
|
criarArquivo(path.join(raiz, '.gitignore'), CONTEUDO_GITIGNORE_HTML);
|
|
178
395
|
criarArquivo(path.join(raiz, '.gitattributes'), CONTEUDO_GITATTRIBUTES);
|
|
179
396
|
criarArquivo(path.join(raiz, 'README.md'), `# ${nomeProjeto}\n\nProjeto Web (HTML5/JSP) gerado automaticamente.`);
|
|
@@ -183,7 +400,12 @@ function criarProjetoHTML5(raiz, nomeProjeto) {
|
|
|
183
400
|
version: "1.0.0",
|
|
184
401
|
description: "",
|
|
185
402
|
main: "src/main.js",
|
|
186
|
-
scripts: {
|
|
403
|
+
scripts: {
|
|
404
|
+
"build": "node build.js",
|
|
405
|
+
"start": "node build.js",
|
|
406
|
+
"commit": "node commit.js",
|
|
407
|
+
"check": "node verify.js"
|
|
408
|
+
},
|
|
187
409
|
author: "",
|
|
188
410
|
license: "ISC"
|
|
189
411
|
};
|
|
@@ -202,30 +424,29 @@ function criarProjetoHTML5(raiz, nomeProjeto) {
|
|
|
202
424
|
try {
|
|
203
425
|
logPasso('Git', 'Inicializando repositório...');
|
|
204
426
|
execSync('git init', { cwd: raiz, stdio: 'ignore' });
|
|
205
|
-
|
|
206
|
-
|
|
427
|
+
|
|
428
|
+
logPasso('NPM', 'Instalando dependências (ESLint, etc)...');
|
|
429
|
+
|
|
430
|
+
execSync('npm install archiver eslint', { cwd: raiz, stdio: 'ignore' });
|
|
431
|
+
|
|
207
432
|
} catch (e) { console.error('Erro na configuração:', e.message); }
|
|
208
433
|
}
|
|
209
434
|
|
|
210
|
-
// --- MODELO 2: PERSONALIZACAO (Banco/Backend) ---
|
|
211
435
|
function criarProjetoPersonalizacao(raiz, nomeProjeto) {
|
|
212
|
-
const pastas = [
|
|
213
|
-
'doc',
|
|
214
|
-
'src/Dashboard',
|
|
215
|
-
'src/Function',
|
|
216
|
-
'src/Procedure',
|
|
217
|
-
'src/Relatorio',
|
|
218
|
-
'src/SQL',
|
|
219
|
-
'src/Tela',
|
|
220
|
-
'src/Trigger',
|
|
221
|
-
'src/View'
|
|
222
|
-
];
|
|
223
|
-
|
|
436
|
+
const pastas = ['doc','src/Dashboard','src/Function','src/Procedure','src/Relatorio','src/SQL','src/Tela','src/Trigger','src/View'];
|
|
224
437
|
pastas.forEach(p => criarPasta(path.join(raiz, p)));
|
|
225
438
|
|
|
439
|
+
criarArquivo(path.join(raiz, 'commit.js'), CONTEUDO_COMMIT_JS);
|
|
226
440
|
criarArquivo(path.join(raiz, '.gitattributes'), CONTEUDO_GITATTRIBUTES);
|
|
227
441
|
criarArquivo(path.join(raiz, '.gitignore'), CONTEUDO_GITIGNORE_GERAL);
|
|
228
|
-
criarArquivo(path.join(raiz, 'README.md'), `# ${nomeProjeto}\n\nProjeto de Personalização (Banco de Dados/PLSQL)
|
|
442
|
+
criarArquivo(path.join(raiz, 'README.md'), `# ${nomeProjeto}\n\nProjeto de Personalização (Banco de Dados/PLSQL).`);
|
|
443
|
+
|
|
444
|
+
const packageJson = {
|
|
445
|
+
name: nomeProjeto,
|
|
446
|
+
version: "1.0.0",
|
|
447
|
+
scripts: { "commit": "node commit.js" }
|
|
448
|
+
};
|
|
449
|
+
criarArquivo(path.join(raiz, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
229
450
|
|
|
230
451
|
console.log(`\n⚙️ CONFIGURANDO AMBIENTE DE PERSONALIZAÇÃO...`);
|
|
231
452
|
try {
|
|
@@ -234,66 +455,39 @@ function criarProjetoPersonalizacao(raiz, nomeProjeto) {
|
|
|
234
455
|
} catch (e) { console.error('Erro no git init:', e.message); }
|
|
235
456
|
}
|
|
236
457
|
|
|
237
|
-
// --- MODELO 3: JAVA (Estrutura IntelliJ Nativa) ---
|
|
238
458
|
function criarProjetoJava(raiz, nomeProjeto) {
|
|
239
459
|
const nomePacote = nomeProjeto.replace(/-/g, '').toLowerCase();
|
|
240
460
|
const basePath = `src/br/com/sankhya/${nomePacote}`;
|
|
241
|
-
|
|
242
|
-
const pastas = [
|
|
243
|
-
'.idea',
|
|
244
|
-
'doc',
|
|
245
|
-
'out',
|
|
246
|
-
`${basePath}/business/agendador`,
|
|
247
|
-
`${basePath}/business/botao`,
|
|
248
|
-
`${basePath}/business/evento`,
|
|
249
|
-
`${basePath}/business/regra`,
|
|
250
|
-
`${basePath}/domain/model`,
|
|
251
|
-
`${basePath}/domain/repository`
|
|
252
|
-
];
|
|
461
|
+
const pastas = ['.idea','doc','out',`${basePath}/business/agendador`,`${basePath}/business/botao`,`${basePath}/business/evento`,`${basePath}/business/regra`,`${basePath}/domain/model`,`${basePath}/domain/repository`];
|
|
253
462
|
|
|
254
463
|
pastas.forEach(p => criarPasta(path.join(raiz, p)));
|
|
255
464
|
|
|
465
|
+
criarArquivo(path.join(raiz, 'commit.js'), CONTEUDO_COMMIT_JS);
|
|
256
466
|
criarArquivo(path.join(raiz, '.gitignore'), CONTEUDO_GITIGNORE_JAVA);
|
|
257
467
|
criarArquivo(path.join(raiz, 'README.md'), `# ${nomeProjeto}\n\nProjeto Java Sankhya (IntelliJ Nativo).`);
|
|
258
468
|
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
469
|
+
const packageJson = {
|
|
470
|
+
name: nomeProjeto,
|
|
471
|
+
version: "1.0.0",
|
|
472
|
+
scripts: { "commit": "node commit.js" }
|
|
473
|
+
};
|
|
474
|
+
criarArquivo(path.join(raiz, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
475
|
+
|
|
476
|
+
const modulesXml = `<?xml version="1.0" encoding="UTF-8"?><project version="4"><component name="ProjectModuleManager"><modules><module fileurl="file://$PROJECT_DIR$/${nomeProjeto}.iml" filepath="$PROJECT_DIR$/${nomeProjeto}.iml" /></modules></component></project>`;
|
|
267
477
|
criarArquivo(path.join(raiz, '.idea/modules.xml'), modulesXml);
|
|
268
478
|
|
|
269
|
-
const miscXml = `<?xml version="1.0" encoding="UTF-8"
|
|
270
|
-
<project version="4">
|
|
271
|
-
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
|
272
|
-
<output url="file://$PROJECT_DIR$/out" />
|
|
273
|
-
</component>
|
|
274
|
-
</project>`;
|
|
479
|
+
const miscXml = `<?xml version="1.0" encoding="UTF-8"?><project version="4"><component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"><output url="file://$PROJECT_DIR$/out" /></component></project>`;
|
|
275
480
|
criarArquivo(path.join(raiz, '.idea/misc.xml'), miscXml);
|
|
276
481
|
|
|
277
|
-
const imlContent = `<?xml version="1.0" encoding="UTF-8"
|
|
278
|
-
<module type="JAVA_MODULE" version="4">
|
|
279
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
280
|
-
<exclude-output />
|
|
281
|
-
<content url="file://$MODULE_DIR$">
|
|
282
|
-
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
283
|
-
</content>
|
|
284
|
-
<orderEntry type="inheritedJdk" />
|
|
285
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
286
|
-
<orderEntry type="library" name="libs-java" level="application" />
|
|
287
|
-
</component>
|
|
288
|
-
</module>`;
|
|
482
|
+
const imlContent = `<?xml version="1.0" encoding="UTF-8"?><module type="JAVA_MODULE" version="4"><component name="NewModuleRootManager" inherit-compiler-output="true"><exclude-output /><content url="file://$MODULE_DIR$"><sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /></content><orderEntry type="inheritedJdk" /><orderEntry type="sourceFolder" forTests="false" /><orderEntry type="library" name="libs-java" level="application" /></component></module>`;
|
|
289
483
|
criarArquivo(path.join(raiz, `${nomeProjeto}.iml`), imlContent);
|
|
290
484
|
|
|
291
485
|
console.log(`\n⚙️ CONFIGURANDO AMBIENTE JAVA (IntelliJ)...`);
|
|
292
486
|
try {
|
|
293
487
|
logPasso('Git', 'Inicializando repositório...');
|
|
294
488
|
execSync('git init', { cwd: raiz, stdio: 'inherit' });
|
|
295
|
-
console.log(`\n✅ SUCESSO
|
|
296
|
-
console.log(`ℹ️
|
|
489
|
+
console.log(`\n✅ SUCESSO!`);
|
|
490
|
+
console.log(`ℹ️ Para commitar, use: npm run commit`);
|
|
297
491
|
} catch (e) { console.error(e.message); }
|
|
298
492
|
}
|
|
299
493
|
|
|
@@ -312,7 +506,6 @@ function iniciar() {
|
|
|
312
506
|
console.log('===================================================');
|
|
313
507
|
|
|
314
508
|
rl.question('👉 Escolha uma opção (1-3): ', (opcao) => {
|
|
315
|
-
|
|
316
509
|
if (!['1', '2', '3'].includes(opcao.trim())) {
|
|
317
510
|
console.log('❌ Opção inválida.');
|
|
318
511
|
rl.close();
|
|
@@ -346,10 +539,9 @@ function iniciar() {
|
|
|
346
539
|
break;
|
|
347
540
|
case '3':
|
|
348
541
|
criarProjetoJava(raiz, nomeProjeto);
|
|
349
|
-
console.log(`\n✅ PROJETO JAVA CRIADO
|
|
542
|
+
console.log(`\n✅ PROJETO JAVA CRIADO! Rode 'cd ${nomeProjeto}'.`);
|
|
350
543
|
break;
|
|
351
544
|
}
|
|
352
|
-
|
|
353
545
|
rl.close();
|
|
354
546
|
});
|
|
355
547
|
});
|