@jondotsoy/envs 0.1.4 → 0.1.5

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 (3) hide show
  1. package/README.md +27 -5
  2. package/envs.js +3 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,30 +6,46 @@ Requires [Bun](https://bun.com) and git.
6
6
 
7
7
  ![Each worktree keeps its own .env; envs edit and envs push sync the shared values across them](docs/assets/images/worktrees-sync.svg)
8
8
 
9
- ## Installation
9
+ ## Quick start
10
+
11
+ Inside your repo (or any of its worktrees), run:
10
12
 
11
13
  ```bash
12
- bun add -g @jondotsoy/envs
14
+ bunx @jondotsoy/envs edit
13
15
  ```
14
16
 
15
- Or without installing:
17
+ No install or setup needed. The first time, `edit` creates `.envs/values.yml` and `.envs/.gitignore` (containing `*`, so git ignores the folder), collects the current `.env` of every worktree into `values.yml`, opens it in VS Code (`code -w`) and, when you close the editor, writes the values back to each worktree's `.env`.
18
+
19
+ To see all commands:
16
20
 
17
21
  ```bash
18
22
  bunx @jondotsoy/envs help
19
23
  ```
20
24
 
25
+ ### Global install (optional)
26
+
27
+ To use the shorter `envs` command, install it globally:
28
+
29
+ ```bash
30
+ bun add -g @jondotsoy/envs
31
+ ```
32
+
33
+ The examples below use `envs`; without a global install, replace it with `bunx @jondotsoy/envs`.
34
+
21
35
  ## Usage
22
36
 
23
37
  Run the commands inside the repo or any of its worktrees. Inside a worktree, `.envs/` always lives in the main repo.
24
38
 
25
39
  | Command | What it does |
26
40
  | --- | --- |
41
+ | `envs edit` | Runs `init` if `.envs/values.yml` does not exist yet, then runs `pull`, opens `values.yml` with `code -w` and, when the editor closes, runs `push`. If the editor fails, it does not `push`. |
27
42
  | `envs init` | Creates `.envs/`, `.envs/.gitignore` (containing `*`) and an empty `.envs/values.yml`. Does not overwrite existing files. |
28
43
  | `envs pull` | Reads the `.env` of the main repo and of each worktree and writes it to `values.yml`. Variables that are no longer in a `.env` are removed from `values.yml` for that worktree. |
29
44
  | `envs push` | Writes `values.yml` to the `.env` of each worktree. Updates existing variables in place, appends new ones at the end, and keeps comments and variables that are not in `values.yml`. |
30
45
  | `envs lint` | Checks security and prints a warning for each problem. Exits with code 1 if there is any (useful in CI). See below. |
31
- | `envs edit` | Runs `pull`, opens `values.yml` with `code -w` and, when the editor closes, runs `push`. If the editor fails, it does not `push`. |
32
- | `envs help` | Shows the help. |
46
+ | `envs help` | Shows the help (also `--help`, `-h`, or no command). |
47
+
48
+ `pull`, `push` and `lint` need `.envs/values.yml` to exist: if it is missing they exit with code 1 and ask you to run `envs init` (or just use `envs edit`, which creates it).
33
49
 
34
50
  Worktrees are identified by their branch name (or their folder name if they are in detached HEAD). The main repo uses its branch name, for example `main`.
35
51
 
@@ -47,6 +63,12 @@ Worktrees are identified by their branch name (or their folder name if they are
47
63
  ↻ LOG_LEVEL=info → main, feature/biz
48
64
  ```
49
65
 
66
+ Values of sensitive variables (`PASSWORD`, `TOKEN`, `SECRET`, `API_KEY`…, or a `KEY` word such as `KEY_FOO` or `FOO_KEY`) are printed as `********`:
67
+
68
+ ```
69
+ ↻ DB_PASSWORD=******** → main
70
+ ```
71
+
50
72
  Colors are disabled when the [`NO_COLOR`](https://no-color.org) environment variable is set to a non-empty value:
51
73
 
52
74
  ```sh
package/envs.js CHANGED
@@ -471,10 +471,12 @@ ${count} warning(s) found.`);
471
471
  return 1;
472
472
  }
473
473
  async function edit(ctx) {
474
+ const valuesPath = join(await findRoot(ctx.cwd), ".envs/values.yml");
475
+ if (!await Bun.file(valuesPath).exists())
476
+ await init(ctx);
474
477
  const pulled = await pull(ctx);
475
478
  if (pulled !== 0)
476
479
  return pulled;
477
- const valuesPath = join(await findRoot(ctx.cwd), ".envs/values.yml");
478
480
  const code = await ctx.openEditor(valuesPath);
479
481
  if (code !== 0)
480
482
  return code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jondotsoy/envs",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Jonathan Delgado",