@optique/env 1.0.0-dev.1658 → 1.0.0-dev.1659
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.cjs +21 -36
- package/dist/index.js +21 -36
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,6 @@ const __optique_core_parser = __toESM(require("@optique/core/parser"));
|
|
|
28
28
|
const __optique_core_valueparser = __toESM(require("@optique/core/valueparser"));
|
|
29
29
|
|
|
30
30
|
//#region src/index.ts
|
|
31
|
-
const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
|
|
32
31
|
const activeEnvSourceRegistry = /* @__PURE__ */ new Map();
|
|
33
32
|
/**
|
|
34
33
|
* Sets active environment source data for a context.
|
|
@@ -139,12 +138,7 @@ function bindEnv(parser, options) {
|
|
|
139
138
|
initialState: parser.initialState,
|
|
140
139
|
getSuggestRuntimeNodes(state, path) {
|
|
141
140
|
const innerState = isEnvBindState(state) ? state.cliState === void 0 ? parser.initialState : state.cliState : state;
|
|
142
|
-
|
|
143
|
-
return boundParser.dependencyMetadata?.source != null ? [...innerNodes, {
|
|
144
|
-
path,
|
|
145
|
-
parser: boundParser,
|
|
146
|
-
state
|
|
147
|
-
}] : innerNodes;
|
|
141
|
+
return (0, __optique_core_parser.getDelegatingSuggestRuntimeNodes)(parser, boundParser, state, path, innerState);
|
|
148
142
|
},
|
|
149
143
|
parse: (context) => {
|
|
150
144
|
const annotations = (0, __optique_core_annotations.getAnnotations)(context.state);
|
|
@@ -199,10 +193,7 @@ function bindEnv(parser, options) {
|
|
|
199
193
|
return parser.getDocFragments(state, defaultValue);
|
|
200
194
|
}
|
|
201
195
|
};
|
|
202
|
-
|
|
203
|
-
value: true,
|
|
204
|
-
configurable: true
|
|
205
|
-
});
|
|
196
|
+
(0, __optique_core_parser.defineInheritedAnnotationParser)(boundParser);
|
|
206
197
|
if ("placeholder" in parser) Object.defineProperty(boundParser, "placeholder", {
|
|
207
198
|
get() {
|
|
208
199
|
return parser.placeholder;
|
|
@@ -215,30 +206,24 @@ function bindEnv(parser, options) {
|
|
|
215
206
|
configurable: true,
|
|
216
207
|
enumerable: false
|
|
217
208
|
});
|
|
218
|
-
const dependencyMetadata = parser.dependencyMetadata
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
configurable: true,
|
|
239
|
-
enumerable: false
|
|
240
|
-
});
|
|
241
|
-
}
|
|
209
|
+
const dependencyMetadata = (0, __optique_core_parser.composeWrappedSourceMetadata)(parser.dependencyMetadata, (sourceMetadata) => ({
|
|
210
|
+
...sourceMetadata,
|
|
211
|
+
extractSourceValue: (state) => {
|
|
212
|
+
if (!isEnvBindState(state)) {
|
|
213
|
+
if (sourceMetadata.preservesSourceValue) return getEnvSourceValue(state, options, state, sourceMetadata.extractSourceValue);
|
|
214
|
+
return sourceMetadata.extractSourceValue(state);
|
|
215
|
+
}
|
|
216
|
+
if (state.hasCliValue) return sourceMetadata.extractSourceValue(state.cliState);
|
|
217
|
+
const innerState = state.cliState ?? state;
|
|
218
|
+
if (!sourceMetadata.preservesSourceValue) return sourceMetadata.extractSourceValue(innerState);
|
|
219
|
+
return getEnvSourceValue(state, options, innerState, sourceMetadata.extractSourceValue);
|
|
220
|
+
}
|
|
221
|
+
}));
|
|
222
|
+
if (dependencyMetadata != null) Object.defineProperty(boundParser, "dependencyMetadata", {
|
|
223
|
+
value: dependencyMetadata,
|
|
224
|
+
configurable: true,
|
|
225
|
+
enumerable: false
|
|
226
|
+
});
|
|
242
227
|
return boundParser;
|
|
243
228
|
}
|
|
244
229
|
function getEnvOrDefault(state, options, mode, innerParser, innerState, exec) {
|
|
@@ -262,7 +247,7 @@ function getEnvOrDefault(state, options, mode, innerParser, innerState, exec) {
|
|
|
262
247
|
value: options.default
|
|
263
248
|
});
|
|
264
249
|
if (innerParser != null) {
|
|
265
|
-
const completeState = innerState ?? (annotations != null && innerParser.initialState == null && Reflect.get(innerParser, inheritParentAnnotationsKey) === true ? (0, __optique_core_annotations.injectAnnotations)(innerParser.initialState, annotations) : innerParser.initialState);
|
|
250
|
+
const completeState = innerState ?? (annotations != null && innerParser.initialState == null && Reflect.get(innerParser, __optique_core_parser.inheritParentAnnotationsKey) === true ? (0, __optique_core_annotations.injectAnnotations)(innerParser.initialState, annotations) : innerParser.initialState);
|
|
266
251
|
return (0, __optique_core_mode_dispatch.wrapForMode)(mode, innerParser.complete(completeState, exec));
|
|
267
252
|
}
|
|
268
253
|
return (0, __optique_core_mode_dispatch.wrapForMode)(mode, {
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { annotationKey, getAnnotations, injectAnnotations, isInjectedAnnotationWrapper } from "@optique/core/annotations";
|
|
2
2
|
import { envVar, message, valueSet } from "@optique/core/message";
|
|
3
3
|
import { mapModeValue, wrapForMode } from "@optique/core/mode-dispatch";
|
|
4
|
-
import { unmatchedNonCliDependencySourceStateMarker } from "@optique/core/parser";
|
|
4
|
+
import { composeWrappedSourceMetadata, defineInheritedAnnotationParser, getDelegatingSuggestRuntimeNodes, inheritParentAnnotationsKey, unmatchedNonCliDependencySourceStateMarker } from "@optique/core/parser";
|
|
5
5
|
import { ensureNonEmptyString, isValueParser } from "@optique/core/valueparser";
|
|
6
6
|
|
|
7
7
|
//#region src/index.ts
|
|
8
|
-
const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
|
|
9
8
|
const activeEnvSourceRegistry = /* @__PURE__ */ new Map();
|
|
10
9
|
/**
|
|
11
10
|
* Sets active environment source data for a context.
|
|
@@ -116,12 +115,7 @@ function bindEnv(parser, options) {
|
|
|
116
115
|
initialState: parser.initialState,
|
|
117
116
|
getSuggestRuntimeNodes(state, path) {
|
|
118
117
|
const innerState = isEnvBindState(state) ? state.cliState === void 0 ? parser.initialState : state.cliState : state;
|
|
119
|
-
|
|
120
|
-
return boundParser.dependencyMetadata?.source != null ? [...innerNodes, {
|
|
121
|
-
path,
|
|
122
|
-
parser: boundParser,
|
|
123
|
-
state
|
|
124
|
-
}] : innerNodes;
|
|
118
|
+
return getDelegatingSuggestRuntimeNodes(parser, boundParser, state, path, innerState);
|
|
125
119
|
},
|
|
126
120
|
parse: (context) => {
|
|
127
121
|
const annotations = getAnnotations(context.state);
|
|
@@ -176,10 +170,7 @@ function bindEnv(parser, options) {
|
|
|
176
170
|
return parser.getDocFragments(state, defaultValue);
|
|
177
171
|
}
|
|
178
172
|
};
|
|
179
|
-
|
|
180
|
-
value: true,
|
|
181
|
-
configurable: true
|
|
182
|
-
});
|
|
173
|
+
defineInheritedAnnotationParser(boundParser);
|
|
183
174
|
if ("placeholder" in parser) Object.defineProperty(boundParser, "placeholder", {
|
|
184
175
|
get() {
|
|
185
176
|
return parser.placeholder;
|
|
@@ -192,30 +183,24 @@ function bindEnv(parser, options) {
|
|
|
192
183
|
configurable: true,
|
|
193
184
|
enumerable: false
|
|
194
185
|
});
|
|
195
|
-
const dependencyMetadata = parser.dependencyMetadata
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
configurable: true,
|
|
216
|
-
enumerable: false
|
|
217
|
-
});
|
|
218
|
-
}
|
|
186
|
+
const dependencyMetadata = composeWrappedSourceMetadata(parser.dependencyMetadata, (sourceMetadata) => ({
|
|
187
|
+
...sourceMetadata,
|
|
188
|
+
extractSourceValue: (state) => {
|
|
189
|
+
if (!isEnvBindState(state)) {
|
|
190
|
+
if (sourceMetadata.preservesSourceValue) return getEnvSourceValue(state, options, state, sourceMetadata.extractSourceValue);
|
|
191
|
+
return sourceMetadata.extractSourceValue(state);
|
|
192
|
+
}
|
|
193
|
+
if (state.hasCliValue) return sourceMetadata.extractSourceValue(state.cliState);
|
|
194
|
+
const innerState = state.cliState ?? state;
|
|
195
|
+
if (!sourceMetadata.preservesSourceValue) return sourceMetadata.extractSourceValue(innerState);
|
|
196
|
+
return getEnvSourceValue(state, options, innerState, sourceMetadata.extractSourceValue);
|
|
197
|
+
}
|
|
198
|
+
}));
|
|
199
|
+
if (dependencyMetadata != null) Object.defineProperty(boundParser, "dependencyMetadata", {
|
|
200
|
+
value: dependencyMetadata,
|
|
201
|
+
configurable: true,
|
|
202
|
+
enumerable: false
|
|
203
|
+
});
|
|
219
204
|
return boundParser;
|
|
220
205
|
}
|
|
221
206
|
function getEnvOrDefault(state, options, mode, innerParser, innerState, exec) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/env",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.1659+94dcbc28",
|
|
4
4
|
"description": "Environment variable support for Optique",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"sideEffects": false,
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@optique/core": "1.0.0-dev.
|
|
57
|
+
"@optique/core": "1.0.0-dev.1659+94dcbc28"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^20.19.9",
|