@argos-ci/cli 0.4.2 → 0.4.3
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.mjs +16 -52
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -4,14 +4,13 @@ import { resolve } from 'node:path';
|
|
|
4
4
|
import { program } from 'commander';
|
|
5
5
|
import convict from 'convict';
|
|
6
6
|
import { execSync } from 'node:child_process';
|
|
7
|
-
import {
|
|
7
|
+
import { existsSync, readFileSync, createReadStream } from 'node:fs';
|
|
8
8
|
import createDebug from 'debug';
|
|
9
9
|
import envCi from 'env-ci';
|
|
10
10
|
import glob from 'fast-glob';
|
|
11
11
|
import { promisify } from 'node:util';
|
|
12
12
|
import sharp from 'sharp';
|
|
13
13
|
import tmp from 'tmp';
|
|
14
|
-
import { createReadStream } from 'node:fs';
|
|
15
14
|
import { createHash } from 'node:crypto';
|
|
16
15
|
import axios from 'axios';
|
|
17
16
|
import ora from 'ora';
|
|
@@ -173,39 +172,6 @@ const service$3 = {
|
|
|
173
172
|
})
|
|
174
173
|
};
|
|
175
174
|
|
|
176
|
-
const getSha = ({ env })=>{
|
|
177
|
-
const isPr = env.GITHUB_EVENT_NAME === "pull_request" || env.GITHUB_EVENT_NAME === "pull_request_target";
|
|
178
|
-
if (isPr) {
|
|
179
|
-
const mergeCommitRegex = /^[a-z0-9]{40} [a-z0-9]{40}$/;
|
|
180
|
-
const mergeCommitMessage = execSync$1("git show --no-patch --format=%P").toString().trim();
|
|
181
|
-
// console.log(
|
|
182
|
-
// `Handling PR with parent hash(es) '${mergeCommitMessage}' of current commit.`
|
|
183
|
-
// );
|
|
184
|
-
if (mergeCommitRegex.exec(mergeCommitMessage)) {
|
|
185
|
-
const mergeCommit = mergeCommitMessage.split(" ")[1];
|
|
186
|
-
// console.log(
|
|
187
|
-
// `Fixing merge commit SHA ${process.env.GITHUB_SHA} -> ${mergeCommit}`
|
|
188
|
-
// );
|
|
189
|
-
return mergeCommit;
|
|
190
|
-
} else if (mergeCommitMessage === "") {
|
|
191
|
-
console.error(`Error: automatic detection of commit SHA failed.
|
|
192
|
-
|
|
193
|
-
Please run "actions/checkout" with "fetch-depth: 2". Example:
|
|
194
|
-
|
|
195
|
-
steps:
|
|
196
|
-
- uses: actions/checkout@v3
|
|
197
|
-
with:
|
|
198
|
-
fetch-depth: 2
|
|
199
|
-
|
|
200
|
-
`);
|
|
201
|
-
process.exit(1);
|
|
202
|
-
} else {
|
|
203
|
-
console.error(`Commit with SHA ${process.env.GITHUB_SHA} is not a valid commit`);
|
|
204
|
-
process.exit(1);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return process.env.GITHUB_SHA ?? null;
|
|
208
|
-
};
|
|
209
175
|
const getBranch = ({ env })=>{
|
|
210
176
|
if (env.GITHUB_HEAD_REF) {
|
|
211
177
|
return env.GITHUB_HEAD_REF;
|
|
@@ -221,34 +187,32 @@ const getRepository$1 = ({ env })=>{
|
|
|
221
187
|
if (!env.GITHUB_REPOSITORY) return null;
|
|
222
188
|
return env.GITHUB_REPOSITORY.split("/")[1];
|
|
223
189
|
};
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return Number(branchMatches[1]);
|
|
229
|
-
}
|
|
230
|
-
return null;
|
|
190
|
+
const readEventPayload = ({ env })=>{
|
|
191
|
+
if (!env.GITHUB_EVENT_PATH) return null;
|
|
192
|
+
if (!existsSync(env.GITHUB_EVENT_PATH)) return null;
|
|
193
|
+
return JSON.parse(readFileSync(env.GITHUB_EVENT_PATH, "utf-8"));
|
|
231
194
|
};
|
|
232
195
|
const service$2 = {
|
|
233
196
|
name: "GitHub Actions",
|
|
234
197
|
detect: ({ env })=>Boolean(env.GITHUB_ACTIONS),
|
|
235
|
-
config: ({ env })=>
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
198
|
+
config: ({ env })=>{
|
|
199
|
+
const payload = readEventPayload({
|
|
200
|
+
env
|
|
201
|
+
});
|
|
202
|
+
return {
|
|
203
|
+
commit: payload?.pull_request?.head.sha || process.env.GITHUB_SHA || null,
|
|
204
|
+
branch: payload?.pull_request?.head.ref || getBranch({
|
|
240
205
|
env
|
|
241
|
-
}),
|
|
206
|
+
}) || null,
|
|
242
207
|
owner: env.GITHUB_REPOSITORY_OWNER || null,
|
|
243
208
|
repository: getRepository$1({
|
|
244
209
|
env
|
|
245
210
|
}),
|
|
246
211
|
jobId: env.GITHUB_JOB || null,
|
|
247
212
|
runId: env.GITHUB_RUN_ID || null,
|
|
248
|
-
prNumber:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
})
|
|
213
|
+
prNumber: payload?.pull_request?.number || null
|
|
214
|
+
};
|
|
215
|
+
}
|
|
252
216
|
};
|
|
253
217
|
|
|
254
218
|
const getPrNumber$1 = ({ env })=>{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/cli",
|
|
3
3
|
"description": "Visual testing solution to avoid visual regression. Argos CLI is used to interact with and upload screenshots to argos-ci.com via command line.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.3",
|
|
5
5
|
"bin": {
|
|
6
6
|
"argos": "./bin/argos-cli.js"
|
|
7
7
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@argos-ci/core": "^0.7.
|
|
43
|
+
"@argos-ci/core": "^0.7.3",
|
|
44
44
|
"commander": "^9.4.1",
|
|
45
45
|
"ora": "^6.1.2",
|
|
46
46
|
"update-notifier": "^6.0.2"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"rollup": "^2.79.1",
|
|
50
50
|
"rollup-plugin-swc3": "^0.6.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "56d7e2259161c49265d8983ce0f0ecfe71910d2b"
|
|
53
53
|
}
|