@jondotsoy/envs 0.1.1 → 0.1.3

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 +48 -46
  2. package/SECURITY.md +29 -29
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,53 +1,55 @@
1
1
  # @jondotsoy/envs
2
2
 
3
- CLI para mantener en un solo archivo (`.envs/values.yml`) los valores del `.env` de cada worktree de git. Edita todos los valores juntos y distribúyelos a cada worktree, o recógelos desde los `.env` existentes.
3
+ CLI that keeps the `.env` values of every git worktree in a single file (`.envs/values.yml`). Edit all values together and distribute them to each worktree, or collect them from the existing `.env` files.
4
4
 
5
- Requiere [Bun](https://bun.com) y git.
5
+ Requires [Bun](https://bun.com) and git.
6
6
 
7
- ## Instalación
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
+
9
+ ## Installation
8
10
 
9
11
  ```bash
10
12
  bun add -g @jondotsoy/envs
11
13
  ```
12
14
 
13
- O sin instalar:
15
+ Or without installing:
14
16
 
15
17
  ```bash
16
18
  bunx @jondotsoy/envs help
17
19
  ```
18
20
 
19
- ## Uso
21
+ ## Usage
20
22
 
21
- Ejecuta los comandos dentro del repo o de cualquiera de sus worktrees. Dentro de un worktree, `.envs/` siempre vive en el repo principal.
23
+ Run the commands inside the repo or any of its worktrees. Inside a worktree, `.envs/` always lives in the main repo.
22
24
 
23
- | Comando | Qué hace |
25
+ | Command | What it does |
24
26
  | --- | --- |
25
- | `envs init` | Crea `.envs/`, `.envs/.gitignore` (con `*`) y un `.envs/values.yml` vacío. No sobrescribe archivos existentes. |
26
- | `envs pull` | Lee el `.env` del repo principal y de cada worktree y lo escribe en `values.yml`. Las variables que ya no están en un `.env` se quitan de `values.yml` para ese worktree. |
27
- | `envs push` | Escribe `values.yml` en el `.env` de cada worktree. Actualiza las variables existentes en su línea, agrega las nuevas al final y conserva comentarios y variables que no están en `values.yml`. |
28
- | `envs lint` | Revisa la seguridad y muestra un warning por cada problema. Termina con código 1 si hay alguno (útil en CI). Ver abajo. |
29
- | `envs edit` | Ejecuta `pull`, abre `values.yml` con `code -w` y, al cerrar el editor, ejecuta `push`. Si el editor falla, no hace `push`. |
30
- | `envs help` | Muestra la ayuda. |
27
+ | `envs init` | Creates `.envs/`, `.envs/.gitignore` (containing `*`) and an empty `.envs/values.yml`. Does not overwrite existing files. |
28
+ | `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
+ | `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
+ | `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. |
31
33
 
32
- Los worktrees se identifican por el nombre de su rama (o el nombre de su carpeta si están en HEAD desacoplado). El repo principal usa el nombre de su rama, por ejemplo `main`.
34
+ 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`.
33
35
 
34
36
  ### `envs lint`
35
37
 
36
- Nunca imprime los valores, solo la variable y su ubicación (`envs.DB_PASSWORD.main`).
38
+ It never prints values, only the variable and its location (`envs.DB_PASSWORD.main`).
37
39
 
38
- | Regla | Detecta |
40
+ | Rule | Detects |
39
41
  | --- | --- |
40
- | `tracked-values`, `unignored-values` | `values.yml` está versionado en git o no está ignorado. |
41
- | `tracked-dotenv`, `unignored-dotenv` | El `.env` de un worktree está versionado o no está ignorado. |
42
- | `open-permissions` | `values.yml` es legible por otros usuarios (usa `chmod 600`). |
43
- | `executable-files` | `values.yml` o un `.env` tiene permiso de ejecución (usa `chmod -x`). |
44
- | `writable-files` | `values.yml` o un `.env` es escribible por el grupo u otros usuarios (usa `chmod go-w`). |
45
- | `weak-secret` | Variable sensible (`PASSWORD`, `TOKEN`, `SECRET`, `API_KEY`…) vacía o con un valor típico (`changeme`, `admin`…). |
46
- | `shared-secret` | Variable sensible en `defaults`, que se escribe en todos los worktrees. |
47
- | `secret-pattern` | Valor con formato de secreto conocido (AWS, GitHub, Slack, `sk-…`, clave privada). |
48
- | `url-credentials`, `insecure-url` | URL remota con contraseña embebida, o con `http://`, `ws://` o `ftp://`. |
49
-
50
- ## Formato de `values.yml`
42
+ | `tracked-values`, `unignored-values` | `values.yml` is tracked by git or is not ignored. |
43
+ | `tracked-dotenv`, `unignored-dotenv` | A worktree's `.env` is tracked or is not ignored. |
44
+ | `open-permissions` | `values.yml` is readable by other users (use `chmod 600`). |
45
+ | `executable-files` | `values.yml` or a `.env` has the execute permission (use `chmod -x`). |
46
+ | `writable-files` | `values.yml` or a `.env` is writable by the group or other users (use `chmod go-w`). |
47
+ | `weak-secret` | Sensitive variable (`PASSWORD`, `TOKEN`, `SECRET`, `API_KEY`…) that is empty or has a typical value (`changeme`, `admin`…). |
48
+ | `shared-secret` | Sensitive variable in `defaults`, which is written to all worktrees. |
49
+ | `secret-pattern` | Value with a known secret format (AWS, GitHub, Slack, `sk-…`, private key). |
50
+ | `url-credentials`, `insecure-url` | Remote URL with an embedded password, or using `http://`, `ws://` or `ftp://`. |
51
+
52
+ ## `values.yml` format
51
53
 
52
54
  ```yaml
53
55
  defaults:
@@ -62,42 +64,42 @@ envs:
62
64
  feature-x: "3001"
63
65
  ```
64
66
 
65
- - `defaults`: valor por defecto de cada variable. `push` lo escribe en el `.env` de todos los worktrees.
66
- - `envs.<VARIABLE>.<worktree>`: valor de la variable en ese worktree. Sobrescribe al valor de `defaults`.
67
- - Los valores pueden ser strings, números o booleanos (`PORT: 3000`, `DEBUG: true`); `push` los escribe en el `.env` como texto (`PORT=3000`, `DEBUG=true`). `pull` convierte `true`/`false` y los números canónicos (`3000`, `0.5`) a booleanos y números; el resto (`007`, `1e3`) queda como string.
67
+ - `defaults`: default value of each variable. `push` writes it to the `.env` of all worktrees.
68
+ - `envs.<VARIABLE>.<worktree>`: value of the variable in that worktree. It overrides the value from `defaults`.
69
+ - Values can be strings, numbers or booleans (`PORT: 3000`, `DEBUG: true`); `push` writes them to the `.env` as text (`PORT=3000`, `DEBUG=true`). `pull` converts `true`/`false` and canonical numbers (`3000`, `0.5`) to booleans and numbers; anything else (`007`, `1e3`) stays a string.
68
70
 
69
- El schema (JSON Schema) está en [`schema/values.schema.json`](schema/values.schema.json). Para que VS Code valide el archivo con la extensión YAML, agrega al inicio de `values.yml`:
71
+ The schema (JSON Schema) is at [`schema/values.schema.json`](schema/values.schema.json). To have VS Code validate the file with the YAML extension, add this at the top of `values.yml`:
70
72
 
71
73
  ```yaml
72
74
  # yaml-language-server: $schema=../schema/values.schema.json
73
75
  ```
74
76
 
75
- ## Desarrollo
77
+ ## Development
76
78
 
77
79
  ```bash
78
80
  bun install
79
- bun test # ejecuta los tests
80
- bun test --coverage # con cobertura
81
- bun run build # genera dist/ (envs.js y package.json)
81
+ bun test # run the tests
82
+ bun test --coverage # with coverage
83
+ bun run build # generates dist/ (envs.js and package.json)
82
84
  ```
83
85
 
84
- - `src/envs.ts`: lógica de los comandos. `src/bin/envs.ts`: punto de entrada del CLI.
85
- - `test/fixtures/workspace.ts`: fixture `createWorkspace({ main, worktrees, files })`, que crea un repo git temporal con worktrees, cada uno en su propia carpeta temporal.
86
+ - `src/envs.ts`: command logic. `src/bin/envs.ts`: CLI entry point.
87
+ - `test/fixtures/workspace.ts`: `createWorkspace({ main, worktrees, files })` fixture, which creates a temporary git repo with worktrees, each in its own temporary folder.
86
88
 
87
- ## Publicación
89
+ ## Publishing
88
90
 
89
- El workflow **Publish** (Actions → Publish → Run workflow) sube la versión, hace el build y publica `dist/` en npm por OIDC (trusted publishing). Inputs:
91
+ The **Publish** workflow (Actions → Publish → Run workflow) bumps the version, builds and publishes `dist/` to npm via OIDC (trusted publishing). Inputs:
90
92
 
91
- - `bump`: `major`, `minor`, `patch` o `prerelease`.
92
- - `tag`: dist-tag de npm (`latest`, `default`, `alpha` o `demo`). Con un tag distinto de `latest` la versión es una prerelease (`0.0.2-alpha.0`).
93
- - `provenance`: publica con provenance. npm solo lo acepta si el repositorio es público.
93
+ - `bump`: `major`, `minor`, `patch` or `prerelease`.
94
+ - `tag`: npm dist-tag (`latest`, `default`, `alpha` or `demo`). With a tag other than `latest` the version is a prerelease (`0.0.2-alpha.0`).
95
+ - `provenance`: publish with provenance. npm only accepts it if the repository is public.
94
96
 
95
- Luego del publish crea el commit y el tag de la versión, y un release en GitHub con el enlace a la versión en npm.
97
+ After publishing, it creates the version commit and tag, and a GitHub release linking to the version on npm.
96
98
 
97
- ## Seguridad
99
+ ## Security
98
100
 
99
- Para reportar una vulnerabilidad, mira [SECURITY.md](SECURITY.md).
101
+ To report a vulnerability, see [SECURITY.md](SECURITY.md).
100
102
 
101
- ## Licencia
103
+ ## License
102
104
 
103
105
  [MIT](LICENSE)
package/SECURITY.md CHANGED
@@ -1,46 +1,46 @@
1
- # Política de seguridad
1
+ # Security Policy
2
2
 
3
- ## Versiones soportadas
3
+ ## Supported versions
4
4
 
5
- Solo se mantiene la última versión publicada en npm de `@jondotsoy/envs`. Las correcciones de seguridad se publican en una versión nueva.
5
+ Only the latest version of `@jondotsoy/envs` published on npm is maintained. Security fixes are released in a new version.
6
6
 
7
- ## Reportar una vulnerabilidad
7
+ ## Reporting a vulnerability
8
8
 
9
- No abras un issue público para reportar una vulnerabilidad. Repórtala de forma privada por uno de estos medios:
9
+ Do not open a public issue to report a vulnerability. Report it privately through one of these channels:
10
10
 
11
- - Con el reporte privado de vulnerabilidades de GitHub: pestaña **Security** del repositorio, **Report a vulnerability**.
12
- - Por correo a [hi@jon.soy](mailto:hi@jon.soy).
11
+ - GitHub's private vulnerability reporting: the repository's **Security** tab, **Report a vulnerability**.
12
+ - By email to [hi@jon.soy](mailto:hi@jon.soy).
13
13
 
14
- Incluye, si puedes:
14
+ If you can, include:
15
15
 
16
- - la versión de `@jondotsoy/envs` y de Bun que usas;
17
- - una descripción del problema y su impacto;
18
- - los pasos para reproducirlo.
16
+ - the version of `@jondotsoy/envs` and of Bun you use;
17
+ - a description of the problem and its impact;
18
+ - the steps to reproduce it.
19
19
 
20
- Te responderé lo antes posible y coordinaremos la corrección y la divulgación del problema.
20
+ I will reply as soon as possible and we will coordinate the fix and the disclosure of the issue.
21
21
 
22
- ## Archivos que modifica
22
+ ## Files it modifies
23
23
 
24
- `envs` solo lee y escribe los archivos de esta tabla. `<raíz>` es el repo principal (dentro de un worktree, el repo padre) y `<worktree>` es la carpeta de cada worktree que lista `git worktree list`, incluido el repo principal, aunque esté fuera de `<raíz>`.
24
+ `envs` only reads and writes the files in this table. `<root>` is the main repo (inside a worktree, the parent repo) and `<worktree>` is the folder of each worktree listed by `git worktree list`, including the main repo, even if it is outside `<root>`.
25
25
 
26
- | Comando | Lee | Escribe |
26
+ | Command | Reads | Writes |
27
27
  | --- | --- | --- |
28
- | `envs init` | — | Crea `<raíz>/.envs/`, `<raíz>/.envs/.gitignore` y `<raíz>/.envs/values.yml`, solo si no existen. Nunca sobrescribe. |
29
- | `envs pull` | `<worktree>/.env` de cada worktree | Reescribe `<raíz>/.envs/values.yml`. El archivo se serializa de nuevo, así que se pierden los comentarios del YAML. |
30
- | `envs push` | `<raíz>/.envs/values.yml` | Crea o actualiza `<worktree>/.env` de cada worktree que tenga valores. Actualiza las variables existentes en su línea, agrega las nuevas al final y conserva el resto del archivo. Si hay `defaults`, esto incluye a todos los worktrees. |
31
- | `envs edit` | Lo mismo que `pull` y `push` | Lo mismo que `pull` y `push`. Además ejecuta `code -w <raíz>/.envs/values.yml`. |
28
+ | `envs init` | — | Creates `<root>/.envs/`, `<root>/.envs/.gitignore` and `<root>/.envs/values.yml`, only if they do not exist. Never overwrites. |
29
+ | `envs pull` | `<worktree>/.env` of each worktree | Rewrites `<root>/.envs/values.yml`. The file is serialized again, so YAML comments are lost. |
30
+ | `envs push` | `<root>/.envs/values.yml` | Creates or updates `<worktree>/.env` of each worktree that has values. Updates existing variables in place, appends new ones at the end and keeps the rest of the file. If there are `defaults`, this includes all worktrees. |
31
+ | `envs edit` | Same as `pull` and `push` | Same as `pull` and `push`. It also runs `code -w <root>/.envs/values.yml`. |
32
32
 
33
- Además:
33
+ Additionally:
34
34
 
35
- - Ejecuta `git rev-parse` y `git worktree list` para ubicar la raíz y los worktrees. Son comandos de solo lectura.
36
- - `envs edit` ejecuta el programa `code` que encuentre en el `PATH`.
37
- - No hace conexiones de red ni modifica otros archivos del proyecto, ni siquiera el `.gitignore` de tu proyecto.
35
+ - It runs `git rev-parse` and `git worktree list` to locate the root and the worktrees. These are read-only commands.
36
+ - `envs edit` runs the `code` program found in the `PATH`.
37
+ - It makes no network connections and does not modify other project files, not even your project's `.gitignore`.
38
38
 
39
- ## Manejo de secretos
39
+ ## Handling secrets
40
40
 
41
- `envs` trabaja con valores que suelen ser secretos:
41
+ `envs` works with values that are often secrets:
42
42
 
43
- - `.envs/values.yml` guarda los valores de todos los worktrees en texto plano.
44
- - `envs init` crea `.envs/.gitignore` con `*`, para que la carpeta `.envs/` no se suba a git. No quites ese archivo.
45
- - `envs push` escribe los valores en los archivos `.env` de cada worktree. Asegúrate de que `.env` esté en el `.gitignore` de tu proyecto.
46
- - No compartas `values.yml` ni lo pegues en issues o logs.
43
+ - `.envs/values.yml` stores the values of all worktrees in plain text.
44
+ - `envs init` creates `.envs/.gitignore` with `*`, so the `.envs/` folder is not committed to git. Do not remove that file.
45
+ - `envs push` writes the values to the `.env` files of each worktree. Make sure `.env` is in your project's `.gitignore`.
46
+ - Do not share `values.yml` or paste it in issues or logs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jondotsoy/envs",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Jonathan Delgado",