@argos-ci/cli 3.2.0 → 4.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.
- package/dist/index.js +56 -27
- package/package.json +4 -4
- package/LICENSE +0 -7
package/dist/index.js
CHANGED
|
@@ -11,10 +11,18 @@ import ora from "ora";
|
|
|
11
11
|
|
|
12
12
|
// src/options.ts
|
|
13
13
|
import { Option } from "commander";
|
|
14
|
-
var
|
|
14
|
+
var parallelNonceOption = new Option(
|
|
15
15
|
"--parallel-nonce <string>",
|
|
16
16
|
"A unique ID for this parallel build"
|
|
17
17
|
).env("ARGOS_PARALLEL_NONCE");
|
|
18
|
+
var tokenOption = new Option(
|
|
19
|
+
"--token <token>",
|
|
20
|
+
"Repository token"
|
|
21
|
+
).env("ARGOS_TOKEN");
|
|
22
|
+
var buildNameOption = new Option(
|
|
23
|
+
"--build-name <string>",
|
|
24
|
+
"Name of the build, in case you want to run multiple Argos builds in a single CI job"
|
|
25
|
+
).env("ARGOS_BUILD_NAME");
|
|
18
26
|
|
|
19
27
|
// src/commands/upload.ts
|
|
20
28
|
function uploadCommand(program2) {
|
|
@@ -25,14 +33,7 @@ function uploadCommand(program2) {
|
|
|
25
33
|
).option(
|
|
26
34
|
"-i, --ignore <patterns...>",
|
|
27
35
|
'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
|
+
).addOption(tokenOption).addOption(buildNameOption).addOption(
|
|
36
37
|
new Option2(
|
|
37
38
|
"--mode <string>",
|
|
38
39
|
"Mode of comparison applied. CI for visual regression testing, monitoring for visual monitoring."
|
|
@@ -47,7 +48,7 @@ function uploadCommand(program2) {
|
|
|
47
48
|
"--parallel-total <number>",
|
|
48
49
|
"The number of parallel nodes being ran"
|
|
49
50
|
).env("ARGOS_PARALLEL_TOTAL")
|
|
50
|
-
).addOption(
|
|
51
|
+
).addOption(parallelNonceOption).addOption(
|
|
51
52
|
new Option2(
|
|
52
53
|
"--parallel-index <number>",
|
|
53
54
|
"The index of the parallel node being ran (must be at least 1)"
|
|
@@ -67,31 +68,38 @@ function uploadCommand(program2) {
|
|
|
67
68
|
"--threshold <number>",
|
|
68
69
|
"Sensitivity threshold between 0 and 1. The higher the threshold, the less sensitive the diff will be. Default to 0.5"
|
|
69
70
|
).env("ARGOS_THRESHOLD")
|
|
70
|
-
).addOption(
|
|
71
|
-
new Option2(
|
|
72
|
-
"--skipped",
|
|
73
|
-
"Mark this build as skipped. No screenshots are uploaded, and the commit status is marked as success."
|
|
74
|
-
).env("ARGOS_SKIPPED")
|
|
75
71
|
).action(async (directory, options) => {
|
|
76
72
|
const spinner = ora("Uploading screenshots").start();
|
|
77
73
|
try {
|
|
74
|
+
const parallel = (() => {
|
|
75
|
+
if (!options.parallel) {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
if (!options.parallelNonce) {
|
|
79
|
+
spinner.fail("--parallel-nonce is required if --parallel is set");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
if (!options.parallelTotal) {
|
|
83
|
+
spinner.fail("--parallel-total is required if --parallel is set");
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
nonce: options.parallelNonce,
|
|
88
|
+
total: options.parallelTotal,
|
|
89
|
+
index: options.parallelIndex
|
|
90
|
+
};
|
|
91
|
+
})();
|
|
78
92
|
const result = await upload({
|
|
79
93
|
token: options.token,
|
|
80
94
|
root: directory,
|
|
81
95
|
buildName: options.buildName,
|
|
82
96
|
files: options.files,
|
|
83
97
|
ignore: options.ignore,
|
|
84
|
-
|
|
85
|
-
parallel: options.parallel ? {
|
|
86
|
-
nonce: options.parallelNonce,
|
|
87
|
-
total: options.parallelTotal,
|
|
88
|
-
index: options.parallelIndex
|
|
89
|
-
} : void 0,
|
|
98
|
+
parallel,
|
|
90
99
|
referenceBranch: options.referenceBranch,
|
|
91
100
|
referenceCommit: options.referenceCommit,
|
|
92
101
|
mode: options.mode,
|
|
93
|
-
threshold: options.threshold
|
|
94
|
-
skipped: options.skipped
|
|
102
|
+
threshold: options.threshold
|
|
95
103
|
});
|
|
96
104
|
spinner.succeed(`Build created: ${result.build.url}`);
|
|
97
105
|
} catch (error) {
|
|
@@ -108,13 +116,11 @@ function uploadCommand(program2) {
|
|
|
108
116
|
import ora2 from "ora";
|
|
109
117
|
import { finalize } from "@argos-ci/core";
|
|
110
118
|
function finalizeCommand(program2) {
|
|
111
|
-
program2.command("finalize").description("Finalize pending parallel builds").addOption(
|
|
119
|
+
program2.command("finalize").description("Finalize pending parallel builds").addOption(parallelNonceOption).action(async (options) => {
|
|
112
120
|
const spinner = ora2("Finalizing builds").start();
|
|
113
121
|
try {
|
|
114
122
|
const result = await finalize({
|
|
115
|
-
parallel: {
|
|
116
|
-
nonce: options.parallelNonce
|
|
117
|
-
}
|
|
123
|
+
parallel: options.parallelNonce ? { nonce: options.parallelNonce } : void 0
|
|
118
124
|
});
|
|
119
125
|
spinner.succeed(
|
|
120
126
|
result.builds.length === 0 ? "No builds to finalize" : `Builds finalized: ${result.builds.map((b) => b.url).join(", ")}`
|
|
@@ -129,6 +135,28 @@ function finalizeCommand(program2) {
|
|
|
129
135
|
});
|
|
130
136
|
}
|
|
131
137
|
|
|
138
|
+
// src/commands/skip.ts
|
|
139
|
+
import { skip } from "@argos-ci/core";
|
|
140
|
+
import ora3 from "ora";
|
|
141
|
+
function skipCommand(program2) {
|
|
142
|
+
program2.command("skip").description("Mark a build as skipped").addOption(tokenOption).addOption(buildNameOption).action(async (options) => {
|
|
143
|
+
const spinner = ora3("Creating skipped build").start();
|
|
144
|
+
try {
|
|
145
|
+
const result = await skip({
|
|
146
|
+
token: options.token,
|
|
147
|
+
buildName: options.buildName
|
|
148
|
+
});
|
|
149
|
+
spinner.succeed(`Build created: ${result.build.url}`);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (error instanceof Error) {
|
|
152
|
+
spinner.fail(`Build failed: ${error.message}`);
|
|
153
|
+
console.error(error.stack);
|
|
154
|
+
}
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
132
160
|
// src/index.ts
|
|
133
161
|
var __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
134
162
|
var rawPkg = await readFile(resolve(__dirname, "..", "package.json"), "utf8");
|
|
@@ -137,6 +165,7 @@ program.name(pkg.name).description(
|
|
|
137
165
|
"Interact with and upload screenshots to Argos via command line."
|
|
138
166
|
).version(pkg.version);
|
|
139
167
|
uploadCommand(program);
|
|
168
|
+
skipCommand(program);
|
|
140
169
|
finalizeCommand(program);
|
|
141
170
|
if (!process.argv.slice(2).length) {
|
|
142
171
|
program.outputHelp();
|
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": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"argos": "./bin/argos-cli.js"
|
|
7
7
|
},
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@argos-ci/core": "
|
|
37
|
+
"@argos-ci/core": "5.0.0",
|
|
38
38
|
"commander": "^14.0.2",
|
|
39
39
|
"ora": "^9.0.0",
|
|
40
40
|
"update-notifier": "^7.3.1"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsup",
|
|
44
|
-
"e2e": "node e2e/upload.js",
|
|
44
|
+
"e2e": "node e2e/upload.js && node e2e/skip.js",
|
|
45
45
|
"check-types": "tsc",
|
|
46
46
|
"check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
|
|
47
47
|
"lint": "eslint ."
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "d460ccc12fe75b1d9389d58647f1906bee7d5e0d"
|
|
50
50
|
}
|
package/LICENSE
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Copyright 2022 Smooth Code
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|