|
1 | 1 | # envkit |
2 | 2 |
|
3 | | -**envkit** is a CLI that manages local development environments from a single config file. Define dependencies, databases, and services in one place; run one command to set up the project, generate Docker Compose, and optionally snapshot or share configs—without committing secrets. |
| 3 | +Set up your whole local dev environment with one command. Define your dependencies, databases, and services in a single file — then let envkit install everything, spin up Docker, and keep your setup shareable and versioned. Secrets stay in `.env`, never in your config. |
4 | 4 |
|
5 | | -**Requirements:** Node.js >= 16 |
6 | | - |
7 | | ---- |
8 | | - |
9 | | -## What it does |
10 | | - |
11 | | -- **Setup** — Uses your `.dev-env.yml` to install dependencies and run database migrations and seed commands in one go. |
12 | | -- **Generate** — Builds a `docker-compose.yml` from the same config (databases, services, network). |
13 | | -- **Snapshots** — Saves and restores config versions under `.devkit/snapshots/` so you can switch between setups. |
14 | | -- **Share** — Exports a sanitized config (secrets replaced with placeholders) or imports a shared config file into your project. |
15 | | - |
16 | | -Configuration is a single YAML file; secrets live in `.env` and are referenced as `${VAR_NAME}`. The CLI discovers the project root from your current directory (it looks for `.dev-env.yml` or markers like `package.json`). |
17 | | - |
18 | | ---- |
| 5 | +> Requires Node.js 16+ |
19 | 6 |
|
20 | 7 | ## Install |
21 | 8 |
|
22 | 9 | ```bash |
23 | 10 | npm install -g dev-env-kit |
24 | 11 | ``` |
25 | 12 |
|
26 | | -After installation you can use either: |
27 | | - |
28 | | -- **`envkit <command>`** — short name |
29 | | -- **`dev-env-kit <command>`** — same, using the package name |
30 | | - |
31 | | -After install, **path-setup** runs automatically: if you're in an interactive terminal, you may be prompted to add envkit to your PATH so `envkit` works from any folder. You can run it again anytime with `npx dev-env-kit path-setup` or `npx dev-env-kit pathsetup` (no hyphen; use `pathsetup` if your shell doesn't like `path-setup`). |
32 | | - |
33 | | -If the command is still not found, use: |
34 | | - |
35 | | -```bash |
36 | | -npx dev-env-kit <command> |
37 | | -``` |
38 | | - |
39 | | ---- |
40 | | - |
41 | | -## How to use |
42 | | - |
43 | | -### 1. Add a config file |
44 | | - |
45 | | -You need a `.dev-env.yml` in your project root for **setup**, **generate**, **share export**, and **snapshot create**. If you don’t have one yet: |
46 | | - |
47 | | -- **Interactive terminal:** Run `envkit init` to create `.dev-env.yml` via a short wizard. If you run a command that needs config (e.g. `envkit setup`) without a config file, the CLI will ask whether to run `envkit init` now. |
48 | | -- **Non-interactive (CI, scripts):** Create `.dev-env.yml` by hand or run `envkit init` in a terminal first; otherwise those commands exit with a message to create a config or run `envkit init`. |
49 | | - |
50 | | -**If you already have an example file**, the fastest way to start is to copy it and edit it: |
51 | | - |
52 | | -```bash |
53 | | -cp .dev-env.example.yml .dev-env.yml |
54 | | -``` |
55 | | - |
56 | | -The example file documents all options (dependencies, databases, services, env vars, Docker settings). Keep sensitive values in a `.env` file and reference them in the config with `${VAR_NAME}` so they never end up in version control. |
57 | | - |
58 | | -See [.dev-env.example.yml](./.dev-env.example.yml) for the full reference. |
59 | | - |
60 | | -### 2. Set up the environment |
61 | | - |
62 | | -From the project root (or any subdirectory): |
63 | | - |
64 | | -```bash |
65 | | -envkit setup |
66 | | -``` |
67 | | - |
68 | | -This installs dependencies, runs database migrations, and runs seed commands according to your config. You can narrow what runs: |
69 | | - |
70 | | -| Option | Description | |
71 | | -|---------------|--------------------------------------| |
72 | | -| `--skip-deps` | Skip dependency installation | |
73 | | -| `--skip-db` | Skip database migrations and seed | |
74 | | -| `--dry-run` | Show what would run, without running | |
75 | | - |
76 | | -### 3. Validate your config |
77 | | - |
78 | | -Check that `.dev-env.yml` (and any `.env`) is well-formed without running setup or generate — handy for CI and pre-commit hooks: |
79 | | - |
80 | | -```bash |
81 | | -envkit validate |
82 | | -``` |
83 | | - |
84 | | -It exits non-zero on a missing or invalid config. Add `--strict` to also fail on warnings (e.g. hardcoded passwords, port conflicts) and unresolved `${VAR}` references: |
85 | | - |
86 | | -```bash |
87 | | -envkit validate --strict |
88 | | -``` |
89 | | - |
90 | | -### 4. Generate Docker Compose |
91 | | - |
92 | | -When `docker.enabled` is set in your config, you can generate a Compose file from it: |
93 | | - |
94 | | -```bash |
95 | | -envkit generate |
96 | | -``` |
97 | | - |
98 | | -Output goes to `docker-compose.yml` by default. Use `-o <file>` to write elsewhere, e.g. `envkit generate -o docker-compose.dev.yml`. To preview the generated Compose without writing a file (e.g. to pipe or inspect it), use `--dry-run`: |
99 | | - |
100 | | -```bash |
101 | | -envkit generate --dry-run |
102 | | -``` |
103 | | - |
104 | | -### 5. Snapshots |
105 | | - |
106 | | -Save the current config as a named snapshot under `.devkit/snapshots/`: |
107 | | - |
108 | | -```bash |
109 | | -envkit snapshot create [name] |
110 | | -``` |
111 | | - |
112 | | -If you omit the name, a timestamp-based name is used. List existing snapshots: |
113 | | - |
114 | | -```bash |
115 | | -envkit snapshot list |
116 | | -``` |
| 13 | +This gives you the `envkit` command (also available as `dev-env-kit`). If your shell can't find it afterward, run `envkit path-setup` once. |
117 | 14 |
|
118 | | -Restore a snapshot. This overwrites `.dev-env.yml`, but your current config is automatically backed up to a `pre-restore-<timestamp>` snapshot first, and you'll be asked to confirm in an interactive terminal (use `--yes` to skip the prompt in scripts): |
| 15 | +## Quick start |
119 | 16 |
|
120 | 17 | ```bash |
121 | | -envkit snapshot restore <name> |
| 18 | +envkit init # answer a few questions to create .dev-env.yml |
| 19 | +envkit setup # install dependencies + run migrations/seeds |
| 20 | +envkit generate # create docker-compose.yml from your config |
122 | 21 | ``` |
123 | 22 |
|
124 | | -Delete a snapshot you no longer need: |
| 23 | +That's the whole loop. Run any command from your project root or any subfolder — envkit finds the project automatically. |
125 | 24 |
|
126 | | -```bash |
127 | | -envkit snapshot delete <name> |
128 | | -``` |
| 25 | +## Commands |
129 | 26 |
|
130 | | -### 6. Share config (export / import) |
| 27 | +| Command | What it does | |
| 28 | +|---------|--------------| |
| 29 | +| `envkit init` | Create your `.dev-env.yml` with a short interactive wizard. | |
| 30 | +| `envkit setup` | Install dependencies and run database migrations + seeds. Skip parts with `--skip-deps`, `--skip-db`, or preview with `--dry-run`. | |
| 31 | +| `envkit validate` | Check your config is valid — great for CI. Use `--strict` to also fail on warnings. | |
| 32 | +| `envkit generate` | Build a `docker-compose.yml` from your config. `--dry-run` prints it instead of writing. | |
| 33 | +| `envkit snapshot create/list/restore/delete` | Save and switch between config versions. Restoring backs up your current config first. | |
| 34 | +| `envkit share export` / `import` | Share your setup with teammates — secrets are swapped for placeholders on export. | |
131 | 35 |
|
132 | | -Export a safe-to-share copy of your config (passwords and secrets become placeholders like `${DB_PASSWORD}`): |
| 36 | +Add `-v` for more detail or `-q` for less. Run `envkit <command> --help` anytime. |
133 | 37 |
|
134 | | -```bash |
135 | | -envkit share export |
136 | | -``` |
| 38 | +## Configuration |
137 | 39 |
|
138 | | -By default this writes `dev-env.shared.yml`. Use `-o <file>` to change the path. |
| 40 | +Everything lives in one `.dev-env.yml` at your project root. Keep secrets in a `.env` file and reference them with `${VAR_NAME}`: |
139 | 41 |
|
140 | | -Import a shared config file (it is validated and then written to `.dev-env.yml` by default). The `<file>` path is resolved relative to your **current working directory**: |
| 42 | +```yaml |
| 43 | +name: my-app |
141 | 44 |
|
142 | | -```bash |
143 | | -envkit share import path/to/dev-env.shared.yml |
144 | | -``` |
| 45 | +dependencies: |
| 46 | + - type: npm |
| 47 | + command: npm install |
145 | 48 |
|
146 | | -Use `-o <file>` to write to a different path (also relative to the current directory unless you pass an absolute path). To check a shared file is valid without writing anything (useful in CI), pass `--validate-only`: |
| 49 | +databases: |
| 50 | + - type: postgresql |
| 51 | + port: 5432 |
| 52 | + user: ${DB_USER} |
| 53 | + password: ${DB_PASSWORD} |
| 54 | + database: myapp |
147 | 55 |
|
148 | | -```bash |
149 | | -envkit share import path/to/dev-env.shared.yml --validate-only |
| 56 | +docker: |
| 57 | + enabled: true |
150 | 58 | ``` |
151 | 59 |
|
152 | | -### Global options |
| 60 | +See [.dev-env.example.yml](./.dev-env.example.yml) for every available option. Don't have a config yet? Just run `envkit init` — or if you run `envkit setup` without one, it'll offer to create it for you. |
153 | 61 |
|
154 | | -- **`-v, --verbose`** — More detailed log output. |
155 | | -- **`-q, --quiet`** — Reduce output. |
156 | | - |
157 | | -Example: `envkit -q setup` |
158 | | - |
159 | | ---- |
160 | | - |
161 | | -## Command reference |
162 | | - |
163 | | -| Command | Description | |
164 | | -|--------|-------------| |
165 | | -| `envkit init` | Create `.dev-env.yml` interactively (wizard). Run from a project folder when you don’t have a config yet. | |
166 | | -| `envkit setup` | Install dependencies, run database migrations, and run seed commands from your config. Use `--skip-deps`, `--skip-db`, or `--dry-run` to limit what runs. | |
167 | | -| `envkit validate` | Validate `.dev-env.yml` (and `.env`) without running setup or generate. Add `--strict` to fail on warnings and unresolved `${VAR}` references. CI/pre-commit friendly. | |
168 | | -| `envkit generate` | Generate `docker-compose.yml` from your config (requires `docker.enabled` in config). Use `-o <file>` to set the output path, or `--dry-run` to print without writing. | |
169 | | -| `envkit snapshot create [name]` | Save the current `.dev-env.yml` as a snapshot under `.devkit/snapshots/`. Omit `name` to use a timestamp. | |
170 | | -| `envkit snapshot list` | List all saved snapshots. | |
171 | | -| `envkit snapshot restore <name>` | Restore a snapshot; overwrites `.dev-env.yml` (current config is backed up first). Use `--yes` to skip the confirmation prompt. | |
172 | | -| `envkit snapshot delete <name>` | Delete a saved snapshot. | |
173 | | -| `envkit share export` | Export a sanitized config (secrets → placeholders) to share safely. Default output: `dev-env.shared.yml`; use `-o <file>` to override. | |
174 | | -| `envkit share import <file>` | Import a shared config file; writes to `.dev-env.yml` by default. Use `-o <file>` to write elsewhere, or `--validate-only` to validate without writing. | |
175 | | -| `envkit path-setup` or `envkit pathsetup` | Add the npm global bin folder to your PATH so `envkit` works from any directory. Use if the shell says “envkit” is not recognized after a global install. | |
176 | | - |
177 | | -For more detail: `envkit --help` or `envkit <command> --help`. |
178 | | ---- |
179 | | - |
180 | | -## Development and testing |
181 | | - |
182 | | -To work on the source or run tests: |
| 62 | +## Contributing |
183 | 63 |
|
184 | 64 | ```bash |
185 | 65 | npm install |
186 | 66 | npm test |
187 | 67 | ``` |
188 | 68 |
|
189 | | -Use `npm test -- --coverage` for a coverage report. |
190 | | - |
191 | | ---- |
192 | | - |
193 | 69 | ## License |
194 | 70 |
|
195 | 71 | MIT |
0 commit comments