@fabrika/cli 0.0.14 → 0.0.15
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 +10 -10
- package/src/control.ts +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
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.
|
|
33
|
-
"@fabrika/auth-core": "^0.0.
|
|
34
|
-
"@fabrika/control-contract": "^0.0.
|
|
35
|
-
"@fabrika/installation-cloudflare": "^0.0.
|
|
36
|
-
"@fabrika/installation-contract": "^0.0.
|
|
37
|
-
"@fabrika/installation-zerops": "^0.0.
|
|
38
|
-
"@fabrika/provider-cloudflare": "^0.0.
|
|
39
|
-
"@fabrika/provider-contract": "^0.0.
|
|
40
|
-
"@fabrika/provider-zerops": "^0.0.
|
|
32
|
+
"@fabrika/app": "^0.0.15",
|
|
33
|
+
"@fabrika/auth-core": "^0.0.15",
|
|
34
|
+
"@fabrika/control-contract": "^0.0.15",
|
|
35
|
+
"@fabrika/installation-cloudflare": "^0.0.15",
|
|
36
|
+
"@fabrika/installation-contract": "^0.0.15",
|
|
37
|
+
"@fabrika/installation-zerops": "^0.0.15",
|
|
38
|
+
"@fabrika/provider-cloudflare": "^0.0.15",
|
|
39
|
+
"@fabrika/provider-contract": "^0.0.15",
|
|
40
|
+
"@fabrika/provider-zerops": "^0.0.15"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/control.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
JsonValue,
|
|
19
19
|
PlanDeploymentNamespaceRequest,
|
|
20
20
|
PutAppEnvRequest,
|
|
21
|
+
PutAppVarRequest,
|
|
21
22
|
RegisterAppRequest,
|
|
22
23
|
RunDto,
|
|
23
24
|
} from '@fabrika/control-contract'
|
|
@@ -31,6 +32,9 @@ Usage:
|
|
|
31
32
|
fabrika control apps environments list --app=<id>
|
|
32
33
|
fabrika control apps environments put --provider=<name> --app=<id> --env=<name> --manifest=<path>
|
|
33
34
|
[--domain=<host>] [--public-origin=<url>] [--trigger-ref=<ref>] [--namespace=<id>]
|
|
35
|
+
fabrika control apps variables list --app=<id>
|
|
36
|
+
fabrika control apps variables put --app=<id> --name=<name> --value=<text> [--env=<name>]
|
|
37
|
+
fabrika control apps variables delete --app=<id> --name=<name> [--env=<name>]
|
|
34
38
|
fabrika control register --provider=<name> --app=<id> --repo=<url> --env=<name> --manifest=<path>
|
|
35
39
|
[--domain=<host>] [--public-origin=<url>] [--trigger-ref=<ref>]
|
|
36
40
|
[--namespace=<id>] [--installation-id=<n|none>]
|
|
@@ -360,12 +364,48 @@ const runEnvironments = async (
|
|
|
360
364
|
throw new Error(`Unknown \`control apps environments\` verb: ${verb ?? '(missing)'}`)
|
|
361
365
|
}
|
|
362
366
|
|
|
367
|
+
/**
|
|
368
|
+
* A variable is NOT a secret: its value is stored and read back in clear, so it takes a flag. The one
|
|
369
|
+
* thing an app cannot commit and fabrika cannot infer — an installation's IAM issuer, say — is written
|
|
370
|
+
* here, and the deploy carries it to the service's environment.
|
|
371
|
+
*/
|
|
372
|
+
const runVariables = async (verb: string | undefined, flags: Flags, env: Readonly<Record<string, string | undefined>>): Promise<void> => {
|
|
373
|
+
const client = controlClient(flags, env)
|
|
374
|
+
const appId = required(flags, 'app')
|
|
375
|
+
const scope = optional(flags, 'env')
|
|
376
|
+
if (verb === 'list') {
|
|
377
|
+
const result = await client.apps.variables.list({ appId })
|
|
378
|
+
emit(flags, result, () => result.items.map((item) => `${item.env ?? '*'}\t${item.name}\t${item.value}`).join('\n'))
|
|
379
|
+
return
|
|
380
|
+
}
|
|
381
|
+
if (verb === 'put') {
|
|
382
|
+
const variable: PutAppVarRequest = {
|
|
383
|
+
name: required(flags, 'name'),
|
|
384
|
+
value: required(flags, 'value'),
|
|
385
|
+
...(scope === undefined ? {} : { env: scope }),
|
|
386
|
+
}
|
|
387
|
+
const result = await client.apps.variables.put({ appId, variable })
|
|
388
|
+
emit(flags, result, () => `${result.env ?? '*'}\t${result.name}\t${result.value}`)
|
|
389
|
+
return
|
|
390
|
+
}
|
|
391
|
+
if (verb === 'delete') {
|
|
392
|
+
const result = await client.apps.variables.delete({ appId, name: required(flags, 'name'), ...(scope === undefined ? {} : { env: scope }) })
|
|
393
|
+
emit(flags, result, () => (result.ok ? 'deleted' : 'not deleted'))
|
|
394
|
+
return
|
|
395
|
+
}
|
|
396
|
+
throw new Error(`Unknown \`control apps variables\` verb: ${verb ?? '(missing)'}`)
|
|
397
|
+
}
|
|
398
|
+
|
|
363
399
|
const runApps = async (
|
|
364
400
|
verb: string | undefined,
|
|
365
401
|
flags: Flags,
|
|
366
402
|
provider: string | undefined,
|
|
367
403
|
env: Readonly<Record<string, string | undefined>>,
|
|
368
404
|
): Promise<void> => {
|
|
405
|
+
if (verb === 'variables') {
|
|
406
|
+
await runVariables(flags.positional[1], flags, env)
|
|
407
|
+
return
|
|
408
|
+
}
|
|
369
409
|
if (verb === 'environments') {
|
|
370
410
|
await runEnvironments(flags.positional[1], flags, provider, env)
|
|
371
411
|
return
|