@argos-ci/core 1.5.5-alpha.3 → 2.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.
Files changed (2) hide show
  1. package/dist/index.mjs +24 -30
  2. package/package.json +11 -11
package/dist/index.mjs CHANGED
@@ -181,7 +181,7 @@ const getBranch = ({ env })=>{
181
181
  return null;
182
182
  }
183
183
  const matches = branchRegex.exec(env.GITHUB_REF);
184
- return (matches === null || matches === void 0 ? void 0 : matches[1]) ?? null;
184
+ return matches?.[1] ?? null;
185
185
  };
186
186
  const getRepository$1 = ({ env })=>{
187
187
  if (!env.GITHUB_REPOSITORY) return null;
@@ -196,7 +196,6 @@ const service$4 = {
196
196
  name: "GitHub Actions",
197
197
  detect: ({ env })=>Boolean(env.GITHUB_ACTIONS),
198
198
  config: async ({ env })=>{
199
- var _payload_pull_request, _payload_pull_request1, _payload_pull_request2;
200
199
  const payload = readEventPayload({
201
200
  env
202
201
  });
@@ -215,7 +214,7 @@ const service$4 = {
215
214
  nonce: `${env.GITHUB_RUN_ID}-${env.GITHUB_RUN_ATTEMPT}` || null
216
215
  };
217
216
  // If the job is triggered by from a "deployment" or a "deployment_status"
218
- if (payload === null || payload === void 0 ? void 0 : payload.deployment) {
217
+ if (payload?.deployment) {
219
218
  debug("Deployment event detected");
220
219
  // Try to find a relevant pull request for the sha
221
220
  const pullRequest = await getPullRequestFromHeadSha({
@@ -225,18 +224,18 @@ const service$4 = {
225
224
  ...commonConfig,
226
225
  // If no pull request is found, we fallback to the deployment environment as branch name
227
226
  // Branch name is required to create a build but has no real impact on the build.
228
- branch: (pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.head.ref) || payload.deployment.environment || null,
229
- prNumber: (pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.number) || null,
230
- prHeadCommit: (pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.head.sha) || null
227
+ branch: pullRequest?.head.ref || payload.deployment.environment || null,
228
+ prNumber: pullRequest?.number || null,
229
+ prHeadCommit: pullRequest?.head.sha || null
231
230
  };
232
231
  }
233
232
  return {
234
233
  ...commonConfig,
235
- branch: (payload === null || payload === void 0 ? void 0 : (_payload_pull_request = payload.pull_request) === null || _payload_pull_request === void 0 ? void 0 : _payload_pull_request.head.ref) || getBranch({
234
+ branch: payload?.pull_request?.head.ref || getBranch({
236
235
  env
237
236
  }) || null,
238
- prNumber: (payload === null || payload === void 0 ? void 0 : (_payload_pull_request1 = payload.pull_request) === null || _payload_pull_request1 === void 0 ? void 0 : _payload_pull_request1.number) || null,
239
- prHeadCommit: (payload === null || payload === void 0 ? void 0 : (_payload_pull_request2 = payload.pull_request) === null || _payload_pull_request2 === void 0 ? void 0 : _payload_pull_request2.head.sha) ?? null
237
+ prNumber: payload?.pull_request?.number || null,
238
+ prHeadCommit: payload?.pull_request?.head.sha ?? null
240
239
  };
241
240
  }
242
241
  };
@@ -495,21 +494,21 @@ async function readConfig(options = {}) {
495
494
  const ciEnv = await getCiEnvironment();
496
495
  config.load({
497
496
  apiBaseUrl: options.apiBaseUrl || config.get("apiBaseUrl"),
498
- commit: options.commit || config.get("commit") || (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.commit) || null,
499
- branch: options.branch || config.get("branch") || (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.branch) || null,
497
+ commit: options.commit || config.get("commit") || ciEnv?.commit || null,
498
+ branch: options.branch || config.get("branch") || ciEnv?.branch || null,
500
499
  token: options.token || config.get("token") || null,
501
500
  buildName: options.buildName || config.get("buildName") || null,
502
- prNumber: options.prNumber || config.get("prNumber") || (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.prNumber) || null,
503
- prHeadCommit: config.get("prHeadCommit") || (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.prHeadCommit) || null,
501
+ prNumber: options.prNumber || config.get("prNumber") || ciEnv?.prNumber || null,
502
+ prHeadCommit: config.get("prHeadCommit") || ciEnv?.prHeadCommit || null,
504
503
  referenceBranch: options.referenceBranch || config.get("referenceBranch") || null,
505
504
  referenceCommit: options.referenceCommit || config.get("referenceCommit") || null,
506
- ciService: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.name) || null,
507
- owner: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.owner) || null,
508
- repository: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.repository) || null,
509
- jobId: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.jobId) || null,
510
- runId: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.runId) || null,
505
+ ciService: ciEnv?.name || null,
506
+ owner: ciEnv?.owner || null,
507
+ repository: ciEnv?.repository || null,
508
+ jobId: ciEnv?.jobId || null,
509
+ runId: ciEnv?.runId || null,
511
510
  parallel: options.parallel ?? config.get("parallel") ?? false,
512
- parallelNonce: options.parallelNonce || config.get("parallelNonce") || (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.nonce) || null,
511
+ parallelNonce: options.parallelNonce || config.get("parallelNonce") || ciEnv?.nonce || null,
513
512
  parallelTotal: options.parallelTotal || config.get("parallelTotal") || null
514
513
  });
515
514
  config.validate();
@@ -612,8 +611,7 @@ const createArgosApiClient = (options)=>{
612
611
  });
613
612
  return response.data;
614
613
  } catch (error) {
615
- var _error_response_data_error, _error_response_data, _error_response;
616
- if (error === null || error === void 0 ? void 0 : (_error_response = error.response) === null || _error_response === void 0 ? void 0 : (_error_response_data = _error_response.data) === null || _error_response_data === void 0 ? void 0 : (_error_response_data_error = _error_response_data.error) === null || _error_response_data_error === void 0 ? void 0 : _error_response_data_error.message) {
614
+ if (error?.response?.data?.error?.message) {
617
615
  // @ts-ignore
618
616
  throw new Error(error.response.data.error.message, {
619
617
  cause: error
@@ -691,7 +689,6 @@ async function uploadFilesToS3(files) {
691
689
  /**
692
690
  * Upload screenshots to argos-ci.com.
693
691
  */ async function upload(params) {
694
- var _result_pwTraces;
695
692
  debug("Starting upload with params", params);
696
693
  // Read config
697
694
  const config = await getConfigFromOptions(params);
@@ -774,7 +771,7 @@ async function uploadFilesToS3(files) {
774
771
  contentType: "image/png"
775
772
  };
776
773
  }),
777
- ...((_result_pwTraces = result.pwTraces) === null || _result_pwTraces === void 0 ? void 0 : _result_pwTraces.map(({ key, putUrl })=>{
774
+ ...result.pwTraces?.map(({ key, putUrl })=>{
778
775
  const screenshot = screenshots.find((s)=>s.pwTrace && s.pwTrace.hash === key);
779
776
  if (!screenshot || !screenshot.pwTrace) {
780
777
  throw new Error(`Invariant: trace with ${key} not found`);
@@ -784,22 +781,19 @@ async function uploadFilesToS3(files) {
784
781
  path: screenshot.pwTrace.path,
785
782
  contentType: "application/json"
786
783
  };
787
- })) ?? []
784
+ }) ?? []
788
785
  ];
789
786
  await uploadFilesToS3(uploadFiles);
790
787
  // Update build
791
788
  debug("Updating build");
792
789
  await apiClient.updateBuild({
793
790
  buildId: result.build.id,
794
- screenshots: screenshots.map((screenshot)=>{
795
- var _screenshot_pwTrace;
796
- return {
791
+ screenshots: screenshots.map((screenshot)=>({
797
792
  key: screenshot.hash,
798
793
  name: screenshot.name,
799
794
  metadata: screenshot.metadata,
800
- pwTraceKey: ((_screenshot_pwTrace = screenshot.pwTrace) === null || _screenshot_pwTrace === void 0 ? void 0 : _screenshot_pwTrace.hash) ?? null
801
- };
802
- }),
795
+ pwTraceKey: screenshot.pwTrace?.hash ?? null
796
+ })),
803
797
  parallel: config.parallel,
804
798
  parallelTotal: config.parallelTotal
805
799
  });
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": "1.5.5-alpha.3+f0cee6a",
4
+ "version": "2.0.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "types": "./dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/argos-ci/argos-javascript/issues"
25
25
  },
26
26
  "engines": {
27
- "node": ">=16.0.0"
27
+ "node": ">=18.0.0"
28
28
  },
29
29
  "license": "MIT",
30
30
  "keywords": [
@@ -40,24 +40,24 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@argos-ci/util": "1.2.1",
44
- "axios": "^1.5.0",
43
+ "@argos-ci/util": "2.0.0",
44
+ "axios": "^1.6.8",
45
45
  "convict": "^6.2.4",
46
46
  "debug": "^4.3.4",
47
- "fast-glob": "^3.3.1",
48
- "sharp": "^0.32.5",
49
- "tmp": "^0.2.1"
47
+ "fast-glob": "^3.3.2",
48
+ "sharp": "^0.33.3",
49
+ "tmp": "^0.2.3"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/convict": "^6.1.4",
52
+ "@types/convict": "^6.1.6",
53
53
  "@types/debug": "^4.1.12",
54
- "@types/tmp": "^0.2.3",
55
- "msw": "^1.3.0"
54
+ "@types/tmp": "^0.2.6",
55
+ "msw": "^2.2.13"
56
56
  },
57
57
  "scripts": {
58
58
  "prebuild": "rm -rf dist",
59
59
  "build": "rollup -c",
60
60
  "e2e": "node ./e2e/upload.cjs && node ./e2e/upload.mjs"
61
61
  },
62
- "gitHead": "f0cee6a09987b4af96e8d6705f958a40ebe2b866"
62
+ "gitHead": "fcadf37f2a9c4a65a3f4c082db56aff2576c8c16"
63
63
  }