@vertaaux/cli 0.4.0 → 0.5.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/CHANGELOG.md +116 -0
- package/MIGRATION.md +239 -0
- package/README.md +62 -17
- package/dist/app/interactive-app.d.ts +103 -0
- package/dist/app/interactive-app.d.ts.map +1 -0
- package/dist/app/interactive-app.js +328 -0
- package/dist/app/layout/canvas.d.ts +23 -0
- package/dist/app/layout/canvas.d.ts.map +1 -0
- package/dist/app/layout/canvas.js +36 -0
- package/dist/app/layout/footer.d.ts +31 -0
- package/dist/app/layout/footer.d.ts.map +1 -0
- package/dist/app/layout/footer.js +41 -0
- package/dist/app/layout/header.d.ts +20 -0
- package/dist/app/layout/header.d.ts.map +1 -0
- package/dist/app/layout/header.js +27 -0
- package/dist/app/menu/categories.d.ts +20 -0
- package/dist/app/menu/categories.d.ts.map +1 -0
- package/dist/app/menu/categories.js +166 -0
- package/dist/app/menu/filter.d.ts +17 -0
- package/dist/app/menu/filter.d.ts.map +1 -0
- package/dist/app/menu/filter.js +33 -0
- package/dist/app/menu/menu-view.d.ts +35 -0
- package/dist/app/menu/menu-view.d.ts.map +1 -0
- package/dist/app/menu/menu-view.js +230 -0
- package/dist/app/menu/recent.d.ts +24 -0
- package/dist/app/menu/recent.d.ts.map +1 -0
- package/dist/app/menu/recent.js +49 -0
- package/dist/app/types.d.ts +43 -0
- package/dist/app/types.d.ts.map +1 -0
- package/dist/app/types.js +7 -0
- package/dist/app/views/command-runner.d.ts +36 -0
- package/dist/app/views/command-runner.d.ts.map +1 -0
- package/dist/app/views/command-runner.js +415 -0
- package/dist/app/views/help-overlay.d.ts +21 -0
- package/dist/app/views/help-overlay.d.ts.map +1 -0
- package/dist/app/views/help-overlay.js +46 -0
- package/dist/auth/ci-token.d.ts +8 -2
- package/dist/auth/ci-token.d.ts.map +1 -1
- package/dist/auth/ci-token.js +15 -30
- package/dist/auth/device-flow.d.ts +2 -1
- package/dist/auth/device-flow.d.ts.map +1 -1
- package/dist/auth/device-flow.js +13 -10
- package/dist/auth/token-store.d.ts.map +1 -1
- package/dist/auth/token-store.js +12 -2
- package/dist/baseline/diff.d.ts +2 -2
- package/dist/baseline/diff.d.ts.map +1 -1
- package/dist/baseline/diff.js +15 -34
- package/dist/commands/a11y.d.ts +11 -0
- package/dist/commands/a11y.d.ts.map +1 -0
- package/dist/commands/a11y.js +149 -0
- package/dist/commands/audit/artifacts.d.ts +27 -0
- package/dist/commands/audit/artifacts.d.ts.map +1 -0
- package/dist/commands/audit/artifacts.js +158 -0
- package/dist/commands/audit/ci-detection.d.ts +18 -0
- package/dist/commands/audit/ci-detection.d.ts.map +1 -0
- package/dist/commands/audit/ci-detection.js +71 -0
- package/dist/commands/audit/explain.d.ts +11 -0
- package/dist/commands/audit/explain.d.ts.map +1 -0
- package/dist/commands/audit/explain.js +45 -0
- package/dist/commands/audit/filters.d.ts +17 -0
- package/dist/commands/audit/filters.d.ts.map +1 -0
- package/dist/commands/audit/filters.js +40 -0
- package/dist/commands/audit/index.d.ts +18 -0
- package/dist/commands/audit/index.d.ts.map +1 -0
- package/dist/commands/audit/index.js +589 -0
- package/dist/commands/audit/output.d.ts +32 -0
- package/dist/commands/audit/output.d.ts.map +1 -0
- package/dist/commands/audit/output.js +129 -0
- package/dist/commands/audit/policy.d.ts +27 -0
- package/dist/commands/audit/policy.d.ts.map +1 -0
- package/dist/commands/audit/policy.js +147 -0
- package/dist/commands/audit/scoring.d.ts +23 -0
- package/dist/commands/audit/scoring.d.ts.map +1 -0
- package/dist/commands/audit/scoring.js +70 -0
- package/dist/commands/audit/types.d.ts +89 -0
- package/dist/commands/audit/types.d.ts.map +1 -0
- package/dist/commands/audit/types.js +8 -0
- package/dist/commands/audit.d.ts +2 -60
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +2 -1097
- package/dist/commands/baseline.d.ts +2 -0
- package/dist/commands/baseline.d.ts.map +1 -1
- package/dist/commands/baseline.js +221 -123
- package/dist/commands/comment.d.ts +22 -0
- package/dist/commands/comment.d.ts.map +1 -1
- package/dist/commands/comment.js +127 -62
- package/dist/commands/compare.d.ts +17 -0
- package/dist/commands/compare.d.ts.map +1 -1
- package/dist/commands/compare.js +288 -181
- package/dist/commands/diff.d.ts +7 -0
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +181 -143
- package/dist/commands/doc.d.ts +10 -0
- package/dist/commands/doc.d.ts.map +1 -1
- package/dist/commands/doc.js +135 -77
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +166 -19
- package/dist/commands/download.d.ts +10 -0
- package/dist/commands/download.d.ts.map +1 -1
- package/dist/commands/download.js +169 -112
- package/dist/commands/explain.d.ts +5 -0
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +242 -156
- package/dist/commands/fix-all.d.ts +25 -0
- package/dist/commands/fix-all.d.ts.map +1 -0
- package/dist/commands/fix-all.js +206 -0
- package/dist/commands/fix-plan.d.ts +9 -0
- package/dist/commands/fix-plan.d.ts.map +1 -1
- package/dist/commands/fix-plan.js +154 -90
- package/dist/commands/fix.d.ts +17 -0
- package/dist/commands/fix.d.ts.map +1 -0
- package/dist/commands/fix.js +111 -0
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +94 -42
- package/dist/commands/login.d.ts +18 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +263 -92
- package/dist/commands/patch-review.d.ts +11 -0
- package/dist/commands/patch-review.d.ts.map +1 -1
- package/dist/commands/patch-review.js +160 -98
- package/dist/commands/policy.d.ts +31 -0
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js +270 -125
- package/dist/commands/release-notes.d.ts +10 -0
- package/dist/commands/release-notes.d.ts.map +1 -1
- package/dist/commands/release-notes.js +128 -74
- package/dist/commands/scan.d.ts +13 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +133 -0
- package/dist/commands/status.d.ts +9 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +81 -0
- package/dist/commands/suggest.d.ts +10 -0
- package/dist/commands/suggest.d.ts.map +1 -1
- package/dist/commands/suggest.js +180 -83
- package/dist/commands/triage.d.ts +35 -0
- package/dist/commands/triage.d.ts.map +1 -1
- package/dist/commands/triage.js +207 -82
- package/dist/commands/upload.d.ts +9 -0
- package/dist/commands/upload.d.ts.map +1 -1
- package/dist/commands/upload.js +140 -101
- package/dist/commands/verify.d.ts +13 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +118 -0
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +127 -991
- package/dist/interactive/fix-wizard.d.ts +3 -0
- package/dist/interactive/fix-wizard.d.ts.map +1 -1
- package/dist/interactive/fix-wizard.js +130 -112
- package/dist/interactive/init-wizard.d.ts +3 -1
- package/dist/interactive/init-wizard.d.ts.map +1 -1
- package/dist/interactive/init-wizard.js +207 -138
- package/dist/interactive/prompts.d.ts +7 -3
- package/dist/interactive/prompts.d.ts.map +1 -1
- package/dist/interactive/prompts.js +44 -23
- package/dist/output/envelope.d.ts +9 -0
- package/dist/output/envelope.d.ts.map +1 -1
- package/dist/output/envelope.js +37 -3
- package/dist/output/factory.d.ts +2 -1
- package/dist/output/factory.d.ts.map +1 -1
- package/dist/output/html.d.ts +2 -1
- package/dist/output/html.d.ts.map +1 -1
- package/dist/output/html.js +3 -2
- package/dist/output/human.d.ts +2 -1
- package/dist/output/human.d.ts.map +1 -1
- package/dist/output/human.js +3 -2
- package/dist/output/json.d.ts +2 -1
- package/dist/output/json.d.ts.map +1 -1
- package/dist/output/junit.d.ts +2 -1
- package/dist/output/junit.d.ts.map +1 -1
- package/dist/output/sarif.d.ts +2 -1
- package/dist/output/sarif.d.ts.map +1 -1
- package/dist/policy/schema.d.ts +137 -0
- package/dist/policy/schema.d.ts.map +1 -1
- package/dist/policy/schema.js +107 -0
- package/dist/prompts/command-catalog.js +9 -9
- package/dist/types.d.ts +74 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/ui/banner.d.ts +34 -0
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +97 -5
- package/dist/ui/diagnostics.d.ts +9 -4
- package/dist/ui/diagnostics.d.ts.map +1 -1
- package/dist/ui/diagnostics.js +32 -82
- package/dist/ui/strings.d.ts +373 -0
- package/dist/ui/strings.d.ts.map +1 -0
- package/dist/ui/strings.js +499 -0
- package/dist/ui/table.d.ts +0 -2
- package/dist/ui/table.d.ts.map +1 -1
- package/dist/ui/table.js +3 -4
- package/dist/utils/api-client.d.ts +46 -0
- package/dist/utils/api-client.d.ts.map +1 -0
- package/dist/utils/api-client.js +170 -0
- package/dist/utils/client.d.ts +29 -18
- package/dist/utils/client.d.ts.map +1 -1
- package/dist/utils/client.js +104 -12
- package/dist/utils/formatters.d.ts +38 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +277 -0
- package/dist/utils/root-args.d.ts +12 -0
- package/dist/utils/root-args.d.ts.map +1 -0
- package/dist/utils/root-args.js +44 -0
- package/dist/utils/stdin.d.ts +7 -0
- package/dist/utils/stdin.d.ts.map +1 -1
- package/dist/utils/stdin.js +32 -2
- package/dist/utils/url-classify.d.ts.map +1 -1
- package/dist/utils/url-classify.js +24 -3
- package/node_modules/@vertaaux/tui/dist/index.cjs +1216 -27
- package/node_modules/@vertaaux/tui/dist/index.cjs.map +1 -1
- package/node_modules/@vertaaux/tui/dist/index.d.cts +361 -4
- package/node_modules/@vertaaux/tui/dist/index.d.ts +361 -4
- package/node_modules/@vertaaux/tui/dist/index.js +1189 -27
- package/node_modules/@vertaaux/tui/dist/index.js.map +1 -1
- package/node_modules/@vertaaux/tui/package.json +2 -3
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +83 -0
- package/node_modules/chalk/readme.md +297 -0
- package/node_modules/chalk/source/index.d.ts +325 -0
- package/node_modules/chalk/source/index.js +225 -0
- package/node_modules/chalk/source/utilities.js +33 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/package.json +20 -5
- package/dist/commands/client.d.ts +0 -14
- package/dist/commands/client.d.ts.map +0 -1
- package/dist/commands/client.js +0 -362
- package/dist/commands/drift.d.ts +0 -15
- package/dist/commands/drift.d.ts.map +0 -1
- package/dist/commands/drift.js +0 -309
- package/dist/commands/protect.d.ts +0 -16
- package/dist/commands/protect.d.ts.map +0 -1
- package/dist/commands/protect.js +0 -323
- package/dist/commands/report.d.ts +0 -15
- package/dist/commands/report.d.ts.map +0 -1
- package/dist/commands/report.js +0 -214
- package/dist/policy/sync.d.ts +0 -67
- package/dist/policy/sync.d.ts.map +0 -1
- package/dist/policy/sync.js +0 -147
package/dist/commands/comment.js
CHANGED
|
@@ -7,13 +7,16 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import fs from "fs";
|
|
9
9
|
import path from "path";
|
|
10
|
+
import { renderError, runSteps, createRenderer } from "@vertaaux/tui";
|
|
10
11
|
import { loadBaseline } from "../baseline/manager.js";
|
|
11
12
|
import { ExitCode } from "../utils/exit-codes.js";
|
|
12
13
|
import { formatMarkdownComment, categorizeIssuesForComment, } from "../output/markdown.js";
|
|
13
|
-
import { createEnvelope, writeJsonOutput, writeOutput } from "../output/envelope.js";
|
|
14
|
+
import { createEnvelope, writeDataOutput, writeJsonOutput, writeOutput } from "../output/envelope.js";
|
|
14
15
|
import { resolveCommandFormat } from "../output/formats.js";
|
|
15
16
|
import { postOrUpdateGitHubComment, parseRepository, extractPRNumber, } from "../ci/github-api.js";
|
|
16
17
|
import { postOrUpdateGitLabNote, getGitLabConfig, extractMRIid, } from "../ci/gitlab-api.js";
|
|
18
|
+
import { strings } from "../ui/strings.js";
|
|
19
|
+
import { unwrapJsonEnvelope } from "../utils/stdin.js";
|
|
17
20
|
/**
|
|
18
21
|
* Default path for latest audit results.
|
|
19
22
|
*/
|
|
@@ -126,18 +129,37 @@ async function postComment(context, markdown) {
|
|
|
126
129
|
/**
|
|
127
130
|
* Handle the comment command.
|
|
128
131
|
*/
|
|
129
|
-
async function handleComment(options) {
|
|
132
|
+
export async function handleComment(options) {
|
|
133
|
+
const renderer = createRenderer("auto");
|
|
134
|
+
const baseState = {
|
|
135
|
+
phase: "comment",
|
|
136
|
+
phaseIndex: 1,
|
|
137
|
+
phaseTotal: 1,
|
|
138
|
+
url: "",
|
|
139
|
+
mode: "comment",
|
|
140
|
+
progress: {},
|
|
141
|
+
totals: {},
|
|
142
|
+
issueCount: 0,
|
|
143
|
+
scorePreview: null,
|
|
144
|
+
verbose: false,
|
|
145
|
+
elapsed: 0,
|
|
146
|
+
};
|
|
147
|
+
const startTime = Date.now();
|
|
130
148
|
let auditResult;
|
|
131
|
-
// Load audit results
|
|
149
|
+
// Load audit results (pre-step, may need async iteration for stdin)
|
|
132
150
|
if (options.input) {
|
|
133
151
|
// From file
|
|
134
152
|
const inputPath = path.resolve(process.cwd(), options.input);
|
|
135
153
|
if (!fs.existsSync(inputPath)) {
|
|
136
|
-
|
|
154
|
+
process.stderr.write(renderError({
|
|
155
|
+
message: `Input file not found: ${options.input}`,
|
|
156
|
+
suggestion: "vertaa audit <url>",
|
|
157
|
+
exitCode: ExitCode.ERROR,
|
|
158
|
+
}) + "\n");
|
|
137
159
|
process.exit(ExitCode.ERROR);
|
|
138
160
|
}
|
|
139
161
|
const content = fs.readFileSync(inputPath, "utf-8");
|
|
140
|
-
auditResult = JSON.parse(content);
|
|
162
|
+
auditResult = unwrapJsonEnvelope(JSON.parse(content));
|
|
141
163
|
}
|
|
142
164
|
else if (!process.stdin.isTTY) {
|
|
143
165
|
// From stdin
|
|
@@ -146,17 +168,21 @@ async function handleComment(options) {
|
|
|
146
168
|
chunks.push(chunk);
|
|
147
169
|
}
|
|
148
170
|
const content = Buffer.concat(chunks).toString("utf-8");
|
|
149
|
-
auditResult = JSON.parse(content);
|
|
171
|
+
auditResult = unwrapJsonEnvelope(JSON.parse(content));
|
|
150
172
|
}
|
|
151
173
|
else {
|
|
152
174
|
// Try latest audit file
|
|
153
175
|
const latestPath = path.resolve(process.cwd(), LATEST_AUDIT_PATH);
|
|
154
176
|
if (fs.existsSync(latestPath)) {
|
|
155
177
|
const content = fs.readFileSync(latestPath, "utf-8");
|
|
156
|
-
auditResult = JSON.parse(content);
|
|
178
|
+
auditResult = unwrapJsonEnvelope(JSON.parse(content));
|
|
157
179
|
}
|
|
158
180
|
else {
|
|
159
|
-
|
|
181
|
+
process.stderr.write(renderError({
|
|
182
|
+
message: strings.comment.errors.noInput,
|
|
183
|
+
suggestion: "vertaa audit <url>",
|
|
184
|
+
exitCode: ExitCode.ERROR,
|
|
185
|
+
}) + "\n");
|
|
160
186
|
process.exit(ExitCode.ERROR);
|
|
161
187
|
}
|
|
162
188
|
}
|
|
@@ -169,58 +195,85 @@ async function handleComment(options) {
|
|
|
169
195
|
// Try default baseline
|
|
170
196
|
baseline = await loadBaseline();
|
|
171
197
|
}
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
// Build comment data
|
|
176
|
-
const commentData = {
|
|
177
|
-
auditId: auditResult.job_id,
|
|
178
|
-
url: auditResult.url,
|
|
179
|
-
newIssues,
|
|
180
|
-
fixedIssues,
|
|
181
|
-
existingIssues,
|
|
182
|
-
scores: auditResult.scores,
|
|
183
|
-
};
|
|
184
|
-
// Generate output
|
|
198
|
+
// State to capture within steps
|
|
199
|
+
let outputContent = "";
|
|
200
|
+
let jsonData = {};
|
|
185
201
|
const isJson = options.format === "json";
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
202
|
+
const steps = [
|
|
203
|
+
{
|
|
204
|
+
id: "generate",
|
|
205
|
+
actionText: "Generating review comment...",
|
|
206
|
+
summaryText: "Comment generated",
|
|
207
|
+
run: async () => {
|
|
208
|
+
// Categorize issues
|
|
209
|
+
const issues = normalizeIssues(auditResult.issues);
|
|
210
|
+
const { newIssues, fixedIssues, existingIssues } = categorizeIssuesForComment(issues, baseline);
|
|
211
|
+
// Build comment data
|
|
212
|
+
const commentData = {
|
|
213
|
+
auditId: auditResult.job_id,
|
|
214
|
+
url: auditResult.url,
|
|
215
|
+
newIssues,
|
|
216
|
+
fixedIssues,
|
|
217
|
+
existingIssues,
|
|
218
|
+
scores: auditResult.scores,
|
|
219
|
+
};
|
|
220
|
+
jsonData = {
|
|
221
|
+
auditId: auditResult.job_id,
|
|
222
|
+
url: auditResult.url,
|
|
223
|
+
newIssues: newIssues.length,
|
|
224
|
+
existingIssues: existingIssues.length,
|
|
225
|
+
fixedIssues: fixedIssues.length,
|
|
226
|
+
issues: {
|
|
227
|
+
new: newIssues,
|
|
228
|
+
existing: existingIssues,
|
|
229
|
+
fixed: fixedIssues,
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
if (isJson) {
|
|
233
|
+
outputContent = JSON.stringify(jsonData, null, 2);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
outputContent = formatMarkdownComment(commentData, {
|
|
237
|
+
groupBy: options.groupBy || "severity",
|
|
238
|
+
collapse: options.collapse ?? newIssues.length > 3,
|
|
239
|
+
collapseThreshold: 3,
|
|
240
|
+
includeEvidence: true,
|
|
241
|
+
includeFixes: true,
|
|
242
|
+
baseUrl: "https://vertaaux.ai",
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
},
|
|
196
246
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (
|
|
200
|
-
//
|
|
201
|
-
output = JSON.stringify(jsonData, null, 2);
|
|
247
|
+
];
|
|
248
|
+
// Check if posting and we should skip
|
|
249
|
+
if (options.post && options.noPostIfClean) {
|
|
250
|
+
// We need to generate first to check, so we still run the step
|
|
202
251
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
252
|
+
const { success, states } = await runSteps(steps, {
|
|
253
|
+
failFast: true,
|
|
254
|
+
onStateChange: (stepStates) => {
|
|
255
|
+
renderer.update({ ...baseState, stepStates, elapsed: Date.now() - startTime });
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
renderer.finish({ url: "", mode: "comment", overallScore: 0, scores: {}, issueCount: 0, passed: success, elapsed: Date.now() - startTime });
|
|
259
|
+
if (!success) {
|
|
260
|
+
const failed = states.find(s => s.status === "failed");
|
|
261
|
+
process.stderr.write(renderError({
|
|
262
|
+
message: failed?.failReason || "Command failed",
|
|
263
|
+
suggestion: "vertaa doctor",
|
|
264
|
+
}) + "\n");
|
|
265
|
+
process.exitCode = ExitCode.ERROR;
|
|
213
266
|
}
|
|
214
267
|
// Handle posting
|
|
215
268
|
if (options.post) {
|
|
269
|
+
const newIssuesCount = jsonData.newIssues ?? 0;
|
|
216
270
|
// Check if we should skip posting
|
|
217
|
-
if (options.noPostIfClean &&
|
|
218
|
-
console.error("No new issues found. Skipping comment post (--no-post-if-clean).");
|
|
271
|
+
if (options.noPostIfClean && newIssuesCount === 0) {
|
|
219
272
|
// Still write output if requested
|
|
220
273
|
if (options.output) {
|
|
221
274
|
const outputPath = path.resolve(process.cwd(), options.output);
|
|
222
|
-
fs.writeFileSync(outputPath,
|
|
223
|
-
|
|
275
|
+
fs.writeFileSync(outputPath, outputContent, "utf-8");
|
|
276
|
+
writeOutput(`Comment written to: ${outputPath}`);
|
|
224
277
|
}
|
|
225
278
|
return;
|
|
226
279
|
}
|
|
@@ -264,30 +317,38 @@ async function handleComment(options) {
|
|
|
264
317
|
context = detectCIContext();
|
|
265
318
|
}
|
|
266
319
|
if (!context) {
|
|
267
|
-
|
|
268
|
-
|
|
320
|
+
process.stderr.write(renderError({
|
|
321
|
+
message: "Cannot post comment — not in a recognized CI environment.",
|
|
322
|
+
context: "Provide --github-token with --repo and --pr, or run in GitHub Actions/GitLab CI.",
|
|
323
|
+
suggestion: "vertaa comment --github-token <token> --repo owner/repo --pr <number>",
|
|
324
|
+
exitCode: ExitCode.ERROR,
|
|
325
|
+
}) + "\n");
|
|
269
326
|
// Output for debugging via stdout
|
|
270
327
|
if (isJson) {
|
|
271
328
|
writeJsonOutput(jsonData, "comment");
|
|
272
329
|
}
|
|
273
330
|
else {
|
|
274
|
-
|
|
331
|
+
writeDataOutput(outputContent);
|
|
275
332
|
}
|
|
276
333
|
process.exit(ExitCode.ERROR);
|
|
277
334
|
}
|
|
278
335
|
try {
|
|
279
|
-
const result = await postComment(context,
|
|
280
|
-
|
|
336
|
+
const result = await postComment(context, outputContent);
|
|
337
|
+
writeOutput(`Comment posted: ${result.url}`);
|
|
281
338
|
}
|
|
282
339
|
catch (error) {
|
|
283
|
-
|
|
340
|
+
process.stderr.write(renderError({
|
|
341
|
+
message: `Error posting comment: ${error instanceof Error ? error.message : String(error)}`,
|
|
342
|
+
context: "Generated output written for debugging.",
|
|
343
|
+
suggestion: "vertaa comment --github-token <token> --repo owner/repo --pr <number>",
|
|
344
|
+
exitCode: ExitCode.ERROR,
|
|
345
|
+
}) + "\n");
|
|
284
346
|
// Output for debugging even on failure
|
|
285
|
-
console.error("\nGenerated output (for debugging):");
|
|
286
347
|
if (isJson) {
|
|
287
348
|
writeJsonOutput(jsonData, "comment");
|
|
288
349
|
}
|
|
289
350
|
else {
|
|
290
|
-
|
|
351
|
+
writeDataOutput(outputContent);
|
|
291
352
|
}
|
|
292
353
|
process.exit(ExitCode.ERROR);
|
|
293
354
|
}
|
|
@@ -297,9 +358,9 @@ async function handleComment(options) {
|
|
|
297
358
|
const outputPath = path.resolve(process.cwd(), options.output);
|
|
298
359
|
const fileContent = isJson
|
|
299
360
|
? JSON.stringify(createEnvelope(jsonData, "comment"), null, 2)
|
|
300
|
-
:
|
|
361
|
+
: outputContent;
|
|
301
362
|
fs.writeFileSync(outputPath, fileContent, "utf-8");
|
|
302
|
-
|
|
363
|
+
writeOutput(`Comment written to: ${outputPath}`);
|
|
303
364
|
}
|
|
304
365
|
else if (!options.post) {
|
|
305
366
|
// Only print to stdout if not posting (posting already logs URL)
|
|
@@ -307,7 +368,7 @@ async function handleComment(options) {
|
|
|
307
368
|
writeJsonOutput(jsonData, "comment");
|
|
308
369
|
}
|
|
309
370
|
else {
|
|
310
|
-
|
|
371
|
+
writeDataOutput(outputContent);
|
|
311
372
|
}
|
|
312
373
|
}
|
|
313
374
|
}
|
|
@@ -354,7 +415,11 @@ export function registerCommentCommand(program) {
|
|
|
354
415
|
});
|
|
355
416
|
}
|
|
356
417
|
catch (error) {
|
|
357
|
-
|
|
418
|
+
process.stderr.write(renderError({
|
|
419
|
+
message: error instanceof Error ? error.message : String(error),
|
|
420
|
+
suggestion: "vertaa audit <url>",
|
|
421
|
+
exitCode: ExitCode.ERROR,
|
|
422
|
+
}) + "\n");
|
|
358
423
|
process.exit(ExitCode.ERROR);
|
|
359
424
|
}
|
|
360
425
|
});
|
|
@@ -16,5 +16,22 @@
|
|
|
16
16
|
* vertaa compare --before baseline.json --after current.json --verbose
|
|
17
17
|
*/
|
|
18
18
|
import { Command } from "commander";
|
|
19
|
+
export interface CompareCommandOptions {
|
|
20
|
+
urlA?: string;
|
|
21
|
+
urlB?: string;
|
|
22
|
+
before?: string;
|
|
23
|
+
after?: string;
|
|
24
|
+
mode?: string;
|
|
25
|
+
wait?: boolean;
|
|
26
|
+
timeout?: string;
|
|
27
|
+
interval?: string;
|
|
28
|
+
failOnScore?: string;
|
|
29
|
+
format?: string;
|
|
30
|
+
base?: string;
|
|
31
|
+
verbose?: boolean;
|
|
32
|
+
machine?: boolean;
|
|
33
|
+
apiKey?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function handleCompare(opts: CompareCommandOptions): Promise<void>;
|
|
19
36
|
export declare function registerCompareCommand(program: Command): void;
|
|
20
37
|
//# sourceMappingURL=compare.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/commands/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/commands/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6MpC,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmR9E;AAMD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuE7D"}
|