@argos-ci/core 0.10.0 → 0.11.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/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +34 -34
- package/package.json +14 -13
package/dist/index.cjs
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -30,7 +30,7 @@ const mustBeCommit = (value)=>{
|
|
|
30
30
|
};
|
|
31
31
|
const mustBeArgosToken = (value)=>{
|
|
32
32
|
if (value && value.length !== 40) {
|
|
33
|
-
throw new Error("
|
|
33
|
+
throw new Error("Invalid Argos repository token (must be 40 characters)");
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
const schema = {
|
|
@@ -146,8 +146,8 @@ const createConfig = ()=>{
|
|
|
146
146
|
|
|
147
147
|
const service$5 = {
|
|
148
148
|
name: "Buildkite",
|
|
149
|
-
detect: ({ env
|
|
150
|
-
config: ({ env
|
|
149
|
+
detect: ({ env })=>Boolean(env.BUILDKITE),
|
|
150
|
+
config: ({ env })=>{
|
|
151
151
|
return {
|
|
152
152
|
// Buildkite doesn't work well so we fallback to git to ensure we have commit and branch
|
|
153
153
|
commit: env.BUILDKITE_COMMIT || head() || null,
|
|
@@ -164,8 +164,8 @@ const service$5 = {
|
|
|
164
164
|
|
|
165
165
|
const service$4 = {
|
|
166
166
|
name: "Heroku",
|
|
167
|
-
detect: ({ env
|
|
168
|
-
config: ({ env
|
|
167
|
+
detect: ({ env })=>Boolean(env.HEROKU_TEST_RUN_ID),
|
|
168
|
+
config: ({ env })=>({
|
|
169
169
|
commit: env.HEROKU_TEST_RUN_COMMIT_VERSION || null,
|
|
170
170
|
branch: env.HEROKU_TEST_RUN_BRANCH || null,
|
|
171
171
|
owner: null,
|
|
@@ -177,7 +177,7 @@ const service$4 = {
|
|
|
177
177
|
})
|
|
178
178
|
};
|
|
179
179
|
|
|
180
|
-
const getBranch = ({ env
|
|
180
|
+
const getBranch = ({ env })=>{
|
|
181
181
|
if (env.GITHUB_HEAD_REF) {
|
|
182
182
|
return env.GITHUB_HEAD_REF;
|
|
183
183
|
}
|
|
@@ -188,19 +188,19 @@ const getBranch = ({ env })=>{
|
|
|
188
188
|
}
|
|
189
189
|
return null;
|
|
190
190
|
};
|
|
191
|
-
const getRepository$1 = ({ env
|
|
191
|
+
const getRepository$1 = ({ env })=>{
|
|
192
192
|
if (!env.GITHUB_REPOSITORY) return null;
|
|
193
193
|
return env.GITHUB_REPOSITORY.split("/")[1];
|
|
194
194
|
};
|
|
195
|
-
const readEventPayload = ({ env
|
|
195
|
+
const readEventPayload = ({ env })=>{
|
|
196
196
|
if (!env.GITHUB_EVENT_PATH) return null;
|
|
197
197
|
if (!existsSync(env.GITHUB_EVENT_PATH)) return null;
|
|
198
198
|
return JSON.parse(readFileSync(env.GITHUB_EVENT_PATH, "utf-8"));
|
|
199
199
|
};
|
|
200
200
|
const service$3 = {
|
|
201
201
|
name: "GitHub Actions",
|
|
202
|
-
detect: ({ env
|
|
203
|
-
config: ({ env
|
|
202
|
+
detect: ({ env })=>Boolean(env.GITHUB_ACTIONS),
|
|
203
|
+
config: ({ env })=>{
|
|
204
204
|
const payload = readEventPayload({
|
|
205
205
|
env
|
|
206
206
|
});
|
|
@@ -221,7 +221,7 @@ const service$3 = {
|
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
223
|
|
|
224
|
-
const getPrNumber$1 = ({ env
|
|
224
|
+
const getPrNumber$1 = ({ env })=>{
|
|
225
225
|
const branchRegex = /pull\/(\d+)/;
|
|
226
226
|
const matches = branchRegex.exec(env.CIRCLE_PULL_REQUEST || "");
|
|
227
227
|
if (matches) {
|
|
@@ -231,8 +231,8 @@ const getPrNumber$1 = ({ env })=>{
|
|
|
231
231
|
};
|
|
232
232
|
const service$2 = {
|
|
233
233
|
name: "CircleCI",
|
|
234
|
-
detect: ({ env
|
|
235
|
-
config: ({ env
|
|
234
|
+
detect: ({ env })=>Boolean(env.CIRCLECI),
|
|
235
|
+
config: ({ env })=>{
|
|
236
236
|
return {
|
|
237
237
|
commit: env.CIRCLE_SHA1 || null,
|
|
238
238
|
branch: env.CIRCLE_BRANCH || null,
|
|
@@ -248,23 +248,23 @@ const service$2 = {
|
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
|
|
251
|
-
const getOwner = ({ env
|
|
251
|
+
const getOwner = ({ env })=>{
|
|
252
252
|
if (!env.TRAVIS_REPO_SLUG) return null;
|
|
253
253
|
return env.TRAVIS_REPO_SLUG.split("/")[0] || null;
|
|
254
254
|
};
|
|
255
|
-
const getRepository = ({ env
|
|
255
|
+
const getRepository = ({ env })=>{
|
|
256
256
|
if (!env.TRAVIS_REPO_SLUG) return null;
|
|
257
257
|
return env.TRAVIS_REPO_SLUG.split("/")[1] || null;
|
|
258
258
|
};
|
|
259
|
-
const getPrNumber = ({ env
|
|
259
|
+
const getPrNumber = ({ env })=>{
|
|
260
260
|
if (env.TRAVIS_PULL_REQUEST) return Number(env.TRAVIS_PULL_REQUEST);
|
|
261
261
|
return null;
|
|
262
262
|
};
|
|
263
263
|
const service$1 = {
|
|
264
264
|
name: "Travis CI",
|
|
265
|
-
detect: ({ env
|
|
265
|
+
detect: ({ env })=>Boolean(env.TRAVIS),
|
|
266
266
|
config: (ctx)=>{
|
|
267
|
-
const { env
|
|
267
|
+
const { env } = ctx;
|
|
268
268
|
return {
|
|
269
269
|
commit: env.TRAVIS_COMMIT || null,
|
|
270
270
|
branch: env.TRAVIS_BRANCH || null,
|
|
@@ -280,8 +280,8 @@ const service$1 = {
|
|
|
280
280
|
|
|
281
281
|
const service = {
|
|
282
282
|
name: "GitLab",
|
|
283
|
-
detect: ({ env
|
|
284
|
-
config: ({ env
|
|
283
|
+
detect: ({ env })=>env.GITLAB_CI === "true",
|
|
284
|
+
config: ({ env })=>{
|
|
285
285
|
return {
|
|
286
286
|
commit: env.CI_COMMIT_SHA || null,
|
|
287
287
|
branch: env.CI_COMMIT_REF_NAME || null,
|
|
@@ -343,7 +343,7 @@ const services = [
|
|
|
343
343
|
service$5,
|
|
344
344
|
service
|
|
345
345
|
];
|
|
346
|
-
const getCiEnvironment = ({ env =process.env
|
|
346
|
+
const getCiEnvironment = ({ env = process.env } = {})=>{
|
|
347
347
|
const ctx = {
|
|
348
348
|
env
|
|
349
349
|
};
|
|
@@ -364,12 +364,12 @@ const getCiEnvironment = ({ env =process.env } = {})=>{
|
|
|
364
364
|
}
|
|
365
365
|
// We fallback on "env-ci" library, not very good but it's better than nothing
|
|
366
366
|
debug("Falling back on env-ci");
|
|
367
|
-
const
|
|
368
|
-
debug("CI environment",
|
|
369
|
-
return
|
|
367
|
+
const ciEnvironment = getCiEnvironmentFromEnvCi(ctx);
|
|
368
|
+
debug("CI environment", ciEnvironment);
|
|
369
|
+
return ciEnvironment;
|
|
370
370
|
};
|
|
371
371
|
|
|
372
|
-
const discoverScreenshots = async (patterns, { root =process.cwd()
|
|
372
|
+
const discoverScreenshots = async (patterns, { root = process.cwd(), ignore } = {})=>{
|
|
373
373
|
const matches = await glob(patterns, {
|
|
374
374
|
onlyFiles: true,
|
|
375
375
|
ignore,
|
|
@@ -406,7 +406,7 @@ const hashFile = async (filepath)=>{
|
|
|
406
406
|
};
|
|
407
407
|
|
|
408
408
|
const base64Encode = (obj)=>Buffer.from(JSON.stringify(obj), "utf8").toString("base64");
|
|
409
|
-
const getBearerToken = ({ token
|
|
409
|
+
const getBearerToken = ({ token, ciService, owner, repository, jobId, runId, prNumber })=>{
|
|
410
410
|
if (token) return `Bearer ${token}`;
|
|
411
411
|
switch(ciService){
|
|
412
412
|
case "GitHub Actions":
|
|
@@ -467,7 +467,7 @@ const createArgosApiClient = (options)=>{
|
|
|
467
467
|
return call("POST", "/builds", input);
|
|
468
468
|
},
|
|
469
469
|
updateBuild: async (input)=>{
|
|
470
|
-
const { buildId
|
|
470
|
+
const { buildId, ...body } = input;
|
|
471
471
|
return call("PUT", `/builds/${buildId}`, body);
|
|
472
472
|
}
|
|
473
473
|
};
|
|
@@ -505,12 +505,12 @@ const getConfigFromOptions = (options)=>{
|
|
|
505
505
|
const config = createConfig();
|
|
506
506
|
const ciEnv = getCiEnvironment();
|
|
507
507
|
config.load({
|
|
508
|
-
apiBaseUrl: config.get("apiBaseUrl")
|
|
509
|
-
commit: config.get("commit") ??
|
|
510
|
-
branch: config.get("branch") ??
|
|
511
|
-
token: config.get("token") ??
|
|
512
|
-
buildName: config.get("buildName") ??
|
|
513
|
-
prNumber: config.get("prNumber") ??
|
|
508
|
+
apiBaseUrl: options.apiBaseUrl ?? config.get("apiBaseUrl"),
|
|
509
|
+
commit: options.commit ?? config.get("commit") ?? ciEnv?.commit ?? null,
|
|
510
|
+
branch: options.branch ?? config.get("branch") ?? ciEnv?.branch ?? null,
|
|
511
|
+
token: options.token ?? config.get("token") ?? null,
|
|
512
|
+
buildName: options.buildName ?? config.get("buildName") ?? null,
|
|
513
|
+
prNumber: options.prNumber ?? config.get("prNumber") ?? ciEnv?.prNumber ?? null,
|
|
514
514
|
prHeadCommit: config.get("prHeadCommit") ?? ciEnv?.prHeadCommit ?? null,
|
|
515
515
|
ciService: ciEnv?.name ?? null,
|
|
516
516
|
owner: ciEnv?.owner ?? null,
|
|
@@ -578,7 +578,7 @@ const getConfigFromOptions = (options)=>{
|
|
|
578
578
|
debug(`Uploading chunk ${i + 1}/${chunks.length}`);
|
|
579
579
|
const timeLabel = `Chunk ${i + 1}/${chunks.length}`;
|
|
580
580
|
debugTime(timeLabel);
|
|
581
|
-
await Promise.all(chunks[i].map(async ({ key
|
|
581
|
+
await Promise.all(chunks[i].map(async ({ key, putUrl })=>{
|
|
582
582
|
const screenshot = screenshots.find((s)=>s.hash === key);
|
|
583
583
|
if (!screenshot) {
|
|
584
584
|
throw new Error(`Invariant: screenshot with hash ${key} not found`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/core",
|
|
3
3
|
"description": "Visual testing solution to avoid visual regression. The core component of Argos SDK that handles build creation.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.1",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prebuild": "rm -rf dist",
|
|
7
7
|
"build": "rollup -c",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"url": "https://github.com/argos-ci/argos-javascript/issues"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=16.0.0"
|
|
33
33
|
},
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"keywords": [
|
|
@@ -45,20 +45,21 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"axios": "1.
|
|
49
|
-
"convict": "^6.2.
|
|
48
|
+
"axios": "^1.5.0",
|
|
49
|
+
"convict": "^6.2.4",
|
|
50
50
|
"debug": "^4.3.4",
|
|
51
|
-
"env-ci": "^
|
|
52
|
-
"fast-glob": "^3.
|
|
53
|
-
"sharp": "^0.
|
|
51
|
+
"env-ci": "^9.1.1",
|
|
52
|
+
"fast-glob": "^3.3.1",
|
|
53
|
+
"sharp": "^0.32.5",
|
|
54
54
|
"tmp": "^0.2.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@types/convict": "^6.1.
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"rollup
|
|
61
|
-
"rollup-plugin-
|
|
57
|
+
"@types/convict": "^6.1.4",
|
|
58
|
+
"@types/tmp": "^0.2.3",
|
|
59
|
+
"msw": "^1.3.0",
|
|
60
|
+
"rollup": "^3.29.0",
|
|
61
|
+
"rollup-plugin-dts": "^6.0.1",
|
|
62
|
+
"rollup-plugin-swc3": "^0.10.1"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "8e3c44d658f3abd5ce3ac1bc829e2754974a2125"
|
|
64
65
|
}
|