jiradc-cli 1.0.29 → 1.0.30

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.js +41 -17
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -2397,14 +2397,50 @@ function registerUserCommands(program) {
2397
2397
  search3(user);
2398
2398
  }
2399
2399
 
2400
+ // src/utils/xray/guards.ts
2401
+ function assertExactlyOne(opts, keys, label) {
2402
+ const present = keys.filter((k) => opts[k] !== void 0);
2403
+ if (present.length !== 1)
2404
+ throw new Error(`Provide exactly one of ${keys.map((k) => `--${k}`).join(", ")} (${label}).`);
2405
+ return present[0];
2406
+ }
2407
+ function assertAtLeastOne(opts, keys) {
2408
+ if (!keys.some((k) => opts[k] !== void 0))
2409
+ throw new Error(`Provide at least one of ${keys.map((k) => `--${k}`).join(", ")}.`);
2410
+ }
2411
+
2400
2412
  // src/commands/xray/execution/add.ts
2401
2413
  function add(parent) {
2402
- const cmd = parent.command("add").description("Add tests to a Test Execution").argument("<execKey>", "Test Execution issue key (e.g. AI-200)", issueKey).requiredOption("--test <keys>", "Comma-separated test issue keys to add (e.g. AI-1,AI-2)", keyList);
2403
- examples(cmd, ["AI-200 --test AI-1", "AI-200 --test AI-1,AI-2,AI-3"]);
2414
+ const cmd = parent.command("add").description("Add tests to a Test Execution, directly (--test) and/or by expanding Test Sets (--set)").argument("<execKey>", "Test Execution issue key (e.g. AI-200)", issueKey).option("--test <keys>", "Comma-separated test issue keys to add (e.g. AI-1,AI-2)", keyList).option(
2415
+ "--set <keys>",
2416
+ "Comma-separated Test Set keys; each set's current tests are added to the execution (e.g. AI-300)",
2417
+ keyList
2418
+ );
2419
+ examples(cmd, [
2420
+ "AI-200 --test AI-1",
2421
+ "AI-200 --test AI-1,AI-2",
2422
+ "AI-200 --set AI-300",
2423
+ "AI-200 --test AI-1 --set AI-300"
2424
+ ]);
2404
2425
  cmd.action(async (execKey, opts) => {
2405
- const client = getClient();
2406
- const result = await client.testExecutions.addTests({ execKey, keys: opts.test });
2407
- output(result ?? { added: true });
2426
+ assertAtLeastOne(opts, ["test", "set"]);
2427
+ const client = getClient();
2428
+ const keys = new Set(opts.test ?? []);
2429
+ if (opts.set) {
2430
+ const lists = await Promise.all(opts.set.map((setKey) => client.testSets.listTests({ setKey })));
2431
+ for (const list20 of lists) {
2432
+ const tests = Array.isArray(list20) ? list20 : list20.tests ?? [];
2433
+ for (const t of tests) {
2434
+ if (t.key) keys.add(String(t.key));
2435
+ }
2436
+ }
2437
+ }
2438
+ const allKeys = [...keys];
2439
+ if (allKeys.length === 0) {
2440
+ throw new Error("No tests to add \u2014 the given --set(s) contain no tests and no --test keys were provided.");
2441
+ }
2442
+ const result = await client.testExecutions.addTests({ execKey, keys: allKeys });
2443
+ output(result ?? { added: allKeys });
2408
2444
  });
2409
2445
  }
2410
2446
 
@@ -2751,18 +2787,6 @@ function registerImportCommands(xray) {
2751
2787
  feature2(importGroup);
2752
2788
  }
2753
2789
 
2754
- // src/utils/xray/guards.ts
2755
- function assertExactlyOne(opts, keys, label) {
2756
- const present = keys.filter((k) => opts[k] !== void 0);
2757
- if (present.length !== 1)
2758
- throw new Error(`Provide exactly one of ${keys.map((k) => `--${k}`).join(", ")} (${label}).`);
2759
- return present[0];
2760
- }
2761
- function assertAtLeastOne(opts, keys) {
2762
- if (!keys.some((k) => opts[k] !== void 0))
2763
- throw new Error(`Provide at least one of ${keys.map((k) => `--${k}`).join(", ")}.`);
2764
- }
2765
-
2766
2790
  // src/commands/xray/plan/add.ts
2767
2791
  function add3(parent) {
2768
2792
  const cmd = parent.command("add").description("Add tests and/or executions to a Test Plan").argument("<planKey>", "Test Plan issue key (e.g. QA-573)", issueKey).option("--test <keys>", "Comma-separated test issue keys to add (e.g. QA-1,QA-2)", keyList).option("--execution <keys>", "Comma-separated test execution keys to add (e.g. QA-200,QA-201)", keyList);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jiradc-cli",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "publish": true,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,9 +23,9 @@
23
23
  "tsx": "^4.19.2",
24
24
  "typescript": "^5.7.2",
25
25
  "vitest": "^4.0.16",
26
+ "cli-utils": "1.0.0",
26
27
  "config-eslint": "0.0.0",
27
- "config-typescript": "0.0.0",
28
- "cli-utils": "1.0.0"
28
+ "config-typescript": "0.0.0"
29
29
  },
30
30
  "engines": {
31
31
  "node": ">=22.0.0"