scenv 0.9.0 → 1.0.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.
- package/README.md +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ await apiUrl.save(); // write current value to a context file
|
|
|
42
42
|
|
|
43
43
|
Any string value matching **`@<context>:<key>`** (e.g. `@prod:core_server_url`) is resolved from that context file first—in set, env, context, default, and prompts.
|
|
44
44
|
|
|
45
|
-
Prompting
|
|
45
|
+
Prompting is off by default (`prompt: "never"`). To enable it, set config `prompt` to `always`, `fallback`, or `no-env` (via config file, `SCENV_PROMPT`, or `configure()`).
|
|
46
46
|
|
|
47
47
|
## Optional integrations
|
|
48
48
|
|
package/dist/index.cjs
CHANGED
|
@@ -526,7 +526,7 @@ function scenv(name, options = {}) {
|
|
|
526
526
|
return { raw: void 0, source: void 0 };
|
|
527
527
|
}
|
|
528
528
|
function shouldPrompt(config, hadValue, hadEnv) {
|
|
529
|
-
const mode = config.prompt ?? "
|
|
529
|
+
const mode = config.prompt ?? "never";
|
|
530
530
|
if (mode === "never") return false;
|
|
531
531
|
if (mode === "always") return true;
|
|
532
532
|
if (mode === "fallback") return !hadValue;
|
|
@@ -542,7 +542,7 @@ function scenv(name, options = {}) {
|
|
|
542
542
|
const doPrompt = shouldPrompt(config, hadValue, hadEnv);
|
|
543
543
|
log(
|
|
544
544
|
"debug",
|
|
545
|
-
`prompt decision key=${key} prompt=${config.prompt ?? "
|
|
545
|
+
`prompt decision key=${key} prompt=${config.prompt ?? "never"} hadValue=${hadValue} hadEnv=${hadEnv} -> ${doPrompt ? "prompt" : "no prompt"}`
|
|
546
546
|
);
|
|
547
547
|
const effectiveDefault = overrides?.default !== void 0 ? overrides.default : defaultValue;
|
|
548
548
|
const resolvedDefault = effectiveDefault === void 0 ? void 0 : typeof effectiveDefault === "string" ? resolveContextReference(effectiveDefault, key) : effectiveDefault;
|
package/dist/index.d.cts
CHANGED
|
@@ -29,7 +29,7 @@ interface ScenvConfig {
|
|
|
29
29
|
context?: string[];
|
|
30
30
|
/** Merge these context names with existing (CLI: `--add-context a,b,c`). Ignored if `context` is set in the same layer. */
|
|
31
31
|
addContext?: string[];
|
|
32
|
-
/** When to prompt for a variable value. See {@link PromptMode}. Default is `"
|
|
32
|
+
/** When to prompt for a variable value. See {@link PromptMode}. Default is `"never"`; set to `always`, `fallback`, or `no-env` to enable prompting (via config file, SCENV_PROMPT, or configure()). */
|
|
33
33
|
prompt?: PromptMode;
|
|
34
34
|
/** If true, environment variables are not used during resolution. */
|
|
35
35
|
ignoreEnv?: boolean;
|
|
@@ -203,7 +203,7 @@ interface ScenvVariableOptions<T = string> {
|
|
|
203
203
|
default?: T;
|
|
204
204
|
/** Optional. Parses the raw string (or default) into output type T. Receives raw value (typically string). Return { success: true, data } with the parsed value; variable type is inferred from data. */
|
|
205
205
|
parser?: (val: unknown) => ParserResult<T>;
|
|
206
|
-
/** Optional. Called when config
|
|
206
|
+
/** Optional. Called when config has enabled prompting (e.g. prompt: "fallback" and no value found). Overrides callbacks.defaultPrompt for this variable. */
|
|
207
207
|
prompt?: PromptFn<T>;
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
@@ -254,7 +254,7 @@ interface ScenvVariable<T> {
|
|
|
254
254
|
* - Environment variable (e.g. API_URL for key "api_url")
|
|
255
255
|
* - Context files (merged key-value from the context list in config, e.g. dev.context.json)
|
|
256
256
|
*
|
|
257
|
-
* If
|
|
257
|
+
* If prompting is enabled in config (prompt: "always", "fallback", or "no-env"), the prompt callback
|
|
258
258
|
* may run. When it runs, it receives the variable name and a suggested value (the raw value if any, otherwise
|
|
259
259
|
* the default option). The callback's return value is used as the value. When we don't prompt, we use the
|
|
260
260
|
* raw value if present, otherwise the default option, otherwise get() throws (no value).
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ interface ScenvConfig {
|
|
|
29
29
|
context?: string[];
|
|
30
30
|
/** Merge these context names with existing (CLI: `--add-context a,b,c`). Ignored if `context` is set in the same layer. */
|
|
31
31
|
addContext?: string[];
|
|
32
|
-
/** When to prompt for a variable value. See {@link PromptMode}. Default is `"
|
|
32
|
+
/** When to prompt for a variable value. See {@link PromptMode}. Default is `"never"`; set to `always`, `fallback`, or `no-env` to enable prompting (via config file, SCENV_PROMPT, or configure()). */
|
|
33
33
|
prompt?: PromptMode;
|
|
34
34
|
/** If true, environment variables are not used during resolution. */
|
|
35
35
|
ignoreEnv?: boolean;
|
|
@@ -203,7 +203,7 @@ interface ScenvVariableOptions<T = string> {
|
|
|
203
203
|
default?: T;
|
|
204
204
|
/** Optional. Parses the raw string (or default) into output type T. Receives raw value (typically string). Return { success: true, data } with the parsed value; variable type is inferred from data. */
|
|
205
205
|
parser?: (val: unknown) => ParserResult<T>;
|
|
206
|
-
/** Optional. Called when config
|
|
206
|
+
/** Optional. Called when config has enabled prompting (e.g. prompt: "fallback" and no value found). Overrides callbacks.defaultPrompt for this variable. */
|
|
207
207
|
prompt?: PromptFn<T>;
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
@@ -254,7 +254,7 @@ interface ScenvVariable<T> {
|
|
|
254
254
|
* - Environment variable (e.g. API_URL for key "api_url")
|
|
255
255
|
* - Context files (merged key-value from the context list in config, e.g. dev.context.json)
|
|
256
256
|
*
|
|
257
|
-
* If
|
|
257
|
+
* If prompting is enabled in config (prompt: "always", "fallback", or "no-env"), the prompt callback
|
|
258
258
|
* may run. When it runs, it receives the variable name and a suggested value (the raw value if any, otherwise
|
|
259
259
|
* the default option). The callback's return value is used as the value. When we don't prompt, we use the
|
|
260
260
|
* raw value if present, otherwise the default option, otherwise get() throws (no value).
|
package/dist/index.js
CHANGED
|
@@ -493,7 +493,7 @@ function scenv(name, options = {}) {
|
|
|
493
493
|
return { raw: void 0, source: void 0 };
|
|
494
494
|
}
|
|
495
495
|
function shouldPrompt(config, hadValue, hadEnv) {
|
|
496
|
-
const mode = config.prompt ?? "
|
|
496
|
+
const mode = config.prompt ?? "never";
|
|
497
497
|
if (mode === "never") return false;
|
|
498
498
|
if (mode === "always") return true;
|
|
499
499
|
if (mode === "fallback") return !hadValue;
|
|
@@ -509,7 +509,7 @@ function scenv(name, options = {}) {
|
|
|
509
509
|
const doPrompt = shouldPrompt(config, hadValue, hadEnv);
|
|
510
510
|
log(
|
|
511
511
|
"debug",
|
|
512
|
-
`prompt decision key=${key} prompt=${config.prompt ?? "
|
|
512
|
+
`prompt decision key=${key} prompt=${config.prompt ?? "never"} hadValue=${hadValue} hadEnv=${hadEnv} -> ${doPrompt ? "prompt" : "no prompt"}`
|
|
513
513
|
);
|
|
514
514
|
const effectiveDefault = overrides?.default !== void 0 ? overrides.default : defaultValue;
|
|
515
515
|
const resolvedDefault = effectiveDefault === void 0 ? void 0 : typeof effectiveDefault === "string" ? resolveContextReference(effectiveDefault, key) : effectiveDefault;
|