@argos-ci/cli 2.4.6 → 2.5.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.
package/bin/argos-cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import "../dist/index.mjs";
3
+ import "../dist/index.js";
package/dist/index.js ADDED
@@ -0,0 +1,139 @@
1
+ // src/index.ts
2
+ import { readFile } from "node:fs/promises";
3
+ import { fileURLToPath } from "node:url";
4
+ import { resolve } from "node:path";
5
+ import { program } from "commander";
6
+
7
+ // src/commands/upload.ts
8
+ import { Option as Option2 } from "commander";
9
+ import { upload } from "@argos-ci/core";
10
+ import ora from "ora";
11
+
12
+ // src/options.ts
13
+ import { Option } from "commander";
14
+ var parallelNonce = new Option(
15
+ "--parallel-nonce <string>",
16
+ "A unique ID for this parallel build"
17
+ ).env("ARGOS_PARALLEL_NONCE");
18
+
19
+ // src/commands/upload.ts
20
+ function uploadCommand(program2) {
21
+ program2.command("upload").argument("<directory>", "Directory to upload").description("Upload screenshots to Argos").option(
22
+ "-f, --files <patterns...>",
23
+ "One or more globs matching image file paths to upload",
24
+ "**/*.{png,jpg,jpeg}"
25
+ ).option(
26
+ "-i, --ignore <patterns...>",
27
+ 'One or more globs matching image file paths to ignore (ex: "**/*.png **/diff.jpg")'
28
+ ).addOption(
29
+ new Option2("--token <token>", "Repository token").env("ARGOS_TOKEN")
30
+ ).addOption(
31
+ new Option2(
32
+ "--build-name <string>",
33
+ "Name of the build, in case you want to run multiple Argos builds in a single CI job"
34
+ ).env("ARGOS_BUILD_NAME")
35
+ ).addOption(
36
+ new Option2(
37
+ "--mode <string>",
38
+ "Mode of comparison applied. CI for visual regression testing, monitoring for visual monitoring."
39
+ ).default("ci").choices(["ci", "monitoring"]).env("ARGOS_MODE")
40
+ ).addOption(
41
+ new Option2(
42
+ "--parallel",
43
+ "Enable parallel mode. Run multiple Argos builds and combine them at the end"
44
+ ).env("ARGOS_PARALLEL")
45
+ ).addOption(
46
+ new Option2(
47
+ "--parallel-total <number>",
48
+ "The number of parallel nodes being ran"
49
+ ).env("ARGOS_PARALLEL_TOTAL")
50
+ ).addOption(parallelNonce).addOption(
51
+ new Option2(
52
+ "--parallel-index <number>",
53
+ "The index of the parallel node being ran"
54
+ ).env("ARGOS_PARALLEL_INDEX")
55
+ ).addOption(
56
+ new Option2(
57
+ "--reference-branch <string>",
58
+ "Branch used as baseline for screenshot comparison"
59
+ ).env("ARGOS_REFERENCE_BRANCH")
60
+ ).addOption(
61
+ new Option2(
62
+ "--reference-commit <string>",
63
+ "Commit used as baseline for screenshot comparison"
64
+ ).env("ARGOS_REFERENCE_COMMIT")
65
+ ).addOption(
66
+ new Option2(
67
+ "--threshold <number>",
68
+ "Sensitivity threshold between 0 and 1. The higher the threshold, the less sensitive the diff will be. Default to 0.5"
69
+ ).env("ARGOS_THRESHOLD")
70
+ ).action(async (directory, options) => {
71
+ const spinner = ora("Uploading screenshots").start();
72
+ try {
73
+ const result = await upload({
74
+ token: options.token,
75
+ root: directory,
76
+ buildName: options.buildName,
77
+ files: options.files,
78
+ ignore: options.ignore,
79
+ prNumber: options.pullRequest ? Number(options.pullRequest) : void 0,
80
+ parallel: options.parallel ? {
81
+ nonce: options.parallelNonce,
82
+ total: options.parallelTotal,
83
+ index: options.parallelIndex
84
+ } : false,
85
+ referenceBranch: options.referenceBranch,
86
+ referenceCommit: options.referenceCommit,
87
+ mode: options.mode,
88
+ threshold: options.threshold
89
+ });
90
+ spinner.succeed(`Build created: ${result.build.url}`);
91
+ } catch (error) {
92
+ if (error instanceof Error) {
93
+ spinner.fail(`Build failed: ${error.message}`);
94
+ console.error(error.stack);
95
+ }
96
+ process.exit(1);
97
+ }
98
+ });
99
+ }
100
+
101
+ // src/commands/finalize.ts
102
+ import ora2 from "ora";
103
+ import { finalize } from "@argos-ci/core";
104
+ function finalizeCommand(program2) {
105
+ program2.command("finalize").description("Finalize pending parallel builds").addOption(parallelNonce).action(async (options) => {
106
+ const spinner = ora2("Finalizing builds").start();
107
+ try {
108
+ const result = await finalize({
109
+ parallel: {
110
+ nonce: options.parallelNonce
111
+ }
112
+ });
113
+ spinner.succeed(
114
+ result.builds.length === 0 ? "No builds to finalize" : `Builds finalized: ${result.builds.map((b) => b.url).join(", ")}`
115
+ );
116
+ } catch (error) {
117
+ if (error instanceof Error) {
118
+ spinner.fail(`Failed to finalize: ${error.message}`);
119
+ console.error(error.stack);
120
+ }
121
+ process.exit(1);
122
+ }
123
+ });
124
+ }
125
+
126
+ // src/index.ts
127
+ var __dirname = fileURLToPath(new URL(".", import.meta.url));
128
+ var rawPkg = await readFile(resolve(__dirname, "..", "package.json"), "utf8");
129
+ var pkg = JSON.parse(rawPkg);
130
+ program.name(pkg.name).description(
131
+ "Interact with and upload screenshots to Argos via command line."
132
+ ).version(pkg.version);
133
+ uploadCommand(program);
134
+ finalizeCommand(program);
135
+ if (!process.argv.slice(2).length) {
136
+ program.outputHelp();
137
+ } else {
138
+ program.parse(process.argv);
139
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/cli",
3
- "description": "Visual testing solution to avoid visual regression. Argos CLI is used to interact with and upload screenshots to argos-ci.com via command line.",
4
- "version": "2.4.6",
3
+ "description": "Command-line (CLI) for visual testing with Argos.",
4
+ "version": "2.5.0",
5
5
  "bin": {
6
6
  "argos": "./bin/argos-cli.js"
7
7
  },
@@ -14,7 +14,7 @@
14
14
  "url": "https://github.com/argos-ci/argos-javascript.git",
15
15
  "directory": "packages/core"
16
16
  },
17
- "homepage": "https://github.com/argos-ci/argos-javascript/tree/main/packages/core#readme",
17
+ "homepage": "https://argos-ci.com/docs/argos-cli",
18
18
  "bugs": {
19
19
  "url": "https://github.com/argos-ci/argos-javascript/issues"
20
20
  },
@@ -23,9 +23,8 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "keywords": [
26
+ "cli",
26
27
  "argos",
27
- "automation",
28
- "test automation",
29
28
  "testing",
30
29
  "visual testing",
31
30
  "regression",
@@ -35,15 +34,14 @@
35
34
  "access": "public"
36
35
  },
37
36
  "dependencies": {
38
- "@argos-ci/core": "2.9.1",
37
+ "@argos-ci/core": "2.10.0",
39
38
  "commander": "^12.1.0",
40
- "ora": "^8.0.1",
41
- "update-notifier": "^7.2.0"
39
+ "ora": "^8.1.0",
40
+ "update-notifier": "^7.3.1"
42
41
  },
43
42
  "scripts": {
44
- "prebuild": "rm -rf dist",
45
- "build": "rollup -c",
43
+ "build": "tsup",
46
44
  "e2e": "node e2e/upload.js"
47
45
  },
48
- "gitHead": "db599c8bc3021cb18315f4e39717f9c2990e7847"
46
+ "gitHead": "fe6e055a43e955e7df362ddaec59c84dc274bbb2"
49
47
  }
package/dist/index.mjs DELETED
@@ -1,75 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { fileURLToPath } from 'node:url';
3
- import { resolve } from 'node:path';
4
- import { Option, program } from 'commander';
5
- import { upload, finalize } from '@argos-ci/core';
6
- import ora from 'ora';
7
-
8
- const parallelNonce = new Option("--parallel-nonce <string>", "A unique ID for this parallel build").env("ARGOS_PARALLEL_NONCE");
9
-
10
- function uploadCommand(program) {
11
- 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(new Option("--token <token>", "Repository token").env("ARGOS_TOKEN")).addOption(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")).addOption(new Option("--mode <string>", "Mode of comparison applied. CI for visual regression testing, monitoring for visual monitoring.").default("ci").choices([
12
- "ci",
13
- "monitoring"
14
- ]).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(parallelNonce).addOption(new Option("--parallel-index <number>", "The index of the parallel node being ran").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")).action(async (directory, options)=>{
15
- const spinner = ora("Uploading screenshots").start();
16
- try {
17
- const result = await upload({
18
- token: options.token,
19
- root: directory,
20
- buildName: options.buildName,
21
- files: options.files,
22
- ignore: options.ignore,
23
- prNumber: options.pullRequest ? Number(options.pullRequest) : undefined,
24
- parallel: options.parallel ? {
25
- nonce: options.parallelNonce,
26
- total: options.parallelTotal,
27
- index: options.parallelIndex
28
- } : false,
29
- referenceBranch: options.referenceBranch,
30
- referenceCommit: options.referenceCommit,
31
- mode: options.mode,
32
- threshold: options.threshold
33
- });
34
- spinner.succeed(`Build created: ${result.build.url}`);
35
- } catch (error) {
36
- if (error instanceof Error) {
37
- spinner.fail(`Build failed: ${error.message}`);
38
- console.error(error.stack);
39
- }
40
- process.exit(1);
41
- }
42
- });
43
- }
44
-
45
- function finalizeCommand(program) {
46
- program.command("finalize").description("Finalize pending parallel builds").addOption(parallelNonce).action(async (options)=>{
47
- const spinner = ora("Finalizing builds").start();
48
- try {
49
- const result = await finalize({
50
- parallel: {
51
- nonce: options.parallelNonce
52
- }
53
- });
54
- spinner.succeed(result.builds.length === 0 ? "No builds to finalize" : `Builds finalized: ${result.builds.map((b)=>b.url).join(", ")}`);
55
- } catch (error) {
56
- if (error instanceof Error) {
57
- spinner.fail(`Failed to finalize: ${error.message}`);
58
- console.error(error.stack);
59
- }
60
- process.exit(1);
61
- }
62
- });
63
- }
64
-
65
- const __dirname = fileURLToPath(new URL(".", import.meta.url));
66
- const rawPkg = await readFile(resolve(__dirname, "..", "package.json"), "utf8");
67
- const pkg = JSON.parse(rawPkg);
68
- program.name(pkg.name).description("Interact with and upload screenshots to Argos via command line.").version(pkg.version);
69
- uploadCommand(program);
70
- finalizeCommand(program);
71
- if (!process.argv.slice(2).length) {
72
- program.outputHelp();
73
- } else {
74
- program.parse(process.argv);
75
- }