@argos-ci/cli 5.1.2 → 6.0.0

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.
Files changed (2) hide show
  1. package/dist/index.mjs +715 -233
  2. package/package.json +8 -7
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { resolve } from "node:path";
4
4
  import { Option, program } from "commander";
5
5
  import { deploy, finalize, skip, upload } from "@argos-ci/core";
6
6
  import ora from "ora";
7
- import { createClient, formatAPIError, throwAPIError } from "@argos-ci/api-client";
7
+ import { APIError, createClient, throwAPIError } from "@argos-ci/api-client";
8
8
  import { homedir } from "node:os";
9
9
  import { createServer } from "node:http";
10
10
  import { createHash, randomBytes } from "node:crypto";
@@ -14,10 +14,12 @@ const parallelNonceOption = new Option("--parallel-nonce <string>", "A unique ID
14
14
  const tokenOption = new Option("--token <token>", "Repository token").env("ARGOS_TOKEN");
15
15
  const projectOption = new Option("--project <slug>", "Argos project slug (account/project), used to disambiguate tokenless authentication when multiple projects are linked to the same repository").env("ARGOS_PROJECT");
16
16
  const buildNameOption = new Option("--build-name <string>", "Name of the build, in case you want to run multiple Argos builds in a single CI job").env("ARGOS_BUILD_NAME");
17
+ const jsonOption = new Option("--json", "Output machine-readable JSON instead of human-readable text");
18
+ const projectPathOption = new Option("--project <owner/project>", "Project path in owner/project format. Required for build-number references on review and comment commands").env("ARGOS_PROJECT");
17
19
  //#endregion
18
20
  //#region src/commands/upload.ts
19
21
  function uploadCommand(program) {
20
- program.command("upload").argument("<directory>", "Directory to upload").description("Upload screenshots to Argos").option("-f, --files <patterns...>", "One or more globs matching image file paths to upload", "**/*.{png,jpg,jpeg}").option("-i, --ignore <patterns...>", "One or more globs matching image file paths to ignore (ex: \"**/*.png **/diff.jpg\")").addOption(tokenOption).addOption(projectOption).addOption(buildNameOption).addOption(new Option("--mode <string>", "Mode of comparison applied. CI for visual regression testing, monitoring for visual monitoring.").default("ci").choices(["ci", "monitoring"]).env("ARGOS_MODE")).addOption(new Option("--parallel", "Enable parallel mode. Run multiple Argos builds and combine them at the end").env("ARGOS_PARALLEL")).addOption(new Option("--parallel-total <number>", "The number of parallel nodes being ran").env("ARGOS_PARALLEL_TOTAL")).addOption(parallelNonceOption).addOption(new Option("--parallel-index <number>", "The index of the parallel node being ran (must be at least 1)").env("ARGOS_PARALLEL_INDEX")).addOption(new Option("--reference-branch <string>", "Branch used as baseline for screenshot comparison").env("ARGOS_REFERENCE_BRANCH")).addOption(new Option("--reference-commit <string>", "Commit used as baseline for screenshot comparison").env("ARGOS_REFERENCE_COMMIT")).addOption(new Option("--threshold <number>", "Sensitivity threshold between 0 and 1. The higher the threshold, the less sensitive the diff will be. Default to 0.5").env("ARGOS_THRESHOLD")).addOption(new Option("--subset", "Whether this build contains only a subset of screenshots.\nThis is useful when a build is created from an incomplete test suite where some tests are skipped.").env("ARGOS_SUBSET")).action(async (directory, options) => {
22
+ program.command("upload").argument("<directory>", "Directory to upload").description("Upload screenshots to Argos").option("-f, --files <patterns...>", "One or more globs matching image file paths to upload", "**/*.{png,jpg,jpeg}").option("-i, --ignore <patterns...>", "One or more globs matching image file paths to ignore (ex: \"**/*.png **/diff.jpg\")").addOption(tokenOption).addOption(projectOption).addOption(buildNameOption).addOption(new Option("--mode <string>", "Mode of comparison applied. CI for visual regression testing, monitoring for visual monitoring.").default("ci").choices(["ci", "monitoring"]).env("ARGOS_MODE")).addOption(new Option("--parallel", "Enable parallel mode. Run multiple Argos builds and combine them at the end.\nCan also be set via the ARGOS_PARALLEL environment variable.")).addOption(new Option("--parallel-total <number>", "The number of parallel nodes being ran").env("ARGOS_PARALLEL_TOTAL")).addOption(parallelNonceOption).addOption(new Option("--parallel-index <number>", "The index of the parallel node being ran (must be at least 1)").env("ARGOS_PARALLEL_INDEX")).addOption(new Option("--reference-branch <string>", "Branch used as baseline for screenshot comparison").env("ARGOS_REFERENCE_BRANCH")).addOption(new Option("--reference-commit <string>", "Commit used as baseline for screenshot comparison").env("ARGOS_REFERENCE_COMMIT")).addOption(new Option("--threshold <number>", "Sensitivity threshold between 0 and 1. The higher the threshold, the less sensitive the diff will be. Default to 0.5").env("ARGOS_THRESHOLD")).addOption(new Option("--subset", "Whether this build contains only a subset of screenshots.\nThis is useful when a build is created from an incomplete test suite where some tests are skipped.\nCan also be set via the ARGOS_SUBSET environment variable.")).action(async (directory, options) => {
21
23
  const spinner = ora("Uploading screenshots").start();
22
24
  try {
23
25
  const parallel = (() => {
@@ -98,6 +100,187 @@ function skipCommand(program) {
98
100
  });
99
101
  }
100
102
  //#endregion
103
+ //#region src/lib/api.ts
104
+ /** Optional override for the API base URL (used in tests and dev). */
105
+ function getApiBaseUrl() {
106
+ return process.env["ARGOS_API_BASE_URL"];
107
+ }
108
+ /** Create an Argos API client authenticated with the given token. */
109
+ function createApiClient(authToken) {
110
+ return createClient({
111
+ authToken,
112
+ baseUrl: getApiBaseUrl()
113
+ });
114
+ }
115
+ /**
116
+ * Unwrap an `openapi-fetch` result, returning its data or throwing a formatted
117
+ * {@link APIError} when the request failed or returned an empty body.
118
+ */
119
+ function unwrap(result) {
120
+ if (!result.response.ok) throwAPIError(result.error, result.response);
121
+ if (result.data === void 0 || result.data === null) throw new APIError("Unexpected empty response from API.", { status: result.response.status });
122
+ return result.data;
123
+ }
124
+ //#endregion
125
+ //#region src/lib/format.ts
126
+ /** Render a scalar, using `-` for empty values. */
127
+ function formatValue(value) {
128
+ if (value === null || value === void 0 || value === "") return "-";
129
+ return String(value);
130
+ }
131
+ function formatUser(user) {
132
+ if (!user) return "-";
133
+ return user.name ? `${user.name} (@${user.slug})` : `@${user.slug}`;
134
+ }
135
+ function formatStats(stats) {
136
+ if (!stats) return "-";
137
+ return [
138
+ `total ${stats.total}`,
139
+ `changed ${stats.changed}`,
140
+ `added ${stats.added}`,
141
+ `removed ${stats.removed}`,
142
+ `unchanged ${stats.unchanged}`
143
+ ].join(", ");
144
+ }
145
+ const SNAPSHOT_STATUS_ORDER = [
146
+ "changed",
147
+ "added",
148
+ "removed",
149
+ "unchanged",
150
+ "ignored",
151
+ "pending",
152
+ "failure",
153
+ "retryFailure"
154
+ ];
155
+ function formatSnapshotSummary(diffs) {
156
+ const counts = /* @__PURE__ */ new Map();
157
+ for (const diff of diffs) counts.set(diff.status, (counts.get(diff.status) ?? 0) + 1);
158
+ return SNAPSHOT_STATUS_ORDER.map((status) => {
159
+ const count = counts.get(status);
160
+ return count ? `${status} ${count}` : null;
161
+ }).filter((part) => Boolean(part)).join(", ");
162
+ }
163
+ function formatBuild(build) {
164
+ return [
165
+ `Build #${build.number}`,
166
+ `Status: ${build.status}`,
167
+ `Snapshots: ${formatStats(build.stats)}`,
168
+ `Conclusion: ${formatValue(build.conclusion)}`,
169
+ `Branch: ${formatValue(build.head?.branch)}`,
170
+ `Commit: ${formatValue(build.head?.sha)}`,
171
+ `Base branch: ${formatValue(build.base?.branch)}`,
172
+ `Base commit: ${formatValue(build.base?.sha)}`,
173
+ `URL: ${build.url}`
174
+ ].join("\n");
175
+ }
176
+ function formatSnapshots(diffs, build) {
177
+ if (diffs.length === 0) return "No snapshots found.";
178
+ return [
179
+ `Snapshots for build #${build.number}`,
180
+ `Count: ${diffs.length}`,
181
+ `Summary: ${formatSnapshotSummary(diffs)}`,
182
+ "",
183
+ ...diffs.flatMap((diff) => [
184
+ `${diff.name} [${diff.status}]`,
185
+ ` Review: ${build.url}/${diff.id}`,
186
+ ` Mask: ${formatValue(diff.url)}`,
187
+ ` Base file: ${formatValue(diff.base?.url)}`,
188
+ ` Head file: ${formatValue(diff.head?.url)}`,
189
+ ` Score: ${formatValue(diff.score)}`,
190
+ ` Group: ${formatValue(diff.group)}`,
191
+ ""
192
+ ])
193
+ ].slice(0, -1).join("\n");
194
+ }
195
+ function formatReview(review) {
196
+ const lines = [
197
+ `Review #${review.id}`,
198
+ `State: ${review.state}`,
199
+ `Author: ${formatUser(review.user)}`,
200
+ `Date: ${review.date}`
201
+ ];
202
+ if (review.dismissedAt) lines.push(`Dismissed: ${review.dismissedAt} by ${formatUser(review.dismissedBy)}`);
203
+ return lines.join("\n");
204
+ }
205
+ function formatReviews(reviews) {
206
+ if (reviews.length === 0) return "No reviews found.";
207
+ return [
208
+ `Reviews (${reviews.length})`,
209
+ "",
210
+ ...reviews.flatMap((review) => [
211
+ `#${review.id} [${review.state}${review.dismissedAt ? ", dismissed" : ""}]`,
212
+ ` Author: ${formatUser(review.user)}`,
213
+ ` Date: ${review.date}`,
214
+ ""
215
+ ])
216
+ ].slice(0, -1).join("\n");
217
+ }
218
+ function indent(text) {
219
+ return text.split("\n").map((line) => ` ${line}`).join("\n");
220
+ }
221
+ function formatAnchor(anchor) {
222
+ if (!anchor) return null;
223
+ return anchor.type === "point" ? `point ${anchor.x},${anchor.y}` : `lines ${anchor.from}-${anchor.to}`;
224
+ }
225
+ function formatReactions(reactions) {
226
+ if (reactions.length === 0) return null;
227
+ return reactions.map((r) => `${r.emoji} ${r.count}`).join(" ");
228
+ }
229
+ function formatComment(comment) {
230
+ const lines = [`Comment #${comment.id}`, `Author: ${formatUser(comment.author)}`];
231
+ if (comment.threadId) lines.push(`Reply to: ${comment.threadId}`);
232
+ if (comment.screenshotDiffId) {
233
+ const anchor = formatAnchor(comment.anchor);
234
+ lines.push(`Diff: ${comment.screenshotDiffId}${anchor ? ` (${anchor})` : ""}`);
235
+ }
236
+ if (comment.pending) lines.push("Pending: draft (only visible to you)");
237
+ if (comment.resolvedAt) lines.push(`Resolved: ${comment.resolvedAt}`);
238
+ const reactions = formatReactions(comment.reactions);
239
+ if (reactions) lines.push(`Reactions: ${reactions}`);
240
+ lines.push(`Date: ${comment.createdAt}${comment.editedAt ? " (edited)" : ""}`);
241
+ lines.push("", indent(comment.text));
242
+ return lines.join("\n");
243
+ }
244
+ function formatComments(comments) {
245
+ if (comments.length === 0) return "No comments found.";
246
+ return [
247
+ `Comments (${comments.length})`,
248
+ "",
249
+ ...comments.flatMap((comment) => {
250
+ const tags = [
251
+ comment.threadId ? "reply" : "thread",
252
+ comment.pending ? "draft" : null,
253
+ comment.resolvedAt ? "resolved" : null
254
+ ].filter(Boolean);
255
+ return [
256
+ `#${comment.id} [${tags.join(", ")}] ${formatUser(comment.author)}`,
257
+ indent(comment.text),
258
+ ""
259
+ ];
260
+ })
261
+ ].slice(0, -1).join("\n");
262
+ }
263
+ //#endregion
264
+ //#region src/lib/cli-error.ts
265
+ /**
266
+ * Error whose message is meant to be shown to the user verbatim (prefixed with
267
+ * `Error: `) before the CLI exits with a non-zero code. Throw it — via
268
+ * {@link fail} — instead of calling `process.exit` directly so the failure can
269
+ * be unit-tested and handled in a single place ({@link handleCliError}).
270
+ */
271
+ var CliError = class extends Error {
272
+ constructor(message) {
273
+ super(message);
274
+ this.name = "CliError";
275
+ }
276
+ };
277
+ /**
278
+ * Abort the current command with a user-facing message.
279
+ */
280
+ function fail(message) {
281
+ throw new CliError(message);
282
+ }
283
+ //#endregion
101
284
  //#region src/auth.ts
102
285
  function getConfigPaths() {
103
286
  const configDir = resolve(homedir(), ".config", "argos-ci");
@@ -160,266 +343,558 @@ async function removeToken() {
160
343
  await writeConfig({});
161
344
  }
162
345
  //#endregion
163
- //#region src/commands/build.ts
164
- const reviewConclusions = {
165
- approve: "APPROVE",
166
- "request-changes": "REQUEST_CHANGES"
167
- };
168
- async function getTokenOrExit(options) {
169
- const token = options.token || process.env["ARGOS_TOKEN"] || await getStoredToken();
170
- if (!token) {
171
- console.error("Error: No Argos token found. Use --token, set ARGOS_TOKEN, or run `argos login`.");
172
- process.exit(1);
173
- }
174
- return token;
346
+ //#region src/lib/build-reference.ts
347
+ const BUILD_URL_REGEXP = /^https:\/\/app\.argos-ci\.(?:com|dev(?::\d+)?)\/(?<owner>[^/?#]+)\/(?<project>[^/?#]+)\/builds\/(?<buildNumber>\d+)(?:[/?#]|$)/;
348
+ /**
349
+ * Parse a build reference, accepting either a bare build number (`"1234"`) or a
350
+ * full Argos build URL. Returns `null` when the input is neither.
351
+ */
352
+ function parseBuildReference(reference) {
353
+ const asNumber = Number(reference);
354
+ if (Number.isInteger(asNumber) && asNumber > 0) return { buildNumber: asNumber };
355
+ const match = reference.match(BUILD_URL_REGEXP);
356
+ if (match?.groups) return {
357
+ owner: match.groups.owner,
358
+ project: match.groups.project,
359
+ buildNumber: Number(match.groups.buildNumber)
360
+ };
361
+ return null;
175
362
  }
176
- function getAPIBaseURL() {
177
- return process.env["ARGOS_API_BASE_URL"];
363
+ /**
364
+ * Like {@link parseBuildReference} but aborts the command with a clear message
365
+ * when the reference is invalid.
366
+ */
367
+ function parseBuildReferenceOrFail(reference) {
368
+ const parsed = parseBuildReference(reference);
369
+ if (!parsed) fail(`Build reference must be a valid build number or Argos build URL (https://app.argos-ci.com/.../builds/<number>), got "${reference}".`);
370
+ return parsed;
178
371
  }
179
- function getProjectTokenOrExit(options) {
180
- const projectToken = options.token || process.env["ARGOS_TOKEN"];
181
- if (!projectToken) {
182
- console.error("Error: No Argos project token found. Use --token or set ARGOS_TOKEN.");
183
- process.exit(1);
184
- }
185
- return projectToken;
372
+ //#endregion
373
+ //#region src/lib/project.ts
374
+ /**
375
+ * Parse a `owner/project` slug. Returns `null` when it is not exactly two
376
+ * non-empty segments.
377
+ */
378
+ function parseProjectPath(slug) {
379
+ const parts = slug.split("/");
380
+ if (parts.length !== 2 || !parts[0] || !parts[1]) return null;
381
+ return {
382
+ owner: parts[0],
383
+ project: parts[1]
384
+ };
186
385
  }
187
- function isBuildPending(build) {
188
- return build.status === "pending" || build.status === "progress";
386
+ /**
387
+ * Like {@link parseProjectPath} but aborts the command on an invalid slug.
388
+ */
389
+ function parseProjectPathOrFail(slug) {
390
+ const parsed = parseProjectPath(slug);
391
+ if (!parsed) fail("--project must be in the format 'owner/project'.");
392
+ return parsed;
189
393
  }
190
- function parseBuildReferenceDetailsOrExit(buildReference) {
191
- const parsedBuildNumber = Number(buildReference);
192
- if (Number.isFinite(parsedBuildNumber) && Number.isInteger(parsedBuildNumber)) return { buildNumber: parsedBuildNumber };
193
- const urlMatch = buildReference.match(/^https:\/\/app\.argos-ci\.(?:com|dev(?::\d+)?)\/(?<owner>[^/?#]+)\/(?<project>[^/?#]+)\/builds\/(?<buildNumber>\d+)(?:\/?$|[?#])/);
194
- if (urlMatch?.groups) return {
195
- owner: urlMatch.groups.owner,
196
- project: urlMatch.groups.project,
197
- buildNumber: Number(urlMatch.groups.buildNumber)
198
- };
199
- console.error(`Error: Build reference must be a valid build number or Argos build URL (https://app.argos-ci.com/.../builds/<number>), got "${buildReference}".`);
200
- process.exit(1);
394
+ //#endregion
395
+ //#region src/lib/target.ts
396
+ /**
397
+ * Resolve the API token, preferring an explicit token (`--token` /
398
+ * `ARGOS_TOKEN`) over the one stored by `argos login`.
399
+ */
400
+ async function resolveToken(options) {
401
+ const token = options.token || process.env["ARGOS_TOKEN"] || await getStoredToken();
402
+ if (!token) fail("No Argos token found. Use --token, set ARGOS_TOKEN, or run `argos login`.");
403
+ return token;
201
404
  }
202
- function formatValue(value) {
203
- if (value === null || value === void 0 || value === "") return "-";
204
- return String(value);
405
+ function explicitProjectPath(reference, options) {
406
+ if (reference.owner && reference.project) return {
407
+ owner: reference.owner,
408
+ project: reference.project
409
+ };
410
+ if (options.project) return parseProjectPathOrFail(options.project);
411
+ return null;
205
412
  }
206
- function formatStats(stats) {
207
- if (!stats) return "-";
208
- return [
209
- `total ${stats.total}`,
210
- `changed ${stats.changed}`,
211
- `added ${stats.added}`,
212
- `removed ${stats.removed}`,
213
- `unchanged ${stats.unchanged}`
214
- ].join(", ");
413
+ /**
414
+ * Resolve a build reference into a ready-to-use {@link BuildTarget}: an
415
+ * authenticated client and the `owner`, `project` and `buildNumber` needed by
416
+ * every build-scoped endpoint.
417
+ */
418
+ async function resolveBuildTarget(reference, options, { auth }) {
419
+ const parsed = parseBuildReferenceOrFail(reference);
420
+ const buildNumber = String(parsed.buildNumber);
421
+ const client = createApiClient(await resolveToken(options));
422
+ if (auth === "user") {
423
+ const projectPath = explicitProjectPath(parsed, options);
424
+ if (!projectPath) fail("--project <owner/project> is required for build-number references.");
425
+ return {
426
+ client,
427
+ ...projectPath,
428
+ buildNumber
429
+ };
430
+ }
431
+ const projectPath = explicitProjectPath(parsed, options);
432
+ if (projectPath) return {
433
+ client,
434
+ ...projectPath,
435
+ buildNumber
436
+ };
437
+ const project = unwrap(await client.GET("/project"));
438
+ return {
439
+ client,
440
+ owner: project.account.slug,
441
+ project: project.name,
442
+ buildNumber
443
+ };
215
444
  }
216
- function formatSnapshotSummary(diffs) {
217
- const counts = /* @__PURE__ */ new Map();
218
- for (const diff of diffs) counts.set(diff.status, (counts.get(diff.status) ?? 0) + 1);
219
- return [
220
- "changed",
221
- "added",
222
- "removed",
223
- "unchanged",
224
- "ignored",
225
- "pending",
226
- "failure",
227
- "retryFailure"
228
- ].map((status) => {
229
- const count = counts.get(status);
230
- return count ? `${status} ${count}` : null;
231
- }).filter((part) => Boolean(part)).join(", ");
445
+ //#endregion
446
+ //#region src/lib/run.ts
447
+ const USER_AUTH_HINT = "Ensure your token is a personal access token with access to this project. Project tokens (ARGOS_TOKEN in CI) can read build data but cannot perform review or comment actions.";
448
+ /**
449
+ * Print an error and exit. {@link CliError} and {@link APIError} messages are
450
+ * shown as-is; permission failures on user-authenticated commands get an extra
451
+ * hint about token types.
452
+ */
453
+ function handleCliError(error, auth) {
454
+ let message;
455
+ if (error instanceof CliError || error instanceof APIError) {
456
+ message = error.message;
457
+ if (auth === "user" && error instanceof APIError && (error.status === 401 || error.status === 403)) message += `\n${USER_AUTH_HINT}`;
458
+ } else if (error instanceof Error) message = error.message;
459
+ else message = String(error);
460
+ console.error(`Error: ${message}`);
461
+ process.exit(1);
232
462
  }
233
- function printBuild(build) {
234
- const lines = [
235
- `Build #${build.number}`,
236
- `Status: ${build.status}`,
237
- `Snapshots: ${formatStats(build.stats)}`,
238
- `Conclusion: ${formatValue(build.conclusion)}`,
239
- `Branch: ${formatValue(build.head?.branch)}`,
240
- `Commit: ${formatValue(build.head?.sha)}`,
241
- `Base branch: ${formatValue(build.base?.branch)}`,
242
- `Base commit: ${formatValue(build.base?.sha)}`,
243
- `URL: ${build.url}`
244
- ];
245
- console.log(lines.join("\n"));
463
+ /** Print a command result as pretty JSON or human-readable text. */
464
+ function output(data, options, format) {
465
+ console.log(options.json ? JSON.stringify(data, null, 2) : format(data));
246
466
  }
247
- function printSnapshots(diffs, build) {
248
- if (diffs.length === 0) {
249
- console.log("No snapshots found.");
250
- return;
467
+ /**
468
+ * Run a build-scoped command end to end: resolve the build target, run the
469
+ * handler, print the result, and turn any failure into a clean CLI error.
470
+ */
471
+ async function runBuildAction(opts) {
472
+ try {
473
+ const target = await resolveBuildTarget(opts.reference, opts.options, { auth: opts.auth });
474
+ output(await opts.handler(target), opts.options, opts.format);
475
+ } catch (error) {
476
+ handleCliError(error, opts.auth);
251
477
  }
252
- const lines = [
253
- `Snapshots for build #${build.number}`,
254
- `Count: ${diffs.length}`,
255
- `Summary: ${formatSnapshotSummary(diffs)}`,
256
- "",
257
- ...diffs.flatMap((diff) => {
258
- return [
259
- `${diff.name} [${diff.status}]`,
260
- ` Review: ${build.url}/${diff.id}`,
261
- ` Mask: ${formatValue(diff.url)}`,
262
- ` Base file: ${formatValue(diff.base?.url)}`,
263
- ` Head file: ${formatValue(diff.head?.url)}`,
264
- ` Score: ${formatValue(diff.score)}`,
265
- ` Group: ${formatValue(diff.group)}`,
266
- ""
267
- ];
268
- })
269
- ];
270
- console.log(lines.slice(0, -1).join("\n"));
271
478
  }
272
- function printReview(review, buildNumber) {
273
- const lines = [
274
- `Review #${review.id}`,
275
- `State: ${review.state}`,
276
- `Build: #${buildNumber}`
277
- ];
278
- console.log(lines.join("\n"));
479
+ //#endregion
480
+ //#region src/commands/build/get.ts
481
+ function registerBuildGet(build) {
482
+ build.command("get").description("Fetch build metadata").argument("<buildReference>", "Build number or Argos build URL").addOption(tokenOption).addOption(jsonOption).action((reference, options) => runBuildAction({
483
+ reference,
484
+ options,
485
+ auth: "project",
486
+ handler: async ({ client, owner, project, buildNumber }) => unwrap(await client.GET("/projects/{owner}/{project}/builds/{buildNumber}", { params: { path: {
487
+ owner,
488
+ project,
489
+ buildNumber
490
+ } } })),
491
+ format: formatBuild
492
+ }));
279
493
  }
280
- function createProjectClient(options) {
281
- return createClient({
282
- authToken: getProjectTokenOrExit(options),
283
- baseUrl: getAPIBaseURL()
284
- });
494
+ //#endregion
495
+ //#region src/commands/build/snapshots.ts
496
+ const PER_PAGE = 100;
497
+ function isBuildPending(build) {
498
+ return build.status === "pending" || build.status === "progress";
499
+ }
500
+ async function fetchBuild(target) {
501
+ const { client, owner, project, buildNumber } = target;
502
+ return unwrap(await client.GET("/projects/{owner}/{project}/builds/{buildNumber}", { params: { path: {
503
+ owner,
504
+ project,
505
+ buildNumber
506
+ } } }));
285
507
  }
286
- async function fetchAllDiffs(client, project, buildNumber, options) {
508
+ /** Fetch every diff of a build, following pagination. */
509
+ async function fetchAllDiffs(target, options) {
510
+ const { client, owner, project, buildNumber } = target;
287
511
  const results = [];
288
- let page = 1;
289
- const perPage = 100;
290
- while (true) {
291
- const query = {
292
- page: String(page),
293
- perPage: String(perPage),
294
- ...options?.needsReview ? { needsReview: true } : {}
295
- };
296
- const { data, error, response } = await client.GET("/projects/{owner}/{project}/builds/{buildNumber}/diffs", { params: {
512
+ for (let page = 1;; page++) {
513
+ const data = unwrap(await client.GET("/projects/{owner}/{project}/builds/{buildNumber}/diffs", { params: {
297
514
  path: {
298
- owner: project.account.slug,
299
- project: project.name,
300
- buildNumber: String(buildNumber)
515
+ owner,
516
+ project,
517
+ buildNumber
301
518
  },
302
- query
303
- } });
304
- if (error || !data) {
305
- if (error) throwAPIError(error, response);
306
- throw new Error("Unexpected empty response from API.");
307
- }
519
+ query: {
520
+ page: String(page),
521
+ perPage: String(PER_PAGE),
522
+ ...options.needsReview ? { needsReview: "true" } : {}
523
+ }
524
+ } }));
308
525
  results.push(...data.results);
309
- if (results.length >= data.pageInfo.total) break;
310
- page++;
526
+ if (results.length >= data.pageInfo.total || data.results.length === 0) break;
311
527
  }
312
528
  return results;
313
529
  }
314
- async function fetchProject(client) {
315
- const { data, error, response } = await client.GET("/project");
316
- if (error) throwAPIError(error, response);
317
- if (!data) {
318
- console.error("Error: Unexpected empty response from API.");
319
- process.exit(1);
530
+ function registerBuildSnapshots(build) {
531
+ build.command("snapshots").description("Fetch snapshot diffs for a build").argument("<buildReference>", "Build number or Argos build URL").addOption(new Option("--needs-review", "Only include snapshot diffs that require review")).addOption(tokenOption).addOption(jsonOption).action(async (reference, options) => {
532
+ try {
533
+ const target = await resolveBuildTarget(reference, options, { auth: "project" });
534
+ const build = await fetchBuild(target);
535
+ if (isBuildPending(build)) {
536
+ const message = `Build #${build.number} is still processing (${build.status}). Try again in a moment.`;
537
+ if (options.json) {
538
+ console.error(`Error: ${message}`);
539
+ process.exit(1);
540
+ }
541
+ console.log(message);
542
+ return;
543
+ }
544
+ output(await fetchAllDiffs(target, { needsReview: Boolean(options.needsReview) }), options, (data) => formatSnapshots(data, build));
545
+ } catch (error) {
546
+ handleCliError(error, "project");
547
+ }
548
+ });
549
+ }
550
+ //#endregion
551
+ //#region src/commands/build/index.ts
552
+ function buildCommand(program) {
553
+ const build = program.command("build").description("Inspect Argos builds");
554
+ registerBuildGet(build);
555
+ registerBuildSnapshots(build);
556
+ }
557
+ //#endregion
558
+ //#region src/lib/body.ts
559
+ /**
560
+ * Resolve the Markdown body of a comment or review from the mutually-exclusive
561
+ * `--body` (inline) and `--body-file` (path) options.
562
+ *
563
+ * The Argos API also accepts a rich-text JSON document, but that form is only
564
+ * needed for `@mentions` (which require user ids); the CLI exposes Markdown
565
+ * only, which the API converts server-side.
566
+ */
567
+ async function resolveBody(options, { required = false } = {}) {
568
+ const { body, bodyFile } = options;
569
+ if (body !== void 0 && bodyFile !== void 0) fail("Use either --body or --body-file, not both.");
570
+ if (body !== void 0) return body;
571
+ if (bodyFile !== void 0) try {
572
+ return await readFile(bodyFile, "utf8");
573
+ } catch (error) {
574
+ fail(`Failed to read --body-file "${bodyFile}": ${error instanceof Error ? error.message : String(error)}`);
320
575
  }
321
- return data;
576
+ if (required) fail("A comment body is required. Use --body <markdown> or --body-file <path>.");
322
577
  }
323
- async function fetchBuildByNumber(client, project, buildNumber, errorLabel) {
324
- const { data, error, response } = await client.GET("/projects/{owner}/{project}/builds/{buildNumber}", { params: { path: {
325
- owner: project.account.slug,
326
- project: project.name,
327
- buildNumber: String(buildNumber)
328
- } } });
329
- if (error) {
330
- if (response.status === 404) {
331
- console.error(`Error: Build number ${errorLabel} not found.`);
332
- process.exit(1);
333
- }
334
- throwAPIError(error, response);
578
+ //#endregion
579
+ //#region src/commands/review/create.ts
580
+ const events = {
581
+ approve: "APPROVE",
582
+ reject: "REJECT",
583
+ comment: "COMMENT"
584
+ };
585
+ function registerReviewCreate(review) {
586
+ review.command("create").description("Submit a review on a build").argument("<buildReference>", "Build number or Argos build URL").addOption(new Option("--event <event>", "Review event to apply to the build").choices(Object.keys(events)).makeOptionMandatory()).option("--body <markdown>", "Markdown comment to attach to the review").option("--body-file <path>", "Read the review comment from a Markdown file").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, options) => runBuildAction({
587
+ reference,
588
+ options,
589
+ auth: "user",
590
+ handler: async ({ client, owner, project, buildNumber }) => {
591
+ const body = await resolveBody(options);
592
+ return unwrap(await client.POST("/projects/{owner}/{project}/builds/{buildNumber}/reviews", {
593
+ params: { path: {
594
+ owner,
595
+ project,
596
+ buildNumber
597
+ } },
598
+ body: {
599
+ event: events[options.event],
600
+ body
601
+ }
602
+ }));
603
+ },
604
+ format: formatReview
605
+ }));
606
+ }
607
+ //#endregion
608
+ //#region src/commands/review/dismiss.ts
609
+ function registerReviewDismiss(review) {
610
+ review.command("dismiss").description("Dismiss a submitted review on a build").argument("<buildReference>", "Build number or Argos build URL").argument("<reviewId>", "ID of the review to dismiss").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, reviewId, options) => runBuildAction({
611
+ reference,
612
+ options,
613
+ auth: "user",
614
+ handler: async ({ client, owner, project, buildNumber }) => unwrap(await client.POST("/projects/{owner}/{project}/builds/{buildNumber}/reviews/{reviewId}/dismiss", { params: { path: {
615
+ owner,
616
+ project,
617
+ buildNumber,
618
+ reviewId
619
+ } } })),
620
+ format: formatReview
621
+ }));
622
+ }
623
+ //#endregion
624
+ //#region src/commands/review/list.ts
625
+ function registerReviewList(review) {
626
+ review.command("list").description("List the reviews submitted on a build").argument("<buildReference>", "Build number or Argos build URL").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, options) => runBuildAction({
627
+ reference,
628
+ options,
629
+ auth: "user",
630
+ handler: async ({ client, owner, project, buildNumber }) => unwrap(await client.GET("/projects/{owner}/{project}/builds/{buildNumber}/reviews", { params: { path: {
631
+ owner,
632
+ project,
633
+ buildNumber
634
+ } } })),
635
+ format: formatReviews
636
+ }));
637
+ }
638
+ //#endregion
639
+ //#region src/commands/review/index.ts
640
+ function reviewCommand(program) {
641
+ const review = program.command("review").description("List, submit, and dismiss build reviews");
642
+ registerReviewList(review);
643
+ registerReviewCreate(review);
644
+ registerReviewDismiss(review);
645
+ }
646
+ //#endregion
647
+ //#region src/lib/anchor.ts
648
+ function parsePair(value) {
649
+ const parts = value.split(",").map((part) => Number(part.trim()));
650
+ if (parts.length !== 2 || parts.some((part) => Number.isNaN(part))) return null;
651
+ return [parts[0], parts[1]];
652
+ }
653
+ /**
654
+ * Build a comment anchor from the mutually-exclusive `--anchor-point` and
655
+ * `--anchor-lines` options. Returns `undefined` when neither is provided.
656
+ */
657
+ function parseAnchor(options) {
658
+ const { anchorPoint, anchorLines } = options;
659
+ if (anchorPoint && anchorLines) fail("Use either --anchor-point or --anchor-lines, not both.");
660
+ if (anchorPoint) {
661
+ const pair = parsePair(anchorPoint);
662
+ if (!pair) fail("--anchor-point must be two numbers, e.g. --anchor-point 0.5,0.5.");
663
+ const [x, y] = pair;
664
+ if (x < 0 || x > 1 || y < 0 || y > 1) fail("--anchor-point coordinates must be normalized between 0 and 1.");
665
+ return {
666
+ type: "point",
667
+ x,
668
+ y
669
+ };
335
670
  }
336
- if (!data) {
337
- console.error("Error: Unexpected empty response from API.");
338
- process.exit(1);
671
+ if (anchorLines) {
672
+ const pair = parsePair(anchorLines);
673
+ if (!pair) fail("--anchor-lines must be two numbers, e.g. --anchor-lines 10,20.");
674
+ const [from, to] = pair;
675
+ if (!Number.isInteger(from) || !Number.isInteger(to) || from < 1 || to < from) fail("--anchor-lines must be a 1-based range where from <= to.");
676
+ return {
677
+ type: "lines",
678
+ from,
679
+ to
680
+ };
339
681
  }
340
- return data;
341
682
  }
342
- function buildCommand(program) {
343
- const build = program.command("build").description("Manage Argos builds");
344
- const createJsonOption = () => new Option("--json", "Output machine-readable JSON instead of human-readable text");
345
- build.command("get").description("Fetch build metadata").argument("<buildReference>", "Build number or Argos build URL").addOption(tokenOption).addOption(createJsonOption()).action(async (buildReference, options) => {
346
- const { buildNumber } = parseBuildReferenceDetailsOrExit(buildReference);
347
- const client = createProjectClient(options);
348
- const build = await fetchBuildByNumber(client, await fetchProject(client), buildNumber, buildReference);
349
- if (options.json) {
350
- console.log(JSON.stringify(build, null, 2));
351
- return;
352
- }
353
- printBuild(build);
354
- });
355
- build.command("snapshots").description("Fetch snapshot diffs for a build").argument("<buildReference>", "Build number or Argos build URL").option("--needs-review", "Only include snapshot diffs that require review").addOption(tokenOption).addOption(createJsonOption()).action(async (buildReference, options) => {
356
- const { buildNumber } = parseBuildReferenceDetailsOrExit(buildReference);
357
- const client = createProjectClient(options);
358
- const project = await fetchProject(client);
359
- const build = await fetchBuildByNumber(client, project, buildNumber, buildReference);
360
- if (isBuildPending(build)) {
361
- if (options.json) {
362
- console.error(`Error: Build #${build.number} is still processing (${build.status}). Try again in a moment.`);
363
- process.exit(1);
364
- }
365
- console.log(`Build #${build.number} is still processing (${build.status}). Try again in a moment.`);
366
- return;
367
- }
368
- const diffs = await fetchAllDiffs(client, project, buildNumber, { needsReview: Boolean(options.needsReview) });
369
- if (options.json) {
370
- console.log(JSON.stringify(diffs, null, 2));
371
- return;
372
- }
373
- printSnapshots(diffs, build);
374
- });
375
- build.command("review").description("Create a review on a build").argument("<buildReference>", "Build number or Argos build URL").addOption(new Option("--conclusion <conclusion>", "Overall review conclusion for the build: \"approve\" or \"request-changes\"").choices(Object.keys(reviewConclusions)).makeOptionMandatory()).option("--project <project>", "Project path in owner/project format").addOption(tokenOption).addOption(createJsonOption()).action(async (buildReference, options) => {
376
- const conclusion = reviewConclusions[options.conclusion];
377
- const buildReferenceDetails = parseBuildReferenceDetailsOrExit(buildReference);
378
- let owner;
379
- let project;
380
- if (buildReferenceDetails.owner && buildReferenceDetails.project) {
381
- owner = buildReferenceDetails.owner;
382
- project = buildReferenceDetails.project;
383
- } else if (options.project) {
384
- const parts = options.project.split("/");
385
- if (parts.length !== 2 || !parts[0] || !parts[1]) {
386
- console.error("Error: --project must be in the format 'owner/project'.");
387
- process.exit(1);
388
- }
389
- [owner, project] = parts;
390
- } else {
391
- console.error("Error: --project <owner/project> is required for build-number references.");
392
- process.exit(1);
393
- }
394
- const { data, error, response } = await createClient({
395
- authToken: await getTokenOrExit(options),
396
- baseUrl: getAPIBaseURL()
397
- }).POST("/projects/{owner}/{project}/builds/{buildNumber}/reviews", {
683
+ //#endregion
684
+ //#region src/commands/comment/create.ts
685
+ function registerCommentCreate(comment) {
686
+ comment.command("create").description("Post a comment (or reply) on a build").argument("<buildReference>", "Build number or Argos build URL").option("--body <markdown>", "Markdown body of the comment").option("--body-file <path>", "Read the comment body from a Markdown file").option("--reply-to <threadId>", "Reply to an existing thread (its root comment ID)").option("--diff <screenshotDiffId>", "Anchor the comment to a screenshot diff").option("--anchor-point <x,y>", "Point on the diff in normalized 0-1 coordinates (requires --diff)").option("--anchor-lines <from,to>", "1-based inclusive line range on the diff (requires --diff)").option("--draft", "Attach to your pending review instead of posting immediately").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, options) => runBuildAction({
687
+ reference,
688
+ options,
689
+ auth: "user",
690
+ handler: async ({ client, owner, project, buildNumber }) => {
691
+ const body = await resolveBody(options, { required: true });
692
+ const anchor = parseAnchor(options);
693
+ if (anchor && !options.diff) fail("--anchor-point and --anchor-lines require --diff <screenshotDiffId>.");
694
+ return unwrap(await client.POST("/projects/{owner}/{project}/builds/{buildNumber}/comments", {
695
+ params: { path: {
696
+ owner,
697
+ project,
698
+ buildNumber
699
+ } },
700
+ body: {
701
+ body,
702
+ threadId: options.replyTo,
703
+ screenshotDiffId: options.diff,
704
+ anchor,
705
+ addToReview: options.draft
706
+ }
707
+ }));
708
+ },
709
+ format: formatComment
710
+ }));
711
+ }
712
+ //#endregion
713
+ //#region src/commands/comment/_action.ts
714
+ /**
715
+ * Register a `comment <name> <buildReference> <commentId>` command that runs
716
+ * `perform` and prints the returned comment. Used for the single-comment
717
+ * actions that share the same shape (get, delete, resolve, subscribe, …).
718
+ */
719
+ function defineCommentAction(opts) {
720
+ return (comment) => {
721
+ comment.command(opts.name).description(opts.description).argument("<buildReference>", "Build number or Argos build URL").argument("<commentId>", "ID of the comment").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, commentId, options) => runBuildAction({
722
+ reference,
723
+ options,
724
+ auth: "user",
725
+ handler: ({ client, owner, project, buildNumber }) => opts.perform({
726
+ client,
727
+ owner,
728
+ project,
729
+ buildNumber,
730
+ commentId
731
+ }),
732
+ format: formatComment
733
+ }));
734
+ };
735
+ }
736
+ //#endregion
737
+ //#region src/commands/comment/delete.ts
738
+ const registerCommentDelete = defineCommentAction({
739
+ name: "delete",
740
+ description: "Delete a comment on a build (author only)",
741
+ perform: async ({ client, owner, project, buildNumber, commentId }) => unwrap(await client.DELETE("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}", { params: { path: {
742
+ owner,
743
+ project,
744
+ buildNumber,
745
+ commentId
746
+ } } }))
747
+ });
748
+ //#endregion
749
+ //#region src/commands/comment/edit.ts
750
+ function registerCommentEdit(comment) {
751
+ comment.command("edit").description("Update the body of a comment (author only)").argument("<buildReference>", "Build number or Argos build URL").argument("<commentId>", "ID of the comment").option("--body <markdown>", "New Markdown body of the comment").option("--body-file <path>", "Read the new body from a Markdown file").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, commentId, options) => runBuildAction({
752
+ reference,
753
+ options,
754
+ auth: "user",
755
+ handler: async ({ client, owner, project, buildNumber }) => {
756
+ const body = await resolveBody(options, { required: true });
757
+ return unwrap(await client.PATCH("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}", {
758
+ params: { path: {
759
+ owner,
760
+ project,
761
+ buildNumber,
762
+ commentId
763
+ } },
764
+ body: { body }
765
+ }));
766
+ },
767
+ format: formatComment
768
+ }));
769
+ }
770
+ //#endregion
771
+ //#region src/commands/comment/get.ts
772
+ const registerCommentGet = defineCommentAction({
773
+ name: "get",
774
+ description: "Fetch a single comment on a build",
775
+ perform: async ({ client, owner, project, buildNumber, commentId }) => unwrap(await client.GET("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}", { params: { path: {
776
+ owner,
777
+ project,
778
+ buildNumber,
779
+ commentId
780
+ } } }))
781
+ });
782
+ //#endregion
783
+ //#region src/commands/comment/list.ts
784
+ function registerCommentList(comment) {
785
+ comment.command("list").description("List the comments on a build").argument("<buildReference>", "Build number or Argos build URL").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, options) => runBuildAction({
786
+ reference,
787
+ options,
788
+ auth: "user",
789
+ handler: async ({ client, owner, project, buildNumber }) => unwrap(await client.GET("/projects/{owner}/{project}/builds/{buildNumber}/comments", { params: { path: {
790
+ owner,
791
+ project,
792
+ buildNumber
793
+ } } })),
794
+ format: formatComments
795
+ }));
796
+ }
797
+ //#endregion
798
+ //#region src/commands/comment/react.ts
799
+ function registerCommentReact(comment) {
800
+ comment.command("react").description("Add an emoji reaction to a comment").argument("<buildReference>", "Build number or Argos build URL").argument("<commentId>", "ID of the comment").argument("<emoji>", "Emoji to react with").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, commentId, emoji, options) => runBuildAction({
801
+ reference,
802
+ options,
803
+ auth: "user",
804
+ handler: async ({ client, owner, project, buildNumber }) => unwrap(await client.POST("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}/reactions", {
398
805
  params: { path: {
399
806
  owner,
400
807
  project,
401
- buildNumber: String(buildReferenceDetails.buildNumber)
808
+ buildNumber,
809
+ commentId
402
810
  } },
403
- body: { conclusion }
404
- });
405
- if (error) {
406
- const message = formatAPIError(error, response);
407
- throw new Error([
408
- `Failed to create review for ${owner}/${project} build #${buildReferenceDetails.buildNumber}: ${message}`,
409
- "Make sure the token passed with --token is a user access token with access to this project.",
410
- "Project tokens from ARGOS_TOKEN can read build data, but they cannot create reviews."
411
- ].join("\n"));
412
- }
413
- if (!data) {
414
- console.error("Error: Unexpected empty response from API.");
415
- process.exit(1);
416
- }
417
- if (options.json) {
418
- console.log(JSON.stringify(data, null, 2));
419
- return;
420
- }
421
- printReview(data, buildReferenceDetails.buildNumber);
422
- });
811
+ body: { emoji }
812
+ })),
813
+ format: formatComment
814
+ }));
815
+ }
816
+ //#endregion
817
+ //#region src/commands/comment/resolve.ts
818
+ const registerCommentResolve = defineCommentAction({
819
+ name: "resolve",
820
+ description: "Mark a comment thread as resolved",
821
+ perform: async ({ client, owner, project, buildNumber, commentId }) => unwrap(await client.POST("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}/resolve", { params: { path: {
822
+ owner,
823
+ project,
824
+ buildNumber,
825
+ commentId
826
+ } } }))
827
+ });
828
+ //#endregion
829
+ //#region src/commands/comment/subscribe.ts
830
+ const registerCommentSubscribe = defineCommentAction({
831
+ name: "subscribe",
832
+ description: "Subscribe to a comment thread's notifications",
833
+ perform: async ({ client, owner, project, buildNumber, commentId }) => unwrap(await client.POST("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}/subscription", { params: { path: {
834
+ owner,
835
+ project,
836
+ buildNumber,
837
+ commentId
838
+ } } }))
839
+ });
840
+ //#endregion
841
+ //#region src/commands/comment/unreact.ts
842
+ function registerCommentUnreact(comment) {
843
+ comment.command("unreact").description("Remove one of your emoji reactions from a comment").argument("<buildReference>", "Build number or Argos build URL").argument("<commentId>", "ID of the comment").argument("<emoji>", "Emoji reaction to remove").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, commentId, emoji, options) => runBuildAction({
844
+ reference,
845
+ options,
846
+ auth: "user",
847
+ handler: async ({ client, owner, project, buildNumber }) => unwrap(await client.DELETE("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}/reactions", { params: {
848
+ path: {
849
+ owner,
850
+ project,
851
+ buildNumber,
852
+ commentId
853
+ },
854
+ query: { emoji }
855
+ } })),
856
+ format: formatComment
857
+ }));
858
+ }
859
+ //#endregion
860
+ //#region src/commands/comment/unresolve.ts
861
+ const registerCommentUnresolve = defineCommentAction({
862
+ name: "unresolve",
863
+ description: "Reopen a resolved comment thread",
864
+ perform: async ({ client, owner, project, buildNumber, commentId }) => unwrap(await client.POST("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}/unresolve", { params: { path: {
865
+ owner,
866
+ project,
867
+ buildNumber,
868
+ commentId
869
+ } } }))
870
+ });
871
+ //#endregion
872
+ //#region src/commands/comment/unsubscribe.ts
873
+ const registerCommentUnsubscribe = defineCommentAction({
874
+ name: "unsubscribe",
875
+ description: "Unsubscribe from a comment thread's notifications",
876
+ perform: async ({ client, owner, project, buildNumber, commentId }) => unwrap(await client.DELETE("/projects/{owner}/{project}/builds/{buildNumber}/comments/{commentId}/subscription", { params: { path: {
877
+ owner,
878
+ project,
879
+ buildNumber,
880
+ commentId
881
+ } } }))
882
+ });
883
+ //#endregion
884
+ //#region src/commands/comment/index.ts
885
+ function commentCommand(program) {
886
+ const comment = program.command("comment").description("List, post, and act on build comments");
887
+ registerCommentList(comment);
888
+ registerCommentCreate(comment);
889
+ registerCommentGet(comment);
890
+ registerCommentEdit(comment);
891
+ registerCommentDelete(comment);
892
+ registerCommentResolve(comment);
893
+ registerCommentUnresolve(comment);
894
+ registerCommentReact(comment);
895
+ registerCommentUnreact(comment);
896
+ registerCommentSubscribe(comment);
897
+ registerCommentUnsubscribe(comment);
423
898
  }
424
899
  //#endregion
425
900
  //#region src/commands/login.ts
@@ -564,6 +1039,10 @@ function loginCommand(program) {
564
1039
  await saveToken(data.token);
565
1040
  console.log(successColor("Logged in to Argos successfully."));
566
1041
  });
1042
+ }
1043
+ //#endregion
1044
+ //#region src/commands/logout.ts
1045
+ function logoutCommand(program) {
567
1046
  program.command("logout").description("Log out from Argos").action(async () => {
568
1047
  if (!await getStoredToken()) {
569
1048
  console.log("No token found. You are already logged out.");
@@ -603,7 +1082,10 @@ uploadCommand(program);
603
1082
  skipCommand(program);
604
1083
  finalizeCommand(program);
605
1084
  buildCommand(program);
1085
+ reviewCommand(program);
1086
+ commentCommand(program);
606
1087
  loginCommand(program);
1088
+ logoutCommand(program);
607
1089
  deployCommand(program);
608
1090
  if (!process.argv.slice(2).length) program.outputHelp();
609
1091
  else program.parse(process.argv);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/cli",
3
3
  "description": "Command-line (CLI) for visual testing with Argos.",
4
- "version": "5.1.2",
4
+ "version": "6.0.0",
5
5
  "bin": {
6
6
  "argos": "./bin/argos-cli.js"
7
7
  },
@@ -34,8 +34,8 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@argos-ci/api-client": "0.22.1",
38
- "@argos-ci/core": "6.2.2",
37
+ "@argos-ci/api-client": "0.23.0",
38
+ "@argos-ci/core": "6.3.0",
39
39
  "commander": "^15.0.0",
40
40
  "open": "^11.0.0",
41
41
  "ora": "^9.4.0",
@@ -46,12 +46,13 @@
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsdown",
49
- "e2e": "vitest --tags-filter=\"not oidc and not tokenless\"",
50
- "e2e-oidc": "vitest e2e/upload-oidc.test.js",
51
- "e2e-tokenless": "vitest e2e/upload-tokenless.test.js",
49
+ "test": "vitest run src",
50
+ "e2e": "vitest e2e --tags-filter=\"not oidc and not tokenless\"",
51
+ "e2e-oidc": "vitest e2e/upload-oidc.test.ts",
52
+ "e2e-tokenless": "vitest e2e/upload-tokenless.test.ts",
52
53
  "check-types": "tsc",
53
54
  "check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
54
55
  "lint": "eslint ."
55
56
  },
56
- "gitHead": "5bcfacce28cbe061590665bf5dec220439c8aebc"
57
+ "gitHead": "a2fb6e1a811e66f3839293ea5a71e93fee838aac"
57
58
  }