@dataparade/cli 0.0.20 → 0.0.22
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 +12 -10
- package/dist/package.json +2 -1
- package/dist/src/ai-enrichment/agent-orchestrator.d.ts +8 -2
- package/dist/src/ai-enrichment/agent-orchestrator.js +140 -70
- package/dist/src/ai-enrichment/provider-prompt.js +36 -2
- package/dist/src/cli.js +98 -51
- package/dist/src/config/scan-env.d.ts +5 -0
- package/dist/src/config/scan-env.js +12 -1
- package/dist/src/core/pipeline/scan-pipeline.d.ts +2 -1
- package/dist/src/core/pipeline/scan-pipeline.js +7 -4
- package/dist/src/ui/brand.d.ts +28 -0
- package/dist/src/ui/brand.js +72 -0
- package/dist/src/ui/scan-progress-renderer.d.ts +69 -0
- package/dist/src/ui/scan-progress-renderer.js +386 -0
- package/dist/src/ui/teaching-lines.d.ts +9 -0
- package/dist/src/ui/teaching-lines.js +144 -0
- package/dist/src/ui/types.d.ts +33 -0
- package/dist/src/ui/types.js +2 -0
- package/dist/src/upload/run-upload.d.ts +1 -1
- package/dist/src/upload/run-upload.js +21 -16
- package/dist/src/upload/types.d.ts +4 -0
- package/dist/tests/cli/cli.spec.js +77 -40
- package/dist/tests/unit/ai-enrichment/agent-orchestrator.spec.js +227 -147
- package/dist/tests/unit/ai-enrichment/provider-prompt.spec.js +35 -0
- package/dist/tests/unit/cli/scan-quota-flow.spec.js +9 -0
- package/dist/tests/unit/config/scan-env-debug.spec.js +17 -8
- package/dist/tests/unit/ui/brand.spec.d.ts +1 -0
- package/dist/tests/unit/ui/brand.spec.js +52 -0
- package/dist/tests/unit/ui/scan-progress-renderer.spec.d.ts +1 -0
- package/dist/tests/unit/ui/scan-progress-renderer.spec.js +275 -0
- package/dist/tests/unit/ui/teaching-lines.spec.d.ts +1 -0
- package/dist/tests/unit/ui/teaching-lines.spec.js +62 -0
- package/dist/tests/unit/upload/run-upload.spec.js +29 -27
- package/package.json +2 -1
|
@@ -6,96 +6,133 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const child_process_1 = require("child_process");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const cliDistPath = path_1.default.join(__dirname,
|
|
10
|
-
const cliCwd = path_1.default.join(__dirname,
|
|
11
|
-
const scanFixturePath = path_1.default.join(cliCwd,
|
|
12
|
-
describe(
|
|
9
|
+
const cliDistPath = path_1.default.join(__dirname, '../../dist/bin/cli.js');
|
|
10
|
+
const cliCwd = path_1.default.join(__dirname, '../../');
|
|
11
|
+
const scanFixturePath = path_1.default.join(cliCwd, 'tests/fixtures/typescript-basic');
|
|
12
|
+
describe('CLI', () => {
|
|
13
13
|
beforeAll(() => {
|
|
14
14
|
if (!(0, fs_1.existsSync)(cliDistPath)) {
|
|
15
15
|
throw new Error(`CLI not built. Run 'pnpm build' first. Expected: ${cliDistPath}`);
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
it(
|
|
19
|
-
const result = (0, child_process_1.spawnSync)(
|
|
18
|
+
it('scan <path> writes a dataflow.json wrapper to the current directory and exits 0', () => {
|
|
19
|
+
const result = (0, child_process_1.spawnSync)('node', [
|
|
20
20
|
cliDistPath,
|
|
21
|
-
|
|
21
|
+
'scan',
|
|
22
22
|
scanFixturePath,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
'--no-ai-inference',
|
|
24
|
+
'--skip-auto-upload',
|
|
25
25
|
], {
|
|
26
|
-
encoding:
|
|
26
|
+
encoding: 'utf-8',
|
|
27
27
|
cwd: cliCwd,
|
|
28
28
|
});
|
|
29
29
|
expect(result.status).toBe(0);
|
|
30
|
-
const outputPath = path_1.default.join(cliCwd,
|
|
30
|
+
const outputPath = path_1.default.join(cliCwd, 'dataflow.json');
|
|
31
31
|
const exists = (0, fs_1.existsSync)(outputPath);
|
|
32
32
|
expect(exists).toBe(true);
|
|
33
|
-
const contents = (0, fs_1.readFileSync)(outputPath,
|
|
33
|
+
const contents = (0, fs_1.readFileSync)(outputPath, 'utf8').trim();
|
|
34
34
|
const dataflow = JSON.parse(contents);
|
|
35
35
|
expect(dataflow.schemaVersion).toBeDefined();
|
|
36
36
|
expect(dataflow.graph).toBeDefined();
|
|
37
37
|
expect(Array.isArray(dataflow.graph.nodes)).toBe(true);
|
|
38
38
|
expect(Array.isArray(dataflow.graph.edges)).toBe(true);
|
|
39
39
|
});
|
|
40
|
-
it(
|
|
41
|
-
const result = (0, child_process_1.spawnSync)(
|
|
40
|
+
it('scan fixture produces a dataflow.json wrapper with at least one node', () => {
|
|
41
|
+
const result = (0, child_process_1.spawnSync)('node', [
|
|
42
42
|
cliDistPath,
|
|
43
|
-
|
|
43
|
+
'scan',
|
|
44
44
|
scanFixturePath,
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
'--no-ai-inference',
|
|
46
|
+
'--skip-auto-upload',
|
|
47
47
|
], {
|
|
48
|
-
encoding:
|
|
48
|
+
encoding: 'utf-8',
|
|
49
49
|
cwd: cliCwd,
|
|
50
50
|
});
|
|
51
51
|
expect(result.status).toBe(0);
|
|
52
|
-
const outputPath = path_1.default.join(cliCwd,
|
|
53
|
-
const contents = (0, fs_1.readFileSync)(outputPath,
|
|
52
|
+
const outputPath = path_1.default.join(cliCwd, 'dataflow.json');
|
|
53
|
+
const contents = (0, fs_1.readFileSync)(outputPath, 'utf8').trim();
|
|
54
54
|
const dataflow = JSON.parse(contents);
|
|
55
55
|
expect(Array.isArray(dataflow.graph.nodes)).toBe(true);
|
|
56
56
|
expect(dataflow.graph.nodes.length).toBeGreaterThan(0);
|
|
57
57
|
});
|
|
58
|
-
it(
|
|
59
|
-
const outputFile =
|
|
60
|
-
const result = (0, child_process_1.spawnSync)(
|
|
58
|
+
it('scan fixture --output writes a dataflow.json wrapper to the given file and prints a short message', () => {
|
|
59
|
+
const outputFile = 'scan-fixture-summary.json';
|
|
60
|
+
const result = (0, child_process_1.spawnSync)('node', [
|
|
61
61
|
cliDistPath,
|
|
62
|
-
|
|
62
|
+
'scan',
|
|
63
63
|
scanFixturePath,
|
|
64
|
-
|
|
64
|
+
'--output',
|
|
65
65
|
outputFile,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
'--no-ai-inference',
|
|
67
|
+
'--skip-auto-upload',
|
|
68
68
|
], {
|
|
69
|
-
encoding:
|
|
69
|
+
encoding: 'utf-8',
|
|
70
70
|
cwd: cliCwd,
|
|
71
71
|
});
|
|
72
72
|
expect(result.status).toBe(0);
|
|
73
73
|
expect(result.stdout).toContain(`[scan] dataflow.json written to ${path_1.default.join(cliCwd, outputFile)}`);
|
|
74
|
-
const fileContents = (0, fs_1.readFileSync)(path_1.default.join(cliCwd, outputFile),
|
|
74
|
+
const fileContents = (0, fs_1.readFileSync)(path_1.default.join(cliCwd, outputFile), 'utf8').trim();
|
|
75
75
|
const dataflow = JSON.parse(fileContents);
|
|
76
76
|
expect(dataflow.graph).toBeDefined();
|
|
77
77
|
expect(Array.isArray(dataflow.graph.nodes)).toBe(true);
|
|
78
78
|
});
|
|
79
|
-
it(
|
|
80
|
-
const
|
|
81
|
-
|
|
79
|
+
it('scan mixed-language fixture prints teaching lines before dataflow.json written', () => {
|
|
80
|
+
const teachingFixture = path_1.default.join(cliCwd, 'tests/fixtures/mixed-language-basic');
|
|
81
|
+
const outputFile = 'scan-teaching-progress.json';
|
|
82
|
+
const result = (0, child_process_1.spawnSync)('node', [
|
|
83
|
+
cliDistPath,
|
|
84
|
+
'scan',
|
|
85
|
+
teachingFixture,
|
|
86
|
+
'--output',
|
|
87
|
+
outputFile,
|
|
88
|
+
'--no-ai-inference',
|
|
89
|
+
'--skip-auto-upload',
|
|
90
|
+
], {
|
|
91
|
+
encoding: 'utf-8',
|
|
92
|
+
cwd: cliCwd,
|
|
93
|
+
env: {
|
|
94
|
+
...process.env,
|
|
95
|
+
// Force plain progress (no spinner/ANSI) for stable assertions.
|
|
96
|
+
NO_COLOR: '1',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
expect(result.status).toBe(0);
|
|
100
|
+
const writtenMarker = `[scan] dataflow.json written to ${path_1.default.join(cliCwd, outputFile)}`;
|
|
101
|
+
expect(result.stdout).toContain(writtenMarker);
|
|
102
|
+
const beforeWrite = result.stdout.split(writtenMarker)[0] ?? '';
|
|
103
|
+
expect(beforeWrite).toMatch(/Map privacy data flows from your code/);
|
|
104
|
+
const teachingHits = [
|
|
105
|
+
/Found \d+ .+ routes?/i,
|
|
106
|
+
/Talks to /i,
|
|
107
|
+
/Calls out to /i,
|
|
108
|
+
/Stripe|OpenAI|Sentry|Postgres|Express|FastAPI/i,
|
|
109
|
+
].filter((re) => re.test(beforeWrite));
|
|
110
|
+
expect(teachingHits.length).toBeGreaterThanOrEqual(2);
|
|
111
|
+
// Non-TTY / NO_COLOR: no ANSI escape codes and no braille spinner frames.
|
|
112
|
+
// eslint-disable-next-line no-control-regex -- asserting absence of ESC CSI sequences
|
|
113
|
+
expect(result.stdout).not.toMatch(/\x1b\[[0-9;]*m/);
|
|
114
|
+
expect(result.stdout).not.toMatch(/[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]/);
|
|
115
|
+
});
|
|
116
|
+
it('unknown command shows usage and exits non-zero', () => {
|
|
117
|
+
const result = (0, child_process_1.spawnSync)('node', [cliDistPath, 'unknowncommand'], {
|
|
118
|
+
encoding: 'utf-8',
|
|
82
119
|
cwd: cliCwd,
|
|
83
120
|
});
|
|
84
121
|
expect(result.status).not.toBe(0);
|
|
85
122
|
expect(result.stderr).toMatch(/Unknown command|error|usage|Usage/i);
|
|
86
123
|
});
|
|
87
|
-
it(
|
|
88
|
-
const result = (0, child_process_1.spawnSync)(
|
|
89
|
-
encoding:
|
|
124
|
+
it('--help shows usage', () => {
|
|
125
|
+
const result = (0, child_process_1.spawnSync)('node', [cliDistPath, '--help'], {
|
|
126
|
+
encoding: 'utf-8',
|
|
90
127
|
cwd: cliCwd,
|
|
91
128
|
});
|
|
92
129
|
expect(result.status).toBe(0);
|
|
93
|
-
expect(result.stdout).toContain(
|
|
94
|
-
expect(result.stdout).toContain(
|
|
130
|
+
expect(result.stdout).toContain('dataparade');
|
|
131
|
+
expect(result.stdout).toContain('scan');
|
|
95
132
|
});
|
|
96
|
-
it(
|
|
97
|
-
const result = (0, child_process_1.spawnSync)(
|
|
98
|
-
encoding:
|
|
133
|
+
it('scan --help shows scan usage', () => {
|
|
134
|
+
const result = (0, child_process_1.spawnSync)('node', [cliDistPath, 'scan', '--help'], {
|
|
135
|
+
encoding: 'utf-8',
|
|
99
136
|
cwd: cliCwd,
|
|
100
137
|
});
|
|
101
138
|
expect(result.status).toBe(0);
|