@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,70 @@
|
|
|
1
|
+
import { RequiredEnvVar, EnvVarType } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Helper to create a required env var configuration with type checking
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const config = envVar("EXPO_PUBLIC_API_URL")
|
|
7
|
+
* .withType("string")
|
|
8
|
+
* .withDescription("Backend API endpoint")
|
|
9
|
+
* .build();
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const config = envVar("EXPO_PUBLIC_DEBUG_MODE")
|
|
13
|
+
* .withDescription("Enable debug logging")
|
|
14
|
+
* .withType("boolean")
|
|
15
|
+
* .build();
|
|
16
|
+
*/
|
|
17
|
+
declare class EnvVarBuilder {
|
|
18
|
+
private key;
|
|
19
|
+
constructor(key: string);
|
|
20
|
+
private expectedType?;
|
|
21
|
+
private expectedValue?;
|
|
22
|
+
private description?;
|
|
23
|
+
/** Just check if the variable exists */
|
|
24
|
+
exists(): RequiredEnvVar;
|
|
25
|
+
/** Check for a specific value */
|
|
26
|
+
withValue(value: string): this;
|
|
27
|
+
/** Check for a specific type */
|
|
28
|
+
withType(type: EnvVarType): this;
|
|
29
|
+
/** Add a description for documentation */
|
|
30
|
+
withDescription(desc: string): this;
|
|
31
|
+
/** Build the final configuration */
|
|
32
|
+
build(): RequiredEnvVar;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Fluent builder for defining expected environment variables. Helps teams author readable
|
|
36
|
+
* `requiredEnvVars` arrays by chaining type/value/description requirements while keeping the
|
|
37
|
+
* final shape compatible with `EnvVarsModal` and related helpers.
|
|
38
|
+
*
|
|
39
|
+
* @param key - Environment variable name to validate.
|
|
40
|
+
* @returns Builder with convenience methods like `.withType()` and `.withValue()`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function envVar(key: string): EnvVarBuilder;
|
|
43
|
+
/**
|
|
44
|
+
* Normalizes `requiredEnvVars` definitions while documenting intent in code. The helper simply
|
|
45
|
+
* returns the provided array, but allows teams to co-locate examples and benefit from IDE hovers.
|
|
46
|
+
*
|
|
47
|
+
* @param vars - Collection of required environment variable definitions created manually or via `envVar()`.
|
|
48
|
+
* @returns The original array, unchanged, for ergonomic chaining and inference.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* const requiredEnvVars = createEnvVarConfig([
|
|
52
|
+
* // Simple existence check
|
|
53
|
+
* "EXPO_PUBLIC_API_URL",
|
|
54
|
+
*
|
|
55
|
+
* // Type checking
|
|
56
|
+
* { key: "EXPO_PUBLIC_DEBUG_MODE", expectedType: "boolean" },
|
|
57
|
+
*
|
|
58
|
+
* // Value checking
|
|
59
|
+
* { key: "EXPO_PUBLIC_ENVIRONMENT", expectedValue: "development" },
|
|
60
|
+
*
|
|
61
|
+
* // With descriptions
|
|
62
|
+
* envVar("EXPO_PUBLIC_MAX_RETRIES")
|
|
63
|
+
* .withType("number")
|
|
64
|
+
* .withDescription("Maximum number of API retry attempts")
|
|
65
|
+
* .build(),
|
|
66
|
+
* ]);
|
|
67
|
+
*/
|
|
68
|
+
export declare function createEnvVarConfig(vars: RequiredEnvVar[]): RequiredEnvVar[];
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/env/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,cAAM,aAAa;IACL,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,MAAM;IAE/B,OAAO,CAAC,YAAY,CAAC,CAAa;IAClC,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B,wCAAwC;IACxC,MAAM,IAAI,cAAc;IAIxB,iCAAiC;IACjC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM9B,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAMhC,0CAA0C;IAC1C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKnC,oCAAoC;IACpC,KAAK,IAAI,cAAc;CAwBxB;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,iBAEjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAE3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/env/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EnvVarInfo, RequiredEnvVar, EnvVarStats } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Combines the auto-detected runtime environment values with the declared `requiredEnvVars`
|
|
4
|
+
* configuration and produces categorized metadata for rendering in the UI.
|
|
5
|
+
*
|
|
6
|
+
* @param autoCollectedEnvVars - Values discovered via `useDynamicEnv` (key/value string map).
|
|
7
|
+
* @param requiredEnvVars - Optional list of required variables describing expectations to validate.
|
|
8
|
+
* @returns Required and optional variable collections annotated with validation status.
|
|
9
|
+
*/
|
|
10
|
+
export declare const processEnvVars: (autoCollectedEnvVars: Record<string, string>, requiredEnvVars?: RequiredEnvVar[]) => {
|
|
11
|
+
requiredVars: EnvVarInfo[];
|
|
12
|
+
optionalVars: EnvVarInfo[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Derives aggregate statistics from the processed environment variable lists for health badges
|
|
16
|
+
* and summary chips in the modal UI.
|
|
17
|
+
*
|
|
18
|
+
* @param requiredVars - Processed required variables with validation state.
|
|
19
|
+
* @param optionalVars - Processed optional variables discovered at runtime.
|
|
20
|
+
* @param totalEnvVars - Raw key/value map of every detected environment variable.
|
|
21
|
+
* @returns Counts related to overall env health for display purposes.
|
|
22
|
+
*/
|
|
23
|
+
export declare const calculateStats: (requiredVars: EnvVarInfo[], optionalVars: EnvVarInfo[], totalEnvVars: Record<string, string>) => EnvVarStats;
|
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/env/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGnE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GACzB,sBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5C,kBAAkB,cAAc,EAAE;;;CA8FnC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GACzB,cAAc,UAAU,EAAE,EAC1B,cAAc,UAAU,EAAE,EAC1B,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACnC,WA0BF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,cAAc,aAAa,CAAC;AAG5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-configured environment variables tool for FloatingDevTools
|
|
3
|
+
*
|
|
4
|
+
* This preset provides a zero-config way to add env var inspection to your dev tools.
|
|
5
|
+
* Just import and add it to your apps array!
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { envToolPreset } from '@buoy-gg/env';
|
|
10
|
+
*
|
|
11
|
+
* const installedApps = [
|
|
12
|
+
* envToolPreset, // That's it!
|
|
13
|
+
* // ...other tools
|
|
14
|
+
* ];
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import { EnvVarsModal } from "./env/components/EnvVarsModal";
|
|
18
|
+
import type { RequiredEnvVar } from "./env/types";
|
|
19
|
+
/**
|
|
20
|
+
* Pre-configured environment variables tool for FloatingDevTools.
|
|
21
|
+
* Includes:
|
|
22
|
+
* - Automatic env var discovery
|
|
23
|
+
* - Required variable validation
|
|
24
|
+
* - Search and filtering
|
|
25
|
+
* - Copy functionality
|
|
26
|
+
*/
|
|
27
|
+
export declare const envToolPreset: {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
slot: "both";
|
|
32
|
+
icon: ({ size }: {
|
|
33
|
+
size: number;
|
|
34
|
+
}) => import("react").JSX.Element;
|
|
35
|
+
component: typeof EnvVarsModal;
|
|
36
|
+
props: {
|
|
37
|
+
requiredEnvVars: RequiredEnvVar[];
|
|
38
|
+
enableSharedModalDimensions: boolean;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Create a custom environment variables tool configuration.
|
|
43
|
+
* Use this if you want to override default settings or provide required env vars.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { createEnvTool, envVar, createEnvVarConfig } from '@buoy-gg/env';
|
|
48
|
+
*
|
|
49
|
+
* const requiredEnvVars = createEnvVarConfig([
|
|
50
|
+
* envVar("EXPO_PUBLIC_API_URL").exists(),
|
|
51
|
+
* envVar("EXPO_PUBLIC_DEBUG_MODE").withType("boolean").build(),
|
|
52
|
+
* ]);
|
|
53
|
+
*
|
|
54
|
+
* const myEnvTool = createEnvTool({
|
|
55
|
+
* requiredEnvVars,
|
|
56
|
+
* colorPreset: "cyan",
|
|
57
|
+
* enableSharedModalDimensions: true,
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function createEnvTool(options?: {
|
|
62
|
+
/** Tool name (default: "ENV") */
|
|
63
|
+
name?: string;
|
|
64
|
+
/** Tool description */
|
|
65
|
+
description?: string;
|
|
66
|
+
/** Custom tool ID (default: "env") */
|
|
67
|
+
id?: string;
|
|
68
|
+
/** Array of required environment variables to validate */
|
|
69
|
+
requiredEnvVars?: RequiredEnvVar[];
|
|
70
|
+
/** Enable shared modal dimensions */
|
|
71
|
+
enableSharedModalDimensions?: boolean;
|
|
72
|
+
}): {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
description: string;
|
|
76
|
+
slot: "both";
|
|
77
|
+
icon: ({ size }: {
|
|
78
|
+
size: number;
|
|
79
|
+
}) => import("react").JSX.Element;
|
|
80
|
+
component: typeof EnvVarsModal;
|
|
81
|
+
props: {
|
|
82
|
+
requiredEnvVars: RequiredEnvVar[];
|
|
83
|
+
enableSharedModalDimensions: boolean;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=preset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../src/preset.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;qBAKP;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;;;yBAGR,cAAc,EAAE;;;CAG1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE;IACtC,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,qCAAqC;IACrC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;;;;;qBAOoB;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;;;;;;EASpC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@buoy-gg/env",
|
|
3
|
+
"version": "1.7.2",
|
|
4
|
+
"description": "Environment variables dev tooling",
|
|
5
|
+
"main": "lib/commonjs/index.js",
|
|
6
|
+
"module": "lib/module/index.js",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index.tsx",
|
|
9
|
+
"source": "src/index.tsx",
|
|
10
|
+
"files": [
|
|
11
|
+
"lib"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "bob build",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"prepublishOnly": "bob build",
|
|
18
|
+
"clean": "rimraf lib",
|
|
19
|
+
"test": "pnpm run typecheck"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@buoy-gg/floating-tools-core": "workspace:*",
|
|
23
|
+
"@buoy-gg/shared-ui": "workspace:*"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "*",
|
|
27
|
+
"react-native": "*"
|
|
28
|
+
},
|
|
29
|
+
"react-native-builder-bob": {
|
|
30
|
+
"source": "src",
|
|
31
|
+
"output": "lib",
|
|
32
|
+
"targets": [
|
|
33
|
+
[
|
|
34
|
+
"commonjs",
|
|
35
|
+
{
|
|
36
|
+
"sourceMaps": false
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
"module",
|
|
41
|
+
{
|
|
42
|
+
"sourceMaps": false
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"typescript"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/react": "^19.1.0",
|
|
50
|
+
"@types/react-native": "^0.73.0",
|
|
51
|
+
"typescript": "~5.8.3"
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/LovesWorking/react-native-buoy.git",
|
|
56
|
+
"directory": "packages/env-tools"
|
|
57
|
+
},
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/LovesWorking/react-native-buoy/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/LovesWorking/react-native-buoy/tree/main/packages/env-tools#readme",
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public",
|
|
64
|
+
"tag": "latest"
|
|
65
|
+
}
|
|
66
|
+
}
|