@fabrika/cli 0.0.22 → 0.0.24

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.0.22",
3
+ "version": "0.0.24",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,14 +29,14 @@
29
29
  "test": "bun test"
30
30
  },
31
31
  "dependencies": {
32
- "@fabrika/app": "^0.0.22",
33
- "@fabrika/auth-core": "^0.0.22",
34
- "@fabrika/control-contract": "^0.0.22",
35
- "@fabrika/installation-cloudflare": "^0.0.22",
36
- "@fabrika/installation-contract": "^0.0.22",
37
- "@fabrika/installation-zerops": "^0.0.22",
38
- "@fabrika/provider-cloudflare": "^0.0.22",
39
- "@fabrika/provider-contract": "^0.0.22",
40
- "@fabrika/provider-zerops": "^0.0.22"
32
+ "@fabrika/app": "^0.0.24",
33
+ "@fabrika/auth-core": "^0.0.24",
34
+ "@fabrika/control-contract": "^0.0.24",
35
+ "@fabrika/installation-cloudflare": "^0.0.24",
36
+ "@fabrika/installation-contract": "^0.0.24",
37
+ "@fabrika/installation-zerops": "^0.0.24",
38
+ "@fabrika/provider-cloudflare": "^0.0.24",
39
+ "@fabrika/provider-contract": "^0.0.24",
40
+ "@fabrika/provider-zerops": "^0.0.24"
41
41
  }
42
42
  }
package/src/control.ts CHANGED
@@ -39,9 +39,11 @@ Usage:
39
39
  [--domain=<host>] [--public-origin=<url>] [--trigger-ref=<ref>]
40
40
  [--namespace=<id>] [--installation-id=<n|none>]
41
41
  fabrika control namespaces list
42
+ fabrika control namespaces get --namespace=<id>
42
43
  fabrika control namespaces plan --namespace=<id> --env=<name> --preset=<cheap|mid|full> [placement]
43
44
  fabrika control namespaces create --namespace=<id> --env=<name> --preset=<cheap|mid|full> [placement]
44
45
  fabrika control namespaces reconcile --namespace=<id>
46
+ fabrika control namespaces remove --namespace=<id>
45
47
  fabrika control deploy --app=<id> --env=<name> [--ref=<ref>]
46
48
  fabrika control runs list [--app=<id>] [--env=<name>] [--limit=<n>]
47
49
  fabrika control runs get --run=<id>
@@ -62,8 +64,12 @@ Namespace placement options, each defaulting to what the preset would choose:
62
64
  --public-access=<custom-domain|zerops-subdomain>
63
65
  --exclusive-app=<id> required by, and only by, the \`full\` preset
64
66
 
65
- \`namespaces plan\` is a preview and changes nothing; \`namespaces create\` plans and then commits
66
- that exact plan, which is what the console's two-step form does.
67
+ \`namespaces plan\` is a preview and changes nothing. \`namespaces create\` commits that exact plan — the
68
+ same two steps the console's form takes — and returns as soon as the placement is recorded: provisioning
69
+ runs behind the control queue and takes minutes, so the state comes back \`pending\`. Follow it with
70
+ \`namespaces get\` or \`namespaces list\`; nothing needs to stay connected. \`namespaces remove\` frees the id
71
+ of a placement no application is registered in. It deletes nothing at the provider and prints, on stderr,
72
+ the provider resources it stopped tracking.
67
73
 
68
74
  Every command accepts --json, which prints the procedure's result verbatim.
69
75
 
@@ -454,6 +460,13 @@ const runRuns = async (verb: string | undefined, flags: Flags, env: Readonly<Rec
454
460
  const namespaceLine = (namespace: DeploymentNamespaceDto): string =>
455
461
  `${namespace.id}\t${namespace.env}\t${namespace.state}\t${namespace.exclusiveAppId ?? '-'}`
456
462
 
463
+ /** The failure is a DIAGNOSTIC, so it goes to stderr and leaves the data columns above untouched. */
464
+ const warnNamespaceFailure = (namespace: DeploymentNamespaceDto): void => {
465
+ // Falsy, not `=== null`: a control plane that omits the field must not print an empty diagnostic.
466
+ if (!namespace.lastError) return
467
+ console.warn(`${namespace.lastErrorCode ?? 'unknown'}: ${namespace.lastError}`)
468
+ }
469
+
457
470
  /** Placement flags are the preset's overrides, so only the ones actually given are sent. */
458
471
  const namespacePlan = (flags: Flags): PlanDeploymentNamespaceRequest => {
459
472
  const exclusiveAppId = optional(flags, 'exclusive-app')
@@ -480,18 +493,35 @@ const runNamespaces = async (verb: string | undefined, flags: Flags, env: Readon
480
493
  emit(flags, result, () => result.items.map(namespaceLine).join('\n'))
481
494
  return
482
495
  }
496
+ if (verb === 'get') {
497
+ const result = await client.namespaces.get({ namespaceId: required(flags, 'namespace') })
498
+ warnNamespaceFailure(result)
499
+ emit(flags, result, () => namespaceLine(result))
500
+ return
501
+ }
483
502
  if (verb === 'plan') {
484
503
  const result = await client.namespaces.plan(namespacePlan(flags))
485
504
  emit(flags, result, () => JSON.stringify(result.namespace.target.payload))
486
505
  return
487
506
  }
488
507
  if (verb === 'reconcile') {
489
- // Provisioning checkpoints its progress, so a namespace left `failed` by a timeout or a denied
490
- // call is resumed by reconciling it again rather than by creating a second one.
508
+ // Provisioning checkpoints its progress, so a namespace left `failed` by a denied or interrupted
509
+ // call is resumed by re-queueing it here rather than by creating a second one under another id.
491
510
  const result = await client.namespaces.reconcile({ namespaceId: required(flags, 'namespace') })
492
511
  emit(flags, result, () => namespaceLine(result))
493
512
  return
494
513
  }
514
+ if (verb === 'remove') {
515
+ const result = await client.namespaces.remove({ namespaceId: required(flags, 'namespace') })
516
+ // Fabrika holds OWNER on the projects it creates and deletes none of them here (ADR-0034), so what
517
+ // it has just stopped tracking is named for the operator to remove by hand. Only the facts the
518
+ // provider MARKED as live resources: a policy fact is not something anyone has to go and delete.
519
+ for (const fact of (result.removed.presentation?.facts ?? []).filter((fact) => fact.resource === true)) {
520
+ console.warn(`retained\t${fact.label}\t${fact.value}`)
521
+ }
522
+ emit(flags, result, () => namespaceLine(result.removed))
523
+ return
524
+ }
495
525
  if (verb === 'create') {
496
526
  const request = namespacePlan(flags)
497
527
  // Plan then commit THAT plan, exactly as the console's two-step form does — never a second
@@ -503,6 +533,7 @@ const runNamespaces = async (verb: string | undefined, flags: Flags, env: Readon
503
533
  target: planned.namespace.target,
504
534
  ...(request.exclusiveAppId === undefined ? {} : { exclusiveAppId: request.exclusiveAppId }),
505
535
  })
536
+ warnNamespaceFailure(result)
506
537
  emit(flags, result, () => namespaceLine(result))
507
538
  return
508
539
  }
package/src/index.ts CHANGED
@@ -12,6 +12,7 @@ Usage:
12
12
  fabrika platform init --provider=<cloudflare|zerops> [provider options]
13
13
  fabrika platform plan --provider=<cloudflare|zerops> [provider options]
14
14
  fabrika platform deploy --provider=<cloudflare|zerops> [provider options]
15
+ fabrika platform admin --provider=zerops --email=<address> [provider options]
15
16
  fabrika app deploy [--provider=cloudflare] --env=<env> [--config=<path>] [--dry-run]
16
17
  fabrika app build [--provider=zerops] --env=<env> [--config=<path>] [--output=<path>]
17
18
  fabrika namespace <plan|create|adopt|reconcile> --provider=zerops [provider options]
@@ -26,7 +27,8 @@ provider-neutral, loads no installation package, and speaks the same typed API t
26
27
 
27
28
  Which platform commands exist, and how WIDE each one is, is the provider's own answer — Zerops'
28
29
  \`platform deploy\` owns the whole ordered sequence while Cloudflare's is one step of a scaffolded
29
- workflow (ADR-0027), and only Zerops offers \`platform install\`, the from-scratch bring-up. Run
30
+ workflow (ADR-0027), and only Zerops offers \`platform install\`, the from-scratch bring-up, and
31
+ \`platform admin\`, which admits the first human to what that bring-up created. Run
30
32
  \`fabrika platform <command> --provider=<name> --help\` for that surface.
31
33
  `
32
34