@karmaniverous/get-dotenv 6.2.3 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +1 -0
  2. package/dist/chunks/AwsRestJsonProtocol-Dv5q8CFK.mjs +932 -0
  3. package/dist/chunks/createCli-BSn6Be40.mjs +440 -0
  4. package/dist/chunks/externalDataInterceptor-pqHO-Qmn.mjs +19 -0
  5. package/dist/chunks/getSSOTokenFromFile-otmZHSRV.mjs +22 -0
  6. package/dist/chunks/helpConfig-CGejgwWW.mjs +12 -0
  7. package/dist/chunks/index-B18W-ELX.mjs +273 -0
  8. package/dist/chunks/index-BNcKuiBy.mjs +9375 -0
  9. package/dist/chunks/index-Bi0RIILn.mjs +25 -0
  10. package/dist/chunks/index-BqZ3PB6c.mjs +375 -0
  11. package/dist/chunks/index-C4Ac6feq.mjs +355 -0
  12. package/dist/chunks/index-C6uLiKpC.mjs +703 -0
  13. package/dist/chunks/index-CGg5wWCm.mjs +188 -0
  14. package/dist/chunks/index-CXpZ0pei.mjs +579 -0
  15. package/dist/chunks/index-CYoFYXZv.mjs +103 -0
  16. package/dist/chunks/index-DFNcs3pR.mjs +444 -0
  17. package/dist/chunks/index-DLQEHTw4.mjs +83 -0
  18. package/dist/chunks/index-DtRaL61T.mjs +380 -0
  19. package/dist/chunks/index-eZMlmESW.mjs +522 -0
  20. package/dist/chunks/invoke-DuRPU1oC.mjs +60 -0
  21. package/dist/chunks/loadModuleDefault-Dj8B3Stt.mjs +123 -0
  22. package/dist/chunks/loadSso-CJ_XUhEj.mjs +413 -0
  23. package/dist/chunks/loader-CePOf74i.mjs +347 -0
  24. package/dist/chunks/overlayEnv-Bqh_kPGA.mjs +235 -0
  25. package/dist/chunks/package-boo9EyYs.mjs +5 -0
  26. package/dist/chunks/parseKnownFiles-B6x1cUmR.mjs +23 -0
  27. package/dist/chunks/readMergedOptions-DLBDzpXX.mjs +1627 -0
  28. package/dist/chunks/resolveCliOptions-_qtsVxda.mjs +139 -0
  29. package/dist/chunks/sdk-stream-mixin-DCdC70Up.mjs +167 -0
  30. package/dist/chunks/spawnEnv-CQwFu7ZJ.mjs +307 -0
  31. package/dist/chunks/types-DdqcXCV1.mjs +59 -0
  32. package/dist/chunks/validate-CDl0rE6k.mjs +61 -0
  33. package/dist/cli.mjs +39 -19307
  34. package/dist/cliHost.mjs +21 -2800
  35. package/dist/config.mjs +11 -509
  36. package/dist/env-overlay.mjs +7 -337
  37. package/dist/getdotenv.cli.mjs +39 -19305
  38. package/dist/index.d.ts +485 -2
  39. package/dist/index.mjs +657 -19322
  40. package/dist/plugins-aws.d.ts +1 -4
  41. package/dist/plugins-aws.mjs +66 -2568
  42. package/dist/plugins-batch.mjs +17 -2573
  43. package/dist/plugins-cmd.mjs +20 -3094
  44. package/dist/plugins-init.d.ts +8 -0
  45. package/dist/plugins-init.mjs +85 -2297
  46. package/dist/plugins.mjs +36 -18817
  47. package/package.json +1 -2
  48. package/dist/templates/cli/index.ts +0 -25
  49. package/dist/templates/cli/plugins/hello/defaultAction.ts +0 -27
  50. package/dist/templates/cli/plugins/hello/index.ts +0 -26
  51. package/dist/templates/cli/plugins/hello/options.ts +0 -31
  52. package/dist/templates/cli/plugins/hello/strangerAction.ts +0 -20
  53. package/dist/templates/cli/plugins/hello/types.ts +0 -13
  54. package/dist/templates/config/js/getdotenv.config.js +0 -20
  55. package/dist/templates/config/json/local/getdotenv.config.local.json +0 -7
  56. package/dist/templates/config/json/public/getdotenv.config.json +0 -9
  57. package/dist/templates/config/public/getdotenv.config.json +0 -8
  58. package/dist/templates/config/ts/getdotenv.config.ts +0 -28
  59. package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +0 -7
  60. package/dist/templates/config/yaml/public/getdotenv.config.yaml +0 -7
  61. package/dist/templates/defaultAction.ts +0 -27
  62. package/dist/templates/getdotenv.config.js +0 -20
  63. package/dist/templates/getdotenv.config.json +0 -9
  64. package/dist/templates/getdotenv.config.local.json +0 -7
  65. package/dist/templates/getdotenv.config.local.yaml +0 -7
  66. package/dist/templates/getdotenv.config.ts +0 -28
  67. package/dist/templates/getdotenv.config.yaml +0 -7
  68. package/dist/templates/hello/defaultAction.ts +0 -27
  69. package/dist/templates/hello/index.ts +0 -26
  70. package/dist/templates/hello/options.ts +0 -31
  71. package/dist/templates/hello/strangerAction.ts +0 -20
  72. package/dist/templates/hello/types.ts +0 -13
  73. package/dist/templates/index.ts +0 -26
  74. package/dist/templates/js/getdotenv.config.js +0 -20
  75. package/dist/templates/json/local/getdotenv.config.local.json +0 -7
  76. package/dist/templates/json/public/getdotenv.config.json +0 -9
  77. package/dist/templates/local/getdotenv.config.local.json +0 -7
  78. package/dist/templates/local/getdotenv.config.local.yaml +0 -7
  79. package/dist/templates/options.ts +0 -31
  80. package/dist/templates/plugins/hello/defaultAction.ts +0 -27
  81. package/dist/templates/plugins/hello/index.ts +0 -26
  82. package/dist/templates/plugins/hello/options.ts +0 -31
  83. package/dist/templates/plugins/hello/strangerAction.ts +0 -20
  84. package/dist/templates/plugins/hello/types.ts +0 -13
  85. package/dist/templates/public/getdotenv.config.json +0 -9
  86. package/dist/templates/public/getdotenv.config.yaml +0 -7
  87. package/dist/templates/strangerAction.ts +0 -20
  88. package/dist/templates/ts/getdotenv.config.ts +0 -28
  89. package/dist/templates/types.ts +0 -13
  90. package/dist/templates/yaml/local/getdotenv.config.local.yaml +0 -7
  91. package/dist/templates/yaml/public/getdotenv.config.yaml +0 -7
package/package.json CHANGED
@@ -57,7 +57,6 @@
57
57
  "release-it": "^19.1.0",
58
58
  "rimraf": "^6.1.2",
59
59
  "rollup": "^4.53.3",
60
- "rollup-plugin-copy": "^3.5.0",
61
60
  "rollup-plugin-dts": "^6.3.0",
62
61
  "tslib": "^2.8.1",
63
62
  "tsx": "^4.21.0",
@@ -221,5 +220,5 @@
221
220
  },
222
221
  "type": "module",
223
222
  "types": "dist/index.d.ts",
224
- "version": "6.2.3"
223
+ "version": "6.3.0"
225
224
  }
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { createCli } from '@karmaniverous/get-dotenv/cli';
4
- import {
5
- awsPlugin,
6
- awsWhoamiPlugin,
7
- batchPlugin,
8
- cmdPlugin,
9
- initPlugin,
10
- } from '@karmaniverous/get-dotenv/plugins';
11
-
12
- import { helloPlugin } from './plugins/hello';
13
-
14
- await createCli({
15
- alias: 'mycli',
16
- compose: (program) =>
17
- program
18
- .use(
19
- cmdPlugin({ asDefault: true, optionAlias: '-c, --cmd <command...>' }),
20
- )
21
- .use(batchPlugin())
22
- .use(awsPlugin().use(awsWhoamiPlugin()))
23
- .use(initPlugin())
24
- .use(helloPlugin()),
25
- })();
@@ -1,27 +0,0 @@
1
- import {
2
- type GetDotenvCliPublic,
3
- getRootCommand,
4
- } from '@karmaniverous/get-dotenv/cliHost';
5
-
6
- import type { HelloPlugin } from '.';
7
- import type { HelloCommand } from './options';
8
-
9
- export function attachHelloDefaultAction(
10
- cli: GetDotenvCliPublic,
11
- cmd: HelloCommand,
12
- plugin: HelloPlugin,
13
- ) {
14
- cmd.action((opts) => {
15
- const ctx = cli.getCtx();
16
- // Derive CLI name from the true root command using a typed helper.
17
- const rootName = getRootCommand(cli).name();
18
-
19
- const cfg = plugin.readConfig(cli);
20
- const loud =
21
- opts.loud === true ? true : opts.loudOff === true ? false : cfg.loud;
22
-
23
- const keys = Object.keys(ctx.dotenv);
24
- const label = `Hello, stranger!\n\n[${rootName}] dotenv keys (${String(keys.length)}):`;
25
- console.log(loud ? label.toUpperCase() : label, keys.join(', '));
26
- });
27
- }
@@ -1,26 +0,0 @@
1
- import { definePlugin } from '@karmaniverous/get-dotenv/cliHost';
2
-
3
- import { attachHelloDefaultAction } from './defaultAction';
4
- import { attachHelloOptions } from './options';
5
- import { attachHelloStrangerAction } from './strangerAction';
6
- import { helloPluginConfigSchema } from './types';
7
-
8
- export const helloPlugin = () => {
9
- const plugin = definePlugin({
10
- ns: 'hello',
11
- configSchema: helloPluginConfigSchema,
12
- setup(cli) {
13
- // Keep description in the plugin “index” (this file), not in an options helper.
14
- cli.description('Say hello with current dotenv context');
15
-
16
- const helloCmd = attachHelloOptions(cli, plugin);
17
- attachHelloDefaultAction(cli, helloCmd, plugin);
18
- attachHelloStrangerAction(cli);
19
-
20
- return undefined;
21
- },
22
- });
23
- return plugin;
24
- };
25
-
26
- export type HelloPlugin = ReturnType<typeof helloPlugin>;
@@ -1,31 +0,0 @@
1
- import type { GetDotenvCliPublic } from '@karmaniverous/get-dotenv/cliHost';
2
-
3
- import type { HelloPlugin } from '.';
4
- import type { HelloPluginConfig } from './types';
5
-
6
- export function attachHelloOptions(
7
- cli: GetDotenvCliPublic,
8
- plugin: HelloPlugin,
9
- ) {
10
- const loudOn = plugin
11
- .createPluginDynamicOption(
12
- cli,
13
- '-l, --loud',
14
- (_bag, pluginCfg: Readonly<HelloPluginConfig>) =>
15
- `print greeting in ALL CAPS${pluginCfg.loud ? ' (default)' : ''}`,
16
- )
17
- .conflicts('loudOff');
18
-
19
- const loudOff = plugin
20
- .createPluginDynamicOption(
21
- cli,
22
- '-L, --loud-off',
23
- (_bag, pluginCfg: Readonly<HelloPluginConfig>) =>
24
- `print greeting in normal case${pluginCfg.loud ? '' : ' (default)'}`,
25
- )
26
- .conflicts('loud');
27
-
28
- return cli.addOption(loudOn).addOption(loudOff);
29
- }
30
-
31
- export type HelloCommand = ReturnType<typeof attachHelloOptions>;
@@ -1,20 +0,0 @@
1
- import type { GetDotenvCliPublic } from '@karmaniverous/get-dotenv/cliHost';
2
-
3
- /**
4
- * Attach the `stranger` subcommand under `hello`.
5
- *
6
- * Reads `SECRET_IDENTITY` from the resolved get-dotenv context (`cli.getCtx().dotenv`).
7
- *
8
- * @param cli - The `hello` command mount.
9
- * @returns Nothing.
10
- */
11
- export function attachHelloStrangerAction(cli: GetDotenvCliPublic): void {
12
- const really = cli
13
- .ns('stranger')
14
- .description('Print SECRET_IDENTITY from the resolved dotenv context');
15
-
16
- really.action(() => {
17
- const secretIdentity = really.getCtx().dotenv.SECRET_IDENTITY;
18
- console.log(`My secret identity is ${secretIdentity ?? 'still a secret'}.`);
19
- });
20
- }
@@ -1,13 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * Zod schema for hello plugin configuration.
5
- */
6
- export const helloPluginConfigSchema = z.object({
7
- loud: z.boolean().optional().default(false),
8
- });
9
-
10
- /**
11
- * Hello plugin configuration object.
12
- */
13
- export type HelloPluginConfig = z.infer<typeof helloPluginConfigSchema>;
@@ -1,20 +0,0 @@
1
- export default {
2
- // Help-time root defaults (example):
3
- // rootOptionDefaults: {
4
- // redact: true,
5
- // // redactPatterns: ['API_KEY', 'SECRET'],
6
- // },
7
- // Help-time visibility (example): hide selected root flags in -h
8
- // rootOptionVisibility: { capture: false },
9
-
10
- vars: { APP_SETTING: 'app_value' },
11
- envVars: { dev: { ENV_SETTING: 'dev_value' } },
12
- dynamic: {
13
- GREETING: ({ APP_SETTING = '' }) => `Hello ${APP_SETTING}`,
14
- // Example: env-aware dynamic value. The second argument receives the
15
- // selected environment (if any); tailor behavior per environment.
16
- // For example, with env='dev' this yields "for-dev"; when env is not
17
- // provided, this returns an empty string.
18
- ENV_TAG: (_vars, env) => (env ? `for-${env}` : ''),
19
- },
20
- };
@@ -1,7 +0,0 @@
1
- {
2
- "vars": { "APP_SECRET": "secret_value" },
3
- "envVars": {
4
- "dev": { "ENV_SECRET": "dev_secret" },
5
- "test": { "ENV_SECRET": "test_secret" }
6
- }
7
- }
@@ -1,9 +0,0 @@
1
- {
2
- "vars": {
3
- "APP_SETTING": "app_value"
4
- },
5
- "envVars": {
6
- "dev": { "ENV_SETTING": "dev_value" },
7
- "test": { "ENV_SETTING": "test_value" }
8
- }
9
- }
@@ -1,8 +0,0 @@
1
- {
2
- "vars": {
3
- "APP_NAME": "my-app"
4
- },
5
- "envVars": {
6
- "dev": { "DEV_ONLY": "1" }
7
- }
8
- }
@@ -1,28 +0,0 @@
1
- import { defineGetDotenvConfig } from '@karmaniverous/get-dotenv';
2
-
3
- type Vars = {
4
- APP_SETTING?: string;
5
- ENV_SETTING?: string;
6
- };
7
-
8
- export default defineGetDotenvConfig<Vars>({
9
- // Help-time root defaults (example):
10
- // rootOptionDefaults: {
11
- // redact: true,
12
- // // redactPatterns: ['API_KEY', 'SECRET'],
13
- // },
14
- // Help-time visibility (example): hide selected root flags in -h
15
- // rootOptionVisibility: { capture: false },
16
-
17
- vars: { APP_SETTING: 'app_value' },
18
- envVars: { dev: { ENV_SETTING: 'dev_value' } },
19
- dynamic: {
20
- GREETING: ({ APP_SETTING = '' }) => `${APP_SETTING}-ts`,
21
- // Example: env-aware dynamic value. The second argument receives the
22
- // selected environment (if any); tailor behavior per environment.
23
- // For example, with env='dev' this yields "for-dev"; when env is not
24
- // provided, this returns an empty string.
25
- ENV_TAG: (_vars: Record<string, string | undefined>, env?: string) =>
26
- env ? `for-${env}` : '',
27
- },
28
- });
@@ -1,7 +0,0 @@
1
- vars:
2
- APP_SECRET: "secret_value"
3
- envVars:
4
- dev:
5
- ENV_SECRET: "dev_secret"
6
- test:
7
- ENV_SECRET: "test_secret"
@@ -1,7 +0,0 @@
1
- vars:
2
- APP_SETTING: "app_value"
3
- envVars:
4
- dev:
5
- ENV_SETTING: "dev_value"
6
- test:
7
- ENV_SETTING: "test_value"
@@ -1,27 +0,0 @@
1
- import {
2
- type GetDotenvCliPublic,
3
- getRootCommand,
4
- } from '@karmaniverous/get-dotenv/cliHost';
5
-
6
- import type { HelloPlugin } from '.';
7
- import type { HelloCommand } from './options';
8
-
9
- export function attachHelloDefaultAction(
10
- cli: GetDotenvCliPublic,
11
- cmd: HelloCommand,
12
- plugin: HelloPlugin,
13
- ) {
14
- cmd.action((opts) => {
15
- const ctx = cli.getCtx();
16
- // Derive CLI name from the true root command using a typed helper.
17
- const rootName = getRootCommand(cli).name();
18
-
19
- const cfg = plugin.readConfig(cli);
20
- const loud =
21
- opts.loud === true ? true : opts.loudOff === true ? false : cfg.loud;
22
-
23
- const keys = Object.keys(ctx.dotenv);
24
- const label = `Hello, stranger!\n\n[${rootName}] dotenv keys (${String(keys.length)}):`;
25
- console.log(loud ? label.toUpperCase() : label, keys.join(', '));
26
- });
27
- }
@@ -1,20 +0,0 @@
1
- export default {
2
- // Help-time root defaults (example):
3
- // rootOptionDefaults: {
4
- // redact: true,
5
- // // redactPatterns: ['API_KEY', 'SECRET'],
6
- // },
7
- // Help-time visibility (example): hide selected root flags in -h
8
- // rootOptionVisibility: { capture: false },
9
-
10
- vars: { APP_SETTING: 'app_value' },
11
- envVars: { dev: { ENV_SETTING: 'dev_value' } },
12
- dynamic: {
13
- GREETING: ({ APP_SETTING = '' }) => `Hello ${APP_SETTING}`,
14
- // Example: env-aware dynamic value. The second argument receives the
15
- // selected environment (if any); tailor behavior per environment.
16
- // For example, with env='dev' this yields "for-dev"; when env is not
17
- // provided, this returns an empty string.
18
- ENV_TAG: (_vars, env) => (env ? `for-${env}` : ''),
19
- },
20
- };
@@ -1,9 +0,0 @@
1
- {
2
- "vars": {
3
- "APP_SETTING": "app_value"
4
- },
5
- "envVars": {
6
- "dev": { "ENV_SETTING": "dev_value" },
7
- "test": { "ENV_SETTING": "test_value" }
8
- }
9
- }
@@ -1,7 +0,0 @@
1
- {
2
- "vars": { "APP_SECRET": "secret_value" },
3
- "envVars": {
4
- "dev": { "ENV_SECRET": "dev_secret" },
5
- "test": { "ENV_SECRET": "test_secret" }
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- vars:
2
- APP_SECRET: "secret_value"
3
- envVars:
4
- dev:
5
- ENV_SECRET: "dev_secret"
6
- test:
7
- ENV_SECRET: "test_secret"
@@ -1,28 +0,0 @@
1
- import { defineGetDotenvConfig } from '@karmaniverous/get-dotenv';
2
-
3
- type Vars = {
4
- APP_SETTING?: string;
5
- ENV_SETTING?: string;
6
- };
7
-
8
- export default defineGetDotenvConfig<Vars>({
9
- // Help-time root defaults (example):
10
- // rootOptionDefaults: {
11
- // redact: true,
12
- // // redactPatterns: ['API_KEY', 'SECRET'],
13
- // },
14
- // Help-time visibility (example): hide selected root flags in -h
15
- // rootOptionVisibility: { capture: false },
16
-
17
- vars: { APP_SETTING: 'app_value' },
18
- envVars: { dev: { ENV_SETTING: 'dev_value' } },
19
- dynamic: {
20
- GREETING: ({ APP_SETTING = '' }) => `${APP_SETTING}-ts`,
21
- // Example: env-aware dynamic value. The second argument receives the
22
- // selected environment (if any); tailor behavior per environment.
23
- // For example, with env='dev' this yields "for-dev"; when env is not
24
- // provided, this returns an empty string.
25
- ENV_TAG: (_vars: Record<string, string | undefined>, env?: string) =>
26
- env ? `for-${env}` : '',
27
- },
28
- });
@@ -1,7 +0,0 @@
1
- vars:
2
- APP_SETTING: "app_value"
3
- envVars:
4
- dev:
5
- ENV_SETTING: "dev_value"
6
- test:
7
- ENV_SETTING: "test_value"
@@ -1,27 +0,0 @@
1
- import {
2
- type GetDotenvCliPublic,
3
- getRootCommand,
4
- } from '@karmaniverous/get-dotenv/cliHost';
5
-
6
- import type { HelloPlugin } from '.';
7
- import type { HelloCommand } from './options';
8
-
9
- export function attachHelloDefaultAction(
10
- cli: GetDotenvCliPublic,
11
- cmd: HelloCommand,
12
- plugin: HelloPlugin,
13
- ) {
14
- cmd.action((opts) => {
15
- const ctx = cli.getCtx();
16
- // Derive CLI name from the true root command using a typed helper.
17
- const rootName = getRootCommand(cli).name();
18
-
19
- const cfg = plugin.readConfig(cli);
20
- const loud =
21
- opts.loud === true ? true : opts.loudOff === true ? false : cfg.loud;
22
-
23
- const keys = Object.keys(ctx.dotenv);
24
- const label = `Hello, stranger!\n\n[${rootName}] dotenv keys (${String(keys.length)}):`;
25
- console.log(loud ? label.toUpperCase() : label, keys.join(', '));
26
- });
27
- }
@@ -1,26 +0,0 @@
1
- import { definePlugin } from '@karmaniverous/get-dotenv/cliHost';
2
-
3
- import { attachHelloDefaultAction } from './defaultAction';
4
- import { attachHelloOptions } from './options';
5
- import { attachHelloStrangerAction } from './strangerAction';
6
- import { helloPluginConfigSchema } from './types';
7
-
8
- export const helloPlugin = () => {
9
- const plugin = definePlugin({
10
- ns: 'hello',
11
- configSchema: helloPluginConfigSchema,
12
- setup(cli) {
13
- // Keep description in the plugin “index” (this file), not in an options helper.
14
- cli.description('Say hello with current dotenv context');
15
-
16
- const helloCmd = attachHelloOptions(cli, plugin);
17
- attachHelloDefaultAction(cli, helloCmd, plugin);
18
- attachHelloStrangerAction(cli);
19
-
20
- return undefined;
21
- },
22
- });
23
- return plugin;
24
- };
25
-
26
- export type HelloPlugin = ReturnType<typeof helloPlugin>;
@@ -1,31 +0,0 @@
1
- import type { GetDotenvCliPublic } from '@karmaniverous/get-dotenv/cliHost';
2
-
3
- import type { HelloPlugin } from '.';
4
- import type { HelloPluginConfig } from './types';
5
-
6
- export function attachHelloOptions(
7
- cli: GetDotenvCliPublic,
8
- plugin: HelloPlugin,
9
- ) {
10
- const loudOn = plugin
11
- .createPluginDynamicOption(
12
- cli,
13
- '-l, --loud',
14
- (_bag, pluginCfg: Readonly<HelloPluginConfig>) =>
15
- `print greeting in ALL CAPS${pluginCfg.loud ? ' (default)' : ''}`,
16
- )
17
- .conflicts('loudOff');
18
-
19
- const loudOff = plugin
20
- .createPluginDynamicOption(
21
- cli,
22
- '-L, --loud-off',
23
- (_bag, pluginCfg: Readonly<HelloPluginConfig>) =>
24
- `print greeting in normal case${pluginCfg.loud ? '' : ' (default)'}`,
25
- )
26
- .conflicts('loud');
27
-
28
- return cli.addOption(loudOn).addOption(loudOff);
29
- }
30
-
31
- export type HelloCommand = ReturnType<typeof attachHelloOptions>;
@@ -1,20 +0,0 @@
1
- import type { GetDotenvCliPublic } from '@karmaniverous/get-dotenv/cliHost';
2
-
3
- /**
4
- * Attach the `stranger` subcommand under `hello`.
5
- *
6
- * Reads `SECRET_IDENTITY` from the resolved get-dotenv context (`cli.getCtx().dotenv`).
7
- *
8
- * @param cli - The `hello` command mount.
9
- * @returns Nothing.
10
- */
11
- export function attachHelloStrangerAction(cli: GetDotenvCliPublic): void {
12
- const really = cli
13
- .ns('stranger')
14
- .description('Print SECRET_IDENTITY from the resolved dotenv context');
15
-
16
- really.action(() => {
17
- const secretIdentity = really.getCtx().dotenv.SECRET_IDENTITY;
18
- console.log(`My secret identity is ${secretIdentity ?? 'still a secret'}.`);
19
- });
20
- }
@@ -1,13 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * Zod schema for hello plugin configuration.
5
- */
6
- export const helloPluginConfigSchema = z.object({
7
- loud: z.boolean().optional().default(false),
8
- });
9
-
10
- /**
11
- * Hello plugin configuration object.
12
- */
13
- export type HelloPluginConfig = z.infer<typeof helloPluginConfigSchema>;
@@ -1,26 +0,0 @@
1
- import { definePlugin } from '@karmaniverous/get-dotenv/cliHost';
2
-
3
- import { attachHelloDefaultAction } from './defaultAction';
4
- import { attachHelloOptions } from './options';
5
- import { attachHelloStrangerAction } from './strangerAction';
6
- import { helloPluginConfigSchema } from './types';
7
-
8
- export const helloPlugin = () => {
9
- const plugin = definePlugin({
10
- ns: 'hello',
11
- configSchema: helloPluginConfigSchema,
12
- setup(cli) {
13
- // Keep description in the plugin “index” (this file), not in an options helper.
14
- cli.description('Say hello with current dotenv context');
15
-
16
- const helloCmd = attachHelloOptions(cli, plugin);
17
- attachHelloDefaultAction(cli, helloCmd, plugin);
18
- attachHelloStrangerAction(cli);
19
-
20
- return undefined;
21
- },
22
- });
23
- return plugin;
24
- };
25
-
26
- export type HelloPlugin = ReturnType<typeof helloPlugin>;
@@ -1,20 +0,0 @@
1
- export default {
2
- // Help-time root defaults (example):
3
- // rootOptionDefaults: {
4
- // redact: true,
5
- // // redactPatterns: ['API_KEY', 'SECRET'],
6
- // },
7
- // Help-time visibility (example): hide selected root flags in -h
8
- // rootOptionVisibility: { capture: false },
9
-
10
- vars: { APP_SETTING: 'app_value' },
11
- envVars: { dev: { ENV_SETTING: 'dev_value' } },
12
- dynamic: {
13
- GREETING: ({ APP_SETTING = '' }) => `Hello ${APP_SETTING}`,
14
- // Example: env-aware dynamic value. The second argument receives the
15
- // selected environment (if any); tailor behavior per environment.
16
- // For example, with env='dev' this yields "for-dev"; when env is not
17
- // provided, this returns an empty string.
18
- ENV_TAG: (_vars, env) => (env ? `for-${env}` : ''),
19
- },
20
- };
@@ -1,7 +0,0 @@
1
- {
2
- "vars": { "APP_SECRET": "secret_value" },
3
- "envVars": {
4
- "dev": { "ENV_SECRET": "dev_secret" },
5
- "test": { "ENV_SECRET": "test_secret" }
6
- }
7
- }
@@ -1,9 +0,0 @@
1
- {
2
- "vars": {
3
- "APP_SETTING": "app_value"
4
- },
5
- "envVars": {
6
- "dev": { "ENV_SETTING": "dev_value" },
7
- "test": { "ENV_SETTING": "test_value" }
8
- }
9
- }
@@ -1,7 +0,0 @@
1
- {
2
- "vars": { "APP_SECRET": "secret_value" },
3
- "envVars": {
4
- "dev": { "ENV_SECRET": "dev_secret" },
5
- "test": { "ENV_SECRET": "test_secret" }
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- vars:
2
- APP_SECRET: "secret_value"
3
- envVars:
4
- dev:
5
- ENV_SECRET: "dev_secret"
6
- test:
7
- ENV_SECRET: "test_secret"
@@ -1,31 +0,0 @@
1
- import type { GetDotenvCliPublic } from '@karmaniverous/get-dotenv/cliHost';
2
-
3
- import type { HelloPlugin } from '.';
4
- import type { HelloPluginConfig } from './types';
5
-
6
- export function attachHelloOptions(
7
- cli: GetDotenvCliPublic,
8
- plugin: HelloPlugin,
9
- ) {
10
- const loudOn = plugin
11
- .createPluginDynamicOption(
12
- cli,
13
- '-l, --loud',
14
- (_bag, pluginCfg: Readonly<HelloPluginConfig>) =>
15
- `print greeting in ALL CAPS${pluginCfg.loud ? ' (default)' : ''}`,
16
- )
17
- .conflicts('loudOff');
18
-
19
- const loudOff = plugin
20
- .createPluginDynamicOption(
21
- cli,
22
- '-L, --loud-off',
23
- (_bag, pluginCfg: Readonly<HelloPluginConfig>) =>
24
- `print greeting in normal case${pluginCfg.loud ? '' : ' (default)'}`,
25
- )
26
- .conflicts('loud');
27
-
28
- return cli.addOption(loudOn).addOption(loudOff);
29
- }
30
-
31
- export type HelloCommand = ReturnType<typeof attachHelloOptions>;
@@ -1,27 +0,0 @@
1
- import {
2
- type GetDotenvCliPublic,
3
- getRootCommand,
4
- } from '@karmaniverous/get-dotenv/cliHost';
5
-
6
- import type { HelloPlugin } from '.';
7
- import type { HelloCommand } from './options';
8
-
9
- export function attachHelloDefaultAction(
10
- cli: GetDotenvCliPublic,
11
- cmd: HelloCommand,
12
- plugin: HelloPlugin,
13
- ) {
14
- cmd.action((opts) => {
15
- const ctx = cli.getCtx();
16
- // Derive CLI name from the true root command using a typed helper.
17
- const rootName = getRootCommand(cli).name();
18
-
19
- const cfg = plugin.readConfig(cli);
20
- const loud =
21
- opts.loud === true ? true : opts.loudOff === true ? false : cfg.loud;
22
-
23
- const keys = Object.keys(ctx.dotenv);
24
- const label = `Hello, stranger!\n\n[${rootName}] dotenv keys (${String(keys.length)}):`;
25
- console.log(loud ? label.toUpperCase() : label, keys.join(', '));
26
- });
27
- }