@karmaniverous/get-dotenv 5.2.2 → 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/README.md +1 -1
- 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 -35
- package/dist/index.cjs +10 -35
- 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 -36
- 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 -30
- 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 -30
- 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 +3674 -0
- package/dist/plugins.d.cts +210 -0
- package/dist/plugins.d.mts +210 -0
- package/dist/plugins.d.ts +210 -0
- package/dist/plugins.mjs +3667 -0
- package/package.json +13 -1
package/README.md
CHANGED
|
@@ -390,7 +390,7 @@ Diagnostics and CI capture:
|
|
|
390
390
|
- [Cascade and precedence](./guides/cascade.md)
|
|
391
391
|
- [Shell execution behavior and quoting](./guides/shell.md)
|
|
392
392
|
- [Config files and overlays](./guides/config.md)
|
|
393
|
-
- [Plugin-first host and plugins](./guides/plugins.md)
|
|
393
|
+
- [Plugin-first host and plugins](./guides/plugins/index.md)
|
|
394
394
|
|
|
395
395
|
The guides are also included in the [hosted API docs](https://docs.karmanivero.us/get-dotenv).
|
|
396
396
|
|
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;
|
|
@@ -3299,36 +3303,6 @@ const cmdPlugin = (options = {}) => definePlugin({
|
|
|
3299
3303
|
},
|
|
3300
3304
|
});
|
|
3301
3305
|
|
|
3302
|
-
/**
|
|
3303
|
-
* Demo plugin (educational).
|
|
3304
|
-
*
|
|
3305
|
-
* Purpose
|
|
3306
|
-
* - Showcase how to build a plugin for the GetDotenv CLI host.
|
|
3307
|
-
* - Demonstrate:
|
|
3308
|
-
* - Accessing the resolved dotenv context (ctx).
|
|
3309
|
-
* - Executing child processes with explicit env injection.
|
|
3310
|
-
* - Resolving commands via scripts and honoring per-script shell overrides.
|
|
3311
|
-
* - Thin adapters: business logic stays minimal; use shared helpers.
|
|
3312
|
-
*
|
|
3313
|
-
* Key host APIs used:
|
|
3314
|
-
* - definePlugin: declare a plugin with setup and optional afterResolve.
|
|
3315
|
-
* - cli.ns(name): create a namespaced subcommand under the root CLI.
|
|
3316
|
-
* - cli.getCtx(): access \{ optionsResolved, dotenv, plugins?, pluginConfigs? \}.
|
|
3317
|
-
*
|
|
3318
|
-
* Design notes
|
|
3319
|
-
* - We use the shared runCommand() helper so behavior matches the built-in
|
|
3320
|
-
* cmd/batch plugins (env sanitization, plain vs shell execution, stdio).
|
|
3321
|
-
* - We inject ctx.dotenv into child env explicitly to avoid bleeding prior
|
|
3322
|
-
* secrets from process.env when exclusions are set (e.g., --exclude-private).
|
|
3323
|
-
* - We resolve scripts and shell using shared helpers to honor overrides:
|
|
3324
|
-
* resolveCommand(scripts, input) and resolveShell(scripts, input, shell).
|
|
3325
|
-
*
|
|
3326
|
-
* Usage (examples)
|
|
3327
|
-
* getdotenv demo ctx
|
|
3328
|
-
* getdotenv demo run --print APP_SETTING
|
|
3329
|
-
* getdotenv demo script echo OK
|
|
3330
|
-
* getdotenv --trace demo run --print ENV_SETTING
|
|
3331
|
-
*/
|
|
3332
3306
|
const demoPlugin = () => definePlugin({
|
|
3333
3307
|
id: 'demo',
|
|
3334
3308
|
setup(cli) {
|
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;
|
|
@@ -3308,36 +3312,6 @@ const cmdPlugin = (options = {}) => definePlugin({
|
|
|
3308
3312
|
},
|
|
3309
3313
|
});
|
|
3310
3314
|
|
|
3311
|
-
/**
|
|
3312
|
-
* Demo plugin (educational).
|
|
3313
|
-
*
|
|
3314
|
-
* Purpose
|
|
3315
|
-
* - Showcase how to build a plugin for the GetDotenv CLI host.
|
|
3316
|
-
* - Demonstrate:
|
|
3317
|
-
* - Accessing the resolved dotenv context (ctx).
|
|
3318
|
-
* - Executing child processes with explicit env injection.
|
|
3319
|
-
* - Resolving commands via scripts and honoring per-script shell overrides.
|
|
3320
|
-
* - Thin adapters: business logic stays minimal; use shared helpers.
|
|
3321
|
-
*
|
|
3322
|
-
* Key host APIs used:
|
|
3323
|
-
* - definePlugin: declare a plugin with setup and optional afterResolve.
|
|
3324
|
-
* - cli.ns(name): create a namespaced subcommand under the root CLI.
|
|
3325
|
-
* - cli.getCtx(): access \{ optionsResolved, dotenv, plugins?, pluginConfigs? \}.
|
|
3326
|
-
*
|
|
3327
|
-
* Design notes
|
|
3328
|
-
* - We use the shared runCommand() helper so behavior matches the built-in
|
|
3329
|
-
* cmd/batch plugins (env sanitization, plain vs shell execution, stdio).
|
|
3330
|
-
* - We inject ctx.dotenv into child env explicitly to avoid bleeding prior
|
|
3331
|
-
* secrets from process.env when exclusions are set (e.g., --exclude-private).
|
|
3332
|
-
* - We resolve scripts and shell using shared helpers to honor overrides:
|
|
3333
|
-
* resolveCommand(scripts, input) and resolveShell(scripts, input, shell).
|
|
3334
|
-
*
|
|
3335
|
-
* Usage (examples)
|
|
3336
|
-
* getdotenv demo ctx
|
|
3337
|
-
* getdotenv demo run --print APP_SETTING
|
|
3338
|
-
* getdotenv demo script echo OK
|
|
3339
|
-
* getdotenv --trace demo run --print ENV_SETTING
|
|
3340
|
-
*/
|
|
3341
3315
|
const demoPlugin = () => definePlugin({
|
|
3342
3316
|
id: 'demo',
|
|
3343
3317
|
setup(cli) {
|
|
@@ -4138,6 +4112,7 @@ function createCli(opts = {}) {
|
|
|
4138
4112
|
};
|
|
4139
4113
|
}
|
|
4140
4114
|
|
|
4115
|
+
exports.buildSpawnEnv = buildSpawnEnv;
|
|
4141
4116
|
exports.createCli = createCli;
|
|
4142
4117
|
exports.defineDynamic = defineDynamic;
|
|
4143
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;
|
|
@@ -3305,36 +3309,6 @@ const cmdPlugin = (options = {}) => definePlugin({
|
|
|
3305
3309
|
},
|
|
3306
3310
|
});
|
|
3307
3311
|
|
|
3308
|
-
/**
|
|
3309
|
-
* Demo plugin (educational).
|
|
3310
|
-
*
|
|
3311
|
-
* Purpose
|
|
3312
|
-
* - Showcase how to build a plugin for the GetDotenv CLI host.
|
|
3313
|
-
* - Demonstrate:
|
|
3314
|
-
* - Accessing the resolved dotenv context (ctx).
|
|
3315
|
-
* - Executing child processes with explicit env injection.
|
|
3316
|
-
* - Resolving commands via scripts and honoring per-script shell overrides.
|
|
3317
|
-
* - Thin adapters: business logic stays minimal; use shared helpers.
|
|
3318
|
-
*
|
|
3319
|
-
* Key host APIs used:
|
|
3320
|
-
* - definePlugin: declare a plugin with setup and optional afterResolve.
|
|
3321
|
-
* - cli.ns(name): create a namespaced subcommand under the root CLI.
|
|
3322
|
-
* - cli.getCtx(): access \{ optionsResolved, dotenv, plugins?, pluginConfigs? \}.
|
|
3323
|
-
*
|
|
3324
|
-
* Design notes
|
|
3325
|
-
* - We use the shared runCommand() helper so behavior matches the built-in
|
|
3326
|
-
* cmd/batch plugins (env sanitization, plain vs shell execution, stdio).
|
|
3327
|
-
* - We inject ctx.dotenv into child env explicitly to avoid bleeding prior
|
|
3328
|
-
* secrets from process.env when exclusions are set (e.g., --exclude-private).
|
|
3329
|
-
* - We resolve scripts and shell using shared helpers to honor overrides:
|
|
3330
|
-
* resolveCommand(scripts, input) and resolveShell(scripts, input, shell).
|
|
3331
|
-
*
|
|
3332
|
-
* Usage (examples)
|
|
3333
|
-
* getdotenv demo ctx
|
|
3334
|
-
* getdotenv demo run --print APP_SETTING
|
|
3335
|
-
* getdotenv demo script echo OK
|
|
3336
|
-
* getdotenv --trace demo run --print ENV_SETTING
|
|
3337
|
-
*/
|
|
3338
3312
|
const demoPlugin = () => definePlugin({
|
|
3339
3313
|
id: 'demo',
|
|
3340
3314
|
setup(cli) {
|
|
@@ -4135,4 +4109,4 @@ function createCli(opts = {}) {
|
|
|
4135
4109
|
};
|
|
4136
4110
|
}
|
|
4137
4111
|
|
|
4138
|
-
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
|
*
|