@karmaniverous/get-dotenv 6.2.3 → 6.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/chunks/AwsRestJsonProtocol-Bq1HE-Ln.mjs +932 -0
- package/dist/chunks/createCli-BY6_cfZr.mjs +439 -0
- package/dist/chunks/externalDataInterceptor-CbsdEYa-.mjs +19 -0
- package/dist/chunks/getSSOTokenFromFile-hUSpR7Wf.mjs +22 -0
- package/dist/chunks/helpConfig-CGejgwWW.mjs +12 -0
- package/dist/chunks/index-B5JKTBOL.mjs +443 -0
- package/dist/chunks/index-BEJFiHMX.mjs +522 -0
- package/dist/chunks/index-BPYF6K_G.mjs +82 -0
- package/dist/chunks/index-Bc3h0a95.mjs +374 -0
- package/dist/chunks/index-BpCF5UKx.mjs +272 -0
- package/dist/chunks/index-C_wqbTwI.mjs +187 -0
- package/dist/chunks/index-CeCufHlm.mjs +9374 -0
- package/dist/chunks/index-Cu7rdyqN.mjs +102 -0
- package/dist/chunks/index-DWAtHEA-.mjs +379 -0
- package/dist/chunks/index-Dp1Ip6Ra.mjs +354 -0
- package/dist/chunks/index-DyU5pKKi.mjs +24 -0
- package/dist/chunks/index-c7zKtEuy.mjs +578 -0
- package/dist/chunks/index-cIunyiUQ.mjs +702 -0
- package/dist/chunks/invoke-DuRPU1oC.mjs +60 -0
- package/dist/chunks/loadModuleDefault-Dj8B3Stt.mjs +123 -0
- package/dist/chunks/loadSso-w1eTVg0O.mjs +412 -0
- package/dist/chunks/loader-DnhPeGfq.mjs +346 -0
- package/dist/chunks/overlayEnv-Bs2kVayG.mjs +234 -0
- package/dist/chunks/package-boo9EyYs.mjs +5 -0
- package/dist/chunks/parseKnownFiles-B9cDK21V.mjs +23 -0
- package/dist/chunks/readMergedOptions-Nt0TR7dX.mjs +1626 -0
- package/dist/chunks/resolveCliOptions-TFRzhB2c.mjs +138 -0
- package/dist/chunks/sdk-stream-mixin-BZoJ5jy9.mjs +167 -0
- package/dist/chunks/spawnEnv-CN8a7cNR.mjs +306 -0
- package/dist/chunks/types-DJ-BGABd.mjs +59 -0
- package/dist/chunks/validate-CDl0rE6k.mjs +61 -0
- package/dist/cli.mjs +39 -19307
- package/dist/cliHost.mjs +20 -2800
- package/dist/config.mjs +10 -509
- package/dist/env-overlay.mjs +6 -337
- package/dist/getdotenv.cli.mjs +39 -19305
- package/dist/index.mjs +39 -19396
- package/dist/plugins-aws.d.ts +1 -4
- package/dist/plugins-aws.mjs +65 -2568
- package/dist/plugins-batch.mjs +16 -2573
- package/dist/plugins-cmd.mjs +19 -3094
- package/dist/plugins-init.d.ts +8 -0
- package/dist/plugins-init.mjs +85 -2297
- package/dist/plugins.mjs +36 -18817
- package/package.json +1 -2
- package/dist/templates/cli/index.ts +0 -25
- package/dist/templates/cli/plugins/hello/defaultAction.ts +0 -27
- package/dist/templates/cli/plugins/hello/index.ts +0 -26
- package/dist/templates/cli/plugins/hello/options.ts +0 -31
- package/dist/templates/cli/plugins/hello/strangerAction.ts +0 -20
- package/dist/templates/cli/plugins/hello/types.ts +0 -13
- package/dist/templates/config/js/getdotenv.config.js +0 -20
- package/dist/templates/config/json/local/getdotenv.config.local.json +0 -7
- package/dist/templates/config/json/public/getdotenv.config.json +0 -9
- package/dist/templates/config/public/getdotenv.config.json +0 -8
- package/dist/templates/config/ts/getdotenv.config.ts +0 -28
- package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +0 -7
- package/dist/templates/config/yaml/public/getdotenv.config.yaml +0 -7
- package/dist/templates/defaultAction.ts +0 -27
- package/dist/templates/getdotenv.config.js +0 -20
- package/dist/templates/getdotenv.config.json +0 -9
- package/dist/templates/getdotenv.config.local.json +0 -7
- package/dist/templates/getdotenv.config.local.yaml +0 -7
- package/dist/templates/getdotenv.config.ts +0 -28
- package/dist/templates/getdotenv.config.yaml +0 -7
- package/dist/templates/hello/defaultAction.ts +0 -27
- package/dist/templates/hello/index.ts +0 -26
- package/dist/templates/hello/options.ts +0 -31
- package/dist/templates/hello/strangerAction.ts +0 -20
- package/dist/templates/hello/types.ts +0 -13
- package/dist/templates/index.ts +0 -26
- package/dist/templates/js/getdotenv.config.js +0 -20
- package/dist/templates/json/local/getdotenv.config.local.json +0 -7
- package/dist/templates/json/public/getdotenv.config.json +0 -9
- package/dist/templates/local/getdotenv.config.local.json +0 -7
- package/dist/templates/local/getdotenv.config.local.yaml +0 -7
- package/dist/templates/options.ts +0 -31
- package/dist/templates/plugins/hello/defaultAction.ts +0 -27
- package/dist/templates/plugins/hello/index.ts +0 -26
- package/dist/templates/plugins/hello/options.ts +0 -31
- package/dist/templates/plugins/hello/strangerAction.ts +0 -20
- package/dist/templates/plugins/hello/types.ts +0 -13
- package/dist/templates/public/getdotenv.config.json +0 -9
- package/dist/templates/public/getdotenv.config.yaml +0 -7
- package/dist/templates/strangerAction.ts +0 -20
- package/dist/templates/ts/getdotenv.config.ts +0 -28
- package/dist/templates/types.ts +0 -13
- package/dist/templates/yaml/local/getdotenv.config.local.yaml +0 -7
- 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.
|
|
223
|
+
"version": "6.2.4"
|
|
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,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,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,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,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>;
|
package/dist/templates/index.ts
DELETED
|
@@ -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,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
|
-
}
|