@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,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createEnvVarConfig = createEnvVarConfig;
|
|
7
|
+
exports.envVar = envVar;
|
|
8
|
+
/**
|
|
9
|
+
* Helper to create a required env var configuration with type checking
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const config = envVar("EXPO_PUBLIC_API_URL")
|
|
13
|
+
* .withType("string")
|
|
14
|
+
* .withDescription("Backend API endpoint")
|
|
15
|
+
* .build();
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const config = envVar("EXPO_PUBLIC_DEBUG_MODE")
|
|
19
|
+
* .withDescription("Enable debug logging")
|
|
20
|
+
* .withType("boolean")
|
|
21
|
+
* .build();
|
|
22
|
+
*/
|
|
23
|
+
class EnvVarBuilder {
|
|
24
|
+
constructor(key) {
|
|
25
|
+
this.key = key;
|
|
26
|
+
}
|
|
27
|
+
/** Just check if the variable exists */
|
|
28
|
+
exists() {
|
|
29
|
+
return this.key;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Check for a specific value */
|
|
33
|
+
withValue(value) {
|
|
34
|
+
this.expectedValue = value;
|
|
35
|
+
delete this.expectedType; // Can't have both type and value
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Check for a specific type */
|
|
40
|
+
withType(type) {
|
|
41
|
+
this.expectedType = type;
|
|
42
|
+
delete this.expectedValue; // Can't have both type and value
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Add a description for documentation */
|
|
47
|
+
withDescription(desc) {
|
|
48
|
+
this.description = desc;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Build the final configuration */
|
|
53
|
+
build() {
|
|
54
|
+
if (this.expectedValue !== undefined) {
|
|
55
|
+
return this.description ? {
|
|
56
|
+
key: this.key,
|
|
57
|
+
expectedValue: this.expectedValue,
|
|
58
|
+
description: this.description
|
|
59
|
+
} : {
|
|
60
|
+
key: this.key,
|
|
61
|
+
expectedValue: this.expectedValue
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (this.expectedType !== undefined) {
|
|
65
|
+
return this.description ? {
|
|
66
|
+
key: this.key,
|
|
67
|
+
expectedType: this.expectedType,
|
|
68
|
+
description: this.description
|
|
69
|
+
} : {
|
|
70
|
+
key: this.key,
|
|
71
|
+
expectedType: this.expectedType
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// If neither type nor value is specified, just check existence
|
|
76
|
+
return this.key;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Fluent builder for defining expected environment variables. Helps teams author readable
|
|
82
|
+
* `requiredEnvVars` arrays by chaining type/value/description requirements while keeping the
|
|
83
|
+
* final shape compatible with `EnvVarsModal` and related helpers.
|
|
84
|
+
*
|
|
85
|
+
* @param key - Environment variable name to validate.
|
|
86
|
+
* @returns Builder with convenience methods like `.withType()` and `.withValue()`.
|
|
87
|
+
*/
|
|
88
|
+
function envVar(key) {
|
|
89
|
+
return new EnvVarBuilder(key);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Normalizes `requiredEnvVars` definitions while documenting intent in code. The helper simply
|
|
94
|
+
* returns the provided array, but allows teams to co-locate examples and benefit from IDE hovers.
|
|
95
|
+
*
|
|
96
|
+
* @param vars - Collection of required environment variable definitions created manually or via `envVar()`.
|
|
97
|
+
* @returns The original array, unchanged, for ergonomic chaining and inference.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const requiredEnvVars = createEnvVarConfig([
|
|
101
|
+
* // Simple existence check
|
|
102
|
+
* "EXPO_PUBLIC_API_URL",
|
|
103
|
+
*
|
|
104
|
+
* // Type checking
|
|
105
|
+
* { key: "EXPO_PUBLIC_DEBUG_MODE", expectedType: "boolean" },
|
|
106
|
+
*
|
|
107
|
+
* // Value checking
|
|
108
|
+
* { key: "EXPO_PUBLIC_ENVIRONMENT", expectedValue: "development" },
|
|
109
|
+
*
|
|
110
|
+
* // With descriptions
|
|
111
|
+
* envVar("EXPO_PUBLIC_MAX_RETRIES")
|
|
112
|
+
* .withType("number")
|
|
113
|
+
* .withDescription("Maximum number of API retry attempts")
|
|
114
|
+
* .build(),
|
|
115
|
+
* ]);
|
|
116
|
+
*/
|
|
117
|
+
function createEnvVarConfig(vars) {
|
|
118
|
+
return vars;
|
|
119
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _envTypeDetector = require("./envTypeDetector");
|
|
7
|
+
Object.keys(_envTypeDetector).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _envTypeDetector[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _envTypeDetector[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _helpers = require("./helpers");
|
|
18
|
+
Object.keys(_helpers).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _helpers[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _helpers[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _utils = require("./utils");
|
|
29
|
+
Object.keys(_utils).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _utils[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.processEnvVars = exports.calculateStats = void 0;
|
|
7
|
+
var _envTypeDetector = require("./envTypeDetector");
|
|
8
|
+
/**
|
|
9
|
+
* Combines the auto-detected runtime environment values with the declared `requiredEnvVars`
|
|
10
|
+
* configuration and produces categorized metadata for rendering in the UI.
|
|
11
|
+
*
|
|
12
|
+
* @param autoCollectedEnvVars - Values discovered via `useDynamicEnv` (key/value string map).
|
|
13
|
+
* @param requiredEnvVars - Optional list of required variables describing expectations to validate.
|
|
14
|
+
* @returns Required and optional variable collections annotated with validation status.
|
|
15
|
+
*/
|
|
16
|
+
const processEnvVars = (autoCollectedEnvVars, requiredEnvVars) => {
|
|
17
|
+
const requiredVarInfos = [];
|
|
18
|
+
const optionalVarInfos = [];
|
|
19
|
+
const processedKeys = new Set();
|
|
20
|
+
|
|
21
|
+
// Process required variables
|
|
22
|
+
requiredEnvVars?.forEach(envVar => {
|
|
23
|
+
const key = typeof envVar === "string" ? envVar : envVar.key;
|
|
24
|
+
const expectedValue = typeof envVar === "object" && "expectedValue" in envVar ? envVar.expectedValue : undefined;
|
|
25
|
+
const expectedType = typeof envVar === "object" && "expectedType" in envVar ? envVar.expectedType : undefined;
|
|
26
|
+
const description = typeof envVar === "object" && "description" in envVar ? envVar.description : undefined;
|
|
27
|
+
processedKeys.add(key);
|
|
28
|
+
const actualValue = autoCollectedEnvVars[key];
|
|
29
|
+
const isPresent = actualValue !== undefined;
|
|
30
|
+
let status;
|
|
31
|
+
if (!isPresent) {
|
|
32
|
+
status = "required_missing";
|
|
33
|
+
} else if (expectedValue) {
|
|
34
|
+
// Handle different expectedValue patterns
|
|
35
|
+
let valueMatches = false;
|
|
36
|
+
if (expectedValue === "sk_*") {
|
|
37
|
+
valueMatches = actualValue.startsWith("sk_");
|
|
38
|
+
} else if (expectedValue === "production or development") {
|
|
39
|
+
valueMatches = actualValue === "production" || actualValue === "development";
|
|
40
|
+
} else {
|
|
41
|
+
valueMatches = actualValue === expectedValue;
|
|
42
|
+
}
|
|
43
|
+
status = valueMatches ? "required_present" : "required_wrong_value";
|
|
44
|
+
} else if (expectedType && (0, _envTypeDetector.getEnvVarType)(actualValue).toLowerCase() !== expectedType.toLowerCase()) {
|
|
45
|
+
status = "required_wrong_type";
|
|
46
|
+
} else {
|
|
47
|
+
status = "required_present";
|
|
48
|
+
}
|
|
49
|
+
requiredVarInfos.push({
|
|
50
|
+
key,
|
|
51
|
+
value: actualValue,
|
|
52
|
+
expectedValue,
|
|
53
|
+
expectedType,
|
|
54
|
+
description,
|
|
55
|
+
status,
|
|
56
|
+
category: "required"
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Process optional variables (those that exist but aren't required)
|
|
61
|
+
Object.entries(autoCollectedEnvVars).forEach(([key, value]) => {
|
|
62
|
+
if (!processedKeys.has(key)) {
|
|
63
|
+
optionalVarInfos.push({
|
|
64
|
+
key,
|
|
65
|
+
value,
|
|
66
|
+
status: "optional_present",
|
|
67
|
+
category: "optional"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Sort each category
|
|
73
|
+
requiredVarInfos.sort((a, b) => {
|
|
74
|
+
const statusOrder = {
|
|
75
|
+
required_missing: 0,
|
|
76
|
+
required_wrong_value: 1,
|
|
77
|
+
required_wrong_type: 2,
|
|
78
|
+
required_present: 3,
|
|
79
|
+
optional_present: 4
|
|
80
|
+
};
|
|
81
|
+
if (statusOrder[a.status] !== statusOrder[b.status]) {
|
|
82
|
+
return statusOrder[a.status] - statusOrder[b.status];
|
|
83
|
+
}
|
|
84
|
+
return a.key.localeCompare(b.key);
|
|
85
|
+
});
|
|
86
|
+
optionalVarInfos.sort((a, b) => a.key.localeCompare(b.key));
|
|
87
|
+
return {
|
|
88
|
+
requiredVars: requiredVarInfos,
|
|
89
|
+
optionalVars: optionalVarInfos
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Derives aggregate statistics from the processed environment variable lists for health badges
|
|
95
|
+
* and summary chips in the modal UI.
|
|
96
|
+
*
|
|
97
|
+
* @param requiredVars - Processed required variables with validation state.
|
|
98
|
+
* @param optionalVars - Processed optional variables discovered at runtime.
|
|
99
|
+
* @param totalEnvVars - Raw key/value map of every detected environment variable.
|
|
100
|
+
* @returns Counts related to overall env health for display purposes.
|
|
101
|
+
*/
|
|
102
|
+
exports.processEnvVars = processEnvVars;
|
|
103
|
+
const calculateStats = (requiredVars, optionalVars, totalEnvVars) => {
|
|
104
|
+
const totalCount = Object.keys(totalEnvVars).length;
|
|
105
|
+
const requiredCount = requiredVars.length;
|
|
106
|
+
const missingCount = requiredVars.filter(v => v.status === "required_missing").length;
|
|
107
|
+
const wrongValueCount = requiredVars.filter(v => v.status === "required_wrong_value").length;
|
|
108
|
+
const wrongTypeCount = requiredVars.filter(v => v.status === "required_wrong_type").length;
|
|
109
|
+
const presentRequiredCount = requiredVars.filter(v => v.status === "required_present").length;
|
|
110
|
+
const optionalCount = optionalVars.length;
|
|
111
|
+
return {
|
|
112
|
+
totalCount,
|
|
113
|
+
requiredCount,
|
|
114
|
+
missingCount,
|
|
115
|
+
wrongValueCount,
|
|
116
|
+
wrongTypeCount,
|
|
117
|
+
presentRequiredCount,
|
|
118
|
+
optionalCount
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
exports.calculateStats = calculateStats;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
envToolPreset: true,
|
|
8
|
+
createEnvTool: true,
|
|
9
|
+
EnvVarsModal: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "EnvVarsModal", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _EnvVarsModal.EnvVarsModal;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createEnvTool", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _preset.createEnvTool;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "envToolPreset", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _preset.envToolPreset;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var _preset = require("./preset");
|
|
30
|
+
var _EnvVarsModal = require("./env/components/EnvVarsModal");
|
|
31
|
+
var _types = require("./env/types");
|
|
32
|
+
Object.keys(_types).forEach(function (key) {
|
|
33
|
+
if (key === "default" || key === "__esModule") return;
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
35
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
36
|
+
Object.defineProperty(exports, key, {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _types[key];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
var _utils = require("./env/utils");
|
|
44
|
+
Object.keys(_utils).forEach(function (key) {
|
|
45
|
+
if (key === "default" || key === "__esModule") return;
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
47
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
48
|
+
Object.defineProperty(exports, key, {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _utils[key];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createEnvTool = createEnvTool;
|
|
7
|
+
exports.envToolPreset = void 0;
|
|
8
|
+
var _floatingToolsCore = require("@buoy-gg/floating-tools-core");
|
|
9
|
+
var _EnvVarsModal = require("./env/components/EnvVarsModal");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
/**
|
|
12
|
+
* Pre-configured environment variables tool for FloatingDevTools
|
|
13
|
+
*
|
|
14
|
+
* This preset provides a zero-config way to add env var inspection to your dev tools.
|
|
15
|
+
* Just import and add it to your apps array!
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { envToolPreset } from '@buoy-gg/env';
|
|
20
|
+
*
|
|
21
|
+
* const installedApps = [
|
|
22
|
+
* envToolPreset, // That's it!
|
|
23
|
+
* // ...other tools
|
|
24
|
+
* ];
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Pre-configured environment variables tool for FloatingDevTools.
|
|
30
|
+
* Includes:
|
|
31
|
+
* - Automatic env var discovery
|
|
32
|
+
* - Required variable validation
|
|
33
|
+
* - Search and filtering
|
|
34
|
+
* - Copy functionality
|
|
35
|
+
*/
|
|
36
|
+
const envToolPreset = exports.envToolPreset = {
|
|
37
|
+
id: "env",
|
|
38
|
+
name: "ENV",
|
|
39
|
+
description: "Environment variables debugger",
|
|
40
|
+
slot: "both",
|
|
41
|
+
icon: ({
|
|
42
|
+
size
|
|
43
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingToolsCore.EnvIcon, {
|
|
44
|
+
size: size
|
|
45
|
+
}),
|
|
46
|
+
component: _EnvVarsModal.EnvVarsModal,
|
|
47
|
+
props: {
|
|
48
|
+
requiredEnvVars: [],
|
|
49
|
+
enableSharedModalDimensions: true
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Create a custom environment variables tool configuration.
|
|
55
|
+
* Use this if you want to override default settings or provide required env vars.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* import { createEnvTool, envVar, createEnvVarConfig } from '@buoy-gg/env';
|
|
60
|
+
*
|
|
61
|
+
* const requiredEnvVars = createEnvVarConfig([
|
|
62
|
+
* envVar("EXPO_PUBLIC_API_URL").exists(),
|
|
63
|
+
* envVar("EXPO_PUBLIC_DEBUG_MODE").withType("boolean").build(),
|
|
64
|
+
* ]);
|
|
65
|
+
*
|
|
66
|
+
* const myEnvTool = createEnvTool({
|
|
67
|
+
* requiredEnvVars,
|
|
68
|
+
* colorPreset: "cyan",
|
|
69
|
+
* enableSharedModalDimensions: true,
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function createEnvTool(options) {
|
|
74
|
+
return {
|
|
75
|
+
id: options?.id || "env",
|
|
76
|
+
name: options?.name || "ENV",
|
|
77
|
+
description: options?.description || "Environment variables debugger",
|
|
78
|
+
slot: "both",
|
|
79
|
+
icon: ({
|
|
80
|
+
size
|
|
81
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingToolsCore.EnvIcon, {
|
|
82
|
+
size: size
|
|
83
|
+
}),
|
|
84
|
+
component: _EnvVarsModal.EnvVarsModal,
|
|
85
|
+
props: {
|
|
86
|
+
requiredEnvVars: options?.requiredEnvVars || [],
|
|
87
|
+
enableSharedModalDimensions: options?.enableSharedModalDimensions !== undefined ? options.enableSharedModalDimensions : true
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Main entry point for the Environment Variables feature
|
|
5
|
+
* This component orchestrates all env-related functionality
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Re-export only the public APIs that are actually used
|
|
9
|
+
|
|
10
|
+
export { envVar, createEnvVarConfig } from "./utils/helpers";
|
|
11
|
+
export { EnvVarsModal } from "./components/EnvVarsModal";
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
|
|
4
|
+
import { CompactRow, buoyColors } from "@buoy-gg/shared-ui";
|
|
5
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export function EnvStatsOverview({
|
|
7
|
+
stats,
|
|
8
|
+
healthPercentage,
|
|
9
|
+
healthStatus,
|
|
10
|
+
healthColor,
|
|
11
|
+
activeFilter = "all",
|
|
12
|
+
onFilterChange
|
|
13
|
+
}) {
|
|
14
|
+
const issuesCount = stats.wrongValueCount + stats.wrongTypeCount;
|
|
15
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
16
|
+
style: styles.container,
|
|
17
|
+
children: [/*#__PURE__*/_jsx(CompactRow, {
|
|
18
|
+
statusDotColor: healthColor,
|
|
19
|
+
statusLabel: "System",
|
|
20
|
+
statusSublabel: healthStatus.toLowerCase(),
|
|
21
|
+
primaryText: "Environment Configuration",
|
|
22
|
+
secondaryText: `${healthPercentage}% healthy`,
|
|
23
|
+
customBadge: /*#__PURE__*/_jsx(View, {
|
|
24
|
+
style: [styles.percentBadge, {
|
|
25
|
+
borderColor: healthColor + "40",
|
|
26
|
+
backgroundColor: healthColor + "10"
|
|
27
|
+
}],
|
|
28
|
+
children: /*#__PURE__*/_jsxs(Text, {
|
|
29
|
+
style: [styles.percentText, {
|
|
30
|
+
color: healthColor
|
|
31
|
+
}],
|
|
32
|
+
children: [healthPercentage, "%"]
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
36
|
+
style: styles.statsGrid,
|
|
37
|
+
children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
38
|
+
style: [styles.statCard, activeFilter === "all" && styles.statCardActive],
|
|
39
|
+
onPress: () => onFilterChange?.("all"),
|
|
40
|
+
activeOpacity: 0.8,
|
|
41
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
42
|
+
style: [styles.statValue, activeFilter === "all" && styles.statValueActive],
|
|
43
|
+
children: stats.requiredCount + stats.optionalCount
|
|
44
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
45
|
+
style: [styles.statLabel, activeFilter === "all" && styles.statLabelActive],
|
|
46
|
+
children: "ALL"
|
|
47
|
+
})]
|
|
48
|
+
}), /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
49
|
+
style: [styles.statCard, activeFilter === "missing" && styles.statCardActive],
|
|
50
|
+
onPress: () => onFilterChange?.("missing"),
|
|
51
|
+
activeOpacity: 0.8,
|
|
52
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
53
|
+
style: [styles.statValue, activeFilter === "missing" && styles.statValueActive],
|
|
54
|
+
children: stats.missingCount
|
|
55
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
56
|
+
style: [styles.statLabel, activeFilter === "missing" && styles.statLabelActive],
|
|
57
|
+
children: "MISSING"
|
|
58
|
+
})]
|
|
59
|
+
}), /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
60
|
+
style: [styles.statCard, activeFilter === "issues" && styles.statCardActive],
|
|
61
|
+
onPress: () => onFilterChange?.("issues"),
|
|
62
|
+
activeOpacity: 0.8,
|
|
63
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
64
|
+
style: [styles.statValue, activeFilter === "issues" && styles.statValueActive],
|
|
65
|
+
children: issuesCount
|
|
66
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
67
|
+
style: [styles.statLabel, activeFilter === "issues" && styles.statLabelActive],
|
|
68
|
+
children: "ISSUES"
|
|
69
|
+
})]
|
|
70
|
+
})]
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const styles = StyleSheet.create({
|
|
75
|
+
container: {
|
|
76
|
+
gap: 8
|
|
77
|
+
},
|
|
78
|
+
statsGrid: {
|
|
79
|
+
flexDirection: "row",
|
|
80
|
+
gap: 8,
|
|
81
|
+
paddingHorizontal: 4
|
|
82
|
+
},
|
|
83
|
+
statCard: {
|
|
84
|
+
flex: 1,
|
|
85
|
+
backgroundColor: buoyColors.card,
|
|
86
|
+
borderRadius: 10,
|
|
87
|
+
borderWidth: 1,
|
|
88
|
+
borderColor: buoyColors.border,
|
|
89
|
+
padding: 12,
|
|
90
|
+
alignItems: "center",
|
|
91
|
+
justifyContent: "center",
|
|
92
|
+
minHeight: 64
|
|
93
|
+
},
|
|
94
|
+
statCardActive: {
|
|
95
|
+
borderColor: buoyColors.primary,
|
|
96
|
+
backgroundColor: buoyColors.primary + "10"
|
|
97
|
+
},
|
|
98
|
+
statValue: {
|
|
99
|
+
fontSize: 22,
|
|
100
|
+
fontWeight: "700",
|
|
101
|
+
fontFamily: "monospace",
|
|
102
|
+
lineHeight: 26,
|
|
103
|
+
color: buoyColors.text
|
|
104
|
+
},
|
|
105
|
+
statValueActive: {
|
|
106
|
+
color: buoyColors.primary
|
|
107
|
+
},
|
|
108
|
+
statLabel: {
|
|
109
|
+
fontSize: 9,
|
|
110
|
+
color: buoyColors.textMuted,
|
|
111
|
+
marginTop: 4,
|
|
112
|
+
textTransform: "uppercase",
|
|
113
|
+
letterSpacing: 0.5,
|
|
114
|
+
fontWeight: "600"
|
|
115
|
+
},
|
|
116
|
+
statLabelActive: {
|
|
117
|
+
color: buoyColors.primary
|
|
118
|
+
},
|
|
119
|
+
percentBadge: {
|
|
120
|
+
paddingHorizontal: 8,
|
|
121
|
+
paddingVertical: 4,
|
|
122
|
+
borderRadius: 6,
|
|
123
|
+
borderWidth: 1
|
|
124
|
+
},
|
|
125
|
+
percentText: {
|
|
126
|
+
fontSize: 14,
|
|
127
|
+
fontWeight: "700",
|
|
128
|
+
fontFamily: "monospace"
|
|
129
|
+
}
|
|
130
|
+
});
|