@karmaniverous/get-dotenv 5.2.3 → 5.2.4
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 +7 -0
- package/dist/cliHost.d.cts +33 -8
- package/dist/cliHost.d.mts +33 -8
- package/dist/cliHost.d.ts +33 -8
- package/dist/cliHost.mjs +7 -0
- package/dist/getdotenv.cli.mjs +9 -5
- package/dist/index.cjs +10 -5
- package/dist/index.d.cts +19 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.mjs +10 -6
- package/dist/plugins-aws.cjs +7 -0
- package/dist/plugins-aws.d.cts +29 -162
- package/dist/plugins-aws.d.mts +29 -162
- package/dist/plugins-aws.d.ts +29 -162
- package/dist/plugins-aws.mjs +7 -0
- package/dist/plugins-batch.cjs +7 -0
- package/dist/plugins-batch.d.cts +29 -162
- package/dist/plugins-batch.d.mts +29 -162
- package/dist/plugins-batch.d.ts +29 -162
- package/dist/plugins-batch.mjs +7 -0
- package/dist/plugins-cmd.cjs +9 -5
- package/dist/plugins-cmd.d.cts +29 -162
- package/dist/plugins-cmd.d.mts +29 -162
- package/dist/plugins-cmd.d.ts +29 -162
- package/dist/plugins-cmd.mjs +9 -5
- package/dist/plugins-demo.cjs +7 -0
- package/dist/plugins-demo.d.cts +29 -162
- package/dist/plugins-demo.d.mts +29 -162
- package/dist/plugins-demo.d.ts +29 -162
- package/dist/plugins-demo.mjs +7 -0
- package/dist/plugins-init.cjs +7 -0
- package/dist/plugins-init.d.cts +29 -162
- package/dist/plugins-init.d.mts +29 -162
- package/dist/plugins-init.d.ts +29 -162
- package/dist/plugins-init.mjs +7 -0
- package/dist/plugins.cjs +9 -5
- package/dist/plugins.d.cts +29 -162
- package/dist/plugins.d.mts +29 -162
- package/dist/plugins.d.ts +29 -162
- package/dist/plugins.mjs +9 -5
- package/package.json +1 -1
package/dist/cliHost.cjs
CHANGED
|
@@ -12,6 +12,13 @@ var dotenv = require('dotenv');
|
|
|
12
12
|
var crypto = require('crypto');
|
|
13
13
|
|
|
14
14
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
15
|
+
/** src/cliHost/definePlugin.ts
|
|
16
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
17
|
+
*
|
|
18
|
+
* This module exposes a structural public interface for the host that plugins
|
|
19
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
20
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
21
|
+
*/
|
|
15
22
|
/**
|
|
16
23
|
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
17
24
|
*
|
package/dist/cliHost.d.cts
CHANGED
|
@@ -269,17 +269,41 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
269
269
|
private _runAfterResolve;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
/** src/cliHost/definePlugin.ts
|
|
273
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
274
|
+
*
|
|
275
|
+
* This module exposes a structural public interface for the host that plugins
|
|
276
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
277
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Structural public interface for the host exposed to plugins.
|
|
282
|
+
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
283
|
+
* - Adds host-specific helpers used by built-in plugins.
|
|
284
|
+
*
|
|
285
|
+
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
286
|
+
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
287
|
+
*/
|
|
288
|
+
type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
|
|
289
|
+
ns: (name: string) => Command;
|
|
290
|
+
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
291
|
+
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
292
|
+
};
|
|
293
|
+
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
294
|
+
interface GetDotenvCliPlugin {
|
|
295
|
+
id?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
298
|
+
* Runs parent → children (pre-order).
|
|
299
|
+
*/
|
|
300
|
+
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
277
301
|
/**
|
|
278
302
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
279
303
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
280
304
|
* Runs parent → children (pre-order).
|
|
281
305
|
*/
|
|
282
|
-
afterResolve?: (cli:
|
|
306
|
+
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
283
307
|
/**
|
|
284
308
|
* Optional Zod schema for this plugin's config slice (from config.plugins[id]).
|
|
285
309
|
* When provided, the host validates the merged config under the guarded loader path.
|
|
@@ -287,7 +311,8 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
287
311
|
configSchema?: ZodType;
|
|
288
312
|
/**
|
|
289
313
|
* Compositional children. Installed after the parent per pre-order.
|
|
290
|
-
*/
|
|
314
|
+
*/
|
|
315
|
+
children: GetDotenvCliPlugin[];
|
|
291
316
|
/**
|
|
292
317
|
* Compose a child plugin. Returns the parent to enable chaining.
|
|
293
318
|
*/
|
|
@@ -317,4 +342,4 @@ declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
|
|
|
317
342
|
declare const readMergedOptions: (cmd: Command) => GetDotenvCliOptions | undefined;
|
|
318
343
|
|
|
319
344
|
export { GetDotenvCli, definePlugin, readMergedOptions };
|
|
320
|
-
export type { DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, ScriptsTable };
|
|
345
|
+
export type { DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, GetDotenvCliPublic, ScriptsTable };
|
package/dist/cliHost.d.mts
CHANGED
|
@@ -269,17 +269,41 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
269
269
|
private _runAfterResolve;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
/** src/cliHost/definePlugin.ts
|
|
273
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
274
|
+
*
|
|
275
|
+
* This module exposes a structural public interface for the host that plugins
|
|
276
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
277
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Structural public interface for the host exposed to plugins.
|
|
282
|
+
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
283
|
+
* - Adds host-specific helpers used by built-in plugins.
|
|
284
|
+
*
|
|
285
|
+
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
286
|
+
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
287
|
+
*/
|
|
288
|
+
type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
|
|
289
|
+
ns: (name: string) => Command;
|
|
290
|
+
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
291
|
+
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
292
|
+
};
|
|
293
|
+
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
294
|
+
interface GetDotenvCliPlugin {
|
|
295
|
+
id?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
298
|
+
* Runs parent → children (pre-order).
|
|
299
|
+
*/
|
|
300
|
+
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
277
301
|
/**
|
|
278
302
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
279
303
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
280
304
|
* Runs parent → children (pre-order).
|
|
281
305
|
*/
|
|
282
|
-
afterResolve?: (cli:
|
|
306
|
+
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
283
307
|
/**
|
|
284
308
|
* Optional Zod schema for this plugin's config slice (from config.plugins[id]).
|
|
285
309
|
* When provided, the host validates the merged config under the guarded loader path.
|
|
@@ -287,7 +311,8 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
287
311
|
configSchema?: ZodType;
|
|
288
312
|
/**
|
|
289
313
|
* Compositional children. Installed after the parent per pre-order.
|
|
290
|
-
*/
|
|
314
|
+
*/
|
|
315
|
+
children: GetDotenvCliPlugin[];
|
|
291
316
|
/**
|
|
292
317
|
* Compose a child plugin. Returns the parent to enable chaining.
|
|
293
318
|
*/
|
|
@@ -317,4 +342,4 @@ declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
|
|
|
317
342
|
declare const readMergedOptions: (cmd: Command) => GetDotenvCliOptions | undefined;
|
|
318
343
|
|
|
319
344
|
export { GetDotenvCli, definePlugin, readMergedOptions };
|
|
320
|
-
export type { DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, ScriptsTable };
|
|
345
|
+
export type { DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, GetDotenvCliPublic, ScriptsTable };
|
package/dist/cliHost.d.ts
CHANGED
|
@@ -269,17 +269,41 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
269
269
|
private _runAfterResolve;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
/** src/cliHost/definePlugin.ts
|
|
273
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
274
|
+
*
|
|
275
|
+
* This module exposes a structural public interface for the host that plugins
|
|
276
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
277
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Structural public interface for the host exposed to plugins.
|
|
282
|
+
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
283
|
+
* - Adds host-specific helpers used by built-in plugins.
|
|
284
|
+
*
|
|
285
|
+
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
286
|
+
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
287
|
+
*/
|
|
288
|
+
type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
|
|
289
|
+
ns: (name: string) => Command;
|
|
290
|
+
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
291
|
+
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
292
|
+
};
|
|
293
|
+
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
294
|
+
interface GetDotenvCliPlugin {
|
|
295
|
+
id?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
298
|
+
* Runs parent → children (pre-order).
|
|
299
|
+
*/
|
|
300
|
+
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
277
301
|
/**
|
|
278
302
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
279
303
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
280
304
|
* Runs parent → children (pre-order).
|
|
281
305
|
*/
|
|
282
|
-
afterResolve?: (cli:
|
|
306
|
+
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
283
307
|
/**
|
|
284
308
|
* Optional Zod schema for this plugin's config slice (from config.plugins[id]).
|
|
285
309
|
* When provided, the host validates the merged config under the guarded loader path.
|
|
@@ -287,7 +311,8 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
287
311
|
configSchema?: ZodType;
|
|
288
312
|
/**
|
|
289
313
|
* Compositional children. Installed after the parent per pre-order.
|
|
290
|
-
*/
|
|
314
|
+
*/
|
|
315
|
+
children: GetDotenvCliPlugin[];
|
|
291
316
|
/**
|
|
292
317
|
* Compose a child plugin. Returns the parent to enable chaining.
|
|
293
318
|
*/
|
|
@@ -317,4 +342,4 @@ declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
|
|
|
317
342
|
declare const readMergedOptions: (cmd: Command) => GetDotenvCliOptions | undefined;
|
|
318
343
|
|
|
319
344
|
export { GetDotenvCli, definePlugin, readMergedOptions };
|
|
320
|
-
export type { DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, ScriptsTable };
|
|
345
|
+
export type { DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, GetDotenvCliPublic, ScriptsTable };
|
package/dist/cliHost.mjs
CHANGED
|
@@ -9,6 +9,13 @@ import { nanoid } from 'nanoid';
|
|
|
9
9
|
import { parse } from 'dotenv';
|
|
10
10
|
import { createHash } from 'crypto';
|
|
11
11
|
|
|
12
|
+
/** src/cliHost/definePlugin.ts
|
|
13
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
14
|
+
*
|
|
15
|
+
* This module exposes a structural public interface for the host that plugins
|
|
16
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
17
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
18
|
+
*/
|
|
12
19
|
/**
|
|
13
20
|
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
14
21
|
*
|
package/dist/getdotenv.cli.mjs
CHANGED
|
@@ -2066,6 +2066,13 @@ const buildSpawnEnv = (base, overlay) => {
|
|
|
2066
2066
|
return out;
|
|
2067
2067
|
};
|
|
2068
2068
|
|
|
2069
|
+
/** src/cliHost/definePlugin.ts
|
|
2070
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
2071
|
+
*
|
|
2072
|
+
* This module exposes a structural public interface for the host that plugins
|
|
2073
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
2074
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
2075
|
+
*/
|
|
2069
2076
|
/**
|
|
2070
2077
|
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
2071
2078
|
*
|
|
@@ -3202,11 +3209,8 @@ const cmdPlugin = (options = {}) => definePlugin({
|
|
|
3202
3209
|
const { logger: _omit, ...envBag } = merged;
|
|
3203
3210
|
const capture = process.env.GETDOTENV_STDIO === 'pipe' ||
|
|
3204
3211
|
Boolean(merged.capture);
|
|
3205
|
-
// Prefer explicit env injection
|
|
3206
|
-
|
|
3207
|
-
// exclusions (e.g., --exclude-private) are in effect.
|
|
3208
|
-
const host = cli;
|
|
3209
|
-
const ctx = host.getCtx();
|
|
3212
|
+
// Prefer explicit env injection using the resolved dotenv map.
|
|
3213
|
+
const ctx = cli.getCtx();
|
|
3210
3214
|
const dotenv = (ctx?.dotenv ?? {});
|
|
3211
3215
|
// Diagnostics: --trace [keys...] (space-delimited keys if provided; all keys when true)
|
|
3212
3216
|
const traceOpt = merged.trace;
|
package/dist/index.cjs
CHANGED
|
@@ -2075,6 +2075,13 @@ const buildSpawnEnv = (base, overlay) => {
|
|
|
2075
2075
|
return out;
|
|
2076
2076
|
};
|
|
2077
2077
|
|
|
2078
|
+
/** src/cliHost/definePlugin.ts
|
|
2079
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
2080
|
+
*
|
|
2081
|
+
* This module exposes a structural public interface for the host that plugins
|
|
2082
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
2083
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
2084
|
+
*/
|
|
2078
2085
|
/**
|
|
2079
2086
|
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
2080
2087
|
*
|
|
@@ -3211,11 +3218,8 @@ const cmdPlugin = (options = {}) => definePlugin({
|
|
|
3211
3218
|
const { logger: _omit, ...envBag } = merged;
|
|
3212
3219
|
const capture = process.env.GETDOTENV_STDIO === 'pipe' ||
|
|
3213
3220
|
Boolean(merged.capture);
|
|
3214
|
-
// Prefer explicit env injection
|
|
3215
|
-
|
|
3216
|
-
// exclusions (e.g., --exclude-private) are in effect.
|
|
3217
|
-
const host = cli;
|
|
3218
|
-
const ctx = host.getCtx();
|
|
3221
|
+
// Prefer explicit env injection using the resolved dotenv map.
|
|
3222
|
+
const ctx = cli.getCtx();
|
|
3219
3223
|
const dotenv = (ctx?.dotenv ?? {});
|
|
3220
3224
|
// Diagnostics: --trace [keys...] (space-delimited keys if provided; all keys when true)
|
|
3221
3225
|
const traceOpt = merged.trace;
|
|
@@ -4108,6 +4112,7 @@ function createCli(opts = {}) {
|
|
|
4108
4112
|
};
|
|
4109
4113
|
}
|
|
4110
4114
|
|
|
4115
|
+
exports.buildSpawnEnv = buildSpawnEnv;
|
|
4111
4116
|
exports.createCli = createCli;
|
|
4112
4117
|
exports.defineDynamic = defineDynamic;
|
|
4113
4118
|
exports.dotenvExpand = dotenvExpand;
|
package/dist/index.d.cts
CHANGED
|
@@ -70,6 +70,24 @@ declare module '../cliHost/GetDotenvCli' {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** src/cliCore/spawnEnv.ts
|
|
74
|
+
* Build a sanitized environment bag for child processes.
|
|
75
|
+
*
|
|
76
|
+
* Requirements addressed:
|
|
77
|
+
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
78
|
+
* - Drop undefined values (exactOptional semantics).
|
|
79
|
+
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
80
|
+
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
81
|
+
* Normalize TMP/TEMP consistency when either is present.
|
|
82
|
+
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
83
|
+
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
84
|
+
*
|
|
85
|
+
* Adapter responsibility: pure mapping; no business logic.
|
|
86
|
+
*/
|
|
87
|
+
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
88
|
+
/** Build a sanitized env for child processes from base + overlay. */
|
|
89
|
+
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
90
|
+
|
|
73
91
|
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
74
92
|
vars?: string | Record<string, string | undefined>;
|
|
75
93
|
paths?: string | string[];
|
|
@@ -456,5 +474,5 @@ declare function createCli(opts?: CreateCliOptions): {
|
|
|
456
474
|
run: (argv: string[]) => Promise<void>;
|
|
457
475
|
};
|
|
458
476
|
|
|
459
|
-
export { createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
477
|
+
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
460
478
|
export type { CreateCliOptions, GetDotenvDynamic, GetDotenvOptions, ProcessEnv };
|
package/dist/index.d.mts
CHANGED
|
@@ -70,6 +70,24 @@ declare module '../cliHost/GetDotenvCli' {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** src/cliCore/spawnEnv.ts
|
|
74
|
+
* Build a sanitized environment bag for child processes.
|
|
75
|
+
*
|
|
76
|
+
* Requirements addressed:
|
|
77
|
+
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
78
|
+
* - Drop undefined values (exactOptional semantics).
|
|
79
|
+
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
80
|
+
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
81
|
+
* Normalize TMP/TEMP consistency when either is present.
|
|
82
|
+
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
83
|
+
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
84
|
+
*
|
|
85
|
+
* Adapter responsibility: pure mapping; no business logic.
|
|
86
|
+
*/
|
|
87
|
+
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
88
|
+
/** Build a sanitized env for child processes from base + overlay. */
|
|
89
|
+
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
90
|
+
|
|
73
91
|
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
74
92
|
vars?: string | Record<string, string | undefined>;
|
|
75
93
|
paths?: string | string[];
|
|
@@ -456,5 +474,5 @@ declare function createCli(opts?: CreateCliOptions): {
|
|
|
456
474
|
run: (argv: string[]) => Promise<void>;
|
|
457
475
|
};
|
|
458
476
|
|
|
459
|
-
export { createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
477
|
+
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
460
478
|
export type { CreateCliOptions, GetDotenvDynamic, GetDotenvOptions, ProcessEnv };
|
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,24 @@ declare module '../cliHost/GetDotenvCli' {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** src/cliCore/spawnEnv.ts
|
|
74
|
+
* Build a sanitized environment bag for child processes.
|
|
75
|
+
*
|
|
76
|
+
* Requirements addressed:
|
|
77
|
+
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
78
|
+
* - Drop undefined values (exactOptional semantics).
|
|
79
|
+
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
80
|
+
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
81
|
+
* Normalize TMP/TEMP consistency when either is present.
|
|
82
|
+
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
83
|
+
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
84
|
+
*
|
|
85
|
+
* Adapter responsibility: pure mapping; no business logic.
|
|
86
|
+
*/
|
|
87
|
+
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
88
|
+
/** Build a sanitized env for child processes from base + overlay. */
|
|
89
|
+
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
90
|
+
|
|
73
91
|
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
74
92
|
vars?: string | Record<string, string | undefined>;
|
|
75
93
|
paths?: string | string[];
|
|
@@ -456,5 +474,5 @@ declare function createCli(opts?: CreateCliOptions): {
|
|
|
456
474
|
run: (argv: string[]) => Promise<void>;
|
|
457
475
|
};
|
|
458
476
|
|
|
459
|
-
export { createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
477
|
+
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
460
478
|
export type { CreateCliOptions, GetDotenvDynamic, GetDotenvOptions, ProcessEnv };
|
package/dist/index.mjs
CHANGED
|
@@ -2072,6 +2072,13 @@ const buildSpawnEnv = (base, overlay) => {
|
|
|
2072
2072
|
return out;
|
|
2073
2073
|
};
|
|
2074
2074
|
|
|
2075
|
+
/** src/cliHost/definePlugin.ts
|
|
2076
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
2077
|
+
*
|
|
2078
|
+
* This module exposes a structural public interface for the host that plugins
|
|
2079
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
2080
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
2081
|
+
*/
|
|
2075
2082
|
/**
|
|
2076
2083
|
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
2077
2084
|
*
|
|
@@ -3208,11 +3215,8 @@ const cmdPlugin = (options = {}) => definePlugin({
|
|
|
3208
3215
|
const { logger: _omit, ...envBag } = merged;
|
|
3209
3216
|
const capture = process.env.GETDOTENV_STDIO === 'pipe' ||
|
|
3210
3217
|
Boolean(merged.capture);
|
|
3211
|
-
// Prefer explicit env injection
|
|
3212
|
-
|
|
3213
|
-
// exclusions (e.g., --exclude-private) are in effect.
|
|
3214
|
-
const host = cli;
|
|
3215
|
-
const ctx = host.getCtx();
|
|
3218
|
+
// Prefer explicit env injection using the resolved dotenv map.
|
|
3219
|
+
const ctx = cli.getCtx();
|
|
3216
3220
|
const dotenv = (ctx?.dotenv ?? {});
|
|
3217
3221
|
// Diagnostics: --trace [keys...] (space-delimited keys if provided; all keys when true)
|
|
3218
3222
|
const traceOpt = merged.trace;
|
|
@@ -4105,4 +4109,4 @@ function createCli(opts = {}) {
|
|
|
4105
4109
|
};
|
|
4106
4110
|
}
|
|
4107
4111
|
|
|
4108
|
-
export { createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
4112
|
+
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
package/dist/plugins-aws.cjs
CHANGED
|
@@ -236,6 +236,13 @@ const buildSpawnEnv = (base, overlay) => {
|
|
|
236
236
|
return out;
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
+
/** src/cliHost/definePlugin.ts
|
|
240
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
241
|
+
*
|
|
242
|
+
* This module exposes a structural public interface for the host that plugins
|
|
243
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
244
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
245
|
+
*/
|
|
239
246
|
/**
|
|
240
247
|
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
241
248
|
*
|
package/dist/plugins-aws.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
1
|
import { Command } from 'commander';
|
|
2
|
+
import { ZodType } from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A minimal representation of an environment key/value mapping.
|
|
@@ -95,93 +95,6 @@ interface GetDotenvOptions {
|
|
|
95
95
|
useConfigLoader?: boolean;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
type Scripts = Record<string, string | {
|
|
99
|
-
cmd: string;
|
|
100
|
-
shell?: string | boolean;
|
|
101
|
-
}>;
|
|
102
|
-
/**
|
|
103
|
-
* Options passed programmatically to `getDotenvCli`.
|
|
104
|
-
*/
|
|
105
|
-
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
106
|
-
/**
|
|
107
|
-
* Logs CLI internals when true.
|
|
108
|
-
*/
|
|
109
|
-
debug?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Strict mode: fail the run when env validation issues are detected
|
|
112
|
-
* (schema or requiredKeys). Warns by default when false or unset.
|
|
113
|
-
*/
|
|
114
|
-
strict?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Redaction (presentation): mask secret-like values in logs/trace.
|
|
117
|
-
*/
|
|
118
|
-
redact?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
|
|
121
|
-
*/
|
|
122
|
-
warnEntropy?: boolean;
|
|
123
|
-
entropyThreshold?: number;
|
|
124
|
-
entropyMinLength?: number;
|
|
125
|
-
entropyWhitelist?: string[];
|
|
126
|
-
redactPatterns?: string[];
|
|
127
|
-
/**
|
|
128
|
-
* When true, capture child stdout/stderr and re-emit after completion.
|
|
129
|
-
* Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
|
|
130
|
-
*/
|
|
131
|
-
capture?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* A delimited string of paths to dotenv files.
|
|
134
|
-
*/
|
|
135
|
-
paths?: string;
|
|
136
|
-
/**
|
|
137
|
-
* A delimiter string with which to split `paths`. Only used if
|
|
138
|
-
* `pathsDelimiterPattern` is not provided.
|
|
139
|
-
*/
|
|
140
|
-
pathsDelimiter?: string;
|
|
141
|
-
/**
|
|
142
|
-
* A regular expression pattern with which to split `paths`. Supersedes
|
|
143
|
-
* `pathsDelimiter`.
|
|
144
|
-
*/
|
|
145
|
-
pathsDelimiterPattern?: string;
|
|
146
|
-
/**
|
|
147
|
-
* Scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
148
|
-
*/
|
|
149
|
-
scripts?: Scripts;
|
|
150
|
-
/**
|
|
151
|
-
* Determines how commands and scripts are executed. If `false` or
|
|
152
|
-
* `undefined`, commands are executed as plain Javascript using the default
|
|
153
|
-
* execa parser. If `true`, commands are executed using the default OS shell
|
|
154
|
-
* parser. Otherwise the user may provide a specific shell string (e.g.
|
|
155
|
-
* `/bin/bash`)
|
|
156
|
-
*/
|
|
157
|
-
shell?: string | boolean;
|
|
158
|
-
/**
|
|
159
|
-
* A delimited string of key-value pairs declaratively specifying variables &
|
|
160
|
-
* values to be loaded in addition to any dotenv files.
|
|
161
|
-
*/
|
|
162
|
-
vars?: string;
|
|
163
|
-
/**
|
|
164
|
-
* A string with which to split keys from values in `vars`. Only used if
|
|
165
|
-
* `varsDelimiterPattern` is not provided.
|
|
166
|
-
*/
|
|
167
|
-
varsAssignor?: string;
|
|
168
|
-
/**
|
|
169
|
-
* A regular expression pattern with which to split variable names from values
|
|
170
|
-
* in `vars`. Supersedes `varsAssignor`.
|
|
171
|
-
*/
|
|
172
|
-
varsAssignorPattern?: string;
|
|
173
|
-
/**
|
|
174
|
-
* A string with which to split `vars` into key-value pairs. Only used if
|
|
175
|
-
* `varsDelimiterPattern` is not provided.
|
|
176
|
-
*/
|
|
177
|
-
varsDelimiter?: string;
|
|
178
|
-
/**
|
|
179
|
-
* A regular expression pattern with which to split `vars` into key-value
|
|
180
|
-
* pairs. Supersedes `varsDelimiter`.
|
|
181
|
-
*/
|
|
182
|
-
varsDelimiterPattern?: string;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
98
|
/** * Per-invocation context shared with plugins and actions. */
|
|
186
99
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
187
100
|
optionsResolved: TOptions;
|
|
@@ -189,89 +102,42 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
189
102
|
plugins?: Record<string, unknown>;
|
|
190
103
|
pluginConfigs?: Record<string, unknown>;
|
|
191
104
|
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Plugin
|
|
105
|
+
|
|
106
|
+
/** src/cliHost/definePlugin.ts
|
|
107
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
195
108
|
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
|
|
200
|
-
|
|
109
|
+
* This module exposes a structural public interface for the host that plugins
|
|
110
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
111
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Structural public interface for the host exposed to plugins.
|
|
116
|
+
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
117
|
+
* - Adds host-specific helpers used by built-in plugins.
|
|
201
118
|
*
|
|
202
|
-
*
|
|
119
|
+
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
120
|
+
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
203
121
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
constructor(alias?: string);
|
|
213
|
-
/**
|
|
214
|
-
* Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
|
|
215
|
-
*/
|
|
216
|
-
resolveAndLoad(customOptions?: Partial<TOptions>): Promise<GetDotenvCliCtx<TOptions>>;
|
|
217
|
-
/**
|
|
218
|
-
* Retrieve the current invocation context (if any).
|
|
219
|
-
*/
|
|
220
|
-
getCtx(): GetDotenvCliCtx<TOptions> | undefined;
|
|
221
|
-
/**
|
|
222
|
-
* Retrieve the merged root CLI options bag (if set by passOptions()).
|
|
223
|
-
* Downstream-safe: no generics required.
|
|
224
|
-
*/
|
|
225
|
-
getOptions(): GetDotenvCliOptions | undefined;
|
|
226
|
-
/** Internal: set the merged root options bag for this run. */
|
|
227
|
-
_setOptionsBag(bag: GetDotenvCliOptions): void;
|
|
228
|
-
/** * Convenience helper to create a namespaced subcommand.
|
|
229
|
-
*/
|
|
230
|
-
ns(name: string): Command;
|
|
231
|
-
/**
|
|
232
|
-
* Tag options added during the provided callback as 'app' for grouped help.
|
|
233
|
-
* Allows downstream apps to demarcate their root-level options.
|
|
234
|
-
*/
|
|
235
|
-
tagAppOptions<T>(fn: (root: Command) => T): T;
|
|
236
|
-
/**
|
|
237
|
-
* Branding helper: set CLI name/description/version and optional help header.
|
|
238
|
-
* If version is omitted and importMetaUrl is provided, attempts to read the
|
|
239
|
-
* nearest package.json version (best-effort; non-fatal on failure).
|
|
240
|
-
*/
|
|
241
|
-
brand(args: {
|
|
242
|
-
name?: string;
|
|
243
|
-
description?: string;
|
|
244
|
-
version?: string;
|
|
245
|
-
importMetaUrl?: string;
|
|
246
|
-
helpHeader?: string;
|
|
247
|
-
}): Promise<this>;
|
|
248
|
-
/**
|
|
249
|
-
* Register a plugin for installation (parent level).
|
|
250
|
-
* Installation occurs on first resolveAndLoad() (or explicit install()).
|
|
251
|
-
*/
|
|
252
|
-
use(plugin: GetDotenvCliPlugin): this;
|
|
122
|
+
type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
|
|
123
|
+
ns: (name: string) => Command;
|
|
124
|
+
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
125
|
+
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
126
|
+
};
|
|
127
|
+
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
128
|
+
interface GetDotenvCliPlugin {
|
|
129
|
+
id?: string;
|
|
253
130
|
/**
|
|
254
|
-
*
|
|
255
|
-
* Runs
|
|
131
|
+
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
132
|
+
* Runs parent → children (pre-order).
|
|
256
133
|
*/
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Run afterResolve hooks for all plugins (parent → children).
|
|
260
|
-
*/
|
|
261
|
-
private _runAfterResolve;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/** Public plugin contract used by the GetDotenv CLI host. */ interface GetDotenvCliPlugin {
|
|
265
|
-
id?: string /**
|
|
266
|
-
* Setup phase: register commands and wiring on the provided CLI instance. * Runs parent → children (pre-order).
|
|
267
|
-
*/;
|
|
268
|
-
setup: (cli: GetDotenvCli) => void | Promise<void>;
|
|
134
|
+
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
269
135
|
/**
|
|
270
136
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
271
137
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
272
138
|
* Runs parent → children (pre-order).
|
|
273
139
|
*/
|
|
274
|
-
afterResolve?: (cli:
|
|
140
|
+
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
275
141
|
/**
|
|
276
142
|
* Optional Zod schema for this plugin's config slice (from config.plugins[id]).
|
|
277
143
|
* When provided, the host validates the merged config under the guarded loader path.
|
|
@@ -279,7 +145,8 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
279
145
|
configSchema?: ZodType;
|
|
280
146
|
/**
|
|
281
147
|
* Compositional children. Installed after the parent per pre-order.
|
|
282
|
-
*/
|
|
148
|
+
*/
|
|
149
|
+
children: GetDotenvCliPlugin[];
|
|
283
150
|
/**
|
|
284
151
|
* Compose a child plugin. Returns the parent to enable chaining.
|
|
285
152
|
*/
|