@argos-ci/core 0.12.0 → 0.12.1-alpha.4

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
@@ -38,11 +38,11 @@ declare const upload: (params: UploadParameters) => Promise<{
38
38
  url: string;
39
39
  };
40
40
  screenshots: {
41
+ metadata: import("@argos-ci/util").ScreenshotMetadata | null;
41
42
  optimizedPath: string;
42
43
  hash: string;
43
44
  name: string;
44
45
  path: string;
45
46
  }[];
46
47
  }>;
47
-
48
- export { type UploadParameters, upload };
48
+ export { UploadParameters, upload };
package/dist/index.mjs CHANGED
@@ -11,6 +11,7 @@ import tmp from 'tmp';
11
11
  import { createHash } from 'node:crypto';
12
12
  import axios from 'axios';
13
13
  import { readFile } from 'node:fs/promises';
14
+ import { readMetadata } from '@argos-ci/util';
14
15
 
15
16
  const mustBeApiBaseUrl = (value)=>{
16
17
  const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
@@ -213,12 +214,13 @@ const service$3 = {
213
214
  name: "GitHub Actions",
214
215
  detect: ({ env })=>Boolean(env.GITHUB_ACTIONS),
215
216
  config: ({ env })=>{
217
+ var _payload_pull_request, _payload_pull_request1, _payload_pull_request2;
216
218
  const payload = readEventPayload({
217
219
  env
218
220
  });
219
221
  return {
220
222
  commit: process.env.GITHUB_SHA || null,
221
- branch: payload?.pull_request?.head.ref || getBranch({
223
+ 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({
222
224
  env
223
225
  }) || null,
224
226
  owner: env.GITHUB_REPOSITORY_OWNER || null,
@@ -227,8 +229,8 @@ const service$3 = {
227
229
  }),
228
230
  jobId: env.GITHUB_JOB || null,
229
231
  runId: env.GITHUB_RUN_ID || null,
230
- prNumber: payload?.pull_request?.number || null,
231
- prHeadCommit: payload?.pull_request?.head.sha ?? null
232
+ 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,
233
+ 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
232
234
  };
233
235
  }
234
236
  };
@@ -387,10 +389,13 @@ const discoverScreenshots = async (patterns, { root = process.cwd(), ignore } =
387
389
  ignore,
388
390
  cwd: root
389
391
  });
390
- return matches.map((match)=>({
392
+ return matches.map((match)=>{
393
+ const path = resolve(root, match);
394
+ return {
391
395
  name: match,
392
- path: resolve(root, match)
393
- }));
396
+ path
397
+ };
398
+ });
394
399
  };
395
400
 
396
401
  const tmpFile = promisify(tmp.file);
@@ -465,7 +470,8 @@ const createArgosApiClient = (options)=>{
465
470
  });
466
471
  return response.data;
467
472
  } catch (error) {
468
- if (error?.response?.data?.error?.message) {
473
+ var _error_response_data_error, _error_response_data, _error_response;
474
+ 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) {
469
475
  // @ts-ignore
470
476
  throw new Error(error.response.data.error.message, {
471
477
  cause: error
@@ -518,19 +524,19 @@ const getConfigFromOptions = (options)=>{
518
524
  const ciEnv = getCiEnvironment();
519
525
  config.load({
520
526
  apiBaseUrl: options.apiBaseUrl ?? config.get("apiBaseUrl"),
521
- commit: options.commit ?? config.get("commit") ?? ciEnv?.commit ?? null,
522
- branch: options.branch ?? config.get("branch") ?? ciEnv?.branch ?? null,
527
+ commit: options.commit ?? config.get("commit") ?? (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.commit) ?? null,
528
+ branch: options.branch ?? config.get("branch") ?? (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.branch) ?? null,
523
529
  token: options.token ?? config.get("token") ?? null,
524
530
  buildName: options.buildName ?? config.get("buildName") ?? null,
525
- prNumber: options.prNumber ?? config.get("prNumber") ?? ciEnv?.prNumber ?? null,
526
- prHeadCommit: config.get("prHeadCommit") ?? ciEnv?.prHeadCommit ?? null,
531
+ prNumber: options.prNumber ?? config.get("prNumber") ?? (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.prNumber) ?? null,
532
+ prHeadCommit: config.get("prHeadCommit") ?? (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.prHeadCommit) ?? null,
527
533
  referenceBranch: options.referenceBranch ?? config.get("referenceBranch") ?? null,
528
534
  referenceCommit: options.referenceCommit ?? config.get("referenceCommit") ?? null,
529
- ciService: ciEnv?.name ?? null,
530
- owner: ciEnv?.owner ?? null,
531
- repository: ciEnv?.repository ?? null,
532
- jobId: ciEnv?.jobId ?? null,
533
- runId: ciEnv?.runId ?? null
535
+ ciService: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.name) ?? null,
536
+ owner: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.owner) ?? null,
537
+ repository: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.repository) ?? null,
538
+ jobId: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.jobId) ?? null,
539
+ runId: (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.runId) ?? null
534
540
  });
535
541
  if (options.parallel) {
536
542
  config.load({
@@ -564,10 +570,14 @@ const getConfigFromOptions = (options)=>{
564
570
  debug("Found screenshots", foundScreenshots);
565
571
  // Optimize & compute hashes
566
572
  const screenshots = await Promise.all(foundScreenshots.map(async (screenshot)=>{
567
- const optimizedPath = await optimizeScreenshot(screenshot.path);
573
+ const [metadata, optimizedPath] = await Promise.all([
574
+ readMetadata(screenshot.path),
575
+ optimizeScreenshot(screenshot.path)
576
+ ]);
568
577
  const hash = await hashFile(optimizedPath);
569
578
  return {
570
579
  ...screenshot,
580
+ metadata,
571
581
  optimizedPath,
572
582
  hash
573
583
  };
@@ -612,7 +622,8 @@ const getConfigFromOptions = (options)=>{
612
622
  buildId: result.build.id,
613
623
  screenshots: screenshots.map((screenshot)=>({
614
624
  key: screenshot.hash,
615
- name: screenshot.name
625
+ name: screenshot.name,
626
+ metadata: screenshot.metadata
616
627
  })),
617
628
  parallel: config.parallel,
618
629
  parallelTotal: config.parallelTotal
package/package.json CHANGED
@@ -1,12 +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.12.0",
5
- "scripts": {
6
- "prebuild": "rm -rf dist",
7
- "build": "rollup -c",
8
- "e2e": "node ./e2e/upload.cjs && node ./e2e/upload.mjs"
9
- },
4
+ "version": "0.12.1-alpha.4+8a2e9db",
10
5
  "type": "module",
11
6
  "main": "./dist/index.cjs",
12
7
  "types": "./dist/index.d.ts",
@@ -45,6 +40,7 @@
45
40
  "access": "public"
46
41
  },
47
42
  "dependencies": {
43
+ "@argos-ci/util": "0.0.1-alpha.182+8a2e9db",
48
44
  "axios": "^1.5.0",
49
45
  "convict": "^6.2.4",
50
46
  "debug": "^4.3.4",
@@ -55,11 +51,14 @@
55
51
  },
56
52
  "devDependencies": {
57
53
  "@types/convict": "^6.1.4",
54
+ "@types/debug": "^4.1.9",
58
55
  "@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"
56
+ "msw": "^1.3.0"
57
+ },
58
+ "scripts": {
59
+ "prebuild": "rm -rf dist",
60
+ "build": "rollup -c",
61
+ "e2e": "node ./e2e/upload.cjs && node ./e2e/upload.mjs"
63
62
  },
64
- "gitHead": "e58b26f5c3a9998d89353c4435aa742b5ae3d244"
63
+ "gitHead": "8a2e9db6427071708c3d701a3230f228b1216893"
65
64
  }