@optique/config 1.3.0 → 1.4.0-dev.2600
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 +9 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -27,6 +27,8 @@ Quick start
|
|
|
27
27
|
-----------
|
|
28
28
|
|
|
29
29
|
~~~~ typescript
|
|
30
|
+
import { homedir } from "node:os";
|
|
31
|
+
import { join } from "node:path";
|
|
30
32
|
import { z } from "zod";
|
|
31
33
|
import { createConfigContext, bindConfig } from "@optique/config";
|
|
32
34
|
import { object } from "@optique/core/constructs";
|
|
@@ -45,7 +47,10 @@ const configContext = createConfigContext({ schema: configSchema });
|
|
|
45
47
|
|
|
46
48
|
// 2. Bind parsers to config values
|
|
47
49
|
const parser = object({
|
|
48
|
-
config: withDefault(
|
|
50
|
+
config: withDefault(
|
|
51
|
+
option("--config", string()),
|
|
52
|
+
join(homedir(), ".myapp.json"),
|
|
53
|
+
),
|
|
49
54
|
host: bindConfig(option("--host", string()), {
|
|
50
55
|
context: configContext,
|
|
51
56
|
key: "host",
|
|
@@ -61,7 +66,9 @@ const parser = object({
|
|
|
61
66
|
// 3. Run with config support via contexts
|
|
62
67
|
const result = await runAsync(parser, {
|
|
63
68
|
contexts: [configContext],
|
|
64
|
-
|
|
69
|
+
contextOptions: {
|
|
70
|
+
getConfigPath: (parsed) => parsed.config,
|
|
71
|
+
},
|
|
65
72
|
args: process.argv.slice(2),
|
|
66
73
|
});
|
|
67
74
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-dev.2600",
|
|
4
4
|
"description": "Configuration file support for Optique with Standard Schema validation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@standard-schema/spec": "^1.1.0"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@optique/core": "1.
|
|
68
|
+
"@optique/core": "1.4.0-dev.2600+6c98c033"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@optique/env": "1.
|
|
71
|
+
"@optique/env": "1.4.0-dev.2600+6c98c033",
|
|
72
72
|
"@standard-schema/spec": "^1.1.0",
|
|
73
73
|
"@types/node": "^24.0.0",
|
|
74
74
|
"fast-check": "^4.7.0",
|