@karmaniverous/get-dotenv 5.0.0-0 → 5.0.0-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/dist/cliHost.cjs +28 -17
- package/dist/cliHost.d.cts +1 -3
- package/dist/cliHost.d.mts +1 -3
- package/dist/cliHost.d.ts +1 -3
- package/dist/cliHost.mjs +28 -17
- package/dist/env-overlay.d.cts +1 -3
- package/dist/env-overlay.d.mts +1 -3
- package/dist/env-overlay.d.ts +1 -3
- package/dist/getdotenv.cli.mjs +28 -17
- package/dist/index.cjs +39 -21
- package/dist/index.d.cts +6 -4
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +39 -21
- package/dist/plugins-aws.d.cts +1 -3
- package/dist/plugins-aws.d.mts +1 -3
- package/dist/plugins-aws.d.ts +1 -3
- package/dist/plugins-batch.d.cts +1 -3
- package/dist/plugins-batch.d.mts +1 -3
- package/dist/plugins-batch.d.ts +1 -3
- package/dist/plugins-init.d.cts +1 -3
- package/dist/plugins-init.d.mts +1 -3
- package/dist/plugins-init.d.ts +1 -3
- package/package.json +1 -1
package/dist/cliHost.cjs
CHANGED
|
@@ -100,10 +100,7 @@ const defaultsDeep = (...layers) => {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
// src/GetDotenvOptions.ts
|
|
103
|
-
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
104
|
-
* A minimal representation of an environment key/value mapping.
|
|
105
|
-
* Values may be `undefined` to represent "unset".
|
|
106
|
-
*/
|
|
103
|
+
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
107
104
|
/**
|
|
108
105
|
* Converts programmatic CLI options to `getDotenv` options. *
|
|
109
106
|
* @param cliOptions - CLI options. Defaults to `{}`.
|
|
@@ -114,8 +111,7 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
114
111
|
/**
|
|
115
112
|
* Convert CLI-facing string options into {@link GetDotenvOptions}.
|
|
116
113
|
*
|
|
117
|
-
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter
|
|
118
|
-
* or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
114
|
+
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter * or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
119
115
|
* pairs (configurable delimiters) into a {@link ProcessEnv}.
|
|
120
116
|
* - Drops CLI-only keys that have no programmatic equivalent.
|
|
121
117
|
*
|
|
@@ -128,21 +124,36 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
128
124
|
delete restObj.debug;
|
|
129
125
|
delete restObj.scripts;
|
|
130
126
|
const splitBy = (value, delim, pattern) => (value ? value.split(pattern ? RegExp(pattern) : (delim ?? ' ')) : []);
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
// Tolerate vars as either a CLI string ("A=1 B=2") or an object map.
|
|
128
|
+
let parsedVars;
|
|
129
|
+
if (typeof vars === 'string') {
|
|
130
|
+
const kvPairs = splitBy(vars, varsDelimiter, varsDelimiterPattern).map((v) => v.split(varsAssignorPattern
|
|
133
131
|
? RegExp(varsAssignorPattern)
|
|
134
|
-
: (varsAssignor ?? '=')))
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
: (varsAssignor ?? '=')));
|
|
133
|
+
parsedVars = Object.fromEntries(kvPairs);
|
|
134
|
+
}
|
|
135
|
+
else if (vars && typeof vars === 'object' && !Array.isArray(vars)) {
|
|
136
|
+
// Keep only string or undefined values to match ProcessEnv.
|
|
137
|
+
const entries = Object.entries(vars).filter(([k, v]) => typeof k === 'string' && (typeof v === 'string' || v === undefined));
|
|
138
|
+
parsedVars = Object.fromEntries(entries);
|
|
139
|
+
}
|
|
140
|
+
// Drop undefined-valued entries at the converter stage to match ProcessEnv
|
|
141
|
+
// expectations and the compat test assertions.
|
|
142
|
+
if (parsedVars) {
|
|
143
|
+
parsedVars = Object.fromEntries(Object.entries(parsedVars).filter(([, v]) => v !== undefined));
|
|
144
|
+
}
|
|
145
|
+
// Tolerate paths as either a delimited string or string[]
|
|
146
|
+
// Use a locally cast union type to avoid lint warnings about always-falsy conditions
|
|
147
|
+
// under the RootOptionsShape (which declares paths as string | undefined).
|
|
148
|
+
const pathsAny = paths;
|
|
149
|
+
const pathsOut = Array.isArray(pathsAny)
|
|
150
|
+
? pathsAny.filter((p) => typeof p === 'string')
|
|
151
|
+
: splitBy(pathsAny, pathsDelimiter, pathsDelimiterPattern);
|
|
137
152
|
// Preserve exactOptionalPropertyTypes: only include keys when defined.
|
|
138
153
|
return {
|
|
139
154
|
...restObj,
|
|
140
|
-
...(paths
|
|
141
|
-
|
|
142
|
-
paths: splitBy(paths, pathsDelimiter, pathsDelimiterPattern),
|
|
143
|
-
}
|
|
144
|
-
: {}),
|
|
145
|
-
...(vars !== undefined ? { vars: parsedVars } : {}),
|
|
155
|
+
...(pathsOut.length > 0 ? { paths: pathsOut } : {}),
|
|
156
|
+
...(parsedVars !== undefined ? { vars: parsedVars } : {}),
|
|
146
157
|
};
|
|
147
158
|
};
|
|
148
159
|
const resolveGetDotenvOptions = async (customOptions) => {
|
package/dist/cliHost.d.cts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/cliHost.d.mts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/cliHost.d.ts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/cliHost.mjs
CHANGED
|
@@ -97,10 +97,7 @@ const defaultsDeep = (...layers) => {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
// src/GetDotenvOptions.ts
|
|
100
|
-
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
101
|
-
* A minimal representation of an environment key/value mapping.
|
|
102
|
-
* Values may be `undefined` to represent "unset".
|
|
103
|
-
*/
|
|
100
|
+
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
104
101
|
/**
|
|
105
102
|
* Converts programmatic CLI options to `getDotenv` options. *
|
|
106
103
|
* @param cliOptions - CLI options. Defaults to `{}`.
|
|
@@ -111,8 +108,7 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
111
108
|
/**
|
|
112
109
|
* Convert CLI-facing string options into {@link GetDotenvOptions}.
|
|
113
110
|
*
|
|
114
|
-
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter
|
|
115
|
-
* or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
111
|
+
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter * or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
116
112
|
* pairs (configurable delimiters) into a {@link ProcessEnv}.
|
|
117
113
|
* - Drops CLI-only keys that have no programmatic equivalent.
|
|
118
114
|
*
|
|
@@ -125,21 +121,36 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
125
121
|
delete restObj.debug;
|
|
126
122
|
delete restObj.scripts;
|
|
127
123
|
const splitBy = (value, delim, pattern) => (value ? value.split(pattern ? RegExp(pattern) : (delim ?? ' ')) : []);
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
// Tolerate vars as either a CLI string ("A=1 B=2") or an object map.
|
|
125
|
+
let parsedVars;
|
|
126
|
+
if (typeof vars === 'string') {
|
|
127
|
+
const kvPairs = splitBy(vars, varsDelimiter, varsDelimiterPattern).map((v) => v.split(varsAssignorPattern
|
|
130
128
|
? RegExp(varsAssignorPattern)
|
|
131
|
-
: (varsAssignor ?? '=')))
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
: (varsAssignor ?? '=')));
|
|
130
|
+
parsedVars = Object.fromEntries(kvPairs);
|
|
131
|
+
}
|
|
132
|
+
else if (vars && typeof vars === 'object' && !Array.isArray(vars)) {
|
|
133
|
+
// Keep only string or undefined values to match ProcessEnv.
|
|
134
|
+
const entries = Object.entries(vars).filter(([k, v]) => typeof k === 'string' && (typeof v === 'string' || v === undefined));
|
|
135
|
+
parsedVars = Object.fromEntries(entries);
|
|
136
|
+
}
|
|
137
|
+
// Drop undefined-valued entries at the converter stage to match ProcessEnv
|
|
138
|
+
// expectations and the compat test assertions.
|
|
139
|
+
if (parsedVars) {
|
|
140
|
+
parsedVars = Object.fromEntries(Object.entries(parsedVars).filter(([, v]) => v !== undefined));
|
|
141
|
+
}
|
|
142
|
+
// Tolerate paths as either a delimited string or string[]
|
|
143
|
+
// Use a locally cast union type to avoid lint warnings about always-falsy conditions
|
|
144
|
+
// under the RootOptionsShape (which declares paths as string | undefined).
|
|
145
|
+
const pathsAny = paths;
|
|
146
|
+
const pathsOut = Array.isArray(pathsAny)
|
|
147
|
+
? pathsAny.filter((p) => typeof p === 'string')
|
|
148
|
+
: splitBy(pathsAny, pathsDelimiter, pathsDelimiterPattern);
|
|
134
149
|
// Preserve exactOptionalPropertyTypes: only include keys when defined.
|
|
135
150
|
return {
|
|
136
151
|
...restObj,
|
|
137
|
-
...(paths
|
|
138
|
-
|
|
139
|
-
paths: splitBy(paths, pathsDelimiter, pathsDelimiterPattern),
|
|
140
|
-
}
|
|
141
|
-
: {}),
|
|
142
|
-
...(vars !== undefined ? { vars: parsedVars } : {}),
|
|
152
|
+
...(pathsOut.length > 0 ? { paths: pathsOut } : {}),
|
|
153
|
+
...(parsedVars !== undefined ? { vars: parsedVars } : {}),
|
|
143
154
|
};
|
|
144
155
|
};
|
|
145
156
|
const resolveGetDotenvOptions = async (customOptions) => {
|
package/dist/env-overlay.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A minimal representation of an environment key/value mapping.
|
|
3
|
-
* Values may be `undefined` to represent "unset".
|
|
4
|
-
*/
|
|
5
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
3
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
6
4
|
|
|
7
5
|
type Scripts = Record<string, string | {
|
|
8
6
|
cmd: string;
|
package/dist/env-overlay.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A minimal representation of an environment key/value mapping.
|
|
3
|
-
* Values may be `undefined` to represent "unset".
|
|
4
|
-
*/
|
|
5
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
3
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
6
4
|
|
|
7
5
|
type Scripts = Record<string, string | {
|
|
8
6
|
cmd: string;
|
package/dist/env-overlay.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A minimal representation of an environment key/value mapping.
|
|
3
|
-
* Values may be `undefined` to represent "unset".
|
|
4
|
-
*/
|
|
5
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
3
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
6
4
|
|
|
7
5
|
type Scripts = Record<string, string | {
|
|
8
6
|
cmd: string;
|
package/dist/getdotenv.cli.mjs
CHANGED
|
@@ -81,10 +81,7 @@ const defaultsDeep = (...layers) => {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
// src/GetDotenvOptions.ts
|
|
84
|
-
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
85
|
-
* A minimal representation of an environment key/value mapping.
|
|
86
|
-
* Values may be `undefined` to represent "unset".
|
|
87
|
-
*/
|
|
84
|
+
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
88
85
|
/**
|
|
89
86
|
* Converts programmatic CLI options to `getDotenv` options. *
|
|
90
87
|
* @param cliOptions - CLI options. Defaults to `{}`.
|
|
@@ -95,8 +92,7 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
95
92
|
/**
|
|
96
93
|
* Convert CLI-facing string options into {@link GetDotenvOptions}.
|
|
97
94
|
*
|
|
98
|
-
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter
|
|
99
|
-
* or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
95
|
+
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter * or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
100
96
|
* pairs (configurable delimiters) into a {@link ProcessEnv}.
|
|
101
97
|
* - Drops CLI-only keys that have no programmatic equivalent.
|
|
102
98
|
*
|
|
@@ -109,21 +105,36 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
109
105
|
delete restObj.debug;
|
|
110
106
|
delete restObj.scripts;
|
|
111
107
|
const splitBy = (value, delim, pattern) => (value ? value.split(pattern ? RegExp(pattern) : (delim ?? ' ')) : []);
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
// Tolerate vars as either a CLI string ("A=1 B=2") or an object map.
|
|
109
|
+
let parsedVars;
|
|
110
|
+
if (typeof vars === 'string') {
|
|
111
|
+
const kvPairs = splitBy(vars, varsDelimiter, varsDelimiterPattern).map((v) => v.split(varsAssignorPattern
|
|
114
112
|
? RegExp(varsAssignorPattern)
|
|
115
|
-
: (varsAssignor ?? '=')))
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
: (varsAssignor ?? '=')));
|
|
114
|
+
parsedVars = Object.fromEntries(kvPairs);
|
|
115
|
+
}
|
|
116
|
+
else if (vars && typeof vars === 'object' && !Array.isArray(vars)) {
|
|
117
|
+
// Keep only string or undefined values to match ProcessEnv.
|
|
118
|
+
const entries = Object.entries(vars).filter(([k, v]) => typeof k === 'string' && (typeof v === 'string' || v === undefined));
|
|
119
|
+
parsedVars = Object.fromEntries(entries);
|
|
120
|
+
}
|
|
121
|
+
// Drop undefined-valued entries at the converter stage to match ProcessEnv
|
|
122
|
+
// expectations and the compat test assertions.
|
|
123
|
+
if (parsedVars) {
|
|
124
|
+
parsedVars = Object.fromEntries(Object.entries(parsedVars).filter(([, v]) => v !== undefined));
|
|
125
|
+
}
|
|
126
|
+
// Tolerate paths as either a delimited string or string[]
|
|
127
|
+
// Use a locally cast union type to avoid lint warnings about always-falsy conditions
|
|
128
|
+
// under the RootOptionsShape (which declares paths as string | undefined).
|
|
129
|
+
const pathsAny = paths;
|
|
130
|
+
const pathsOut = Array.isArray(pathsAny)
|
|
131
|
+
? pathsAny.filter((p) => typeof p === 'string')
|
|
132
|
+
: splitBy(pathsAny, pathsDelimiter, pathsDelimiterPattern);
|
|
118
133
|
// Preserve exactOptionalPropertyTypes: only include keys when defined.
|
|
119
134
|
return {
|
|
120
135
|
...restObj,
|
|
121
|
-
...(paths
|
|
122
|
-
|
|
123
|
-
paths: splitBy(paths, pathsDelimiter, pathsDelimiterPattern),
|
|
124
|
-
}
|
|
125
|
-
: {}),
|
|
126
|
-
...(vars !== undefined ? { vars: parsedVars } : {}),
|
|
136
|
+
...(pathsOut.length > 0 ? { paths: pathsOut } : {}),
|
|
137
|
+
...(parsedVars !== undefined ? { vars: parsedVars } : {}),
|
|
127
138
|
};
|
|
128
139
|
};
|
|
129
140
|
const resolveGetDotenvOptions = async (customOptions) => {
|
package/dist/index.cjs
CHANGED
|
@@ -498,7 +498,8 @@ const cmdCommand$1 = new commander.Command()
|
|
|
498
498
|
.description('execute command, conflicts with --command option (default subcommand)')
|
|
499
499
|
.enablePositionalOptions()
|
|
500
500
|
.passThroughOptions()
|
|
501
|
-
.
|
|
501
|
+
.argument('[command...]')
|
|
502
|
+
.action(async (commandParts, _options, thisCommand) => {
|
|
502
503
|
if (!thisCommand.parent)
|
|
503
504
|
throw new Error(`unable to resolve parent command`);
|
|
504
505
|
if (!thisCommand.parent.parent)
|
|
@@ -511,7 +512,12 @@ const cmdCommand$1 = new commander.Command()
|
|
|
511
512
|
const pkgCwd = !!raw.pkgCwd;
|
|
512
513
|
const rootPath = typeof raw.rootPath === 'string' ? raw.rootPath : './';
|
|
513
514
|
// Execute command.
|
|
514
|
-
const
|
|
515
|
+
const args = Array.isArray(commandParts) ? commandParts : [];
|
|
516
|
+
// When no positional tokens are provided (e.g., option form `-c/--command`),
|
|
517
|
+
// the preSubcommand hook handles execution. Avoid a duplicate call here.
|
|
518
|
+
if (args.length === 0)
|
|
519
|
+
return;
|
|
520
|
+
const command = args.map(String).join(' ');
|
|
515
521
|
await execShellCommandBatch({
|
|
516
522
|
command: resolveCommand(getDotenvCliOptions.scripts, command),
|
|
517
523
|
getDotenvCliOptions,
|
|
@@ -578,8 +584,9 @@ const cmdCommand = new commander.Command()
|
|
|
578
584
|
.configureHelp({ showGlobalOptions: true })
|
|
579
585
|
.enablePositionalOptions()
|
|
580
586
|
.passThroughOptions()
|
|
581
|
-
.
|
|
582
|
-
|
|
587
|
+
.argument('[command...]')
|
|
588
|
+
.action(async (commandParts, _options, thisCommand) => {
|
|
589
|
+
const args = Array.isArray(commandParts) ? commandParts : [];
|
|
583
590
|
if (args.length === 0)
|
|
584
591
|
return;
|
|
585
592
|
if (!thisCommand.parent)
|
|
@@ -682,10 +689,7 @@ const defaultsDeep = (...layers) => {
|
|
|
682
689
|
};
|
|
683
690
|
|
|
684
691
|
// src/GetDotenvOptions.ts
|
|
685
|
-
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
686
|
-
* A minimal representation of an environment key/value mapping.
|
|
687
|
-
* Values may be `undefined` to represent "unset".
|
|
688
|
-
*/
|
|
692
|
+
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
689
693
|
/**
|
|
690
694
|
* Helper to define a dynamic map with strong inference.
|
|
691
695
|
*
|
|
@@ -703,8 +707,7 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
703
707
|
/**
|
|
704
708
|
* Convert CLI-facing string options into {@link GetDotenvOptions}.
|
|
705
709
|
*
|
|
706
|
-
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter
|
|
707
|
-
* or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
710
|
+
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter * or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
708
711
|
* pairs (configurable delimiters) into a {@link ProcessEnv}.
|
|
709
712
|
* - Drops CLI-only keys that have no programmatic equivalent.
|
|
710
713
|
*
|
|
@@ -717,21 +720,36 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
717
720
|
delete restObj.debug;
|
|
718
721
|
delete restObj.scripts;
|
|
719
722
|
const splitBy = (value, delim, pattern) => (value ? value.split(pattern ? RegExp(pattern) : (delim ?? ' ')) : []);
|
|
720
|
-
|
|
721
|
-
|
|
723
|
+
// Tolerate vars as either a CLI string ("A=1 B=2") or an object map.
|
|
724
|
+
let parsedVars;
|
|
725
|
+
if (typeof vars === 'string') {
|
|
726
|
+
const kvPairs = splitBy(vars, varsDelimiter, varsDelimiterPattern).map((v) => v.split(varsAssignorPattern
|
|
722
727
|
? RegExp(varsAssignorPattern)
|
|
723
|
-
: (varsAssignor ?? '=')))
|
|
724
|
-
|
|
725
|
-
|
|
728
|
+
: (varsAssignor ?? '=')));
|
|
729
|
+
parsedVars = Object.fromEntries(kvPairs);
|
|
730
|
+
}
|
|
731
|
+
else if (vars && typeof vars === 'object' && !Array.isArray(vars)) {
|
|
732
|
+
// Keep only string or undefined values to match ProcessEnv.
|
|
733
|
+
const entries = Object.entries(vars).filter(([k, v]) => typeof k === 'string' && (typeof v === 'string' || v === undefined));
|
|
734
|
+
parsedVars = Object.fromEntries(entries);
|
|
735
|
+
}
|
|
736
|
+
// Drop undefined-valued entries at the converter stage to match ProcessEnv
|
|
737
|
+
// expectations and the compat test assertions.
|
|
738
|
+
if (parsedVars) {
|
|
739
|
+
parsedVars = Object.fromEntries(Object.entries(parsedVars).filter(([, v]) => v !== undefined));
|
|
740
|
+
}
|
|
741
|
+
// Tolerate paths as either a delimited string or string[]
|
|
742
|
+
// Use a locally cast union type to avoid lint warnings about always-falsy conditions
|
|
743
|
+
// under the RootOptionsShape (which declares paths as string | undefined).
|
|
744
|
+
const pathsAny = paths;
|
|
745
|
+
const pathsOut = Array.isArray(pathsAny)
|
|
746
|
+
? pathsAny.filter((p) => typeof p === 'string')
|
|
747
|
+
: splitBy(pathsAny, pathsDelimiter, pathsDelimiterPattern);
|
|
726
748
|
// Preserve exactOptionalPropertyTypes: only include keys when defined.
|
|
727
749
|
return {
|
|
728
750
|
...restObj,
|
|
729
|
-
...(paths
|
|
730
|
-
|
|
731
|
-
paths: splitBy(paths, pathsDelimiter, pathsDelimiterPattern),
|
|
732
|
-
}
|
|
733
|
-
: {}),
|
|
734
|
-
...(vars !== undefined ? { vars: parsedVars } : {}),
|
|
751
|
+
...(pathsOut.length > 0 ? { paths: pathsOut } : {}),
|
|
752
|
+
...(parsedVars !== undefined ? { vars: parsedVars } : {}),
|
|
735
753
|
};
|
|
736
754
|
};
|
|
737
755
|
const resolveGetDotenvOptions = async (customOptions) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -42,11 +42,13 @@ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<s
|
|
|
42
42
|
shell?: TShell;
|
|
43
43
|
}>;
|
|
44
44
|
|
|
45
|
+
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
46
|
+
vars?: string | Record<string, string | undefined>;
|
|
47
|
+
paths?: string | string[];
|
|
48
|
+
};
|
|
45
49
|
/**
|
|
46
50
|
* A minimal representation of an environment key/value mapping.
|
|
47
|
-
* Values may be `undefined` to represent "unset".
|
|
48
|
-
*/
|
|
49
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
51
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
50
52
|
/**
|
|
51
53
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
52
54
|
* and the selected environment (if any), and returns either a string to set
|
|
@@ -150,7 +152,7 @@ interface GetDotenvOptions {
|
|
|
150
152
|
*
|
|
151
153
|
* @returns `getDotenv` options.
|
|
152
154
|
*/
|
|
153
|
-
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }:
|
|
155
|
+
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }: RootOptionsShapeCompat) => GetDotenvOptions;
|
|
154
156
|
|
|
155
157
|
/**
|
|
156
158
|
* Recursively expands environment variables in a string. Variables may be
|
package/dist/index.d.mts
CHANGED
|
@@ -42,11 +42,13 @@ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<s
|
|
|
42
42
|
shell?: TShell;
|
|
43
43
|
}>;
|
|
44
44
|
|
|
45
|
+
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
46
|
+
vars?: string | Record<string, string | undefined>;
|
|
47
|
+
paths?: string | string[];
|
|
48
|
+
};
|
|
45
49
|
/**
|
|
46
50
|
* A minimal representation of an environment key/value mapping.
|
|
47
|
-
* Values may be `undefined` to represent "unset".
|
|
48
|
-
*/
|
|
49
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
51
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
50
52
|
/**
|
|
51
53
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
52
54
|
* and the selected environment (if any), and returns either a string to set
|
|
@@ -150,7 +152,7 @@ interface GetDotenvOptions {
|
|
|
150
152
|
*
|
|
151
153
|
* @returns `getDotenv` options.
|
|
152
154
|
*/
|
|
153
|
-
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }:
|
|
155
|
+
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }: RootOptionsShapeCompat) => GetDotenvOptions;
|
|
154
156
|
|
|
155
157
|
/**
|
|
156
158
|
* Recursively expands environment variables in a string. Variables may be
|
package/dist/index.d.ts
CHANGED
|
@@ -42,11 +42,13 @@ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<s
|
|
|
42
42
|
shell?: TShell;
|
|
43
43
|
}>;
|
|
44
44
|
|
|
45
|
+
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
46
|
+
vars?: string | Record<string, string | undefined>;
|
|
47
|
+
paths?: string | string[];
|
|
48
|
+
};
|
|
45
49
|
/**
|
|
46
50
|
* A minimal representation of an environment key/value mapping.
|
|
47
|
-
* Values may be `undefined` to represent "unset".
|
|
48
|
-
*/
|
|
49
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
51
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
50
52
|
/**
|
|
51
53
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
52
54
|
* and the selected environment (if any), and returns either a string to set
|
|
@@ -150,7 +152,7 @@ interface GetDotenvOptions {
|
|
|
150
152
|
*
|
|
151
153
|
* @returns `getDotenv` options.
|
|
152
154
|
*/
|
|
153
|
-
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }:
|
|
155
|
+
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }: RootOptionsShapeCompat) => GetDotenvOptions;
|
|
154
156
|
|
|
155
157
|
/**
|
|
156
158
|
* Recursively expands environment variables in a string. Variables may be
|
package/dist/index.mjs
CHANGED
|
@@ -495,7 +495,8 @@ const cmdCommand$1 = new Command()
|
|
|
495
495
|
.description('execute command, conflicts with --command option (default subcommand)')
|
|
496
496
|
.enablePositionalOptions()
|
|
497
497
|
.passThroughOptions()
|
|
498
|
-
.
|
|
498
|
+
.argument('[command...]')
|
|
499
|
+
.action(async (commandParts, _options, thisCommand) => {
|
|
499
500
|
if (!thisCommand.parent)
|
|
500
501
|
throw new Error(`unable to resolve parent command`);
|
|
501
502
|
if (!thisCommand.parent.parent)
|
|
@@ -508,7 +509,12 @@ const cmdCommand$1 = new Command()
|
|
|
508
509
|
const pkgCwd = !!raw.pkgCwd;
|
|
509
510
|
const rootPath = typeof raw.rootPath === 'string' ? raw.rootPath : './';
|
|
510
511
|
// Execute command.
|
|
511
|
-
const
|
|
512
|
+
const args = Array.isArray(commandParts) ? commandParts : [];
|
|
513
|
+
// When no positional tokens are provided (e.g., option form `-c/--command`),
|
|
514
|
+
// the preSubcommand hook handles execution. Avoid a duplicate call here.
|
|
515
|
+
if (args.length === 0)
|
|
516
|
+
return;
|
|
517
|
+
const command = args.map(String).join(' ');
|
|
512
518
|
await execShellCommandBatch({
|
|
513
519
|
command: resolveCommand(getDotenvCliOptions.scripts, command),
|
|
514
520
|
getDotenvCliOptions,
|
|
@@ -575,8 +581,9 @@ const cmdCommand = new Command()
|
|
|
575
581
|
.configureHelp({ showGlobalOptions: true })
|
|
576
582
|
.enablePositionalOptions()
|
|
577
583
|
.passThroughOptions()
|
|
578
|
-
.
|
|
579
|
-
|
|
584
|
+
.argument('[command...]')
|
|
585
|
+
.action(async (commandParts, _options, thisCommand) => {
|
|
586
|
+
const args = Array.isArray(commandParts) ? commandParts : [];
|
|
580
587
|
if (args.length === 0)
|
|
581
588
|
return;
|
|
582
589
|
if (!thisCommand.parent)
|
|
@@ -679,10 +686,7 @@ const defaultsDeep = (...layers) => {
|
|
|
679
686
|
};
|
|
680
687
|
|
|
681
688
|
// src/GetDotenvOptions.ts
|
|
682
|
-
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
683
|
-
* A minimal representation of an environment key/value mapping.
|
|
684
|
-
* Values may be `undefined` to represent "unset".
|
|
685
|
-
*/
|
|
689
|
+
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
686
690
|
/**
|
|
687
691
|
* Helper to define a dynamic map with strong inference.
|
|
688
692
|
*
|
|
@@ -700,8 +704,7 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
700
704
|
/**
|
|
701
705
|
* Convert CLI-facing string options into {@link GetDotenvOptions}.
|
|
702
706
|
*
|
|
703
|
-
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter
|
|
704
|
-
* or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
707
|
+
* - Splits {@link GetDotenvCliOptions.paths} using either a delimiter * or a regular expression pattern into a string array. * - Parses {@link GetDotenvCliOptions.vars} as space-separated `KEY=VALUE`
|
|
705
708
|
* pairs (configurable delimiters) into a {@link ProcessEnv}.
|
|
706
709
|
* - Drops CLI-only keys that have no programmatic equivalent.
|
|
707
710
|
*
|
|
@@ -714,21 +717,36 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
714
717
|
delete restObj.debug;
|
|
715
718
|
delete restObj.scripts;
|
|
716
719
|
const splitBy = (value, delim, pattern) => (value ? value.split(pattern ? RegExp(pattern) : (delim ?? ' ')) : []);
|
|
717
|
-
|
|
718
|
-
|
|
720
|
+
// Tolerate vars as either a CLI string ("A=1 B=2") or an object map.
|
|
721
|
+
let parsedVars;
|
|
722
|
+
if (typeof vars === 'string') {
|
|
723
|
+
const kvPairs = splitBy(vars, varsDelimiter, varsDelimiterPattern).map((v) => v.split(varsAssignorPattern
|
|
719
724
|
? RegExp(varsAssignorPattern)
|
|
720
|
-
: (varsAssignor ?? '=')))
|
|
721
|
-
|
|
722
|
-
|
|
725
|
+
: (varsAssignor ?? '=')));
|
|
726
|
+
parsedVars = Object.fromEntries(kvPairs);
|
|
727
|
+
}
|
|
728
|
+
else if (vars && typeof vars === 'object' && !Array.isArray(vars)) {
|
|
729
|
+
// Keep only string or undefined values to match ProcessEnv.
|
|
730
|
+
const entries = Object.entries(vars).filter(([k, v]) => typeof k === 'string' && (typeof v === 'string' || v === undefined));
|
|
731
|
+
parsedVars = Object.fromEntries(entries);
|
|
732
|
+
}
|
|
733
|
+
// Drop undefined-valued entries at the converter stage to match ProcessEnv
|
|
734
|
+
// expectations and the compat test assertions.
|
|
735
|
+
if (parsedVars) {
|
|
736
|
+
parsedVars = Object.fromEntries(Object.entries(parsedVars).filter(([, v]) => v !== undefined));
|
|
737
|
+
}
|
|
738
|
+
// Tolerate paths as either a delimited string or string[]
|
|
739
|
+
// Use a locally cast union type to avoid lint warnings about always-falsy conditions
|
|
740
|
+
// under the RootOptionsShape (which declares paths as string | undefined).
|
|
741
|
+
const pathsAny = paths;
|
|
742
|
+
const pathsOut = Array.isArray(pathsAny)
|
|
743
|
+
? pathsAny.filter((p) => typeof p === 'string')
|
|
744
|
+
: splitBy(pathsAny, pathsDelimiter, pathsDelimiterPattern);
|
|
723
745
|
// Preserve exactOptionalPropertyTypes: only include keys when defined.
|
|
724
746
|
return {
|
|
725
747
|
...restObj,
|
|
726
|
-
...(paths
|
|
727
|
-
|
|
728
|
-
paths: splitBy(paths, pathsDelimiter, pathsDelimiterPattern),
|
|
729
|
-
}
|
|
730
|
-
: {}),
|
|
731
|
-
...(vars !== undefined ? { vars: parsedVars } : {}),
|
|
748
|
+
...(pathsOut.length > 0 ? { paths: pathsOut } : {}),
|
|
749
|
+
...(parsedVars !== undefined ? { vars: parsedVars } : {}),
|
|
732
750
|
};
|
|
733
751
|
};
|
|
734
752
|
const resolveGetDotenvOptions = async (customOptions) => {
|
package/dist/plugins-aws.d.cts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/plugins-aws.d.mts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/plugins-aws.d.ts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/plugins-batch.d.cts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/plugins-batch.d.mts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/plugins-batch.d.ts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/plugins-init.d.cts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/plugins-init.d.mts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/dist/plugins-init.d.ts
CHANGED
|
@@ -3,9 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
7
|
-
*/
|
|
8
|
-
type ProcessEnv = Record<string, string | undefined>;
|
|
6
|
+
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
9
7
|
/**
|
|
10
8
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
11
9
|
* and the selected environment (if any), and returns either a string to set
|
package/package.json
CHANGED