@localctl/cli 0.5.0-beta.2 โ†’ 0.5.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.
Files changed (45) hide show
  1. package/README.md +32 -76
  2. package/package.json +3 -10
  3. package/schema/app.schema.json +678 -44
  4. package/src/commands/doctor.js +1 -16
  5. package/src/commands/down.js +3 -1
  6. package/src/commands/generateManifests.js +4 -0
  7. package/src/commands/logs.js +1 -0
  8. package/src/commands/new.js +42 -20
  9. package/src/commands/prune.js +4 -0
  10. package/src/commands/reload.js +11 -3
  11. package/src/commands/secrets.js +3 -3
  12. package/src/commands/setup.js +1 -11
  13. package/src/commands/tiltConfig.js +11 -0
  14. package/src/commands/uninstall.js +5 -6
  15. package/src/commands/up.js +9 -1
  16. package/src/commands/validate.js +48 -0
  17. package/src/index.js +2 -0
  18. package/src/lib/addonDirs.js +1 -2
  19. package/src/lib/addonLoader.js +38 -17
  20. package/src/lib/addons/mongo/addon.yaml +2 -0
  21. package/src/lib/addons/postgres/addon.yaml +5 -1
  22. package/src/lib/addons/redis/addon.yaml +2 -0
  23. package/src/lib/appSecrets.js +107 -36
  24. package/src/lib/clusterProvision.js +45 -211
  25. package/src/lib/configSchema.js +412 -41
  26. package/src/lib/engine.js +3 -13
  27. package/src/lib/envFile.js +58 -0
  28. package/src/lib/exec.js +6 -7
  29. package/src/lib/hostGuard.js +107 -0
  30. package/src/lib/hostsFile.js +9 -8
  31. package/src/lib/kubeErrors.js +22 -0
  32. package/src/lib/loadConfig.js +183 -9
  33. package/src/lib/manifestGen.js +96 -32
  34. package/src/lib/namespaces.js +83 -0
  35. package/src/lib/pathGuard.js +79 -0
  36. package/src/lib/paths.js +2 -6
  37. package/src/lib/podman.js +3 -93
  38. package/src/lib/projectContext.js +2 -2
  39. package/src/lib/quantities.js +20 -0
  40. package/src/lib/safeRead.js +41 -0
  41. package/src/lib/tiltConfig.js +25 -0
  42. package/src/lib/toolInstall.js +2 -141
  43. package/src/lib/yamlLoad.js +48 -0
  44. package/templates/Tiltfile.tmpl +22 -14
  45. package/src/lib/linuxDistro.js +0 -122
package/README.md CHANGED
@@ -62,7 +62,7 @@ JSON file per app.
62
62
  | ๐Ÿงฉ **One cluster, one CLI** | A single [k3d](https://k3d.io) cluster runs every app you develop. No per-project Kubernetes setup. |
63
63
  | ๐ŸŒ **A subdomain per app** | `orders.local.test`, `billing.local.test`, routed by Traefik. No `localhost:3000` vs `:3001`. |
64
64
  | ๐Ÿ”’ **HTTPS by default** | A locally-trusted wildcard certificate (via [mkcert](https://github.com/FiloSottile/mkcert)). Green padlock, no browser warnings. |
65
- | ๐Ÿ“„ **Config, not YAML** | Each app has one `.local/config.json`. Every Kubernetes manifest is generated from it. |
65
+ | ๐Ÿ“„ **Config, not manifests** | Each app has one `.local/config.yaml`. Every Kubernetes manifest is generated from it. |
66
66
  | โšก **Fast inner loop** | [Tilt](https://tilt.dev) builds, deploys, and live-syncs changed files into the running container. |
67
67
  | ๐Ÿž **Debugger-friendly** | Debug ports forwarded to `localhost`. Node, Python, Go, Java and .NET patterns included. |
68
68
  | ๐Ÿ—„๏ธ **Databases in one line** | Postgres, Redis and MongoDB per app, from real Helm charts, with credentials injected as Secrets. |
@@ -73,15 +73,14 @@ JSON file per app.
73
73
 
74
74
  | Requirement | Notes |
75
75
  |---|---|
76
- | **macOS**, **Windows** or **Linux** | Windows commands run in PowerShell. Linux support is [experimental](#linux-experimental). |
76
+ | **macOS** or **Windows** | Windows commands run in PowerShell. |
77
77
  | **Node.js 18+** | Needed to install the CLI from npm. |
78
78
  | **Container engine** | [Podman Desktop](https://podman-desktop.io/) (or Docker Desktop / Rancher Desktop), running. See [supported container engines](#supported-container-engines). |
79
- | **Homebrew** (macOS) or **winget** (Windows) | Used once by `localctl setup` to install missing tools. Linux needs only `curl`. |
79
+ | **Homebrew** or **winget** | Used once by `localctl setup` to install missing tools. |
80
80
 
81
81
  `localctl setup` installs `k3d`, `kubectl`, `tilt`, `mkcert` and `helm` for you if they're missing.
82
82
  On Windows, Tilt isn't on winget, so it's downloaded from its GitHub release into
83
- `~\.localctl\tools` and added to your user PATH. On Linux, all five tools are downloaded as
84
- official release binaries into `~/.localctl/tools` (no sudo, no distro packages).
83
+ `~.localctl ools` and added to your user PATH.
85
84
 
86
85
  ### Supported container engines
87
86
 
@@ -90,63 +89,12 @@ official release binaries into `~/.localctl/tools` (no sudo, no distro packages)
90
89
  | [Podman Desktop](https://podman-desktop.io/) | โœ… Tested |
91
90
  | [Docker Desktop](https://www.docker.com/products/docker-desktop/) | ๐Ÿงช Experimental โ€” setup and app deploy verified on Windows |
92
91
  | [Rancher Desktop](https://rancherdesktop.io/) | ๐Ÿงช Experimental โ€” not yet tested |
93
- | Docker Engine / native Podman (Linux) | ๐Ÿงช Experimental โ€” see [Linux](#linux-experimental) |
94
92
 
95
93
  Experimental engines are detected and should work, since k3d only needs a Docker-compatible API,
96
94
  but they haven't been through a full test cycle yet. `localctl setup` and `localctl doctor` print
97
95
  a warning when one is in use. If you try one, please
98
96
  [report how it went](https://github.com/psilvmoreira/localctl/issues/new).
99
97
 
100
- ### Required tools
101
-
102
- What has to be on your machine **before** `localctl setup`, and what `setup` installs for you:
103
-
104
- | | You install | `localctl setup` installs |
105
- |---|---|---|
106
- | **All platforms** | **Node.js 18+** (to install and run the CLI), a **container engine** | `k3d`, `kubectl`, `tilt`, `mkcert`, `helm` |
107
- | **macOS** | [Homebrew](https://brew.sh) | via `brew` (plus `nss` for Firefox, optional) |
108
- | **Windows** | `winget` (ships with Windows) | via `winget`, Tilt from its GitHub release |
109
- | **Linux** | `curl` and `tar`, `sudo` (hosts file, CA trust) | downloaded as release binaries into `~/.localctl/tools` |
110
-
111
- `localctl setup` needs administrator rights once, for the `*.local.test` hosts entry and the local
112
- CA trust.
113
-
114
- ### Linux (experimental)
115
-
116
- Linux support is **experimental**: it hasn't been through a full test cycle (CI only runs the
117
- smoke tests there), and `setup`/`doctor` print a warning. It's published on the `beta` dist-tag:
118
-
119
- ```sh
120
- npm install -g @localctl/cli@beta
121
- ```
122
-
123
- Targeted distributions, all with systemd and a mkcert-supported trust store:
124
-
125
- | Family | Distributions | Docker Engine install |
126
- |---|---|---|
127
- | Debian | Ubuntu, Debian, Linux Mint, Pop!_OS | `localctl setup --install-docker` (Docker's official script) |
128
- | Red Hat | Fedora, RHEL, Rocky, AlmaLinux, CentOS Stream | `localctl setup --install-docker` (Docker's official script) |
129
- | Arch | Arch, Manjaro, EndeavourOS | `localctl setup --install-docker` (`pacman`) |
130
- | SUSE | openSUSE Leap/Tumbleweed | `localctl setup --install-docker` (`zypper`) |
131
-
132
- Other distributions (Alpine, Void, Gentoo, NixOS, immutable/atomic desktops) may work if you
133
- bring Docker (or Podman) and Node.js yourself, but aren't targeted. WSL needs the Windows hosts
134
- file edited too.
135
-
136
- What's different on Linux:
137
-
138
- - **Docker Engine** is the recommended engine (root daemon, nothing else to configure). If none is
139
- running, `localctl setup --install-docker` installs it for the families above. It needs `sudo`,
140
- and you must **log out and back in** afterwards so your user joins the `docker` group.
141
- - **Podman** runs natively, no VM. The insecure-registry entry goes in
142
- `~/.config/containers/registries.conf.d/` (no sudo, no restart). k3d needs Podman's API socket:
143
- `systemctl --user enable --now podman.socket`. Rootless Podman also can't bind :80/:443 by
144
- default: `sudo sysctl net.ipv4.ip_unprivileged_port_start=80`.
145
- - **Firefox/Chromium trust** needs `certutil` (`libnss3-tools` on Debian/Ubuntu, `nss-tools` on
146
- Fedora). `setup` prints the command for your distro; install it and re-run `mkcert -install`.
147
-
148
- Hit a problem? [Open an issue](https://github.com/psilvmoreira/localctl/issues/new).
149
-
150
98
  ## Installation
151
99
 
152
100
  ```sh
@@ -225,7 +173,7 @@ self-contained shim in `~/.localctl/bin` and run `localctl setup` for you:
225
173
  localctl app new
226
174
  ```
227
175
 
228
- This asks for an app name and port, then creates `.local/config.json` and a `Tiltfile`.
176
+ This asks for an app name and port, then creates `.local/config.yaml` and a `Tiltfile`.
229
177
 
230
178
  **2. Deploy:**
231
179
 
@@ -298,7 +246,7 @@ Run `localctl <command> --help` for every option, or see the full
298
246
 
299
247
  | Command | Description |
300
248
  |---|---|
301
- | `localctl app new` | Scaffold `.local/config.json` and a `Tiltfile` in the current repository. |
249
+ | `localctl app new` | Scaffold `.local/config.yaml` and a `Tiltfile` in the current repository. |
302
250
  | `localctl app up [-f]` | Build, deploy and live-reload the app. Background by default; `-f` for the Tilt UI. |
303
251
  | `localctl app down` | Stop the dev loop and remove the app. Keeps its data. |
304
252
  | `localctl app reload [-a <name>]` | Force a rebuild and redeploy without waiting for a file change. |
@@ -306,7 +254,7 @@ Run `localctl <command> --help` for every option, or see the full
306
254
  | `localctl app logs [name] [-f]` | Show or follow an app's logs. Inside its repository the name is optional. |
307
255
  | `localctl app exec [cmd...]` | Open a shell (default `sh`) in the app's pod. |
308
256
  | `localctl app prune [-y]` | Delete leftover data (volumes, secrets) of apps already taken down. |
309
- | `localctl app secrets set <KEY> [value]` | Store a secret as a Kubernetes Secret, never in `config.json`. |
257
+ | `localctl app secrets set <KEY> [value]` | Store a secret as a Kubernetes Secret, never in `config.yaml`. |
310
258
  | `localctl app secrets list` / `show [KEY]` / `unset <KEY>` | List, reveal or remove secrets. |
311
259
 
312
260
  </details>
@@ -326,20 +274,28 @@ Run `localctl <command> --help` for every option, or see the full
326
274
 
327
275
  ## Configuration
328
276
 
329
- Everything about how an app runs locally lives in its `.local/config.json`:
330
-
331
- ```json
332
- {
333
- "name": "orders-api",
334
- "subdomain": "orders",
335
- "port": 3000,
336
- "build": { "context": ".", "dockerfile": "Dockerfile" },
337
- "env": { "NODE_ENV": "development" },
338
- "debug": { "enabled": true, "port": 9229, "type": "node" },
339
- "dependencies": [{ "type": "postgres", "database": "orders" }],
340
- "sync": [{ "localPath": "./src", "remotePath": "/app/src" }],
341
- "tls": true
342
- }
277
+ Everything about how an app runs locally lives in its `.local/config.yaml`:
278
+
279
+ ```yaml
280
+ name: orders-api
281
+ subdomain: orders
282
+ port: 3000
283
+ build:
284
+ context: .
285
+ dockerfile: Dockerfile
286
+ env:
287
+ NODE_ENV: development
288
+ debug:
289
+ enabled: true
290
+ port: 9229
291
+ type: node
292
+ dependencies:
293
+ - type: postgres
294
+ database: orders
295
+ sync:
296
+ - localPath: ./src
297
+ remotePath: /app/src
298
+ tls: true
343
299
  ```
344
300
 
345
301
  This deploys `orders-api` at `https://orders.local.test`, with its own Postgres instance and the
@@ -368,7 +324,7 @@ To add your own addon, see [**Adding tools**](https://psilvmoreira.github.io/loc
368
324
  ## How it works
369
325
 
370
326
  ```
371
- .local/config.json โ”€โ”€โ–บ localctl โ”€โ”€โ–บ Kubernetes manifests โ”€โ”€โ–บ Tilt โ”€โ”€โ–บ k3d cluster
327
+ .local/config.yaml โ”€โ”€โ–บ localctl โ”€โ”€โ–บ Kubernetes manifests โ”€โ”€โ–บ Tilt โ”€โ”€โ–บ k3d cluster
372
328
  (your app repo) validates (generated, never builds, Traefik ingress
373
329
  + generates hand-written) pushes, + local registry
374
330
  live-syncs + *.local.test TLS
@@ -387,7 +343,7 @@ The full documentation lives at **[psilvmoreira.github.io/localctl](https://psil
387
343
  | [Getting started](https://psilvmoreira.github.io/localctl/getting-started/) | Install and first deploy, step by step |
388
344
  | [Architecture](https://psilvmoreira.github.io/localctl/architecture/) | Every component, why it was chosen, multi-project support |
389
345
  | [CLI commands](https://psilvmoreira.github.io/localctl/cli-reference/) | Every command and option |
390
- | [Config schema](https://psilvmoreira.github.io/localctl/config-schema/) | Every `.local/config.json` field |
346
+ | [Config schema](https://psilvmoreira.github.io/localctl/config-schema/) | Every `.local/config.yaml` field |
391
347
  | [Debugging](https://psilvmoreira.github.io/localctl/debugging/) | Attach a debugger in Node, Python, Go, Java and .NET |
392
348
  | [Adding tools](https://psilvmoreira.github.io/localctl/adding-tools/) | Write your own per-app or cluster-wide addon |
393
349
  | [Troubleshooting](https://psilvmoreira.github.io/localctl/troubleshooting/) | Known issues, with cause and fix |
@@ -452,7 +408,7 @@ localctl/
452
408
  โ”‚ โ”œโ”€โ”€ templates/ Tiltfile copied into apps by `localctl app new`
453
409
  โ”‚ โ””โ”€โ”€ scripts/ packaging and test scripts
454
410
  โ”œโ”€โ”€ cluster/manifests/ cluster-level manifests (TLS store, addon namespace)
455
- โ”œโ”€โ”€ schema/ JSON Schema for .local/config.json
411
+ โ”œโ”€โ”€ schema/ JSON Schema for .local/config.yaml
456
412
  โ”œโ”€โ”€ examples/ ready-to-run sample apps
457
413
  โ”œโ”€โ”€ docs/ documentation pages (MkDocs Material, deployed to GitHub Pages)
458
414
  โ”œโ”€โ”€ overrides/ docs site template overrides (landing page)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localctl/cli",
3
- "version": "0.5.0-beta.2",
3
+ "version": "0.5.0",
4
4
  "description": "localctl - local Kubernetes dev platform CLI",
5
5
  "keywords": [
6
6
  "kubernetes",
@@ -35,10 +35,8 @@
35
35
  "scripts": {
36
36
  "sync-assets": "node scripts/sync-assets.js",
37
37
  "prepack": "node scripts/sync-assets.js",
38
- "test": "node scripts/smoke-test.js",
39
- "test:pack": "node scripts/pack-test.js",
40
- "test:e2e": "node scripts/e2e/run.js",
41
- "test:e2e:distros": "node scripts/e2e/distros.js"
38
+ "test": "node scripts/smoke-test.js && node scripts/schema-check.js && node --test test/config.test.js",
39
+ "test:pack": "node scripts/pack-test.js"
42
40
  },
43
41
  "dependencies": {
44
42
  "chalk": "^4.1.2",
@@ -50,11 +48,6 @@
50
48
  "node": ">=18"
51
49
  },
52
50
  "localctl": {
53
- "platforms": {
54
- "darwin": "tested",
55
- "win32": "tested",
56
- "linux": "experimental"
57
- },
58
51
  "containerEngines": {
59
52
  "podman": "tested",
60
53
  "docker": "experimental",