@camox/cli 0.24.1 → 0.26.0

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/index.mjs +59 -13
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -238,7 +238,6 @@ const runtimeSchema = z.object({
238
238
  projectSlug: z.string().min(1),
239
239
  apiUrl: z.string().url(),
240
240
  authenticationUrl: z.string().url(),
241
- environmentName: z.string().min(1),
242
241
  disableTelemetry: z.boolean().optional().default(false)
243
242
  });
244
243
  const SIDECAR = path.join("node_modules", ".camox", "runtime.json");
@@ -323,9 +322,11 @@ async function callRemote(params) {
323
322
  * and render the result. Exit codes: 0 on success, 1 on tool error, 2 on
324
323
  * auth/project resolution failure.
325
324
  *
326
- * Project, apiUrl, and authenticationUrl all come from the vite plugin's
327
- * `node_modules/.camox/runtime.json` sidecar that's the single source of
328
- * truth. `--project <slug>` and `CAMOX_PROJECT` may override the slug.
325
+ * Project, apiUrl, and authenticationUrl come from the vite plugin's
326
+ * `node_modules/.camox/runtime.json` sidecar. `--project <slug>` and
327
+ * `CAMOX_PROJECT` may override the slug. The environment is *not* read
328
+ * from the sidecar — it's derived from auth (`dev:<email>`) by default,
329
+ * with `--production` as the only opt-in for prod.
329
330
  */
330
331
  async function dispatch(opts) {
331
332
  let runtime;
@@ -344,7 +345,11 @@ async function dispatch(opts) {
344
345
  code: "NOT_AUTHENTICATED",
345
346
  message: `No stored credentials for ${runtime.authenticationUrl}. Run \`camox login\` against this backend first.`
346
347
  }, 2);
347
- const environmentName = opts.production ? "production" : runtime.environmentName;
348
+ if (!opts.production && !token.email) return fail({
349
+ code: "AUTH_INCOMPLETE",
350
+ message: "Auth token is missing an email. Run `camox login` to refresh credentials."
351
+ }, 2);
352
+ const environmentName = opts.production ? "production" : `dev:${token.email}`;
348
353
  const projectId = await resolveProjectId(token.token, slug, runtime.apiUrl);
349
354
  const response = await callRemote({
350
355
  token: token.token,
@@ -367,6 +372,7 @@ async function dispatch(opts) {
367
372
  const projectFlag$3 = optional(option("--project", string({ metavar: "SLUG" })));
368
373
  const jsonFlag$3 = option("--json");
369
374
  const productionFlag$2 = option("--production");
375
+ const liveFlag$1 = option("--live");
370
376
  const parser$7 = command("blocks", or(command("types", object({
371
377
  command: constant("blocks.types"),
372
378
  project: projectFlag$3,
@@ -381,6 +387,7 @@ const parser$7 = command("blocks", or(command("types", object({
381
387
  })), command("get", object({
382
388
  command: constant("blocks.get"),
383
389
  id: option("--id", integer({ metavar: "ID" })),
390
+ live: liveFlag$1,
384
391
  project: projectFlag$3,
385
392
  production: productionFlag$2,
386
393
  json: jsonFlag$3
@@ -472,7 +479,10 @@ async function handler$7(args) {
472
479
  });
473
480
  case "blocks.get": return dispatch({
474
481
  toolName: "getBlock",
475
- args: { id: args.id },
482
+ args: {
483
+ id: args.id,
484
+ source: args.live ? "live" : "draft"
485
+ },
476
486
  projectFlag,
477
487
  production,
478
488
  outputMode
@@ -914,19 +924,32 @@ function logout() {
914
924
  const projectFlag = optional(option("--project", string({ metavar: "SLUG" })));
915
925
  const jsonFlag = option("--json");
916
926
  const productionFlag = option("--production");
917
- const parser$1 = command("pages", or(command("list", object({
927
+ const liveFlag = option("--live");
928
+ const list = command("list", object({
918
929
  command: constant("pages.list"),
919
930
  project: projectFlag,
920
931
  production: productionFlag,
921
932
  json: jsonFlag
922
- })), command("get", object({
933
+ }));
934
+ const get = command("get", object({
923
935
  command: constant("pages.get"),
924
936
  id: optional(option("--id", integer({ metavar: "ID" }))),
925
937
  path: optional(option("--path", string({ metavar: "PATH" }))),
938
+ live: liveFlag,
926
939
  project: projectFlag,
927
940
  production: productionFlag,
928
941
  json: jsonFlag
929
- })), command("create", object({
942
+ }));
943
+ const publish = command("publish", object({
944
+ command: constant("pages.publish"),
945
+ id: optional(option("--id", integer({ metavar: "ID" }))),
946
+ path: optional(option("--path", string({ metavar: "PATH" }))),
947
+ noLayout: option("--no-layout"),
948
+ project: projectFlag,
949
+ production: productionFlag,
950
+ json: jsonFlag
951
+ }));
952
+ const parser$1 = command("pages", or(list, get, command("create", object({
930
953
  command: constant("pages.create"),
931
954
  pathSegment: option("--path-segment", string({ metavar: "SEGMENT" })),
932
955
  layoutId: option("--layout-id", integer({ metavar: "ID" })),
@@ -956,7 +979,7 @@ const parser$1 = command("pages", or(command("list", object({
956
979
  project: projectFlag,
957
980
  production: productionFlag,
958
981
  json: jsonFlag
959
- }))));
982
+ })), publish));
960
983
  async function handler$1(args) {
961
984
  const outputMode = args.json ? "json" : "auto";
962
985
  const projectFlag = args.project;
@@ -979,7 +1002,10 @@ async function handler$1(args) {
979
1002
  }
980
1003
  return dispatch({
981
1004
  toolName: "getPage",
982
- args: args.id != null ? { id: args.id } : { path: args.path },
1005
+ args: {
1006
+ ...args.id != null ? { id: args.id } : { path: args.path },
1007
+ source: args.live ? "live" : "draft"
1008
+ },
983
1009
  projectFlag,
984
1010
  production,
985
1011
  outputMode
@@ -1024,6 +1050,24 @@ async function handler$1(args) {
1024
1050
  production,
1025
1051
  outputMode
1026
1052
  });
1053
+ case "pages.publish":
1054
+ if (args.id == null === (args.path == null)) {
1055
+ printError({
1056
+ code: "INVALID_ARGS",
1057
+ message: "Pass exactly one of --id or --path."
1058
+ });
1059
+ process.exit(2);
1060
+ }
1061
+ return dispatch({
1062
+ toolName: "publishPage",
1063
+ args: {
1064
+ ...args.id != null ? { id: args.id } : { path: args.path },
1065
+ alsoPublishLayout: !args.noLayout
1066
+ },
1067
+ projectFlag,
1068
+ production,
1069
+ outputMode
1070
+ });
1027
1071
  }
1028
1072
  }
1029
1073
  //#endregion
@@ -1047,8 +1091,8 @@ async function handler(args) {
1047
1091
  }
1048
1092
  throw err;
1049
1093
  }
1050
- const environmentName = args.production ? "production" : runtime.environmentName;
1051
1094
  const token = readAuthTokenForUrl(runtime.authenticationUrl);
1095
+ const environmentName = args.production ? "production" : token?.email ? `dev:${token.email}` : null;
1052
1096
  const status = {
1053
1097
  projectSlug: runtime.projectSlug,
1054
1098
  environmentName,
@@ -1066,7 +1110,7 @@ async function handler(args) {
1066
1110
  }
1067
1111
  const lines = [
1068
1112
  `project: ${status.projectSlug}`,
1069
- `environment: ${status.environmentName}`,
1113
+ `environment: ${status.environmentName ?? "(unknown — run `camox login`)"}`,
1070
1114
  `api: ${status.apiUrl}`,
1071
1115
  `auth: ${status.authenticationUrl}`,
1072
1116
  status.user ? `signed in: ${status.user.name} <${status.user.email}>` : `signed in: (no token for ${status.authenticationUrl} — run \`camox login\`)`
@@ -1102,10 +1146,12 @@ switch (result.command) {
1102
1146
  case "pages.update":
1103
1147
  case "pages.set-layout":
1104
1148
  case "pages.delete":
1149
+ case "pages.publish":
1105
1150
  await handler$1(result);
1106
1151
  break;
1107
1152
  case "blocks.types":
1108
1153
  case "blocks.describe":
1154
+ case "blocks.get":
1109
1155
  case "blocks.create":
1110
1156
  case "blocks.edit":
1111
1157
  case "blocks.move":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camox/cli",
3
- "version": "0.24.1",
3
+ "version": "0.26.0",
4
4
  "bin": {
5
5
  "camox": "./dist/index.mjs"
6
6
  },
@@ -26,7 +26,7 @@
26
26
  "@types/node": "^24.12.2",
27
27
  "@typescript/native-preview": "7.0.0-dev.20260412.1",
28
28
  "vite-plus": "latest",
29
- "@camox/api-contract": "0.24.1"
29
+ "@camox/api-contract": "0.26.0"
30
30
  },
31
31
  "nx": {
32
32
  "tags": [