scenv-inquirer 0.4.0 → 0.4.1
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 +4 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ npm install scenv scenv-inquirer inquirer
|
|
|
18
18
|
|
|
19
19
|
### Variable prompt
|
|
20
20
|
|
|
21
|
-
Use `prompt()` as the `prompt` option for a variable. Scenv calls it with `(name, defaultValue)` when it needs to ask the user.
|
|
21
|
+
Use `prompt()` as the `prompt` option for a variable. Scenv calls it with `(name, defaultValue)` when it needs to ask the user. **Scenv does not prompt by default** — enable prompting via config (e.g. `configure({ prompt: "fallback" })`, `SCENV_PROMPT=fallback`, or `prompt` in `scenv.config.json`).
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
24
|
import { scenv } from "scenv";
|
|
@@ -29,7 +29,8 @@ const apiUrl = scenv("API URL", {
|
|
|
29
29
|
prompt: prompt(),
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
configure({ prompt: "fallback" }); // or "always" / "no-env"
|
|
33
|
+
const url = await apiUrl.get(); // prompts via inquirer if no env/context
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
### Default prompt for all variables
|
|
@@ -56,7 +57,7 @@ configure(callbacks());
|
|
|
56
57
|
configure({ ...yourConfig, ...callbacks() });
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
This sets **defaultPrompt** so variable values are prompted via inquirer when no value is resolved from set/env/context.
|
|
60
|
+
This sets **defaultPrompt** so variable values are prompted via inquirer when no value is resolved from set/env/context. You must still enable prompting in scenv (e.g. `configure({ prompt: "fallback" })`).
|
|
60
61
|
|
|
61
62
|
## API
|
|
62
63
|
|
package/dist/index.d.cts
CHANGED
|
@@ -4,9 +4,9 @@ import { ScenvCallbacks, DefaultPromptFn } from 'scenv';
|
|
|
4
4
|
* Returns an inquirer-based prompt function for use with scenv variables. Use as the
|
|
5
5
|
* variable's `prompt` option or as `callbacks.defaultPrompt`. Scenv calls it with the
|
|
6
6
|
* variable name and default value when prompting; this shows an inquirer input prompt.
|
|
7
|
-
* Returned value is a string; use a
|
|
7
|
+
* Returned value is a string; use a parser (e.g. scenv-zod) for type coercion.
|
|
8
8
|
*
|
|
9
|
-
* @typeParam T - Value type (default string). Cast or
|
|
9
|
+
* @typeParam T - Value type (default string). Cast or parse in your parser.
|
|
10
10
|
* @returns A function `(name, defaultValue) => Promise<T>` suitable for scenv's prompt or defaultPrompt.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { ScenvCallbacks, DefaultPromptFn } from 'scenv';
|
|
|
4
4
|
* Returns an inquirer-based prompt function for use with scenv variables. Use as the
|
|
5
5
|
* variable's `prompt` option or as `callbacks.defaultPrompt`. Scenv calls it with the
|
|
6
6
|
* variable name and default value when prompting; this shows an inquirer input prompt.
|
|
7
|
-
* Returned value is a string; use a
|
|
7
|
+
* Returned value is a string; use a parser (e.g. scenv-zod) for type coercion.
|
|
8
8
|
*
|
|
9
|
-
* @typeParam T - Value type (default string). Cast or
|
|
9
|
+
* @typeParam T - Value type (default string). Cast or parse in your parser.
|
|
10
10
|
* @returns A function `(name, defaultValue) => Promise<T>` suitable for scenv's prompt or defaultPrompt.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
package/package.json
CHANGED