tribunal-kit 4.4.1 → 4.4.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/.agent/history/architecture-graph.yaml +140 -0
- package/.agent/history/graph-cache.json +262 -0
- package/.agent/history/snapshots/bin__tribunal-kit.js.json +19 -0
- package/.agent/history/snapshots/eslint.config.js.json +9 -0
- package/.agent/history/snapshots/migrate_refs.js.json +11 -0
- package/.agent/history/snapshots/scripts__changelog.js.json +13 -0
- package/.agent/history/snapshots/scripts__sync-version.js.json +12 -0
- package/.agent/history/snapshots/scripts__validate-payload.js.json +12 -0
- package/.agent/history/snapshots/test__integration__bridges.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__init.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__routing.test.js.json +12 -0
- package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__wave2.test.js.json +14 -0
- package/.agent/history/snapshots/test__unit__args.test.js.json +20 -0
- package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__context_broker.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__copyDir.test.js.json +23 -0
- package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +12 -0
- package/.agent/history/snapshots/test__unit__inner_loop_validator.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +23 -0
- package/.agent/history/snapshots/test__unit__semver.test.js.json +20 -0
- package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +12 -0
- package/.agent/scripts/_colors.js +170 -18
- package/.agent/scripts/_utils.js +244 -42
- package/.agent/scripts/bundle_analyzer.js +261 -290
- package/.agent/scripts/case_law_manager.js +1 -7
- package/.agent/scripts/checklist.js +278 -266
- package/.agent/scripts/colors.js +11 -17
- package/.agent/scripts/context_broker.js +1 -7
- package/.agent/scripts/dependency_analyzer.js +234 -272
- package/.agent/scripts/graph_builder.js +46 -18
- package/.agent/scripts/graph_visualizer.js +10 -4
- package/.agent/scripts/graph_zoom.js +6 -4
- package/.agent/scripts/inner_loop_validator.js +2 -8
- package/.agent/scripts/lint_runner.js +186 -187
- package/.agent/scripts/schema_validator.js +8 -25
- package/.agent/scripts/security_scan.js +276 -303
- package/.agent/scripts/session_manager.js +1 -7
- package/.agent/scripts/skill_evolution.js +1 -8
- package/.agent/scripts/skill_integrator.js +1 -7
- package/.agent/scripts/test_runner.js +186 -193
- package/.agent/scripts/utils.js +17 -32
- package/.agent/scripts/verify_all.js +248 -257
- package/package.json +1 -1
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
12
|
|
|
13
|
+
const { RED, GREEN, DIM, RESET } = require('./_colors');
|
|
14
|
+
|
|
13
15
|
const AGENT_DIR = path.join(process.cwd(), '.agent');
|
|
14
16
|
const HISTORY_DIR = path.join(AGENT_DIR, 'history');
|
|
15
17
|
const CACHE_FILE = path.join(HISTORY_DIR, 'graph-cache.json');
|
|
@@ -17,7 +19,7 @@ const HTML_FILE = path.join(HISTORY_DIR, 'architecture-explorer.html');
|
|
|
17
19
|
|
|
18
20
|
function main() {
|
|
19
21
|
if (!fs.existsSync(CACHE_FILE)) {
|
|
20
|
-
console.error(
|
|
22
|
+
console.error(`${RED}✖ Error: graph-cache.json not found. Run graph_builder.js first.${RESET}`);
|
|
21
23
|
process.exit(1);
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -377,8 +379,12 @@ function main() {
|
|
|
377
379
|
</html>`;
|
|
378
380
|
|
|
379
381
|
fs.writeFileSync(HTML_FILE, htmlContent);
|
|
380
|
-
console.log(
|
|
381
|
-
console.log(`
|
|
382
|
+
console.log(`${GREEN}✔ Interactive visualizer generated.${RESET}`);
|
|
383
|
+
console.log(` ${DIM}Saved to: ${HTML_FILE}${RESET}`);
|
|
382
384
|
}
|
|
383
385
|
|
|
384
|
-
main
|
|
386
|
+
module.exports = { main };
|
|
387
|
+
|
|
388
|
+
if (require.main === module) {
|
|
389
|
+
main();
|
|
390
|
+
}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
12
|
|
|
13
|
+
const { RED, CYAN, RESET } = require('./_colors');
|
|
14
|
+
|
|
13
15
|
function getFlag(name) {
|
|
14
16
|
const idx = process.argv.indexOf(name);
|
|
15
17
|
return (idx !== -1 && process.argv[idx + 1]) ? process.argv[idx + 1] : null;
|
|
@@ -18,14 +20,14 @@ function getFlag(name) {
|
|
|
18
20
|
const targetFile = getFlag('--focus');
|
|
19
21
|
|
|
20
22
|
if (!targetFile) {
|
|
21
|
-
console.error(
|
|
23
|
+
console.error(`${RED}✖ Error: Provide a file to zoom into. Usage: node graph_zoom.js --focus <filepath>${RESET}`);
|
|
22
24
|
process.exit(1);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const absolutePath = path.resolve(process.cwd(), targetFile);
|
|
26
28
|
|
|
27
29
|
if (!fs.existsSync(absolutePath)) {
|
|
28
|
-
console.error(
|
|
30
|
+
console.error(`${RED}✖ Error: File not found at ${absolutePath}${RESET}`);
|
|
29
31
|
process.exit(1);
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -119,7 +121,7 @@ function extractSkeleton(content) {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
function main() {
|
|
122
|
-
console.log(
|
|
124
|
+
console.log(`${CYAN}✦ Zooming into: ${targetFile}${RESET}`);
|
|
123
125
|
|
|
124
126
|
try {
|
|
125
127
|
const content = fs.readFileSync(absolutePath, 'utf8');
|
|
@@ -142,7 +144,7 @@ function main() {
|
|
|
142
144
|
console.log('--- SKELETON END ---\n');
|
|
143
145
|
|
|
144
146
|
} catch (e) {
|
|
145
|
-
console.error(
|
|
147
|
+
console.error(`${RED}✖ Error parsing file: ${e.message}${RESET}`);
|
|
146
148
|
// Fallback Logic: Return truncated raw on hard failure
|
|
147
149
|
const rawContent = fs.readFileSync(absolutePath, 'utf8').split('\n').slice(0, 100).join('\n');
|
|
148
150
|
console.log('\n--- RAW FILE FALLBACK (100 lines) ---');
|
|
@@ -120,14 +120,8 @@ const SYNTAX_HEURISTICS = [
|
|
|
120
120
|
},
|
|
121
121
|
];
|
|
122
122
|
|
|
123
|
-
// ── ANSI colors (
|
|
124
|
-
const GREEN
|
|
125
|
-
const YELLOW = '\x1b[93m';
|
|
126
|
-
const RED = '\x1b[91m';
|
|
127
|
-
const CYAN = '\x1b[96m';
|
|
128
|
-
const BOLD = '\x1b[1m';
|
|
129
|
-
const DIM = '\x1b[2m';
|
|
130
|
-
const RESET = '\x1b[0m';
|
|
123
|
+
// ── ANSI colors (centralized via _colors.js) ─────────────────────────────
|
|
124
|
+
const { GREEN, YELLOW, RED, CYAN, BOLD, DIM, RESET } = require('./_colors');
|
|
131
125
|
|
|
132
126
|
// ── Core scanning ─────────────────────────────────────────────────────────
|
|
133
127
|
|
|
@@ -1,187 +1,186 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* lint_runner.js — Standalone lint runner for the Tribunal Agent Kit.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* node .agent/scripts/lint_runner.js .
|
|
7
|
-
* node .agent/scripts/lint_runner.js . --fix
|
|
8
|
-
* node .agent/scripts/lint_runner.js . --files src/index.ts src/utils.ts
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const fs = require('fs');
|
|
14
|
-
const path = require('path');
|
|
15
|
-
const { spawnSync } = require('child_process');
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
if (result.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (!runLinter("
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* lint_runner.js — Standalone lint runner for the Tribunal Agent Kit.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node .agent/scripts/lint_runner.js .
|
|
7
|
+
* node .agent/scripts/lint_runner.js . --fix
|
|
8
|
+
* node .agent/scripts/lint_runner.js . --files src/index.ts src/utils.ts
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const { spawnSync } = require('child_process');
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
RED, GREEN, YELLOW, BLUE, BOLD, DIM, CYAN, RESET,
|
|
19
|
+
banner, sectionHeader, summaryTable, timer, formatMs,
|
|
20
|
+
ok, fail, skip,
|
|
21
|
+
} = require('./_colors');
|
|
22
|
+
|
|
23
|
+
const RESULTS = [];
|
|
24
|
+
|
|
25
|
+
function runLinter(label, cmd, cwd) {
|
|
26
|
+
const elapsed = timer();
|
|
27
|
+
try {
|
|
28
|
+
const executable = process.platform === 'win32' && cmd[0] === 'npx' ? 'npx.cmd' : cmd[0];
|
|
29
|
+
const result = spawnSync(executable, cmd.slice(1), {
|
|
30
|
+
cwd,
|
|
31
|
+
encoding: 'utf8',
|
|
32
|
+
timeout: 120000,
|
|
33
|
+
shell: process.platform === 'win32'
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const ms = elapsed();
|
|
37
|
+
if (result.status === 0) {
|
|
38
|
+
ok(`${label} — clean ${DIM}(${formatMs(ms)})${RESET}`);
|
|
39
|
+
RESULTS.push({ name: label, status: 'pass', ms });
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fail(`${label} — issues found ${DIM}(${formatMs(ms)})${RESET}`);
|
|
44
|
+
RESULTS.push({ name: label, status: 'fail', ms });
|
|
45
|
+
if (result.error) {
|
|
46
|
+
console.log(` Error: ${result.error.message}`);
|
|
47
|
+
}
|
|
48
|
+
const out = result.stdout ? result.stdout.toString() : '';
|
|
49
|
+
const err = result.stderr ? result.stderr.toString() : '';
|
|
50
|
+
const output = (out + "\n" + err).trim();
|
|
51
|
+
if (output) {
|
|
52
|
+
const lines = output.split('\n');
|
|
53
|
+
for (const line of lines.slice(0, 15)) {
|
|
54
|
+
console.log(` ${line}`);
|
|
55
|
+
}
|
|
56
|
+
if (lines.length > 15) {
|
|
57
|
+
console.log(` ... and ${lines.length - 15} more lines`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
} catch {
|
|
62
|
+
skip(`${label} — tool not installed`);
|
|
63
|
+
RESULTS.push({ name: label, status: 'skip' });
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function detectLinters(projectRoot) {
|
|
69
|
+
const available = {};
|
|
70
|
+
const pkgJson = path.join(projectRoot, "package.json");
|
|
71
|
+
|
|
72
|
+
if (fs.existsSync(pkgJson)) {
|
|
73
|
+
const eslintFiles = [".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml", "eslint.config.js", "eslint.config.mjs"];
|
|
74
|
+
available.eslint = eslintFiles.some(f => fs.existsSync(path.join(projectRoot, f)));
|
|
75
|
+
|
|
76
|
+
const prettierFiles = [".prettierrc", ".prettierrc.js", ".prettierrc.json", "prettier.config.js"];
|
|
77
|
+
available.prettier = prettierFiles.some(f => fs.existsSync(path.join(projectRoot, f)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
available.ruff = fs.existsSync(path.join(projectRoot, "pyproject.toml")) || fs.existsSync(path.join(projectRoot, "ruff.toml"));
|
|
81
|
+
available.flake8 = fs.existsSync(path.join(projectRoot, ".flake8")) || fs.existsSync(path.join(projectRoot, "setup.cfg"));
|
|
82
|
+
|
|
83
|
+
return available;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function main() {
|
|
87
|
+
const args = process.argv.slice(2);
|
|
88
|
+
let targetPath = null;
|
|
89
|
+
let fixFlag = false;
|
|
90
|
+
let fileArgs = [];
|
|
91
|
+
|
|
92
|
+
let i = 0;
|
|
93
|
+
while (i < args.length) {
|
|
94
|
+
if (args[i] === '--fix') fixFlag = true;
|
|
95
|
+
else if (args[i] === '--files') {
|
|
96
|
+
i++;
|
|
97
|
+
while (i < args.length && !args[i].startsWith('--')) {
|
|
98
|
+
fileArgs.push(args[i++]);
|
|
99
|
+
}
|
|
100
|
+
continue;
|
|
101
|
+
} else if (!targetPath && !args[i].startsWith('-')) {
|
|
102
|
+
targetPath = args[i];
|
|
103
|
+
}
|
|
104
|
+
i++;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!targetPath) {
|
|
108
|
+
console.log("Usage: node lint_runner.js <path> [--fix] [--files <file1> <file2> ...]");
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const projectRoot = path.resolve(targetPath);
|
|
113
|
+
if (!fs.existsSync(projectRoot) || !fs.statSync(projectRoot).isDirectory()) {
|
|
114
|
+
fail(`Directory not found: ${projectRoot}`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
console.log(banner('lint_runner.js', { Project: projectRoot, Mode: fixFlag ? 'fix' : 'check' }));
|
|
119
|
+
|
|
120
|
+
const available = detectLinters(projectRoot);
|
|
121
|
+
if (!Object.values(available).some(Boolean)) {
|
|
122
|
+
skip("No linter configuration detected in this project");
|
|
123
|
+
process.exit(0);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
RESULTS.length = 0;
|
|
127
|
+
let failures = 0;
|
|
128
|
+
|
|
129
|
+
if (available.eslint) {
|
|
130
|
+
console.log(sectionHeader('ESLint'));
|
|
131
|
+
const cmd = ["npx", "eslint"];
|
|
132
|
+
if (fixFlag) cmd.push("--fix");
|
|
133
|
+
if (fileArgs.length) cmd.push(...fileArgs);
|
|
134
|
+
else cmd.push(".", "--max-warnings=0");
|
|
135
|
+
if (!runLinter("ESLint", cmd, projectRoot)) failures++;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (available.prettier) {
|
|
139
|
+
console.log(sectionHeader('Prettier'));
|
|
140
|
+
const cmd = ["npx", "prettier"];
|
|
141
|
+
if (fixFlag) cmd.push("--write");
|
|
142
|
+
else cmd.push("--check");
|
|
143
|
+
if (fileArgs.length) cmd.push(...fileArgs);
|
|
144
|
+
else cmd.push(".");
|
|
145
|
+
if (!runLinter("Prettier", cmd, projectRoot)) failures++;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (available.ruff) {
|
|
149
|
+
console.log(sectionHeader('Ruff (Python)'));
|
|
150
|
+
const cmd = ["ruff", "check"];
|
|
151
|
+
if (fixFlag) cmd.push("--fix");
|
|
152
|
+
if (fileArgs.length) cmd.push(...fileArgs);
|
|
153
|
+
else cmd.push(".");
|
|
154
|
+
if (!runLinter("Ruff", cmd, projectRoot)) failures++;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (available.flake8 && !available.ruff) {
|
|
158
|
+
console.log(sectionHeader('Flake8 (Python)'));
|
|
159
|
+
const cmd = ["flake8"];
|
|
160
|
+
if (fileArgs.length) cmd.push(...fileArgs);
|
|
161
|
+
else cmd.push(".");
|
|
162
|
+
if (!runLinter("Flake8", cmd, projectRoot)) failures++;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (fs.existsSync(path.join(projectRoot, "tsconfig.json"))) {
|
|
166
|
+
console.log(sectionHeader('TypeScript'));
|
|
167
|
+
if (!runLinter("TypeScript", ["npx", "tsc", "--noEmit"], projectRoot)) failures++;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
console.log(`\n${BOLD}${CYAN}━━━ Lint Summary ━━━${RESET}`);
|
|
171
|
+
if (RESULTS.length > 0) {
|
|
172
|
+
summaryTable(RESULTS);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (failures === 0) {
|
|
176
|
+
console.log(`\n${GREEN}${BOLD} ✔ All linters passed.${RESET}\n`);
|
|
177
|
+
} else {
|
|
178
|
+
console.log(`\n${RED}${BOLD} ✖ ${failures} linter(s) reported issues.${RESET}\n`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
process.exit(failures > 0 ? 1 : 0);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (require.main === module) {
|
|
185
|
+
main();
|
|
186
|
+
}
|
|
@@ -13,27 +13,10 @@
|
|
|
13
13
|
const fs = require('fs');
|
|
14
14
|
const path = require('path');
|
|
15
15
|
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function ok(msg) {
|
|
23
|
-
console.log(` ${GREEN}✅ ${msg}${RESET}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function fail(msg) {
|
|
27
|
-
console.log(` ${RED}❌ ${msg}${RESET}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function warn(msg) {
|
|
31
|
-
console.log(` ${YELLOW}⚠️ ${msg}${RESET}`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function skip(msg) {
|
|
35
|
-
console.log(` ${YELLOW}⏭️ ${msg}${RESET}`);
|
|
36
|
-
}
|
|
16
|
+
const {
|
|
17
|
+
RED, GREEN, YELLOW, BLUE, BOLD, DIM, CYAN, RESET,
|
|
18
|
+
sectionHeader: header, ok, fail, warn, skip,
|
|
19
|
+
} = require('./_colors');
|
|
37
20
|
|
|
38
21
|
function detectOrm(projectRoot) {
|
|
39
22
|
if (fs.existsSync(path.join(projectRoot, "prisma", "schema.prisma"))) {
|
|
@@ -221,7 +204,7 @@ function main() {
|
|
|
221
204
|
let issuesCount = 0;
|
|
222
205
|
|
|
223
206
|
if (fileArg) {
|
|
224
|
-
header(`Validating: ${fileArg}`);
|
|
207
|
+
console.log(header(`Validating: ${fileArg}`));
|
|
225
208
|
const filepath = path.isAbsolute(fileArg) ? fileArg : path.join(projectRoot, fileArg);
|
|
226
209
|
let issues = [];
|
|
227
210
|
if (filepath.endsWith(".prisma")) issues = validatePrisma(filepath);
|
|
@@ -239,7 +222,7 @@ function main() {
|
|
|
239
222
|
} else if (ormType === "prisma") {
|
|
240
223
|
const schemaPath = path.join(projectRoot, "prisma", "schema.prisma");
|
|
241
224
|
if (fs.existsSync(schemaPath)) {
|
|
242
|
-
header("Prisma Schema Validation");
|
|
225
|
+
console.log(header("Prisma Schema Validation"));
|
|
243
226
|
const issues = validatePrisma(schemaPath);
|
|
244
227
|
for (const [severity, message, line] of issues) {
|
|
245
228
|
if (severity === "error") { fail(`L${line}: ${message}`); issuesCount++; }
|
|
@@ -250,7 +233,7 @@ function main() {
|
|
|
250
233
|
skip(`Prisma schema not found at ${schemaPath}`);
|
|
251
234
|
}
|
|
252
235
|
} else if (ormType === "sql") {
|
|
253
|
-
header("SQL Migration Validation");
|
|
236
|
+
console.log(header("SQL Migration Validation"));
|
|
254
237
|
// Very basic recursion for migrations dir
|
|
255
238
|
function findMigrations(dir) {
|
|
256
239
|
let res = [];
|
|
@@ -281,7 +264,7 @@ function main() {
|
|
|
281
264
|
}
|
|
282
265
|
}
|
|
283
266
|
} else if (ormType === "drizzle") {
|
|
284
|
-
header("Drizzle Schema");
|
|
267
|
+
console.log(header("Drizzle Schema"));
|
|
285
268
|
skip("Drizzle validation not yet implemented — validate manually");
|
|
286
269
|
}
|
|
287
270
|
|