@kitsy/cnos-docs 1.4.0 → 1.5.0
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/docs/api/browser.mdx +2 -0
- package/docs/cli/build.mdx +23 -0
- package/docs/cli/dev.mdx +23 -0
- package/docs/cli/export.mdx +13 -0
- package/docs/cli/index.mdx +1 -1
- package/docs/cli/watch.mdx +10 -0
- package/docs/getting-started/quick-start.mdx +13 -0
- package/docs/guides/frontend-webpack.mdx +58 -0
- package/docs/guides/generated-env-files.mdx +38 -0
- package/docs/guides/migration.mdx +13 -2
- package/manifest.yml +9 -1
- package/package.json +1 -1
package/docs/api/browser.mdx
CHANGED
|
@@ -12,3 +12,5 @@ console.log(cnos('public.app.apiBaseUrl'));
|
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Only promoted browser-safe values are available here.
|
|
15
|
+
|
|
16
|
+
Framework integrations such as `@kitsy/cnos-vite`, `@kitsy/cnos-next`, and `@kitsy/cnos-webpack` are responsible for embedding that browser payload during the build.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: cnos build env
|
|
3
|
+
description: Build flat env-file artifacts from CNOS.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cnos build env
|
|
7
|
+
|
|
8
|
+
Use `build env` when a repo still expects `.env.*` files but CNOS is the source of truth.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
cnos build env --profile local --to .env.local
|
|
12
|
+
cnos build env --profile stage --to .env.stage
|
|
13
|
+
cnos build env --public --framework vite --to .env.production
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`build env`:
|
|
17
|
+
|
|
18
|
+
- resolves the selected CNOS workspace/profile
|
|
19
|
+
- renders a deterministic flat `KEY=VALUE` file
|
|
20
|
+
- writes the target path
|
|
21
|
+
- does not start a child process
|
|
22
|
+
|
|
23
|
+
This is the preferred bridge for build systems and CI pipelines that still consume env files.
|
package/docs/cli/dev.mdx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: cnos dev env
|
|
3
|
+
description: Watch CNOS config, rewrite env artifacts, and restart a child process.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cnos dev env
|
|
7
|
+
|
|
8
|
+
Use `dev env` when a local development workflow still expects a `.env.*` file.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
cnos dev env --profile local --to .env.local -- pnpm dev
|
|
12
|
+
cnos dev env --profile stage --to .env.stage -- node server.js
|
|
13
|
+
cnos dev env --public --framework vite --to .env.local --signal -- pnpm dev
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
By default `dev env`:
|
|
17
|
+
|
|
18
|
+
- writes the env artifact before first launch
|
|
19
|
+
- watches CNOS inputs
|
|
20
|
+
- rewrites the target file on change
|
|
21
|
+
- restarts the child process
|
|
22
|
+
|
|
23
|
+
Use `--signal` when another tool is responsible for reloads and you only want the file to stay current.
|
package/docs/cli/export.mdx
CHANGED
|
@@ -10,3 +10,16 @@ cnos export env
|
|
|
10
10
|
cnos export env --to .env.local
|
|
11
11
|
cnos export env --public --framework vite --to .env.local
|
|
12
12
|
```
|
|
13
|
+
|
|
14
|
+
`export env` is the low-level renderer.
|
|
15
|
+
|
|
16
|
+
Use it when you want:
|
|
17
|
+
|
|
18
|
+
- stdout output for piping
|
|
19
|
+
- one-off JSON/text export behavior
|
|
20
|
+
- direct control over the raw env projection
|
|
21
|
+
|
|
22
|
+
For higher-level file-oriented workflows, prefer:
|
|
23
|
+
|
|
24
|
+
- `cnos build env` for one-shot artifact generation
|
|
25
|
+
- `cnos dev env` for watched dev-time file generation
|
package/docs/cli/index.mdx
CHANGED
|
@@ -9,7 +9,7 @@ The CLI is organized around:
|
|
|
9
9
|
|
|
10
10
|
- setup: `init`, `onboard`, `use`, `profile`
|
|
11
11
|
- data operations: `read`, `value`, `secret`, `promote`
|
|
12
|
-
- workflows: `run`, `export`, `dump`, `diff`, `doctor`
|
|
12
|
+
- workflows: `build env`, `dev env`, `run`, `export`, `dump`, `diff`, `doctor`
|
|
13
13
|
- advanced tooling: `codegen`, `watch`, `migrate`, `drift`, `vault`
|
|
14
14
|
|
|
15
15
|
See the individual command pages in this section.
|
package/docs/cli/watch.mdx
CHANGED
|
@@ -9,3 +9,13 @@ description: Watch config changes and emit signals or restart processes.
|
|
|
9
9
|
cnos watch -- node server.js
|
|
10
10
|
cnos watch --signal
|
|
11
11
|
```
|
|
12
|
+
|
|
13
|
+
`watch` is the low-level graph watcher.
|
|
14
|
+
|
|
15
|
+
Use it when you want to react to CNOS graph changes directly.
|
|
16
|
+
|
|
17
|
+
If your repo still needs `.env.*` files during development, prefer:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cnos dev env --profile local --to .env.local -- pnpm dev
|
|
21
|
+
```
|
|
@@ -11,6 +11,7 @@ cnos value set app.name demo
|
|
|
11
11
|
cnos value set server.port 3000
|
|
12
12
|
cnos value set api.default_query_params '["ab", "bc"]'
|
|
13
13
|
cnos read value.app.name
|
|
14
|
+
cnos build env --profile local --to .env.local
|
|
14
15
|
cnos run -- node server.js
|
|
15
16
|
```
|
|
16
17
|
|
|
@@ -32,3 +33,15 @@ const runtime = await createCnos();
|
|
|
32
33
|
console.log(runtime.value('app.name'));
|
|
33
34
|
console.log(runtime.read<string[]>('value.api.default_query_params'));
|
|
34
35
|
```
|
|
36
|
+
|
|
37
|
+
If your repo still expects env files, keep `.cnos` as the source of truth and generate them:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cnos build env --profile local --to .env.local
|
|
41
|
+
cnos dev env --profile local --to .env.local -- pnpm dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For frontend builds:
|
|
45
|
+
- Vite: `@kitsy/cnos-vite`
|
|
46
|
+
- Webpack/static bundles: `@kitsy/cnos-webpack`
|
|
47
|
+
- Next.js: `@kitsy/cnos-next`
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Frontend with Webpack
|
|
3
|
+
description: Use CNOS public projection with webpack builds, webpack-dev-server, and browser-safe runtime reads.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Frontend with Webpack
|
|
7
|
+
|
|
8
|
+
CNOS integrates with webpack through `@kitsy/cnos-webpack`. This covers the common static-bundle case where webpack produces a browser build that is then deployed as static assets.
|
|
9
|
+
|
|
10
|
+
Promote browser-safe values:
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
public:
|
|
14
|
+
promote:
|
|
15
|
+
- value.app.apiUrl
|
|
16
|
+
- flags.upi_enabled
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Use an async webpack config:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { createCnos } from '@kitsy/cnos/configure';
|
|
23
|
+
import { CnosWebpackPlugin } from '@kitsy/cnos-webpack';
|
|
24
|
+
|
|
25
|
+
export default async () => {
|
|
26
|
+
const cnos = await createCnos({
|
|
27
|
+
profile: process.env.NODE_ENV === 'production' ? 'prod' : 'local',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
devServer: {
|
|
32
|
+
port: Number(cnos.readOr('value.devServer.port', 3000)),
|
|
33
|
+
},
|
|
34
|
+
plugins: [
|
|
35
|
+
new CnosWebpackPlugin({
|
|
36
|
+
profile: process.env.NODE_ENV === 'production' ? 'prod' : 'local',
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Read in browser code:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import cnos from '@kitsy/cnos/browser';
|
|
47
|
+
|
|
48
|
+
console.log(cnos('public.app.apiUrl'));
|
|
49
|
+
console.log(cnos('public.flags.upi_enabled'));
|
|
50
|
+
console.log(process.env.APP_API_URL);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The webpack plugin:
|
|
54
|
+
- injects `process.env.*` define replacements for promoted public values
|
|
55
|
+
- embeds `globalThis.__CNOS_BROWSER_DATA__` for `@kitsy/cnos/browser`
|
|
56
|
+
- keeps server-only `value.*` and `secret.*` out of the browser bundle
|
|
57
|
+
|
|
58
|
+
If you need build-time server config such as `devServer.port`, read it in the webpack config through `createCnos()` so dev and production builds use the same CNOS source of truth.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Generated Env Files
|
|
3
|
+
description: Use CNOS to generate legacy .env artifacts while keeping .cnos as the source of truth.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Generated Env Files
|
|
7
|
+
|
|
8
|
+
CNOS is runtime-first, but many repos still rely on `.env.local`, `.env.stage`, or similar files.
|
|
9
|
+
|
|
10
|
+
Use generated env files as a **bridge**, not as the source of truth.
|
|
11
|
+
|
|
12
|
+
## One-shot build
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
cnos build env --profile local --to .env.local
|
|
16
|
+
cnos build env --profile stage --to .env.stage
|
|
17
|
+
cnos build env --profile prod --to .env.prod
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Watched dev loop
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
cnos dev env --profile local --to .env.local -- pnpm dev
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Public-only frontend artifacts
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cnos build env --public --framework vite --profile local --to .env.local
|
|
30
|
+
cnos build env --public --framework next --profile prod --to .env.production
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Recommended policy
|
|
34
|
+
|
|
35
|
+
- keep `.cnos` as the source of truth
|
|
36
|
+
- keep generated `.env.*` files gitignored
|
|
37
|
+
- migrate app code toward direct CNOS reads over time
|
|
38
|
+
- keep secrets on runtime/vault flows instead of materializing them into env files by default
|
|
@@ -16,6 +16,17 @@ cnos migrate --apply --rewrite
|
|
|
16
16
|
Bridge to existing tooling:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
cnos
|
|
20
|
-
cnos
|
|
19
|
+
cnos build env --to .env.local
|
|
20
|
+
cnos build env --profile stage --to .env.stage
|
|
21
|
+
cnos dev env --profile local --to .env.local -- pnpm dev
|
|
21
22
|
```
|
|
23
|
+
|
|
24
|
+
For webpack or other static bundles, pair this with `@kitsy/cnos-webpack` or `@kitsy/cnos/build` so browser-safe `public.*` values are injected at build time without keeping handwritten `.env` files as the source of truth.
|
|
25
|
+
|
|
26
|
+
Recommended migration sequence:
|
|
27
|
+
|
|
28
|
+
1. Keep `.cnos` as the source of truth.
|
|
29
|
+
2. Generate `.env.*` artifacts for legacy tools.
|
|
30
|
+
3. Migrate server code to `@kitsy/cnos`.
|
|
31
|
+
4. Migrate browser code to `@kitsy/cnos/browser`.
|
|
32
|
+
5. Remove env-file dependencies app by app.
|
package/manifest.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
product: cnos
|
|
2
2
|
title: CNOS Documentation
|
|
3
3
|
tagline: Configuration orchestration for apps, monorepos, and deployment pipelines
|
|
4
|
-
version: "1.
|
|
4
|
+
version: "1.5"
|
|
5
5
|
|
|
6
6
|
sidebar:
|
|
7
7
|
- group: Getting Started
|
|
@@ -21,6 +21,8 @@ sidebar:
|
|
|
21
21
|
label: Backend Projects
|
|
22
22
|
- path: guides/frontend-vite
|
|
23
23
|
label: Frontend with Vite
|
|
24
|
+
- path: guides/frontend-webpack
|
|
25
|
+
label: Frontend with Webpack
|
|
24
26
|
- path: guides/frontend-next
|
|
25
27
|
label: Frontend with Next.js
|
|
26
28
|
- path: guides/ssr
|
|
@@ -35,6 +37,8 @@ sidebar:
|
|
|
35
37
|
label: Secrets and Vaults
|
|
36
38
|
- path: guides/migration
|
|
37
39
|
label: Migrating from .env
|
|
40
|
+
- path: guides/generated-env-files
|
|
41
|
+
label: Generated Env Files
|
|
38
42
|
|
|
39
43
|
- group: CLI Reference
|
|
40
44
|
collapsed: true
|
|
@@ -55,6 +59,10 @@ sidebar:
|
|
|
55
59
|
label: cnos validate
|
|
56
60
|
- path: cli/export
|
|
57
61
|
label: cnos export
|
|
62
|
+
- path: cli/build
|
|
63
|
+
label: cnos build env
|
|
64
|
+
- path: cli/dev
|
|
65
|
+
label: cnos dev env
|
|
58
66
|
- path: cli/run
|
|
59
67
|
label: cnos run
|
|
60
68
|
- path: cli/diff
|