cf-envsync 0.3.1 → 0.3.2
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 +40 -40
- package/dist/index.js +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,16 +73,16 @@ pnpm add -D cf-envsync
|
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
75
|
# Initialize (scans wrangler.jsonc files in monorepos)
|
|
76
|
-
envsync init --monorepo
|
|
76
|
+
npx envsync init --monorepo
|
|
77
77
|
|
|
78
78
|
# Generate .dev.vars for local development
|
|
79
|
-
envsync dev
|
|
79
|
+
npx envsync dev
|
|
80
80
|
|
|
81
81
|
# Push secrets to staging
|
|
82
|
-
envsync push staging
|
|
82
|
+
npx envsync push staging
|
|
83
83
|
|
|
84
84
|
# Validate nothing is missing before deploying
|
|
85
|
-
envsync validate
|
|
85
|
+
npx envsync validate
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
### Requirements
|
|
@@ -102,7 +102,7 @@ A complete walkthrough: project setup → local dev → deploy to staging → va
|
|
|
102
102
|
```bash
|
|
103
103
|
# In your monorepo root
|
|
104
104
|
npm install -D cf-envsync
|
|
105
|
-
envsync init --monorepo
|
|
105
|
+
npx envsync init --monorepo
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
This scans for `wrangler.jsonc` files, discovers your workers, and generates:
|
|
@@ -143,8 +143,8 @@ DEV_TUNNEL_URL=https://my-tunnel.ngrok.io
|
|
|
143
143
|
echo "ENVSYNC_PASSWORD=my-team-password" > .env.password
|
|
144
144
|
|
|
145
145
|
# Encrypt all plain values
|
|
146
|
-
envsync encrypt staging
|
|
147
|
-
envsync encrypt production
|
|
146
|
+
npx envsync encrypt staging
|
|
147
|
+
npx envsync encrypt production
|
|
148
148
|
|
|
149
149
|
# Now .env.staging looks like:
|
|
150
150
|
# DATABASE_URL=envsync:v1:base64payload...
|
|
@@ -154,7 +154,7 @@ envsync encrypt production
|
|
|
154
154
|
### 4. Local development
|
|
155
155
|
|
|
156
156
|
```bash
|
|
157
|
-
envsync dev
|
|
157
|
+
npx envsync dev
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
This reads `.env` + `.env.local`, merges them, and writes `.dev.vars` into each app directory. Start wrangler as usual — it reads `.dev.vars` automatically.
|
|
@@ -188,10 +188,10 @@ If you forgot to set a per-dev override, envsync tells you:
|
|
|
188
188
|
|
|
189
189
|
```bash
|
|
190
190
|
# Preview first
|
|
191
|
-
envsync push staging --dry-run
|
|
191
|
+
npx envsync push staging --dry-run
|
|
192
192
|
|
|
193
193
|
# Push for real
|
|
194
|
-
envsync push staging
|
|
194
|
+
npx envsync push staging
|
|
195
195
|
# Push 4 secrets to worker "my-api-staging" (staging)? yes
|
|
196
196
|
# ✓ Pushed 4 secrets to my-api-staging
|
|
197
197
|
# Push 1 secrets to worker "my-web-staging" (staging)? yes
|
|
@@ -201,7 +201,7 @@ envsync push staging
|
|
|
201
201
|
### 6. Validate before deploying
|
|
202
202
|
|
|
203
203
|
```bash
|
|
204
|
-
envsync validate
|
|
204
|
+
npx envsync validate
|
|
205
205
|
# Checks every app × every environment against .env.example
|
|
206
206
|
# Exit code 1 if anything is missing → safe for CI
|
|
207
207
|
```
|
|
@@ -211,10 +211,10 @@ envsync validate
|
|
|
211
211
|
```yaml
|
|
212
212
|
# GitHub Actions example
|
|
213
213
|
- name: Validate env vars
|
|
214
|
-
run: envsync validate
|
|
214
|
+
run: npx envsync validate
|
|
215
215
|
|
|
216
216
|
- name: Push secrets to production
|
|
217
|
-
run: envsync push production --force
|
|
217
|
+
run: npx envsync push production --force
|
|
218
218
|
env:
|
|
219
219
|
ENVSYNC_PASSWORD: ${{ secrets.ENVSYNC_PASSWORD }}
|
|
220
220
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
|
@@ -229,10 +229,10 @@ envsync validate
|
|
|
229
229
|
The command you'll use most. Merges `.env` + `.env.local` and writes `.dev.vars` for each app.
|
|
230
230
|
|
|
231
231
|
```bash
|
|
232
|
-
envsync dev # All apps
|
|
233
|
-
envsync dev api # Just api
|
|
234
|
-
envsync dev api web # Multiple apps
|
|
235
|
-
envsync dev --env staging # Use staging values for local dev
|
|
232
|
+
npx envsync dev # All apps
|
|
233
|
+
npx envsync dev api # Just api
|
|
234
|
+
npx envsync dev api web # Multiple apps
|
|
235
|
+
npx envsync dev --env staging # Use staging values for local dev
|
|
236
236
|
```
|
|
237
237
|
|
|
238
238
|
```
|
|
@@ -268,10 +268,10 @@ Every key shows exactly where its value came from. Missing per-dev overrides are
|
|
|
268
268
|
Push secrets to Cloudflare Workers via `wrangler secret bulk`. One command, all workers.
|
|
269
269
|
|
|
270
270
|
```bash
|
|
271
|
-
envsync push staging # All apps → staging workers
|
|
272
|
-
envsync push production # All apps → production workers
|
|
273
|
-
envsync push staging api # Just api's staging worker
|
|
274
|
-
envsync push production --shared # Only shared secrets (JWT_SECRET, etc.)
|
|
271
|
+
npx envsync push staging # All apps → staging workers
|
|
272
|
+
npx envsync push production # All apps → production workers
|
|
273
|
+
npx envsync push staging api # Just api's staging worker
|
|
274
|
+
npx envsync push production --shared # Only shared secrets (JWT_SECRET, etc.)
|
|
275
275
|
```
|
|
276
276
|
|
|
277
277
|
```
|
|
@@ -301,11 +301,11 @@ Two modes: **local vs remote** and **env vs env**.
|
|
|
301
301
|
|
|
302
302
|
```bash
|
|
303
303
|
# Local .env.production vs what's actually on Cloudflare
|
|
304
|
-
envsync diff production
|
|
305
|
-
envsync diff production api
|
|
304
|
+
npx envsync diff production
|
|
305
|
+
npx envsync diff production api
|
|
306
306
|
|
|
307
307
|
# Compare two environments side-by-side
|
|
308
|
-
envsync diff staging production
|
|
308
|
+
npx envsync diff staging production
|
|
309
309
|
```
|
|
310
310
|
|
|
311
311
|
```
|
|
@@ -328,9 +328,9 @@ Catch missing keys before they break production.
|
|
|
328
328
|
Checks all apps across all environments against `.env.example`.
|
|
329
329
|
|
|
330
330
|
```bash
|
|
331
|
-
envsync validate # All environments, all apps
|
|
332
|
-
envsync validate staging # Just staging
|
|
333
|
-
envsync validate staging api # Just api in staging
|
|
331
|
+
npx envsync validate # All environments, all apps
|
|
332
|
+
npx envsync validate staging # Just staging
|
|
333
|
+
npx envsync validate staging api # Just api in staging
|
|
334
334
|
```
|
|
335
335
|
|
|
336
336
|
```
|
|
@@ -366,8 +366,8 @@ Exits with code 1 on failure — plug it into CI.
|
|
|
366
366
|
Pull secret key names from Cloudflare and scaffold empty entries in your local `.env` file. (Values are not available via the API — only key names.)
|
|
367
367
|
|
|
368
368
|
```bash
|
|
369
|
-
envsync pull staging
|
|
370
|
-
envsync pull production api
|
|
369
|
+
npx envsync pull staging
|
|
370
|
+
npx envsync pull production api
|
|
371
371
|
```
|
|
372
372
|
|
|
373
373
|
---
|
|
@@ -375,8 +375,8 @@ envsync pull production api
|
|
|
375
375
|
### `envsync list` — See the full picture
|
|
376
376
|
|
|
377
377
|
```bash
|
|
378
|
-
envsync list # Summary table
|
|
379
|
-
envsync list api --keys # Detailed key list for one app
|
|
378
|
+
npx envsync list # Summary table
|
|
379
|
+
npx envsync list api --keys # Detailed key list for one app
|
|
380
380
|
```
|
|
381
381
|
|
|
382
382
|
```
|
|
@@ -410,8 +410,8 @@ $ envsync list
|
|
|
410
410
|
Interactive setup that scans your repo and generates everything.
|
|
411
411
|
|
|
412
412
|
```bash
|
|
413
|
-
envsync init # Single project
|
|
414
|
-
envsync init --monorepo # Scans for wrangler.jsonc files
|
|
413
|
+
npx envsync init # Single project
|
|
414
|
+
npx envsync init --monorepo # Scans for wrangler.jsonc files
|
|
415
415
|
```
|
|
416
416
|
|
|
417
417
|
What it does:
|
|
@@ -429,8 +429,8 @@ What it does:
|
|
|
429
429
|
Alphabetically sorts keys in all `.env*` files. Reduces diff noise, prevents merge conflicts.
|
|
430
430
|
|
|
431
431
|
```bash
|
|
432
|
-
envsync normalize # All .env* files recursively
|
|
433
|
-
envsync normalize .env.staging # Specific file
|
|
432
|
+
npx envsync normalize # All .env* files recursively
|
|
433
|
+
npx envsync normalize .env.staging # Specific file
|
|
434
434
|
```
|
|
435
435
|
|
|
436
436
|
---
|
|
@@ -440,9 +440,9 @@ envsync normalize .env.staging # Specific file
|
|
|
440
440
|
Encrypts plain-text values in a `.env` file using password-based encryption (AES-256-GCM). Only available when `encryption: "password"`.
|
|
441
441
|
|
|
442
442
|
```bash
|
|
443
|
-
envsync encrypt staging # Encrypt all plain values in .env.staging
|
|
444
|
-
envsync encrypt production # Encrypt .env.production
|
|
445
|
-
envsync encrypt staging --dry-run # Preview without writing
|
|
443
|
+
npx envsync encrypt staging # Encrypt all plain values in .env.staging
|
|
444
|
+
npx envsync encrypt production # Encrypt .env.production
|
|
445
|
+
npx envsync encrypt staging --dry-run # Preview without writing
|
|
446
446
|
```
|
|
447
447
|
|
|
448
448
|
```
|
|
@@ -637,8 +637,8 @@ ENVSYNC_PASSWORD_PRODUCTION=production-password
|
|
|
637
637
|
EOF
|
|
638
638
|
|
|
639
639
|
# Encrypt plain values
|
|
640
|
-
envsync encrypt staging
|
|
641
|
-
envsync encrypt production
|
|
640
|
+
npx envsync encrypt staging
|
|
641
|
+
npx envsync encrypt production
|
|
642
642
|
```
|
|
643
643
|
|
|
644
644
|
### File structure
|
package/dist/index.js
CHANGED
|
@@ -13473,7 +13473,7 @@ var init_process = () => {};
|
|
|
13473
13473
|
|
|
13474
13474
|
// src/core/wrangler.ts
|
|
13475
13475
|
async function checkWrangler() {
|
|
13476
|
-
const result = await exec(["wrangler", "--version"]);
|
|
13476
|
+
const result = await exec(["npx", "wrangler", "--version"]);
|
|
13477
13477
|
return result.success;
|
|
13478
13478
|
}
|
|
13479
13479
|
function envFlag(environment) {
|
|
@@ -13484,6 +13484,7 @@ function envFlag(environment) {
|
|
|
13484
13484
|
async function pushSecrets(workerName, secrets, environment, cwd) {
|
|
13485
13485
|
const json = JSON.stringify(secrets);
|
|
13486
13486
|
const args = [
|
|
13487
|
+
"npx",
|
|
13487
13488
|
"wrangler",
|
|
13488
13489
|
"secret",
|
|
13489
13490
|
"bulk",
|
|
@@ -13503,6 +13504,7 @@ async function pushSecrets(workerName, secrets, environment, cwd) {
|
|
|
13503
13504
|
}
|
|
13504
13505
|
async function listSecrets(workerName, environment, cwd) {
|
|
13505
13506
|
const args = [
|
|
13507
|
+
"npx",
|
|
13506
13508
|
"wrangler",
|
|
13507
13509
|
"secret",
|
|
13508
13510
|
"list",
|
|
@@ -13580,7 +13582,7 @@ var init_push = __esm(() => {
|
|
|
13580
13582
|
if (!args["dry-run"]) {
|
|
13581
13583
|
const hasWrangler = await checkWrangler();
|
|
13582
13584
|
if (!hasWrangler) {
|
|
13583
|
-
consola.error("wrangler CLI not found. Install it with: npm i -
|
|
13585
|
+
consola.error("wrangler CLI not found. Install it with: npm i -D wrangler");
|
|
13584
13586
|
process.exit(1);
|
|
13585
13587
|
}
|
|
13586
13588
|
}
|
|
@@ -13721,7 +13723,7 @@ var init_pull = __esm(() => {
|
|
|
13721
13723
|
}
|
|
13722
13724
|
const hasWrangler = await checkWrangler();
|
|
13723
13725
|
if (!hasWrangler) {
|
|
13724
|
-
consola.error("wrangler CLI not found. Install it with: npm i -
|
|
13726
|
+
consola.error("wrangler CLI not found. Install it with: npm i -D wrangler");
|
|
13725
13727
|
process.exit(1);
|
|
13726
13728
|
}
|
|
13727
13729
|
const rawConfig = await loadConfig();
|
|
@@ -14067,7 +14069,7 @@ var init_diff = __esm(() => {
|
|
|
14067
14069
|
} else {
|
|
14068
14070
|
const hasWrangler = await checkWrangler();
|
|
14069
14071
|
if (!hasWrangler) {
|
|
14070
|
-
consola.error("wrangler CLI not found. Install it with: npm i -
|
|
14072
|
+
consola.error("wrangler CLI not found. Install it with: npm i -D wrangler");
|
|
14071
14073
|
process.exit(1);
|
|
14072
14074
|
}
|
|
14073
14075
|
const appNames = target ? [target, ...parseAppNames5(args, 2) ?? []] : parseAppNames5(args, 1);
|