@calo-design/cli 0.13.1 → 0.13.3
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/bin/backend.js +40 -7
- package/package.json +1 -1
package/bin/backend.js
CHANGED
|
@@ -234,7 +234,16 @@ async function cmdDeploy(args) {
|
|
|
234
234
|
async function cmdStatus(args) {
|
|
235
235
|
const root = process.cwd();
|
|
236
236
|
const slug = resolveSlug(args, root);
|
|
237
|
-
|
|
237
|
+
let text;
|
|
238
|
+
try {
|
|
239
|
+
text = await call("GET", `/v1/backend/status?slug=${encodeURIComponent(slug)}`, { raw: true });
|
|
240
|
+
} catch (e) {
|
|
241
|
+
// "no backend for this prototype" is a normal first-run answer. Under --json the
|
|
242
|
+
// contract is "the last stdout line is JSON" — honor it even here, so an agent that
|
|
243
|
+
// parses the last line gets `{ok:false,...}` instead of crashing on a human error line.
|
|
244
|
+
if (has(args, "json")) return emitJson({ ok: false, slug, provisioned: false, error: e.message, status: e.status || null });
|
|
245
|
+
throw e;
|
|
246
|
+
}
|
|
238
247
|
if (has(args, "json")) return emitJson(text);
|
|
239
248
|
const s = JSON.parse(text);
|
|
240
249
|
log(`${c.b(s.slug)} ${c.dim(`(${s.base})`)}`);
|
|
@@ -285,7 +294,16 @@ async function cmdSql(args) {
|
|
|
285
294
|
if (!query) throw new Error('usage: calo-design backend sql "SELECT * FROM items"');
|
|
286
295
|
const root = process.cwd();
|
|
287
296
|
const slug = resolveSlug(args.filter((a) => a !== query), root);
|
|
288
|
-
|
|
297
|
+
let text;
|
|
298
|
+
try {
|
|
299
|
+
text = await call("POST", "/v1/backend/sql", { body: { slug, query }, raw: true });
|
|
300
|
+
} catch (e) {
|
|
301
|
+
if (has(args, "json")) {
|
|
302
|
+
emitJson({ ok: false, error: e.message, status: e.status || null });
|
|
303
|
+
process.exit(1);
|
|
304
|
+
}
|
|
305
|
+
throw e;
|
|
306
|
+
}
|
|
289
307
|
if (has(args, "json")) return emitJson(text);
|
|
290
308
|
const body = JSON.parse(text);
|
|
291
309
|
log(JSON.stringify(body.results, null, 2));
|
|
@@ -316,10 +334,12 @@ async function cmdCheck(args) {
|
|
|
316
334
|
await new Promise((r) => setTimeout(r, 5000));
|
|
317
335
|
} catch (e) {
|
|
318
336
|
if (i >= TRIES) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
337
|
+
const msg = `worker unreachable at ${bj.workerUrl} (${e.message}) — deployed yet? try \`calo-design backend deploy\`, then re-run \`calo-design backend check\``;
|
|
338
|
+
if (has(args, "json")) {
|
|
339
|
+
emitJson({ ok: false, reachable: false, error: msg });
|
|
340
|
+
process.exit(1);
|
|
341
|
+
}
|
|
342
|
+
throw new Error(msg);
|
|
323
343
|
}
|
|
324
344
|
log(c.dim(` worker not reachable yet (${e.message}) — retrying ${i}/${TRIES - 1} in 5s`));
|
|
325
345
|
await new Promise((r) => setTimeout(r, 5000));
|
|
@@ -360,10 +380,23 @@ async function cmdRotateKey(args) {
|
|
|
360
380
|
warn("published web shares still carry the OLD key baked into their bundle — re-run `calo-design share` to fix them");
|
|
361
381
|
}
|
|
362
382
|
|
|
383
|
+
// Org-wide backend list for the Design Kitchen dashboard (machine-facing; --json).
|
|
384
|
+
async function cmdAll(args) {
|
|
385
|
+
const text = await call("GET", "/v1/backend/all", { raw: true });
|
|
386
|
+
if (has(args, "json")) return emitJson(text);
|
|
387
|
+
const { backends } = JSON.parse(text);
|
|
388
|
+
if (!backends.length) return log(c.dim("no prototype backends yet"));
|
|
389
|
+
for (const b of backends) {
|
|
390
|
+
const who = (b.owner || "").split("@")[0];
|
|
391
|
+
log(`${c.b(b.slug)} ${c.dim(who)} ${b.resources.join("+") || c.dim("worker")}${b.deployed ? "" : c.dim(" (not deployed)")}`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
363
395
|
async function cmdBackend(args) {
|
|
364
396
|
const sub = args[0] && !args[0].startsWith("--") ? args[0] : "";
|
|
365
397
|
const rest = args.slice(1);
|
|
366
398
|
if (sub === "init") return cmdInit(rest);
|
|
399
|
+
if (sub === "all") return cmdAll(rest);
|
|
367
400
|
if (sub === "add") return cmdAdd(rest);
|
|
368
401
|
if (sub === "deploy") return cmdDeploy(rest);
|
|
369
402
|
if (sub === "status") return cmdStatus(rest);
|
|
@@ -373,7 +406,7 @@ async function cmdBackend(args) {
|
|
|
373
406
|
if (sub === "secrets") return cmdSecrets(rest);
|
|
374
407
|
if (sub === "rotate-key") return cmdRotateKey(rest);
|
|
375
408
|
throw new Error(
|
|
376
|
-
"unknown backend command — one of: init, add <d1|kv|r2>, deploy, status, logs, sql, check, secrets set, rotate-key"
|
|
409
|
+
"unknown backend command — one of: init, add <d1|kv|r2>, deploy, status, logs, sql, check, secrets set, rotate-key, all"
|
|
377
410
|
);
|
|
378
411
|
}
|
|
379
412
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calo-design/cli",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "One-line setup for Calo design tooling: logs in with your Calo email and installs the calo-design skill + design-system packages. No GitHub account needed.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"calo-design": "bin/cli.js"
|