@buoy-gg/env 1.7.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 +388 -0
- package/lib/commonjs/env/EnvVariables.js +25 -0
- package/lib/commonjs/env/components/EnvStatsOverview.js +134 -0
- package/lib/commonjs/env/components/EnvVarRow.js +170 -0
- package/lib/commonjs/env/components/EnvVarSection.js +84 -0
- package/lib/commonjs/env/components/EnvVarsModal.js +315 -0
- package/lib/commonjs/env/hooks/useDynamicEnv.js +87 -0
- package/lib/commonjs/env/index.js +16 -0
- package/lib/commonjs/env/types/index.js +27 -0
- package/lib/commonjs/env/types/types.js +1 -0
- package/lib/commonjs/env/types/userTypes.js +1 -0
- package/lib/commonjs/env/utils/envTypeDetector.js +59 -0
- package/lib/commonjs/env/utils/helpers.js +119 -0
- package/lib/commonjs/env/utils/index.js +38 -0
- package/lib/commonjs/env/utils/utils.js +121 -0
- package/lib/commonjs/index.js +54 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/preset.js +90 -0
- package/lib/module/env/EnvVariables.js +11 -0
- package/lib/module/env/components/EnvStatsOverview.js +130 -0
- package/lib/module/env/components/EnvVarRow.js +166 -0
- package/lib/module/env/components/EnvVarSection.js +80 -0
- package/lib/module/env/components/EnvVarsModal.js +311 -0
- package/lib/module/env/hooks/useDynamicEnv.js +83 -0
- package/lib/module/env/index.js +3 -0
- package/lib/module/env/types/index.js +4 -0
- package/lib/module/env/types/types.js +1 -0
- package/lib/module/env/types/userTypes.js +1 -0
- package/lib/module/env/utils/envTypeDetector.js +55 -0
- package/lib/module/env/utils/helpers.js +114 -0
- package/lib/module/env/utils/index.js +5 -0
- package/lib/module/env/utils/utils.js +116 -0
- package/lib/module/index.js +13 -0
- package/lib/module/preset.js +85 -0
- package/lib/typescript/env/EnvVariables.d.ts +8 -0
- package/lib/typescript/env/EnvVariables.d.ts.map +1 -0
- package/lib/typescript/env/components/EnvStatsOverview.d.ts +20 -0
- package/lib/typescript/env/components/EnvStatsOverview.d.ts.map +1 -0
- package/lib/typescript/env/components/EnvVarRow.d.ts +9 -0
- package/lib/typescript/env/components/EnvVarRow.d.ts.map +1 -0
- package/lib/typescript/env/components/EnvVarSection.d.ts +10 -0
- package/lib/typescript/env/components/EnvVarSection.d.ts.map +1 -0
- package/lib/typescript/env/components/EnvVarsModal.d.ts +26 -0
- package/lib/typescript/env/components/EnvVarsModal.d.ts.map +1 -0
- package/lib/typescript/env/hooks/useDynamicEnv.d.ts +39 -0
- package/lib/typescript/env/hooks/useDynamicEnv.d.ts.map +1 -0
- package/lib/typescript/env/index.d.ts +2 -0
- package/lib/typescript/env/index.d.ts.map +1 -0
- package/lib/typescript/env/types/index.d.ts +3 -0
- package/lib/typescript/env/types/index.d.ts.map +1 -0
- package/lib/typescript/env/types/types.d.ts +67 -0
- package/lib/typescript/env/types/types.d.ts.map +1 -0
- package/lib/typescript/env/types/userTypes.d.ts +3 -0
- package/lib/typescript/env/types/userTypes.d.ts.map +1 -0
- package/lib/typescript/env/utils/envTypeDetector.d.ts +10 -0
- package/lib/typescript/env/utils/envTypeDetector.d.ts.map +1 -0
- package/lib/typescript/env/utils/helpers.d.ts +70 -0
- package/lib/typescript/env/utils/helpers.d.ts.map +1 -0
- package/lib/typescript/env/utils/index.d.ts +4 -0
- package/lib/typescript/env/utils/index.d.ts.map +1 -0
- package/lib/typescript/env/utils/utils.d.ts +24 -0
- package/lib/typescript/env/utils/utils.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts +86 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Detects the type of an environment variable value
|
|
5
|
+
* First checks if useDynamicEnv already parsed it to the correct type,
|
|
6
|
+
* then analyzes string content to detect what type it represents
|
|
7
|
+
*
|
|
8
|
+
* @returns One of: "string", "number", "boolean", "array", "object"
|
|
9
|
+
*/
|
|
10
|
+
export function getEnvVarType(value) {
|
|
11
|
+
// Check the actual parsed value type from useDynamicEnv
|
|
12
|
+
const type = typeof value;
|
|
13
|
+
if (type === "boolean") return "boolean";
|
|
14
|
+
if (type === "number") return "number";
|
|
15
|
+
if (Array.isArray(value)) return "array";
|
|
16
|
+
if (type === "object" && value !== null) return "object";
|
|
17
|
+
|
|
18
|
+
// For strings, check if they look like other types
|
|
19
|
+
if (type === "string") {
|
|
20
|
+
const strValue = value;
|
|
21
|
+
|
|
22
|
+
// Check if it looks like JSON
|
|
23
|
+
if (strValue.startsWith("{") && strValue.endsWith("}") || strValue.startsWith("[") && strValue.endsWith("]")) {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse(strValue);
|
|
26
|
+
return Array.isArray(parsed) ? "array" : "object";
|
|
27
|
+
} catch {
|
|
28
|
+
return "string";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Check if it's a boolean string
|
|
33
|
+
const lowerStr = strValue.toLowerCase();
|
|
34
|
+
if (lowerStr === "true" || lowerStr === "false" || lowerStr === "enabled" || lowerStr === "disabled" || lowerStr === "yes" || lowerStr === "no" || lowerStr === "on" || lowerStr === "off") {
|
|
35
|
+
return "boolean";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Check if it's a number string (including 1 and 0 as numbers, not booleans)
|
|
39
|
+
if (!isNaN(Number(strValue)) && strValue.trim() !== "") {
|
|
40
|
+
return "number";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Check if it's a URL
|
|
44
|
+
if (strValue.startsWith("http://") || strValue.startsWith("https://")) {
|
|
45
|
+
return "url";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Check if it's a comma-separated array
|
|
49
|
+
if (strValue.includes(",")) {
|
|
50
|
+
return "array";
|
|
51
|
+
}
|
|
52
|
+
return "string";
|
|
53
|
+
}
|
|
54
|
+
return "unknown";
|
|
55
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Helper to create a required env var configuration with type checking
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const config = envVar("EXPO_PUBLIC_API_URL")
|
|
8
|
+
* .withType("string")
|
|
9
|
+
* .withDescription("Backend API endpoint")
|
|
10
|
+
* .build();
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const config = envVar("EXPO_PUBLIC_DEBUG_MODE")
|
|
14
|
+
* .withDescription("Enable debug logging")
|
|
15
|
+
* .withType("boolean")
|
|
16
|
+
* .build();
|
|
17
|
+
*/
|
|
18
|
+
class EnvVarBuilder {
|
|
19
|
+
constructor(key) {
|
|
20
|
+
this.key = key;
|
|
21
|
+
}
|
|
22
|
+
/** Just check if the variable exists */
|
|
23
|
+
exists() {
|
|
24
|
+
return this.key;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Check for a specific value */
|
|
28
|
+
withValue(value) {
|
|
29
|
+
this.expectedValue = value;
|
|
30
|
+
delete this.expectedType; // Can't have both type and value
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Check for a specific type */
|
|
35
|
+
withType(type) {
|
|
36
|
+
this.expectedType = type;
|
|
37
|
+
delete this.expectedValue; // Can't have both type and value
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Add a description for documentation */
|
|
42
|
+
withDescription(desc) {
|
|
43
|
+
this.description = desc;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Build the final configuration */
|
|
48
|
+
build() {
|
|
49
|
+
if (this.expectedValue !== undefined) {
|
|
50
|
+
return this.description ? {
|
|
51
|
+
key: this.key,
|
|
52
|
+
expectedValue: this.expectedValue,
|
|
53
|
+
description: this.description
|
|
54
|
+
} : {
|
|
55
|
+
key: this.key,
|
|
56
|
+
expectedValue: this.expectedValue
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (this.expectedType !== undefined) {
|
|
60
|
+
return this.description ? {
|
|
61
|
+
key: this.key,
|
|
62
|
+
expectedType: this.expectedType,
|
|
63
|
+
description: this.description
|
|
64
|
+
} : {
|
|
65
|
+
key: this.key,
|
|
66
|
+
expectedType: this.expectedType
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// If neither type nor value is specified, just check existence
|
|
71
|
+
return this.key;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Fluent builder for defining expected environment variables. Helps teams author readable
|
|
77
|
+
* `requiredEnvVars` arrays by chaining type/value/description requirements while keeping the
|
|
78
|
+
* final shape compatible with `EnvVarsModal` and related helpers.
|
|
79
|
+
*
|
|
80
|
+
* @param key - Environment variable name to validate.
|
|
81
|
+
* @returns Builder with convenience methods like `.withType()` and `.withValue()`.
|
|
82
|
+
*/
|
|
83
|
+
export function envVar(key) {
|
|
84
|
+
return new EnvVarBuilder(key);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Normalizes `requiredEnvVars` definitions while documenting intent in code. The helper simply
|
|
89
|
+
* returns the provided array, but allows teams to co-locate examples and benefit from IDE hovers.
|
|
90
|
+
*
|
|
91
|
+
* @param vars - Collection of required environment variable definitions created manually or via `envVar()`.
|
|
92
|
+
* @returns The original array, unchanged, for ergonomic chaining and inference.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* const requiredEnvVars = createEnvVarConfig([
|
|
96
|
+
* // Simple existence check
|
|
97
|
+
* "EXPO_PUBLIC_API_URL",
|
|
98
|
+
*
|
|
99
|
+
* // Type checking
|
|
100
|
+
* { key: "EXPO_PUBLIC_DEBUG_MODE", expectedType: "boolean" },
|
|
101
|
+
*
|
|
102
|
+
* // Value checking
|
|
103
|
+
* { key: "EXPO_PUBLIC_ENVIRONMENT", expectedValue: "development" },
|
|
104
|
+
*
|
|
105
|
+
* // With descriptions
|
|
106
|
+
* envVar("EXPO_PUBLIC_MAX_RETRIES")
|
|
107
|
+
* .withType("number")
|
|
108
|
+
* .withDescription("Maximum number of API retry attempts")
|
|
109
|
+
* .build(),
|
|
110
|
+
* ]);
|
|
111
|
+
*/
|
|
112
|
+
export function createEnvVarConfig(vars) {
|
|
113
|
+
return vars;
|
|
114
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getEnvVarType } from "./envTypeDetector";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Combines the auto-detected runtime environment values with the declared `requiredEnvVars`
|
|
7
|
+
* configuration and produces categorized metadata for rendering in the UI.
|
|
8
|
+
*
|
|
9
|
+
* @param autoCollectedEnvVars - Values discovered via `useDynamicEnv` (key/value string map).
|
|
10
|
+
* @param requiredEnvVars - Optional list of required variables describing expectations to validate.
|
|
11
|
+
* @returns Required and optional variable collections annotated with validation status.
|
|
12
|
+
*/
|
|
13
|
+
export const processEnvVars = (autoCollectedEnvVars, requiredEnvVars) => {
|
|
14
|
+
const requiredVarInfos = [];
|
|
15
|
+
const optionalVarInfos = [];
|
|
16
|
+
const processedKeys = new Set();
|
|
17
|
+
|
|
18
|
+
// Process required variables
|
|
19
|
+
requiredEnvVars?.forEach(envVar => {
|
|
20
|
+
const key = typeof envVar === "string" ? envVar : envVar.key;
|
|
21
|
+
const expectedValue = typeof envVar === "object" && "expectedValue" in envVar ? envVar.expectedValue : undefined;
|
|
22
|
+
const expectedType = typeof envVar === "object" && "expectedType" in envVar ? envVar.expectedType : undefined;
|
|
23
|
+
const description = typeof envVar === "object" && "description" in envVar ? envVar.description : undefined;
|
|
24
|
+
processedKeys.add(key);
|
|
25
|
+
const actualValue = autoCollectedEnvVars[key];
|
|
26
|
+
const isPresent = actualValue !== undefined;
|
|
27
|
+
let status;
|
|
28
|
+
if (!isPresent) {
|
|
29
|
+
status = "required_missing";
|
|
30
|
+
} else if (expectedValue) {
|
|
31
|
+
// Handle different expectedValue patterns
|
|
32
|
+
let valueMatches = false;
|
|
33
|
+
if (expectedValue === "sk_*") {
|
|
34
|
+
valueMatches = actualValue.startsWith("sk_");
|
|
35
|
+
} else if (expectedValue === "production or development") {
|
|
36
|
+
valueMatches = actualValue === "production" || actualValue === "development";
|
|
37
|
+
} else {
|
|
38
|
+
valueMatches = actualValue === expectedValue;
|
|
39
|
+
}
|
|
40
|
+
status = valueMatches ? "required_present" : "required_wrong_value";
|
|
41
|
+
} else if (expectedType && getEnvVarType(actualValue).toLowerCase() !== expectedType.toLowerCase()) {
|
|
42
|
+
status = "required_wrong_type";
|
|
43
|
+
} else {
|
|
44
|
+
status = "required_present";
|
|
45
|
+
}
|
|
46
|
+
requiredVarInfos.push({
|
|
47
|
+
key,
|
|
48
|
+
value: actualValue,
|
|
49
|
+
expectedValue,
|
|
50
|
+
expectedType,
|
|
51
|
+
description,
|
|
52
|
+
status,
|
|
53
|
+
category: "required"
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Process optional variables (those that exist but aren't required)
|
|
58
|
+
Object.entries(autoCollectedEnvVars).forEach(([key, value]) => {
|
|
59
|
+
if (!processedKeys.has(key)) {
|
|
60
|
+
optionalVarInfos.push({
|
|
61
|
+
key,
|
|
62
|
+
value,
|
|
63
|
+
status: "optional_present",
|
|
64
|
+
category: "optional"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Sort each category
|
|
70
|
+
requiredVarInfos.sort((a, b) => {
|
|
71
|
+
const statusOrder = {
|
|
72
|
+
required_missing: 0,
|
|
73
|
+
required_wrong_value: 1,
|
|
74
|
+
required_wrong_type: 2,
|
|
75
|
+
required_present: 3,
|
|
76
|
+
optional_present: 4
|
|
77
|
+
};
|
|
78
|
+
if (statusOrder[a.status] !== statusOrder[b.status]) {
|
|
79
|
+
return statusOrder[a.status] - statusOrder[b.status];
|
|
80
|
+
}
|
|
81
|
+
return a.key.localeCompare(b.key);
|
|
82
|
+
});
|
|
83
|
+
optionalVarInfos.sort((a, b) => a.key.localeCompare(b.key));
|
|
84
|
+
return {
|
|
85
|
+
requiredVars: requiredVarInfos,
|
|
86
|
+
optionalVars: optionalVarInfos
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Derives aggregate statistics from the processed environment variable lists for health badges
|
|
92
|
+
* and summary chips in the modal UI.
|
|
93
|
+
*
|
|
94
|
+
* @param requiredVars - Processed required variables with validation state.
|
|
95
|
+
* @param optionalVars - Processed optional variables discovered at runtime.
|
|
96
|
+
* @param totalEnvVars - Raw key/value map of every detected environment variable.
|
|
97
|
+
* @returns Counts related to overall env health for display purposes.
|
|
98
|
+
*/
|
|
99
|
+
export const calculateStats = (requiredVars, optionalVars, totalEnvVars) => {
|
|
100
|
+
const totalCount = Object.keys(totalEnvVars).length;
|
|
101
|
+
const requiredCount = requiredVars.length;
|
|
102
|
+
const missingCount = requiredVars.filter(v => v.status === "required_missing").length;
|
|
103
|
+
const wrongValueCount = requiredVars.filter(v => v.status === "required_wrong_value").length;
|
|
104
|
+
const wrongTypeCount = requiredVars.filter(v => v.status === "required_wrong_type").length;
|
|
105
|
+
const presentRequiredCount = requiredVars.filter(v => v.status === "required_present").length;
|
|
106
|
+
const optionalCount = optionalVars.length;
|
|
107
|
+
return {
|
|
108
|
+
totalCount,
|
|
109
|
+
requiredCount,
|
|
110
|
+
missingCount,
|
|
111
|
+
wrongValueCount,
|
|
112
|
+
wrongTypeCount,
|
|
113
|
+
presentRequiredCount,
|
|
114
|
+
optionalCount
|
|
115
|
+
};
|
|
116
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Export preset configuration (easiest way to add to FloatingDevTools!)
|
|
4
|
+
export { envToolPreset, createEnvTool } from "./preset";
|
|
5
|
+
|
|
6
|
+
// Export main modal component
|
|
7
|
+
export { EnvVarsModal } from "./env/components/EnvVarsModal";
|
|
8
|
+
|
|
9
|
+
// Export types (Environment, UserRole, RequiredEnvVar, etc.)
|
|
10
|
+
export * from "./env/types";
|
|
11
|
+
|
|
12
|
+
// Export utilities (createEnvVarConfig, envVar, etc.)
|
|
13
|
+
export * from "./env/utils";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-configured environment variables tool for FloatingDevTools
|
|
5
|
+
*
|
|
6
|
+
* This preset provides a zero-config way to add env var inspection to your dev tools.
|
|
7
|
+
* Just import and add it to your apps array!
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { envToolPreset } from '@buoy-gg/env';
|
|
12
|
+
*
|
|
13
|
+
* const installedApps = [
|
|
14
|
+
* envToolPreset, // That's it!
|
|
15
|
+
* // ...other tools
|
|
16
|
+
* ];
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { EnvIcon } from "@buoy-gg/floating-tools-core";
|
|
21
|
+
import { EnvVarsModal } from "./env/components/EnvVarsModal";
|
|
22
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
+
/**
|
|
24
|
+
* Pre-configured environment variables tool for FloatingDevTools.
|
|
25
|
+
* Includes:
|
|
26
|
+
* - Automatic env var discovery
|
|
27
|
+
* - Required variable validation
|
|
28
|
+
* - Search and filtering
|
|
29
|
+
* - Copy functionality
|
|
30
|
+
*/
|
|
31
|
+
export const envToolPreset = {
|
|
32
|
+
id: "env",
|
|
33
|
+
name: "ENV",
|
|
34
|
+
description: "Environment variables debugger",
|
|
35
|
+
slot: "both",
|
|
36
|
+
icon: ({
|
|
37
|
+
size
|
|
38
|
+
}) => /*#__PURE__*/_jsx(EnvIcon, {
|
|
39
|
+
size: size
|
|
40
|
+
}),
|
|
41
|
+
component: EnvVarsModal,
|
|
42
|
+
props: {
|
|
43
|
+
requiredEnvVars: [],
|
|
44
|
+
enableSharedModalDimensions: true
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create a custom environment variables tool configuration.
|
|
50
|
+
* Use this if you want to override default settings or provide required env vars.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* import { createEnvTool, envVar, createEnvVarConfig } from '@buoy-gg/env';
|
|
55
|
+
*
|
|
56
|
+
* const requiredEnvVars = createEnvVarConfig([
|
|
57
|
+
* envVar("EXPO_PUBLIC_API_URL").exists(),
|
|
58
|
+
* envVar("EXPO_PUBLIC_DEBUG_MODE").withType("boolean").build(),
|
|
59
|
+
* ]);
|
|
60
|
+
*
|
|
61
|
+
* const myEnvTool = createEnvTool({
|
|
62
|
+
* requiredEnvVars,
|
|
63
|
+
* colorPreset: "cyan",
|
|
64
|
+
* enableSharedModalDimensions: true,
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function createEnvTool(options) {
|
|
69
|
+
return {
|
|
70
|
+
id: options?.id || "env",
|
|
71
|
+
name: options?.name || "ENV",
|
|
72
|
+
description: options?.description || "Environment variables debugger",
|
|
73
|
+
slot: "both",
|
|
74
|
+
icon: ({
|
|
75
|
+
size
|
|
76
|
+
}) => /*#__PURE__*/_jsx(EnvIcon, {
|
|
77
|
+
size: size
|
|
78
|
+
}),
|
|
79
|
+
component: EnvVarsModal,
|
|
80
|
+
props: {
|
|
81
|
+
requiredEnvVars: options?.requiredEnvVars || [],
|
|
82
|
+
enableSharedModalDimensions: options?.enableSharedModalDimensions !== undefined ? options.enableSharedModalDimensions : true
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main entry point for the Environment Variables feature
|
|
3
|
+
* This component orchestrates all env-related functionality
|
|
4
|
+
*/
|
|
5
|
+
export type { RequiredEnvVar, EnvVarInfo, EnvVarStats, EnvVarType, } from "./types";
|
|
6
|
+
export { envVar, createEnvVarConfig } from "./utils/helpers";
|
|
7
|
+
export { EnvVarsModal } from "./components/EnvVarsModal";
|
|
8
|
+
//# sourceMappingURL=EnvVariables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvVariables.d.ts","sourceRoot":"","sources":["../../../src/env/EnvVariables.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type EnvFilterType = "all" | "missing" | "issues";
|
|
2
|
+
interface EnvStatsOverviewProps {
|
|
3
|
+
stats: {
|
|
4
|
+
totalCount: number;
|
|
5
|
+
requiredCount: number;
|
|
6
|
+
optionalCount: number;
|
|
7
|
+
presentRequiredCount: number;
|
|
8
|
+
missingCount: number;
|
|
9
|
+
wrongValueCount: number;
|
|
10
|
+
wrongTypeCount: number;
|
|
11
|
+
};
|
|
12
|
+
healthPercentage: number;
|
|
13
|
+
healthStatus: string;
|
|
14
|
+
healthColor: string;
|
|
15
|
+
activeFilter?: EnvFilterType;
|
|
16
|
+
onFilterChange?: (filter: EnvFilterType) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function EnvStatsOverview({ stats, healthPercentage, healthStatus, healthColor, activeFilter, onFilterChange, }: EnvStatsOverviewProps): import("react").JSX.Element;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=EnvStatsOverview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvStatsOverview.d.ts","sourceRoot":"","sources":["../../../../src/env/components/EnvStatsOverview.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEzD,UAAU,qBAAqB;IAC7B,KAAK,EAAE;QACL,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAoB,EACpB,cAAc,GACf,EAAE,qBAAqB,+BA+GvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EnvVarInfo } from "../types";
|
|
2
|
+
interface EnvVarRowProps {
|
|
3
|
+
envVar: EnvVarInfo;
|
|
4
|
+
isExpanded?: boolean;
|
|
5
|
+
onPress?: (envVar: EnvVarInfo) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function EnvVarRow({ envVar, isExpanded, onPress }: EnvVarRowProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=EnvVarRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvVarRow.d.ts","sourceRoot":"","sources":["../../../../src/env/components/EnvVarRow.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,UAAU,cAAc;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAkDD,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,cAAc,+BAgExE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EnvVarInfo } from "../types";
|
|
2
|
+
interface EnvVarSectionProps {
|
|
3
|
+
title: string;
|
|
4
|
+
count: number;
|
|
5
|
+
vars: EnvVarInfo[];
|
|
6
|
+
emptyMessage: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function EnvVarSection({ title, count, vars, emptyMessage, }: EnvVarSectionProps): import("react").JSX.Element | null;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=EnvVarSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvVarSection.d.ts","sourceRoot":"","sources":["../../../../src/env/components/EnvVarSection.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,GACb,EAAE,kBAAkB,sCA2CpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RequiredEnvVar } from "../types";
|
|
2
|
+
interface EnvVarsModalProps {
|
|
3
|
+
/** Controls the visibility of the modal. */
|
|
4
|
+
visible: boolean;
|
|
5
|
+
/** Callback executed when the modal is dismissed. */
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
/** List of required environment variables to validate against the runtime values. */
|
|
8
|
+
requiredEnvVars: RequiredEnvVar[];
|
|
9
|
+
/** Optional handler fired when navigating back to the parent surface. */
|
|
10
|
+
onBack?: () => void;
|
|
11
|
+
/** Optional handler fired when the modal is minimized. */
|
|
12
|
+
onMinimize?: (modalState: any) => void;
|
|
13
|
+
/**
|
|
14
|
+
* When true, reuse the shared modal sizing keys so multiple dev tools can
|
|
15
|
+
* persist their window dimensions in a single location.
|
|
16
|
+
*/
|
|
17
|
+
enableSharedModalDimensions?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Full-screen modal for inspecting required environment variables. Handles automatic
|
|
21
|
+
* discovery, validation, filtering, and rich search so teams can quickly spot missing
|
|
22
|
+
* or misconfigured values during development sessions.
|
|
23
|
+
*/
|
|
24
|
+
export declare function EnvVarsModal({ visible, onClose, requiredEnvVars, onBack, onMinimize, enableSharedModalDimensions, }: EnvVarsModalProps): import("react").JSX.Element | null;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=EnvVarsModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvVarsModal.d.ts","sourceRoot":"","sources":["../../../../src/env/components/EnvVarsModal.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAc,MAAM,UAAU,CAAC;AAUtD,UAAU,iBAAiB;IACzB,4CAA4C;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,qDAAqD;IACrD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qFAAqF;IACrF,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,OAAO,EACP,eAAe,EACf,MAAM,EACN,UAAU,EACV,2BAAmC,GACpC,EAAE,iBAAiB,sCAgPnB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
interface UseDynamicEnvOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Optional filter function to determine which env vars to include
|
|
4
|
+
* Note: Only EXPO_PUBLIC_ prefixed variables are available in process.env
|
|
5
|
+
*/
|
|
6
|
+
envFilter?: (key: string, value: string | undefined) => boolean;
|
|
7
|
+
}
|
|
8
|
+
interface EnvResult {
|
|
9
|
+
key: string;
|
|
10
|
+
data: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Hook that returns all available environment variables with parsed values
|
|
14
|
+
* Includes all available environment variables by default (only EXPO_PUBLIC_ prefixed vars are loaded by Expo)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Get all available environment variables (only EXPO_PUBLIC_ prefixed)
|
|
18
|
+
* const envVars = useDynamicEnv();
|
|
19
|
+
* // Returns: [
|
|
20
|
+
* // { key: 'EXPO_PUBLIC_API_URL', data: 'https://api.example.com' },
|
|
21
|
+
* // { key: 'EXPO_PUBLIC_APP_NAME', data: 'MyApp' },
|
|
22
|
+
* // ...
|
|
23
|
+
* // ]
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Filter to specific variables
|
|
27
|
+
* const envVars = useDynamicEnv({
|
|
28
|
+
* envFilter: (key) => key.includes('API') || key.includes('URL')
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Filter by value content
|
|
33
|
+
* const envVars = useDynamicEnv({
|
|
34
|
+
* envFilter: (key, value) => value !== undefined && value.length > 0
|
|
35
|
+
* });
|
|
36
|
+
*/
|
|
37
|
+
export declare function useDynamicEnv({ envFilter, }?: UseDynamicEnvOptions): EnvResult[];
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=useDynamicEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDynamicEnv.d.ts","sourceRoot":"","sources":["../../../../src/env/hooks/useDynamicEnv.ts"],"names":[],"mappings":"AAEA,UAAU,oBAAoB;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC;CACjE;AAED,UAAU,SAAS;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAsB,GACvB,GAAE,oBAAyB,GAAG,SAAS,EAAE,CAyDzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/env/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/env/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported environment variable types that can be automatically detected
|
|
3
|
+
*/
|
|
4
|
+
export type EnvVarType = "string" | "number" | "boolean" | "array" | "object" | "url";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for a required environment variable
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Simple string check (just check if it exists)
|
|
10
|
+
* "EXPO_PUBLIC_API_URL"
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Check for specific value
|
|
14
|
+
* { key: "EXPO_PUBLIC_ENVIRONMENT", expectedValue: "development" }
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Check for specific type
|
|
18
|
+
* { key: "EXPO_PUBLIC_DEBUG_MODE", expectedType: "boolean" }
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // With description for documentation
|
|
22
|
+
* {
|
|
23
|
+
* key: "EXPO_PUBLIC_API_URL",
|
|
24
|
+
* expectedType: "string",
|
|
25
|
+
* description: "Backend API endpoint URL"
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
export type RequiredEnvVar = string | {
|
|
29
|
+
/** The environment variable key/name */
|
|
30
|
+
key: string;
|
|
31
|
+
/** Expected exact value for this variable */
|
|
32
|
+
expectedValue: string;
|
|
33
|
+
/** Optional description for documentation */
|
|
34
|
+
description?: string;
|
|
35
|
+
} | {
|
|
36
|
+
/** The environment variable key/name */
|
|
37
|
+
key: string;
|
|
38
|
+
/** Expected type for this variable */
|
|
39
|
+
expectedType: EnvVarType;
|
|
40
|
+
/** Optional description for documentation */
|
|
41
|
+
description?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Internal representation of environment variable information
|
|
45
|
+
*/
|
|
46
|
+
export interface EnvVarInfo {
|
|
47
|
+
key: string;
|
|
48
|
+
value: unknown;
|
|
49
|
+
expectedValue?: string;
|
|
50
|
+
expectedType?: EnvVarType;
|
|
51
|
+
description?: string;
|
|
52
|
+
status: "required_present" | "required_missing" | "required_wrong_value" | "required_wrong_type" | "optional_present";
|
|
53
|
+
category: "required" | "optional";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Statistics about environment variables
|
|
57
|
+
*/
|
|
58
|
+
export interface EnvVarStats {
|
|
59
|
+
totalCount: number;
|
|
60
|
+
requiredCount: number;
|
|
61
|
+
missingCount: number;
|
|
62
|
+
wrongValueCount: number;
|
|
63
|
+
wrongTypeCount: number;
|
|
64
|
+
presentRequiredCount: number;
|
|
65
|
+
optionalCount: number;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/env/types/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,OAAO,GACP,QAAQ,GACR,KAAK,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,cAAc,GACtB,MAAM,GACN;IACE,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACD;IACE,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,YAAY,EAAE,UAAU,CAAC;IACzB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EACF,kBAAkB,GAClB,kBAAkB,GAClB,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,CAAC;IACvB,QAAQ,EAAE,UAAU,GAAG,UAAU,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userTypes.d.ts","sourceRoot":"","sources":["../../../../src/env/types/userTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EnvVarType } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Detects the type of an environment variable value
|
|
4
|
+
* First checks if useDynamicEnv already parsed it to the correct type,
|
|
5
|
+
* then analyzes string content to detect what type it represents
|
|
6
|
+
*
|
|
7
|
+
* @returns One of: "string", "number", "boolean", "array", "object"
|
|
8
|
+
*/
|
|
9
|
+
export declare function getEnvVarType(value: unknown): EnvVarType | "unknown";
|
|
10
|
+
//# sourceMappingURL=envTypeDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envTypeDetector.d.ts","sourceRoot":"","sources":["../../../../src/env/utils/envTypeDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CA4DpE"}
|