@argos-ci/core 0.9.0 → 0.11.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.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  exports.upload = async (params)=>{
2
2
  // @ts-ignore
3
- const { upload } = await import('./index.mjs');
3
+ const { upload } = await import('./index.mjs');
4
4
  return upload(params);
5
5
  };
package/dist/index.d.ts CHANGED
@@ -41,4 +41,4 @@ declare const upload: (params: UploadParameters) => Promise<{
41
41
  }[];
42
42
  }>;
43
43
 
44
- export { UploadParameters, upload };
44
+ export { type UploadParameters, upload };
package/dist/index.mjs CHANGED
@@ -144,10 +144,10 @@ const createConfig = ()=>{
144
144
  }
145
145
  };
146
146
 
147
- const service$4 = {
147
+ const service$5 = {
148
148
  name: "Buildkite",
149
- detect: ({ env })=>Boolean(env.BUILDKITE),
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,
@@ -162,10 +162,10 @@ const service$4 = {
162
162
  }
163
163
  };
164
164
 
165
- const service$3 = {
165
+ const service$4 = {
166
166
  name: "Heroku",
167
- detect: ({ env })=>Boolean(env.HEROKU_TEST_RUN_ID),
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$3 = {
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
- const service$2 = {
200
+ const service$3 = {
201
201
  name: "GitHub Actions",
202
- detect: ({ env })=>Boolean(env.GITHUB_ACTIONS),
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$2 = {
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) {
@@ -229,10 +229,10 @@ const getPrNumber$1 = ({ env })=>{
229
229
  }
230
230
  return null;
231
231
  };
232
- const service$1 = {
232
+ const service$2 = {
233
233
  name: "CircleCI",
234
- detect: ({ env })=>Boolean(env.CIRCLECI),
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$1 = {
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
- const service = {
263
+ const service$1 = {
264
264
  name: "Travis CI",
265
- detect: ({ env })=>Boolean(env.TRAVIS),
265
+ detect: ({ env })=>Boolean(env.TRAVIS),
266
266
  config: (ctx)=>{
267
- const { env } = ctx;
267
+ const { env } = ctx;
268
268
  return {
269
269
  commit: env.TRAVIS_COMMIT || null,
270
270
  branch: env.TRAVIS_BRANCH || null,
@@ -278,6 +278,23 @@ const service = {
278
278
  }
279
279
  };
280
280
 
281
+ const service = {
282
+ name: "GitLab",
283
+ detect: ({ env })=>env.GITLAB_CI === "true",
284
+ config: ({ env })=>{
285
+ return {
286
+ commit: env.CI_COMMIT_SHA || null,
287
+ branch: env.CI_COMMIT_REF_NAME || null,
288
+ owner: null,
289
+ repository: null,
290
+ jobId: null,
291
+ runId: null,
292
+ prNumber: null,
293
+ prHeadCommit: null
294
+ };
295
+ }
296
+ };
297
+
281
298
  const KEY = "@argos-ci/core";
282
299
  const debug = createDebug(KEY);
283
300
  const debugTime = (arg)=>{
@@ -319,13 +336,14 @@ const getCiEnvironmentFromEnvCi = (ctx)=>{
319
336
  };
320
337
 
321
338
  const services = [
339
+ service$4,
322
340
  service$3,
323
341
  service$2,
324
342
  service$1,
325
- service,
326
- service$4
343
+ service$5,
344
+ service
327
345
  ];
328
- const getCiEnvironment = ({ env =process.env } = {})=>{
346
+ const getCiEnvironment = ({ env = process.env } = {})=>{
329
347
  const ctx = {
330
348
  env
331
349
  };
@@ -346,12 +364,12 @@ const getCiEnvironment = ({ env =process.env } = {})=>{
346
364
  }
347
365
  // We fallback on "env-ci" library, not very good but it's better than nothing
348
366
  debug("Falling back on env-ci");
349
- const ciEnvironment1 = getCiEnvironmentFromEnvCi(ctx);
350
- debug("CI environment", ciEnvironment1);
351
- return ciEnvironment1;
367
+ const ciEnvironment = getCiEnvironmentFromEnvCi(ctx);
368
+ debug("CI environment", ciEnvironment);
369
+ return ciEnvironment;
352
370
  };
353
371
 
354
- const discoverScreenshots = async (patterns, { root =process.cwd() , ignore } = {})=>{
372
+ const discoverScreenshots = async (patterns, { root = process.cwd(), ignore } = {})=>{
355
373
  const matches = await glob(patterns, {
356
374
  onlyFiles: true,
357
375
  ignore,
@@ -388,7 +406,7 @@ const hashFile = async (filepath)=>{
388
406
  };
389
407
 
390
408
  const base64Encode = (obj)=>Buffer.from(JSON.stringify(obj), "utf8").toString("base64");
391
- const getBearerToken = ({ token , ciService , owner , repository , jobId , runId , prNumber })=>{
409
+ const getBearerToken = ({ token, ciService, owner, repository, jobId, runId, prNumber })=>{
392
410
  if (token) return `Bearer ${token}`;
393
411
  switch(ciService){
394
412
  case "GitHub Actions":
@@ -449,7 +467,7 @@ const createArgosApiClient = (options)=>{
449
467
  return call("POST", "/builds", input);
450
468
  },
451
469
  updateBuild: async (input)=>{
452
- const { buildId , ...body } = input;
470
+ const { buildId, ...body } = input;
453
471
  return call("PUT", `/builds/${buildId}`, body);
454
472
  }
455
473
  };
@@ -487,12 +505,12 @@ const getConfigFromOptions = (options)=>{
487
505
  const config = createConfig();
488
506
  const ciEnv = getCiEnvironment();
489
507
  config.load({
490
- apiBaseUrl: config.get("apiBaseUrl") ?? options.apiBaseUrl,
491
- commit: config.get("commit") ?? options.commit ?? ciEnv?.commit ?? null,
492
- branch: config.get("branch") ?? options.branch ?? ciEnv?.branch ?? null,
493
- token: config.get("token") ?? options.token ?? null,
494
- buildName: config.get("buildName") ?? options.buildName ?? null,
495
- prNumber: config.get("prNumber") ?? options.prNumber ?? ciEnv?.prNumber ?? null,
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,
496
514
  prHeadCommit: config.get("prHeadCommit") ?? ciEnv?.prHeadCommit ?? null,
497
515
  ciService: ciEnv?.name ?? null,
498
516
  owner: ciEnv?.owner ?? null,
@@ -560,7 +578,7 @@ const getConfigFromOptions = (options)=>{
560
578
  debug(`Uploading chunk ${i + 1}/${chunks.length}`);
561
579
  const timeLabel = `Chunk ${i + 1}/${chunks.length}`;
562
580
  debugTime(timeLabel);
563
- await Promise.all(chunks[i].map(async ({ key , putUrl })=>{
581
+ await Promise.all(chunks[i].map(async ({ key, putUrl })=>{
564
582
  const screenshot = screenshots.find((s)=>s.hash === key);
565
583
  if (!screenshot) {
566
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.9.0",
4
+ "version": "0.11.0",
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": ">=14.0.0"
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.1.2",
49
- "convict": "^6.2.3",
48
+ "axios": "^1.5.0",
49
+ "convict": "^6.2.4",
50
50
  "debug": "^4.3.4",
51
- "env-ci": "^7.3.0",
52
- "fast-glob": "^3.2.12",
53
- "sharp": "^0.31.1",
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.1",
58
- "msw": "^0.47.4",
59
- "rollup": "^2.79.1",
60
- "rollup-plugin-dts": "^4.2.3",
61
- "rollup-plugin-swc3": "^0.6.0"
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": "b54cc5676562cb39a06177899c23f33036b7236b"
64
+ "gitHead": "75d2c0c4dc539dd294d33fb67512ee332186ebeb"
64
65
  }