svamp-cli 0.2.173 → 0.2.174
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/cli.mjs
CHANGED
|
@@ -375,11 +375,11 @@ async function main() {
|
|
|
375
375
|
}), machineId);
|
|
376
376
|
process.exit(0);
|
|
377
377
|
} else if (subcommand === "issue" || subcommand === "issues") {
|
|
378
|
-
const { issueCommand } = await import('./commands-
|
|
378
|
+
const { issueCommand } = await import('./commands-CPHMhYnp.mjs');
|
|
379
379
|
await issueCommand(args.slice(1));
|
|
380
380
|
process.exit(0);
|
|
381
381
|
} else if (subcommand === "workflow" || subcommand === "workflows") {
|
|
382
|
-
const { workflowCommand } = await import('./commands-
|
|
382
|
+
const { workflowCommand } = await import('./commands-B3Uk_kN9.mjs');
|
|
383
383
|
await workflowCommand(args.slice(1));
|
|
384
384
|
process.exit(0);
|
|
385
385
|
} else if (subcommand === "trigger" || subcommand === "triggers" || subcommand === "routine" || subcommand === "routines") {
|
|
@@ -398,7 +398,7 @@ async function main() {
|
|
|
398
398
|
} else if (!subcommand || subcommand === "start") {
|
|
399
399
|
await handleInteractiveCommand();
|
|
400
400
|
} else if (subcommand === "--version" || subcommand === "-v") {
|
|
401
|
-
const pkg = await import('./package-
|
|
401
|
+
const pkg = await import('./package-CmQGdoJz.mjs').catch(() => ({ default: { version: "unknown" } }));
|
|
402
402
|
console.log(`svamp version: ${pkg.default.version}`);
|
|
403
403
|
} else {
|
|
404
404
|
console.error(`Unknown command: ${subcommand}`);
|
|
@@ -33,13 +33,14 @@ function parseWorkflow(content) {
|
|
|
33
33
|
const o = parse(content);
|
|
34
34
|
if (!o || typeof o !== "object" || !o.name) return null;
|
|
35
35
|
const jobs = Array.isArray(o.jobs) ? o.jobs.map((j) => ({ run: String(j?.run ?? "") })).filter((j) => j.run) : [];
|
|
36
|
-
return { name: String(o.name), on: o.on && typeof o.on === "object" ? o.on : void 0, jobs };
|
|
36
|
+
return { name: String(o.name), on: o.on && typeof o.on === "object" ? o.on : void 0, jobs, session: o.session ?? null };
|
|
37
37
|
} catch {
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
function serializeWorkflow(wf) {
|
|
42
42
|
const clean = { name: wf.name };
|
|
43
|
+
if (wf.session) clean.session = wf.session;
|
|
43
44
|
if (wf.on && Object.keys(wf.on).length) clean.on = wf.on;
|
|
44
45
|
clean.jobs = wf.jobs.map((j) => ({ run: j.run }));
|
|
45
46
|
return stringify(clean);
|
|
@@ -137,7 +138,8 @@ async function workflowCommand(args) {
|
|
|
137
138
|
if (onKinds.includes("dispatch")) on.dispatch = true;
|
|
138
139
|
if (onKinds.includes("channel") || flag(rest, "--channel")) on.channel = flag(rest, "--channel") || "default";
|
|
139
140
|
if (onKinds.includes("issue") || flag(rest, "--issue")) on.issue = (flag(rest, "--issue") || "ready").split(",").map((s) => s.trim()).filter(Boolean);
|
|
140
|
-
const
|
|
141
|
+
const owner = flag(rest, "--session") || process.env.SVAMP_SESSION_ID || null;
|
|
142
|
+
const wf = { name, on: Object.keys(on).length ? on : void 0, jobs: runs.map((r) => ({ run: r })), session: owner };
|
|
141
143
|
saveWorkflow(root, wf);
|
|
142
144
|
if (json) console.log(JSON.stringify(wf));
|
|
143
145
|
else console.log(`Saved workflow "${name}" (on: ${describeOn(wf.on)}, ${wf.jobs.length} step${wf.jobs.length === 1 ? "" : "s"}).`);
|
|
@@ -91,14 +91,15 @@ async function issueCommand(args) {
|
|
|
91
91
|
body = void 0;
|
|
92
92
|
}
|
|
93
93
|
const labels = rest.filter((a, idx) => rest[idx - 1] === "--label");
|
|
94
|
-
const
|
|
94
|
+
const owner = flag(rest, "--session") || sessionId;
|
|
95
|
+
const scope = flag(rest, "--scope") || (owner ? "session" : "project");
|
|
95
96
|
const issue = addIssue(root, {
|
|
96
97
|
title,
|
|
97
98
|
status: has(rest, "--ready") ? "ready" : "backlog",
|
|
98
99
|
scope,
|
|
99
100
|
labels,
|
|
100
101
|
verify: buildVerify(rest),
|
|
101
|
-
session: scope === "session" ?
|
|
102
|
+
session: scope === "session" ? owner : null,
|
|
102
103
|
original,
|
|
103
104
|
body
|
|
104
105
|
});
|
|
@@ -112,7 +113,9 @@ async function issueCommand(args) {
|
|
|
112
113
|
if (status && status !== "all") opts.status = status;
|
|
113
114
|
if (flag(rest, "--label")) opts.label = flag(rest, "--label");
|
|
114
115
|
if (flag(rest, "--scope")) opts.scope = flag(rest, "--scope");
|
|
115
|
-
const
|
|
116
|
+
const mineList = flag(rest, "--session") || (has(rest, "--mine") ? sessionId : null);
|
|
117
|
+
let items = listIssues(root, opts);
|
|
118
|
+
if (mineList) items = items.filter((i) => i.scope === "project" || i.session === mineList);
|
|
116
119
|
if (json) {
|
|
117
120
|
console.log(JSON.stringify(items.map(({ body, original, ...r }) => r)));
|
|
118
121
|
break;
|
|
@@ -151,16 +154,19 @@ ${issue.body}`);
|
|
|
151
154
|
case "work": {
|
|
152
155
|
const id = positional(rest)[0];
|
|
153
156
|
if (!id) {
|
|
154
|
-
console.error("usage: svamp issue work <id> [--branch <name>]");
|
|
157
|
+
console.error("usage: svamp issue work <id> [--branch <name>] [--session <id>]");
|
|
155
158
|
process.exit(1);
|
|
156
159
|
}
|
|
157
160
|
const branch = flag(rest, "--branch");
|
|
158
|
-
const
|
|
161
|
+
const worker = flag(rest, "--session") || sessionId;
|
|
162
|
+
const cur = getIssue(root, id);
|
|
163
|
+
const claim = worker && cur && cur.scope === "project" && !cur.session ? { session: worker } : {};
|
|
164
|
+
const updated = updateIssue(root, id, { status: "in_progress", ...branch ? { branch } : {}, ...claim });
|
|
159
165
|
if (!updated) {
|
|
160
166
|
console.error(`Issue not found: ${id}`);
|
|
161
167
|
process.exit(1);
|
|
162
168
|
}
|
|
163
|
-
ok(updated, `#${updated.id} \u2192 in_progress${updated.branch ? ` on ${updated.branch}` : ""}`);
|
|
169
|
+
ok(updated, `#${updated.id} \u2192 in_progress${updated.branch ? ` on ${updated.branch}` : ""}${claim.session ? ` (claimed by ${claim.session})` : ""}`);
|
|
164
170
|
break;
|
|
165
171
|
}
|
|
166
172
|
case "ready":
|
|
@@ -225,6 +231,8 @@ ${tail}
|
|
|
225
231
|
const v = buildVerify(rest);
|
|
226
232
|
if (v || has(rest, "--no-verify")) patch.verify = has(rest, "--no-verify") ? null : v;
|
|
227
233
|
if (flag(rest, "--scope")) patch.scope = flag(rest, "--scope");
|
|
234
|
+
if (has(rest, "--unclaim")) patch.session = null;
|
|
235
|
+
else if (flag(rest, "--session")) patch.session = flag(rest, "--session");
|
|
228
236
|
if (flag(rest, "--body")) patch.body = flag(rest, "--body");
|
|
229
237
|
if (flag(rest, "--status")) patch.status = flag(rest, "--status");
|
|
230
238
|
if (has(rest, "--crew")) patch.disposition = "crew";
|
|
@@ -278,7 +286,9 @@ ${tail}
|
|
|
278
286
|
break;
|
|
279
287
|
}
|
|
280
288
|
case "pending": {
|
|
281
|
-
const
|
|
289
|
+
const mine = flag(rest, "--session") || (has(rest, "--mine") ? sessionId : null);
|
|
290
|
+
const inScope = (i) => !mine || i.scope === "project" || i.session === mine;
|
|
291
|
+
const pending = listIssues(root).filter(inScope).filter((i) => i.status === "ready" || i.status === "in_progress" || i.status === "backlog" && !i.triaged);
|
|
282
292
|
if (json) console.log(JSON.stringify(pending));
|
|
283
293
|
else out(pending.length ? `${pending.length} pending: ${pending.map((i) => "#" + i.id).join(" ")}` : "No pending issues.");
|
|
284
294
|
process.exit(pending.length ? 1 : 0);
|