@simonfestl/husky-cli 1.4.0 → 1.4.1
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/commands/biz/tickets.js +31 -1
- package/package.json +1 -1
|
@@ -126,6 +126,8 @@ ticketsCommand
|
|
|
126
126
|
.description("Update ticket properties")
|
|
127
127
|
.option("--status <status>", "New status (open, pending, solved)")
|
|
128
128
|
.option("--priority <priority>", "New priority (low, normal, high, urgent)")
|
|
129
|
+
.option("-f, --field <field...>", "Set custom field (format: field_id=value or name=value)")
|
|
130
|
+
.option("--json", "Output as JSON")
|
|
129
131
|
.action(async (id, options) => {
|
|
130
132
|
try {
|
|
131
133
|
const client = ZendeskClient.fromConfig();
|
|
@@ -134,13 +136,41 @@ ticketsCommand
|
|
|
134
136
|
updates.status = options.status;
|
|
135
137
|
if (options.priority)
|
|
136
138
|
updates.priority = options.priority;
|
|
139
|
+
if (options.field && options.field.length > 0) {
|
|
140
|
+
updates.custom_fields = options.field.map((f) => {
|
|
141
|
+
const [key, ...valueParts] = f.split("=");
|
|
142
|
+
const value = valueParts.join("=");
|
|
143
|
+
const fieldId = parseInt(key, 10);
|
|
144
|
+
if (isNaN(fieldId)) {
|
|
145
|
+
throw new Error(`Invalid field ID: ${key}. Use numeric field ID (e.g., 28080124674706=value)`);
|
|
146
|
+
}
|
|
147
|
+
if (value === "true")
|
|
148
|
+
return { id: fieldId, value: true };
|
|
149
|
+
if (value === "false")
|
|
150
|
+
return { id: fieldId, value: false };
|
|
151
|
+
if (value === "null" || value === "")
|
|
152
|
+
return { id: fieldId, value: null };
|
|
153
|
+
const numValue = parseInt(value, 10);
|
|
154
|
+
if (!isNaN(numValue) && String(numValue) === value) {
|
|
155
|
+
return { id: fieldId, value: numValue };
|
|
156
|
+
}
|
|
157
|
+
return { id: fieldId, value };
|
|
158
|
+
});
|
|
159
|
+
}
|
|
137
160
|
if (Object.keys(updates).length === 0) {
|
|
138
|
-
console.error("Error: Provide --status or --
|
|
161
|
+
console.error("Error: Provide --status, --priority, or --field");
|
|
139
162
|
process.exit(1);
|
|
140
163
|
}
|
|
141
164
|
const ticket = await client.updateTicket(parseInt(id, 10), updates);
|
|
165
|
+
if (options.json) {
|
|
166
|
+
console.log(JSON.stringify(ticket, null, 2));
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
142
169
|
console.log(`✓ Updated ticket #${ticket.id}`);
|
|
143
170
|
console.log(` Status: ${ticket.status}, Priority: ${ticket.priority || "normal"}`);
|
|
171
|
+
if (updates.custom_fields) {
|
|
172
|
+
console.log(` Custom fields updated: ${updates.custom_fields.length}`);
|
|
173
|
+
}
|
|
144
174
|
}
|
|
145
175
|
catch (error) {
|
|
146
176
|
console.error("Error:", error.message);
|