@rudderhq/cli 0.2.5-canary.6 → 0.2.5-canary.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/index.js +64 -3
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10139,7 +10139,7 @@ var AGENT_CLI_CAPABILITIES = [
|
|
|
10139
10139
|
},
|
|
10140
10140
|
{
|
|
10141
10141
|
id: "issue.create",
|
|
10142
|
-
command: "rudder issue create --org-id <id> ...",
|
|
10142
|
+
command: "rudder issue create --org-id <id> ... [--label-id <id> ...] [--label <name> ...]",
|
|
10143
10143
|
category: "issue",
|
|
10144
10144
|
description: "Create a new issue or subtask with the generic issue surface; agent-created issues default to the creating agent when no assignee is supplied.",
|
|
10145
10145
|
mutating: true,
|
|
@@ -10149,6 +10149,18 @@ var AGENT_CLI_CAPABILITIES = [
|
|
|
10149
10149
|
requiresRunId: false,
|
|
10150
10150
|
attachesRunIdWhenAvailable: true
|
|
10151
10151
|
},
|
|
10152
|
+
{
|
|
10153
|
+
id: "issue.labels.list",
|
|
10154
|
+
command: "rudder issue labels list --org-id <id>",
|
|
10155
|
+
category: "issue",
|
|
10156
|
+
description: "List organization issue labels available for issue creation.",
|
|
10157
|
+
mutating: false,
|
|
10158
|
+
contract: "compat",
|
|
10159
|
+
requiresOrgId: true,
|
|
10160
|
+
requiresAgentId: false,
|
|
10161
|
+
requiresRunId: false,
|
|
10162
|
+
attachesRunIdWhenAvailable: false
|
|
10163
|
+
},
|
|
10152
10164
|
{
|
|
10153
10165
|
id: "approval.get",
|
|
10154
10166
|
command: "rudder approval get <approval-id>",
|
|
@@ -10392,9 +10404,22 @@ function registerIssueCommands(program) {
|
|
|
10392
10404
|
})
|
|
10393
10405
|
);
|
|
10394
10406
|
addCommonClientOptions(
|
|
10395
|
-
issue.command("
|
|
10407
|
+
issue.command("labels").description("Issue label operations").command("list").description("List issue labels for an organization").option("-O, --org-id <id>", "Organization ID").action(async (opts) => {
|
|
10408
|
+
try {
|
|
10409
|
+
const ctx = resolveCommandContext(opts, { requireCompany: true });
|
|
10410
|
+
const rows = await ctx.api.get(`/api/orgs/${ctx.orgId}/labels`) ?? [];
|
|
10411
|
+
printOutput(rows, { json: ctx.json });
|
|
10412
|
+
} catch (err) {
|
|
10413
|
+
handleCommandError(err);
|
|
10414
|
+
}
|
|
10415
|
+
}),
|
|
10416
|
+
{ includeCompany: false }
|
|
10417
|
+
);
|
|
10418
|
+
addCommonClientOptions(
|
|
10419
|
+
issue.command("create").description(getAgentCliCapabilityById("issue.create").description).option("-O, --org-id <id>", "Organization ID").requiredOption("--title <title>", "Issue title").option("--description <text>", "Issue description").option("--status <status>", "Issue status").option("--priority <priority>", "Issue priority").option("--assignee-agent-id <id>", "Assignee agent ID").option("--project-id <id>", "Project ID").option("--goal-id <id>", "Goal ID").option("--parent-id <id>", "Parent issue ID").option("--request-depth <n>", "Request depth integer").option("--billing-code <code>", "Billing code").option("--label-id <id>", "Issue label ID; may be repeated", collectNonEmptyOption("--label-id"), []).option("--label <name>", "Issue label name to resolve exactly; may be repeated", collectNonEmptyOption("--label"), []).action(async (opts) => {
|
|
10396
10420
|
try {
|
|
10397
10421
|
const ctx = resolveCommandContext(opts, { requireCompany: true });
|
|
10422
|
+
const labelIds = await resolveIssueLabelIds(ctx, opts);
|
|
10398
10423
|
const payload = createIssueSchema.parse({
|
|
10399
10424
|
title: opts.title,
|
|
10400
10425
|
description: opts.description,
|
|
@@ -10405,7 +10430,8 @@ function registerIssueCommands(program) {
|
|
|
10405
10430
|
goalId: opts.goalId,
|
|
10406
10431
|
parentId: opts.parentId,
|
|
10407
10432
|
requestDepth: parseOptionalInt(opts.requestDepth),
|
|
10408
|
-
billingCode: opts.billingCode
|
|
10433
|
+
billingCode: opts.billingCode,
|
|
10434
|
+
labelIds: labelIds.length > 0 ? labelIds : void 0
|
|
10409
10435
|
});
|
|
10410
10436
|
const created = await ctx.api.post(`/api/orgs/${ctx.orgId}/issues`, payload);
|
|
10411
10437
|
printOutput(created, { json: ctx.json });
|
|
@@ -10650,6 +10676,41 @@ function collectImagePath(value, previous) {
|
|
|
10650
10676
|
}
|
|
10651
10677
|
return [...previous, trimmed];
|
|
10652
10678
|
}
|
|
10679
|
+
function collectNonEmptyOption(optionName) {
|
|
10680
|
+
return (value, previous) => {
|
|
10681
|
+
const trimmed = value.trim();
|
|
10682
|
+
if (!trimmed) {
|
|
10683
|
+
throw new Error(`${optionName} cannot be empty`);
|
|
10684
|
+
}
|
|
10685
|
+
return [...previous, trimmed];
|
|
10686
|
+
};
|
|
10687
|
+
}
|
|
10688
|
+
async function resolveIssueLabelIds(ctx, opts) {
|
|
10689
|
+
const explicitIds = opts.labelId ?? [];
|
|
10690
|
+
const names = opts.label ?? [];
|
|
10691
|
+
if (names.length === 0 && explicitIds.length > 0) return [...new Set(explicitIds)];
|
|
10692
|
+
if (names.length === 0 && opts.parentId) return [];
|
|
10693
|
+
const labels = await ctx.api.get(`/api/orgs/${ctx.orgId}/labels`) ?? [];
|
|
10694
|
+
if (names.length === 0) {
|
|
10695
|
+
if (ctx.agentId && labels.length >= 5) {
|
|
10696
|
+
throw new Error(
|
|
10697
|
+
`Organization has ${labels.length} issue labels. Choose at least one with --label-id <id> or --label <name>. Available labels: ${formatAvailableLabelNames(labels)}`
|
|
10698
|
+
);
|
|
10699
|
+
}
|
|
10700
|
+
return [];
|
|
10701
|
+
}
|
|
10702
|
+
const resolvedIds = names.map((name) => {
|
|
10703
|
+
const exact = labels.find((label) => label.name === name) ?? labels.find((label) => label.name.toLowerCase() === name.toLowerCase());
|
|
10704
|
+
if (!exact) {
|
|
10705
|
+
throw new Error(`Unknown issue label "${name}". Available labels: ${formatAvailableLabelNames(labels)}`);
|
|
10706
|
+
}
|
|
10707
|
+
return exact.id;
|
|
10708
|
+
});
|
|
10709
|
+
return [.../* @__PURE__ */ new Set([...explicitIds, ...resolvedIds])];
|
|
10710
|
+
}
|
|
10711
|
+
function formatAvailableLabelNames(labels) {
|
|
10712
|
+
return labels.map((label) => label.name).join(", ") || "(none)";
|
|
10713
|
+
}
|
|
10653
10714
|
async function appendUploadedIssueImages(ctx, issueId, body, imagePaths) {
|
|
10654
10715
|
const paths = imagePaths ?? [];
|
|
10655
10716
|
if (paths.length === 0) return body;
|