@acropole/skills 0.0.0-stage → 1.0.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.
- package/README.md +180 -2
- package/agents/revisor-deploy.md +73 -0
- package/agents/revisor-documentacao.md +78 -0
- package/agents/revisor-orfeu.md +80 -0
- package/agents/revisor-trismegisto.md +81 -0
- package/bin/install.js +252 -0
- package/package.json +15 -4
- package/skills/acropole/SKILL.md +75 -0
- package/skills/acropole/references/fluxos/doctor.md +55 -0
- package/skills/acropole/references/fluxos/endpoint-novo.md +22 -0
- package/skills/acropole/references/fluxos/revisar.md +56 -0
- package/skills/acropole/references/fluxos/tela-nova.md +27 -0
- package/skills/acropole/scripts/doctor.mjs +439 -0
- package/skills/angular/SKILL.md +152 -0
- package/skills/angular/references/armadilhas.md +95 -0
- package/skills/angular/references/dados.md +251 -0
- package/skills/angular/references/estrutura.md +260 -0
- package/skills/angular/references/features.md +219 -0
- package/skills/angular/references/testes-build.md +230 -0
- package/skills/angular/scripts/checar.mjs +182 -0
- package/skills/angular/scripts/nucleo.mjs +227 -0
- package/skills/apollo/SKILL.md +222 -0
- package/skills/apollo/references/armadilhas.md +95 -0
- package/skills/apollo/references/envelope-erros.md +120 -0
- package/skills/apollo/references/estrutura-bootstrap.md +299 -0
- package/skills/apollo/references/schema-resolvers.md +183 -0
- package/skills/apollo/references/subscriptions.md +224 -0
- package/skills/apollo/references/testes-build.md +180 -0
- package/skills/apollo/scripts/checar.mjs +160 -0
- package/skills/apollo/scripts/nucleo.mjs +227 -0
- package/skills/docker/SKILL.md +102 -0
- package/skills/docker/references/modelos.md +251 -0
- package/skills/docker/references/porques.md +282 -0
- package/skills/documentacao/SKILL.md +146 -0
- package/skills/documentacao/references/checklist-coerencia.md +59 -0
- package/skills/documentacao/references/ligar-app-novo.md +107 -0
- package/skills/documentacao/references/modelo-especificacao.md +51 -0
- package/skills/documentacao/references/modelo-readme.md +75 -0
- package/skills/documentacao/scripts/checar.mjs +454 -0
- package/skills/documentacao/scripts/nucleo.mjs +227 -0
- package/skills/express/SKILL.md +154 -0
- package/skills/express/references/dados.md +180 -0
- package/skills/express/references/estrutura.md +154 -0
- package/skills/express/references/middlewares.md +227 -0
- package/skills/express/references/rotas-erros.md +274 -0
- package/skills/express/references/testes-deploy.md +150 -0
- package/skills/express/scripts/checar.mjs +115 -0
- package/skills/express/scripts/nucleo.mjs +227 -0
- package/skills/fastapi/SKILL.md +129 -0
- package/skills/fastapi/references/banco.md +185 -0
- package/skills/fastapi/references/estrutura.md +281 -0
- package/skills/fastapi/references/integracoes.md +145 -0
- package/skills/fastapi/references/rotas-erros.md +140 -0
- package/skills/fastapi/references/testes-deploy.md +190 -0
- package/skills/fastapi/scripts/checar.mjs +108 -0
- package/skills/fastapi/scripts/nucleo.mjs +227 -0
- package/skills/hefesto/SKILL.md +119 -0
- package/skills/hefesto/references/conceitos.md +131 -0
- package/skills/hefesto/references/diagnostico.md +70 -0
- package/skills/hefesto/references/fluxo.md +122 -0
- package/skills/hefesto/references/preparar-app.md +105 -0
- package/skills/orfeu/SKILL.md +162 -0
- package/skills/orfeu/references/angular-api.md +201 -0
- package/skills/orfeu/references/angular-armadilhas.md +116 -0
- package/skills/orfeu/references/angular-recipes.md +474 -0
- package/skills/orfeu/references/angular.md +212 -0
- package/skills/orfeu/references/diferencas.md +56 -0
- package/skills/orfeu/references/node-api.md +348 -0
- package/skills/orfeu/references/node-armadilhas.md +158 -0
- package/skills/orfeu/references/node-recipes.md +534 -0
- package/skills/orfeu/references/node.md +204 -0
- package/skills/orfeu/references/python-api.md +346 -0
- package/skills/orfeu/references/python-recipes.md +479 -0
- package/skills/orfeu/references/python.md +234 -0
- package/skills/orfeu/scripts/checar.mjs +126 -0
- package/skills/orfeu/scripts/nucleo.mjs +227 -0
- package/skills/trismegisto/SKILL.md +194 -0
- package/skills/trismegisto/references/angular-api.md +2788 -0
- package/skills/trismegisto/references/angular-exports.md +4020 -0
- package/skills/trismegisto/references/angular-recipes.md +1883 -0
- package/skills/trismegisto/references/angular-types.md +492 -0
- package/skills/trismegisto/references/angular.md +390 -0
- package/skills/trismegisto/references/catalogo/icones.json +912 -0
- package/skills/trismegisto/references/catalogo/seletores.json +7013 -0
- package/skills/trismegisto/references/catalogo/tokens.json +240 -0
- package/skills/trismegisto/references/spine-api.md +1530 -0
- package/skills/trismegisto/references/spine-recipes.md +581 -0
- package/skills/trismegisto/references/spine.md +343 -0
- package/skills/trismegisto/scripts/checar.mjs +216 -0
- package/skills/trismegisto/scripts/nucleo.mjs +227 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Diagnóstico de configuração de um projeto da plataforma (skill `acropole`, fluxo doctor).
|
|
3
|
+
// Node >= 18, sem dependências, sem rede. Só lê arquivos de manifesto/config/código.
|
|
4
|
+
// Severidades: `corrige` (o ajuste é um só e não muda comportamento além do pretendido; --fix aplica),
|
|
5
|
+
// `avisa` (o usuário decide versão/instalação) e `pergunta` (precisa de revisão com contexto antes de mexer).
|
|
6
|
+
// Nunca lê .env/.npmrc (só verifica se existem).
|
|
7
|
+
//
|
|
8
|
+
// Uso: node doctor.mjs [pasta] [--json] [--fix]
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
|
|
12
|
+
const argv = process.argv.slice(2);
|
|
13
|
+
const asJson = argv.includes('--json');
|
|
14
|
+
const doFix = argv.includes('--fix');
|
|
15
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
16
|
+
console.log('Uso: node doctor.mjs [pasta] [--json] [--fix]\n\n' +
|
|
17
|
+
' [pasta] raiz a diagnosticar (padrão: diretório atual; varre até 4 níveis)\n' +
|
|
18
|
+
' --json saída em JSON ({ root, findings, fixed })\n' +
|
|
19
|
+
' --fix aplica só os achados de severidade "corrige"');
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
const root = path.resolve(argv.find((a) => !a.startsWith('--')) ?? '.');
|
|
23
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {
|
|
24
|
+
console.error(`doctor: pasta não encontrada: ${root}`);
|
|
25
|
+
process.exit(2);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const IGNORE = new Set(['node_modules', 'dist', '.git', '.angular', '.venv', 'venv', '__pycache__', 'coverage', '.nx', '.cache', 'tmp']);
|
|
29
|
+
const MAX_DEPTH = 4;
|
|
30
|
+
const rel = (p) => path.relative(root, p).split(path.sep).join('/') || '.';
|
|
31
|
+
const read = (p) => { try { return fs.readFileSync(p, 'utf8'); } catch { return null; } };
|
|
32
|
+
const readJson = (p) => { try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch { return null; } };
|
|
33
|
+
const lineOf = (text, index) => (index < 0 ? 1 : text.slice(0, index).split('\n').length);
|
|
34
|
+
const lineOfStr = (text, needle) => lineOf(text, text.indexOf(needle));
|
|
35
|
+
|
|
36
|
+
/** `# acropole-ignore-next-line <id> -- motivo` (ou //) na linha anterior silencia o achado. */
|
|
37
|
+
function ignored(text, line, id) {
|
|
38
|
+
if (!text || line < 2) return false;
|
|
39
|
+
const prev = text.split(/\r?\n/)[line - 2] ?? '';
|
|
40
|
+
const m = prev.match(/acropole-ignore-next-line\s+([\w,-]+)\s+--\s*\S/);
|
|
41
|
+
return !!m && m[1].split(',').includes(id);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ---------- varredura ----------------------------------------------------------------------------
|
|
45
|
+
const files = { pkg: [], angular: [], docker: [], req: [], pyproject: [] };
|
|
46
|
+
(function walk(dir, depth) {
|
|
47
|
+
let entries;
|
|
48
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
|
|
49
|
+
for (const e of entries) {
|
|
50
|
+
const p = path.join(dir, e.name);
|
|
51
|
+
if (e.isDirectory()) {
|
|
52
|
+
if (!IGNORE.has(e.name) && depth < MAX_DEPTH) walk(p, depth + 1);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!e.isFile()) continue;
|
|
56
|
+
if (e.name === 'package.json') files.pkg.push(p);
|
|
57
|
+
else if (e.name === 'angular.json') files.angular.push(p);
|
|
58
|
+
else if (/^Dockerfile(\..+)?$/i.test(e.name) || /\.Dockerfile$/i.test(e.name)) files.docker.push(p);
|
|
59
|
+
else if (/^requirements.*\.txt$/i.test(e.name)) files.req.push(p);
|
|
60
|
+
else if (e.name === 'pyproject.toml') files.pyproject.push(p);
|
|
61
|
+
}
|
|
62
|
+
})(root, 0);
|
|
63
|
+
|
|
64
|
+
const findings = [];
|
|
65
|
+
const add = (f) => findings.push(f);
|
|
66
|
+
const deps = (pkg) => ({ ...(pkg?.dependencies ?? {}), ...(pkg?.devDependencies ?? {}) });
|
|
67
|
+
|
|
68
|
+
/** Versão comparável: instalada em node_modules, senão a declarada (sem ^~>=, ou a do nome do .tgz). */
|
|
69
|
+
function effectiveVersion(pkgDir, name, declared) {
|
|
70
|
+
const installed = readJson(path.join(pkgDir, 'node_modules', ...name.split('/'), 'package.json'));
|
|
71
|
+
if (installed?.version) return installed.version;
|
|
72
|
+
const local = String(declared).match(/^(?:file|link):(.+)$/);
|
|
73
|
+
if (local && !/.tgz$/.test(local[1])) return readJson(path.join(path.resolve(pkgDir, local[1]), 'package.json'))?.version ?? null;
|
|
74
|
+
if (/^workspace:/.test(String(declared))) return null;
|
|
75
|
+
const tgz = String(declared).match(/(\d+\.\d+\.\d+[\w.-]*?)\.tgz$/);
|
|
76
|
+
if (tgz) return tgz[1];
|
|
77
|
+
const m = String(declared).match(/\d+(\.\d+){0,2}([\w.-]*)?/);
|
|
78
|
+
return m ? m[0] : String(declared);
|
|
79
|
+
}
|
|
80
|
+
const majorOf = (v) => { const m = String(v).match(/\d+/); return m ? Number(m[0]) : null; };
|
|
81
|
+
|
|
82
|
+
// ---------- 1. @trismegisto/* alinhados ----------------------------------------------------------
|
|
83
|
+
const npmOrfeu = []; // { version, where }
|
|
84
|
+
for (const file of files.pkg) {
|
|
85
|
+
const pkg = readJson(file);
|
|
86
|
+
if (!pkg) continue;
|
|
87
|
+
const dir = path.dirname(file);
|
|
88
|
+
const text = read(file);
|
|
89
|
+
const all = deps(pkg);
|
|
90
|
+
const tris = Object.entries(all).filter(([n]) => n.startsWith('@trismegisto/'))
|
|
91
|
+
.map(([n, d]) => ({ name: n, version: effectiveVersion(dir, n, d) }))
|
|
92
|
+
.filter((t) => t.version);
|
|
93
|
+
const distinct = [...new Set(tris.map((t) => t.version))];
|
|
94
|
+
if (distinct.length > 1) {
|
|
95
|
+
const line = lineOfStr(text, `"${tris[0].name}"`);
|
|
96
|
+
if (!ignored(text, line, 'trismegisto-versoes')) {
|
|
97
|
+
add({
|
|
98
|
+
id: 'trismegisto-versoes', severity: 'avisa', path: rel(file), line,
|
|
99
|
+
summary: `@trismegisto/* em versões diferentes: ${tris.map((t) => `${t.name}@${t.version}`).join(', ')}`,
|
|
100
|
+
fix: 'declare todos os @trismegisto/* na mesma versão e reinstale (npm install)',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
for (const [n, d] of Object.entries(all)) {
|
|
105
|
+
if (n.startsWith('@orfeu/') && effectiveVersion(dir, n, d)) npmOrfeu.push({ name: n, version: effectiveVersion(dir, n, d), where: rel(file) });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ---------- 2. uma cópia só de @orfeu/angular --------------------------------------------------
|
|
109
|
+
if (all['@orfeu/angular'] || all['@trismegisto/spine']) {
|
|
110
|
+
const nm = path.join(dir, 'node_modules');
|
|
111
|
+
const candidates = [path.join(nm, '@orfeu', 'angular')];
|
|
112
|
+
let top = [];
|
|
113
|
+
try { top = fs.readdirSync(nm, { withFileTypes: true }); } catch { /* sem node_modules */ }
|
|
114
|
+
for (const e of top) {
|
|
115
|
+
if (!e.isDirectory() || e.name.startsWith('.')) continue;
|
|
116
|
+
const names = e.name.startsWith('@')
|
|
117
|
+
? (() => { try { return fs.readdirSync(path.join(nm, e.name)).map((s) => path.join(e.name, s)); } catch { return []; } })()
|
|
118
|
+
: [e.name];
|
|
119
|
+
for (const n of names) candidates.push(path.join(nm, n, 'node_modules', '@orfeu', 'angular'));
|
|
120
|
+
}
|
|
121
|
+
const copies = new Map();
|
|
122
|
+
for (const c of candidates) {
|
|
123
|
+
const pj = readJson(path.join(c, 'package.json'));
|
|
124
|
+
if (!pj) continue;
|
|
125
|
+
let real = c;
|
|
126
|
+
try { real = fs.realpathSync(c); } catch { /* mantém */ }
|
|
127
|
+
if (!copies.has(real)) copies.set(real, `${rel(c)}@${pj.version}`);
|
|
128
|
+
}
|
|
129
|
+
if (copies.size > 1) {
|
|
130
|
+
const line = lineOfStr(text, '"@orfeu/angular"');
|
|
131
|
+
if (!ignored(text, line, 'orfeu-angular-duplicado')) {
|
|
132
|
+
add({
|
|
133
|
+
id: 'orfeu-angular-duplicado', severity: 'avisa', path: rel(file), line,
|
|
134
|
+
summary: `${copies.size} cópias de @orfeu/angular: ${[...copies.values()].join(', ')}`,
|
|
135
|
+
fix: 'alinhe a versão de @orfeu/angular com a pedida pelo @trismegisto/spine (ou use "overrides") e rode npm dedupe',
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ---------- 3. ordem de styles no angular.json ---------------------------------------------------
|
|
143
|
+
const isTokens = (s) => /@trismegisto\/tokens\b.*tokens\.css$/.test(s);
|
|
144
|
+
const isCore = (s) => /@trismegisto\/core\b.*core\.css$/.test(s);
|
|
145
|
+
const styleName = (s) => (typeof s === 'string' ? s : s?.input ?? '');
|
|
146
|
+
const angularDirs = new Set();
|
|
147
|
+
for (const file of files.angular) {
|
|
148
|
+
const text = read(file);
|
|
149
|
+
const data = readJson(file);
|
|
150
|
+
const dir = path.dirname(file);
|
|
151
|
+
angularDirs.add(dir);
|
|
152
|
+
if (!data?.projects) continue;
|
|
153
|
+
const pkg = readJson(path.join(dir, 'package.json'));
|
|
154
|
+
const usesTris = !!deps(pkg)['@trismegisto/angular'];
|
|
155
|
+
for (const [proj, cfg] of Object.entries(data.projects)) {
|
|
156
|
+
const targets = cfg?.architect ?? cfg?.targets ?? {};
|
|
157
|
+
for (const [target, t] of Object.entries(targets)) {
|
|
158
|
+
const styles = t?.options?.styles;
|
|
159
|
+
if (!Array.isArray(styles)) continue;
|
|
160
|
+
const names = styles.map(styleName);
|
|
161
|
+
const ti = names.findIndex(isTokens);
|
|
162
|
+
const ci = names.findIndex(isCore);
|
|
163
|
+
if (ti >= 0 && ci >= 0 && ci < ti) {
|
|
164
|
+
const line = lineOfStr(text, names[ci]);
|
|
165
|
+
if (!ignored(text, line, 'styles-ordem')) {
|
|
166
|
+
add({
|
|
167
|
+
id: 'styles-ordem', severity: 'corrige', path: rel(file), line,
|
|
168
|
+
summary: `${proj} › ${target}: core.css vem antes de tokens.css no "styles"`,
|
|
169
|
+
fix: 'mover tokens.css para antes de core.css',
|
|
170
|
+
_fix: { kind: 'styles', file, proj, target },
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
} else if (usesTris && target === 'build' && (ti < 0 || ci < 0)) {
|
|
174
|
+
const line = lineOfStr(text, '"styles"');
|
|
175
|
+
if (!ignored(text, line, 'styles-ausente')) {
|
|
176
|
+
add({
|
|
177
|
+
id: 'styles-ausente', severity: 'avisa', path: rel(file), line,
|
|
178
|
+
summary: `${proj} › build: "styles" sem ${ti < 0 ? 'tokens.css' : ''}${ti < 0 && ci < 0 ? ' e ' : ''}${ci < 0 ? 'core.css' : ''} do Trismegisto`,
|
|
179
|
+
fix: 'incluir node_modules/@trismegisto/tokens/dist/tokens.css e depois node_modules/@trismegisto/core/dist/core.css (skill trismegisto §2)',
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ---------- 4. provideHttpClient(withInterceptorsFromDi()) ---------------------------------------
|
|
188
|
+
for (const file of files.pkg) {
|
|
189
|
+
if (deps(readJson(file))['@angular/core']) angularDirs.add(path.dirname(file));
|
|
190
|
+
}
|
|
191
|
+
// O interceptor que manda x-route-id é do spine/@orfeu/angular: sem eles a regra não se aplica.
|
|
192
|
+
const usesAuthInterceptor = (dir) => { const d = deps(readJson(path.join(dir, 'package.json'))); return !!(d['@trismegisto/spine'] || d['@orfeu/angular']); };
|
|
193
|
+
function tsFiles(dir, out = []) {
|
|
194
|
+
let entries;
|
|
195
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return out; }
|
|
196
|
+
for (const e of entries) {
|
|
197
|
+
const p = path.join(dir, e.name);
|
|
198
|
+
if (e.isDirectory()) { if (!IGNORE.has(e.name)) tsFiles(p, out); }
|
|
199
|
+
else if (e.isFile() && e.name.endsWith('.ts') && !e.name.endsWith('.spec.ts') && !e.name.endsWith('.d.ts')) out.push(p);
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
function closingParen(text, open) {
|
|
204
|
+
let depth = 0;
|
|
205
|
+
for (let i = open; i < text.length; i++) {
|
|
206
|
+
if (text[i] === '(') depth++;
|
|
207
|
+
else if (text[i] === ')' && --depth === 0) return i;
|
|
208
|
+
}
|
|
209
|
+
return -1;
|
|
210
|
+
}
|
|
211
|
+
const HTTP_IMPORT_RE = /import\s*\{([^}]*)\}\s*from\s*['"]@angular\/common\/http['"]/;
|
|
212
|
+
const seenTs = new Set();
|
|
213
|
+
for (const dir of angularDirs) {
|
|
214
|
+
if (!usesAuthInterceptor(dir)) continue;
|
|
215
|
+
for (const file of tsFiles(path.join(dir, 'src'))) {
|
|
216
|
+
if (seenTs.has(file)) continue;
|
|
217
|
+
seenTs.add(file);
|
|
218
|
+
const text = read(file);
|
|
219
|
+
if (!text || !text.includes('provideHttpClient')) continue;
|
|
220
|
+
const re = /provideHttpClient\s*\(/g;
|
|
221
|
+
let m;
|
|
222
|
+
while ((m = re.exec(text))) {
|
|
223
|
+
const open = m.index + m[0].length - 1;
|
|
224
|
+
const close = closingParen(text, open);
|
|
225
|
+
if (close < 0) continue;
|
|
226
|
+
if (/withInterceptorsFromDi/.test(text.slice(open + 1, close))) continue;
|
|
227
|
+
const line = lineOf(text, m.index);
|
|
228
|
+
if (ignored(text, line, 'http-interceptors')) continue;
|
|
229
|
+
const importOk = (text.match(HTTP_IMPORT_RE)?.[1] ?? '').includes('provideHttpClient');
|
|
230
|
+
add({
|
|
231
|
+
id: 'http-interceptors', severity: importOk ? 'corrige' : 'avisa', path: rel(file), line,
|
|
232
|
+
summary: 'provideHttpClient sem withInterceptorsFromDi(): o interceptor do spine não roda e o x-route-id some da auditoria',
|
|
233
|
+
fix: 'provideHttpClient(withInterceptorsFromDi()) importando withInterceptorsFromDi de @angular/common/http',
|
|
234
|
+
...(importOk ? { _fix: { kind: 'http', file } } : {}),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ---------- 5. Dockerfile -------------------------------------------------------------------------
|
|
241
|
+
function dockerInstructions(text) {
|
|
242
|
+
const lines = text.split(/\r?\n/);
|
|
243
|
+
const out = [];
|
|
244
|
+
let buf = '';
|
|
245
|
+
let start = 0;
|
|
246
|
+
for (let i = 0; i < lines.length; i++) {
|
|
247
|
+
const raw = lines[i];
|
|
248
|
+
if (!buf && (/^\s*#/.test(raw) || !raw.trim())) continue;
|
|
249
|
+
if (!buf) start = i + 1;
|
|
250
|
+
if (/\\\s*$/.test(raw)) { buf += raw.replace(/\\\s*$/, ' '); continue; }
|
|
251
|
+
buf += raw;
|
|
252
|
+
const m = buf.trim().match(/^(\w+)\s+([\s\S]*)$/);
|
|
253
|
+
if (m) out.push({ op: m[1].toUpperCase(), rest: m[2].trim(), line: start });
|
|
254
|
+
buf = '';
|
|
255
|
+
}
|
|
256
|
+
return out;
|
|
257
|
+
}
|
|
258
|
+
for (const file of files.docker) {
|
|
259
|
+
const text = read(file);
|
|
260
|
+
if (!text) continue;
|
|
261
|
+
const ins = dockerInstructions(text);
|
|
262
|
+
const lastFrom = ins.map((x) => x.op).lastIndexOf('FROM');
|
|
263
|
+
ins.forEach((x, idx) => {
|
|
264
|
+
if ((x.op === 'CMD' || x.op === 'ENTRYPOINT') && idx > lastFrom) {
|
|
265
|
+
let problem = null;
|
|
266
|
+
if (x.rest.startsWith('[')) {
|
|
267
|
+
let arr = null;
|
|
268
|
+
try { arr = JSON.parse(x.rest); } catch { /* inválido */ }
|
|
269
|
+
if (!Array.isArray(arr)) problem = `${x.op} com JSON inválido (o Docker cai para a forma shell)`;
|
|
270
|
+
else if (/^(\/bin\/)?(ba)?sh$/.test(arr[0] ?? '') && arr[1] === '-c' && !/(^|[;&|\s])exec\s/.test(arr[2] ?? '')) {
|
|
271
|
+
problem = `${x.op} com "sh -c" sem exec: o sh fica como PID 1 e não repassa SIGTERM`;
|
|
272
|
+
}
|
|
273
|
+
} else if (!/^exec\s/.test(x.rest)) {
|
|
274
|
+
problem = `${x.op} em forma shell: o sh fica como PID 1 e não repassa SIGTERM (auditoria do Orfeu se perde no stop)`;
|
|
275
|
+
}
|
|
276
|
+
if (problem && !ignored(text, x.line, 'docker-cmd-shell')) {
|
|
277
|
+
add({
|
|
278
|
+
id: 'docker-cmd-shell', severity: 'pergunta', path: rel(file), line: x.line, summary: problem,
|
|
279
|
+
fix: 'forma exec (ex.: CMD ["node", "dist/index.js"] ou CMD ["uvicorn", "src.main:app", ...]) — revise com /acropole revisar <Dockerfile> (revisor-deploy, skill docker)',
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const copyLike = x.op === 'COPY' || x.op === 'ADD';
|
|
284
|
+
const npmrcInImage =
|
|
285
|
+
(copyLike && /(^|[\s/"'])\.npmrc\b/.test(x.rest)) ||
|
|
286
|
+
(x.op === 'RUN' && !/--mount=type=secret/.test(x.rest) && (/>>?\s*\S*\.npmrc\b/.test(x.rest) || /_authToken/.test(x.rest)));
|
|
287
|
+
if (npmrcInImage && !ignored(text, x.line, 'docker-npmrc')) {
|
|
288
|
+
add({
|
|
289
|
+
id: 'docker-npmrc', severity: 'avisa', path: rel(file), line: x.line,
|
|
290
|
+
summary: `.npmrc/credencial de registry gravada numa camada da imagem (${x.op})`,
|
|
291
|
+
fix: 'os pacotes vêm do registry público: remova o .npmrc da imagem (se precisar mesmo, use RUN --mount=type=secret)',
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (copyLike) {
|
|
295
|
+
const parts = x.rest.split(/\s+/).filter((p) => !p.startsWith('--'));
|
|
296
|
+
const ctx = path.dirname(file);
|
|
297
|
+
if (idx > lastFrom && parts.length >= 2 && parts.slice(0, -1).some((s) => s === '.' || s === './') && fs.existsSync(path.join(ctx, '.npmrc'))) {
|
|
298
|
+
const di = read(path.join(ctx, '.dockerignore')) ?? '';
|
|
299
|
+
const excluded = di.split(/\r?\n/).map((l) => l.trim()).some((l) => /^(\*\*\/)?\.npmrc$|^\*$|^\.\*$/.test(l));
|
|
300
|
+
if (!excluded && !ignored(text, x.line, 'docker-npmrc')) {
|
|
301
|
+
add({
|
|
302
|
+
id: 'docker-npmrc', severity: 'avisa', path: rel(file), line: x.line,
|
|
303
|
+
summary: 'COPY do contexto inteiro no estágio final com um .npmrc na pasta e sem .npmrc no .dockerignore',
|
|
304
|
+
fix: 'adicione .npmrc (e .env*) ao .dockerignore',
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// ---------- 6. orfeu Python na mesma major das libs ----------------------------------------------
|
|
313
|
+
const npmMajors = [...new Set(npmOrfeu.map((o) => majorOf(o.version)).filter((v) => v !== null))];
|
|
314
|
+
function checkPyOrfeu(file, line, spec, text) {
|
|
315
|
+
if (!spec.trim()) {
|
|
316
|
+
if (!ignored(text, line, 'orfeu-python-sem-versao')) {
|
|
317
|
+
add({
|
|
318
|
+
id: 'orfeu-python-sem-versao', severity: 'avisa', path: rel(file), line,
|
|
319
|
+
summary: 'orfeu sem versão: cada build pode trazer uma major diferente',
|
|
320
|
+
fix: 'fixe a major, ex.: orfeu[fastapi]>=1.0,<2',
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const major = majorOf(spec);
|
|
326
|
+
if (major === null || !npmMajors.length || npmMajors.includes(major)) return;
|
|
327
|
+
if (ignored(text, line, 'orfeu-python-major')) return;
|
|
328
|
+
add({
|
|
329
|
+
id: 'orfeu-python-major', severity: 'avisa', path: rel(file), line,
|
|
330
|
+
summary: `orfeu (Python) na major ${major}, libs npm @orfeu/* na major ${npmMajors.join('/')} (${npmOrfeu.map((o) => `${o.name}@${o.version}`).join(', ')})`,
|
|
331
|
+
fix: `use orfeu na major ${npmMajors[0]} (ex.: orfeu[fastapi]>=${npmMajors[0]}.0,<${npmMajors[0] + 1})`,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
for (const file of files.req) {
|
|
335
|
+
const text = read(file);
|
|
336
|
+
if (!text) continue;
|
|
337
|
+
text.split(/\r?\n/).forEach((raw, i) => {
|
|
338
|
+
const l = raw.replace(/\s+#.*$/, '').trim();
|
|
339
|
+
const m = l.match(/^orfeu(\[[^\]]*\])?\s*(.*)$/i);
|
|
340
|
+
if (m && !/^[\w-]/.test(m[2])) checkPyOrfeu(file, i + 1, m[2].replace(/;.*$/, ''), text);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
for (const file of files.pyproject) {
|
|
344
|
+
const text = read(file);
|
|
345
|
+
if (!text) continue;
|
|
346
|
+
// O próprio pacote orfeu não depende de si mesmo.
|
|
347
|
+
if (/^\s*name\s*=\s*["']orfeu["']/m.test(text)) continue;
|
|
348
|
+
// Só olha onde se declaram dependências: `dependencies = [...]` (PEP 621), seções
|
|
349
|
+
// [project.optional-dependencies]/[dependency-groups] e as tabelas de dependências do Poetry.
|
|
350
|
+
let section = '';
|
|
351
|
+
let inDepsArray = false;
|
|
352
|
+
text.split(/\r?\n/).forEach((raw, i) => {
|
|
353
|
+
const header = raw.match(/^\s*\[+([^\]]+)\]+\s*$/);
|
|
354
|
+
if (header) { section = header[1].trim(); inDepsArray = false; return; }
|
|
355
|
+
if (section === 'project' && /^\s*dependencies\s*=\s*\[/.test(raw)) inDepsArray = true;
|
|
356
|
+
const depsSection = inDepsArray || /^(project\.optional-dependencies|dependency-groups)$/.test(section);
|
|
357
|
+
if (depsSection) {
|
|
358
|
+
const m = raw.match(/["']orfeu(\[[^\]]*\])?\s*([^"';]*)/i); // "orfeu[fastapi]>=1.0,<2"
|
|
359
|
+
if (m && !/^[\w-]/.test(m[2])) checkPyOrfeu(file, i + 1, m[2], text);
|
|
360
|
+
} else if (/dependencies$/.test(section)) {
|
|
361
|
+
const m = raw.match(/^\s*orfeu\s*=\s*(?:["']([^"']*)["']|\{[^}]*version\s*=\s*["']([^"']*)["'])/i); // Poetry
|
|
362
|
+
if (m) checkPyOrfeu(file, i + 1, m[1] ?? m[2] ?? '', text);
|
|
363
|
+
}
|
|
364
|
+
if (inDepsArray && /\]\s*(#.*)?$/.test(raw)) inDepsArray = false;
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// ---------- --fix ---------------------------------------------------------------------------------
|
|
369
|
+
const fixed = [];
|
|
370
|
+
if (doFix) {
|
|
371
|
+
const byFile = new Map();
|
|
372
|
+
for (const f of findings.filter((x) => x.severity === 'corrige' && x._fix)) {
|
|
373
|
+
if (!byFile.has(f._fix.file)) byFile.set(f._fix.file, []);
|
|
374
|
+
byFile.get(f._fix.file).push(f);
|
|
375
|
+
}
|
|
376
|
+
for (const [file, list] of byFile) {
|
|
377
|
+
if (list[0]._fix.kind === 'styles') {
|
|
378
|
+
const text = read(file);
|
|
379
|
+
const data = JSON.parse(text);
|
|
380
|
+
for (const f of list) {
|
|
381
|
+
const t = (data.projects[f._fix.proj].architect ?? data.projects[f._fix.proj].targets)[f._fix.target];
|
|
382
|
+
const styles = t.options.styles;
|
|
383
|
+
const ti = styles.map(styleName).findIndex(isTokens);
|
|
384
|
+
const [tok] = styles.splice(ti, 1);
|
|
385
|
+
styles.splice(styles.map(styleName).findIndex(isCore), 0, tok);
|
|
386
|
+
}
|
|
387
|
+
const indent = text.match(/\n([ \t]+)"/)?.[1] ?? ' ';
|
|
388
|
+
const eol = text.includes('\r\n') ? '\r\n' : '\n';
|
|
389
|
+
fs.writeFileSync(file, JSON.stringify(data, null, indent).replace(/\n/g, eol) + (/\r?\n$/.test(text) ? eol : ''));
|
|
390
|
+
} else {
|
|
391
|
+
let text = read(file);
|
|
392
|
+
// de trás para frente, para os índices continuarem válidos
|
|
393
|
+
const calls = [];
|
|
394
|
+
const re = /provideHttpClient\s*\(/g;
|
|
395
|
+
let m;
|
|
396
|
+
while ((m = re.exec(text))) {
|
|
397
|
+
const open = m.index + m[0].length - 1;
|
|
398
|
+
const close = closingParen(text, open);
|
|
399
|
+
if (close >= 0 && !/withInterceptorsFromDi/.test(text.slice(open + 1, close))) calls.push({ open, empty: !text.slice(open + 1, close).trim() });
|
|
400
|
+
}
|
|
401
|
+
for (const c of calls.reverse()) {
|
|
402
|
+
text = text.slice(0, c.open + 1) + 'withInterceptorsFromDi()' + (c.empty ? '' : ', ') + text.slice(c.open + 1).replace(/^\s*/, c.empty ? '' : '');
|
|
403
|
+
}
|
|
404
|
+
text = text.replace(HTTP_IMPORT_RE, (all, names) => {
|
|
405
|
+
if (/\bwithInterceptorsFromDi\b/.test(names)) return all;
|
|
406
|
+
const trimmed = names.replace(/\s*,?\s*$/, '');
|
|
407
|
+
const tail = names.slice(trimmed.length).replace(/^\s*,/, '');
|
|
408
|
+
return all.replace(`{${names}}`, `{${trimmed}, withInterceptorsFromDi${tail}}`);
|
|
409
|
+
});
|
|
410
|
+
fs.writeFileSync(file, text);
|
|
411
|
+
}
|
|
412
|
+
for (const f of list) fixed.push(f);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// ---------- saída ---------------------------------------------------------------------------------
|
|
417
|
+
const remaining = findings.filter((f) => !fixed.includes(f));
|
|
418
|
+
const clean = (f) => { const { _fix, ...rest } = f; return rest; };
|
|
419
|
+
if (asJson) {
|
|
420
|
+
console.log(JSON.stringify({ root, findings: remaining.map(clean), fixed: fixed.map(clean) }, null, 2));
|
|
421
|
+
} else {
|
|
422
|
+
console.log(`acropole doctor — ${root}\n`);
|
|
423
|
+
for (const f of fixed) console.log(`Corrigido: ${f.path}:${f.line} ${f.id} ${f.fix}`);
|
|
424
|
+
if (fixed.length) console.log('');
|
|
425
|
+
if (!remaining.length) console.log(fixed.length ? 'Nenhum achado restante.' : 'Nenhum achado.');
|
|
426
|
+
const groups = [
|
|
427
|
+
['corrige', 'Corrige (--fix aplica; rode só a pedido do usuário)'],
|
|
428
|
+
['avisa', 'Avisa (a correção é decisão do usuário)'],
|
|
429
|
+
['pergunta', 'Pergunta (revisar com contexto antes de mexer)'],
|
|
430
|
+
];
|
|
431
|
+
for (const [sev, title] of groups) {
|
|
432
|
+
const list = remaining.filter((f) => f.severity === sev);
|
|
433
|
+
if (!list.length) continue;
|
|
434
|
+
console.log(`${title}:`);
|
|
435
|
+
for (const f of list) console.log(` ${f.path}:${f.line} ${f.id} ${f.summary} → ${f.fix}`);
|
|
436
|
+
console.log('');
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
process.exit(0);
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: angular
|
|
3
|
+
description: "Arquitetura de apps Angular da plataforma (22+, standalone, shell spine): estrutura de pastas, bootstrap, registro de tela por router_id, serviços GraphQL/REST com unwrap, signals, formulários, testes e build. Use ao criar ou alterar um app Angular, a parte de rotas/estado/dados de uma tela, um serviço de dados ou o build. A parte visual da tela (componentes hm-*, tokens, tema, ícones) é da skill trismegisto — numa tela nova use as duas; login/sessão/token é da orfeu."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# angular
|
|
7
|
+
|
|
8
|
+
Como os apps Angular da plataforma são montados e como uma tela nova entra neles. Vale para apps
|
|
9
|
+
**Angular 22+, standalone, com o shell `@trismegisto/spine`** e autenticação via `@orfeu/angular`
|
|
10
|
+
contra o Argos.
|
|
11
|
+
|
|
12
|
+
Skills vizinhas (não duplicar o conteúdo delas aqui):
|
|
13
|
+
|
|
14
|
+
| Assunto | Skill |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| Componentes `hm-*`, tema, tokens `--hm-*`, ícones, layout/shell/sidebar, modal, catálogo de mensagens | `trismegisto` |
|
|
17
|
+
| Sessão, login/callback, `provideAuth`, guards, token e cabeçalhos (`x-access-token`), auditoria | `orfeu` |
|
|
18
|
+
| O servidor GraphQL que o app consome (schema, envelope `{ status, message, data }`, resolvers) | `apollo` |
|
|
19
|
+
| Backends REST em Node / Python | `express` / `fastapi` |
|
|
20
|
+
|
|
21
|
+
Ainda não coberto por nenhuma skill: React, Strawberry, Fastify, Django, Flask.
|
|
22
|
+
|
|
23
|
+
> **Antes de dar por terminado:** `node scripts/checar.mjs <arquivos alterados>` (caminho relativo a esta skill: instalada, fica em `~/.claude/skills/angular/scripts/checar.mjs`; `--help` lista as regras, `--json` para máquina).
|
|
24
|
+
>
|
|
25
|
+
> **Mexeu numa tela ou rota?** Rode também a skill `documentacao`: revise o README da tela e registre a revisão.
|
|
26
|
+
|
|
27
|
+
## Mapa rápido de um app
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
meu-app/
|
|
31
|
+
├── angular.json # builder @angular/build:application, configs prod/dev/homol/local/development
|
|
32
|
+
├── codegen.ts # graphql-codegen (tipos + TypedDocumentNode), roda à mão
|
|
33
|
+
├── Dockerfile # estágios dev / build / site (só o /dist estático)
|
|
34
|
+
├── eslint.a11y.config.js # regras de acessibilidade de template (angular-eslint)
|
|
35
|
+
├── tsconfig.json # strict, baseUrl "./", resolveJsonModule
|
|
36
|
+
└── src/
|
|
37
|
+
├── main.ts # applyRuntimeEnvironment(environment) + bootstrapApplication
|
|
38
|
+
├── index.html # lang="pt-BR", favicon, tela #app-loading
|
|
39
|
+
├── styles.scss # só estilos globais do app, com tokens --hm-*
|
|
40
|
+
├── core/ # app.config.ts, core.providers.ts, core.component.ts, environments/
|
|
41
|
+
├── app/
|
|
42
|
+
│ ├── features/ # uma pasta por tela + features.routes.ts (mapa router_id -> tela lazy)
|
|
43
|
+
│ └── services/ # <dominio>/<dominio>.graphql|.service.ts|.models.ts|.generated.ts
|
|
44
|
+
├── shared/ # componentes/utilitários reaproveitados entre telas do app
|
|
45
|
+
└── assets/ # imagens (logo.svg, favicon), fontes, tema próprio do app
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Detalhes e exemplos completos: [references/estrutura.md](references/estrutura.md).
|
|
49
|
+
|
|
50
|
+
## Regras essenciais
|
|
51
|
+
|
|
52
|
+
**Bootstrap** (`src/core/`)
|
|
53
|
+
- `main.ts` chama `applyRuntimeEnvironment(environment)` (de `@trismegisto/spine`) **antes** do
|
|
54
|
+
`bootstrapApplication`: deriva `redirectUrl`/`postLogoutRedirectUri` da origem atual e, atrás do
|
|
55
|
+
proxy, `authority` e endpoints GraphQL ainda com `CHANGE_ME`. Não grave URL de callback fixa.
|
|
56
|
+
- `app.config.ts`: `provideZoneChangeDetection({ eventCoalescing: true })` (uma vez só),
|
|
57
|
+
`provideRouter(APP_ROUTES)`, `...CORE_PROVIDERS`, `provideUi(spineConfig)`, `provideAuth(...)`,
|
|
58
|
+
`provideAutoService(...)` se o client usa auto-serviço, `provideShell({ appComponents, packageInfo })`.
|
|
59
|
+
- `core.providers.ts`: `provideAnimationsAsync()`, `provideHttpClient(withInterceptorsFromDi())`
|
|
60
|
+
(obrigatório: ativa o interceptor do spine que manda `x-route-id` para a auditoria) e
|
|
61
|
+
`provideGraphql({ endpoints: environment.graphql })`.
|
|
62
|
+
- `zone.js` continua nos `polyfills`. Zoneless só com migração dedicada e testada.
|
|
63
|
+
|
|
64
|
+
**Telas** (`src/app/features/`)
|
|
65
|
+
- Toda tela é registrada em `features.routes.ts` como `ComponentRoute` com `id` = **`router_id`** da
|
|
66
|
+
linha do roteador do client no Argos (não o `route_id` da página) e `load` lazy. A URL vem do Argos,
|
|
67
|
+
não do nome da pasta. Ver [references/features.md](references/features.md).
|
|
68
|
+
- Componentes standalone (sem `standalone: true`, já é o padrão), `ChangeDetectionStrategy.OnPush`,
|
|
69
|
+
`inject()` em vez de construtor, `input()`/`output()`/`model()`, `viewChild()` etc.
|
|
70
|
+
- Estado local em `signal()`; derivado em `computed()`; efeito colateral em `effect()`; valor
|
|
71
|
+
derivado e editável que reseta com a fonte em `linkedSignal()`. Nunca `mutate`.
|
|
72
|
+
- Templates com `@if`/`@for`/`@switch`/`@let`; `@for` sempre com `track item.id`; `[class.x]`/
|
|
73
|
+
`[style.x]` em vez de `ngClass`/`ngStyle`.
|
|
74
|
+
- Formulários reativos (`FormGroup`/`FormControl` com `nonNullable: true`). Desabilitar campo é
|
|
75
|
+
`control.disable()`, nunca `[disabled]` junto de `[formControl]`/`formControlName`. Data de formulário
|
|
76
|
+
em horário local (`toISOString()` é UTC: depois das 21h em UTC-3 vira o dia seguinte).
|
|
77
|
+
- Ação destrutiva (excluir, revogar, sobrescrever) pede confirmação (`HermesDialogService.confirm`).
|
|
78
|
+
- Credencial nunca em `localStorage`/`sessionStorage`; se precisar guardar, em memória (service root).
|
|
79
|
+
|
|
80
|
+
**Dados** (`src/app/services/<dominio>/`)
|
|
81
|
+
- Componente nunca fala com Apollo/HttpClient direto: fala com um service `providedIn: 'root'`.
|
|
82
|
+
- GraphQL: `private readonly gql = injectGraphqlClient('<namedClient>')` +
|
|
83
|
+
`unwrap((await this.gql.query(Doc, vars, options)).campo)`. Documentos tipados pelo codegen
|
|
84
|
+
(`<dominio>.graphql` -> `<dominio>.generated.ts`, commitados).
|
|
85
|
+
- O toast do envelope é automático (mutation sempre; query só em falha não-404; subscription nunca).
|
|
86
|
+
Não repita toast manual; em lote use `{ silenceEnvelope: true }` e avise uma vez.
|
|
87
|
+
- Falha vira `GraphqlEnvelopeError` (com `status`): trate como estado de erro da tela, não como lista
|
|
88
|
+
vazia. **Toda carga tem estado de erro com "Tentar novamente"**; `subscribe` sem `error` e `await` sem
|
|
89
|
+
`try/finally` deixam o skeleton girando para sempre.
|
|
90
|
+
- Trocou o item selecionado ou o filtro: descarte a resposta atrasada (`switchMap` ou contador de
|
|
91
|
+
sequência). Ver [references/dados.md](references/dados.md).
|
|
92
|
+
|
|
93
|
+
**Build e qualidade**
|
|
94
|
+
- Build de produção: `ng build --configuration prod` (é a `defaultConfiguration`, então `ng build`
|
|
95
|
+
basta). Outras: `dev`, `homol`, `local` (troca o `environment.ts` por `fileReplacements`) e
|
|
96
|
+
`development` (só para `ng serve`).
|
|
97
|
+
- `angular.json` > `styles`: `src/styles.scss`, `@trismegisto/tokens/tokens.css`,
|
|
98
|
+
`@trismegisto/core/core.css`.
|
|
99
|
+
- Testes: Karma + Jasmine (`@angular/build:karma`, `ng test`). Acessibilidade: `lint:a11y` e
|
|
100
|
+
`axe:check`. Ver [references/testes-build.md](references/testes-build.md).
|
|
101
|
+
|
|
102
|
+
## Receita: tela nova "pedidos"
|
|
103
|
+
|
|
104
|
+
1. Cadastre a rota/roteador do client no Argos (painel administrativo, aba de roteadores do client) e
|
|
105
|
+
anote o `router_id`.
|
|
106
|
+
2. Escreva as operações em `src/app/services/pedidos/pedidos.graphql` e rode `npm run codegen` com o
|
|
107
|
+
GraphQL local de pé.
|
|
108
|
+
3. Crie `src/app/services/pedidos/pedidos.service.ts` (`injectGraphqlClient` + `unwrap`).
|
|
109
|
+
4. Crie `src/app/features/pedidos/pedidos.component.ts` (OnPush, signals, componentes `hm-*`).
|
|
110
|
+
5. Registre em `features.routes.ts`:
|
|
111
|
+
```ts
|
|
112
|
+
{
|
|
113
|
+
id: '<router_id>',
|
|
114
|
+
load: () => import('src/app/features/pedidos/pedidos.component').then(m => m.PedidosComponent),
|
|
115
|
+
document: { load: () => import('src/app/features/pedidos/README.md').then(m => m.default) }, // opcional
|
|
116
|
+
},
|
|
117
|
+
```
|
|
118
|
+
6. Nada muda em `app.config.ts`: o `provideShell` mescla as telas do app com as da lib.
|
|
119
|
+
7. O `features.routes.spec.ts` confere que todo `load()` resolve e que os `id` são UUID únicos (sem
|
|
120
|
+
diferenciar maiúsculas) — [references/testes-build.md](references/testes-build.md).
|
|
121
|
+
|
|
122
|
+
## Armadilhas reais (resumo)
|
|
123
|
+
|
|
124
|
+
- **`router_id` x `route_id`**: o `id` do `ComponentRoute` é o `router_id`. Usar o id da página faz a
|
|
125
|
+
tela nunca abrir. `route_id`/`component` no `ComponentRoute` são campos **deprecated** (ainda lidos).
|
|
126
|
+
- **Getter/método alimentando `@for`** de componentes compostos (accordion, tabs, stepper, data grid):
|
|
127
|
+
devolve array novo a cada ciclo e quebra expandir/recolher. Use `computed()`.
|
|
128
|
+
- **`input()` não popula `ngOnChanges`**: `changes['x']` vira código morto; reaja com `effect()`.
|
|
129
|
+
- **`new DatePipe('pt-BR')`** sem `registerLocaleData(localePt)` no `main.ts` lança NG0701.
|
|
130
|
+
- **`HermesToastService` sem `<hm-toast-stack />`** montado uma vez no componente raiz: o toast é
|
|
131
|
+
aceito e nunca aparece. (O `NotificationService` do spine já é renderizado pelo layout.)
|
|
132
|
+
- **`provideHttpClient()` sem `withInterceptorsFromDi()`** perde o `x-route-id` da auditoria.
|
|
133
|
+
- **Mensagem do backend** (`message` do envelope) é texto: nunca via `innerHTML`.
|
|
134
|
+
- **`@defer`** encolhe chunks de telas lazy, mas **não** resolve aviso de budget `initial` (o grosso
|
|
135
|
+
é o CSS global do DS e o shell/auth carregados antes de qualquer rota).
|
|
136
|
+
- **`tsconfig.app.json` com `files: ["src/main.ts"]`**: só compila o que é alcançável a partir das
|
|
137
|
+
rotas. Tela fora do `features.routes.ts` não quebra o build — e apodrece em silêncio.
|
|
138
|
+
- **`.npmrc` copiado no Dockerfile** grava credencial na imagem; os pacotes vêm do npm público.
|
|
139
|
+
|
|
140
|
+
Lista completa com contexto: [references/armadilhas.md](references/armadilhas.md).
|
|
141
|
+
|
|
142
|
+
## Referências
|
|
143
|
+
|
|
144
|
+
- [references/estrutura.md](references/estrutura.md) — pastas, `main.ts`, `app.config.ts`,
|
|
145
|
+
`core.providers.ts`, environments, `tsconfig`, `angular.json`, convenções de nome e imports.
|
|
146
|
+
- [references/features.md](references/features.md) — registro no shell, rotas próprias/públicas,
|
|
147
|
+
documentação por tela, anatomia de componente, signals, templates, formulários, a11y, i18n.
|
|
148
|
+
- [references/dados.md](references/dados.md) — GraphQL (`injectGraphqlClient`, `unwrap`, envelope,
|
|
149
|
+
subscriptions), codegen, REST, estado de carregamento/erro, notificações.
|
|
150
|
+
- [references/testes-build.md](references/testes-build.md) — specs (TestBed + Apollo falso), lint de
|
|
151
|
+
acessibilidade, axe, configurações de build, budgets, Docker.
|
|
152
|
+
- [references/armadilhas.md](references/armadilhas.md) — o que NÃO fazer e divergências entre apps.
|