@fabrika/cli 0.4.1 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,19 +30,19 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "zod": "^3.25.76",
33
- "@fabrika/app": "^0.4.1",
34
- "@fabrika/auth-core": "^0.4.1",
35
- "@fabrika/control-contract": "^0.4.1",
36
- "@fabrika/provider-contract": "^0.4.1",
37
- "@fabrika/db": "^0.4.1",
38
- "@fabrika/platform": "^0.4.1",
39
- "@fabrika/platform-node": "^0.4.1",
40
- "@fabrika/check": "^0.4.1"
33
+ "@fabrika/app": "^0.4.3",
34
+ "@fabrika/auth-core": "^0.4.3",
35
+ "@fabrika/control-contract": "^0.4.3",
36
+ "@fabrika/provider-contract": "^0.4.3",
37
+ "@fabrika/db": "^0.4.3",
38
+ "@fabrika/platform": "^0.4.3",
39
+ "@fabrika/platform-node": "^0.4.3",
40
+ "@fabrika/check": "^0.4.3"
41
41
  },
42
42
  "peerDependencies": {
43
- "@fabrika/builder": "^0.4.1",
44
- "@fabrika/provider-cloudflare": "^0.4.1",
45
- "@fabrika/provider-zerops": "^0.4.1"
43
+ "@fabrika/builder": "^0.4.3",
44
+ "@fabrika/provider-cloudflare": "^0.4.3",
45
+ "@fabrika/provider-zerops": "^0.4.3"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "@fabrika/builder": {
package/src/control.ts CHANGED
@@ -64,6 +64,7 @@ Usage:
64
64
  fabrika control namespaces plan --namespace=<id> --env=<name> --preset=<cheap|mid|full> [placement]
65
65
  fabrika control namespaces create --namespace=<id> --env=<name> --preset=<cheap|mid|full> [placement]
66
66
  fabrika control namespaces reconcile --namespace=<id>
67
+ fabrika control namespaces update --namespace=<id> --proxy-source=current
67
68
  fabrika control namespaces remove --namespace=<id>
68
69
  fabrika control deploy --app=<id> --env=<name> [--ref=<ref>]
69
70
  fabrika control runs list [--app=<id>] [--env=<name>] [--limit=<n>]
@@ -82,7 +83,8 @@ proxy. A manifest with no proxy target needs no domain.
82
83
 
83
84
  \`--installation-id\` has three states: omitted resolves the installation from the organization's
84
85
  connected GitHub App, \`none\` registers an anonymous PUBLIC repository source, and a number names one
85
- installation outright.
86
+ installation outright. With \`none\`, control reads the repository once without a token and refuses one
87
+ GitHub hides: a private repository needs the GitHub App connected in the console first.
86
88
 
87
89
  Namespace placement options, each defaulting to what the preset would choose:
88
90
 
@@ -99,7 +101,9 @@ same two steps the console's form takes — and returns as soon as the placement
99
101
  runs behind the control queue and takes minutes, so the state comes back \`pending\`. Follow it with
100
102
  \`namespaces get\` or \`namespaces list\`; nothing needs to stay connected. \`namespaces remove\` frees the id
101
103
  of a placement no application is registered in. It deletes nothing at the provider and prints, on stderr,
102
- the provider resources it stopped tracking.
104
+ the provider resources it stopped tracking. \`namespaces update --proxy-source=current\` re-pins a placement's
105
+ proxy to the source this control plane deploys new placements from — a placement keeps the one it was created
106
+ with until you do — and queues the reconcile that rebuilds the proxy from it; a \`failed\` placement accepts it.
103
107
 
104
108
  Every command accepts --json, which prints the procedure's result verbatim.
105
109
 
@@ -247,6 +251,15 @@ const emit = (flags: Flags, result: unknown, render: () => string): void => {
247
251
  console.info(flags.json ? JSON.stringify(result, null, 2) : render())
248
252
  }
249
253
 
254
+ /** A list prints one row per item; an empty one says so on stderr, so stdout stays data and a human still gets an answer. */
255
+ const emitList = <Item>(flags: Flags, result: { readonly items: readonly Item[] }, row: (item: Item) => string, empty: string): void => {
256
+ if (!flags.json && result.items.length === 0) {
257
+ console.warn(empty)
258
+ return
259
+ }
260
+ emit(flags, result, () => result.items.map(row).join('\n'))
261
+ }
262
+
250
263
  /** `fabrika app build` writes `manifestVersion`; it is the version the provider's artifact codec accepts. */
251
264
  const manifestVersion = (manifest: JsonValue, path: string): number => {
252
265
  const result = manifestHeaderSchema.safeParse(manifest)
@@ -465,8 +478,9 @@ const runEnvironments = async (
465
478
  ): Promise<void> => {
466
479
  const client = controlClient(flags, env)
467
480
  if (verb === 'list') {
468
- const result = await client.apps.environments.list({ appId: required(flags, 'app') })
469
- emit(flags, result, () => result.items.map((item) => `${item.appId}\t${item.env}\t${item.provider}\t${item.domain ?? '-'}`).join('\n'))
481
+ const appId = required(flags, 'app')
482
+ const result = await client.apps.environments.list({ appId })
483
+ emitList(flags, result, (item) => `${item.appId}\t${item.env}\t${item.provider}\t${item.domain ?? '-'}`, `app ${appId} has no environments`)
470
484
  return
471
485
  }
472
486
  if (verb === 'put') {
@@ -507,7 +521,7 @@ const runVariables = async (verb: string | undefined, flags: Flags, env: Readonl
507
521
  const scope = optional(flags, 'env')
508
522
  if (verb === 'list') {
509
523
  const result = await client.apps.variables.list({ appId })
510
- emit(flags, result, () => result.items.map((item) => `${item.env ?? '*'}\t${item.name}\t${item.value}`).join('\n'))
524
+ emitList(flags, result, (item) => `${item.env ?? '*'}\t${item.name}\t${item.value}`, `app ${appId} has no variables`)
511
525
  return
512
526
  }
513
527
  if (verb === 'put') {
@@ -545,7 +559,7 @@ const runApps = async (
545
559
  const client = controlClient(flags, env)
546
560
  if (verb === 'list') {
547
561
  const result = await client.apps.list()
548
- emit(flags, result, () => result.items.map(appLine).join('\n'))
562
+ emitList(flags, result, appLine, 'no applications registered yet')
549
563
  return
550
564
  }
551
565
  if (verb === 'get') {
@@ -567,11 +581,12 @@ const runRuns = async (verb: string | undefined, flags: Flags, env: Readonly<Rec
567
581
  ...(environment === undefined ? {} : { env: environment }),
568
582
  ...(limit === undefined ? {} : { limit: positiveInteger(limit, 'limit') }),
569
583
  })
570
- emit(flags, result, () => result.items.map(runLine).join('\n'))
584
+ emitList(flags, result, runLine, 'no runs')
571
585
  return
572
586
  }
573
587
  if (verb === 'get') {
574
588
  const result = await client.runs.get({ runId: required(flags, 'run') })
589
+ if (result.status === 'failed') console.warn(`why it failed: fabrika control runs log --run=${result.id}`)
575
590
  emit(flags, result, () => runLine(result))
576
591
  return
577
592
  }
@@ -624,11 +639,17 @@ const namespacePlanLines = (plan: PlanDeploymentNamespaceResponse): string[] =>
624
639
  ...plan.presentation.instructions.map((instruction) => `presentation.instruction\t${cell(instruction)}`),
625
640
  ]
626
641
 
627
- /** The failure is a DIAGNOSTIC, so it goes to stderr and leaves the data columns above untouched. */
642
+ /**
643
+ * The failure is a DIAGNOSTIC, so it goes to stderr and leaves the data columns above untouched. A `failed` state is an
644
+ * answer, not a command failure, so the exit code stays 0, and the line names the verb that resumes it. An unconfirmed
645
+ * update is the exception: only retrying that update clears it, and its message says so.
646
+ */
628
647
  const warnNamespaceFailure = (namespace: DeploymentNamespaceDto): void => {
629
648
  // Falsy, not `=== null`: a control plane that omits the field must not print an empty diagnostic.
630
- if (!namespace.lastError) return
631
- console.warn(`${namespace.lastErrorCode ?? 'unknown'}: ${namespace.lastError}`)
649
+ if (namespace.lastError) console.warn(`${namespace.lastErrorCode ?? 'unknown'}: ${namespace.lastError}`)
650
+ if (namespace.state === 'failed' && namespace.unconfirmedTarget === undefined) {
651
+ console.warn(`resume it with: fabrika control namespaces reconcile --namespace=${namespace.id}`)
652
+ }
632
653
  }
633
654
 
634
655
  /** Placement flags are the preset's overrides, so only the ones actually given are sent. */
@@ -654,7 +675,7 @@ const runNamespaces = async (verb: string | undefined, flags: Flags, env: Readon
654
675
  const client = controlClient(flags, env)
655
676
  if (verb === 'list') {
656
677
  const result = await client.namespaces.list()
657
- emit(flags, result, () => result.items.map(namespaceLine).join('\n'))
678
+ emitList(flags, result, namespaceLine, 'no deployment namespaces yet')
658
679
  return
659
680
  }
660
681
  if (verb === 'get') {
@@ -686,6 +707,21 @@ const runNamespaces = async (verb: string | undefined, flags: Flags, env: Readon
686
707
  emit(flags, result, () => namespaceLine(result.removed))
687
708
  return
688
709
  }
710
+ if (verb === 'update') {
711
+ const namespaceId = required(flags, 'namespace')
712
+ if (required(flags, 'proxy-source') !== 'current') {
713
+ throw new Error('--proxy-source takes only `current`: the source this control plane deploys new placements from')
714
+ }
715
+ // The envelope names the provider and codec the stored target already has; the provider merges the field over it.
716
+ const { target } = await client.namespaces.get({ namespaceId })
717
+ const result = await client.namespaces.update({
718
+ namespaceId,
719
+ namespace: { target: { provider: target.provider, version: target.version, payload: { proxySource: 'current' } } },
720
+ })
721
+ warnNamespaceFailure(result)
722
+ emit(flags, result, () => namespaceLine(result))
723
+ return
724
+ }
689
725
  if (verb === 'create') {
690
726
  const request = namespacePlan(flags)
691
727
  // Plan then commit THAT plan, exactly as the console's two-step form does — never a second
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ import { CONTROL_USAGE, registerCompiledManifest, runControlCli } from './contro
9
9
  const USAGE = `fabrika — application platform CLI
10
10
 
11
11
  Usage:
12
+ fabrika platform guide --provider=zerops
12
13
  fabrika platform install --provider=zerops [provider options]
13
14
  fabrika platform init --provider=<cloudflare|zerops> [provider options]
14
15
  fabrika platform plan --provider=<cloudflare|zerops> [provider options]
@@ -29,6 +30,9 @@ Usage:
29
30
  fabrika job run <name>
30
31
  fabrika connect <add|pull> <app>/<export>@<version> --consumer=<app> --env=<env> [--url=<control origin>]
31
32
 
33
+ Installing the platform on Zerops? Run \`fabrika platform guide --provider=zerops\` first: the whole bring-up
34
+ in order, what to ask the human for, and the traps.
35
+
32
36
  For app commands, the provider is read from the config returned by the selected provider's defineApp().
33
37
  An explicit --provider is required only when no app config is available.
34
38