cdk8s 2.7.61 → 2.7.63
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/.jsii +3 -3
- package/lib/api-object.js +1 -1
- package/lib/app.js +1 -1
- package/lib/chart.js +1 -1
- package/lib/cron.js +1 -1
- package/lib/dependency.js +2 -2
- package/lib/duration.js +1 -1
- package/lib/helm.js +1 -1
- package/lib/include.js +1 -1
- package/lib/json-patch.js +1 -1
- package/lib/lazy.js +1 -1
- package/lib/metadata.js +1 -1
- package/lib/names.js +1 -1
- package/lib/size.js +1 -1
- package/lib/testing.js +1 -1
- package/lib/yaml.js +6 -4
- package/node_modules/yaml/README.md +2 -2
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +1 -1
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +4 -3
- package/node_modules/yaml/browser/dist/compose/compose-node.js +18 -5
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +19 -13
- package/node_modules/yaml/browser/dist/compose/composer.js +8 -10
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +30 -13
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +12 -3
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +10 -5
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +17 -6
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +8 -2
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +9 -1
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +1 -1
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +76 -19
- package/node_modules/yaml/browser/dist/doc/anchors.js +2 -2
- package/node_modules/yaml/browser/dist/doc/createNode.js +14 -11
- package/node_modules/yaml/browser/dist/doc/directives.js +11 -3
- package/node_modules/yaml/browser/dist/errors.js +1 -1
- package/node_modules/yaml/browser/dist/index.js +1 -2
- package/node_modules/yaml/browser/dist/node_modules/tslib/tslib.es6.js +164 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +30 -16
- package/node_modules/yaml/browser/dist/nodes/Node.js +7 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +11 -3
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +10 -10
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +5 -13
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +3 -2
- package/node_modules/yaml/browser/dist/nodes/toJS.js +3 -1
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +3 -8
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +2 -2
- package/node_modules/yaml/browser/dist/parse/lexer.js +49 -22
- package/node_modules/yaml/browser/dist/parse/parser.js +142 -68
- package/node_modules/yaml/browser/dist/public-api.js +5 -7
- package/node_modules/yaml/browser/dist/schema/Schema.js +19 -4
- package/node_modules/yaml/browser/dist/schema/common/null.js +3 -1
- package/node_modules/yaml/browser/dist/schema/core/float.js +4 -1
- package/node_modules/yaml/browser/dist/schema/tags.js +17 -13
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +4 -1
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +1 -1
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +1 -1
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +6 -1
- package/node_modules/yaml/browser/dist/stringify/stringify.js +53 -23
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +114 -85
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +18 -12
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +36 -15
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +71 -32
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +56 -53
- package/node_modules/yaml/browser/dist/util.js +3 -0
- package/node_modules/yaml/browser/dist/visit.js +149 -62
- package/node_modules/yaml/dist/compose/compose-collection.js +1 -1
- package/node_modules/yaml/dist/compose/compose-doc.js +4 -3
- package/node_modules/yaml/dist/compose/compose-node.d.ts +4 -2
- package/node_modules/yaml/dist/compose/compose-node.js +18 -5
- package/node_modules/yaml/dist/compose/compose-scalar.js +18 -12
- package/node_modules/yaml/dist/compose/composer.d.ts +3 -3
- package/node_modules/yaml/dist/compose/composer.js +10 -12
- package/node_modules/yaml/dist/compose/resolve-block-map.js +30 -13
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +12 -3
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +10 -5
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +17 -6
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +8 -2
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +2 -1
- package/node_modules/yaml/dist/compose/resolve-props.js +9 -1
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +1 -1
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +24 -15
- package/node_modules/yaml/dist/doc/Document.js +80 -23
- package/node_modules/yaml/dist/doc/anchors.d.ts +3 -3
- package/node_modules/yaml/dist/doc/anchors.js +2 -2
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +1 -1
- package/node_modules/yaml/dist/doc/createNode.d.ts +3 -2
- package/node_modules/yaml/dist/doc/createNode.js +13 -10
- package/node_modules/yaml/dist/doc/directives.d.ts +5 -2
- package/node_modules/yaml/dist/doc/directives.js +11 -3
- package/node_modules/yaml/dist/errors.d.ts +2 -2
- package/node_modules/yaml/dist/errors.js +1 -1
- package/node_modules/yaml/dist/index.d.ts +6 -4
- package/node_modules/yaml/dist/index.js +1 -2
- package/node_modules/yaml/dist/log.d.ts +1 -1
- package/node_modules/yaml/dist/nodes/Alias.d.ts +8 -4
- package/node_modules/yaml/dist/nodes/Collection.d.ts +12 -6
- package/node_modules/yaml/dist/nodes/Collection.js +29 -15
- package/node_modules/yaml/dist/nodes/Node.d.ts +22 -11
- package/node_modules/yaml/dist/nodes/Node.js +7 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +8 -3
- package/node_modules/yaml/dist/nodes/Pair.js +10 -2
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +2 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +1 -1
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +12 -4
- package/node_modules/yaml/dist/nodes/YAMLMap.js +10 -10
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +6 -1
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +5 -13
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +2 -1
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +2 -1
- package/node_modules/yaml/dist/nodes/toJS.js +3 -1
- package/node_modules/yaml/dist/options.d.ts +82 -22
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +6 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +3 -8
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +2 -2
- package/node_modules/yaml/dist/parse/cst-visit.js +2 -2
- package/node_modules/yaml/dist/parse/cst.d.ts +3 -3
- package/node_modules/yaml/dist/parse/lexer.d.ts +2 -0
- package/node_modules/yaml/dist/parse/lexer.js +49 -22
- package/node_modules/yaml/dist/parse/parser.js +142 -68
- package/node_modules/yaml/dist/public-api.js +5 -7
- package/node_modules/yaml/dist/schema/Schema.d.ts +9 -7
- package/node_modules/yaml/dist/schema/Schema.js +18 -3
- package/node_modules/yaml/dist/schema/common/null.js +3 -1
- package/node_modules/yaml/dist/schema/core/float.js +4 -1
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +3 -4
- package/node_modules/yaml/dist/schema/tags.js +17 -13
- package/node_modules/yaml/dist/schema/types.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +4 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +7 -3
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +6 -2
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +6 -1
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +1 -1
- package/node_modules/yaml/dist/stringify/stringify.d.ts +7 -4
- package/node_modules/yaml/dist/stringify/stringify.js +53 -23
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +2 -6
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +113 -84
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -2
- package/node_modules/yaml/dist/stringify/stringifyComment.js +19 -12
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +35 -14
- package/node_modules/yaml/dist/stringify/stringifyPair.js +70 -31
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +7 -1
- package/node_modules/yaml/dist/stringify/stringifyString.js +56 -53
- package/node_modules/yaml/dist/test-events.d.ts +1 -1
- package/node_modules/yaml/dist/test-events.js +14 -14
- package/node_modules/yaml/dist/util.d.ts +3 -0
- package/node_modules/yaml/dist/util.js +6 -0
- package/node_modules/yaml/dist/visit.d.ts +51 -12
- package/node_modules/yaml/dist/visit.js +148 -60
- package/node_modules/yaml/package.json +19 -17
- package/node_modules/yaml/util.d.ts +3 -0
- package/package.json +4 -4
- package/node_modules/yaml/browser/dist/options.js +0 -17
- package/node_modules/yaml/dist/options.js +0 -19
|
@@ -2,18 +2,22 @@ import { Pair } from '../nodes/Pair.js';
|
|
|
2
2
|
import { YAMLMap } from '../nodes/YAMLMap.js';
|
|
3
3
|
import { resolveProps } from './resolve-props.js';
|
|
4
4
|
import { containsNewline } from './util-contains-newline.js';
|
|
5
|
+
import { flowIndentCheck } from './util-flow-indent-check.js';
|
|
5
6
|
import { mapIncludes } from './util-map-includes.js';
|
|
6
7
|
|
|
7
8
|
const startColMsg = 'All mapping items must start at the same column';
|
|
8
9
|
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
9
|
-
var _a;
|
|
10
10
|
const map = new YAMLMap(ctx.schema);
|
|
11
|
+
if (ctx.atRoot)
|
|
12
|
+
ctx.atRoot = false;
|
|
11
13
|
let offset = bm.offset;
|
|
12
|
-
|
|
14
|
+
let commentEnd = null;
|
|
15
|
+
for (const collItem of bm.items) {
|
|
16
|
+
const { start, key, sep, value } = collItem;
|
|
13
17
|
// key properties
|
|
14
18
|
const keyProps = resolveProps(start, {
|
|
15
19
|
indicator: 'explicit-key-ind',
|
|
16
|
-
next: key
|
|
20
|
+
next: key ?? sep?.[0],
|
|
17
21
|
offset,
|
|
18
22
|
onError,
|
|
19
23
|
startOnNewline: true
|
|
@@ -27,7 +31,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
27
31
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
28
32
|
}
|
|
29
33
|
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
30
|
-
|
|
34
|
+
commentEnd = keyProps.end;
|
|
31
35
|
if (keyProps.comment) {
|
|
32
36
|
if (map.comment)
|
|
33
37
|
map.comment += '\n' + keyProps.comment;
|
|
@@ -36,21 +40,24 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
36
40
|
}
|
|
37
41
|
continue;
|
|
38
42
|
}
|
|
43
|
+
if (keyProps.hasNewlineAfterProp || containsNewline(key)) {
|
|
44
|
+
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
|
-
else if (
|
|
47
|
+
else if (keyProps.found?.indent !== bm.indent) {
|
|
41
48
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
42
|
-
|
|
43
|
-
onError(key, // checked by containsNewline()
|
|
44
|
-
'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
|
49
|
+
}
|
|
45
50
|
// key value
|
|
46
51
|
const keyStart = keyProps.end;
|
|
47
52
|
const keyNode = key
|
|
48
53
|
? composeNode(ctx, key, keyProps, onError)
|
|
49
54
|
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
55
|
+
if (ctx.schema.compat)
|
|
56
|
+
flowIndentCheck(bm.indent, key, onError);
|
|
50
57
|
if (mapIncludes(ctx, map.items, keyNode))
|
|
51
58
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
52
59
|
// value properties
|
|
53
|
-
const valueProps = resolveProps(sep
|
|
60
|
+
const valueProps = resolveProps(sep ?? [], {
|
|
54
61
|
indicator: 'map-value-ind',
|
|
55
62
|
next: value,
|
|
56
63
|
offset: keyNode.range[2],
|
|
@@ -60,7 +67,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
60
67
|
offset = valueProps.end;
|
|
61
68
|
if (valueProps.found) {
|
|
62
69
|
if (implicitKey) {
|
|
63
|
-
if (
|
|
70
|
+
if (value?.type === 'block-map' && !valueProps.hasNewline)
|
|
64
71
|
onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'Nested mappings are not allowed in compact mappings');
|
|
65
72
|
if (ctx.options.strict &&
|
|
66
73
|
keyProps.start < valueProps.found.offset - 1024)
|
|
@@ -70,8 +77,13 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
70
77
|
const valueNode = value
|
|
71
78
|
? composeNode(ctx, value, valueProps, onError)
|
|
72
79
|
: composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
|
|
80
|
+
if (ctx.schema.compat)
|
|
81
|
+
flowIndentCheck(bm.indent, value, onError);
|
|
73
82
|
offset = valueNode.range[2];
|
|
74
|
-
|
|
83
|
+
const pair = new Pair(keyNode, valueNode);
|
|
84
|
+
if (ctx.options.keepSourceTokens)
|
|
85
|
+
pair.srcToken = collItem;
|
|
86
|
+
map.items.push(pair);
|
|
75
87
|
}
|
|
76
88
|
else {
|
|
77
89
|
// key with no value
|
|
@@ -83,10 +95,15 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
83
95
|
else
|
|
84
96
|
keyNode.comment = valueProps.comment;
|
|
85
97
|
}
|
|
86
|
-
|
|
98
|
+
const pair = new Pair(keyNode);
|
|
99
|
+
if (ctx.options.keepSourceTokens)
|
|
100
|
+
pair.srcToken = collItem;
|
|
101
|
+
map.items.push(pair);
|
|
87
102
|
}
|
|
88
103
|
}
|
|
89
|
-
|
|
104
|
+
if (commentEnd && commentEnd < offset)
|
|
105
|
+
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content');
|
|
106
|
+
map.range = [bm.offset, offset, commentEnd ?? offset];
|
|
90
107
|
return map;
|
|
91
108
|
}
|
|
92
109
|
|
|
@@ -17,8 +17,10 @@ function resolveBlockScalar(scalar, strict, onError) {
|
|
|
17
17
|
break;
|
|
18
18
|
}
|
|
19
19
|
// shortcut for empty contents
|
|
20
|
-
if (
|
|
21
|
-
const value = header.chomp === '+'
|
|
20
|
+
if (chompStart === 0) {
|
|
21
|
+
const value = header.chomp === '+' && lines.length > 0
|
|
22
|
+
? '\n'.repeat(Math.max(1, lines.length - 1))
|
|
23
|
+
: '';
|
|
22
24
|
let end = start + header.length;
|
|
23
25
|
if (scalar.source)
|
|
24
26
|
end += scalar.source.length;
|
|
@@ -46,6 +48,11 @@ function resolveBlockScalar(scalar, strict, onError) {
|
|
|
46
48
|
}
|
|
47
49
|
offset += indent.length + content.length + 1;
|
|
48
50
|
}
|
|
51
|
+
// include trailing more-indented empty lines in content
|
|
52
|
+
for (let i = lines.length - 1; i >= chompStart; --i) {
|
|
53
|
+
if (lines[i][0].length > trimIndent)
|
|
54
|
+
chompStart = i + 1;
|
|
55
|
+
}
|
|
49
56
|
let value = '';
|
|
50
57
|
let sep = '';
|
|
51
58
|
let prevMoreIndented = false;
|
|
@@ -175,7 +182,9 @@ function splitLines(source) {
|
|
|
175
182
|
const split = source.split(/\n( *)/);
|
|
176
183
|
const first = split[0];
|
|
177
184
|
const m = first.match(/^( *)/);
|
|
178
|
-
const line0 = m
|
|
185
|
+
const line0 = m?.[1]
|
|
186
|
+
? [m[1], first.slice(m[1].length)]
|
|
187
|
+
: ['', first];
|
|
179
188
|
const lines = [line0];
|
|
180
189
|
for (let i = 1; i < split.length; i += 2)
|
|
181
190
|
lines.push([split[i], split[i + 1]]);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { YAMLSeq } from '../nodes/YAMLSeq.js';
|
|
2
2
|
import { resolveProps } from './resolve-props.js';
|
|
3
|
+
import { flowIndentCheck } from './util-flow-indent-check.js';
|
|
3
4
|
|
|
4
5
|
function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
5
6
|
const seq = new YAMLSeq(ctx.schema);
|
|
7
|
+
if (ctx.atRoot)
|
|
8
|
+
ctx.atRoot = false;
|
|
6
9
|
let offset = bs.offset;
|
|
10
|
+
let commentEnd = null;
|
|
7
11
|
for (const { start, value } of bs.items) {
|
|
8
12
|
const props = resolveProps(start, {
|
|
9
13
|
indicator: 'seq-item-ind',
|
|
@@ -12,16 +16,15 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
12
16
|
onError,
|
|
13
17
|
startOnNewline: true
|
|
14
18
|
});
|
|
15
|
-
offset = props.end;
|
|
16
19
|
if (!props.found) {
|
|
17
20
|
if (props.anchor || props.tag || value) {
|
|
18
21
|
if (value && value.type === 'block-seq')
|
|
19
|
-
onError(
|
|
22
|
+
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
20
23
|
else
|
|
21
24
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
22
25
|
}
|
|
23
26
|
else {
|
|
24
|
-
|
|
27
|
+
commentEnd = props.end;
|
|
25
28
|
if (props.comment)
|
|
26
29
|
seq.comment = props.comment;
|
|
27
30
|
continue;
|
|
@@ -29,11 +32,13 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
29
32
|
}
|
|
30
33
|
const node = value
|
|
31
34
|
? composeNode(ctx, value, props, onError)
|
|
32
|
-
: composeEmptyNode(ctx,
|
|
35
|
+
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
36
|
+
if (ctx.schema.compat)
|
|
37
|
+
flowIndentCheck(bs.indent, value, onError);
|
|
33
38
|
offset = node.range[2];
|
|
34
39
|
seq.items.push(node);
|
|
35
40
|
}
|
|
36
|
-
seq.range = [bs.offset, offset, offset];
|
|
41
|
+
seq.range = [bs.offset, offset, commentEnd ?? offset];
|
|
37
42
|
return seq;
|
|
38
43
|
}
|
|
39
44
|
|
|
@@ -16,13 +16,17 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
16
16
|
? new YAMLMap(ctx.schema)
|
|
17
17
|
: new YAMLSeq(ctx.schema);
|
|
18
18
|
coll.flow = true;
|
|
19
|
-
|
|
19
|
+
const atRoot = ctx.atRoot;
|
|
20
|
+
if (atRoot)
|
|
21
|
+
ctx.atRoot = false;
|
|
22
|
+
let offset = fc.offset + fc.start.source.length;
|
|
20
23
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
21
|
-
const
|
|
24
|
+
const collItem = fc.items[i];
|
|
25
|
+
const { start, key, sep, value } = collItem;
|
|
22
26
|
const props = resolveProps(start, {
|
|
23
27
|
flow: fcName,
|
|
24
28
|
indicator: 'explicit-key-ind',
|
|
25
|
-
next: key
|
|
29
|
+
next: key ?? sep?.[0],
|
|
26
30
|
offset,
|
|
27
31
|
onError,
|
|
28
32
|
startOnNewline: false
|
|
@@ -39,6 +43,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
39
43
|
else
|
|
40
44
|
coll.comment = props.comment;
|
|
41
45
|
}
|
|
46
|
+
offset = props.end;
|
|
42
47
|
continue;
|
|
43
48
|
}
|
|
44
49
|
if (!isMap && ctx.options.strict && containsNewline(key))
|
|
@@ -69,7 +74,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
69
74
|
if (prevItemComment) {
|
|
70
75
|
let prev = coll.items[coll.items.length - 1];
|
|
71
76
|
if (isPair(prev))
|
|
72
|
-
prev = prev.value
|
|
77
|
+
prev = prev.value ?? prev.key;
|
|
73
78
|
if (prev.comment)
|
|
74
79
|
prev.comment += '\n' + prevItemComment;
|
|
75
80
|
else
|
|
@@ -99,7 +104,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
99
104
|
if (isBlock(key))
|
|
100
105
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
101
106
|
// value properties
|
|
102
|
-
const valueProps = resolveProps(sep
|
|
107
|
+
const valueProps = resolveProps(sep ?? [], {
|
|
103
108
|
flow: fcName,
|
|
104
109
|
indicator: 'map-value-ind',
|
|
105
110
|
next: value,
|
|
@@ -145,6 +150,8 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
145
150
|
keyNode.comment = valueProps.comment;
|
|
146
151
|
}
|
|
147
152
|
const pair = new Pair(keyNode, valueNode);
|
|
153
|
+
if (ctx.options.keepSourceTokens)
|
|
154
|
+
pair.srcToken = collItem;
|
|
148
155
|
if (isMap) {
|
|
149
156
|
const map = coll;
|
|
150
157
|
if (mapIncludes(ctx, map.items, keyNode))
|
|
@@ -166,7 +173,11 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
166
173
|
if (ce && ce.source === expectedEnd)
|
|
167
174
|
cePos = ce.offset + ce.source.length;
|
|
168
175
|
else {
|
|
169
|
-
|
|
176
|
+
const name = fcName[0].toUpperCase() + fcName.substring(1);
|
|
177
|
+
const msg = atRoot
|
|
178
|
+
? `${name} must end with a ${expectedEnd}`
|
|
179
|
+
: `${name} in block collection must be sufficiently indented and end with a ${expectedEnd}`;
|
|
180
|
+
onError(offset, atRoot ? 'MISSING_CHAR' : 'BAD_INDENT', msg);
|
|
170
181
|
if (ce && ce.source.length !== 1)
|
|
171
182
|
ee.unshift(ce);
|
|
172
183
|
}
|
|
@@ -111,7 +111,7 @@ function foldLines(source) {
|
|
|
111
111
|
const last = /[ \t]*(.*)/sy;
|
|
112
112
|
last.lastIndex = pos;
|
|
113
113
|
match = last.exec(source);
|
|
114
|
-
return res + sep + (
|
|
114
|
+
return res + sep + (match?.[1] ?? '');
|
|
115
115
|
}
|
|
116
116
|
function doubleQuotedValue(source, onError) {
|
|
117
117
|
let res = '';
|
|
@@ -135,6 +135,12 @@ function doubleQuotedValue(source, onError) {
|
|
|
135
135
|
while (next === ' ' || next === '\t')
|
|
136
136
|
next = source[++i + 1];
|
|
137
137
|
}
|
|
138
|
+
else if (next === '\r' && source[i + 1] === '\n') {
|
|
139
|
+
// skip escaped CRLF newlines, but still trim the following line
|
|
140
|
+
next = source[++i + 1];
|
|
141
|
+
while (next === ' ' || next === '\t')
|
|
142
|
+
next = source[++i + 1];
|
|
143
|
+
}
|
|
138
144
|
else if (next === 'x' || next === 'u' || next === 'U') {
|
|
139
145
|
const length = { x: 2, u: 4, U: 8 }[next];
|
|
140
146
|
res += parseCharCode(source, i + 1, length, onError);
|
|
@@ -152,7 +158,7 @@ function doubleQuotedValue(source, onError) {
|
|
|
152
158
|
let next = source[i + 1];
|
|
153
159
|
while (next === ' ' || next === '\t')
|
|
154
160
|
next = source[++i + 1];
|
|
155
|
-
if (next !== '\n')
|
|
161
|
+
if (next !== '\n' && !(next === '\r' && source[i + 2] === '\n'))
|
|
156
162
|
res += i > wsStart ? source.slice(wsStart, i + 1) : ch;
|
|
157
163
|
}
|
|
158
164
|
else {
|
|
@@ -5,6 +5,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
5
5
|
let comment = '';
|
|
6
6
|
let commentSep = '';
|
|
7
7
|
let hasNewline = false;
|
|
8
|
+
let hasNewlineAfterProp = false;
|
|
8
9
|
let reqSpace = false;
|
|
9
10
|
let anchor = null;
|
|
10
11
|
let tag = null;
|
|
@@ -54,11 +55,15 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
54
55
|
commentSep += token.source;
|
|
55
56
|
atNewline = true;
|
|
56
57
|
hasNewline = true;
|
|
58
|
+
if (anchor || tag)
|
|
59
|
+
hasNewlineAfterProp = true;
|
|
57
60
|
hasSpace = true;
|
|
58
61
|
break;
|
|
59
62
|
case 'anchor':
|
|
60
63
|
if (anchor)
|
|
61
64
|
onError(token, 'MULTIPLE_ANCHORS', 'A node can have at most one anchor');
|
|
65
|
+
if (token.source.endsWith(':'))
|
|
66
|
+
onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
|
|
62
67
|
anchor = token;
|
|
63
68
|
if (start === null)
|
|
64
69
|
start = token.offset;
|
|
@@ -81,6 +86,8 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
81
86
|
// Could here handle preceding comments differently
|
|
82
87
|
if (anchor || tag)
|
|
83
88
|
onError(token, 'BAD_PROP_ORDER', `Anchors and tags must be after the ${token.source} indicator`);
|
|
89
|
+
if (found)
|
|
90
|
+
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow ?? 'collection'}`);
|
|
84
91
|
found = token;
|
|
85
92
|
atNewline = false;
|
|
86
93
|
hasSpace = false;
|
|
@@ -116,10 +123,11 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
116
123
|
spaceBefore,
|
|
117
124
|
comment,
|
|
118
125
|
hasNewline,
|
|
126
|
+
hasNewlineAfterProp,
|
|
119
127
|
anchor,
|
|
120
128
|
tag,
|
|
121
129
|
end,
|
|
122
|
-
start: start
|
|
130
|
+
start: start ?? end
|
|
123
131
|
};
|
|
124
132
|
}
|
|
125
133
|
|
|
@@ -14,7 +14,7 @@ function emptyScalarPosition(offset, before, pos) {
|
|
|
14
14
|
// Technically, an empty scalar is immediately after the last non-empty
|
|
15
15
|
// node, but it's more useful to place it after any whitespace.
|
|
16
16
|
st = before[++i];
|
|
17
|
-
while (
|
|
17
|
+
while (st?.type === 'space') {
|
|
18
18
|
offset += st.source.length;
|
|
19
19
|
st = before[++i];
|
|
20
20
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { containsNewline } from './util-contains-newline.js';
|
|
2
|
+
|
|
3
|
+
function flowIndentCheck(indent, fc, onError) {
|
|
4
|
+
if (fc?.type === 'flow-collection') {
|
|
5
|
+
const end = fc.end[0];
|
|
6
|
+
if (end.indent === indent &&
|
|
7
|
+
(end.source === ']' || end.source === '}') &&
|
|
8
|
+
containsNewline(fc)) {
|
|
9
|
+
const msg = 'Flow end indicator should be more indented than parent';
|
|
10
|
+
onError(end, 'BAD_INDENT', msg, true);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { flowIndentCheck };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Alias } from '../nodes/Alias.js';
|
|
2
2
|
import { isEmptyPath, collectionFromPath } from '../nodes/Collection.js';
|
|
3
|
-
import { NODE_TYPE, DOC, isCollection, isScalar } from '../nodes/Node.js';
|
|
3
|
+
import { NODE_TYPE, DOC, isNode, isCollection, isScalar } from '../nodes/Node.js';
|
|
4
4
|
import { Pair } from '../nodes/Pair.js';
|
|
5
5
|
import { toJS } from '../nodes/toJS.js';
|
|
6
|
-
import { defaultOptions } from '../options.js';
|
|
7
6
|
import { Schema } from '../schema/Schema.js';
|
|
8
7
|
import { stringify } from '../stringify/stringify.js';
|
|
9
8
|
import { stringifyDocument } from '../stringify/stringifyDocument.js';
|
|
@@ -31,11 +30,19 @@ class Document {
|
|
|
31
30
|
options = replacer;
|
|
32
31
|
replacer = undefined;
|
|
33
32
|
}
|
|
34
|
-
const opt = Object.assign({
|
|
33
|
+
const opt = Object.assign({
|
|
34
|
+
intAsBigInt: false,
|
|
35
|
+
keepSourceTokens: false,
|
|
36
|
+
logLevel: 'warn',
|
|
37
|
+
prettyErrors: true,
|
|
38
|
+
strict: true,
|
|
39
|
+
uniqueKeys: true,
|
|
40
|
+
version: '1.2'
|
|
41
|
+
}, options);
|
|
35
42
|
this.options = opt;
|
|
36
43
|
let { version } = opt;
|
|
37
|
-
if (options
|
|
38
|
-
this.directives = options.
|
|
44
|
+
if (options?._directives) {
|
|
45
|
+
this.directives = options._directives.atDocument();
|
|
39
46
|
if (this.directives.yaml.explicit)
|
|
40
47
|
version = this.directives.yaml.version;
|
|
41
48
|
}
|
|
@@ -48,6 +55,30 @@ class Document {
|
|
|
48
55
|
this.contents = this.createNode(value, _replacer, options);
|
|
49
56
|
}
|
|
50
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a deep copy of this Document and its contents.
|
|
60
|
+
*
|
|
61
|
+
* Custom Node values that inherit from `Object` still refer to their original instances.
|
|
62
|
+
*/
|
|
63
|
+
clone() {
|
|
64
|
+
const copy = Object.create(Document.prototype, {
|
|
65
|
+
[NODE_TYPE]: { value: DOC }
|
|
66
|
+
});
|
|
67
|
+
copy.commentBefore = this.commentBefore;
|
|
68
|
+
copy.comment = this.comment;
|
|
69
|
+
copy.errors = this.errors.slice();
|
|
70
|
+
copy.warnings = this.warnings.slice();
|
|
71
|
+
copy.options = Object.assign({}, this.options);
|
|
72
|
+
if (this.directives)
|
|
73
|
+
copy.directives = this.directives.clone();
|
|
74
|
+
copy.schema = this.schema.clone();
|
|
75
|
+
copy.contents = isNode(this.contents)
|
|
76
|
+
? this.contents.clone(copy.schema)
|
|
77
|
+
: this.contents;
|
|
78
|
+
if (this.range)
|
|
79
|
+
copy.range = this.range.slice();
|
|
80
|
+
return copy;
|
|
81
|
+
}
|
|
51
82
|
/** Adds a value to the document. */
|
|
52
83
|
add(value) {
|
|
53
84
|
if (assertCollection(this.contents))
|
|
@@ -71,6 +102,7 @@ class Document {
|
|
|
71
102
|
if (!node.anchor) {
|
|
72
103
|
const prev = anchorNames(this);
|
|
73
104
|
node.anchor =
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
74
106
|
!name || prev.has(name) ? findNewAnchor(name || 'a', prev) : name;
|
|
75
107
|
}
|
|
76
108
|
return new Alias(node.anchor);
|
|
@@ -92,10 +124,13 @@ class Document {
|
|
|
92
124
|
options = replacer;
|
|
93
125
|
replacer = undefined;
|
|
94
126
|
}
|
|
95
|
-
const { anchorPrefix, flow, keepUndefined, onTagObj, tag } = options
|
|
96
|
-
const { onAnchor, setAnchors, sourceObjects } = createNodeAnchors(this,
|
|
127
|
+
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options ?? {};
|
|
128
|
+
const { onAnchor, setAnchors, sourceObjects } = createNodeAnchors(this,
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
130
|
+
anchorPrefix || 'a');
|
|
97
131
|
const ctx = {
|
|
98
|
-
|
|
132
|
+
aliasDuplicateObjects: aliasDuplicateObjects ?? true,
|
|
133
|
+
keepUndefined: keepUndefined ?? false,
|
|
99
134
|
onAnchor,
|
|
100
135
|
onTagObj,
|
|
101
136
|
replacer: _replacer,
|
|
@@ -205,26 +240,48 @@ class Document {
|
|
|
205
240
|
}
|
|
206
241
|
/**
|
|
207
242
|
* Change the YAML version and schema used by the document.
|
|
243
|
+
* A `null` version disables support for directives, explicit tags, anchors, and aliases.
|
|
244
|
+
* It also requires the `schema` option to be given as a `Schema` instance value.
|
|
208
245
|
*
|
|
209
|
-
* Overrides all previously set schema options
|
|
246
|
+
* Overrides all previously set schema options.
|
|
210
247
|
*/
|
|
211
|
-
setSchema(version, options) {
|
|
212
|
-
|
|
213
|
-
|
|
248
|
+
setSchema(version, options = {}) {
|
|
249
|
+
if (typeof version === 'number')
|
|
250
|
+
version = String(version);
|
|
251
|
+
let opt;
|
|
252
|
+
switch (version) {
|
|
214
253
|
case '1.1':
|
|
215
|
-
this.directives
|
|
216
|
-
|
|
254
|
+
if (this.directives)
|
|
255
|
+
this.directives.yaml.version = '1.1';
|
|
256
|
+
else
|
|
257
|
+
this.directives = new Directives({ version: '1.1' });
|
|
258
|
+
opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
217
259
|
break;
|
|
218
260
|
case '1.2':
|
|
219
|
-
|
|
220
|
-
|
|
261
|
+
case 'next':
|
|
262
|
+
if (this.directives)
|
|
263
|
+
this.directives.yaml.version = version;
|
|
264
|
+
else
|
|
265
|
+
this.directives = new Directives({ version });
|
|
266
|
+
opt = { merge: false, resolveKnownTags: true, schema: 'core' };
|
|
267
|
+
break;
|
|
268
|
+
case null:
|
|
269
|
+
if (this.directives)
|
|
270
|
+
delete this.directives;
|
|
271
|
+
opt = null;
|
|
221
272
|
break;
|
|
222
273
|
default: {
|
|
223
274
|
const sv = JSON.stringify(version);
|
|
224
|
-
throw new Error(`Expected '1.1'
|
|
275
|
+
throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${sv}`);
|
|
225
276
|
}
|
|
226
277
|
}
|
|
227
|
-
|
|
278
|
+
// Not using `instanceof Schema` to allow for duck typing
|
|
279
|
+
if (options.schema instanceof Object)
|
|
280
|
+
this.schema = options.schema;
|
|
281
|
+
else if (opt)
|
|
282
|
+
this.schema = new Schema(Object.assign(opt, options));
|
|
283
|
+
else
|
|
284
|
+
throw new Error(`With a null YAML version, the { schema: Schema } option is required`);
|
|
228
285
|
}
|
|
229
286
|
// json & jsonArg are only used from toJSON()
|
|
230
287
|
toJS({ json, jsonArg, mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
@@ -237,7 +294,7 @@ class Document {
|
|
|
237
294
|
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100,
|
|
238
295
|
stringify
|
|
239
296
|
};
|
|
240
|
-
const res = toJS(this.contents, jsonArg
|
|
297
|
+
const res = toJS(this.contents, jsonArg ?? '', ctx);
|
|
241
298
|
if (typeof onAnchor === 'function')
|
|
242
299
|
for (const { count, res } of ctx.anchors.values())
|
|
243
300
|
onAnchor(res, count);
|
|
@@ -37,7 +37,7 @@ function createNodeAnchors(doc, prefix) {
|
|
|
37
37
|
const sourceObjects = new Map();
|
|
38
38
|
let prevAnchors = null;
|
|
39
39
|
return {
|
|
40
|
-
onAnchor(source) {
|
|
40
|
+
onAnchor: (source) => {
|
|
41
41
|
aliasObjects.push(source);
|
|
42
42
|
if (!prevAnchors)
|
|
43
43
|
prevAnchors = anchorNames(doc);
|
|
@@ -50,7 +50,7 @@ function createNodeAnchors(doc, prefix) {
|
|
|
50
50
|
* of its child nodes are. This is why anchors are set only after all of
|
|
51
51
|
* the nodes have been created.
|
|
52
52
|
*/
|
|
53
|
-
setAnchors() {
|
|
53
|
+
setAnchors: () => {
|
|
54
54
|
for (const source of aliasObjects) {
|
|
55
55
|
const ref = sourceObjects.get(source);
|
|
56
56
|
if (typeof ref === 'object' &&
|
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
import { Alias } from '../nodes/Alias.js';
|
|
2
|
-
import { isNode, isPair, MAP, SEQ } from '../nodes/Node.js';
|
|
2
|
+
import { isNode, isPair, MAP, SEQ, isDocument } from '../nodes/Node.js';
|
|
3
3
|
import { Scalar } from '../nodes/Scalar.js';
|
|
4
4
|
|
|
5
5
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
6
6
|
function findTagObject(value, tagName, tags) {
|
|
7
7
|
if (tagName) {
|
|
8
8
|
const match = tags.filter(t => t.tag === tagName);
|
|
9
|
-
const tagObj = match.find(t => !t.format)
|
|
9
|
+
const tagObj = match.find(t => !t.format) ?? match[0];
|
|
10
10
|
if (!tagObj)
|
|
11
11
|
throw new Error(`Tag ${tagName} not found`);
|
|
12
12
|
return tagObj;
|
|
13
13
|
}
|
|
14
|
-
return tags.find(t => t.identify
|
|
14
|
+
return tags.find(t => t.identify?.(value) && !t.format);
|
|
15
15
|
}
|
|
16
16
|
function createNode(value, tagName, ctx) {
|
|
17
|
-
|
|
17
|
+
if (isDocument(value))
|
|
18
|
+
value = value.contents;
|
|
18
19
|
if (isNode(value))
|
|
19
20
|
return value;
|
|
20
21
|
if (isPair(value)) {
|
|
21
|
-
const map =
|
|
22
|
+
const map = ctx.schema[MAP].createNode?.(ctx.schema, null, ctx);
|
|
22
23
|
map.items.push(value);
|
|
23
24
|
return map;
|
|
24
25
|
}
|
|
25
26
|
if (value instanceof String ||
|
|
26
27
|
value instanceof Number ||
|
|
27
28
|
value instanceof Boolean ||
|
|
28
|
-
(typeof BigInt
|
|
29
|
+
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
|
|
29
30
|
) {
|
|
30
31
|
// https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
31
32
|
value = value.valueOf();
|
|
32
33
|
}
|
|
33
|
-
const { onAnchor, onTagObj, schema, sourceObjects } = ctx;
|
|
34
|
+
const { aliasDuplicateObjects, onAnchor, onTagObj, schema, sourceObjects } = ctx;
|
|
34
35
|
// Detect duplicate references to the same object & use Alias nodes for all
|
|
35
36
|
// after first. The `ref` wrapper allows for circular references to resolve.
|
|
36
37
|
let ref = undefined;
|
|
37
|
-
if (value && typeof value === 'object') {
|
|
38
|
+
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
38
39
|
ref = sourceObjects.get(value);
|
|
39
40
|
if (ref) {
|
|
40
41
|
if (!ref.anchor)
|
|
@@ -46,12 +47,14 @@ function createNode(value, tagName, ctx) {
|
|
|
46
47
|
sourceObjects.set(value, ref);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
if (tagName
|
|
50
|
+
if (tagName?.startsWith('!!'))
|
|
50
51
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
51
52
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
52
53
|
if (!tagObj) {
|
|
53
|
-
if (value && typeof value.toJSON === 'function')
|
|
54
|
+
if (value && typeof value.toJSON === 'function') {
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
54
56
|
value = value.toJSON();
|
|
57
|
+
}
|
|
55
58
|
if (!value || typeof value !== 'object') {
|
|
56
59
|
const node = new Scalar(value);
|
|
57
60
|
if (ref)
|
|
@@ -69,7 +72,7 @@ function createNode(value, tagName, ctx) {
|
|
|
69
72
|
onTagObj(tagObj);
|
|
70
73
|
delete ctx.onTagObj;
|
|
71
74
|
}
|
|
72
|
-
const node =
|
|
75
|
+
const node = tagObj?.createNode
|
|
73
76
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
74
77
|
: new Scalar(value);
|
|
75
78
|
if (tagName)
|
|
@@ -16,10 +16,17 @@ class Directives {
|
|
|
16
16
|
* The directives-end/doc-start marker `---`. If `null`, a marker may still be
|
|
17
17
|
* included in the document's stringified representation.
|
|
18
18
|
*/
|
|
19
|
-
this.
|
|
19
|
+
this.docStart = null;
|
|
20
|
+
/** The doc-end marker `...`. */
|
|
21
|
+
this.docEnd = false;
|
|
20
22
|
this.yaml = Object.assign({}, Directives.defaultYaml, yaml);
|
|
21
23
|
this.tags = Object.assign({}, Directives.defaultTags, tags);
|
|
22
24
|
}
|
|
25
|
+
clone() {
|
|
26
|
+
const copy = new Directives(this.yaml, this.tags);
|
|
27
|
+
copy.docStart = this.docStart;
|
|
28
|
+
return copy;
|
|
29
|
+
}
|
|
23
30
|
/**
|
|
24
31
|
* During parsing, get a Directives instance for the current document and
|
|
25
32
|
* update the stream state according to the current version's spec.
|
|
@@ -66,7 +73,7 @@ class Directives {
|
|
|
66
73
|
}
|
|
67
74
|
case '%YAML': {
|
|
68
75
|
this.yaml.explicit = true;
|
|
69
|
-
if (parts.length
|
|
76
|
+
if (parts.length !== 1) {
|
|
70
77
|
onError(0, '%YAML directive should contain exactly one part');
|
|
71
78
|
return false;
|
|
72
79
|
}
|
|
@@ -76,7 +83,8 @@ class Directives {
|
|
|
76
83
|
return true;
|
|
77
84
|
}
|
|
78
85
|
else {
|
|
79
|
-
|
|
86
|
+
const isValid = /^\d+\.\d+$/.test(version);
|
|
87
|
+
onError(6, `Unsupported YAML version ${version}`, isValid);
|
|
80
88
|
return false;
|
|
81
89
|
}
|
|
82
90
|
}
|
|
@@ -47,7 +47,7 @@ const prettifyError = (src, lc) => (error) => {
|
|
|
47
47
|
let count = 1;
|
|
48
48
|
const end = error.linePos[1];
|
|
49
49
|
if (end && end.line === line && end.col > col) {
|
|
50
|
-
count = Math.min(end.col - col, 80 - ci);
|
|
50
|
+
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
51
51
|
}
|
|
52
52
|
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
|
53
53
|
error.message += `:\n\n${lineStr}\n${pointer}\n`;
|