@argos-ci/cli 0.3.3-alpha.1 → 0.3.3-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.
Files changed (2) hide show
  1. package/dist/index.mjs +51 -33
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -97,7 +97,7 @@ const schema = {
97
97
  nullable: true
98
98
  },
99
99
  prNumber: {
100
- format: String,
100
+ format: Number,
101
101
  default: null,
102
102
  nullable: true
103
103
  },
@@ -130,6 +130,25 @@ const createConfig = ()=>{
130
130
  return result;
131
131
  };
132
132
 
133
+ const service$4 = {
134
+ detect: ({ env })=>Boolean(env.BUILDKITE),
135
+ config: ({ env })=>{
136
+ const ciProps = envCiDetection({
137
+ env
138
+ });
139
+ return {
140
+ name: "Buildkite",
141
+ commit: ciProps?.commit || null,
142
+ branch: env.BUILDKITE_BRANCH || null,
143
+ owner: env.BUILDKITE_ORGANIZATION_SLUG || null,
144
+ repository: env.BUILDKITE_PROJECT_SLUG || null,
145
+ jobId: env.BUILDKITE_JOB_ID || null,
146
+ runId: ciProps?.runId || null,
147
+ prNumber: env.BUILDKITE_PULL_REQUEST ? Number(env.BUILDKITE_PULL_REQUEST) : null
148
+ };
149
+ }
150
+ };
151
+
133
152
  const service$3 = {
134
153
  detect: ({ env })=>Boolean(env.HEROKU_TEST_RUN_ID),
135
154
  config: ({ env })=>({
@@ -196,7 +215,7 @@ const getPrNumber$1 = ({ env })=>{
196
215
  const branchRegex = /refs\/pull\/(\d+)/;
197
216
  const branchMatches = branchRegex.exec(env.GITHUB_REF || "");
198
217
  if (branchMatches) {
199
- branchMatches[1];
218
+ return Number(branchMatches[1]);
200
219
  }
201
220
  return null;
202
221
  };
@@ -226,7 +245,7 @@ const getPrNumber = ({ env })=>{
226
245
  const branchRegex = /pull\/(\d+)/;
227
246
  const branchMatches = branchRegex.exec(env.CIRCLE_PULL_REQUEST || "");
228
247
  if (branchMatches) {
229
- branchMatches[1];
248
+ return Number(branchMatches[1]);
230
249
  }
231
250
  return null;
232
251
  };
@@ -265,7 +284,7 @@ const service = {
265
284
  repository: ciProps?.repository || null,
266
285
  jobId: ciProps?.jobId || null,
267
286
  runId: ciProps?.runId || null,
268
- prNumber: env.TRAVIS_PULL_REQUEST || null
287
+ prNumber: env.TRAVIS_PULL_REQUEST ? Number(env.TRAVIS_PULL_REQUEST) : null
269
288
  };
270
289
  }
271
290
  };
@@ -274,7 +293,8 @@ const services = [
274
293
  service$3,
275
294
  service$2,
276
295
  service$1,
277
- service
296
+ service,
297
+ service$4
278
298
  ];
279
299
  const envCiDetection = (ctx)=>{
280
300
  const ciContext = envCi(ctx);
@@ -420,34 +440,31 @@ const upload$1 = async (input)=>{
420
440
  const debug = createDebug("@argos-ci/core");
421
441
 
422
442
  const getConfigFromOptions = (options)=>{
423
- const { apiBaseUrl , commit , branch , token , buildName , parallel , prNumber } = options;
424
443
  const config = createConfig();
444
+ const ciEnv = getCiEnvironment();
445
+ if (ciEnv) {
446
+ config.load(omitUndefined({
447
+ commit: ciEnv.commit,
448
+ branch: ciEnv.branch,
449
+ ciService: ciEnv.name,
450
+ owner: ciEnv.owner,
451
+ repository: ciEnv.repository,
452
+ jobId: ciEnv.jobId,
453
+ runId: ciEnv.runId,
454
+ prNumber: ciEnv.prNumber
455
+ }));
456
+ }
425
457
  config.load(omitUndefined({
426
- apiBaseUrl,
427
- commit,
428
- branch,
429
- token,
430
- prNumber,
431
- buildName,
432
- parallel: Boolean(parallel),
433
- parallelNonce: parallel ? parallel.nonce : null,
434
- parallelTotal: parallel ? parallel.total : null
458
+ apiBaseUrl: options.apiBaseUrl,
459
+ commit: options.commit,
460
+ branch: options.branch,
461
+ token: options.token,
462
+ prNumber: options.prNumber,
463
+ buildName: options.buildName,
464
+ parallel: Boolean(options.parallel),
465
+ parallelNonce: options.parallel ? options.parallel.nonce : null,
466
+ parallelTotal: options.parallel ? options.parallel.total : null
435
467
  }));
436
- if (!config.get("commit")) {
437
- const ciEnv = getCiEnvironment();
438
- if (ciEnv) {
439
- config.load(omitUndefined({
440
- commit: ciEnv.commit,
441
- branch: ciEnv.branch,
442
- ciService: ciEnv.name,
443
- owner: ciEnv.owner,
444
- repository: ciEnv.repository,
445
- jobId: ciEnv.jobId,
446
- runId: ciEnv.runId,
447
- prNumber: ciEnv.prNumber
448
- }));
449
- }
450
- }
451
468
  config.validate();
452
469
  return config.get();
453
470
  };
@@ -486,7 +503,8 @@ const getConfigFromOptions = (options)=>{
486
503
  name: config.buildName,
487
504
  parallel: config.parallel,
488
505
  parallelNonce: config.parallelNonce,
489
- screenshotKeys: Array.from(new Set(screenshots.map((screenshot)=>screenshot.hash)))
506
+ screenshotKeys: Array.from(new Set(screenshots.map((screenshot)=>screenshot.hash))),
507
+ prNumber: config.prNumber
490
508
  });
491
509
  debug("Got screenshots", result);
492
510
  // Upload screenshots
@@ -522,7 +540,7 @@ const __dirname = fileURLToPath(new URL(".", import.meta.url));
522
540
  const rawPkg = await readFile(resolve(__dirname, "..", "package.json"), "utf8");
523
541
  const pkg = JSON.parse(rawPkg);
524
542
  program.name(pkg.name).description("Interact with and upload screenshots to argos-ci.com via command line.").version(pkg.version);
525
- program.command("upload").argument("<directory>", "Directory to upload").description("Upload screenshots to argos-ci.com").option("-f, --files <patterns...>", "One or more globs matching image file paths to upload", "**/*.{png,jpg,jpeg}").option("-i, --ignore <patterns...>", 'One or more globs matching image file paths to ignore (ex: "**/*.png **/diff.jpg")').option("--token <token>", "Repository token").option("--prNumber <number>", "Pull-request number").option("--build-name <string>", "Name of the build, in case you want to run multiple Argos builds in a single CI job").option("--parallel", "Enable parallel mode. Run multiple Argos builds and combine them at the end").option("--parallel-total <number>", "The number of parallel nodes being ran").option("--parallel-nonce <string>", "A unique ID for this parallel build").action(async (directory, options)=>{
543
+ program.command("upload").argument("<directory>", "Directory to upload").description("Upload screenshots to argos-ci.com").option("-f, --files <patterns...>", "One or more globs matching image file paths to upload", "**/*.{png,jpg,jpeg}").option("-i, --ignore <patterns...>", 'One or more globs matching image file paths to ignore (ex: "**/*.png **/diff.jpg")').option("--token <token>", "Repository token").option("--pull-request <number>", "Pull-request number").option("--build-name <string>", "Name of the build, in case you want to run multiple Argos builds in a single CI job").option("--parallel", "Enable parallel mode. Run multiple Argos builds and combine them at the end").option("--parallel-total <number>", "The number of parallel nodes being ran").option("--parallel-nonce <string>", "A unique ID for this parallel build").action(async (directory, options)=>{
526
544
  const spinner = ora("Uploading screenshots").start();
527
545
  try {
528
546
  const result = await upload({
@@ -530,7 +548,7 @@ program.command("upload").argument("<directory>", "Directory to upload").descrip
530
548
  buildName: options.buildName,
531
549
  files: options.files,
532
550
  ignore: options.ignore,
533
- prNumber: options.prNumber,
551
+ prNumber: options.pullRequest ? Number(options.pullRequest) : undefined,
534
552
  parallel: options.parallel ? {
535
553
  nonce: options.parallelNonce,
536
554
  total: options.parallelTotal
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.3.3-alpha.1+46d7443",
4
+ "version": "0.3.3-alpha.4+79fe6f6",
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.6.3-alpha.1+46d7443",
43
+ "@argos-ci/core": "^0.6.3-alpha.4+79fe6f6",
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": "46d7443fe360fe5d42482e404bd3ab5c05116567"
52
+ "gitHead": "79fe6f67eb4b2df4cf3f79e301a8a44d787206cb"
53
53
  }