@maestro-js/config 1.0.0-alpha.23 → 1.0.0-alpha.25

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 CHANGED
@@ -16,12 +16,23 @@ await Config.loadConfigFile({
16
16
  })
17
17
  ```
18
18
 
19
- Or auto-load at startup without application code:
19
+ Or auto-load at startup without application code. Options come from CLI flags or environment variables (CLI flags take precedence):
20
20
 
21
21
  ```bash
22
- node --import @maestro-js/config/load --config app --env production --root /path/to/project
22
+ # CLI flags
23
+ node --import @maestro-js/config/load app.js --config app --env production
24
+
25
+ # Environment variables
26
+ MAESTRO_CONFIG_NAME=app MAESTRO_ENV_NAME=production node --import @maestro-js/config/load app.js
23
27
  ```
24
28
 
29
+ | CLI flag | Env var | Description |
30
+ | ---------- | ------------------------------- | -------------------------------------------------- |
31
+ | `--config` | `MAESTRO_CONFIG_NAME` | Config file name without extension (**required**) |
32
+ | `--env` | `MAESTRO_ENV_NAME` / `ENV_NAME` | Environment name (`.env.<name>`) |
33
+ | `--key` | `MAESTRO_ENV_ENCRYPTION_KEY` | 64-char hex key for encrypted `.env` files |
34
+ | `--root` | `MAESTRO_CONFIG_ROOT` | Project root (defaults to `process.cwd()`) |
35
+
25
36
  ## API Reference
26
37
 
27
38
  ### ConfigOptions
@@ -172,13 +183,16 @@ Encrypted values use the format `<iv_base64>.<authTag_base64>.<ciphertext_base64
172
183
 
173
184
  ### Auto-load entry point
174
185
 
175
- The `@maestro-js/config/load` export is a standalone script intended for `node --import`. It parses CLI arguments and calls `Config.loadConfigFile`.
186
+ The `@maestro-js/config/load` export is a standalone script intended for `node --import`. It resolves options from CLI flags or the environment variables below — CLI flags take precedence — and calls `Config.loadConfigFile`.
187
+
188
+ | Option | Environment variable | Default |
189
+ | --- | --- | --- |
190
+ | Config name (required) | `MAESTRO_CONFIG_NAME` | — |
191
+ | Environment name | `MAESTRO_ENV_NAME` (falls back to `ENV_NAME`) | `null` (`.env`) |
192
+ | Encryption key | `MAESTRO_ENV_ENCRYPTION_KEY` | `null` |
193
+ | Project root | `MAESTRO_CONFIG_ROOT` | `process.cwd()` |
176
194
 
177
- CLI flags:
178
- - `--config <name>` (required) -- config file name without extension
179
- - `--env <name>` -- environment name
180
- - `--key <hex>` -- encryption key (falls back to `MAESTRO_ENV_ENCRYPTION_KEY` env var)
181
- - `--root <path>` -- project root (defaults to `process.cwd()`)
195
+ With `node --import`, any CLI flags must be placed **after** the script name — flags before it are parsed by Node itself and rejected. Environment variables aren't position-sensitive, so they're the simpler path for `--import`.
182
196
 
183
197
  ## Cross-Package Integration
184
198
 
package/dist/load.js CHANGED
@@ -3,17 +3,17 @@ import {
3
3
  } from "./chunk-AVYD4MV2.js";
4
4
 
5
5
  // src/load.ts
6
- import "path";
7
- var { configName, envName, encryptionKey, rootDir } = parseArgs(process.argv);
6
+ var { configName, envName, encryptionKey, rootDir } = resolveOptions();
8
7
  await Config.loadConfigFile({ rootDir, configName, envName, encryptionKey });
9
- function parseArgs(argv) {
10
- const configName2 = getArgValue(argv, "--config");
8
+ function resolveOptions() {
9
+ const argv = process.argv;
10
+ const configName2 = getArgValue(argv, "--config") ?? process.env["MAESTRO_CONFIG_NAME"];
11
11
  if (!configName2) {
12
- throw new Error("Missing required --config <name> argument");
12
+ throw new Error("Missing required config name (--config <name> or MAESTRO_CONFIG_NAME)");
13
13
  }
14
- const envName2 = getArgValue(argv, "--env") ?? null;
14
+ const envName2 = getArgValue(argv, "--env") ?? process.env["MAESTRO_ENV_NAME"] ?? process.env["ENV_NAME"] ?? null;
15
15
  const encryptionKey2 = getArgValue(argv, "--key") ?? process.env["MAESTRO_ENV_ENCRYPTION_KEY"] ?? null;
16
- const rootDir2 = getArgValue(argv, "--root") ?? process.cwd();
16
+ const rootDir2 = getArgValue(argv, "--root") ?? process.env["MAESTRO_CONFIG_ROOT"] ?? process.cwd();
17
17
  return { configName: configName2, envName: envName2, encryptionKey: encryptionKey2, rootDir: rootDir2 };
18
18
  }
19
19
  function getArgValue(argv, flag) {
package/package.json CHANGED
@@ -15,9 +15,9 @@
15
15
  "devDependencies": {
16
16
  "@types/node": "^22.19.11"
17
17
  },
18
- "version": "1.0.0-alpha.23",
18
+ "version": "1.0.0-alpha.25",
19
19
  "publishConfig": {
20
- "access": "restricted"
20
+ "access": "public"
21
21
  },
22
22
  "files": [
23
23
  "dist"