shoplazza-ai-dev-cli 0.1.7-snapshot.0 → 0.1.7
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/_chunks/test.mjs +97 -5
- package/package.json +1 -1
package/dist/_chunks/test.mjs
CHANGED
|
@@ -297,7 +297,7 @@ async function create$4(client, args, json) {
|
|
|
297
297
|
console.log(" (case set auto-created)");
|
|
298
298
|
} else console.log(`ℹ Requirement already exists: ${data["req_id"]} (not modified)`);
|
|
299
299
|
}
|
|
300
|
-
async function sync(client, args, json) {
|
|
300
|
+
async function sync$1(client, args, json) {
|
|
301
301
|
const { positional, named } = parseNamedArgs(args);
|
|
302
302
|
const reqId = positional[0];
|
|
303
303
|
if (!reqId) {
|
|
@@ -312,11 +312,12 @@ async function sync(client, args, json) {
|
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
const s = data.summary;
|
|
315
|
-
printSuccess(`Synced ${(s["created"] ?? 0) + (s["referenced"] ?? 0) + (s["updated"] ?? 0)} cases to ${reqId}`);
|
|
315
|
+
printSuccess(`Synced ${(s["created"] ?? 0) + (s["referenced"] ?? 0) + (s["updated"] ?? 0) + (s["skipped"] ?? 0)} cases to ${reqId}`);
|
|
316
316
|
printKV([
|
|
317
317
|
["Created", `${s["created"] ?? 0}${data.results.filter((r) => r.action === "created").map((r) => ` (${r.case_id})`).join("")}`],
|
|
318
318
|
["Referenced", s["referenced"] ?? 0],
|
|
319
319
|
["Updated", s["updated"] ?? 0],
|
|
320
|
+
["Existing (linked)", s["skipped"] ?? 0],
|
|
320
321
|
["Unlinked", s["unlinked"] ?? 0],
|
|
321
322
|
["Failed", s["failed"] ?? 0]
|
|
322
323
|
]);
|
|
@@ -362,7 +363,7 @@ async function runRequirements(client, args, json) {
|
|
|
362
363
|
const subArgs = args.slice(1);
|
|
363
364
|
switch (action) {
|
|
364
365
|
case "create": return create$4(client, subArgs, json);
|
|
365
|
-
case "sync": return sync(client, subArgs, json);
|
|
366
|
+
case "sync": return sync$1(client, subArgs, json);
|
|
366
367
|
case "list": return list$2(client, subArgs, json);
|
|
367
368
|
case "--help":
|
|
368
369
|
case "-h":
|
|
@@ -455,16 +456,35 @@ async function list$1(client, args, json) {
|
|
|
455
456
|
]);
|
|
456
457
|
printPagination(data.total);
|
|
457
458
|
}
|
|
459
|
+
async function batch$1(client, args, json) {
|
|
460
|
+
const { named } = parseNamedArgs(args);
|
|
461
|
+
const payload = readFileInput(requireArg(named, "file", "path"));
|
|
462
|
+
const data = await client.post("/api/test/cases/batch", payload);
|
|
463
|
+
if (json) {
|
|
464
|
+
printJson(data);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const s = data.summary;
|
|
468
|
+
printSuccess(`Batch created ${s["created"] ?? 0} cases`);
|
|
469
|
+
printKV([
|
|
470
|
+
["Created", s["created"] ?? 0],
|
|
471
|
+
["Skipped (dup)", s["skipped"] ?? 0],
|
|
472
|
+
["Failed", s["failed"] ?? 0]
|
|
473
|
+
]);
|
|
474
|
+
for (const r of data.results.filter((r) => r.action === "created")) console.log(` ${r.case_id} ${r.client_ref || ""}`);
|
|
475
|
+
for (const r of data.results.filter((r) => r.action === "failed")) printError(` ${r.client_ref}: ${(r.errors ?? []).join(", ")}`);
|
|
476
|
+
}
|
|
458
477
|
async function runCases(client, args, json) {
|
|
459
478
|
const action = args[0];
|
|
460
479
|
const subArgs = args.slice(1);
|
|
461
480
|
switch (action) {
|
|
462
481
|
case "create": return create$3(client, subArgs, json);
|
|
463
482
|
case "list": return list$1(client, subArgs, json);
|
|
483
|
+
case "batch": return batch$1(client, subArgs, json);
|
|
464
484
|
case "--help":
|
|
465
485
|
case "-h":
|
|
466
486
|
case void 0:
|
|
467
|
-
console.log(`cases commands:\n create Create a standalone case\n list List cases with filters`);
|
|
487
|
+
console.log(`cases commands:\n create Create a standalone case\n list List cases with filters\n batch Batch create cases from JSON (--file <path>)`);
|
|
468
488
|
return;
|
|
469
489
|
default:
|
|
470
490
|
printError(`Unknown cases action: ${action}`);
|
|
@@ -511,16 +531,88 @@ async function members(client, args, json) {
|
|
|
511
531
|
}
|
|
512
532
|
printSuccess(`Added ${data.added}, removed ${data.removed}, invalid: ${(data.invalid ?? []).length}`);
|
|
513
533
|
}
|
|
534
|
+
async function get$1(client, args, json) {
|
|
535
|
+
const { positional } = parseNamedArgs(args);
|
|
536
|
+
const setId = positional[0];
|
|
537
|
+
if (!setId) {
|
|
538
|
+
printError("Usage: test case-sets get <set_id>");
|
|
539
|
+
process.exitCode = 2;
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
const data = await client.get(`/api/test/case-sets/${setId}`);
|
|
543
|
+
if (json) {
|
|
544
|
+
printJson(data);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
printKV([
|
|
548
|
+
["Name", data.name],
|
|
549
|
+
["Kind", data.kind],
|
|
550
|
+
["Members", data.members?.length ?? 0]
|
|
551
|
+
]);
|
|
552
|
+
if (data.members?.length) printTable(data.members, [
|
|
553
|
+
{
|
|
554
|
+
key: "case_id",
|
|
555
|
+
label: "Case ID",
|
|
556
|
+
width: 12
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
key: "title",
|
|
560
|
+
label: "Title"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
key: "case_type",
|
|
564
|
+
label: "Type",
|
|
565
|
+
width: 5
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
key: "priority",
|
|
569
|
+
label: "Pri",
|
|
570
|
+
width: 4
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
key: "group_path",
|
|
574
|
+
label: "Group"
|
|
575
|
+
}
|
|
576
|
+
]);
|
|
577
|
+
}
|
|
578
|
+
async function sync(client, args, json) {
|
|
579
|
+
const { positional, named } = parseNamedArgs(args);
|
|
580
|
+
const setId = positional[0];
|
|
581
|
+
if (!setId) {
|
|
582
|
+
printError("Usage: test case-sets sync <set_id> --file <path>");
|
|
583
|
+
process.exitCode = 2;
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
const payload = readFileInput(requireArg(named, "file", "path"));
|
|
587
|
+
const data = await client.post(`/api/test/case-sets/${setId}/cases:sync`, payload);
|
|
588
|
+
if (json) {
|
|
589
|
+
printJson(data);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const s = data.summary;
|
|
593
|
+
printSuccess(`Synced ${(s["created"] ?? 0) + (s["referenced"] ?? 0) + (s["updated"] ?? 0) + (s["skipped"] ?? 0)} cases to set ${setId}`);
|
|
594
|
+
printKV([
|
|
595
|
+
["Created", `${s["created"] ?? 0}${data.results.filter((r) => r.action === "created").map((r) => ` (${r.case_id})`).join("")}`],
|
|
596
|
+
["Referenced", s["referenced"] ?? 0],
|
|
597
|
+
["Updated", s["updated"] ?? 0],
|
|
598
|
+
["Existing (linked)", s["skipped"] ?? 0],
|
|
599
|
+
["Unlinked", s["unlinked"] ?? 0],
|
|
600
|
+
["Failed", s["failed"] ?? 0]
|
|
601
|
+
]);
|
|
602
|
+
for (const r of data.results.filter((r) => r.action === "failed")) printError(` ${r.client_ref}: ${(r.errors ?? []).join(", ")}`);
|
|
603
|
+
}
|
|
514
604
|
async function runCaseSets(client, args, json) {
|
|
515
605
|
const action = args[0];
|
|
516
606
|
const subArgs = args.slice(1);
|
|
517
607
|
switch (action) {
|
|
518
608
|
case "create": return create$2(client, subArgs, json);
|
|
609
|
+
case "get": return get$1(client, subArgs, json);
|
|
519
610
|
case "members": return members(client, subArgs, json);
|
|
611
|
+
case "sync": return sync(client, subArgs, json);
|
|
520
612
|
case "--help":
|
|
521
613
|
case "-h":
|
|
522
614
|
case void 0:
|
|
523
|
-
console.log(`case-sets commands:\n create Create a case set (--name, --kind)\n members Batch add/remove members (--add/--remove)`);
|
|
615
|
+
console.log(`case-sets commands:\n create Create a case set (--name, --kind)\n get Get case set detail with members\n members Batch add/remove members (--add/--remove)\n sync Sync cases to a set (--file <path>)`);
|
|
524
616
|
return;
|
|
525
617
|
default:
|
|
526
618
|
printError(`Unknown case-sets action: ${action}`);
|