@dataparade/cli 0.0.20 → 0.0.21
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/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/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
|
@@ -1,61 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const run_upload_1 = require("../../../src/upload/run-upload");
|
|
4
|
-
jest.mock(
|
|
4
|
+
jest.mock('../../../src/platform-api/upload-client', () => ({
|
|
5
5
|
cliUploadAnonymousPreview: jest.fn(),
|
|
6
6
|
cliUploadPreview: jest.fn(),
|
|
7
7
|
}));
|
|
8
|
-
jest.mock(
|
|
8
|
+
jest.mock('../../../src/platform-api/telemetry-client', () => ({
|
|
9
9
|
reportCliUsageEvent: jest.fn().mockResolvedValue(undefined),
|
|
10
10
|
}));
|
|
11
|
-
jest.mock(
|
|
11
|
+
jest.mock('../../../src/upload/build-preview-url', () => ({
|
|
12
12
|
buildAnonymousCliPreviewUrl: jest.fn((token) => `https://app.example/preview/cli/${token}`),
|
|
13
13
|
buildImportPreviewUrl: jest.fn((draftId) => `https://app.example/dashboard?importDraft=${draftId}`),
|
|
14
14
|
}));
|
|
15
15
|
const upload_client_1 = require("../../../src/platform-api/upload-client");
|
|
16
16
|
const telemetry_client_1 = require("../../../src/platform-api/telemetry-client");
|
|
17
|
-
describe(
|
|
18
|
-
const logSpy = jest.spyOn(console,
|
|
17
|
+
describe('runDataflowUpload anonymous path', () => {
|
|
18
|
+
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
19
19
|
afterEach(() => {
|
|
20
20
|
jest.clearAllMocks();
|
|
21
21
|
});
|
|
22
22
|
afterAll(() => {
|
|
23
23
|
logSpy.mockRestore();
|
|
24
24
|
});
|
|
25
|
-
it(
|
|
25
|
+
it('passes scanJobId to anonymous upload and mentions claim quota', async () => {
|
|
26
26
|
upload_client_1.cliUploadAnonymousPreview.mockResolvedValue({
|
|
27
|
-
claimToken:
|
|
27
|
+
claimToken: 'claim-1',
|
|
28
28
|
expiresAt: new Date().toISOString(),
|
|
29
|
-
projectName:
|
|
29
|
+
projectName: 'Proj',
|
|
30
30
|
});
|
|
31
31
|
const result = await (0, run_upload_1.runDataflowUpload)({
|
|
32
|
-
dataflow: { schemaVersion:
|
|
33
|
-
projectName:
|
|
34
|
-
scanJobId:
|
|
35
|
-
logPrefix:
|
|
32
|
+
dataflow: { schemaVersion: '1.0' },
|
|
33
|
+
projectName: 'Proj',
|
|
34
|
+
scanJobId: 'job-anon-1',
|
|
35
|
+
logPrefix: '[scan]',
|
|
36
36
|
});
|
|
37
37
|
expect(upload_client_1.cliUploadAnonymousPreview).toHaveBeenCalledWith({
|
|
38
|
-
dataflow: { schemaVersion:
|
|
39
|
-
projectName:
|
|
40
|
-
scanJobId:
|
|
38
|
+
dataflow: { schemaVersion: '1.0' },
|
|
39
|
+
projectName: 'Proj',
|
|
40
|
+
scanJobId: 'job-anon-1',
|
|
41
41
|
cliUsageSessionId: undefined,
|
|
42
|
-
command:
|
|
42
|
+
command: 'scan',
|
|
43
43
|
});
|
|
44
44
|
expect(upload_client_1.cliUploadPreview).not.toHaveBeenCalled();
|
|
45
|
-
expect(result.previewUrl).toContain(
|
|
46
|
-
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining(
|
|
47
|
-
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining(
|
|
45
|
+
expect(result.previewUrl).toContain('claim-1');
|
|
46
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('[scan] Preview ready:'));
|
|
47
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining(result.previewUrl));
|
|
48
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('You can view the diagram now. Claiming it to your account uses 1 scan slot'));
|
|
49
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('platform AI tokens'));
|
|
48
50
|
});
|
|
49
|
-
it(
|
|
50
|
-
upload_client_1.cliUploadAnonymousPreview.mockRejectedValue(new Error(
|
|
51
|
+
it('reports upload_failed and rethrows', async () => {
|
|
52
|
+
upload_client_1.cliUploadAnonymousPreview.mockRejectedValue(new Error('network down'));
|
|
51
53
|
await expect((0, run_upload_1.runDataflowUpload)({
|
|
52
|
-
dataflow: { schemaVersion:
|
|
53
|
-
cliUsageSessionId:
|
|
54
|
-
logPrefix:
|
|
55
|
-
})).rejects.toThrow(
|
|
54
|
+
dataflow: { schemaVersion: '1.0' },
|
|
55
|
+
cliUsageSessionId: '11111111-1111-4111-8111-111111111111',
|
|
56
|
+
logPrefix: '[scan]',
|
|
57
|
+
})).rejects.toThrow('network down');
|
|
56
58
|
expect(telemetry_client_1.reportCliUsageEvent).toHaveBeenCalledWith(expect.objectContaining({
|
|
57
|
-
event:
|
|
58
|
-
errorCode:
|
|
59
|
+
event: 'upload_failed',
|
|
60
|
+
errorCode: 'upload_failed',
|
|
59
61
|
}));
|
|
60
62
|
});
|
|
61
63
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataparade/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "dataPARADE CLI — scan codebases for privacy and security data flows",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"eval:models": "pnpm exec node dist/src/evals/run-model-matrix.js"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
+
"@clack/prompts": "^1.8.1",
|
|
57
58
|
"@dataparade/scanner": "github:DataParade-io/scanner#e66e1bcaef55b61214d170c617df529bd300fc89",
|
|
58
59
|
"@sentry/node": "^10.38.0",
|
|
59
60
|
"commander": "^12.1.0",
|