keytec-ai-cli 0.4.0
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/README.md +120 -0
- package/dist/cli.js +10487 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# keytec-ai
|
|
2
|
+
|
|
3
|
+
One CLI for `.keytec-ai.yml` operations, used by **GitLab CI**, the **DDEV addon**, and the
|
|
4
|
+
`keytec-drupal-deploy` skill — so the logic lives in one tested, versioned place instead of
|
|
5
|
+
being copied into each project.
|
|
6
|
+
|
|
7
|
+
Komodo registry-deploy model: stacks are declared in git as Komodo Resource Sync TOML
|
|
8
|
+
(`komodo/*.toml`, **one stack per branch**) and created by Komodo; `keytec-ai deployer deploy`
|
|
9
|
+
triggers `DeployStack` for the branch's stack and polls until it completes.
|
|
10
|
+
|
|
11
|
+
## Run it
|
|
12
|
+
|
|
13
|
+
Run it with `npx` — a self-contained JS bundle on the public npm registry, no
|
|
14
|
+
install, no `.npmrc`, no auth:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npx keytec-ai-cli config to-env
|
|
18
|
+
npx keytec-ai-cli@0.4.0 deployer deploy develop # pin a version
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
In CI, call it the same way (any node image):
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
# .gitlab-ci.yml in a consumer project
|
|
25
|
+
deploy:
|
|
26
|
+
image: node:22-alpine
|
|
27
|
+
script:
|
|
28
|
+
- npx keytec-ai-cli deployer deploy "$CI_COMMIT_REF_NAME"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
For repeated local use, install once: `npm i -g keytec-ai-cli`, then `keytec-ai …`.
|
|
32
|
+
|
|
33
|
+
## Commands
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
keytec-ai config to-env [--config <path>] [--to-file <path>] Export the config as env vars
|
|
37
|
+
keytec-ai deployer deploy [<branch>] Deploy the branch's Komodo stack
|
|
38
|
+
keytec-ai deployer destroy [<branch>] Tear down the branch's Komodo stack
|
|
39
|
+
keytec-ai deployer provision-secrets Create the per-env secret Komodo Variables
|
|
40
|
+
keytec-ai deployer is-deployed --mr <iid> Is an MR live on its environment?
|
|
41
|
+
keytec-ai deployer release-mrs List the MRs a deploy shipped
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- `config to-env` renders the whole `.keytec-ai.yml` as flat `UPPER_SNAKE` env vars
|
|
45
|
+
(nested keys joined with `_`, arrays comma-joined, empty objects skipped). Writes to
|
|
46
|
+
stdout, or to a file with `--to-file=.env`. The config is located by walking from the
|
|
47
|
+
current directory up to the filesystem root, so it works from any project subdirectory.
|
|
48
|
+
- `deployer deploy` resolves the branch's stack, ensures its secrets exist, triggers
|
|
49
|
+
`DeployStack`, and polls until the on-node deploy completes (fails with Komodo logs on
|
|
50
|
+
error). Stacks are declared in git and created by a Komodo Resource Sync; the CLI never
|
|
51
|
+
creates stacks or sets image tags.
|
|
52
|
+
|
|
53
|
+
## Deploy model
|
|
54
|
+
|
|
55
|
+
Deploy state lives in git as Komodo Resource Sync TOML under `komodo/*.toml` — **not** in
|
|
56
|
+
`.keytec-ai.yml`. Each environment is one `[[stack]]` block keyed by its `branch`; secrets
|
|
57
|
+
are referenced with `[[NAME]]` and provisioned as per-env Komodo Variables.
|
|
58
|
+
|
|
59
|
+
```toml
|
|
60
|
+
# komodo/stacks.toml
|
|
61
|
+
[[stack]]
|
|
62
|
+
name = "lumora-cms-develop"
|
|
63
|
+
[stack.config]
|
|
64
|
+
branch = "develop"
|
|
65
|
+
environment = """
|
|
66
|
+
DB_PASSWORD=[[LUMORA_DEVELOP_DB_PASSWORD]]
|
|
67
|
+
"""
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- one `[[stack]]` per branch — the branch name *is* the environment; 0 or >1 matches errors.
|
|
71
|
+
- `deployer provision-secrets` creates every `[[…]]` secret as a Komodo Variable (idempotent).
|
|
72
|
+
|
|
73
|
+
## deploy env vars
|
|
74
|
+
|
|
75
|
+
- deploy / destroy: `KOMODO_URL`, `KOMODO_API_KEY`, `KOMODO_API_SECRET`
|
|
76
|
+
(+ `CI_COMMIT_REF_NAME` as the default branch in CI).
|
|
77
|
+
- is-deployed / release-mrs: `GITLAB_TOKEN`, `GITLAB_API_URL` (or `CI_API_V4_URL`),
|
|
78
|
+
`GITLAB_PROJECT_ID` (or `CI_PROJECT_ID`), `CI_COMMIT_SHA`.
|
|
79
|
+
|
|
80
|
+
## Develop
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
bun install
|
|
84
|
+
bun test
|
|
85
|
+
bun run dev -- env develop # run from a dir with .keytec-ai.yml
|
|
86
|
+
bun run build # -> ./dist/cli.js (node bundle, what npm publishes)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Releasing
|
|
90
|
+
|
|
91
|
+
**Merge to `1.x` = a new version on npm.** Every push to the `1.x` branch runs
|
|
92
|
+
`publish:npm`, which publishes `package.json` `version` to the public npm registry.
|
|
93
|
+
That's the whole release: nothing to tag, no manual publish step.
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
# 1. work on a feature branch, bump the version, MR into next
|
|
97
|
+
git checkout next && git pull
|
|
98
|
+
git checkout -b feat/my-change
|
|
99
|
+
npm version patch --no-git-tag-version # bump package.json (patch|minor|major)
|
|
100
|
+
# ... commit, push, open MR, merge into next ...
|
|
101
|
+
|
|
102
|
+
# 2. release: merge next into 1.x
|
|
103
|
+
git checkout 1.x && git merge next && git push
|
|
104
|
+
# -> CI publishes keytec-ai-cli@<version> to npm
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The version is the gate: if `package.json` `version` is already on npm,
|
|
108
|
+
`--tolerate-republish` makes the job a no-op, so pushes to `1.x` without a bump
|
|
109
|
+
publish nothing. **Bump `version` in the MR** for the release to actually ship.
|
|
110
|
+
|
|
111
|
+
Under the hood `publish:npm` (on `1.x`) runs `prepublishOnly` to bundle `src` into
|
|
112
|
+
`dist/cli.js`, writes an ephemeral `.npmrc` from the masked `NPM_TOKEN` (never
|
|
113
|
+
committed), and runs `bun publish --access public`. `1.x` is a protected branch so
|
|
114
|
+
the protected `NPM_TOKEN` is exposed there.
|
|
115
|
+
|
|
116
|
+
### CI variables
|
|
117
|
+
|
|
118
|
+
| Variable | Purpose | Flags |
|
|
119
|
+
|----------|---------|-------|
|
|
120
|
+
| `NPM_TOKEN` | npm automation token for `publish:npm` | masked, protected |
|