@karmaniverous/get-dotenv 3.1.18 → 4.0.0-0
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 +55 -190
- package/dist/getdotenv.cli.mjs +26495 -0
- package/dist/index.cjs +26499 -0
- package/dist/index.d.cts +234 -0
- package/dist/index.d.mts +234 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.mjs +26493 -0
- package/package.json +104 -65
- package/bin/getdotenv/index.js +0 -8
- package/dist/default/lib/dotenvExpand.js +0 -67
- package/dist/default/lib/getDotenv.js +0 -228
- package/dist/default/lib/getDotenvCli.js +0 -202
- package/dist/default/lib/index.js +0 -38
- package/dist/default/lib/options.js +0 -45
- package/dist/default/lib/readDotenv.js +0 -47
- package/dist/package.json +0 -3
- package/getdotenv.config.json +0 -24
- package/lib/dotenvExpand.js +0 -63
- package/lib/getDotenv.js +0 -280
- package/lib/getDotenvCli.js +0 -475
- package/lib/index.js +0 -3
- package/lib/options.js +0 -80
- package/lib/readDotenv.js +0 -39
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { Command } from '@commander-js/extra-typings';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options passed programmatically to `getDotenvCli`.
|
|
5
|
+
*/
|
|
6
|
+
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
7
|
+
/**
|
|
8
|
+
* Logs CLI internals when true.
|
|
9
|
+
*/
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A delimited string of paths to dotenv files.
|
|
13
|
+
*/
|
|
14
|
+
paths?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A delimiter string with which to split `paths`. Only used if
|
|
17
|
+
* `pathsDelimiterPattern` is not provided.
|
|
18
|
+
*/
|
|
19
|
+
pathsDelimiter?: string;
|
|
20
|
+
/**
|
|
21
|
+
* A regular expression pattern with which to split `paths`. Supersedes
|
|
22
|
+
* `pathsDelimiter`.
|
|
23
|
+
*/
|
|
24
|
+
pathsDelimiterPattern?: string;
|
|
25
|
+
/**
|
|
26
|
+
* A delimited string of key-value pairs declaratively specifying variables &
|
|
27
|
+
* values to be loaded in addition to any dotenv files.
|
|
28
|
+
*/
|
|
29
|
+
vars?: string;
|
|
30
|
+
/**
|
|
31
|
+
* A string with which to split keys from values in `vars`. Only used if
|
|
32
|
+
* `varsDelimiterPattern` is not provided.
|
|
33
|
+
*/
|
|
34
|
+
varsAssignor?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A regular expression pattern with which to split variable names from values
|
|
37
|
+
* in `vars`. Supersedes `varsAssignor`.
|
|
38
|
+
*/
|
|
39
|
+
varsAssignorPattern?: string;
|
|
40
|
+
/**
|
|
41
|
+
* A string with which to split `vars` into key-value pairs. Only used if
|
|
42
|
+
* `varsDelimiterPattern` is not provided.
|
|
43
|
+
*/
|
|
44
|
+
varsDelimiter?: string;
|
|
45
|
+
/**
|
|
46
|
+
* A regular expression pattern with which to split `vars` into key-value
|
|
47
|
+
* pairs. Supersedes `varsDelimiter`.
|
|
48
|
+
*/
|
|
49
|
+
varsDelimiterPattern?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type ProcessEnv = Record<string, string | undefined>;
|
|
53
|
+
type GetDotenvDynamicFunction = (vars: ProcessEnv) => string | undefined;
|
|
54
|
+
type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
|
|
55
|
+
type Logger = Record<string, (...args: unknown[]) => void>;
|
|
56
|
+
/**
|
|
57
|
+
* Options passed programmatically to `getDotenv` and `getDotEnvSync`.
|
|
58
|
+
*/
|
|
59
|
+
interface GetDotenvOptions {
|
|
60
|
+
/**
|
|
61
|
+
* default target environment (used if `env` is not provided)
|
|
62
|
+
*/
|
|
63
|
+
defaultEnv?: string;
|
|
64
|
+
/**
|
|
65
|
+
* token indicating a dotenv file
|
|
66
|
+
*/
|
|
67
|
+
dotenvToken?: string;
|
|
68
|
+
/**
|
|
69
|
+
* path to file exporting an object keyed to dynamic variable functions
|
|
70
|
+
*/
|
|
71
|
+
dynamicPath?: string;
|
|
72
|
+
/**
|
|
73
|
+
* target environment
|
|
74
|
+
*/
|
|
75
|
+
env?: string;
|
|
76
|
+
/**
|
|
77
|
+
* exclude dynamic variables
|
|
78
|
+
*/
|
|
79
|
+
excludeDynamic?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* exclude environment-specific variables
|
|
82
|
+
*/
|
|
83
|
+
excludeEnv?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* exclude global variables
|
|
86
|
+
*/
|
|
87
|
+
excludeGlobal?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* exclude private variables
|
|
90
|
+
*/
|
|
91
|
+
excludePrivate?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* exclude public variables
|
|
94
|
+
*/
|
|
95
|
+
excludePublic?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* load dotenv to process.env
|
|
98
|
+
*/
|
|
99
|
+
loadProcess?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* log result to logger
|
|
102
|
+
*/
|
|
103
|
+
log?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* logger object (defaults to console)
|
|
106
|
+
*/
|
|
107
|
+
logger?: Logger;
|
|
108
|
+
/**
|
|
109
|
+
* if populated, writes consolidated .env file to this path (follows dotenvExpand rules)
|
|
110
|
+
*/
|
|
111
|
+
outputPath?: string;
|
|
112
|
+
/**
|
|
113
|
+
* array of input directory paths
|
|
114
|
+
*/
|
|
115
|
+
paths?: string[];
|
|
116
|
+
/**
|
|
117
|
+
* filename token indicating private variables
|
|
118
|
+
*/
|
|
119
|
+
privateToken?: string;
|
|
120
|
+
/**
|
|
121
|
+
* explicit variables to include
|
|
122
|
+
*/
|
|
123
|
+
vars?: ProcessEnv;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Recursively expands environment variables in a string. Variables may be
|
|
128
|
+
* presented with optional default as `$VAR[:default]` or `${VAR[:default]}`.
|
|
129
|
+
* Unknown variables will expand to an empty string.
|
|
130
|
+
*
|
|
131
|
+
* @param value - The string to expand.
|
|
132
|
+
* @param ref - The reference object to use for variable expansion.
|
|
133
|
+
* @returns The expanded string.
|
|
134
|
+
*/
|
|
135
|
+
declare const dotenvExpand: (value: string | undefined, ref?: ProcessEnv) => string | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Recursively expands environment variables in the values of a JSON object.
|
|
138
|
+
* Variables may be presented with optional default as `$VAR[:default]` or
|
|
139
|
+
* `${VAR[:default]}`. Unknown variables will expand to an empty string.
|
|
140
|
+
*
|
|
141
|
+
* @param value - The string to expand.
|
|
142
|
+
* @param ref - The reference object to use for variable expansion.
|
|
143
|
+
* @param progressive - Whether to progressively add expanded values to the
|
|
144
|
+
* set of reference keys.
|
|
145
|
+
* @returns The value object with expanded string values.
|
|
146
|
+
*/
|
|
147
|
+
declare const dotenvExpandAll: (values?: ProcessEnv, { ref, progressive, }?: {
|
|
148
|
+
ref?: ProcessEnv;
|
|
149
|
+
progressive?: boolean;
|
|
150
|
+
}) => Record<string, string | undefined>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* GetDotenv CLI Pre-hook Callback function type. Mutates inbound options &
|
|
154
|
+
* executes side effects within the `getDotenv` context.
|
|
155
|
+
*/
|
|
156
|
+
type GetDotenvCliPreHookCallback = (options: GetDotenvCliOptions) => Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* GetDotenv CLI Post-hook Callback function type. Executes side effects within
|
|
159
|
+
* the `getDotenv` context.
|
|
160
|
+
*/
|
|
161
|
+
type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* `generateGetDotenvCli` options. Defines local instance of the GetDotenv CLI and
|
|
164
|
+
* sets defaults that can be overridden by local `getdotenv.config.json` in
|
|
165
|
+
* projects that import the CLI.
|
|
166
|
+
*/
|
|
167
|
+
interface GetDotenvCliGenerateOptions extends Omit<GetDotenvCliOptions, 'env'> {
|
|
168
|
+
/**
|
|
169
|
+
* Cli alias. Should align with the `bin` property in `package.json`.
|
|
170
|
+
*/
|
|
171
|
+
alias?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Cli description (appears in CLI help).
|
|
174
|
+
*/
|
|
175
|
+
description?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Mutates inbound options & executes side effects within the `getDotenv`
|
|
178
|
+
* context before executing CLI commands.
|
|
179
|
+
*/
|
|
180
|
+
preHook?: GetDotenvCliPreHookCallback;
|
|
181
|
+
/**
|
|
182
|
+
* Executes side effects within the `getDotenv` context after executing CLI
|
|
183
|
+
* commands.
|
|
184
|
+
*/
|
|
185
|
+
postHook?: GetDotenvCliPostHookCallback;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Generate a Commander CLI Command for get-dotenv.
|
|
189
|
+
*/
|
|
190
|
+
declare const generateGetDotenvCli: ({ logger, preHook, postHook, ...cliOptionsCustom }?: GetDotenvCliGenerateOptions) => Command<[], {
|
|
191
|
+
env?: string | undefined;
|
|
192
|
+
vars?: string | undefined;
|
|
193
|
+
command?: string | undefined;
|
|
194
|
+
outputPath?: string | undefined;
|
|
195
|
+
loadProcess?: true | undefined;
|
|
196
|
+
loadProcessOff?: true | undefined;
|
|
197
|
+
excludeAll?: true | undefined;
|
|
198
|
+
excludeAllOff?: true | undefined;
|
|
199
|
+
excludeDynamic?: true | undefined;
|
|
200
|
+
excludeDynamicOff?: true | undefined;
|
|
201
|
+
excludeEnv?: true | undefined;
|
|
202
|
+
excludeEnvOff?: true | undefined;
|
|
203
|
+
excludeGlobal?: true | undefined;
|
|
204
|
+
excludeGlobalOff?: true | undefined;
|
|
205
|
+
excludePrivate?: true | undefined;
|
|
206
|
+
excludePrivateOff?: true | undefined;
|
|
207
|
+
excludePublic?: true | undefined;
|
|
208
|
+
excludePublicOff?: true | undefined;
|
|
209
|
+
log?: true | undefined;
|
|
210
|
+
logOff?: true | undefined;
|
|
211
|
+
debug?: true | undefined;
|
|
212
|
+
debugOff?: true | undefined;
|
|
213
|
+
defaultEnv?: string | undefined;
|
|
214
|
+
dotenvToken?: string | undefined;
|
|
215
|
+
dynamicPath?: string | undefined;
|
|
216
|
+
paths?: string | undefined;
|
|
217
|
+
pathsDelimiter: string;
|
|
218
|
+
pathsDelimiterPattern: string;
|
|
219
|
+
privateToken?: string | undefined;
|
|
220
|
+
varsDelimiter: string;
|
|
221
|
+
varsDelimiterPattern: string;
|
|
222
|
+
varsAssignor: string;
|
|
223
|
+
varsAssignorPattern: string;
|
|
224
|
+
}>;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Asynchronously process dotenv files of the form `.env[.<ENV>][.<PRIVATE_TOKEN>]`
|
|
228
|
+
*
|
|
229
|
+
* @param options - `GetDotenvOptions` object
|
|
230
|
+
* @returns The combined parsed dotenv object.
|
|
231
|
+
*/
|
|
232
|
+
declare const getDotenv: (options?: GetDotenvOptions) => Promise<ProcessEnv>;
|
|
233
|
+
|
|
234
|
+
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, generateGetDotenvCli, getDotenv };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { Command } from '@commander-js/extra-typings';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options passed programmatically to `getDotenvCli`.
|
|
5
|
+
*/
|
|
6
|
+
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
7
|
+
/**
|
|
8
|
+
* Logs CLI internals when true.
|
|
9
|
+
*/
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A delimited string of paths to dotenv files.
|
|
13
|
+
*/
|
|
14
|
+
paths?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A delimiter string with which to split `paths`. Only used if
|
|
17
|
+
* `pathsDelimiterPattern` is not provided.
|
|
18
|
+
*/
|
|
19
|
+
pathsDelimiter?: string;
|
|
20
|
+
/**
|
|
21
|
+
* A regular expression pattern with which to split `paths`. Supersedes
|
|
22
|
+
* `pathsDelimiter`.
|
|
23
|
+
*/
|
|
24
|
+
pathsDelimiterPattern?: string;
|
|
25
|
+
/**
|
|
26
|
+
* A delimited string of key-value pairs declaratively specifying variables &
|
|
27
|
+
* values to be loaded in addition to any dotenv files.
|
|
28
|
+
*/
|
|
29
|
+
vars?: string;
|
|
30
|
+
/**
|
|
31
|
+
* A string with which to split keys from values in `vars`. Only used if
|
|
32
|
+
* `varsDelimiterPattern` is not provided.
|
|
33
|
+
*/
|
|
34
|
+
varsAssignor?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A regular expression pattern with which to split variable names from values
|
|
37
|
+
* in `vars`. Supersedes `varsAssignor`.
|
|
38
|
+
*/
|
|
39
|
+
varsAssignorPattern?: string;
|
|
40
|
+
/**
|
|
41
|
+
* A string with which to split `vars` into key-value pairs. Only used if
|
|
42
|
+
* `varsDelimiterPattern` is not provided.
|
|
43
|
+
*/
|
|
44
|
+
varsDelimiter?: string;
|
|
45
|
+
/**
|
|
46
|
+
* A regular expression pattern with which to split `vars` into key-value
|
|
47
|
+
* pairs. Supersedes `varsDelimiter`.
|
|
48
|
+
*/
|
|
49
|
+
varsDelimiterPattern?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type ProcessEnv = Record<string, string | undefined>;
|
|
53
|
+
type GetDotenvDynamicFunction = (vars: ProcessEnv) => string | undefined;
|
|
54
|
+
type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
|
|
55
|
+
type Logger = Record<string, (...args: unknown[]) => void>;
|
|
56
|
+
/**
|
|
57
|
+
* Options passed programmatically to `getDotenv` and `getDotEnvSync`.
|
|
58
|
+
*/
|
|
59
|
+
interface GetDotenvOptions {
|
|
60
|
+
/**
|
|
61
|
+
* default target environment (used if `env` is not provided)
|
|
62
|
+
*/
|
|
63
|
+
defaultEnv?: string;
|
|
64
|
+
/**
|
|
65
|
+
* token indicating a dotenv file
|
|
66
|
+
*/
|
|
67
|
+
dotenvToken?: string;
|
|
68
|
+
/**
|
|
69
|
+
* path to file exporting an object keyed to dynamic variable functions
|
|
70
|
+
*/
|
|
71
|
+
dynamicPath?: string;
|
|
72
|
+
/**
|
|
73
|
+
* target environment
|
|
74
|
+
*/
|
|
75
|
+
env?: string;
|
|
76
|
+
/**
|
|
77
|
+
* exclude dynamic variables
|
|
78
|
+
*/
|
|
79
|
+
excludeDynamic?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* exclude environment-specific variables
|
|
82
|
+
*/
|
|
83
|
+
excludeEnv?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* exclude global variables
|
|
86
|
+
*/
|
|
87
|
+
excludeGlobal?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* exclude private variables
|
|
90
|
+
*/
|
|
91
|
+
excludePrivate?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* exclude public variables
|
|
94
|
+
*/
|
|
95
|
+
excludePublic?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* load dotenv to process.env
|
|
98
|
+
*/
|
|
99
|
+
loadProcess?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* log result to logger
|
|
102
|
+
*/
|
|
103
|
+
log?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* logger object (defaults to console)
|
|
106
|
+
*/
|
|
107
|
+
logger?: Logger;
|
|
108
|
+
/**
|
|
109
|
+
* if populated, writes consolidated .env file to this path (follows dotenvExpand rules)
|
|
110
|
+
*/
|
|
111
|
+
outputPath?: string;
|
|
112
|
+
/**
|
|
113
|
+
* array of input directory paths
|
|
114
|
+
*/
|
|
115
|
+
paths?: string[];
|
|
116
|
+
/**
|
|
117
|
+
* filename token indicating private variables
|
|
118
|
+
*/
|
|
119
|
+
privateToken?: string;
|
|
120
|
+
/**
|
|
121
|
+
* explicit variables to include
|
|
122
|
+
*/
|
|
123
|
+
vars?: ProcessEnv;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Recursively expands environment variables in a string. Variables may be
|
|
128
|
+
* presented with optional default as `$VAR[:default]` or `${VAR[:default]}`.
|
|
129
|
+
* Unknown variables will expand to an empty string.
|
|
130
|
+
*
|
|
131
|
+
* @param value - The string to expand.
|
|
132
|
+
* @param ref - The reference object to use for variable expansion.
|
|
133
|
+
* @returns The expanded string.
|
|
134
|
+
*/
|
|
135
|
+
declare const dotenvExpand: (value: string | undefined, ref?: ProcessEnv) => string | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Recursively expands environment variables in the values of a JSON object.
|
|
138
|
+
* Variables may be presented with optional default as `$VAR[:default]` or
|
|
139
|
+
* `${VAR[:default]}`. Unknown variables will expand to an empty string.
|
|
140
|
+
*
|
|
141
|
+
* @param value - The string to expand.
|
|
142
|
+
* @param ref - The reference object to use for variable expansion.
|
|
143
|
+
* @param progressive - Whether to progressively add expanded values to the
|
|
144
|
+
* set of reference keys.
|
|
145
|
+
* @returns The value object with expanded string values.
|
|
146
|
+
*/
|
|
147
|
+
declare const dotenvExpandAll: (values?: ProcessEnv, { ref, progressive, }?: {
|
|
148
|
+
ref?: ProcessEnv;
|
|
149
|
+
progressive?: boolean;
|
|
150
|
+
}) => Record<string, string | undefined>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* GetDotenv CLI Pre-hook Callback function type. Mutates inbound options &
|
|
154
|
+
* executes side effects within the `getDotenv` context.
|
|
155
|
+
*/
|
|
156
|
+
type GetDotenvCliPreHookCallback = (options: GetDotenvCliOptions) => Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* GetDotenv CLI Post-hook Callback function type. Executes side effects within
|
|
159
|
+
* the `getDotenv` context.
|
|
160
|
+
*/
|
|
161
|
+
type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* `generateGetDotenvCli` options. Defines local instance of the GetDotenv CLI and
|
|
164
|
+
* sets defaults that can be overridden by local `getdotenv.config.json` in
|
|
165
|
+
* projects that import the CLI.
|
|
166
|
+
*/
|
|
167
|
+
interface GetDotenvCliGenerateOptions extends Omit<GetDotenvCliOptions, 'env'> {
|
|
168
|
+
/**
|
|
169
|
+
* Cli alias. Should align with the `bin` property in `package.json`.
|
|
170
|
+
*/
|
|
171
|
+
alias?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Cli description (appears in CLI help).
|
|
174
|
+
*/
|
|
175
|
+
description?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Mutates inbound options & executes side effects within the `getDotenv`
|
|
178
|
+
* context before executing CLI commands.
|
|
179
|
+
*/
|
|
180
|
+
preHook?: GetDotenvCliPreHookCallback;
|
|
181
|
+
/**
|
|
182
|
+
* Executes side effects within the `getDotenv` context after executing CLI
|
|
183
|
+
* commands.
|
|
184
|
+
*/
|
|
185
|
+
postHook?: GetDotenvCliPostHookCallback;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Generate a Commander CLI Command for get-dotenv.
|
|
189
|
+
*/
|
|
190
|
+
declare const generateGetDotenvCli: ({ logger, preHook, postHook, ...cliOptionsCustom }?: GetDotenvCliGenerateOptions) => Command<[], {
|
|
191
|
+
env?: string | undefined;
|
|
192
|
+
vars?: string | undefined;
|
|
193
|
+
command?: string | undefined;
|
|
194
|
+
outputPath?: string | undefined;
|
|
195
|
+
loadProcess?: true | undefined;
|
|
196
|
+
loadProcessOff?: true | undefined;
|
|
197
|
+
excludeAll?: true | undefined;
|
|
198
|
+
excludeAllOff?: true | undefined;
|
|
199
|
+
excludeDynamic?: true | undefined;
|
|
200
|
+
excludeDynamicOff?: true | undefined;
|
|
201
|
+
excludeEnv?: true | undefined;
|
|
202
|
+
excludeEnvOff?: true | undefined;
|
|
203
|
+
excludeGlobal?: true | undefined;
|
|
204
|
+
excludeGlobalOff?: true | undefined;
|
|
205
|
+
excludePrivate?: true | undefined;
|
|
206
|
+
excludePrivateOff?: true | undefined;
|
|
207
|
+
excludePublic?: true | undefined;
|
|
208
|
+
excludePublicOff?: true | undefined;
|
|
209
|
+
log?: true | undefined;
|
|
210
|
+
logOff?: true | undefined;
|
|
211
|
+
debug?: true | undefined;
|
|
212
|
+
debugOff?: true | undefined;
|
|
213
|
+
defaultEnv?: string | undefined;
|
|
214
|
+
dotenvToken?: string | undefined;
|
|
215
|
+
dynamicPath?: string | undefined;
|
|
216
|
+
paths?: string | undefined;
|
|
217
|
+
pathsDelimiter: string;
|
|
218
|
+
pathsDelimiterPattern: string;
|
|
219
|
+
privateToken?: string | undefined;
|
|
220
|
+
varsDelimiter: string;
|
|
221
|
+
varsDelimiterPattern: string;
|
|
222
|
+
varsAssignor: string;
|
|
223
|
+
varsAssignorPattern: string;
|
|
224
|
+
}>;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Asynchronously process dotenv files of the form `.env[.<ENV>][.<PRIVATE_TOKEN>]`
|
|
228
|
+
*
|
|
229
|
+
* @param options - `GetDotenvOptions` object
|
|
230
|
+
* @returns The combined parsed dotenv object.
|
|
231
|
+
*/
|
|
232
|
+
declare const getDotenv: (options?: GetDotenvOptions) => Promise<ProcessEnv>;
|
|
233
|
+
|
|
234
|
+
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, generateGetDotenvCli, getDotenv };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { Command } from '@commander-js/extra-typings';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options passed programmatically to `getDotenvCli`.
|
|
5
|
+
*/
|
|
6
|
+
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
7
|
+
/**
|
|
8
|
+
* Logs CLI internals when true.
|
|
9
|
+
*/
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A delimited string of paths to dotenv files.
|
|
13
|
+
*/
|
|
14
|
+
paths?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A delimiter string with which to split `paths`. Only used if
|
|
17
|
+
* `pathsDelimiterPattern` is not provided.
|
|
18
|
+
*/
|
|
19
|
+
pathsDelimiter?: string;
|
|
20
|
+
/**
|
|
21
|
+
* A regular expression pattern with which to split `paths`. Supersedes
|
|
22
|
+
* `pathsDelimiter`.
|
|
23
|
+
*/
|
|
24
|
+
pathsDelimiterPattern?: string;
|
|
25
|
+
/**
|
|
26
|
+
* A delimited string of key-value pairs declaratively specifying variables &
|
|
27
|
+
* values to be loaded in addition to any dotenv files.
|
|
28
|
+
*/
|
|
29
|
+
vars?: string;
|
|
30
|
+
/**
|
|
31
|
+
* A string with which to split keys from values in `vars`. Only used if
|
|
32
|
+
* `varsDelimiterPattern` is not provided.
|
|
33
|
+
*/
|
|
34
|
+
varsAssignor?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A regular expression pattern with which to split variable names from values
|
|
37
|
+
* in `vars`. Supersedes `varsAssignor`.
|
|
38
|
+
*/
|
|
39
|
+
varsAssignorPattern?: string;
|
|
40
|
+
/**
|
|
41
|
+
* A string with which to split `vars` into key-value pairs. Only used if
|
|
42
|
+
* `varsDelimiterPattern` is not provided.
|
|
43
|
+
*/
|
|
44
|
+
varsDelimiter?: string;
|
|
45
|
+
/**
|
|
46
|
+
* A regular expression pattern with which to split `vars` into key-value
|
|
47
|
+
* pairs. Supersedes `varsDelimiter`.
|
|
48
|
+
*/
|
|
49
|
+
varsDelimiterPattern?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type ProcessEnv = Record<string, string | undefined>;
|
|
53
|
+
type GetDotenvDynamicFunction = (vars: ProcessEnv) => string | undefined;
|
|
54
|
+
type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
|
|
55
|
+
type Logger = Record<string, (...args: unknown[]) => void>;
|
|
56
|
+
/**
|
|
57
|
+
* Options passed programmatically to `getDotenv` and `getDotEnvSync`.
|
|
58
|
+
*/
|
|
59
|
+
interface GetDotenvOptions {
|
|
60
|
+
/**
|
|
61
|
+
* default target environment (used if `env` is not provided)
|
|
62
|
+
*/
|
|
63
|
+
defaultEnv?: string;
|
|
64
|
+
/**
|
|
65
|
+
* token indicating a dotenv file
|
|
66
|
+
*/
|
|
67
|
+
dotenvToken?: string;
|
|
68
|
+
/**
|
|
69
|
+
* path to file exporting an object keyed to dynamic variable functions
|
|
70
|
+
*/
|
|
71
|
+
dynamicPath?: string;
|
|
72
|
+
/**
|
|
73
|
+
* target environment
|
|
74
|
+
*/
|
|
75
|
+
env?: string;
|
|
76
|
+
/**
|
|
77
|
+
* exclude dynamic variables
|
|
78
|
+
*/
|
|
79
|
+
excludeDynamic?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* exclude environment-specific variables
|
|
82
|
+
*/
|
|
83
|
+
excludeEnv?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* exclude global variables
|
|
86
|
+
*/
|
|
87
|
+
excludeGlobal?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* exclude private variables
|
|
90
|
+
*/
|
|
91
|
+
excludePrivate?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* exclude public variables
|
|
94
|
+
*/
|
|
95
|
+
excludePublic?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* load dotenv to process.env
|
|
98
|
+
*/
|
|
99
|
+
loadProcess?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* log result to logger
|
|
102
|
+
*/
|
|
103
|
+
log?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* logger object (defaults to console)
|
|
106
|
+
*/
|
|
107
|
+
logger?: Logger;
|
|
108
|
+
/**
|
|
109
|
+
* if populated, writes consolidated .env file to this path (follows dotenvExpand rules)
|
|
110
|
+
*/
|
|
111
|
+
outputPath?: string;
|
|
112
|
+
/**
|
|
113
|
+
* array of input directory paths
|
|
114
|
+
*/
|
|
115
|
+
paths?: string[];
|
|
116
|
+
/**
|
|
117
|
+
* filename token indicating private variables
|
|
118
|
+
*/
|
|
119
|
+
privateToken?: string;
|
|
120
|
+
/**
|
|
121
|
+
* explicit variables to include
|
|
122
|
+
*/
|
|
123
|
+
vars?: ProcessEnv;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Recursively expands environment variables in a string. Variables may be
|
|
128
|
+
* presented with optional default as `$VAR[:default]` or `${VAR[:default]}`.
|
|
129
|
+
* Unknown variables will expand to an empty string.
|
|
130
|
+
*
|
|
131
|
+
* @param value - The string to expand.
|
|
132
|
+
* @param ref - The reference object to use for variable expansion.
|
|
133
|
+
* @returns The expanded string.
|
|
134
|
+
*/
|
|
135
|
+
declare const dotenvExpand: (value: string | undefined, ref?: ProcessEnv) => string | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Recursively expands environment variables in the values of a JSON object.
|
|
138
|
+
* Variables may be presented with optional default as `$VAR[:default]` or
|
|
139
|
+
* `${VAR[:default]}`. Unknown variables will expand to an empty string.
|
|
140
|
+
*
|
|
141
|
+
* @param value - The string to expand.
|
|
142
|
+
* @param ref - The reference object to use for variable expansion.
|
|
143
|
+
* @param progressive - Whether to progressively add expanded values to the
|
|
144
|
+
* set of reference keys.
|
|
145
|
+
* @returns The value object with expanded string values.
|
|
146
|
+
*/
|
|
147
|
+
declare const dotenvExpandAll: (values?: ProcessEnv, { ref, progressive, }?: {
|
|
148
|
+
ref?: ProcessEnv;
|
|
149
|
+
progressive?: boolean;
|
|
150
|
+
}) => Record<string, string | undefined>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* GetDotenv CLI Pre-hook Callback function type. Mutates inbound options &
|
|
154
|
+
* executes side effects within the `getDotenv` context.
|
|
155
|
+
*/
|
|
156
|
+
type GetDotenvCliPreHookCallback = (options: GetDotenvCliOptions) => Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* GetDotenv CLI Post-hook Callback function type. Executes side effects within
|
|
159
|
+
* the `getDotenv` context.
|
|
160
|
+
*/
|
|
161
|
+
type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* `generateGetDotenvCli` options. Defines local instance of the GetDotenv CLI and
|
|
164
|
+
* sets defaults that can be overridden by local `getdotenv.config.json` in
|
|
165
|
+
* projects that import the CLI.
|
|
166
|
+
*/
|
|
167
|
+
interface GetDotenvCliGenerateOptions extends Omit<GetDotenvCliOptions, 'env'> {
|
|
168
|
+
/**
|
|
169
|
+
* Cli alias. Should align with the `bin` property in `package.json`.
|
|
170
|
+
*/
|
|
171
|
+
alias?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Cli description (appears in CLI help).
|
|
174
|
+
*/
|
|
175
|
+
description?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Mutates inbound options & executes side effects within the `getDotenv`
|
|
178
|
+
* context before executing CLI commands.
|
|
179
|
+
*/
|
|
180
|
+
preHook?: GetDotenvCliPreHookCallback;
|
|
181
|
+
/**
|
|
182
|
+
* Executes side effects within the `getDotenv` context after executing CLI
|
|
183
|
+
* commands.
|
|
184
|
+
*/
|
|
185
|
+
postHook?: GetDotenvCliPostHookCallback;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Generate a Commander CLI Command for get-dotenv.
|
|
189
|
+
*/
|
|
190
|
+
declare const generateGetDotenvCli: ({ logger, preHook, postHook, ...cliOptionsCustom }?: GetDotenvCliGenerateOptions) => Command<[], {
|
|
191
|
+
env?: string | undefined;
|
|
192
|
+
vars?: string | undefined;
|
|
193
|
+
command?: string | undefined;
|
|
194
|
+
outputPath?: string | undefined;
|
|
195
|
+
loadProcess?: true | undefined;
|
|
196
|
+
loadProcessOff?: true | undefined;
|
|
197
|
+
excludeAll?: true | undefined;
|
|
198
|
+
excludeAllOff?: true | undefined;
|
|
199
|
+
excludeDynamic?: true | undefined;
|
|
200
|
+
excludeDynamicOff?: true | undefined;
|
|
201
|
+
excludeEnv?: true | undefined;
|
|
202
|
+
excludeEnvOff?: true | undefined;
|
|
203
|
+
excludeGlobal?: true | undefined;
|
|
204
|
+
excludeGlobalOff?: true | undefined;
|
|
205
|
+
excludePrivate?: true | undefined;
|
|
206
|
+
excludePrivateOff?: true | undefined;
|
|
207
|
+
excludePublic?: true | undefined;
|
|
208
|
+
excludePublicOff?: true | undefined;
|
|
209
|
+
log?: true | undefined;
|
|
210
|
+
logOff?: true | undefined;
|
|
211
|
+
debug?: true | undefined;
|
|
212
|
+
debugOff?: true | undefined;
|
|
213
|
+
defaultEnv?: string | undefined;
|
|
214
|
+
dotenvToken?: string | undefined;
|
|
215
|
+
dynamicPath?: string | undefined;
|
|
216
|
+
paths?: string | undefined;
|
|
217
|
+
pathsDelimiter: string;
|
|
218
|
+
pathsDelimiterPattern: string;
|
|
219
|
+
privateToken?: string | undefined;
|
|
220
|
+
varsDelimiter: string;
|
|
221
|
+
varsDelimiterPattern: string;
|
|
222
|
+
varsAssignor: string;
|
|
223
|
+
varsAssignorPattern: string;
|
|
224
|
+
}>;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Asynchronously process dotenv files of the form `.env[.<ENV>][.<PRIVATE_TOKEN>]`
|
|
228
|
+
*
|
|
229
|
+
* @param options - `GetDotenvOptions` object
|
|
230
|
+
* @returns The combined parsed dotenv object.
|
|
231
|
+
*/
|
|
232
|
+
declare const getDotenv: (options?: GetDotenvOptions) => Promise<ProcessEnv>;
|
|
233
|
+
|
|
234
|
+
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, generateGetDotenvCli, getDotenv };
|