@argos-ci/core 3.2.2 → 3.2.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.d.ts CHANGED
@@ -288,7 +288,6 @@ interface Config {
288
288
  parallelTotal: number | null;
289
289
  referenceBranch: string | null;
290
290
  referenceCommit: string | null;
291
- owner: string | null;
292
291
  repository: string | null;
293
292
  jobId: string | null;
294
293
  runId: string | null;
package/dist/index.js CHANGED
@@ -49,6 +49,14 @@ function branch() {
49
49
  return null;
50
50
  }
51
51
  }
52
+ function getRepositoryURL() {
53
+ try {
54
+ const url = execSync("git config --get remote.origin.url").toString().trim();
55
+ return url;
56
+ } catch {
57
+ return null;
58
+ }
59
+ }
52
60
  function getMergeBaseCommitShaWithDepth(input) {
53
61
  execSync(
54
62
  `git fetch --update-head-ok --depth ${input.depth} origin ${input.head}:${input.head}`
@@ -99,19 +107,27 @@ function listParentCommits(input) {
99
107
  }
100
108
 
101
109
  // src/ci-environment/services/bitrise.ts
102
- var getPrNumber = ({ env }) => {
110
+ function getPrNumber(context) {
111
+ const { env } = context;
103
112
  return env.BITRISE_PULL_REQUEST ? Number(env.BITRISE_PULL_REQUEST) : null;
104
- };
113
+ }
114
+ function getRepository(context) {
115
+ const { env } = context;
116
+ if (env.BITRISEIO_GIT_REPOSITORY_OWNER && env.BITRISEIO_GIT_REPOSITORY_SLUG) {
117
+ return `${env.BITRISEIO_GIT_REPOSITORY_OWNER}/${env.BITRISEIO_GIT_REPOSITORY_SLUG}`;
118
+ }
119
+ return null;
120
+ }
105
121
  var service = {
106
122
  name: "Bitrise",
107
123
  key: "bitrise",
108
124
  detect: ({ env }) => Boolean(env.BITRISE_IO),
109
- config: ({ env }) => {
125
+ config: (context) => {
126
+ const { env } = context;
110
127
  return {
111
128
  commit: env.BITRISE_GIT_COMMIT || null,
112
129
  branch: env.BITRISE_GIT_BRANCH || null,
113
- owner: env.BITRISEIO_GIT_REPOSITORY_OWNER || null,
114
- repository: env.BITRISEIO_GIT_REPOSITORY_SLUG || null,
130
+ repository: getRepository(context),
115
131
  jobId: null,
116
132
  runId: null,
117
133
  runAttempt: null,
@@ -126,18 +142,40 @@ var service = {
126
142
  };
127
143
  var bitrise_default = service;
128
144
 
145
+ // src/util/url.ts
146
+ function getRepositoryNameFromURL(url) {
147
+ const sshMatch = url.match(/^git@[^:]+:([^/]+)\/(.+?)(?:\.git)?$/);
148
+ if (sshMatch && sshMatch[1] && sshMatch[2]) {
149
+ return `${sshMatch[1]}/${sshMatch[2]}`;
150
+ }
151
+ const httpsMatch = url.match(
152
+ /^(?:https?|git):\/\/[^/]+\/([^/]+)\/(.+?)(?:\.git)?$/
153
+ );
154
+ if (httpsMatch && httpsMatch[1] && httpsMatch[2]) {
155
+ return `${httpsMatch[1]}/${httpsMatch[2]}`;
156
+ }
157
+ return null;
158
+ }
159
+
129
160
  // src/ci-environment/services/buildkite.ts
161
+ function getRepository2(context) {
162
+ const { env } = context;
163
+ if (env.BUILDKITE_REPO) {
164
+ return getRepositoryNameFromURL(env.BUILDKITE_REPO);
165
+ }
166
+ return null;
167
+ }
130
168
  var service2 = {
131
169
  name: "Buildkite",
132
170
  key: "buildkite",
133
171
  detect: ({ env }) => Boolean(env.BUILDKITE),
134
- config: ({ env }) => {
172
+ config: (context) => {
173
+ const { env } = context;
135
174
  return {
136
175
  // Buildkite doesn't work well so we fallback to git to ensure we have commit and branch
137
176
  commit: env.BUILDKITE_COMMIT || head() || null,
138
177
  branch: env.BUILDKITE_BRANCH || branch() || null,
139
- owner: env.BUILDKITE_ORGANIZATION_SLUG || null,
140
- repository: env.BUILDKITE_PROJECT_SLUG || null,
178
+ repository: getRepository2(context),
141
179
  jobId: null,
142
180
  runId: null,
143
181
  runAttempt: null,
@@ -256,11 +294,15 @@ function getBranchFromPayload(payload) {
256
294
  }
257
295
  return null;
258
296
  }
259
- function getRepositoryFromContext({ env }) {
260
- if (!env.GITHUB_REPOSITORY) {
261
- return null;
297
+ function getRepository3(context, payload) {
298
+ const { env } = context;
299
+ if (payload && "pull_request" in payload && payload.pull_request) {
300
+ const pr = payload.pull_request;
301
+ if (pr.head && pr.head.repo && pr.head.repo.full_name) {
302
+ return pr.head.repo.full_name;
303
+ }
262
304
  }
263
- return env.GITHUB_REPOSITORY.split("/")[1] || null;
305
+ return env.GITHUB_REPOSITORY || null;
264
306
  }
265
307
  function readEventPayload({ env }) {
266
308
  if (!env.GITHUB_EVENT_PATH) {
@@ -297,8 +339,7 @@ var service4 = {
297
339
  const pullRequest = payload ? getPullRequestFromPayload(payload) : await getPullRequestFromHeadSha(context, sha);
298
340
  return {
299
341
  commit: sha,
300
- owner: env.GITHUB_REPOSITORY_OWNER || null,
301
- repository: getRepositoryFromContext(context),
342
+ repository: getRepository3(context, payload),
302
343
  jobId: env.GITHUB_JOB || null,
303
344
  runId: env.GITHUB_RUN_ID || null,
304
345
  runAttempt: env.GITHUB_RUN_ATTEMPT ? Number(env.GITHUB_RUN_ATTEMPT) : null,
@@ -315,24 +356,34 @@ var service4 = {
315
356
  var github_actions_default = service4;
316
357
 
317
358
  // src/ci-environment/services/circleci.ts
318
- var getPrNumber2 = ({ env }) => {
319
- const branchRegex = /pull\/(\d+)/;
320
- const matches = branchRegex.exec(env.CIRCLE_PULL_REQUEST || "");
359
+ function getPrNumber2(context) {
360
+ const { env } = context;
361
+ const matches = /pull\/(\d+)/.exec(env.CIRCLE_PULL_REQUEST || "");
321
362
  if (matches) {
322
363
  return Number(matches[1]);
323
364
  }
324
365
  return null;
325
- };
366
+ }
367
+ function getRepository4(context) {
368
+ const { env } = context;
369
+ if (env.CIRCLE_PR_REPONAME && env.CIRCLE_PR_USERNAME) {
370
+ return `${env.CIRCLE_PR_USERNAME}/${env.CIRCLE_PR_REPONAME}`;
371
+ }
372
+ if (env.CIRCLE_PROJECT_USERNAME && env.CIRCLE_PROJECT_REPONAME) {
373
+ return `${env.CIRCLE_PROJECT_USERNAME}/${env.CIRCLE_PROJECT_REPONAME}`;
374
+ }
375
+ return null;
376
+ }
326
377
  var service5 = {
327
378
  name: "CircleCI",
328
379
  key: "circleci",
329
380
  detect: ({ env }) => Boolean(env.CIRCLECI),
330
- config: ({ env }) => {
381
+ config: (context) => {
382
+ const { env } = context;
331
383
  return {
332
384
  commit: env.CIRCLE_SHA1 || null,
333
385
  branch: env.CIRCLE_BRANCH || null,
334
- owner: env.CIRCLE_PROJECT_USERNAME || null,
335
- repository: env.CIRCLE_PROJECT_REPONAME || null,
386
+ repository: getRepository4(context),
336
387
  jobId: null,
337
388
  runId: null,
338
389
  runAttempt: null,
@@ -348,24 +399,23 @@ var service5 = {
348
399
  var circleci_default = service5;
349
400
 
350
401
  // src/ci-environment/services/travis.ts
351
- var getOwner = ({ env }) => {
352
- if (!env.TRAVIS_REPO_SLUG) {
353
- return null;
402
+ function getRepository5(context) {
403
+ const { env } = context;
404
+ if (env.TRAVIS_PULL_REQUEST_SLUG) {
405
+ return env.TRAVIS_PULL_REQUEST_SLUG;
354
406
  }
355
- return env.TRAVIS_REPO_SLUG.split("/")[0] || null;
356
- };
357
- var getRepository = ({ env }) => {
358
- if (!env.TRAVIS_REPO_SLUG) {
359
- return null;
407
+ if (env.TRAVIS_REPO_SLUG) {
408
+ return env.TRAVIS_REPO_SLUG;
360
409
  }
361
- return env.TRAVIS_REPO_SLUG.split("/")[1] || null;
362
- };
363
- var getPrNumber3 = ({ env }) => {
410
+ return null;
411
+ }
412
+ function getPrNumber3(context) {
413
+ const { env } = context;
364
414
  if (env.TRAVIS_PULL_REQUEST) {
365
415
  return Number(env.TRAVIS_PULL_REQUEST);
366
416
  }
367
417
  return null;
368
- };
418
+ }
369
419
  var service6 = {
370
420
  name: "Travis CI",
371
421
  key: "travis",
@@ -375,8 +425,7 @@ var service6 = {
375
425
  return {
376
426
  commit: env.TRAVIS_COMMIT || null,
377
427
  branch: env.TRAVIS_BRANCH || null,
378
- owner: getOwner(ctx),
379
- repository: getRepository(ctx),
428
+ repository: getRepository5(ctx),
380
429
  jobId: null,
381
430
  runId: null,
382
431
  runAttempt: null,
@@ -392,16 +441,23 @@ var service6 = {
392
441
  var travis_default = service6;
393
442
 
394
443
  // src/ci-environment/services/gitlab.ts
444
+ function getRepository6(context) {
445
+ const { env } = context;
446
+ if (env.CI_MERGE_REQUEST_PROJECT_PATH) {
447
+ return env.CI_MERGE_REQUEST_PROJECT_PATH;
448
+ }
449
+ return env.CI_PROJECT_PATH || null;
450
+ }
395
451
  var service7 = {
396
452
  name: "GitLab",
397
453
  key: "gitlab",
398
454
  detect: ({ env }) => env.GITLAB_CI === "true",
399
- config: ({ env }) => {
455
+ config: (context) => {
456
+ const { env } = context;
400
457
  return {
401
458
  commit: env.CI_COMMIT_SHA || null,
402
459
  branch: env.CI_COMMIT_REF_NAME || null,
403
- owner: null,
404
- repository: null,
460
+ repository: getRepository6(context),
405
461
  jobId: null,
406
462
  runId: null,
407
463
  runAttempt: null,
@@ -417,6 +473,13 @@ var service7 = {
417
473
  var gitlab_default = service7;
418
474
 
419
475
  // src/ci-environment/services/git.ts
476
+ function getRepository7() {
477
+ const repositoryURL = getRepositoryURL();
478
+ if (!repositoryURL) {
479
+ return null;
480
+ }
481
+ return getRepositoryNameFromURL(repositoryURL);
482
+ }
420
483
  var service8 = {
421
484
  name: "Git",
422
485
  key: "git",
@@ -425,8 +488,7 @@ var service8 = {
425
488
  return {
426
489
  commit: head() || null,
427
490
  branch: branch() || null,
428
- owner: null,
429
- repository: null,
491
+ repository: getRepository7(),
430
492
  jobId: null,
431
493
  runId: null,
432
494
  runAttempt: null,
@@ -673,7 +735,6 @@ async function readConfig(options = {}) {
673
735
  prBaseBranch: config.get("prBaseBranch") || ciEnv?.prBaseBranch || null,
674
736
  referenceBranch: options.referenceBranch || config.get("referenceBranch") || null,
675
737
  referenceCommit: options.referenceCommit || config.get("referenceCommit") || null,
676
- owner: ciEnv?.owner || null,
677
738
  repository: ciEnv?.repository || null,
678
739
  jobId: ciEnv?.jobId || null,
679
740
  runId: ciEnv?.runId || null,
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.2",
4
+ "version": "3.2.3",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "exports": {
@@ -65,5 +65,5 @@
65
65
  "lint": "eslint .",
66
66
  "test": "vitest"
67
67
  },
68
- "gitHead": "ecab2281c36828d0c43728e3ed98e1eefe227c99"
68
+ "gitHead": "c54dac3320a10630c31549153473b70a2b42c2b6"
69
69
  }