@andrian.yablonskyy/thub-agent 1.0.33 → 1.0.34

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 (3) hide show
  1. package/README.md +2 -2
  2. package/package.json +2 -2
  3. package/src/cli.js +21 -2
package/README.md CHANGED
@@ -29,10 +29,10 @@ thub config set user "Your Name" # optional default --user
29
29
 
30
30
  ```
31
31
  thub run [options] Submit a test job and follow its log
32
- thub status <jobId> Show status; follow log if running, verdict and test counts if done
32
+ thub status <jobId> Show status; follow log if running, verdict, test counts and artifacts if done
33
33
  thub cancel <jobId> Cancel a job
34
34
  thub resources List resources and their status
35
- thub jobs [--mine] [--state <s>] List recent jobs
35
+ thub jobs [--mine] [--state <s>] List recent jobs (a cli token: only its own; a ci token: all, or its own with --mine)
36
36
  thub config set <key> <value> Save coordinator URL / token / default group / default user locally
37
37
  thub check-update Compare this Agent with the latest published version
38
38
  thub self-update [--to <x.y.z>] Update this Agent with npm i -g
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrian.yablonskyy/thub-agent",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "TestHub Agent CLI — the single entry point CI/CD and developers use to submit and follow test jobs",
5
5
  "bin": {
6
6
  "thub": "./src/cli.js"
@@ -12,7 +12,7 @@
12
12
  "lint:fix": "eslint . --fix"
13
13
  },
14
14
  "dependencies": {
15
- "@andrian.yablonskyy/thub-common": "^1.0.32",
15
+ "@andrian.yablonskyy/thub-common": "^1.0.33",
16
16
  "commander": "^13.1.0"
17
17
  },
18
18
  "devDependencies": {
package/src/cli.js CHANGED
@@ -252,7 +252,7 @@ program
252
252
 
253
253
  program
254
254
  .command('status')
255
- .description('Show status; follow log if running, verdict and test counts if done')
255
+ .description('Show status; follow log if running, verdict, test counts and artifacts if done')
256
256
  .argument('<jobId>')
257
257
  .option('--json', 'Print the job as JSON once, without following it; exit code: its verdict, or 5 while it\'s still active', false)
258
258
  .action(async (jobId, opts) => {
@@ -282,6 +282,13 @@ program
282
282
  if (job.message){
283
283
  console.log(`Message: ${job.message}`);
284
284
  }
285
+ // What the job published elsewhere and reported (links, not files).
286
+ if (job.artifacts?.length){
287
+ console.log('Artifacts:');
288
+ for (const a of job.artifacts){
289
+ console.log(` ${a.name} ${a.size != null ? formatBytes(a.size) : '—'} ${a.link}`);
290
+ }
291
+ }
285
292
  process.exit(exitCodeForJobState(job.state));
286
293
  }
287
294
  catch (err){
@@ -330,7 +337,7 @@ program
330
337
  program
331
338
  .command('jobs')
332
339
  .description('List recent jobs')
333
- .option('--mine', 'Only jobs submitted by this agent token', false)
340
+ .option('--mine', 'Only jobs submitted by this agent token (always so for a cli token, which sees only its own)', false)
334
341
  .option('--state <state>', 'Filter by state')
335
342
  .option('--json', 'Machine-readable output', false)
336
343
  .action(async (opts) => {
@@ -352,6 +359,18 @@ program
352
359
  }
353
360
  });
354
361
 
362
+ // 1233 -> "1.2 KB" (1024-based), for artifact sizes.
363
+ function formatBytes(bytes){
364
+ const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
365
+ let value = bytes,
366
+ unit = 0;
367
+ while (value >= 1024 && unit < units.length - 1){
368
+ value /= 1024;
369
+ unit += 1;
370
+ }
371
+ return unit === 0 ? `${value} B` : `${value < 10 ? value.toFixed(1) : Math.round(value)} ${units[unit]}`;
372
+ }
373
+
355
374
  const config = program.command('config').description('Manage local Agent configuration');
356
375
  config
357
376
  .command('set')