@fabrika/cli 0.0.13 → 0.0.14
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 +65 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
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.14",
|
|
33
|
+
"@fabrika/auth-core": "^0.0.14",
|
|
34
|
+
"@fabrika/control-contract": "^0.0.14",
|
|
35
|
+
"@fabrika/installation-cloudflare": "^0.0.14",
|
|
36
|
+
"@fabrika/installation-contract": "^0.0.14",
|
|
37
|
+
"@fabrika/installation-zerops": "^0.0.14",
|
|
38
|
+
"@fabrika/provider-cloudflare": "^0.0.14",
|
|
39
|
+
"@fabrika/provider-contract": "^0.0.14",
|
|
40
|
+
"@fabrika/provider-zerops": "^0.0.14"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/control.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
DeploymentNamespaceDto,
|
|
18
18
|
JsonValue,
|
|
19
19
|
PlanDeploymentNamespaceRequest,
|
|
20
|
+
PutAppEnvRequest,
|
|
20
21
|
RegisterAppRequest,
|
|
21
22
|
RunDto,
|
|
22
23
|
} from '@fabrika/control-contract'
|
|
@@ -27,6 +28,9 @@ Usage:
|
|
|
27
28
|
fabrika control key issue --label=<name> --permissions=<a,b,c> [--expires-in=<seconds>]
|
|
28
29
|
fabrika control apps list
|
|
29
30
|
fabrika control apps get --app=<id>
|
|
31
|
+
fabrika control apps environments list --app=<id>
|
|
32
|
+
fabrika control apps environments put --provider=<name> --app=<id> --env=<name> --manifest=<path>
|
|
33
|
+
[--domain=<host>] [--public-origin=<url>] [--trigger-ref=<ref>] [--namespace=<id>]
|
|
30
34
|
fabrika control register --provider=<name> --app=<id> --repo=<url> --env=<name> --manifest=<path>
|
|
31
35
|
[--domain=<host>] [--public-origin=<url>] [--trigger-ref=<ref>]
|
|
32
36
|
[--namespace=<id>] [--installation-id=<n|none>]
|
|
@@ -39,6 +43,10 @@ Usage:
|
|
|
39
43
|
fabrika control runs get --run=<id>
|
|
40
44
|
fabrika control runs log --run=<id>
|
|
41
45
|
|
|
46
|
+
\`register\` CREATES an app and refuses a second one with the same id. Re-registering a changed
|
|
47
|
+
manifest — a new \`zerops.yaml\`, a new import document — is \`apps environments put\`, which replaces
|
|
48
|
+
one environment's envelopes and leaves the app row alone.
|
|
49
|
+
|
|
42
50
|
\`--installation-id\` has three states: omitted resolves the installation from the organization's
|
|
43
51
|
connected GitHub App, \`none\` registers an anonymous PUBLIC repository source, and a number names one
|
|
44
52
|
installation outright.
|
|
@@ -306,7 +314,62 @@ const runRegister = async (flags: Flags, provider: string | undefined, env: Read
|
|
|
306
314
|
emit(flags, result, () => `${result.app.id}\t${result.env.env}\t${result.env.provider}`)
|
|
307
315
|
}
|
|
308
316
|
|
|
309
|
-
|
|
317
|
+
/**
|
|
318
|
+
* `apps environments put` is how a REGISTERED app takes a changed manifest — `register` creates and
|
|
319
|
+
* refuses a second app with the same id, so it cannot serve a redeploy of a moved descriptor.
|
|
320
|
+
*
|
|
321
|
+
* It replaces the whole environment record, so every optional placement flag left out is cleared. That
|
|
322
|
+
* is the procedure's own semantics, shared with the console, not a choice made here.
|
|
323
|
+
*/
|
|
324
|
+
const runEnvironments = async (
|
|
325
|
+
verb: string | undefined,
|
|
326
|
+
flags: Flags,
|
|
327
|
+
provider: string | undefined,
|
|
328
|
+
env: Readonly<Record<string, string | undefined>>,
|
|
329
|
+
): Promise<void> => {
|
|
330
|
+
const client = controlClient(flags, env)
|
|
331
|
+
if (verb === 'list') {
|
|
332
|
+
const result = await client.apps.environments.list({ appId: required(flags, 'app') })
|
|
333
|
+
emit(flags, result, () => result.items.map((item) => `${item.appId}\t${item.env}\t${item.provider}\t${item.domain ?? '-'}`).join('\n'))
|
|
334
|
+
return
|
|
335
|
+
}
|
|
336
|
+
if (verb === 'put') {
|
|
337
|
+
if (provider === undefined || provider === '') {
|
|
338
|
+
throw new Error('--provider=<name> is required: it labels the envelope this environment carries.')
|
|
339
|
+
}
|
|
340
|
+
const manifestPath = required(flags, 'manifest')
|
|
341
|
+
const manifest = await readJsonFile(manifestPath)
|
|
342
|
+
const version = manifestVersion(manifest, manifestPath)
|
|
343
|
+
const domain = optional(flags, 'domain')
|
|
344
|
+
const publicOrigin = optional(flags, 'public-origin')
|
|
345
|
+
const triggerRef = optional(flags, 'trigger-ref')
|
|
346
|
+
const namespaceId = optional(flags, 'namespace')
|
|
347
|
+
const environment: PutAppEnvRequest = {
|
|
348
|
+
// The same empty placeholder `register` sends: the target is DISCOVERED from the manifest.
|
|
349
|
+
target: { provider, version, payload: {} },
|
|
350
|
+
artifact: { provider, version, payload: manifest },
|
|
351
|
+
...(domain === undefined ? {} : { domain }),
|
|
352
|
+
...(publicOrigin === undefined ? {} : { publicOrigin }),
|
|
353
|
+
...(triggerRef === undefined ? {} : { triggerRef }),
|
|
354
|
+
...(namespaceId === undefined ? {} : { namespaceId }),
|
|
355
|
+
}
|
|
356
|
+
const result = await client.apps.environments.put({ appId: required(flags, 'app'), env: required(flags, 'env'), environment })
|
|
357
|
+
emit(flags, result, () => `${result.appId}\t${result.env}\t${result.provider}`)
|
|
358
|
+
return
|
|
359
|
+
}
|
|
360
|
+
throw new Error(`Unknown \`control apps environments\` verb: ${verb ?? '(missing)'}`)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const runApps = async (
|
|
364
|
+
verb: string | undefined,
|
|
365
|
+
flags: Flags,
|
|
366
|
+
provider: string | undefined,
|
|
367
|
+
env: Readonly<Record<string, string | undefined>>,
|
|
368
|
+
): Promise<void> => {
|
|
369
|
+
if (verb === 'environments') {
|
|
370
|
+
await runEnvironments(flags.positional[1], flags, provider, env)
|
|
371
|
+
return
|
|
372
|
+
}
|
|
310
373
|
const client = controlClient(flags, env)
|
|
311
374
|
if (verb === 'list') {
|
|
312
375
|
const result = await client.apps.list()
|
|
@@ -438,7 +501,7 @@ export const runControlCli = async (
|
|
|
438
501
|
await runKeyIssue(flags, env)
|
|
439
502
|
return
|
|
440
503
|
case 'apps':
|
|
441
|
-
await runApps(verb, flags, env)
|
|
504
|
+
await runApps(verb, flags, provider, env)
|
|
442
505
|
return
|
|
443
506
|
case 'runs':
|
|
444
507
|
await runRuns(verb, flags, env)
|