@fabrika/cli 0.3.1 → 0.3.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.
- package/package.json +8 -8
- package/src/control.ts +37 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"zod": "^3.25.76",
|
|
33
|
-
"@fabrika/app": "^0.3.
|
|
34
|
-
"@fabrika/auth-core": "^0.3.
|
|
35
|
-
"@fabrika/builder": "^0.3.
|
|
36
|
-
"@fabrika/control-contract": "^0.3.
|
|
37
|
-
"@fabrika/provider-cloudflare": "^0.3.
|
|
38
|
-
"@fabrika/provider-contract": "^0.3.
|
|
39
|
-
"@fabrika/provider-zerops": "^0.3.
|
|
33
|
+
"@fabrika/app": "^0.3.2",
|
|
34
|
+
"@fabrika/auth-core": "^0.3.2",
|
|
35
|
+
"@fabrika/builder": "^0.3.2",
|
|
36
|
+
"@fabrika/control-contract": "^0.3.2",
|
|
37
|
+
"@fabrika/provider-cloudflare": "^0.3.2",
|
|
38
|
+
"@fabrika/provider-contract": "^0.3.2",
|
|
39
|
+
"@fabrika/provider-zerops": "^0.3.2"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/control.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
DeploymentNamespaceDto,
|
|
19
19
|
JsonValue,
|
|
20
20
|
PlanDeploymentNamespaceRequest,
|
|
21
|
+
PlanDeploymentNamespaceResponse,
|
|
21
22
|
PutAppEnvRequest,
|
|
22
23
|
PutAppVarRequest,
|
|
23
24
|
RegisterAppRequest,
|
|
@@ -90,7 +91,9 @@ Namespace placement options, each defaulting to what the preset would choose:
|
|
|
90
91
|
--public-access=<custom-domain|zerops-subdomain>
|
|
91
92
|
--exclusive-app=<id> required by, and only by, the \`full\` preset
|
|
92
93
|
|
|
93
|
-
\`namespaces plan\` is a preview and changes nothing.
|
|
94
|
+
\`namespaces plan\` is a preview and changes nothing. It prints one \`<path>\\t<value>\` row per field of
|
|
95
|
+
the plan, keyed by its path in \`--json\`; a multi-line value such as the proxy's descriptor file is shown
|
|
96
|
+
by size only. \`namespaces create\` commits that exact plan — the
|
|
94
97
|
same two steps the console's form takes — and returns as soon as the placement is recorded: provisioning
|
|
95
98
|
runs behind the control queue and takes minutes, so the state comes back \`pending\`. Follow it with
|
|
96
99
|
\`namespaces get\` or \`namespaces list\`; nothing needs to stay connected. \`namespaces remove\` frees the id
|
|
@@ -505,6 +508,38 @@ const namespaceHostLines = (namespace: DeploymentNamespaceDetailDto): string[] =
|
|
|
505
508
|
`${entry.host}\t${entry.port}\t${entry.takenBy === undefined ? 'free' : `taken by ${entry.takenBy.appId}/${entry.takenBy.environment}`}`
|
|
506
509
|
)
|
|
507
510
|
|
|
511
|
+
/**
|
|
512
|
+
* One `<path>\t<value>` row per scalar of a provider payload, keyed by its path in `--json`. The payload
|
|
513
|
+
* is the provider's own schema, so it is walked rather than decoded. A multi-line string — a whole
|
|
514
|
+
* descriptor file — cannot be a row cell, so its row names only its size.
|
|
515
|
+
*/
|
|
516
|
+
const payloadRows = (path: string, value: JsonValue): string[] => {
|
|
517
|
+
if (Array.isArray(value)) {
|
|
518
|
+
return value.length === 0 ? [`${path}\t[]`] : value.flatMap((item, index) => payloadRows(`${path}.${index}`, item))
|
|
519
|
+
}
|
|
520
|
+
if (typeof value === 'object' && value !== null) {
|
|
521
|
+
const entries = Object.entries(value)
|
|
522
|
+
return entries.length === 0 ? [`${path}\t{}`] : entries.flatMap(([key, item]) => payloadRows(`${path}.${key}`, item))
|
|
523
|
+
}
|
|
524
|
+
return [`${path}\t${value === null ? 'null' : cell(String(value))}`]
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/** A value that would break a row — a line break or a tab — is shown by size only; `--json` prints it whole. */
|
|
528
|
+
const cell = (value: string): string => /[\r\n\t]/.test(value) ? `(${new TextEncoder().encode(value).byteLength} bytes; --json prints it)` : value
|
|
529
|
+
|
|
530
|
+
const namespacePlanLines = (plan: PlanDeploymentNamespaceResponse): string[] => [
|
|
531
|
+
`namespace.id\t${plan.namespace.id}`,
|
|
532
|
+
`namespace.env\t${plan.namespace.env}`,
|
|
533
|
+
`namespace.exclusiveAppId\t${plan.namespace.exclusiveAppId ?? '-'}`,
|
|
534
|
+
`namespace.target.provider\t${plan.namespace.target.provider}`,
|
|
535
|
+
`namespace.target.version\t${plan.namespace.target.version}`,
|
|
536
|
+
...payloadRows('namespace.target.payload', plan.namespace.target.payload),
|
|
537
|
+
`presentation.preset\t${plan.presentation.preset}`,
|
|
538
|
+
`presentation.title\t${cell(plan.presentation.title)}`,
|
|
539
|
+
...plan.presentation.facts.map((fact) => `presentation.fact\t${cell(fact.label)}\t${cell(fact.value)}`),
|
|
540
|
+
...plan.presentation.instructions.map((instruction) => `presentation.instruction\t${cell(instruction)}`),
|
|
541
|
+
]
|
|
542
|
+
|
|
508
543
|
/** The failure is a DIAGNOSTIC, so it goes to stderr and leaves the data columns above untouched. */
|
|
509
544
|
const warnNamespaceFailure = (namespace: DeploymentNamespaceDto): void => {
|
|
510
545
|
// Falsy, not `=== null`: a control plane that omits the field must not print an empty diagnostic.
|
|
@@ -546,7 +581,7 @@ const runNamespaces = async (verb: string | undefined, flags: Flags, env: Readon
|
|
|
546
581
|
}
|
|
547
582
|
if (verb === 'plan') {
|
|
548
583
|
const result = await client.namespaces.plan(namespacePlan(flags))
|
|
549
|
-
emit(flags, result, () =>
|
|
584
|
+
emit(flags, result, () => namespacePlanLines(result).join('\n'))
|
|
550
585
|
return
|
|
551
586
|
}
|
|
552
587
|
if (verb === 'reconcile') {
|