@dataparade/cli 0.0.33 → 0.0.34
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/dist/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Command } from
|
|
2
|
-
import { type ToolStamps } from
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { type ToolStamps } from './run-diff';
|
|
3
3
|
/** Hidden for now (DATAP-852): compares two Git revisions of one repository. */
|
|
4
4
|
export declare function registerDiffCommand(program: Command, tools: () => ToolStamps): void;
|
|
@@ -10,38 +10,51 @@ const path_1 = __importDefault(require("path"));
|
|
|
10
10
|
const kb_compare_1 = require("../../vendor/kb-compare/dist/src/index.js");
|
|
11
11
|
const scan_env_1 = require("../config/scan-env");
|
|
12
12
|
const run_diff_1 = require("./run-diff");
|
|
13
|
+
const build_preview_url_1 = require("../upload/build-preview-url");
|
|
13
14
|
const upload_diff_1 = require("./upload-diff");
|
|
14
15
|
/** Scans a folder by running this CLI's own `scan` command, with AI off and no upload. */
|
|
15
16
|
function scanWithThisCli() {
|
|
16
17
|
const entry = process.argv[1];
|
|
17
18
|
return (dir, outDir) => {
|
|
18
19
|
try {
|
|
19
|
-
(0, child_process_1.execFileSync)(process.execPath, [
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
(0, child_process_1.execFileSync)(process.execPath, [
|
|
21
|
+
entry,
|
|
22
|
+
'scan',
|
|
23
|
+
dir,
|
|
24
|
+
'--no-ai-inference',
|
|
25
|
+
'-o',
|
|
26
|
+
path_1.default.join(outDir, 'dataflow.json'),
|
|
27
|
+
], {
|
|
28
|
+
env: {
|
|
29
|
+
...process.env,
|
|
30
|
+
DATAPARADE_SKIP_AUTO_UPLOAD: '1',
|
|
31
|
+
SCAN_AI_INFERENCE: 'false',
|
|
32
|
+
},
|
|
33
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
22
34
|
maxBuffer: 64 * 1024 * 1024,
|
|
23
35
|
});
|
|
24
|
-
return JSON.parse(fs_1.default.readFileSync(path_1.default.join(outDir,
|
|
36
|
+
return JSON.parse(fs_1.default.readFileSync(path_1.default.join(outDir, 'facts.json'), 'utf8'));
|
|
25
37
|
}
|
|
26
38
|
catch (error) {
|
|
27
39
|
const stderr = error.stderr?.toString().trim();
|
|
28
|
-
throw new run_diff_1.DiffError(
|
|
40
|
+
throw new run_diff_1.DiffError('SCAN_FAILED', `The scan of ${dir} failed${stderr ? `:\n${stderr.split('\n').slice(-5).join('\n')}` : '.'}`);
|
|
29
41
|
}
|
|
30
42
|
};
|
|
31
43
|
}
|
|
32
44
|
/** Hidden for now (DATAP-852): compares two Git revisions of one repository. */
|
|
33
45
|
function registerDiffCommand(program, tools) {
|
|
34
46
|
program
|
|
35
|
-
.command(
|
|
36
|
-
.description(
|
|
37
|
-
.option(
|
|
38
|
-
.option(
|
|
39
|
-
.option(
|
|
40
|
-
.option(
|
|
47
|
+
.command('diff <repo> <base> <head>', { hidden: true })
|
|
48
|
+
.description('Compare two Git revisions of a repository and write the change set (AI off)')
|
|
49
|
+
.option('-o, --output <dir>', 'Folder for change-set.json, summary.txt and renames.json', 'dataparade-diff')
|
|
50
|
+
.option('--no-cache', 'Scan both revisions again instead of reusing cached scans')
|
|
51
|
+
.option('--upload', 'Upload both scans, the rename map and the root commit, so the backend compares them (needs a workspace API key)')
|
|
52
|
+
.option('--workspace-api-key <key>', 'DataParade workspace API key for --upload (env: DATAPARADE_WORKSPACE_API_KEY)')
|
|
41
53
|
.action(async (repo, base, head, options) => {
|
|
42
|
-
const apiKey = options.workspaceApiKey?.trim() ||
|
|
54
|
+
const apiKey = options.workspaceApiKey?.trim() ||
|
|
55
|
+
(0, scan_env_1.resolveWorkspaceApiKey)(process.env);
|
|
43
56
|
if (options.upload && !apiKey) {
|
|
44
|
-
console.error(
|
|
57
|
+
console.error('--upload needs a workspace API key: pass --workspace-api-key or set DATAPARADE_WORKSPACE_API_KEY.');
|
|
45
58
|
process.exitCode = 1;
|
|
46
59
|
return;
|
|
47
60
|
}
|
|
@@ -61,8 +74,14 @@ function registerDiffCommand(program, tools) {
|
|
|
61
74
|
console.log(result.summary);
|
|
62
75
|
console.log(`\nWrote ${result.files.changeSet}`);
|
|
63
76
|
if (options.upload) {
|
|
64
|
-
const uploaded = await (0, upload_diff_1.uploadDiffScans)({
|
|
77
|
+
const uploaded = await (0, upload_diff_1.uploadDiffScans)({
|
|
78
|
+
apiKey: apiKey,
|
|
79
|
+
repo,
|
|
80
|
+
result,
|
|
81
|
+
log: (line) => console.error(line),
|
|
82
|
+
});
|
|
65
83
|
console.log((0, upload_diff_1.describeUploadedComparison)(uploaded));
|
|
84
|
+
console.log(`Open the head scan: ${(0, build_preview_url_1.buildImportPreviewUrl)(uploaded.head.draftId, undefined, uploaded.head.appUrl)}`);
|
|
66
85
|
}
|
|
67
86
|
}
|
|
68
87
|
catch (error) {
|
|
@@ -73,7 +92,8 @@ function registerDiffCommand(program, tools) {
|
|
|
73
92
|
return;
|
|
74
93
|
}
|
|
75
94
|
console.error(error instanceof Error ? error.message : String(error));
|
|
76
|
-
process.exitCode =
|
|
95
|
+
process.exitCode =
|
|
96
|
+
error instanceof run_diff_1.DiffError && error.code === 'DIRTY_TREE' ? 2 : 1;
|
|
77
97
|
}
|
|
78
98
|
});
|
|
79
99
|
}
|