@argos-ci/core 4.1.4 → 4.1.6

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.d.ts CHANGED
@@ -293,27 +293,99 @@ declare function finalize(params: FinalizeParameters): Promise<{
293
293
  }>;
294
294
 
295
295
  interface Config {
296
+ /**
297
+ * Argos API base URL (for self-hosted installations)
298
+ */
296
299
  apiBaseUrl: string;
300
+ /**
301
+ * The commit SHA1 (40 characters)
302
+ */
297
303
  commit: string;
304
+ /**
305
+ * The git branch name (e.g. "main", "master", "develop", "release/1.0" etc.)
306
+ */
298
307
  branch: string;
308
+ /**
309
+ * The Argos repository token (40 characters)
310
+ */
299
311
  token: string | null;
312
+ /**
313
+ * The name of the build (for multi-build setups)
314
+ */
300
315
  buildName: string | null;
316
+ /**
317
+ * Whether the current run is parallelized (split in multiple jobs) or not
318
+ */
301
319
  parallel: boolean;
320
+ /**
321
+ * The parallelization nonce (identifier shared by all parallel jobs)
322
+ */
302
323
  parallelNonce: string | null;
324
+ /**
325
+ * The index of the current job (between 1 and parallelTotal inclusive, or null if not set)
326
+ */
303
327
  parallelIndex: number | null;
328
+ /**
329
+ * The total number of parallel jobs (or -1 if unknown, or null if not set)
330
+ */
304
331
  parallelTotal: number | null;
332
+ /**
333
+ * The reference git branch to compare against
334
+ */
305
335
  referenceBranch: string | null;
336
+ /**
337
+ * The reference commit SHA1 to compare against
338
+ */
306
339
  referenceCommit: string | null;
340
+ /**
341
+ * The git repository slug (e.g. "my-org/my-repo" or "my-user/my-repo")
342
+ * If from a fork, this is the fork's repository.
343
+ */
307
344
  repository: string | null;
345
+ /**
346
+ * The original git repository slug (e.g. "my-org/my-repo" or "my-user/my-repo")
347
+ * If from a fork, this is the base repository.
348
+ */
349
+ originalRepository: string | null;
350
+ /**
351
+ * The CI job identifier (if available)
352
+ */
308
353
  jobId: string | null;
354
+ /**
355
+ * The CI run identifier (if available)
356
+ */
309
357
  runId: string | null;
358
+ /**
359
+ * The CI run attempt (if available)
360
+ */
310
361
  runAttempt: number | null;
362
+ /**
363
+ * The pull request number (if available)
364
+ */
311
365
  prNumber: number | null;
366
+ /**
367
+ * The pull request head commit SHA1 (if available)
368
+ */
312
369
  prHeadCommit: string | null;
370
+ /**
371
+ * The pull request base branch (if available)
372
+ */
313
373
  prBaseBranch: string | null;
374
+ /**
375
+ * The mode Argos is running in (ci or monitoring)
376
+ */
314
377
  mode: "ci" | "monitoring" | null;
378
+ /**
379
+ * The CI provider name (if detected)
380
+ */
315
381
  ciProvider: string | null;
382
+ /**
383
+ * The threshold to use for this run (if any, between 0 and 1 inclusive, e.g. 0.1 for 10% or 0.0 for 0%)
384
+ */
316
385
  threshold: number | null;
386
+ /**
387
+ * The base URL to use for preview links (if any)
388
+ */
317
389
  previewBaseUrl: string | null;
318
390
  }
319
391
  declare function readConfig(options?: Partial<Config>): Promise<Config>;
package/dist/index.js CHANGED
@@ -131,10 +131,12 @@ var service = {
131
131
  detect: ({ env }) => Boolean(env.BITRISE_IO),
132
132
  config: (context) => {
133
133
  const { env } = context;
134
+ const repository = getRepository(context);
134
135
  return {
135
136
  commit: env.BITRISE_GIT_COMMIT || null,
136
137
  branch: env.BITRISE_GIT_BRANCH || null,
137
- repository: getRepository(context),
138
+ repository,
139
+ originalRepository: repository,
138
140
  jobId: null,
139
141
  runId: null,
140
142
  runAttempt: null,
@@ -178,11 +180,13 @@ var service2 = {
178
180
  detect: ({ env }) => Boolean(env.BUILDKITE),
179
181
  config: (context) => {
180
182
  const { env } = context;
183
+ const repository = getRepository2(context);
181
184
  return {
182
185
  // Buildkite doesn't work well so we fallback to git to ensure we have commit and branch
183
186
  commit: env.BUILDKITE_COMMIT || head() || null,
184
187
  branch: env.BUILDKITE_BRANCH || branch() || null,
185
- repository: getRepository2(context),
188
+ repository,
189
+ originalRepository: repository,
186
190
  jobId: null,
187
191
  runId: null,
188
192
  runAttempt: null,
@@ -207,6 +211,7 @@ var service3 = {
207
211
  branch: env.HEROKU_TEST_RUN_BRANCH || null,
208
212
  owner: null,
209
213
  repository: null,
214
+ originalRepository: null,
210
215
  jobId: null,
211
216
  runId: null,
212
217
  runAttempt: null,
@@ -306,13 +311,16 @@ function getBranchFromPayload(payload) {
306
311
  return null;
307
312
  }
308
313
  function getRepository3(context, payload) {
309
- const { env } = context;
310
314
  if (payload && "pull_request" in payload && payload.pull_request) {
311
315
  const pr = payload.pull_request;
312
316
  if (pr.head && pr.head.repo && pr.head.repo.full_name) {
313
317
  return pr.head.repo.full_name;
314
318
  }
315
319
  }
320
+ return getOriginalRepository(context);
321
+ }
322
+ function getOriginalRepository(context) {
323
+ const { env } = context;
316
324
  return env.GITHUB_REPOSITORY || null;
317
325
  }
318
326
  function readEventPayload({ env }) {
@@ -351,6 +359,7 @@ var service4 = {
351
359
  return {
352
360
  commit: sha,
353
361
  repository: getRepository3(context, payload),
362
+ originalRepository: getOriginalRepository(context),
354
363
  jobId: env.GITHUB_JOB || null,
355
364
  runId: env.GITHUB_RUN_ID || null,
356
365
  runAttempt: env.GITHUB_RUN_ATTEMPT ? Number(env.GITHUB_RUN_ATTEMPT) : null,
@@ -380,6 +389,10 @@ function getRepository4(context) {
380
389
  if (env.CIRCLE_PR_REPONAME && env.CIRCLE_PR_USERNAME) {
381
390
  return `${env.CIRCLE_PR_USERNAME}/${env.CIRCLE_PR_REPONAME}`;
382
391
  }
392
+ return getOriginalRepository2(context);
393
+ }
394
+ function getOriginalRepository2(context) {
395
+ const { env } = context;
383
396
  if (env.CIRCLE_PROJECT_USERNAME && env.CIRCLE_PROJECT_REPONAME) {
384
397
  return `${env.CIRCLE_PROJECT_USERNAME}/${env.CIRCLE_PROJECT_REPONAME}`;
385
398
  }
@@ -395,6 +408,7 @@ var service5 = {
395
408
  commit: env.CIRCLE_SHA1 || null,
396
409
  branch: env.CIRCLE_BRANCH || null,
397
410
  repository: getRepository4(context),
411
+ originalRepository: getOriginalRepository2(context),
398
412
  jobId: null,
399
413
  runId: null,
400
414
  runAttempt: null,
@@ -415,10 +429,11 @@ function getRepository5(context) {
415
429
  if (env.TRAVIS_PULL_REQUEST_SLUG) {
416
430
  return env.TRAVIS_PULL_REQUEST_SLUG;
417
431
  }
418
- if (env.TRAVIS_REPO_SLUG) {
419
- return env.TRAVIS_REPO_SLUG;
420
- }
421
- return null;
432
+ return getOriginalRepository3(context);
433
+ }
434
+ function getOriginalRepository3(context) {
435
+ const { env } = context;
436
+ return env.TRAVIS_REPO_SLUG || null;
422
437
  }
423
438
  function getPrNumber3(context) {
424
439
  const { env } = context;
@@ -437,6 +452,7 @@ var service6 = {
437
452
  commit: env.TRAVIS_COMMIT || null,
438
453
  branch: env.TRAVIS_BRANCH || null,
439
454
  repository: getRepository5(ctx),
455
+ originalRepository: getOriginalRepository3(ctx),
440
456
  jobId: null,
441
457
  runId: null,
442
458
  runAttempt: null,
@@ -457,6 +473,10 @@ function getRepository6(context) {
457
473
  if (env.CI_MERGE_REQUEST_PROJECT_PATH) {
458
474
  return env.CI_MERGE_REQUEST_PROJECT_PATH;
459
475
  }
476
+ return getOriginalRepository4(context);
477
+ }
478
+ function getOriginalRepository4(context) {
479
+ const { env } = context;
460
480
  return env.CI_PROJECT_PATH || null;
461
481
  }
462
482
  var service7 = {
@@ -469,6 +489,7 @@ var service7 = {
469
489
  commit: env.CI_COMMIT_SHA || null,
470
490
  branch: env.CI_COMMIT_REF_NAME || null,
471
491
  repository: getRepository6(context),
492
+ originalRepository: getOriginalRepository4(context),
472
493
  jobId: null,
473
494
  runId: null,
474
495
  runAttempt: null,
@@ -496,10 +517,12 @@ var service8 = {
496
517
  key: "git",
497
518
  detect: () => checkIsGitRepository(),
498
519
  config: () => {
520
+ const repository = getRepository7();
499
521
  return {
500
522
  commit: head() || null,
501
523
  branch: branch() || null,
502
- repository: getRepository7(),
524
+ repository,
525
+ originalRepository: repository,
503
526
  jobId: null,
504
527
  runId: null,
505
528
  runAttempt: null,
@@ -731,6 +754,11 @@ var schema = {
731
754
  default: null,
732
755
  nullable: true
733
756
  },
757
+ originalRepository: {
758
+ format: String,
759
+ default: null,
760
+ nullable: true
761
+ },
734
762
  ciProvider: {
735
763
  format: String,
736
764
  default: null,
@@ -777,6 +805,7 @@ async function readConfig(options = {}) {
777
805
  referenceBranch: options.referenceBranch || defaultConfig.referenceBranch || null,
778
806
  referenceCommit: options.referenceCommit || defaultConfig.referenceCommit || null,
779
807
  repository: ciEnv?.repository || null,
808
+ originalRepository: ciEnv?.originalRepository || null,
780
809
  jobId: ciEnv?.jobId || null,
781
810
  runId: ciEnv?.runId || null,
782
811
  runAttempt: ciEnv?.runAttempt || null,
@@ -898,14 +927,15 @@ var hashFile = async (filepath) => {
898
927
 
899
928
  // src/auth.ts
900
929
  var base64Encode = (obj) => Buffer.from(JSON.stringify(obj), "utf8").toString("base64");
901
- function getAuthToken({
902
- token,
903
- ciProvider,
904
- repository,
905
- jobId,
906
- runId,
907
- prNumber
908
- }) {
930
+ function getAuthToken(args) {
931
+ const {
932
+ token,
933
+ ciProvider,
934
+ originalRepository: repository,
935
+ jobId,
936
+ runId,
937
+ prNumber
938
+ } = args;
909
939
  if (token) {
910
940
  return token;
911
941
  }
@@ -982,10 +1012,10 @@ async function getConfigFromOptions({
982
1012
  }) {
983
1013
  return readConfig({
984
1014
  ...options,
985
- parallel: Boolean(parallel),
986
- parallelNonce: parallel ? parallel.nonce : null,
987
- parallelTotal: parallel ? parallel.total : null,
988
- parallelIndex: parallel ? parallel.index : null
1015
+ parallel: parallel !== void 0 ? Boolean(parallel) : void 0,
1016
+ parallelNonce: parallel ? parallel.nonce : void 0,
1017
+ parallelTotal: parallel ? parallel.total : void 0,
1018
+ parallelIndex: parallel ? parallel.index : void 0
989
1019
  });
990
1020
  }
991
1021
  async function uploadFilesToS3(files) {
@@ -1211,7 +1241,7 @@ async function upload(params) {
1211
1241
  import { createClient as createClient2, throwAPIError as throwAPIError2 } from "@argos-ci/api-client";
1212
1242
  async function finalize(params) {
1213
1243
  const config = await readConfig({
1214
- parallelNonce: params.parallel?.nonce ?? null
1244
+ parallelNonce: params.parallel?.nonce
1215
1245
  });
1216
1246
  const authToken = getAuthToken(config);
1217
1247
  const apiClient = createClient2({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/core",
3
3
  "description": "Node.js SDK for visual testing with Argos.",
4
- "version": "4.1.4",
4
+ "version": "4.1.6",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "exports": {
@@ -40,20 +40,20 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@argos-ci/api-client": "0.11.0",
43
+ "@argos-ci/api-client": "0.11.1",
44
44
  "@argos-ci/util": "3.1.0",
45
45
  "convict": "^6.2.4",
46
- "debug": "^4.4.0",
46
+ "debug": "^4.4.3",
47
47
  "fast-glob": "^3.3.3",
48
- "sharp": "^0.34.3",
49
- "tmp": "^0.2.3"
48
+ "sharp": "^0.34.4",
49
+ "tmp": "^0.2.5"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@octokit/webhooks": "^14.1.3",
53
53
  "@types/convict": "^6.1.6",
54
54
  "@types/debug": "^4.1.12",
55
55
  "@types/tmp": "^0.2.6",
56
- "msw": "^2.10.4",
56
+ "msw": "^2.11.3",
57
57
  "vitest": "catalog:"
58
58
  },
59
59
  "scripts": {
@@ -64,5 +64,5 @@
64
64
  "lint": "eslint .",
65
65
  "test": "vitest"
66
66
  },
67
- "gitHead": "a1f55cdee00ce144eb5b0f7ef08e451867d0c129"
67
+ "gitHead": "00f28041a847158e437aaab5fc9e816f6b609021"
68
68
  }