@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.
- package/dist/index.js +47 -38
- 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 "
|
|
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 "
|
|
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
|
|
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
|
-
|
|
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.
|
|
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 "
|
|
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 "
|
|
774
|
-
import { basename } from "
|
|
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 "
|
|
840
|
-
import { createHash } from "
|
|
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 "
|
|
889
|
-
|
|
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
|
|
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 "
|
|
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
|
|
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
|
|
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
|
-
|
|
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": "
|
|
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": ">=
|
|
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.
|
|
44
|
-
"@argos-ci/util": "
|
|
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.
|
|
48
|
+
"sharp": "^0.34.3",
|
|
50
49
|
"tmp": "^0.2.3"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"@octokit/webhooks": "^
|
|
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.
|
|
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": "
|
|
67
|
+
"gitHead": "807e4a9f3c4bfddd4197ed7394b032a39bc1c58e"
|
|
69
68
|
}
|