@karmaniverous/get-dotenv 4.0.0-2 → 4.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 CHANGED
@@ -76,62 +76,56 @@ If the value corresponding to a key is a function, it will be executed with the
76
76
 
77
77
  Since keys will be evaluated progressively, each successive key function will have access to any previous ones. These keys can also override existing variables.
78
78
 
79
- ## More to Come!
80
-
81
- Implementation always runs a little behind documentation. These topics & improvements are coming soon:
82
-
83
- - An example of dotenv-based environment config.
84
- - Integrating `getdotenv` into your npm scripts.
85
- - Creating a `getdotenv`-based CLI.
86
- - Some gotchas & tips around managing your shell execution context.
87
-
88
- # Command Line Interface
89
-
90
- Note that the defaults below can be changed in your own environment by deriving your base CLI using the [`generateDotenvCli`](./src/generateGetDotenvCli.ts) function or placing a `getdotenv.options.json` file in your project root directory.
91
-
92
- ```text
93
- Usage: getdotenv [options] [command]
94
-
95
- Base CLI.
96
-
97
- Options:
98
- -e, --env <string> target environment (dotenv-expanded)
99
- -v, --vars <string> extra variables expressed as delimited key-value pairs (dotenv-expanded): KEY1=VAL1 KEY2=VAL2
100
- -c, --command <string> shell command string (dotenv-expanded)
101
- -o, --output-path <string> consolidated output file (dotenv-expanded)
102
- -p, --load-process load variables to process.env ON (default)
103
- -P, --load-process-off load variables to process.env OFF
104
- -a, --exclude-all exclude all dotenv variables from loading ON
105
- -A, --exclude-all-off exclude all dotenv variables from loading OFF (default)
106
- -z, --exclude-dynamic exclude dynamic dotenv variables from loading ON
107
- -Z, --exclude-dynamic-off exclude dynamic dotenv variables from loading OFF (default)
108
- -n, --exclude-env exclude environment-specific dotenv variables from loading
109
- -N, --exclude-env-off exclude environment-specific dotenv variables from loading OFF (default)
110
- -g, --exclude-global exclude global dotenv variables from loading ON
111
- -G, --exclude-global-off exclude global dotenv variables from loading OFF (default)
112
- -r, --exclude-private exclude private dotenv variables from loading ON
113
- -R, --exclude-private-off exclude private dotenv variables from loading OFF (default)
114
- -u, --exclude-public exclude public dotenv variables from loading ON
115
- -U, --exclude-public-off exclude public dotenv variables from loading OFF (default)
116
- -l, --log console log loaded variables ON
117
- -L, --log-off console log loaded variables OFF (default)
118
- -d, --debug debug mode ON
119
- -D, --debug-off debug mode OFF (default)
120
- --default-env <string> default target environment
121
- --dotenv-token <string> dotenv-expanded token indicating a dotenv file (default: ".env")
122
- --dynamic-path <string> dynamic variables path
123
- --paths <string> dotenv-expanded delimited list of paths to dotenv directory (default: "./")
124
- --paths-delimiter <string> paths delimiter string (default: " ")
125
- --paths-delimiter-pattern <string> paths delimiter regex pattern
126
- --private-token <string> dotenv-expanded token indicating private variables (default: "local")
127
- --vars-delimiter <string> vars delimiter string (default: " ")
128
- --vars-delimiter-pattern <string> vars delimiter regex pattern
129
- --vars-assignor <string> vars assignment operator string (default: "=")
130
- --vars-assignor-pattern <string> vars assignment operator regex pattern
131
- -h, --help display help for command
132
-
133
- Commands:
134
- cmd execute shell command string (default command)
135
- help [command] display help for command
79
+ ## Command Line Interface
80
+
81
+ You can also use `getdotenv` from the command line:
82
+
83
+ ```bash
84
+ > npx getdotenv -h
85
+
86
+ # Usage: getdotenv [options] [command]
87
+ #
88
+ # Base CLI.
89
+ #
90
+ # Options:
91
+ # -e, --env <string> target environment (dotenv-expanded)
92
+ # -v, --vars <string> extra variables expressed as delimited key-value pairs (dotenv-expanded): KEY1=VAL1 KEY2=VAL2
93
+ # -c, --command <string> shell command string (dotenv-expanded)
94
+ # -o, --output-path <string> consolidated output file (dotenv-expanded)
95
+ # -p, --load-process load variables to process.env ON (default)
96
+ # -P, --load-process-off load variables to process.env OFF
97
+ # -a, --exclude-all exclude all dotenv variables from loading ON
98
+ # -A, --exclude-all-off exclude all dotenv variables from loading OFF (default)
99
+ # -z, --exclude-dynamic exclude dynamic dotenv variables from loading ON
100
+ # -Z, --exclude-dynamic-off exclude dynamic dotenv variables from loading OFF (default)
101
+ # -n, --exclude-env exclude environment-specific dotenv variables from loading
102
+ # -N, --exclude-env-off exclude environment-specific dotenv variables from loading OFF (default)
103
+ # -g, --exclude-global exclude global dotenv variables from loading ON
104
+ # -G, --exclude-global-off exclude global dotenv variables from loading OFF (default)
105
+ # -r, --exclude-private exclude private dotenv variables from loading ON
106
+ # -R, --exclude-private-off exclude private dotenv variables from loading OFF (default)
107
+ # -u, --exclude-public exclude public dotenv variables from loading ON
108
+ # -U, --exclude-public-off exclude public dotenv variables from loading OFF (default)
109
+ # -l, --log console log loaded variables ON
110
+ # -L, --log-off console log loaded variables OFF (default)
111
+ # -d, --debug debug mode ON
112
+ # -D, --debug-off debug mode OFF (default)
113
+ # --default-env <string> default target environment
114
+ # --dotenv-token <string> dotenv-expanded token indicating a dotenv file (default: ".env")
115
+ # --dynamic-path <string> dynamic variables path
116
+ # --paths <string> dotenv-expanded delimited list of paths to dotenv directory (default: "./")
117
+ # --paths-delimiter <string> paths delimiter string (default: " ")
118
+ # --paths-delimiter-pattern <string> paths delimiter regex pattern
119
+ # --private-token <string> dotenv-expanded token indicating private variables (default: "local")
120
+ # --vars-delimiter <string> vars delimiter string (default: " ")
121
+ # --vars-delimiter-pattern <string> vars delimiter regex pattern
122
+ # --vars-assignor <string> vars assignment operator string (default: "=")
123
+ # --vars-assignor-pattern <string> vars assignment operator regex pattern
124
+ # -h, --help display help for command
125
+ #
126
+ # Commands:
127
+ # cmd execute shell command string (default command)
128
+ # help [command] display help for command
136
129
  ```
137
130
 
131
+ See [this example repo](https://github.com/karmaniverous/get-dotenv-child) for a deep dive on using the `getDotenv` CLI and how to extend it for your own projects.
package/dist/index.d.cts CHANGED
@@ -4,10 +4,18 @@ import { Command } from '@commander-js/extra-typings';
4
4
  * Options passed programmatically to `getDotenvCli`.
5
5
  */
6
6
  interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
7
+ /**
8
+ * Cli alias. Should align with the `bin` property in `package.json`.
9
+ */
10
+ alias?: string;
7
11
  /**
8
12
  * Logs CLI internals when true.
9
13
  */
10
14
  debug?: boolean;
15
+ /**
16
+ * Cli description (appears in CLI help).
17
+ */
18
+ description?: string;
11
19
  /**
12
20
  * A delimited string of paths to dotenv files.
13
21
  */
@@ -70,7 +78,7 @@ interface GetDotenvOptions {
70
78
  */
71
79
  dotenvToken?: string;
72
80
  /**
73
- * path to file exporting an object keyed to dynamic variable functions
81
+ * path to JS module default-exporting an object keyed to dynamic variable functions
74
82
  */
75
83
  dynamicPath?: string;
76
84
  /**
@@ -78,31 +86,31 @@ interface GetDotenvOptions {
78
86
  */
79
87
  env?: string;
80
88
  /**
81
- * exclude dynamic variables
89
+ * exclude dynamic variables from loading
82
90
  */
83
91
  excludeDynamic?: boolean;
84
92
  /**
85
- * exclude environment-specific variables
93
+ * exclude environment-specific variables from loading
86
94
  */
87
95
  excludeEnv?: boolean;
88
96
  /**
89
- * exclude global variables
97
+ * exclude global variables from loading
90
98
  */
91
99
  excludeGlobal?: boolean;
92
100
  /**
93
- * exclude private variables
101
+ * exclude private variables from loading
94
102
  */
95
103
  excludePrivate?: boolean;
96
104
  /**
97
- * exclude public variables
105
+ * exclude public variables from loading
98
106
  */
99
107
  excludePublic?: boolean;
100
108
  /**
101
- * load dotenv to process.env
109
+ * load dotenv variables to `process.env`
102
110
  */
103
111
  loadProcess?: boolean;
104
112
  /**
105
- * log result to logger
113
+ * log loaded dotenv variables to `logger`
106
114
  */
107
115
  log?: boolean;
108
116
  /**
@@ -110,7 +118,7 @@ interface GetDotenvOptions {
110
118
  */
111
119
  logger?: Logger;
112
120
  /**
113
- * if populated, writes consolidated .env file to this path (follows dotenvExpand rules)
121
+ * if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
114
122
  */
115
123
  outputPath?: string;
116
124
  /**
@@ -180,13 +188,9 @@ type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
180
188
  */
181
189
  interface GetDotenvCliGenerateOptions extends Omit<GetDotenvCliOptions, 'env'> {
182
190
  /**
183
- * Cli alias. Should align with the `bin` property in `package.json`.
191
+ * Logger object (defaults to console)
184
192
  */
185
- alias?: string;
186
- /**
187
- * Cli description (appears in CLI help).
188
- */
189
- description?: string;
193
+ logger?: Logger;
190
194
  /**
191
195
  * Mutates inbound options & executes side effects within the `getDotenv`
192
196
  * context before executing CLI commands.
package/dist/index.d.mts CHANGED
@@ -4,10 +4,18 @@ import { Command } from '@commander-js/extra-typings';
4
4
  * Options passed programmatically to `getDotenvCli`.
5
5
  */
6
6
  interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
7
+ /**
8
+ * Cli alias. Should align with the `bin` property in `package.json`.
9
+ */
10
+ alias?: string;
7
11
  /**
8
12
  * Logs CLI internals when true.
9
13
  */
10
14
  debug?: boolean;
15
+ /**
16
+ * Cli description (appears in CLI help).
17
+ */
18
+ description?: string;
11
19
  /**
12
20
  * A delimited string of paths to dotenv files.
13
21
  */
@@ -70,7 +78,7 @@ interface GetDotenvOptions {
70
78
  */
71
79
  dotenvToken?: string;
72
80
  /**
73
- * path to file exporting an object keyed to dynamic variable functions
81
+ * path to JS module default-exporting an object keyed to dynamic variable functions
74
82
  */
75
83
  dynamicPath?: string;
76
84
  /**
@@ -78,31 +86,31 @@ interface GetDotenvOptions {
78
86
  */
79
87
  env?: string;
80
88
  /**
81
- * exclude dynamic variables
89
+ * exclude dynamic variables from loading
82
90
  */
83
91
  excludeDynamic?: boolean;
84
92
  /**
85
- * exclude environment-specific variables
93
+ * exclude environment-specific variables from loading
86
94
  */
87
95
  excludeEnv?: boolean;
88
96
  /**
89
- * exclude global variables
97
+ * exclude global variables from loading
90
98
  */
91
99
  excludeGlobal?: boolean;
92
100
  /**
93
- * exclude private variables
101
+ * exclude private variables from loading
94
102
  */
95
103
  excludePrivate?: boolean;
96
104
  /**
97
- * exclude public variables
105
+ * exclude public variables from loading
98
106
  */
99
107
  excludePublic?: boolean;
100
108
  /**
101
- * load dotenv to process.env
109
+ * load dotenv variables to `process.env`
102
110
  */
103
111
  loadProcess?: boolean;
104
112
  /**
105
- * log result to logger
113
+ * log loaded dotenv variables to `logger`
106
114
  */
107
115
  log?: boolean;
108
116
  /**
@@ -110,7 +118,7 @@ interface GetDotenvOptions {
110
118
  */
111
119
  logger?: Logger;
112
120
  /**
113
- * if populated, writes consolidated .env file to this path (follows dotenvExpand rules)
121
+ * if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
114
122
  */
115
123
  outputPath?: string;
116
124
  /**
@@ -180,13 +188,9 @@ type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
180
188
  */
181
189
  interface GetDotenvCliGenerateOptions extends Omit<GetDotenvCliOptions, 'env'> {
182
190
  /**
183
- * Cli alias. Should align with the `bin` property in `package.json`.
191
+ * Logger object (defaults to console)
184
192
  */
185
- alias?: string;
186
- /**
187
- * Cli description (appears in CLI help).
188
- */
189
- description?: string;
193
+ logger?: Logger;
190
194
  /**
191
195
  * Mutates inbound options & executes side effects within the `getDotenv`
192
196
  * context before executing CLI commands.
package/dist/index.d.ts CHANGED
@@ -4,10 +4,18 @@ import { Command } from '@commander-js/extra-typings';
4
4
  * Options passed programmatically to `getDotenvCli`.
5
5
  */
6
6
  interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
7
+ /**
8
+ * Cli alias. Should align with the `bin` property in `package.json`.
9
+ */
10
+ alias?: string;
7
11
  /**
8
12
  * Logs CLI internals when true.
9
13
  */
10
14
  debug?: boolean;
15
+ /**
16
+ * Cli description (appears in CLI help).
17
+ */
18
+ description?: string;
11
19
  /**
12
20
  * A delimited string of paths to dotenv files.
13
21
  */
@@ -70,7 +78,7 @@ interface GetDotenvOptions {
70
78
  */
71
79
  dotenvToken?: string;
72
80
  /**
73
- * path to file exporting an object keyed to dynamic variable functions
81
+ * path to JS module default-exporting an object keyed to dynamic variable functions
74
82
  */
75
83
  dynamicPath?: string;
76
84
  /**
@@ -78,31 +86,31 @@ interface GetDotenvOptions {
78
86
  */
79
87
  env?: string;
80
88
  /**
81
- * exclude dynamic variables
89
+ * exclude dynamic variables from loading
82
90
  */
83
91
  excludeDynamic?: boolean;
84
92
  /**
85
- * exclude environment-specific variables
93
+ * exclude environment-specific variables from loading
86
94
  */
87
95
  excludeEnv?: boolean;
88
96
  /**
89
- * exclude global variables
97
+ * exclude global variables from loading
90
98
  */
91
99
  excludeGlobal?: boolean;
92
100
  /**
93
- * exclude private variables
101
+ * exclude private variables from loading
94
102
  */
95
103
  excludePrivate?: boolean;
96
104
  /**
97
- * exclude public variables
105
+ * exclude public variables from loading
98
106
  */
99
107
  excludePublic?: boolean;
100
108
  /**
101
- * load dotenv to process.env
109
+ * load dotenv variables to `process.env`
102
110
  */
103
111
  loadProcess?: boolean;
104
112
  /**
105
- * log result to logger
113
+ * log loaded dotenv variables to `logger`
106
114
  */
107
115
  log?: boolean;
108
116
  /**
@@ -110,7 +118,7 @@ interface GetDotenvOptions {
110
118
  */
111
119
  logger?: Logger;
112
120
  /**
113
- * if populated, writes consolidated .env file to this path (follows dotenvExpand rules)
121
+ * if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
114
122
  */
115
123
  outputPath?: string;
116
124
  /**
@@ -180,13 +188,9 @@ type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
180
188
  */
181
189
  interface GetDotenvCliGenerateOptions extends Omit<GetDotenvCliOptions, 'env'> {
182
190
  /**
183
- * Cli alias. Should align with the `bin` property in `package.json`.
191
+ * Logger object (defaults to console)
184
192
  */
185
- alias?: string;
186
- /**
187
- * Cli description (appears in CLI help).
188
- */
189
- description?: string;
193
+ logger?: Logger;
190
194
  /**
191
195
  * Mutates inbound options & executes side effects within the `getDotenv`
192
196
  * context before executing CLI commands.
package/package.json CHANGED
@@ -130,5 +130,5 @@
130
130
  },
131
131
  "type": "module",
132
132
  "types": "dist/index.d.ts",
133
- "version": "4.0.0-2"
133
+ "version": "4.0.0"
134
134
  }