cfenv-kv-sync 0.1.0-beta.1

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 ADDED
@@ -0,0 +1,63 @@
1
+ # cfenv (`cfenv-kv-sync`)
2
+
3
+ Cloudflare KV-backed environment sync CLI with a built-in Node hot-update SDK.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g cfenv-kv-sync
9
+ ```
10
+
11
+ ## Core Commands
12
+
13
+ ```bash
14
+ # one-step setup (uses Wrangler auth by default)
15
+ cfenv setup --project myapp --env development
16
+
17
+ # explicit token setup
18
+ cfenv login --profile default --account-id <ACCOUNT_ID> --api-token <API_TOKEN>
19
+ cfenv link --project myapp --env development --namespace-id <NAMESPACE_ID> --profile default
20
+
21
+ # sync
22
+ cfenv push --env development --file .env
23
+ cfenv pull --env development --out .env --overwrite
24
+
25
+ # export (CI/runtime)
26
+ cfenv export --env production --format dotenv --stdout
27
+ cfenv export --env production --format json --stdout
28
+ ```
29
+
30
+ ## Storage Model
31
+
32
+ Default `flat` mode:
33
+
34
+ - `cfenv:<project>:<env>:vars:<ENV_KEY>` => env value
35
+ - `cfenv:<project>:<env>:meta` => checksum and update metadata
36
+
37
+ Optional `snapshot` mode stores versioned snapshots and supports encrypted payloads.
38
+
39
+ ## Node SDK Hot Update
40
+
41
+ ```ts
42
+ import { CfenvHotUpdateClient, applyEntriesToProcessEnv } from "cfenv-kv-sync";
43
+
44
+ const client = new CfenvHotUpdateClient({
45
+ accountId: process.env.CF_ACCOUNT_ID!,
46
+ apiToken: process.env.CF_API_TOKEN!,
47
+ namespaceId: process.env.CF_NAMESPACE_ID!,
48
+ project: "myapp",
49
+ environment: "production",
50
+ intervalMs: 30_000,
51
+ onUpdate(snapshot) {
52
+ applyEntriesToProcessEnv(snapshot.entries, { overwrite: true });
53
+ }
54
+ });
55
+
56
+ await client.start();
57
+ ```
58
+
59
+ ## Security Notes
60
+
61
+ - Use dedicated API tokens for CI/runtime.
62
+ - Do not commit `.env` files.
63
+ - Flat mode stores raw env values in KV.