@buoy-gg/env 6.0.0 → 6.0.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 +42 -356
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,388 +1,74 @@
|
|
|
1
|
-
# @buoy/env
|
|
1
|
+
# @buoy-gg/env
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@buoy-gg/env) [](https://www.npmjs.com/package/@buoy-gg/env)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**View and validate your app's environment variables on-device — auto-discovers `EXPO_PUBLIC_` vars with type detection and a 0-100% health score.**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Part of [Buoy](https://github.com/Buoy-gg/buoy) — devtools that live inside your React Native app. Install it and it auto-appears in the floating menu from [`@buoy-gg/core`](https://www.npmjs.com/package/@buoy-gg/core).
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- **Required Variable Validation**: Define and validate required environment variables
|
|
11
|
-
- **Type Checking**: Validate variable types (string, boolean, number, etc.)
|
|
12
|
-
- **Value Validation**: Check if variables match expected values
|
|
13
|
-
- **Search & Filtering**: Search and filter by variable name, value, or status
|
|
14
|
-
- **Copy Functionality**: Easily copy variable values
|
|
15
|
-
- **Beautiful UI**: Modern, game-themed interface matching other React Buoy tools
|
|
9
|
+

|
|
16
10
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
This package is part of the React Buoy monorepo and is automatically available to other packages and the example app.
|
|
20
|
-
|
|
21
|
-
For external projects:
|
|
11
|
+
## Install
|
|
22
12
|
|
|
23
13
|
```bash
|
|
24
|
-
npm install @buoy/env
|
|
25
|
-
# or
|
|
26
|
-
pnpm add @buoy/env
|
|
27
|
-
# or
|
|
28
|
-
yarn add @buoy/env
|
|
14
|
+
npm install @buoy-gg/core @buoy-gg/env
|
|
29
15
|
```
|
|
30
16
|
|
|
31
|
-
## Quick
|
|
32
|
-
|
|
33
|
-
### Simplest Setup - Just 1 Line!
|
|
34
|
-
|
|
35
|
-
**Import the preset and add it to your tools array. Done!**
|
|
17
|
+
## Quick start
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
import { envToolPreset } from '@buoy/env';
|
|
39
|
-
import { FloatingDevTools } from '@buoy/core';
|
|
19
|
+
Fully automatic. Render the floating menu once — the Environment Inspector is auto-discovered as soon as this package is installed:
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// ...your other tools
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
function App() {
|
|
47
|
-
return (
|
|
48
|
-
<FloatingDevTools
|
|
49
|
-
apps={installedApps}
|
|
50
|
-
environment="local"
|
|
51
|
-
userRole="admin"
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**Done!** The preset automatically:
|
|
58
|
-
- ✅ Inspects all environment variables
|
|
59
|
-
- ✅ Provides search and filtering
|
|
60
|
-
- ✅ Includes copy functionality
|
|
61
|
-
- ✅ No configuration required
|
|
62
|
-
|
|
63
|
-
### Custom Configuration
|
|
64
|
-
|
|
65
|
-
If you need to validate specific environment variables:
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import { createEnvTool, createEnvVarConfig, envVar } from '@buoy/env';
|
|
69
|
-
|
|
70
|
-
// Define required environment variables
|
|
71
|
-
const requiredEnvVars = createEnvVarConfig([
|
|
72
|
-
envVar("EXPO_PUBLIC_API_URL").exists(),
|
|
73
|
-
envVar("EXPO_PUBLIC_DEBUG_MODE").withType("boolean").build(),
|
|
74
|
-
envVar("EXPO_PUBLIC_ENVIRONMENT").withValue("development").build(),
|
|
75
|
-
]);
|
|
76
|
-
|
|
77
|
-
// Create custom tool with validation
|
|
78
|
-
const myEnvTool = createEnvTool({
|
|
79
|
-
requiredEnvVars,
|
|
80
|
-
colorPreset: "cyan",
|
|
81
|
-
enableSharedModalDimensions: true,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const installedApps = [
|
|
85
|
-
myEnvTool,
|
|
86
|
-
// ...other tools
|
|
87
|
-
];
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Alternative: Manual Setup
|
|
91
|
-
|
|
92
|
-
If you're not using FloatingDevTools or want more control:
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
import { EnvVarsModal, createEnvVarConfig, envVar } from '@buoy/env';
|
|
96
|
-
|
|
97
|
-
const requiredEnvVars = createEnvVarConfig([
|
|
98
|
-
envVar("EXPO_PUBLIC_API_URL").exists(),
|
|
99
|
-
envVar("EXPO_PUBLIC_DEBUG_MODE").withType("boolean").build(),
|
|
100
|
-
]);
|
|
101
|
-
|
|
102
|
-
function App() {
|
|
103
|
-
const [showEnv, setShowEnv] = useState(false);
|
|
21
|
+
```tsx
|
|
22
|
+
import { FloatingDevTools } from "@buoy-gg/core";
|
|
104
23
|
|
|
24
|
+
export default function App() {
|
|
105
25
|
return (
|
|
106
26
|
<>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</Button>
|
|
110
|
-
|
|
111
|
-
<EnvVarsModal
|
|
112
|
-
visible={showEnv}
|
|
113
|
-
onClose={() => setShowEnv(false)}
|
|
114
|
-
requiredEnvVars={requiredEnvVars}
|
|
115
|
-
/>
|
|
27
|
+
{/* your app */}
|
|
28
|
+
<FloatingDevTools />
|
|
116
29
|
</>
|
|
117
30
|
);
|
|
118
31
|
}
|
|
119
32
|
```
|
|
120
33
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
### Presets
|
|
124
|
-
|
|
125
|
-
#### `envToolPreset`
|
|
126
|
-
|
|
127
|
-
Pre-configured environment variables tool ready to use with FloatingDevTools.
|
|
128
|
-
|
|
129
|
-
**Example:**
|
|
130
|
-
```typescript
|
|
131
|
-
import { envToolPreset } from '@buoy/env';
|
|
132
|
-
|
|
133
|
-
const installedApps = [envToolPreset];
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
#### `createEnvTool(options?)`
|
|
137
|
-
|
|
138
|
-
Create a custom environment variables tool configuration.
|
|
139
|
-
|
|
140
|
-
**Options:**
|
|
141
|
-
```typescript
|
|
142
|
-
{
|
|
143
|
-
/** Tool name (default: "ENV") */
|
|
144
|
-
name?: string;
|
|
145
|
-
/** Tool description */
|
|
146
|
-
description?: string;
|
|
147
|
-
/** Icon color preset (default: "green") */
|
|
148
|
-
colorPreset?: "orange" | "cyan" | "purple" | "pink" | "yellow" | "green";
|
|
149
|
-
/** Custom tool ID (default: "env") */
|
|
150
|
-
id?: string;
|
|
151
|
-
/** Array of required environment variables to validate */
|
|
152
|
-
requiredEnvVars?: RequiredEnvVar[];
|
|
153
|
-
/** Enable shared modal dimensions */
|
|
154
|
-
enableSharedModalDimensions?: boolean;
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**Example:**
|
|
159
|
-
```typescript
|
|
160
|
-
import { createEnvTool, createEnvVarConfig, envVar } from '@buoy/env';
|
|
34
|
+
To validate required variables, build the tool with `createEnvTool` and the fluent `envVar` builder, then pass it via `apps={[...]}`:
|
|
161
35
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
envVar("DEBUG").withType("boolean").build(),
|
|
165
|
-
]);
|
|
36
|
+
```tsx
|
|
37
|
+
import { createEnvTool, envVar } from "@buoy-gg/env";
|
|
166
38
|
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
39
|
+
const envTool = createEnvTool({
|
|
40
|
+
requiredEnvVars: [
|
|
41
|
+
envVar("EXPO_PUBLIC_API_URL").exists(),
|
|
42
|
+
envVar("EXPO_PUBLIC_DEBUG_MODE").withType("boolean").build(),
|
|
43
|
+
envVar("EXPO_PUBLIC_ENVIRONMENT").withValue("development").build(),
|
|
44
|
+
envVar("EXPO_PUBLIC_MAX_RETRIES")
|
|
45
|
+
.withType("number")
|
|
46
|
+
.withDescription("Maximum API retry attempts")
|
|
47
|
+
.build(),
|
|
48
|
+
],
|
|
172
49
|
});
|
|
173
50
|
```
|
|
174
51
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
#### `EnvVarsModal`
|
|
178
|
-
|
|
179
|
-
Main modal component for inspecting environment variables.
|
|
180
|
-
|
|
181
|
-
**Props:**
|
|
182
|
-
```typescript
|
|
183
|
-
interface EnvVarsModalProps {
|
|
184
|
-
/** Whether the modal is visible */
|
|
185
|
-
visible: boolean;
|
|
186
|
-
/** Callback when modal is closed */
|
|
187
|
-
onClose: () => void;
|
|
188
|
-
/** List of required environment variables to validate */
|
|
189
|
-
requiredEnvVars: RequiredEnvVar[];
|
|
190
|
-
/** Optional back button handler */
|
|
191
|
-
onBack?: () => void;
|
|
192
|
-
/** Whether to use shared modal dimensions */
|
|
193
|
-
enableSharedModalDimensions?: boolean;
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
**Example:**
|
|
198
|
-
```typescript
|
|
199
|
-
<EnvVarsModal
|
|
200
|
-
visible={isVisible}
|
|
201
|
-
onClose={handleClose}
|
|
202
|
-
requiredEnvVars={requiredEnvVars}
|
|
203
|
-
/>
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Utilities
|
|
207
|
-
|
|
208
|
-
#### `createEnvVarConfig(validators)`
|
|
209
|
-
|
|
210
|
-
Create an array of required environment variables with validation rules.
|
|
211
|
-
|
|
212
|
-
**Signature:**
|
|
213
|
-
```typescript
|
|
214
|
-
function createEnvVarConfig(
|
|
215
|
-
validators: EnvVarValidator[]
|
|
216
|
-
): RequiredEnvVar[]
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
**Example:**
|
|
220
|
-
```typescript
|
|
221
|
-
import { createEnvVarConfig, envVar } from '@buoy/env';
|
|
222
|
-
|
|
223
|
-
const config = createEnvVarConfig([
|
|
224
|
-
envVar("API_URL").exists(),
|
|
225
|
-
envVar("DEBUG").withType("boolean").build(),
|
|
226
|
-
envVar("ENVIRONMENT").withValue("production").build(),
|
|
227
|
-
]);
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
#### `envVar(key)`
|
|
231
|
-
|
|
232
|
-
Create a fluent validator for an environment variable.
|
|
233
|
-
|
|
234
|
-
**Signature:**
|
|
235
|
-
```typescript
|
|
236
|
-
function envVar(key: string): EnvVarValidator
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
**Methods:**
|
|
240
|
-
- `.exists()` - Validate that the variable exists
|
|
241
|
-
- `.withType(type)` - Validate the variable type (string, boolean, number, etc.)
|
|
242
|
-
- `.withValue(value)` - Validate the variable matches a specific value
|
|
243
|
-
- `.build()` - Finalize the validator
|
|
244
|
-
|
|
245
|
-
**Example:**
|
|
246
|
-
```typescript
|
|
247
|
-
import { envVar } from '@buoy/env';
|
|
248
|
-
|
|
249
|
-
// Variable must exist
|
|
250
|
-
envVar("API_URL").exists();
|
|
251
|
-
|
|
252
|
-
// Variable must be a boolean
|
|
253
|
-
envVar("DEBUG_MODE").withType("boolean").build();
|
|
254
|
-
|
|
255
|
-
// Variable must match specific value
|
|
256
|
-
envVar("ENVIRONMENT").withValue("staging").build();
|
|
257
|
-
|
|
258
|
-
// Combined validation
|
|
259
|
-
envVar("PORT")
|
|
260
|
-
.withType("number")
|
|
261
|
-
.withValue("3000")
|
|
262
|
-
.build();
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
### Types
|
|
266
|
-
|
|
267
|
-
#### `RequiredEnvVar`
|
|
268
|
-
|
|
269
|
-
```typescript
|
|
270
|
-
interface RequiredEnvVar {
|
|
271
|
-
/** Environment variable key */
|
|
272
|
-
key: string;
|
|
273
|
-
/** Optional description */
|
|
274
|
-
description?: string;
|
|
275
|
-
/** Expected type */
|
|
276
|
-
expectedType?: "string" | "boolean" | "number" | "json";
|
|
277
|
-
/** Expected value */
|
|
278
|
-
expectedValue?: string;
|
|
279
|
-
/** Whether the variable must exist */
|
|
280
|
-
required?: boolean;
|
|
281
|
-
}
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
#### `Environment`
|
|
285
|
-
|
|
286
|
-
```typescript
|
|
287
|
-
type Environment =
|
|
288
|
-
| "local"
|
|
289
|
-
| "development"
|
|
290
|
-
| "staging"
|
|
291
|
-
| "production"
|
|
292
|
-
| string;
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
#### `UserRole`
|
|
296
|
-
|
|
297
|
-
```typescript
|
|
298
|
-
type UserRole = "admin" | "internal" | "user";
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
## Use Cases
|
|
302
|
-
|
|
303
|
-
### API Configuration Validation
|
|
304
|
-
|
|
305
|
-
```typescript
|
|
306
|
-
import { createEnvTool, createEnvVarConfig, envVar } from '@buoy/env';
|
|
307
|
-
|
|
308
|
-
const requiredEnvVars = createEnvVarConfig([
|
|
309
|
-
envVar("EXPO_PUBLIC_API_URL").exists(),
|
|
310
|
-
envVar("EXPO_PUBLIC_API_KEY").exists(),
|
|
311
|
-
envVar("EXPO_PUBLIC_API_TIMEOUT").withType("number").build(),
|
|
312
|
-
]);
|
|
313
|
-
|
|
314
|
-
const envTool = createEnvTool({ requiredEnvVars });
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### Environment-Specific Validation
|
|
318
|
-
|
|
319
|
-
```typescript
|
|
320
|
-
import { createEnvVarConfig, envVar } from '@buoy/env';
|
|
321
|
-
|
|
322
|
-
const requiredEnvVars = createEnvVarConfig([
|
|
323
|
-
envVar("EXPO_PUBLIC_ENVIRONMENT")
|
|
324
|
-
.withValue("development")
|
|
325
|
-
.build(),
|
|
326
|
-
envVar("EXPO_PUBLIC_DEBUG_MODE")
|
|
327
|
-
.withType("boolean")
|
|
328
|
-
.build(),
|
|
329
|
-
envVar("EXPO_PUBLIC_ENABLE_LOGGING")
|
|
330
|
-
.withType("boolean")
|
|
331
|
-
.build(),
|
|
332
|
-
]);
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### Feature Flag Configuration
|
|
336
|
-
|
|
337
|
-
```typescript
|
|
338
|
-
import { createEnvVarConfig, envVar } from '@buoy/env';
|
|
339
|
-
|
|
340
|
-
const requiredEnvVars = createEnvVarConfig([
|
|
341
|
-
envVar("EXPO_PUBLIC_FEATURE_NEW_UI")
|
|
342
|
-
.withType("boolean")
|
|
343
|
-
.build(),
|
|
344
|
-
envVar("EXPO_PUBLIC_FEATURE_ANALYTICS")
|
|
345
|
-
.withType("boolean")
|
|
346
|
-
.build(),
|
|
347
|
-
envVar("EXPO_PUBLIC_FEATURE_BETA")
|
|
348
|
-
.withType("boolean")
|
|
349
|
-
.build(),
|
|
350
|
-
]);
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
## Dependencies
|
|
52
|
+
## What you get
|
|
354
53
|
|
|
355
|
-
-
|
|
356
|
-
-
|
|
54
|
+
- **Automatic discovery** — every `EXPO_PUBLIC_`-prefixed variable is collected with zero configuration.
|
|
55
|
+
- **Required-variable validation** — declare which vars must exist, with expected values or types: `string`, `number`, `boolean`, `array`, `object`, `url`.
|
|
56
|
+
- **Type detection** — values are auto-classified (string, number, boolean, array, object, url, json).
|
|
57
|
+
- **Health score** — a 0-100% health percentage with HEALTHY / WARNING / ERROR / CRITICAL states, plus counts for total, required, missing, and wrong value/type.
|
|
58
|
+
- **Per-variable status** — green (present and correct), yellow (wrong value or type), red (required but missing).
|
|
59
|
+
- **Search and filters** — real-time search plus "All", "Missing", and "Issues" filters.
|
|
60
|
+
- **Copy to clipboard** — copy any value with one tap.
|
|
357
61
|
|
|
358
|
-
##
|
|
359
|
-
|
|
360
|
-
### Building
|
|
361
|
-
|
|
362
|
-
```bash
|
|
363
|
-
pnpm build
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### Type Checking
|
|
367
|
-
|
|
368
|
-
```bash
|
|
369
|
-
pnpm typecheck
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
### Clean Build
|
|
373
|
-
|
|
374
|
-
```bash
|
|
375
|
-
pnpm clean
|
|
376
|
-
```
|
|
62
|
+
## Desktop & AI
|
|
377
63
|
|
|
378
|
-
|
|
64
|
+
The same live session streams to [Buoy Desktop](https://github.com/Buoy-gg/Buoy-Desktop) (free, macOS/Windows/Linux) and to Claude Code or Cursor via the [Buoy MCP server](https://buoy.gg/buoy/latest/docs/mcp).
|
|
379
65
|
|
|
380
|
-
|
|
66
|
+
## Free vs Pro
|
|
381
67
|
|
|
382
|
-
|
|
68
|
+
Every tool is free. [Pro](https://buoy.gg/pricing) unlocks production builds, the MCP server, and unlimited capture. Every weekend, Pro features unlock free for everyone.
|
|
383
69
|
|
|
384
|
-
|
|
70
|
+
---
|
|
385
71
|
|
|
386
|
-
|
|
72
|
+
📚 [Full docs](https://buoy.gg/buoy/latest/docs/tools/env) · [All Buoy tools](https://github.com/Buoy-gg/buoy)
|
|
387
73
|
|
|
388
|
-
|
|
74
|
+
Proprietary software. © Buoy LLC. [Terms](https://buoy.gg/terms)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/env",
|
|
3
|
-
"version": "6.0.
|
|
4
|
-
"description": "Environment
|
|
3
|
+
"version": "6.0.1",
|
|
4
|
+
"description": "Environment variable devtool for React Native — auto-discovers EXPO_PUBLIC_ vars, validates types, scores config health. Part of Buoy devtools.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
7
7
|
"types": "lib/typescript/index.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@buoy-gg/floating-tools-core": "6.0.
|
|
30
|
-
"@buoy-gg/shared-ui": "6.0.
|
|
29
|
+
"@buoy-gg/floating-tools-core": "6.0.1",
|
|
30
|
+
"@buoy-gg/shared-ui": "6.0.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "*",
|