@super-repo/envx 0.2.3-b.3 → 0.2.3-b.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/index.js CHANGED
@@ -1,8 +1,19 @@
1
- import { n as loadDotenvxConfig, u as loadEnv } from "./chunks/src-CwrtyfZE.js";
1
+ import { C as serializeEnv, D as encryptValueAsymmetric, E as decryptValueAsymmetric, O as generateKeyPair, S as parseEnv, T as ENCRYPTED_PREFIX, _ as resolveEnvPaths, a as rotateFiles, b as expandRecord, c as defaultKeysPath, f as detectEnvironment, g as resolveCwdOrWorkspace, h as loadEnv, i as auditFiles, k as isEncrypted, l as readKeysFile, n as loadDotenvxConfig, o as decryptFiles, p as findWorkspaceRoot, r as BUILT_IN_PATTERNS, s as encryptFiles, u as writeKeysFile, w as toRecord, y as expandEnvSrc } from "./chunks/src-D0n2wHDg.js";
2
2
  //#region src/index.ts
3
3
  function envx(arg) {
4
- const { config } = loadDotenvxConfig();
5
- loadEnv(mergeOpts(config, arg === void 0 ? {} : typeof arg === "string" ? { cascade: arg } : arg));
4
+ const { config: baseConfig } = loadDotenvxConfig();
5
+ const userOpts = arg === void 0 ? {} : typeof arg === "string" ? { cascade: arg } : arg;
6
+ let cfg = baseConfig;
7
+ if (userOpts.profile) {
8
+ const profile = cfg.profiles?.[userOpts.profile];
9
+ if (!profile) throw new Error(`[ENVX_UNKNOWN_PROFILE] '${userOpts.profile}' not found (available: ${Object.keys(cfg.profiles ?? {}).join(", ") || "none"})`);
10
+ cfg = {
11
+ ...cfg,
12
+ ...profile
13
+ };
14
+ }
15
+ const { profile: _drop, ...rest } = userOpts;
16
+ loadEnv(mergeOpts(cfg, rest));
6
17
  return process.env;
7
18
  }
8
19
  /**
@@ -37,9 +48,17 @@ function mergeOpts(config, user) {
37
48
  else if (config.defaults !== void 0) out.defaults = config.defaults;
38
49
  if (user.workspaceRoot !== void 0) out.workspaceRoot = user.workspaceRoot;
39
50
  else if (config.workspaceRoot !== void 0) out.workspaceRoot = config.workspaceRoot;
51
+ if (user.schema !== void 0) out.schema = user.schema;
52
+ else if (config.schema !== void 0) out.schema = config.schema;
53
+ if (user.resolvers !== void 0) out.resolvers = user.resolvers;
54
+ else if (config.resolvers !== void 0) out.resolvers = config.resolvers;
55
+ if (user.publicPrefixes !== void 0) out.publicPrefixes = user.publicPrefixes;
56
+ else if (config.publicPrefixes !== void 0) out.publicPrefixes = config.publicPrefixes;
57
+ if (user.publicSource !== void 0) out.publicSource = user.publicSource;
58
+ else if (config.publicSource !== void 0) out.publicSource = config.publicSource;
40
59
  return out;
41
60
  }
42
61
  //#endregion
43
- export { envx as default, envx };
62
+ export { BUILT_IN_PATTERNS, ENCRYPTED_PREFIX, auditFiles, decryptFiles, decryptValueAsymmetric, envx as default, envx, defaultKeysPath, detectEnvironment, encryptFiles, encryptValueAsymmetric, expandEnvSrc, expandRecord, findWorkspaceRoot, generateKeyPair, isEncrypted, loadDotenvxConfig, parseEnv, readKeysFile, resolveCwdOrWorkspace, resolveEnvPaths, rotateFiles, serializeEnv, toRecord, writeKeysFile };
44
63
 
45
64
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// #region -- Programmatic Entry Point ----------------------\n\nimport {\n loadEnv,\n loadDotenvxConfig,\n type DotenvxConfig,\n type LoadEnvOptions,\n} from \"@honeycluster/libs\";\n\n/**\n * Load env files into `process.env` and return it.\n *\n * Modeled after the `dotenv` API but with explicit scoping. Three call\n * shapes:\n *\n * ```ts\n * import envx from \"@honeycluster/envx\";\n *\n * envx(); // load `.env` (auto-detect from NODE_ENV / VERCEL_ENV / NETLIFY)\n * envx(\"prod\"); // load `.env` with cascade=prod (.env, .env.prod, .env.local, .env.prod.local)\n * envx({ envFiles: [\"vault/.env.prod\"], envPath: \"vault\", quiet: false }); // full options\n * ```\n *\n * In all cases `process.env` is mutated and returned for ergonomic\n * destructuring. Config file discovery (`envx.config.{ts,js,json}` /\n * `package.json` `envx.config`) runs automatically; programmatic\n * options layer on top of the discovered config, with caller-supplied\n * fields winning per-field.\n */\nfunction envx(): NodeJS.ProcessEnv;\nfunction envx(scope: string): NodeJS.ProcessEnv;\nfunction envx(opts: LoadEnvOptions): NodeJS.ProcessEnv;\nfunction envx(arg?: string | LoadEnvOptions): NodeJS.ProcessEnv {\n const { config } = loadDotenvxConfig();\n const userOpts: LoadEnvOptions =\n arg === undefined\n ? {}\n : typeof arg === \"string\"\n ? { cascade: arg }\n : arg;\n loadEnv(mergeOpts(config, userOpts));\n return process.env;\n}\n\n/**\n * Per-field merge: caller-supplied option wins, falling through to the\n * matching config field, falling through to whatever default `loadEnv`\n * has built in. Fields the caller doesn't pass and the config doesn't\n * set are simply omitted from the merged options object.\n */\nfunction mergeOpts(\n config: DotenvxConfig,\n user: LoadEnvOptions,\n): LoadEnvOptions {\n const out: { -readonly [K in keyof LoadEnvOptions]: LoadEnvOptions[K] } = {};\n\n // env-file selection\n if (user.envFiles !== undefined) out.envFiles = user.envFiles;\n else if (config.envFiles !== undefined) out.envFiles = [...config.envFiles];\n\n if (user.envPath !== undefined) out.envPath = user.envPath;\n else if (config.envPath !== undefined) out.envPath = config.envPath;\n\n if (user.cascade !== undefined) out.cascade = user.cascade;\n else if (config.cascade !== undefined) out.cascade = config.cascade;\n\n if (user.vault !== undefined) out.vault = user.vault;\n\n if (user.variables !== undefined) out.variables = user.variables;\n\n // load behavior\n if (user.override !== undefined) out.override = user.override;\n else if (config.override !== undefined) out.override = config.override;\n\n if (user.quiet !== undefined) out.quiet = user.quiet;\n else if (config.quiet !== undefined) out.quiet = config.quiet;\n\n // auto-detection\n if (user.autoDetect !== undefined) out.autoDetect = user.autoDetect;\n else if (config.autoDetect !== undefined) out.autoDetect = config.autoDetect;\n\n if (user.nodeEnvMap !== undefined) out.nodeEnvMap = user.nodeEnvMap;\n else if (config.nodeEnvMap !== undefined) out.nodeEnvMap = config.nodeEnvMap;\n\n // post-load behavior\n if (user.required !== undefined) out.required = user.required;\n else if (config.required !== undefined) out.required = config.required;\n\n if (user.expand !== undefined) out.expand = user.expand;\n else if (config.expand !== undefined) out.expand = config.expand;\n\n if (user.defaults !== undefined) out.defaults = user.defaults;\n else if (config.defaults !== undefined) out.defaults = config.defaults;\n\n // advanced\n if (user.workspaceRoot !== undefined) out.workspaceRoot = user.workspaceRoot;\n else if (config.workspaceRoot !== undefined) out.workspaceRoot = config.workspaceRoot;\n\n return out;\n}\n\nexport default envx;\nexport { envx };\n\n// Re-export the types callers will need to type their own wrappers.\nexport type { LoadEnvOptions };\n\n// #endregion -----------------------------------------------\n"],"mappings":";;AAgCA,SAAS,KAAK,KAAkD;CAC9D,MAAM,EAAE,WAAW,mBAAmB;CAOtC,QAAQ,UAAU,QALhB,QAAQ,KAAA,IACJ,EAAE,GACF,OAAO,QAAQ,WACb,EAAE,SAAS,KAAK,GAChB,IAC2B,CAAC;CACpC,OAAO,QAAQ;;;;;;;;AASjB,SAAS,UACP,QACA,MACgB;CAChB,MAAM,MAAoE,EAAE;CAG5E,IAAI,KAAK,aAAa,KAAA,GAAW,IAAI,WAAW,KAAK;MAChD,IAAI,OAAO,aAAa,KAAA,GAAW,IAAI,WAAW,CAAC,GAAG,OAAO,SAAS;CAE3E,IAAI,KAAK,YAAY,KAAA,GAAW,IAAI,UAAU,KAAK;MAC9C,IAAI,OAAO,YAAY,KAAA,GAAW,IAAI,UAAU,OAAO;CAE5D,IAAI,KAAK,YAAY,KAAA,GAAW,IAAI,UAAU,KAAK;MAC9C,IAAI,OAAO,YAAY,KAAA,GAAW,IAAI,UAAU,OAAO;CAE5D,IAAI,KAAK,UAAU,KAAA,GAAW,IAAI,QAAQ,KAAK;CAE/C,IAAI,KAAK,cAAc,KAAA,GAAW,IAAI,YAAY,KAAK;CAGvD,IAAI,KAAK,aAAa,KAAA,GAAW,IAAI,WAAW,KAAK;MAChD,IAAI,OAAO,aAAa,KAAA,GAAW,IAAI,WAAW,OAAO;CAE9D,IAAI,KAAK,UAAU,KAAA,GAAW,IAAI,QAAQ,KAAK;MAC1C,IAAI,OAAO,UAAU,KAAA,GAAW,IAAI,QAAQ,OAAO;CAGxD,IAAI,KAAK,eAAe,KAAA,GAAW,IAAI,aAAa,KAAK;MACpD,IAAI,OAAO,eAAe,KAAA,GAAW,IAAI,aAAa,OAAO;CAElE,IAAI,KAAK,eAAe,KAAA,GAAW,IAAI,aAAa,KAAK;MACpD,IAAI,OAAO,eAAe,KAAA,GAAW,IAAI,aAAa,OAAO;CAGlE,IAAI,KAAK,aAAa,KAAA,GAAW,IAAI,WAAW,KAAK;MAChD,IAAI,OAAO,aAAa,KAAA,GAAW,IAAI,WAAW,OAAO;CAE9D,IAAI,KAAK,WAAW,KAAA,GAAW,IAAI,SAAS,KAAK;MAC5C,IAAI,OAAO,WAAW,KAAA,GAAW,IAAI,SAAS,OAAO;CAE1D,IAAI,KAAK,aAAa,KAAA,GAAW,IAAI,WAAW,KAAK;MAChD,IAAI,OAAO,aAAa,KAAA,GAAW,IAAI,WAAW,OAAO;CAG9D,IAAI,KAAK,kBAAkB,KAAA,GAAW,IAAI,gBAAgB,KAAK;MAC1D,IAAI,OAAO,kBAAkB,KAAA,GAAW,IAAI,gBAAgB,OAAO;CAExE,OAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// #region -- Programmatic Entry Point ----------------------\n\nimport {\n loadEnv,\n loadDotenvxConfig,\n type DotenvxConfig,\n type LoadEnvOptions,\n} from \"@super-repo/envx-libs\";\n\n// Re-export the lib surface that consumers depend on (especially the\n// `auditFiles` API used by czar's `envxAuditPlugin`). Internal\n// packages `@super-repo/envx-libs` and `@super-repo/envx-common`\n// aren't on npm — `@super-repo/envx` is the only published entry, so\n// every public API has to be reachable from here.\nexport {\n // Audit (plaintext-secret scanner)\n auditFiles,\n BUILT_IN_PATTERNS,\n type AuditFinding,\n type AuditOptions,\n type SecretPattern,\n // Crypto primitives\n ENCRYPTED_PREFIX,\n generateKeyPair,\n encryptValueAsymmetric,\n decryptValueAsymmetric,\n isEncrypted,\n // High-level operations\n encryptFiles,\n decryptFiles,\n rotateFiles,\n // Env-file parser\n parseEnv,\n serializeEnv,\n toRecord,\n // Variable expansion\n expandRecord,\n expandEnvSrc,\n // Config + path resolution\n loadDotenvxConfig,\n findWorkspaceRoot,\n resolveCwdOrWorkspace,\n resolveEnvPaths,\n detectEnvironment,\n // Keys-file management\n readKeysFile,\n writeKeysFile,\n defaultKeysPath,\n} from \"@super-repo/envx-libs\";\n\nexport type {\n DotenvxConfig,\n LoadEnvOptions,\n ProcessedEnv,\n ProcessingError,\n ErrorCode,\n RunOptions,\n RunResult,\n ExpandOptions,\n ExpandResult,\n EnvLine,\n KvLine,\n RawLine,\n} from \"@super-repo/envx-libs\";\n\n/**\n * Load env files into `process.env` and return it.\n *\n * Modeled after the `dotenv` API but with explicit scoping. Three call\n * shapes:\n *\n * ```ts\n * import envx from \"@super-repo/envx\";\n *\n * envx(); // load `.env` (auto-detect from NODE_ENV / VERCEL_ENV / NETLIFY)\n * envx(\"prod\"); // load `.env` with cascade=prod (.env, .env.prod, .env.local, .env.prod.local)\n * envx({ envFiles: [\"vault/.env.prod\"], envPath: \"vault\", quiet: false }); // full options\n * ```\n *\n * In all cases `process.env` is mutated and returned for ergonomic\n * destructuring. Config file discovery (`envx.config.{ts,js,json}` /\n * `package.json` `envx.config`) runs automatically; programmatic\n * options layer on top of the discovered config, with caller-supplied\n * fields winning per-field.\n */\n/**\n * Programmatic options accept everything `LoadEnvOptions` does plus an\n * optional `profile` name. When set, the matching `config.profiles[name]`\n * is merged onto the base config (per-field) before the user options\n * take over.\n */\nexport type EnvxProgrammaticOptions = LoadEnvOptions & { readonly profile?: string };\n\nfunction envx(): NodeJS.ProcessEnv;\nfunction envx(scope: string): NodeJS.ProcessEnv;\nfunction envx(opts: EnvxProgrammaticOptions): NodeJS.ProcessEnv;\nfunction envx(arg?: string | EnvxProgrammaticOptions): NodeJS.ProcessEnv {\n const { config: baseConfig } = loadDotenvxConfig();\n const userOpts: EnvxProgrammaticOptions =\n arg === undefined\n ? {}\n : typeof arg === \"string\"\n ? { cascade: arg }\n : arg;\n let cfg: DotenvxConfig = baseConfig;\n if (userOpts.profile) {\n const profile = cfg.profiles?.[userOpts.profile];\n if (!profile) {\n throw new Error(\n `[ENVX_UNKNOWN_PROFILE] '${userOpts.profile}' not found (available: ${\n Object.keys(cfg.profiles ?? {}).join(\", \") || \"none\"\n })`,\n );\n }\n cfg = { ...cfg, ...profile };\n }\n // Strip `profile` before passing to mergeOpts — it's not a LoadEnvOptions field.\n const { profile: _drop, ...rest } = userOpts;\n void _drop;\n loadEnv(mergeOpts(cfg, rest));\n return process.env;\n}\n\n/**\n * Per-field merge: caller-supplied option wins, falling through to the\n * matching config field, falling through to whatever default `loadEnv`\n * has built in. Fields the caller doesn't pass and the config doesn't\n * set are simply omitted from the merged options object.\n */\nfunction mergeOpts(\n config: DotenvxConfig,\n user: LoadEnvOptions,\n): LoadEnvOptions {\n const out: { -readonly [K in keyof LoadEnvOptions]: LoadEnvOptions[K] } = {};\n\n // env-file selection\n if (user.envFiles !== undefined) out.envFiles = user.envFiles;\n else if (config.envFiles !== undefined) out.envFiles = [...config.envFiles];\n\n if (user.envPath !== undefined) out.envPath = user.envPath;\n else if (config.envPath !== undefined) out.envPath = config.envPath;\n\n if (user.cascade !== undefined) out.cascade = user.cascade;\n else if (config.cascade !== undefined) out.cascade = config.cascade;\n\n if (user.vault !== undefined) out.vault = user.vault;\n\n if (user.variables !== undefined) out.variables = user.variables;\n\n // load behavior\n if (user.override !== undefined) out.override = user.override;\n else if (config.override !== undefined) out.override = config.override;\n\n if (user.quiet !== undefined) out.quiet = user.quiet;\n else if (config.quiet !== undefined) out.quiet = config.quiet;\n\n // auto-detection\n if (user.autoDetect !== undefined) out.autoDetect = user.autoDetect;\n else if (config.autoDetect !== undefined) out.autoDetect = config.autoDetect;\n\n if (user.nodeEnvMap !== undefined) out.nodeEnvMap = user.nodeEnvMap;\n else if (config.nodeEnvMap !== undefined) out.nodeEnvMap = config.nodeEnvMap;\n\n // post-load behavior\n if (user.required !== undefined) out.required = user.required;\n else if (config.required !== undefined) out.required = config.required;\n\n if (user.expand !== undefined) out.expand = user.expand;\n else if (config.expand !== undefined) out.expand = config.expand;\n\n if (user.defaults !== undefined) out.defaults = user.defaults;\n else if (config.defaults !== undefined) out.defaults = config.defaults;\n\n // advanced\n if (user.workspaceRoot !== undefined) out.workspaceRoot = user.workspaceRoot;\n else if (config.workspaceRoot !== undefined) out.workspaceRoot = config.workspaceRoot;\n\n if (user.schema !== undefined) out.schema = user.schema;\n else if (config.schema !== undefined) out.schema = config.schema;\n\n if (user.resolvers !== undefined) out.resolvers = user.resolvers;\n else if (config.resolvers !== undefined) out.resolvers = config.resolvers;\n\n if (user.publicPrefixes !== undefined) out.publicPrefixes = user.publicPrefixes;\n else if (config.publicPrefixes !== undefined) out.publicPrefixes = config.publicPrefixes;\n\n if (user.publicSource !== undefined) out.publicSource = user.publicSource;\n else if (config.publicSource !== undefined) out.publicSource = config.publicSource;\n\n return out;\n}\n\nexport default envx;\nexport { envx };\n\n// Re-export the types callers will need to type their own wrappers.\nexport type { LoadEnvOptions };\n\n// #endregion -----------------------------------------------\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@super-repo/envx",
3
3
  "description": "A global executable to run applications with the ENV variables witin a monorepo loaded by dotenvx",
4
- "version": "0.2.3-b.3",
4
+ "version": "0.2.3-b.4",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "envx": "./dist/cli.js",
@@ -60,8 +60,8 @@
60
60
  "vite": "^8.0.11",
61
61
  "vite-plugin-dts": "^5.0.0",
62
62
  "vitest": "^4.1.5",
63
- "@super-repo/cli": "0.2.3-b.3",
64
- "@super-repo/envx-common": "0.0.1",
65
- "@super-repo/envx-libs": "0.0.1"
63
+ "@super-repo/envx-libs": "0.0.1",
64
+ "@super-repo/cli": "0.2.3-b.4",
65
+ "@super-repo/envx-common": "0.0.1"
66
66
  }
67
67
  }
@@ -1,538 +0,0 @@
1
- import { _ as isEncrypted, a as encryptFiles, c as findWorkspaceRoot, d as resolveCwdOrWorkspace, f as resolveEnvPaths, g as parseEnv, h as log, i as decryptFiles, l as listEnvFiles, m as expandEnvSrc, n as loadDotenvxConfig, o as DEFAULT_NODE_ENV_MAP, p as validateCmdVariable, r as rotateFiles, s as detectEnvironment, t as writeProcessed, u as loadEnv } from "./src-CwrtyfZE.js";
2
- import * as fs from "fs";
3
- import * as path from "path";
4
- import yargs from "yargs";
5
- import { execSync } from "child_process";
6
- //#region src/commands/debug.ts
7
- var debugCommand = {
8
- command: "debug",
9
- describe: "Show which env files would be loaded and which variables would be applied, without loading them.",
10
- handler: (argv) => {
11
- const paths = resolveEnvPaths({
12
- envFiles: argv["env"],
13
- cascade: argv["cascade"]
14
- });
15
- const rawVars = argv["variables"];
16
- const variables = rawVars ? Object.fromEntries(rawVars.map(validateCmdVariable)) : {};
17
- log.info(`Paths: ${JSON.stringify(paths)}`);
18
- log.info(`Variables: ${JSON.stringify(variables)}`);
19
- }
20
- };
21
- //#endregion
22
- //#region src/commands/decrypt.ts
23
- /** Mirror of `dotenvx decrypt` from upstream — see also encrypt.ts. */
24
- var decryptCommand = {
25
- command: "decrypt",
26
- describe: "Decrypt the values in one or more .env files in place using the matching private key in .env.keys.",
27
- builder: (yargs) => yargs.option("env-keys-file", {
28
- alias: "fk",
29
- type: "string",
30
- describe: "Path to the .env.keys file (default: ./.env.keys at cwd, regardless of --dir / --env-path)."
31
- }).option("key", {
32
- alias: "k",
33
- type: "array",
34
- string: true,
35
- describe: "Specific keys (or picomatch globs) to decrypt. Default: all keys."
36
- }).option("exclude-key", {
37
- alias: "ek",
38
- type: "array",
39
- string: true,
40
- describe: "Keys (or picomatch globs) to leave encrypted."
41
- }).option("stdout", {
42
- type: "boolean",
43
- default: false,
44
- describe: "Write the decrypted env contents to stdout instead of saving in place."
45
- }).help("h").alias("h", "help"),
46
- handler: (argv) => {
47
- const envFiles = argv["env"] ?? [".env"];
48
- const keys = argv["key"];
49
- const excludeKeys = argv["exclude-key"];
50
- const envKeysFile = argv["env-keys-file"];
51
- const stdout = argv["stdout"] ?? false;
52
- const result = decryptFiles({
53
- envFiles,
54
- ...keys ? { keys } : {},
55
- ...excludeKeys ? { excludeKeys } : {},
56
- ...envKeysFile ? { envKeysFile } : {}
57
- });
58
- let hadError = false;
59
- for (const processed of result.processedEnvs) {
60
- if (processed.error) {
61
- hadError = true;
62
- log.error(`${processed.envFilepath}: ${processed.error.message}`);
63
- if (processed.error.help) log.dim(processed.error.help);
64
- continue;
65
- }
66
- if (stdout) process.stdout.write(processed.envSrc);
67
- }
68
- if (!stdout) {
69
- const { written } = writeProcessed(result.processedEnvs);
70
- for (const w of written) log.success(`decrypted ${w}`);
71
- if (written.length === 0 && result.unchangedFilepaths.length > 0 && !hadError) log.dim(`no changes (${result.unchangedFilepaths.join(", ")})`);
72
- }
73
- if (hadError) process.exitCode = 1;
74
- }
75
- };
76
- //#endregion
77
- //#region src/commands/encrypt.ts
78
- /**
79
- * Mirrors the upstream `dotenvx encrypt` flags so existing muscle
80
- * memory carries over. The `--env` global doubles as the file list
81
- * (the upstream calls it `--env-file`); this CLI keeps a single
82
- * canonical name across subcommands.
83
- */
84
- var encryptCommand = {
85
- command: "encrypt",
86
- describe: "Encrypt the values in one or more .env files. Generates a private key in .env.keys on first run.",
87
- builder: (yargs) => yargs.option("env-keys-file", {
88
- alias: "fk",
89
- type: "string",
90
- describe: "Path to the .env.keys file (default: ./.env.keys at cwd, regardless of --dir / --env-path)."
91
- }).option("key", {
92
- alias: "k",
93
- type: "array",
94
- string: true,
95
- describe: "Specific keys (or picomatch globs) to encrypt. Default: all keys."
96
- }).option("exclude-key", {
97
- alias: "ek",
98
- type: "array",
99
- string: true,
100
- describe: "Keys (or picomatch globs) to leave plaintext."
101
- }).option("stdout", {
102
- type: "boolean",
103
- default: false,
104
- describe: "Write the encrypted env contents to stdout instead of saving in place."
105
- }).help("h").alias("h", "help"),
106
- handler: (argv) => {
107
- const envFiles = argv["env"] ?? [".env"];
108
- const keys = argv["key"];
109
- const excludeKeys = argv["exclude-key"];
110
- const envKeysFile = argv["env-keys-file"];
111
- const stdout = argv["stdout"] ?? false;
112
- const result = encryptFiles({
113
- envFiles,
114
- ...keys ? { keys } : {},
115
- ...excludeKeys ? { excludeKeys } : {},
116
- ...envKeysFile ? { envKeysFile } : {}
117
- });
118
- let hadError = false;
119
- for (const processed of result.processedEnvs) {
120
- if (processed.error) {
121
- hadError = true;
122
- log.error(`${processed.envFilepath}: ${processed.error.message}`);
123
- if (processed.error.help) log.dim(processed.error.help);
124
- continue;
125
- }
126
- if (stdout) {
127
- process.stdout.write(processed.envSrc);
128
- continue;
129
- }
130
- if (processed.privateKeyAdded) log.success(`key added to .env.keys (${processed.privateKeyName ?? "<unknown>"})`);
131
- }
132
- if (!stdout) {
133
- const { written } = writeProcessed(result.processedEnvs);
134
- for (const w of written) log.success(`encrypted ${w}`);
135
- if (written.length === 0 && result.unchangedFilepaths.length > 0 && !hadError) log.dim(`no changes (${result.unchangedFilepaths.join(", ")})`);
136
- }
137
- if (hadError) process.exitCode = 1;
138
- }
139
- };
140
- //#endregion
141
- //#region src/commands/expand.ts
142
- /**
143
- * Decrypts (when needed) and expands variable references in an env
144
- * file. Mirrors the workflow `decrypt-vault` action — but cycle-safe,
145
- * supports `${VAR:-default}` / `${VAR:?msg}`, and never silently
146
- * truncates after N passes.
147
- */
148
- var expandCommand = {
149
- command: "expand",
150
- describe: "Decrypt (if needed) and expand ${VAR}/$VAR references in an env file. Outputs to stdout by default.",
151
- builder: (yargs) => yargs.option("output", {
152
- type: "string",
153
- describe: "Write the expanded result to this file (default: stdout)."
154
- }).option("env-keys-file", {
155
- alias: "fk",
156
- type: "string",
157
- describe: "Path to .env.keys (default: ./.env.keys at cwd, regardless of --dir / --env-path)."
158
- }).option("on-missing", {
159
- type: "string",
160
- choices: [
161
- "leave",
162
- "empty",
163
- "throw"
164
- ],
165
- default: "leave",
166
- describe: "How to handle ${UNRESOLVED_VAR}: leave it literal, substitute empty, or fail."
167
- }).help("h").alias("h", "help"),
168
- handler: (argv) => {
169
- const envFiles = argv["env"] ?? [".env"];
170
- if (envFiles.length !== 1) {
171
- log.error(`expand operates on a single env file at a time; got ${String(envFiles.length)}.`);
172
- process.exit(1);
173
- }
174
- const envFile = envFiles[0];
175
- const filepath = path.resolve(envFile);
176
- if (!fs.existsSync(filepath)) {
177
- log.error(`env file not found: ${envFile}`);
178
- process.exit(1);
179
- }
180
- let envSrc = fs.readFileSync(filepath, "utf8");
181
- if (parseEnv(envSrc).some((l) => l.type === "kv" && isEncrypted(l.value))) {
182
- const envKeysFile = argv["env-keys-file"];
183
- const processed = decryptFiles({
184
- envFiles: [envFile],
185
- ...envKeysFile ? { envKeysFile } : {}
186
- }).processedEnvs[0];
187
- if (processed?.error) {
188
- log.error(`${envFile}: ${processed.error.message}`);
189
- if (processed.error.help) log.dim(processed.error.help);
190
- process.exit(1);
191
- }
192
- envSrc = processed.envSrc;
193
- }
194
- const onMissing = argv["on-missing"];
195
- const result = expandEnvSrc(envSrc, { onMissing });
196
- for (const v of result.unresolved) log.warn(`unresolved variable: ${v}`);
197
- for (const cycle of result.cycles) log.warn(`cycle: ${cycle.join(" → ")}`);
198
- const output = argv["output"];
199
- if (output) {
200
- fs.writeFileSync(path.resolve(output), result.envSrc);
201
- log.success(`expanded ${envFile} → ${output}`);
202
- } else {
203
- process.stdout.write(result.envSrc);
204
- if (!result.envSrc.endsWith("\n")) process.stdout.write("\n");
205
- }
206
- }
207
- };
208
- //#endregion
209
- //#region src/commands/info.ts
210
- /**
211
- * Print everything envx knows about the current invocation: which
212
- * config file it found, the resolved settings, which platform signals
213
- * are present, what auto-detection produced, the NODE_ENV → suffix
214
- * map (built-in + user overrides), and the env file paths it would
215
- * load. Read-only — does not mutate process.env or write any files.
216
- */
217
- var infoCommand = {
218
- command: "info",
219
- describe: "Show resolved configuration, auto-detection details, NODE_ENV mappings, and which env files would be loaded.",
220
- builder: (yargs) => yargs.help("h").alias("h", "help"),
221
- handler: (argv) => {
222
- const cfg = argv["__envxConfig"] ?? {};
223
- const cfgSource = argv["__envxConfigSource"];
224
- const cfgOrigin = argv["__envxConfigOrigin"];
225
- const workspaceRoot = findWorkspaceRoot();
226
- const cwd = process.cwd();
227
- log.info("envx info");
228
- log.dim("─".repeat(60));
229
- log.info("Workspace");
230
- line("cwd", cwd);
231
- line("workspace root", workspaceRoot === cwd ? `${workspaceRoot} (none detected — using cwd)` : workspaceRoot);
232
- blank();
233
- log.info("Config");
234
- line("source", cfgSource ?? "(none — built-in defaults)");
235
- line("origin", cfgOrigin ?? "defaults");
236
- blank();
237
- log.info("Resolved settings");
238
- line("envFiles", argv["env"] ?? cfg.envFiles ?? [".env"]);
239
- line("envPath", argv["env-path"] ?? cfg.envPath ?? "(none)");
240
- line("cascade", formatCascade(argv["cascade"] ?? cfg.cascade));
241
- line("envKeysFile", formatPath(argv["env-keys-file"] ?? cfg.envKeysFile, cwd, workspaceRoot));
242
- line("override", argv["override"] ?? cfg.override ?? false);
243
- line("quiet", argv["quiet"] ?? cfg.quiet ?? true);
244
- line("autoDetect", cfg.autoDetect ?? true);
245
- line("expand", cfg.expand ?? false);
246
- line("required", cfg.required && cfg.required.length > 0 ? cfg.required : "(none)");
247
- line("defaults", cfg.defaults && Object.keys(cfg.defaults).length > 0 ? cfg.defaults : "(none)");
248
- line("workspaceRoot (config)", cfg.workspaceRoot ?? "(auto-detect via findWorkspaceRoot)");
249
- blank();
250
- log.info("Platform signals (process.env)");
251
- line("VERCEL", process.env["VERCEL"] ?? "(unset)");
252
- line("VERCEL_ENV", process.env["VERCEL_ENV"] ?? "(unset)");
253
- line("NETLIFY", process.env["NETLIFY"] ?? "(unset)");
254
- line("CONTEXT", process.env["CONTEXT"] ?? "(unset)");
255
- line("NODE_ENV", process.env.NODE_ENV ?? "(unset)");
256
- blank();
257
- log.info("Auto-detection");
258
- const autoDetect = cfg.autoDetect ?? true;
259
- if (!autoDetect) line("status", "disabled (autoDetect: false)");
260
- else {
261
- const detected = detectEnvironment({ ...cfg.nodeEnvMap !== void 0 ? { nodeEnvMap: cfg.nodeEnvMap } : {} });
262
- line("source", pickDetectionSource());
263
- line("detected", detected);
264
- line("→ env file", detected === "root" ? ".env" : `.env.${detected}`);
265
- }
266
- blank();
267
- log.info("NODE_ENV → suffix mapping");
268
- log.dim(" (any NODE_ENV value not in this map passes through lowercased,");
269
- log.dim(" so e.g. NODE_ENV=qa loads .env.qa)");
270
- const userMap = cfg.nodeEnvMap ?? {};
271
- const merged = {
272
- ...DEFAULT_NODE_ENV_MAP,
273
- ...userMap
274
- };
275
- const allKeys = Array.from(new Set([...Object.keys(merged)])).sort();
276
- for (const k of allKeys) {
277
- const v = merged[k] ?? "";
278
- const suffix = v === "" ? "(no suffix → .env)" : `.env.${v}`;
279
- const origin = userMap[k] === void 0 ? "default" : DEFAULT_NODE_ENV_MAP[k] === void 0 ? "config" : "config (override)";
280
- line(` ${k.padEnd(14)} → ${suffix}`, origin);
281
- }
282
- blank();
283
- log.info("Resolved env file paths (would be loaded in this order)");
284
- const paths = resolveEnvPaths({
285
- ...argv["env"] !== void 0 ? { envFiles: argv["env"] } : {},
286
- ...argv["cascade"] !== void 0 ? { cascade: argv["cascade"] } : {},
287
- autoDetect,
288
- ...cfg.nodeEnvMap !== void 0 ? { nodeEnvMap: cfg.nodeEnvMap } : {}
289
- });
290
- if (paths.length === 0) line("(none)", "");
291
- else {
292
- const subdir = argv["env-path"] ?? (argv["vault"] ? "vault" : "");
293
- for (const p of paths) {
294
- if (path.isAbsolute(p)) {
295
- log.dim(` ${p}`);
296
- continue;
297
- }
298
- const resolved = subdir ? resolveCwdOrWorkspace(path.join(subdir, p)) : resolveCwdOrWorkspace(p);
299
- log.dim(` ${p} → ${resolved}`);
300
- }
301
- }
302
- }
303
- };
304
- function line(key, value, suffix) {
305
- const v = value === void 0 || value === null ? "(unset)" : Array.isArray(value) ? value.length === 0 ? "[]" : JSON.stringify(value) : typeof value === "object" ? JSON.stringify(value) : String(value);
306
- const tail = suffix ? ` ${dim(`(${suffix})`)}` : "";
307
- log.dim(` ${key.padEnd(14)} ${v}${tail}`);
308
- }
309
- function blank() {
310
- console.log("");
311
- }
312
- function dim(s) {
313
- return `\x1b[2m${s}\x1b[22m`;
314
- }
315
- function formatCascade(cascade) {
316
- if (cascade === void 0 || cascade === false) return "(off)";
317
- if (cascade === true) return "true (uses auto-detected env name)";
318
- return String(cascade);
319
- }
320
- function pickDetectionSource() {
321
- if (process.env["VERCEL"]) return "Vercel (VERCEL_ENV)";
322
- if (process.env["NETLIFY"]) return "Netlify (CONTEXT)";
323
- if (process.env.NODE_ENV) return "NODE_ENV";
324
- return "(no signals — fallback to .env)";
325
- }
326
- function formatPath(raw, cwd, wsRoot) {
327
- if (!raw) return `${resolveCwdOrWorkspace(".env.keys", cwd)} (default: cwd-first, ws-root fallback)`;
328
- if (path.isAbsolute(raw)) return `${raw} (absolute)`;
329
- return `${raw} → ${path.resolve(cwd, raw)} (or ${path.resolve(wsRoot, raw)} if not at cwd)`;
330
- }
331
- //#endregion
332
- //#region src/commands/print.ts
333
- var printCommand = {
334
- command: "print <variable>",
335
- describe: "Load env files and print the value of a single variable.",
336
- builder: (yargs) => yargs.positional("variable", {
337
- describe: "Name of the variable to print",
338
- type: "string",
339
- demandOption: true
340
- }),
341
- handler: (argv) => {
342
- loadEnv({
343
- envFiles: argv["env"],
344
- variables: argv["variables"],
345
- cascade: argv["cascade"],
346
- vault: argv["vault"],
347
- envPath: argv["env-path"],
348
- override: argv["override"],
349
- quiet: argv["quiet"]
350
- });
351
- const name = argv["variable"];
352
- const value = process.env[name];
353
- process.stdout.write(value != null ? `${value}\n` : "\n");
354
- }
355
- };
356
- //#endregion
357
- //#region src/commands/rotate.ts
358
- /**
359
- * Rotate the asymmetric keypair for one or more env files. Generates a
360
- * fresh secp256k1 keypair, decrypts existing values with the old
361
- * private key, re-encrypts with the new public key, and updates both
362
- * the `ENVX_PUBLIC_KEY*` header in the env file and the
363
- * `ENVX_PRIVATE_KEY*` entry in `.env.keys`.
364
- *
365
- * Files without a public-key header surface an error — run
366
- * `envx encrypt` against them first to set up the keypair.
367
- */
368
- var rotateCommand = {
369
- command: "rotate",
370
- describe: "Rotate the asymmetric keypair for one or more env files.",
371
- builder: (yargs) => yargs.option("env-keys-file", {
372
- alias: "fk",
373
- type: "string",
374
- describe: "Path to the .env.keys file (default: ./.env.keys at cwd). Relative paths resolve against each env file's directory."
375
- }).option("key", {
376
- alias: "k",
377
- type: "array",
378
- string: true,
379
- describe: "Specific keys (or picomatch globs) to rotate. Default: all encrypted keys."
380
- }).option("exclude-key", {
381
- alias: "ek",
382
- type: "array",
383
- string: true,
384
- describe: "Keys (or picomatch globs) to leave with their existing ciphertext."
385
- }).help("h").alias("h", "help"),
386
- handler: (argv) => {
387
- const envFiles = argv["env"] ?? [".env"];
388
- const keys = argv["key"];
389
- const excludeKeys = argv["exclude-key"];
390
- const envKeysFile = argv["env-keys-file"];
391
- const result = rotateFiles({
392
- envFiles,
393
- ...keys ? { keys } : {},
394
- ...excludeKeys ? { excludeKeys } : {},
395
- ...envKeysFile ? { envKeysFile } : {}
396
- });
397
- let hadError = false;
398
- for (const processed of result.processedEnvs) if (processed.error) {
399
- hadError = true;
400
- log.error(`${processed.envFilepath}: ${processed.error.message}`);
401
- if (processed.error.help) log.dim(processed.error.help);
402
- }
403
- const { written } = writeProcessed(result.processedEnvs);
404
- for (const w of written) log.success(`rotated ${w}`);
405
- if (written.length === 0 && result.unchangedFilepaths.length > 0 && !hadError) log.dim(`no changes (${result.unchangedFilepaths.join(", ")})`);
406
- if (hadError) process.exitCode = 1;
407
- }
408
- };
409
- //#endregion
410
- //#region src/commands/run.ts
411
- var runCommand = {
412
- command: "run [command..]",
413
- aliases: ["$0"],
414
- describe: "Load env files into process.env and execute a command. Default subcommand — `dotenvx-run [command]` is equivalent.",
415
- builder: (yargs) => yargs.positional("command", {
416
- describe: "Command to execute after loading env files",
417
- type: "string",
418
- array: true
419
- }),
420
- handler: (argv) => {
421
- const command = (argv["command"] ?? []).join(" ");
422
- const cfg = argv["__envxConfig"] ?? {};
423
- loadEnv({
424
- envFiles: argv["env"],
425
- variables: argv["variables"],
426
- cascade: argv["cascade"],
427
- vault: argv["vault"],
428
- envPath: argv["env-path"],
429
- override: argv["override"],
430
- quiet: argv["quiet"],
431
- ...cfg.autoDetect !== void 0 ? { autoDetect: cfg.autoDetect } : {},
432
- ...cfg.nodeEnvMap !== void 0 ? { nodeEnvMap: cfg.nodeEnvMap } : {},
433
- ...cfg.required !== void 0 ? { required: cfg.required } : {},
434
- ...cfg.expand !== void 0 ? { expand: cfg.expand } : {},
435
- ...cfg.defaults !== void 0 ? { defaults: cfg.defaults } : {},
436
- ...cfg.workspaceRoot !== void 0 ? { workspaceRoot: cfg.workspaceRoot } : {}
437
- });
438
- if (!command) return;
439
- log.info(`Running: ${command}`);
440
- try {
441
- execSync(command, { stdio: "inherit" });
442
- log.success(`Command completed: ${command}`);
443
- } catch (error) {
444
- const msg = error instanceof Error ? error.message : String(error);
445
- log.error(`Command failed: ${msg}`);
446
- process.exit(1);
447
- }
448
- }
449
- };
450
- //#endregion
451
- //#region src/commands/index.ts
452
- /**
453
- * Build the yargs CLI for `dotenvx-run`. Global options (env, variables,
454
- * cascade, vault, override, quiet) are registered on the root so every
455
- * subcommand inherits them.
456
- */
457
- function createCli(argvInput) {
458
- return yargs(argvInput).scriptName("envx").usage("$0 <command> [options]").option("config", {
459
- alias: "c",
460
- type: "string",
461
- describe: "Path to an envx config file (default: discovered from package.json `envx.config` or envx.config.{ts,js,json})."
462
- }).option("env", {
463
- alias: "e",
464
- type: "array",
465
- describe: "Env files to load. Default: [\".env\"] (or `envFiles` from config; or every .env* under --env-path when set). Auto-detects environment when omitted."
466
- }).option("env-path", {
467
- alias: ["dir", "d"],
468
- type: "string",
469
- describe: "Subdirectory of the workspace root holding the env files (e.g. `vault`). When set and --env is omitted, every .env* file in that directory is included."
470
- }).option("variables", {
471
- alias: "v",
472
- type: "array",
473
- describe: "Inline variables in the form name=value (repeatable).",
474
- default: []
475
- }).option("cascade", {
476
- type: "string",
477
- describe: "Cascade load order: .env, .env.<cascade>, .env.local, .env.<cascade>.local"
478
- }).option("vault", {
479
- alias: "va",
480
- type: "boolean",
481
- describe: "Shortcut for `--env-path vault`."
482
- }).option("override", {
483
- alias: "o",
484
- type: "boolean",
485
- describe: "Override existing process.env values. Conflicts with --cascade."
486
- }).option("quiet", {
487
- alias: "q",
488
- type: "boolean",
489
- describe: "Suppress dotenv's own output."
490
- }).middleware((argv) => {
491
- const configPath = argv["config"];
492
- let loaded;
493
- try {
494
- loaded = loadDotenvxConfig({ ...configPath ? { configPath } : {} });
495
- } catch (e) {
496
- log.error(`config error: ${e.message}`);
497
- process.exit(1);
498
- }
499
- if (loaded.source) log.dim(`config: ${loaded.source} (${loaded.origin})`);
500
- const cfg = loaded.config;
501
- argv["__envxConfig"] = cfg;
502
- argv["__envxConfigSource"] = loaded.source;
503
- argv["__envxConfigOrigin"] = loaded.origin;
504
- if (argv["cascade"] === void 0 && cfg.cascade !== void 0) argv["cascade"] = cfg.cascade;
505
- if (argv["override"] === void 0) argv["override"] = cfg.override ?? false;
506
- if (argv["quiet"] === void 0) argv["quiet"] = cfg.quiet ?? true;
507
- if (argv["vault"] === void 0) argv["vault"] = false;
508
- if (argv["env-keys-file"] === void 0 && cfg.envKeysFile !== void 0) argv["env-keys-file"] = cfg.envKeysFile;
509
- if (argv["env-path"] === void 0) {
510
- if (cfg.envPath !== void 0) argv["env-path"] = cfg.envPath;
511
- else if (argv["vault"]) argv["env-path"] = "vault";
512
- }
513
- const userPassedEnv = Array.isArray(argv["env"]) && argv["env"].length > 0;
514
- let files;
515
- if (userPassedEnv) files = argv["env"];
516
- else if (cfg.envFiles && cfg.envFiles.length > 0) files = [...cfg.envFiles];
517
- else if (typeof argv["env-path"] === "string") {
518
- const subdir = argv["env-path"];
519
- const discovered = listEnvFiles(resolveCwdOrWorkspace(subdir));
520
- if (discovered.length > 0) {
521
- files = discovered;
522
- log.dim(`env-path ${subdir}: discovered ${String(discovered.length)} file(s) — ${discovered.join(", ")}`);
523
- } else {
524
- files = [".env"];
525
- log.warn(`env-path ${subdir}: no .env* files found; falling back to [".env"]`);
526
- }
527
- } else files = [".env"];
528
- if (typeof argv["env-path"] === "string") {
529
- const dir = resolveCwdOrWorkspace(argv["env-path"]);
530
- files = files.map((f) => path.isAbsolute(f) ? f : path.join(dir, f));
531
- }
532
- argv["env"] = files;
533
- }).command(runCommand).command(printCommand).command(debugCommand).command(encryptCommand).command(decryptCommand).command(expandCommand).command(rotateCommand).command(infoCommand).help("h").alias("h", "help").version().strictCommands().demandCommand(0).recommendCommands().epilog("Examples:\n envx -- node app.js # load .env (auto-detected) and run\n envx --env dev -- pnpm start # load .env.dev\n envx print DATABASE_URL # print one variable\n envx debug --cascade prod # show resolved paths\n envx encrypt -e .env.prod # encrypt values in .env.prod\n envx decrypt -e .env.prod -k FOO # decrypt only FOO\n envx expand -e vault/.env.prod # decrypt + expand to stdout\n envx -c ./my.config.json run -- node app.js");
534
- }
535
- //#endregion
536
- export { createCli as t };
537
-
538
- //# sourceMappingURL=commands-DNf_gJRx.js.map