@calo-design/cli 0.13.1 → 0.13.2

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.
Files changed (2) hide show
  1. package/bin/backend.js +26 -6
  2. 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
- const text = await call("GET", `/v1/backend/status?slug=${encodeURIComponent(slug)}`, { raw: true });
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
- const text = await call("POST", "/v1/backend/sql", { body: { slug, query }, raw: true });
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
- throw new Error(
320
- `worker unreachable at ${bj.workerUrl} (${e.message}) — deployed yet? try \`calo-design backend deploy\`, ` +
321
- "then re-run `calo-design backend check`"
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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calo-design/cli",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
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"