Skip to content

Commit 5c5992b

Browse files
committed
merge: sync main into cleanup branch
2 parents 6373264 + d087c29 commit 5c5992b

27 files changed

Lines changed: 972 additions & 22241 deletions

README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ const config = useSafeRuntimeConfig()
142142
</script>
143143
```
144144

145+
You can also use the same composable in server code:
146+
147+
```ts
148+
// server/utils/config.ts
149+
export function getPrivateConfig() {
150+
const config = useSafeRuntimeConfig()
151+
return {
152+
secretKey: config.secretKey,
153+
apiBase: config.public.apiBase,
154+
}
155+
}
156+
```
157+
145158
## Configuration Options
146159

147160
| Option | Type | Default | Description |
@@ -160,27 +173,31 @@ const config = useSafeRuntimeConfig()
160173

161174
[Shelve](https://shelve.cloud) is a secrets management service. This module fetches secrets from Shelve at build time and merges them into your runtime config before validation.
162175

163-
### Zero-Config Setup
176+
### Configure Shelve
164177

165-
If you have a `shelve.json` file in your project root, the integration enables automatically:
178+
Configure Shelve directly in your Nuxt config:
166179

167180
```ts
168181
export default defineNuxtConfig({
169182
safeRuntimeConfig: {
170183
$schema: runtimeConfigSchema,
171-
shelve: true, // Auto-detects project, team, and environment
184+
shelve: {
185+
project: 'my-app',
186+
slug: 'my-team',
187+
},
172188
},
173189
})
174190
```
175191

176192
The module resolves configuration from multiple sources (highest priority first):
177193

178-
| Config | Sources |
179-
| ----------- | ---------------------------------------------------------------------- |
180-
| project | `nuxt.config``SHELVE_PROJECT``shelve.json``package.json` name |
181-
| slug | `nuxt.config``SHELVE_TEAM_SLUG``shelve.json` |
182-
| environment | `nuxt.config``SHELVE_ENV``shelve.json` → dev mode auto |
183-
| token | `SHELVE_TOKEN``~/.shelve` file |
194+
| Config | Sources |
195+
| ----------- | ------------------------------------------------------------ |
196+
| project | `nuxt.config``SHELVE_PROJECT``package.json` name |
197+
| slug | `nuxt.config.slug/team``SHELVE_TEAM``SHELVE_TEAM_SLUG` |
198+
| environment | `nuxt.config``SHELVE_ENV` → dev mode auto |
199+
| url | `nuxt.config``SHELVE_URL``https://app.shelve.cloud` |
200+
| token | `SHELVE_TOKEN``~/.shelve` |
184201

185202
### Explicit Configuration
186203

@@ -232,6 +249,14 @@ export default defineNuxtConfig({
232249

233250
The runtime plugin runs before validation, so freshly fetched secrets are validated against your schema.
234251

252+
### Install Wizard UX
253+
254+
On module install, an interactive setup wizard can help bootstrap validation and Shelve config. The wizard now:
255+
256+
- shows a preview of planned actions first (install deps, write `~/.shelve`, edit `nuxt.config`)
257+
- asks for a final confirmation before applying any change
258+
- skips automatically in CI and non-interactive terminals (non-TTY)
259+
235260
## Runtime Validation
236261

237262
By default, validation only runs at build time. Enable runtime validation to catch environment variable issues when the server starts:
@@ -289,7 +314,7 @@ The rule includes auto-fix support — run `eslint --fix` to automatically repla
289314

290315
## Type Safety
291316

292-
Types are auto-generated at build time from your schema's JSON Schema representation. The `useSafeRuntimeConfig()` composable returns a fully typed object — no manual generics needed:
317+
Types are auto-generated at build time from your schema's JSON Schema representation. The `useSafeRuntimeConfig()` composable returns a fully typed object in both app and server contexts (`app.vue`, `server/api`, `server/utils`) — no manual generics needed:
293318

294319
```ts
295320
const config = useSafeRuntimeConfig()
@@ -311,6 +336,12 @@ When validation fails, you see detailed error messages:
311336

312337
The module stops the build process until all validation errors are resolved.
313338

339+
## Upcoming Major Release Notes
340+
341+
- Shelve setup no longer documents `shelve.json` auto-enablement; supported sources are `nuxt.config`, env vars, and `package.json` fallback for project name.
342+
- The install wizard now previews actions and requires explicit confirmation before mutating files or writing credentials.
343+
- Runtime and wizard key-shaping now use the same env-key mapping rules to avoid schema/runtime drift.
344+
314345
## Why This Module?
315346

316347
Nuxt's built-in schema validation is designed for module authors and broader configuration. This module focuses specifically on **runtime config validation** using Standard Schema, allowing you to:

docs/1.guide/3.type-safety.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ icon: ph:shield-check
44

55
# Type Safety
66

7-
The module generates TypeScript types from your schema, making `useSafeRuntimeConfig()` fully typed without manual generics.
7+
The module generates TypeScript types from your schema, making `useSafeRuntimeConfig()` fully typed without manual generics in both app and server code.
88

99
## How It Works
1010

@@ -56,7 +56,7 @@ interface SafeRuntimeConfig {
5656

5757
## Server vs Client
5858

59-
On the server, you get the full config. On the client, only `public` properties are available:
59+
On the server (including `server/api` and `server/utils`), you get the full config. On the client, only `public` properties are available:
6060

6161
```ts
6262
// Server
@@ -69,6 +69,17 @@ config.secretKey // undefined (private keys not exposed)
6969
config.public.apiBase // available
7070
```
7171

72+
```ts
73+
// server/utils/config.ts
74+
export function getServerConfig() {
75+
const config = useSafeRuntimeConfig()
76+
return {
77+
secretKey: config.secretKey,
78+
apiBase: config.public.apiBase,
79+
}
80+
}
81+
```
82+
7283
## Generated Types Location
7384

7485
Types are stored in `.nuxt/types/safe-runtime-config.d.ts` and automatically included via Nuxt's type augmentation.

docs/3.integrations/2.shelve.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ export default defineNuxtConfig({
5757

5858
For local development, run `shelve login` to authenticate. For CI/CD, set the `SHELVE_TOKEN` environment variable.
5959

60+
## Setup Wizard
61+
62+
On module install (interactive terminals only), the setup wizard can bootstrap schema + Shelve configuration.
63+
64+
Before mutating anything, it shows the planned actions and asks for final confirmation:
65+
66+
- install validation dependencies (if needed)
67+
- write `~/.shelve` token (if newly entered)
68+
- update `nuxt.config`
69+
70+
In CI and non-interactive terminals, the wizard is skipped automatically.
71+
6072
## How It Works
6173

6274
1. The module reads your Shelve configuration from nuxt.config
@@ -170,7 +182,17 @@ You can override any configuration using environment variables:
170182
| ------------------ | ------------------------------ |
171183
| `SHELVE_TOKEN` | Authentication token |
172184
| `SHELVE_PROJECT` | Project name |
185+
| `SHELVE_TEAM` | Team slug |
173186
| `SHELVE_TEAM_SLUG` | Team slug |
174187
| `SHELVE_ENV` | Environment name |
175188
| `SHELVE_URL` | API URL (for self-hosted) |
176189

190+
Resolution priority (high to low):
191+
192+
| Config | Priority |
193+
| ------------- | ------------------------------------------------------------------ |
194+
| `project` | `nuxt.config``SHELVE_PROJECT``package.json` name |
195+
| `slug` | `nuxt.config.slug/team``SHELVE_TEAM``SHELVE_TEAM_SLUG` |
196+
| `environment` | `nuxt.config``SHELVE_ENV` → auto (`development`/`production`) |
197+
| `url` | `nuxt.config``SHELVE_URL``https://app.shelve.cloud` |
198+
| `token` | `SHELVE_TOKEN``~/.shelve` |

0 commit comments

Comments
 (0)