@uetuluk/create-cli 0.0.2 → 0.0.4

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/dist/cli.js +18 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -25,11 +25,27 @@ async function api(serverUrl2, path, init = {}) {
25
25
  } catch {
26
26
  }
27
27
  if (!r.ok) {
28
- const msg = body && typeof body === "object" && (body.error || body.message) || `HTTP ${r.status}`;
28
+ const msg = formatErrorMessage(body, r.status);
29
29
  throw new ApiError(r.status, msg, body);
30
30
  }
31
31
  return body;
32
32
  }
33
+ function formatErrorMessage(body, status) {
34
+ if (!body || typeof body !== "object") return `HTTP ${status}`;
35
+ const b = body;
36
+ const outer = typeof b.error === "string" && b.error || typeof b.message === "string" && b.message || "";
37
+ const inner = innerDetail(b.data);
38
+ if (outer && inner && inner !== outer) return `${outer}: ${inner}`;
39
+ return outer || inner || `HTTP ${status}`;
40
+ }
41
+ function innerDetail(data) {
42
+ if (!data || typeof data !== "object") return "";
43
+ const d = data;
44
+ for (const v of [d.error, d.detail, d.message]) {
45
+ if (typeof v === "string" && v) return v;
46
+ }
47
+ return "";
48
+ }
33
49
 
34
50
  // src/store.ts
35
51
  import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -265,7 +281,7 @@ cli.command("deploy <name>", "push schema + migrations to your instance").option
265
281
  const r = await api(inst.url, "/api/v1/migrations", {
266
282
  method: "POST",
267
283
  token: inst.adminToken,
268
- body: JSON.stringify({ migrations: [], settings, lastVersion: null })
284
+ body: JSON.stringify({ settings, generate: true })
269
285
  });
270
286
  console.log(colors.green(`deployed to ${inst.url}`));
271
287
  if (r.applied?.length) console.log(` applied: ${r.applied.join(", ")}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uetuluk/create-cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "CLI for the create.ritsdev.top platform — register, provision, and deploy teenybase instances.",
5
5
  "type": "module",
6
6
  "bin": {