@argos-ci/core 3.2.3 → 4.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.js +47 -38
  2. package/package.json +8 -9
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { createClient, throwAPIError } from "@argos-ci/api-client";
5
5
  import convict from "convict";
6
6
 
7
7
  // src/ci-environment/git.ts
8
- import { execSync } from "node:child_process";
8
+ import { execSync } from "child_process";
9
9
 
10
10
  // src/debug.ts
11
11
  import createDebug from "debug";
@@ -214,8 +214,7 @@ var service3 = {
214
214
  var heroku_default = service3;
215
215
 
216
216
  // src/ci-environment/services/github-actions.ts
217
- import { existsSync, readFileSync } from "node:fs";
218
- import axios from "axios";
217
+ import { existsSync, readFileSync } from "fs";
219
218
  async function getPullRequestFromHeadSha({ env }, sha) {
220
219
  debug("Fetching pull request number from head sha", sha);
221
220
  if (!env.GITHUB_REPOSITORY) {
@@ -241,27 +240,32 @@ DISABLE_GITHUB_TOKEN_WARNING: true
241
240
  return null;
242
241
  }
243
242
  try {
244
- const result = await axios.get(
245
- `https://api.github.com/repos/${env.GITHUB_REPOSITORY}/pulls`,
246
- {
247
- params: {
248
- state: "open",
249
- sort: "updated",
250
- per_page: 30,
251
- page: 1
252
- },
253
- headers: {
254
- Accept: "application/vnd.github+json",
255
- Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
256
- "X-GitHub-Api-Version": "2022-11-28"
257
- }
258
- }
243
+ const url = new URL(
244
+ `https://api.github.com/repos/${env.GITHUB_REPOSITORY}/pulls`
259
245
  );
260
- if (result.data.length === 0) {
246
+ url.search = new URLSearchParams({
247
+ state: "open",
248
+ sort: "updated",
249
+ per_page: "30",
250
+ page: "1"
251
+ }).toString();
252
+ const response = await fetch(url, {
253
+ headers: {
254
+ Accept: "application/vnd.github+json",
255
+ Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
256
+ "X-GitHub-Api-Version": "2022-11-28"
257
+ },
258
+ signal: AbortSignal.timeout(1e4)
259
+ });
260
+ if (!response.ok) {
261
+ throw new Error(`Failed to fetch pull requests: ${response.statusText}`);
262
+ }
263
+ const result = await response.json();
264
+ if (result.length === 0) {
261
265
  debug("Aborting because no pull request found");
262
266
  return null;
263
267
  }
264
- const matchingPr = result.data.find((pr) => pr.head.sha === sha);
268
+ const matchingPr = result.find((pr) => pr.head.sha === sha);
265
269
  if (matchingPr) {
266
270
  debug("Pull request found", matchingPr);
267
271
  return matchingPr;
@@ -752,7 +756,7 @@ async function readConfig(options = {}) {
752
756
  }
753
757
 
754
758
  // src/discovery.ts
755
- import { resolve } from "node:path";
759
+ import { resolve } from "path";
756
760
  import glob from "fast-glob";
757
761
  var discoverScreenshots = async (patterns, { root = process.cwd(), ignore } = {}) => {
758
762
  debug(
@@ -770,8 +774,8 @@ var discoverScreenshots = async (patterns, { root = process.cwd(), ignore } = {}
770
774
  };
771
775
 
772
776
  // src/optimize.ts
773
- import { promisify } from "node:util";
774
- import { basename } from "node:path";
777
+ import { promisify } from "util";
778
+ import { basename } from "path";
775
779
  import sharp from "sharp";
776
780
  import tmp from "tmp";
777
781
  var tmpFile = promisify(tmp.file);
@@ -836,8 +840,8 @@ var optimizeScreenshot = async (filepath) => {
836
840
  };
837
841
 
838
842
  // src/hashing.ts
839
- import { createReadStream } from "node:fs";
840
- import { createHash } from "node:crypto";
843
+ import { createReadStream } from "fs";
844
+ import { createHash } from "crypto";
841
845
  var hashFile = async (filepath) => {
842
846
  const fileStream = createReadStream(filepath);
843
847
  const hash = createHash("sha256");
@@ -885,19 +889,24 @@ function getAuthToken({
885
889
  }
886
890
 
887
891
  // src/s3.ts
888
- import { readFile } from "node:fs/promises";
889
- import axios2 from "axios";
890
- var upload = async (input) => {
892
+ import { readFile } from "fs/promises";
893
+ async function uploadFile(input) {
891
894
  const file = await readFile(input.path);
892
- await axios2({
895
+ const response = await fetch(input.url, {
893
896
  method: "PUT",
894
- url: input.url,
895
- data: file,
896
897
  headers: {
897
- "Content-Type": input.contentType
898
- }
898
+ "Content-Type": input.contentType,
899
+ "Content-Length": file.length.toString()
900
+ },
901
+ signal: AbortSignal.timeout(3e4),
902
+ body: new Uint8Array(file)
899
903
  });
900
- };
904
+ if (!response.ok) {
905
+ throw new Error(
906
+ `Failed to upload file to ${input.url}: ${response.status} ${response.statusText}`
907
+ );
908
+ }
909
+ }
901
910
 
902
911
  // src/util/chunk.ts
903
912
  var chunk = (collection, size) => {
@@ -915,7 +924,7 @@ import { getPlaywrightTracePath, readMetadata } from "@argos-ci/util";
915
924
 
916
925
  // src/version.ts
917
926
  import { readVersionFromPackage } from "@argos-ci/util";
918
- import { createRequire } from "node:module";
927
+ import { createRequire } from "module";
919
928
  var require2 = createRequire(import.meta.url);
920
929
  async function getArgosCoreSDKIdentifier() {
921
930
  const pkgPath = require2.resolve("@argos-ci/core/package.json");
@@ -951,7 +960,7 @@ async function uploadFilesToS3(files) {
951
960
  }
952
961
  await Promise.all(
953
962
  chunk2.map(async ({ url, path, contentType }) => {
954
- await upload({
963
+ await uploadFile({
955
964
  url,
956
965
  path,
957
966
  contentType
@@ -971,7 +980,7 @@ function formatPreviewUrl(url, formatter) {
971
980
  formatter.baseUrl
972
981
  ).href;
973
982
  }
974
- async function upload2(params) {
983
+ async function upload(params) {
975
984
  debug("Starting upload with params", params);
976
985
  const [config, argosSdk] = await Promise.all([
977
986
  getConfigFromOptions(params),
@@ -1183,5 +1192,5 @@ async function finalize(params) {
1183
1192
  export {
1184
1193
  finalize,
1185
1194
  readConfig,
1186
- upload2 as upload
1195
+ upload
1187
1196
  };
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": "3.2.3",
4
+ "version": "4.0.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "exports": {
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/argos-ci/argos-javascript/issues"
25
25
  },
26
26
  "engines": {
27
- "node": ">=18.0.0"
27
+ "node": ">=20.0.0"
28
28
  },
29
29
  "license": "MIT",
30
30
  "keywords": [
@@ -40,21 +40,20 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@argos-ci/api-client": "0.8.2",
44
- "@argos-ci/util": "2.3.3",
45
- "axios": "^1.8.4",
43
+ "@argos-ci/api-client": "0.9.0",
44
+ "@argos-ci/util": "3.0.0",
46
45
  "convict": "^6.2.4",
47
46
  "debug": "^4.4.0",
48
47
  "fast-glob": "^3.3.3",
49
- "sharp": "^0.33.5",
48
+ "sharp": "^0.34.3",
50
49
  "tmp": "^0.2.3"
51
50
  },
52
51
  "devDependencies": {
53
- "@octokit/webhooks": "^13.7.5",
52
+ "@octokit/webhooks": "^14.1.3",
54
53
  "@types/convict": "^6.1.6",
55
54
  "@types/debug": "^4.1.12",
56
55
  "@types/tmp": "^0.2.6",
57
- "msw": "^2.7.3",
56
+ "msw": "^2.10.4",
58
57
  "vitest": "catalog:"
59
58
  },
60
59
  "scripts": {
@@ -65,5 +64,5 @@
65
64
  "lint": "eslint .",
66
65
  "test": "vitest"
67
66
  },
68
- "gitHead": "c54dac3320a10630c31549153473b70a2b42c2b6"
67
+ "gitHead": "807e4a9f3c4bfddd4197ed7394b032a39bc1c58e"
69
68
  }