@hamak/smart-data-dico 1.9.0 → 1.9.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/backend/dist/validate.mjs +10559 -0
- package/bin/cli.js +44 -1
- package/package.json +2 -2
package/bin/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { dirname, join, resolve } from 'node:path';
|
|
5
5
|
import { existsSync, mkdirSync, cpSync, writeFileSync } from 'fs';
|
|
6
|
-
import { spawn } from 'child_process';
|
|
6
|
+
import { spawn, spawnSync } from 'child_process';
|
|
7
7
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = dirname(__filename);
|
|
@@ -16,6 +16,10 @@ for (let i = 0; i < args.length; i++) {
|
|
|
16
16
|
if (args[i] === '--port' && args[i + 1]) { flags.port = args[++i]; }
|
|
17
17
|
else if (args[i] === '--data-dir' && args[i + 1]) { flags.dataDir = args[++i]; }
|
|
18
18
|
else if (args[i] === '--no-open') { flags.noOpen = true; }
|
|
19
|
+
else if (args[i] === '--validate') {
|
|
20
|
+
// `--validate [folder]` — folder is optional; defaults to the data dir.
|
|
21
|
+
flags.validate = (args[i + 1] && !args[i + 1].startsWith('-')) ? args[++i] : true;
|
|
22
|
+
}
|
|
19
23
|
else if (args[i] === '--help' || args[i] === '-h') { flags.help = true; }
|
|
20
24
|
}
|
|
21
25
|
|
|
@@ -30,6 +34,8 @@ if (flags.help) {
|
|
|
30
34
|
Options:
|
|
31
35
|
--port <number> Server port (default: 3001)
|
|
32
36
|
--data-dir <path> Data directory path (default: ./data-dictionaries)
|
|
37
|
+
--validate [path] Validate a project folder and exit (no server).
|
|
38
|
+
Defaults to the data dir. Exit code 1 on errors.
|
|
33
39
|
--no-open Don't open browser automatically
|
|
34
40
|
-h, --help Show this help
|
|
35
41
|
|
|
@@ -37,10 +43,47 @@ if (flags.help) {
|
|
|
37
43
|
smart-data-dico
|
|
38
44
|
smart-data-dico --port 4000
|
|
39
45
|
smart-data-dico --data-dir ~/my-dictionaries
|
|
46
|
+
smart-data-dico --validate ./my-project
|
|
47
|
+
npx @hamak/smart-data-dico --validate ./my-project
|
|
40
48
|
`);
|
|
41
49
|
process.exit(0);
|
|
42
50
|
}
|
|
43
51
|
|
|
52
|
+
// --validate: run the standalone project validator and exit (no server).
|
|
53
|
+
// Mirrors the server's bundled/source dual-mode resolution below.
|
|
54
|
+
if (flags.validate !== undefined) {
|
|
55
|
+
const folder = resolve(
|
|
56
|
+
typeof flags.validate === 'string'
|
|
57
|
+
? flags.validate
|
|
58
|
+
: (flags.dataDir || process.env.DATA_DIR || './data-dictionaries'),
|
|
59
|
+
);
|
|
60
|
+
const bundledValidator = join(PKG_ROOT, 'backend', 'dist', 'validate.mjs');
|
|
61
|
+
const sourceValidator = join(PKG_ROOT, 'backend', 'src', 'scripts', 'validateDico.ts');
|
|
62
|
+
|
|
63
|
+
let vbin, vargs;
|
|
64
|
+
if (existsSync(bundledValidator)) {
|
|
65
|
+
vbin = process.execPath; // node — bundle has all deps inlined
|
|
66
|
+
vargs = [bundledValidator, '--data-dir', folder];
|
|
67
|
+
} else if (existsSync(sourceValidator)) {
|
|
68
|
+
const tsx = [
|
|
69
|
+
join(PKG_ROOT, 'node_modules', '.bin', 'tsx'),
|
|
70
|
+
join(PKG_ROOT, 'backend', 'node_modules', '.bin', 'tsx'),
|
|
71
|
+
].find(p => existsSync(p));
|
|
72
|
+
vbin = tsx || 'npx';
|
|
73
|
+
vargs = tsx ? [sourceValidator, '--data-dir', folder] : ['tsx', sourceValidator, '--data-dir', folder];
|
|
74
|
+
} else {
|
|
75
|
+
console.error('Error: validator not found (neither bundled nor source).');
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const r = spawnSync(vbin, vargs, { cwd: PKG_ROOT, stdio: 'inherit', env: process.env });
|
|
80
|
+
if (r.error) {
|
|
81
|
+
console.error('Failed to run validator:', r.error.message);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
process.exit(r.status ?? 0);
|
|
85
|
+
}
|
|
86
|
+
|
|
44
87
|
const port = flags.port || process.env.PORT || '3001';
|
|
45
88
|
const dataDir = resolve(flags.dataDir || process.env.DATA_DIR || './data-dictionaries');
|
|
46
89
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hamak/smart-data-dico",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Collaborative data dictionary management system — model, document, and govern your data landscape",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
|
38
|
-
"url": "https://github.com/amah/smart-data-dico.git"
|
|
38
|
+
"url": "git+https://github.com/amah/smart-data-dico.git"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@ai-sdk/anthropic": "^3.0.64",
|