@lowdefy/build 4.0.0-alpha.30 → 4.0.0-alpha.31
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.
|
@@ -20,6 +20,7 @@ function makeRefDefinition(refDefinition) {
|
|
|
20
20
|
id: uuid(),
|
|
21
21
|
original: refDefinition,
|
|
22
22
|
path: getRefPath(refDefinition),
|
|
23
|
+
key: get(refDefinition, 'key'),
|
|
23
24
|
resolver: get(refDefinition, 'resolver'),
|
|
24
25
|
transformer: get(refDefinition, 'transformer'),
|
|
25
26
|
vars: get(refDefinition, 'vars', {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import { type } from '@lowdefy/helpers';
|
|
15
|
+
*/ /* eslint-disable no-param-reassign */ import { get, type } from '@lowdefy/helpers';
|
|
16
16
|
import { getFileExtension, getFileSubExtension } from '@lowdefy/node-utils';
|
|
17
17
|
import JSON5 from 'json5';
|
|
18
18
|
import YAML from 'yaml';
|
|
@@ -26,12 +26,17 @@ function parseRefContent({ content , refDef }) {
|
|
|
26
26
|
ext = getFileSubExtension(path);
|
|
27
27
|
}
|
|
28
28
|
if (ext === 'yaml' || ext === 'yml') {
|
|
29
|
-
|
|
29
|
+
content = YAML.parse(content);
|
|
30
30
|
}
|
|
31
31
|
if (ext === 'json') {
|
|
32
|
-
|
|
32
|
+
content = JSON5.parse(content);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
if (refDef.key) {
|
|
36
|
+
content = get(content, refDef.key, {
|
|
37
|
+
default: null
|
|
38
|
+
});
|
|
39
|
+
}
|
|
35
40
|
return content;
|
|
36
41
|
}
|
|
37
42
|
export default parseRefContent;
|
|
@@ -24,12 +24,12 @@ function refReviver(key, value) {
|
|
|
24
24
|
default: null
|
|
25
25
|
})));
|
|
26
26
|
}
|
|
27
|
-
if (type.isObject(value._var) && type.isString(value._var.
|
|
28
|
-
return JSON.parse(JSON.stringify(get(this.vars, value._var.
|
|
27
|
+
if (type.isObject(value._var) && type.isString(value._var.key)) {
|
|
28
|
+
return JSON.parse(JSON.stringify(get(this.vars, value._var.key, {
|
|
29
29
|
default: type.isNone(value._var.default) ? null : value._var.default
|
|
30
30
|
})));
|
|
31
31
|
}
|
|
32
|
-
throw new Error(`"_var" operator takes a string or object with
|
|
32
|
+
throw new Error(`"_var" operator takes a string or object with "key" field as arguments. Received "${JSON.stringify(value)}"`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return value;
|