cdk8s 2.7.62 → 2.7.64
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/.backportrc.json +0 -1
- 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 +5 -3
- package/node_modules/yaml/browser/dist/options.js +0 -17
- package/node_modules/yaml/dist/options.js +0 -19
|
@@ -10,6 +10,7 @@ const CN = { composeNode, composeEmptyNode };
|
|
|
10
10
|
function composeNode(ctx, token, props, onError) {
|
|
11
11
|
const { spaceBefore, comment, anchor, tag } = props;
|
|
12
12
|
let node;
|
|
13
|
+
let isSrcToken = true;
|
|
13
14
|
switch (token.type) {
|
|
14
15
|
case 'alias':
|
|
15
16
|
node = composeAlias(ctx, token, onError);
|
|
@@ -31,9 +32,14 @@ function composeNode(ctx, token, props, onError) {
|
|
|
31
32
|
if (anchor)
|
|
32
33
|
node.anchor = anchor.source.substring(1);
|
|
33
34
|
break;
|
|
34
|
-
default:
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
default: {
|
|
36
|
+
const message = token.type === 'error'
|
|
37
|
+
? token.message
|
|
38
|
+
: `Unsupported token (type: ${token.type})`;
|
|
39
|
+
onError(token, 'UNEXPECTED_TOKEN', message);
|
|
40
|
+
node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError);
|
|
41
|
+
isSrcToken = false;
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
if (anchor && node.anchor === '')
|
|
39
45
|
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
@@ -45,9 +51,12 @@ function composeNode(ctx, token, props, onError) {
|
|
|
45
51
|
else
|
|
46
52
|
node.commentBefore = comment;
|
|
47
53
|
}
|
|
54
|
+
// @ts-expect-error Type checking misses meaning of isSrcToken
|
|
55
|
+
if (ctx.options.keepSourceTokens && isSrcToken)
|
|
56
|
+
node.srcToken = token;
|
|
48
57
|
return node;
|
|
49
58
|
}
|
|
50
|
-
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
59
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
51
60
|
const token = {
|
|
52
61
|
type: 'scalar',
|
|
53
62
|
offset: utilEmptyScalarPosition.emptyScalarPosition(offset, before, pos),
|
|
@@ -62,14 +71,18 @@ function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anch
|
|
|
62
71
|
}
|
|
63
72
|
if (spaceBefore)
|
|
64
73
|
node.spaceBefore = true;
|
|
65
|
-
if (comment)
|
|
74
|
+
if (comment) {
|
|
66
75
|
node.comment = comment;
|
|
76
|
+
node.range[2] = end;
|
|
77
|
+
}
|
|
67
78
|
return node;
|
|
68
79
|
}
|
|
69
80
|
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
70
81
|
const alias = new Alias.Alias(source.substring(1));
|
|
71
82
|
if (alias.source === '')
|
|
72
83
|
onError(offset, 'BAD_ALIAS', 'Alias cannot be an empty string');
|
|
84
|
+
if (alias.source.endsWith(':'))
|
|
85
|
+
onError(offset + source.length - 1, 'BAD_ALIAS', 'Alias ending in : is ambiguous', true);
|
|
73
86
|
const valueEnd = offset + source.length;
|
|
74
87
|
const re = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError);
|
|
75
88
|
alias.range = [offset, valueEnd, re.offset];
|
|
@@ -14,14 +14,17 @@ function composeScalar(ctx, token, tagToken, onError) {
|
|
|
14
14
|
: null;
|
|
15
15
|
const tag = tagToken && tagName
|
|
16
16
|
? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
|
|
17
|
-
:
|
|
17
|
+
: token.type === 'scalar'
|
|
18
|
+
? findScalarTagByTest(ctx, value, token, onError)
|
|
19
|
+
: ctx.schema[Node.SCALAR];
|
|
18
20
|
let scalar;
|
|
19
21
|
try {
|
|
20
|
-
const res = tag.resolve(value, msg => onError(tagToken
|
|
22
|
+
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
21
23
|
scalar = Node.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
22
24
|
}
|
|
23
25
|
catch (error) {
|
|
24
|
-
|
|
26
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
27
|
+
onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg);
|
|
25
28
|
scalar = new Scalar.Scalar(value);
|
|
26
29
|
}
|
|
27
30
|
scalar.range = range;
|
|
@@ -37,7 +40,6 @@ function composeScalar(ctx, token, tagToken, onError) {
|
|
|
37
40
|
return scalar;
|
|
38
41
|
}
|
|
39
42
|
function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
40
|
-
var _a;
|
|
41
43
|
if (tagName === '!')
|
|
42
44
|
return schema[Node.SCALAR]; // non-specific tag
|
|
43
45
|
const matchWithTest = [];
|
|
@@ -50,7 +52,7 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
for (const tag of matchWithTest)
|
|
53
|
-
if (
|
|
55
|
+
if (tag.test?.test(value))
|
|
54
56
|
return tag;
|
|
55
57
|
const kt = schema.knownTags[tagName];
|
|
56
58
|
if (kt && !kt.collection) {
|
|
@@ -62,15 +64,19 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
62
64
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
63
65
|
return schema[Node.SCALAR];
|
|
64
66
|
}
|
|
65
|
-
function findScalarTagByTest(schema, value,
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
68
|
+
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[Node.SCALAR];
|
|
69
|
+
if (schema.compat) {
|
|
70
|
+
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
71
|
+
schema[Node.SCALAR];
|
|
72
|
+
if (tag.tag !== compat.tag) {
|
|
73
|
+
const ts = directives.tagString(tag.tag);
|
|
74
|
+
const cs = directives.tagString(compat.tag);
|
|
75
|
+
const msg = `Value may be parsed as either ${ts} or ${cs}`;
|
|
76
|
+
onError(token, 'TAG_RESOLVE_FAILED', msg, true);
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
|
-
return
|
|
79
|
+
return tag;
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
exports.composeScalar = composeScalar;
|
|
@@ -2,13 +2,13 @@ import { Directives } from '../doc/directives.js';
|
|
|
2
2
|
import { Document } from '../doc/Document.js';
|
|
3
3
|
import { ErrorCode, YAMLParseError, YAMLWarning } from '../errors.js';
|
|
4
4
|
import { Range } from '../nodes/Node.js';
|
|
5
|
-
import { DocumentOptions, ParseOptions, SchemaOptions } from '../options.js';
|
|
5
|
+
import type { DocumentOptions, ParseOptions, SchemaOptions } from '../options.js';
|
|
6
6
|
import type { Token } from '../parse/cst.js';
|
|
7
|
-
|
|
7
|
+
type ErrorSource = number | [number, number] | Range | {
|
|
8
8
|
offset: number;
|
|
9
9
|
source?: string;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type ComposeErrorHandler = (source: ErrorSource, code: ErrorCode, message: string, warning?: boolean) => void;
|
|
12
12
|
/**
|
|
13
13
|
* Compose a stream of CST nodes into a stream of YAML Documents.
|
|
14
14
|
*
|
|
@@ -4,7 +4,6 @@ var directives = require('../doc/directives.js');
|
|
|
4
4
|
var Document = require('../doc/Document.js');
|
|
5
5
|
var errors = require('../errors.js');
|
|
6
6
|
var Node = require('../nodes/Node.js');
|
|
7
|
-
var options = require('../options.js');
|
|
8
7
|
var composeDoc = require('./compose-doc.js');
|
|
9
8
|
var resolveEnd = require('./resolve-end.js');
|
|
10
9
|
|
|
@@ -17,7 +16,6 @@ function getErrorPos(src) {
|
|
|
17
16
|
return [offset, offset + (typeof source === 'string' ? source.length : 1)];
|
|
18
17
|
}
|
|
19
18
|
function parsePrelude(prelude) {
|
|
20
|
-
var _a;
|
|
21
19
|
let comment = '';
|
|
22
20
|
let atComment = false;
|
|
23
21
|
let afterEmptyLine = false;
|
|
@@ -32,7 +30,7 @@ function parsePrelude(prelude) {
|
|
|
32
30
|
afterEmptyLine = false;
|
|
33
31
|
break;
|
|
34
32
|
case '%':
|
|
35
|
-
if (
|
|
33
|
+
if (prelude[i + 1]?.[0] !== '#')
|
|
36
34
|
i += 1;
|
|
37
35
|
atComment = false;
|
|
38
36
|
break;
|
|
@@ -57,7 +55,7 @@ function parsePrelude(prelude) {
|
|
|
57
55
|
* ```
|
|
58
56
|
*/
|
|
59
57
|
class Composer {
|
|
60
|
-
constructor(options
|
|
58
|
+
constructor(options = {}) {
|
|
61
59
|
this.doc = null;
|
|
62
60
|
this.atDirectives = false;
|
|
63
61
|
this.prelude = [];
|
|
@@ -70,10 +68,9 @@ class Composer {
|
|
|
70
68
|
else
|
|
71
69
|
this.errors.push(new errors.YAMLParseError(pos, code, message));
|
|
72
70
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.options = options$1;
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
72
|
+
this.directives = new directives.Directives({ version: options.version || '1.2' });
|
|
73
|
+
this.options = options;
|
|
77
74
|
}
|
|
78
75
|
decorate(doc, afterDoc) {
|
|
79
76
|
const { comment, afterEmptyLine } = parsePrelude(this.prelude);
|
|
@@ -83,7 +80,7 @@ class Composer {
|
|
|
83
80
|
if (afterDoc) {
|
|
84
81
|
doc.comment = doc.comment ? `${doc.comment}\n${comment}` : comment;
|
|
85
82
|
}
|
|
86
|
-
else if (afterEmptyLine || doc.directives.
|
|
83
|
+
else if (afterEmptyLine || doc.directives.docStart || !dc) {
|
|
87
84
|
doc.commentBefore = comment;
|
|
88
85
|
}
|
|
89
86
|
else if (Node.isCollection(dc) && !dc.flow && dc.items.length > 0) {
|
|
@@ -150,8 +147,8 @@ class Composer {
|
|
|
150
147
|
break;
|
|
151
148
|
case 'document': {
|
|
152
149
|
const doc = composeDoc.composeDoc(this.options, this.directives, token, this.onError);
|
|
153
|
-
if (this.atDirectives && !doc.directives.
|
|
154
|
-
this.onError(token, 'MISSING_CHAR', 'Missing directives-end indicator line');
|
|
150
|
+
if (this.atDirectives && !doc.directives.docStart)
|
|
151
|
+
this.onError(token, 'MISSING_CHAR', 'Missing directives-end/doc-start indicator line');
|
|
155
152
|
this.decorate(doc, false);
|
|
156
153
|
if (this.doc)
|
|
157
154
|
yield this.doc;
|
|
@@ -183,6 +180,7 @@ class Composer {
|
|
|
183
180
|
this.errors.push(new errors.YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg));
|
|
184
181
|
break;
|
|
185
182
|
}
|
|
183
|
+
this.doc.directives.docEnd = true;
|
|
186
184
|
const end = resolveEnd.resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError);
|
|
187
185
|
this.decorate(this.doc, true);
|
|
188
186
|
if (end.comment) {
|
|
@@ -209,7 +207,7 @@ class Composer {
|
|
|
209
207
|
this.doc = null;
|
|
210
208
|
}
|
|
211
209
|
else if (forceDoc) {
|
|
212
|
-
const opts = Object.assign({
|
|
210
|
+
const opts = Object.assign({ _directives: this.directives }, this.options);
|
|
213
211
|
const doc = new Document.Document(undefined, opts);
|
|
214
212
|
if (this.atDirectives)
|
|
215
213
|
this.onError(endOffset, 'MISSING_CHAR', 'Missing directives-end indicator line');
|
|
@@ -4,18 +4,22 @@ var Pair = require('../nodes/Pair.js');
|
|
|
4
4
|
var YAMLMap = require('../nodes/YAMLMap.js');
|
|
5
5
|
var resolveProps = require('./resolve-props.js');
|
|
6
6
|
var utilContainsNewline = require('./util-contains-newline.js');
|
|
7
|
+
var utilFlowIndentCheck = require('./util-flow-indent-check.js');
|
|
7
8
|
var utilMapIncludes = require('./util-map-includes.js');
|
|
8
9
|
|
|
9
10
|
const startColMsg = 'All mapping items must start at the same column';
|
|
10
11
|
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
11
|
-
var _a;
|
|
12
12
|
const map = new YAMLMap.YAMLMap(ctx.schema);
|
|
13
|
+
if (ctx.atRoot)
|
|
14
|
+
ctx.atRoot = false;
|
|
13
15
|
let offset = bm.offset;
|
|
14
|
-
|
|
16
|
+
let commentEnd = null;
|
|
17
|
+
for (const collItem of bm.items) {
|
|
18
|
+
const { start, key, sep, value } = collItem;
|
|
15
19
|
// key properties
|
|
16
20
|
const keyProps = resolveProps.resolveProps(start, {
|
|
17
21
|
indicator: 'explicit-key-ind',
|
|
18
|
-
next: key
|
|
22
|
+
next: key ?? sep?.[0],
|
|
19
23
|
offset,
|
|
20
24
|
onError,
|
|
21
25
|
startOnNewline: true
|
|
@@ -29,7 +33,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
29
33
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
30
34
|
}
|
|
31
35
|
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
32
|
-
|
|
36
|
+
commentEnd = keyProps.end;
|
|
33
37
|
if (keyProps.comment) {
|
|
34
38
|
if (map.comment)
|
|
35
39
|
map.comment += '\n' + keyProps.comment;
|
|
@@ -38,21 +42,24 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
38
42
|
}
|
|
39
43
|
continue;
|
|
40
44
|
}
|
|
45
|
+
if (keyProps.hasNewlineAfterProp || utilContainsNewline.containsNewline(key)) {
|
|
46
|
+
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
|
-
else if (
|
|
49
|
+
else if (keyProps.found?.indent !== bm.indent) {
|
|
43
50
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
44
|
-
|
|
45
|
-
onError(key, // checked by containsNewline()
|
|
46
|
-
'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
|
51
|
+
}
|
|
47
52
|
// key value
|
|
48
53
|
const keyStart = keyProps.end;
|
|
49
54
|
const keyNode = key
|
|
50
55
|
? composeNode(ctx, key, keyProps, onError)
|
|
51
56
|
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
57
|
+
if (ctx.schema.compat)
|
|
58
|
+
utilFlowIndentCheck.flowIndentCheck(bm.indent, key, onError);
|
|
52
59
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
53
60
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
54
61
|
// value properties
|
|
55
|
-
const valueProps = resolveProps.resolveProps(sep
|
|
62
|
+
const valueProps = resolveProps.resolveProps(sep ?? [], {
|
|
56
63
|
indicator: 'map-value-ind',
|
|
57
64
|
next: value,
|
|
58
65
|
offset: keyNode.range[2],
|
|
@@ -62,7 +69,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
62
69
|
offset = valueProps.end;
|
|
63
70
|
if (valueProps.found) {
|
|
64
71
|
if (implicitKey) {
|
|
65
|
-
if (
|
|
72
|
+
if (value?.type === 'block-map' && !valueProps.hasNewline)
|
|
66
73
|
onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'Nested mappings are not allowed in compact mappings');
|
|
67
74
|
if (ctx.options.strict &&
|
|
68
75
|
keyProps.start < valueProps.found.offset - 1024)
|
|
@@ -72,8 +79,13 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
72
79
|
const valueNode = value
|
|
73
80
|
? composeNode(ctx, value, valueProps, onError)
|
|
74
81
|
: composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
|
|
82
|
+
if (ctx.schema.compat)
|
|
83
|
+
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
75
84
|
offset = valueNode.range[2];
|
|
76
|
-
|
|
85
|
+
const pair = new Pair.Pair(keyNode, valueNode);
|
|
86
|
+
if (ctx.options.keepSourceTokens)
|
|
87
|
+
pair.srcToken = collItem;
|
|
88
|
+
map.items.push(pair);
|
|
77
89
|
}
|
|
78
90
|
else {
|
|
79
91
|
// key with no value
|
|
@@ -85,10 +97,15 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
85
97
|
else
|
|
86
98
|
keyNode.comment = valueProps.comment;
|
|
87
99
|
}
|
|
88
|
-
|
|
100
|
+
const pair = new Pair.Pair(keyNode);
|
|
101
|
+
if (ctx.options.keepSourceTokens)
|
|
102
|
+
pair.srcToken = collItem;
|
|
103
|
+
map.items.push(pair);
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
|
-
|
|
106
|
+
if (commentEnd && commentEnd < offset)
|
|
107
|
+
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content');
|
|
108
|
+
map.range = [bm.offset, offset, commentEnd ?? offset];
|
|
92
109
|
return map;
|
|
93
110
|
}
|
|
94
111
|
|
|
@@ -19,8 +19,10 @@ function resolveBlockScalar(scalar, strict, onError) {
|
|
|
19
19
|
break;
|
|
20
20
|
}
|
|
21
21
|
// shortcut for empty contents
|
|
22
|
-
if (
|
|
23
|
-
const value = header.chomp === '+'
|
|
22
|
+
if (chompStart === 0) {
|
|
23
|
+
const value = header.chomp === '+' && lines.length > 0
|
|
24
|
+
? '\n'.repeat(Math.max(1, lines.length - 1))
|
|
25
|
+
: '';
|
|
24
26
|
let end = start + header.length;
|
|
25
27
|
if (scalar.source)
|
|
26
28
|
end += scalar.source.length;
|
|
@@ -48,6 +50,11 @@ function resolveBlockScalar(scalar, strict, onError) {
|
|
|
48
50
|
}
|
|
49
51
|
offset += indent.length + content.length + 1;
|
|
50
52
|
}
|
|
53
|
+
// include trailing more-indented empty lines in content
|
|
54
|
+
for (let i = lines.length - 1; i >= chompStart; --i) {
|
|
55
|
+
if (lines[i][0].length > trimIndent)
|
|
56
|
+
chompStart = i + 1;
|
|
57
|
+
}
|
|
51
58
|
let value = '';
|
|
52
59
|
let sep = '';
|
|
53
60
|
let prevMoreIndented = false;
|
|
@@ -177,7 +184,9 @@ function splitLines(source) {
|
|
|
177
184
|
const split = source.split(/\n( *)/);
|
|
178
185
|
const first = split[0];
|
|
179
186
|
const m = first.match(/^( *)/);
|
|
180
|
-
const line0 = m
|
|
187
|
+
const line0 = m?.[1]
|
|
188
|
+
? [m[1], first.slice(m[1].length)]
|
|
189
|
+
: ['', first];
|
|
181
190
|
const lines = [line0];
|
|
182
191
|
for (let i = 1; i < split.length; i += 2)
|
|
183
192
|
lines.push([split[i], split[i + 1]]);
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var YAMLSeq = require('../nodes/YAMLSeq.js');
|
|
4
4
|
var resolveProps = require('./resolve-props.js');
|
|
5
|
+
var utilFlowIndentCheck = require('./util-flow-indent-check.js');
|
|
5
6
|
|
|
6
7
|
function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
7
8
|
const seq = new YAMLSeq.YAMLSeq(ctx.schema);
|
|
9
|
+
if (ctx.atRoot)
|
|
10
|
+
ctx.atRoot = false;
|
|
8
11
|
let offset = bs.offset;
|
|
12
|
+
let commentEnd = null;
|
|
9
13
|
for (const { start, value } of bs.items) {
|
|
10
14
|
const props = resolveProps.resolveProps(start, {
|
|
11
15
|
indicator: 'seq-item-ind',
|
|
@@ -14,16 +18,15 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
14
18
|
onError,
|
|
15
19
|
startOnNewline: true
|
|
16
20
|
});
|
|
17
|
-
offset = props.end;
|
|
18
21
|
if (!props.found) {
|
|
19
22
|
if (props.anchor || props.tag || value) {
|
|
20
23
|
if (value && value.type === 'block-seq')
|
|
21
|
-
onError(
|
|
24
|
+
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
22
25
|
else
|
|
23
26
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
24
27
|
}
|
|
25
28
|
else {
|
|
26
|
-
|
|
29
|
+
commentEnd = props.end;
|
|
27
30
|
if (props.comment)
|
|
28
31
|
seq.comment = props.comment;
|
|
29
32
|
continue;
|
|
@@ -31,11 +34,13 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
31
34
|
}
|
|
32
35
|
const node = value
|
|
33
36
|
? composeNode(ctx, value, props, onError)
|
|
34
|
-
: composeEmptyNode(ctx,
|
|
37
|
+
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
38
|
+
if (ctx.schema.compat)
|
|
39
|
+
utilFlowIndentCheck.flowIndentCheck(bs.indent, value, onError);
|
|
35
40
|
offset = node.range[2];
|
|
36
41
|
seq.items.push(node);
|
|
37
42
|
}
|
|
38
|
-
seq.range = [bs.offset, offset, offset];
|
|
43
|
+
seq.range = [bs.offset, offset, commentEnd ?? offset];
|
|
39
44
|
return seq;
|
|
40
45
|
}
|
|
41
46
|
|
|
@@ -18,13 +18,17 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
18
18
|
? new YAMLMap.YAMLMap(ctx.schema)
|
|
19
19
|
: new YAMLSeq.YAMLSeq(ctx.schema);
|
|
20
20
|
coll.flow = true;
|
|
21
|
-
|
|
21
|
+
const atRoot = ctx.atRoot;
|
|
22
|
+
if (atRoot)
|
|
23
|
+
ctx.atRoot = false;
|
|
24
|
+
let offset = fc.offset + fc.start.source.length;
|
|
22
25
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
23
|
-
const
|
|
26
|
+
const collItem = fc.items[i];
|
|
27
|
+
const { start, key, sep, value } = collItem;
|
|
24
28
|
const props = resolveProps.resolveProps(start, {
|
|
25
29
|
flow: fcName,
|
|
26
30
|
indicator: 'explicit-key-ind',
|
|
27
|
-
next: key
|
|
31
|
+
next: key ?? sep?.[0],
|
|
28
32
|
offset,
|
|
29
33
|
onError,
|
|
30
34
|
startOnNewline: false
|
|
@@ -41,6 +45,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
41
45
|
else
|
|
42
46
|
coll.comment = props.comment;
|
|
43
47
|
}
|
|
48
|
+
offset = props.end;
|
|
44
49
|
continue;
|
|
45
50
|
}
|
|
46
51
|
if (!isMap && ctx.options.strict && utilContainsNewline.containsNewline(key))
|
|
@@ -71,7 +76,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
71
76
|
if (prevItemComment) {
|
|
72
77
|
let prev = coll.items[coll.items.length - 1];
|
|
73
78
|
if (Node.isPair(prev))
|
|
74
|
-
prev = prev.value
|
|
79
|
+
prev = prev.value ?? prev.key;
|
|
75
80
|
if (prev.comment)
|
|
76
81
|
prev.comment += '\n' + prevItemComment;
|
|
77
82
|
else
|
|
@@ -101,7 +106,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
101
106
|
if (isBlock(key))
|
|
102
107
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
103
108
|
// value properties
|
|
104
|
-
const valueProps = resolveProps.resolveProps(sep
|
|
109
|
+
const valueProps = resolveProps.resolveProps(sep ?? [], {
|
|
105
110
|
flow: fcName,
|
|
106
111
|
indicator: 'map-value-ind',
|
|
107
112
|
next: value,
|
|
@@ -147,6 +152,8 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
147
152
|
keyNode.comment = valueProps.comment;
|
|
148
153
|
}
|
|
149
154
|
const pair = new Pair.Pair(keyNode, valueNode);
|
|
155
|
+
if (ctx.options.keepSourceTokens)
|
|
156
|
+
pair.srcToken = collItem;
|
|
150
157
|
if (isMap) {
|
|
151
158
|
const map = coll;
|
|
152
159
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
@@ -168,7 +175,11 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
168
175
|
if (ce && ce.source === expectedEnd)
|
|
169
176
|
cePos = ce.offset + ce.source.length;
|
|
170
177
|
else {
|
|
171
|
-
|
|
178
|
+
const name = fcName[0].toUpperCase() + fcName.substring(1);
|
|
179
|
+
const msg = atRoot
|
|
180
|
+
? `${name} must end with a ${expectedEnd}`
|
|
181
|
+
: `${name} in block collection must be sufficiently indented and end with a ${expectedEnd}`;
|
|
182
|
+
onError(offset, atRoot ? 'MISSING_CHAR' : 'BAD_INDENT', msg);
|
|
172
183
|
if (ce && ce.source.length !== 1)
|
|
173
184
|
ee.unshift(ce);
|
|
174
185
|
}
|
|
@@ -113,7 +113,7 @@ function foldLines(source) {
|
|
|
113
113
|
const last = /[ \t]*(.*)/sy;
|
|
114
114
|
last.lastIndex = pos;
|
|
115
115
|
match = last.exec(source);
|
|
116
|
-
return res + sep + (
|
|
116
|
+
return res + sep + (match?.[1] ?? '');
|
|
117
117
|
}
|
|
118
118
|
function doubleQuotedValue(source, onError) {
|
|
119
119
|
let res = '';
|
|
@@ -137,6 +137,12 @@ function doubleQuotedValue(source, onError) {
|
|
|
137
137
|
while (next === ' ' || next === '\t')
|
|
138
138
|
next = source[++i + 1];
|
|
139
139
|
}
|
|
140
|
+
else if (next === '\r' && source[i + 1] === '\n') {
|
|
141
|
+
// skip escaped CRLF newlines, but still trim the following line
|
|
142
|
+
next = source[++i + 1];
|
|
143
|
+
while (next === ' ' || next === '\t')
|
|
144
|
+
next = source[++i + 1];
|
|
145
|
+
}
|
|
140
146
|
else if (next === 'x' || next === 'u' || next === 'U') {
|
|
141
147
|
const length = { x: 2, u: 4, U: 8 }[next];
|
|
142
148
|
res += parseCharCode(source, i + 1, length, onError);
|
|
@@ -154,7 +160,7 @@ function doubleQuotedValue(source, onError) {
|
|
|
154
160
|
let next = source[i + 1];
|
|
155
161
|
while (next === ' ' || next === '\t')
|
|
156
162
|
next = source[++i + 1];
|
|
157
|
-
if (next !== '\n')
|
|
163
|
+
if (next !== '\n' && !(next === '\r' && source[i + 2] === '\n'))
|
|
158
164
|
res += i > wsStart ? source.slice(wsStart, i + 1) : ch;
|
|
159
165
|
}
|
|
160
166
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SourceToken, Token } from '../parse/cst.js';
|
|
2
2
|
import type { ComposeErrorHandler } from './composer.js';
|
|
3
3
|
export interface ResolvePropsArg {
|
|
4
|
-
flow?:
|
|
4
|
+
flow?: 'flow map' | 'flow sequence';
|
|
5
5
|
indicator: 'doc-start' | 'explicit-key-ind' | 'map-value-ind' | 'seq-item-ind';
|
|
6
6
|
next: Token | null | undefined;
|
|
7
7
|
offset: number;
|
|
@@ -14,6 +14,7 @@ export declare function resolveProps(tokens: SourceToken[], { flow, indicator, n
|
|
|
14
14
|
spaceBefore: boolean;
|
|
15
15
|
comment: string;
|
|
16
16
|
hasNewline: boolean;
|
|
17
|
+
hasNewlineAfterProp: boolean;
|
|
17
18
|
anchor: SourceToken | null;
|
|
18
19
|
tag: SourceToken | null;
|
|
19
20
|
end: number;
|
|
@@ -7,6 +7,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
7
7
|
let comment = '';
|
|
8
8
|
let commentSep = '';
|
|
9
9
|
let hasNewline = false;
|
|
10
|
+
let hasNewlineAfterProp = false;
|
|
10
11
|
let reqSpace = false;
|
|
11
12
|
let anchor = null;
|
|
12
13
|
let tag = null;
|
|
@@ -56,11 +57,15 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
56
57
|
commentSep += token.source;
|
|
57
58
|
atNewline = true;
|
|
58
59
|
hasNewline = true;
|
|
60
|
+
if (anchor || tag)
|
|
61
|
+
hasNewlineAfterProp = true;
|
|
59
62
|
hasSpace = true;
|
|
60
63
|
break;
|
|
61
64
|
case 'anchor':
|
|
62
65
|
if (anchor)
|
|
63
66
|
onError(token, 'MULTIPLE_ANCHORS', 'A node can have at most one anchor');
|
|
67
|
+
if (token.source.endsWith(':'))
|
|
68
|
+
onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
|
|
64
69
|
anchor = token;
|
|
65
70
|
if (start === null)
|
|
66
71
|
start = token.offset;
|
|
@@ -83,6 +88,8 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
83
88
|
// Could here handle preceding comments differently
|
|
84
89
|
if (anchor || tag)
|
|
85
90
|
onError(token, 'BAD_PROP_ORDER', `Anchors and tags must be after the ${token.source} indicator`);
|
|
91
|
+
if (found)
|
|
92
|
+
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow ?? 'collection'}`);
|
|
86
93
|
found = token;
|
|
87
94
|
atNewline = false;
|
|
88
95
|
hasSpace = false;
|
|
@@ -118,10 +125,11 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
118
125
|
spaceBefore,
|
|
119
126
|
comment,
|
|
120
127
|
hasNewline,
|
|
128
|
+
hasNewlineAfterProp,
|
|
121
129
|
anchor,
|
|
122
130
|
tag,
|
|
123
131
|
end,
|
|
124
|
-
start: start
|
|
132
|
+
start: start ?? end
|
|
125
133
|
};
|
|
126
134
|
}
|
|
127
135
|
|
|
@@ -16,7 +16,7 @@ function emptyScalarPosition(offset, before, pos) {
|
|
|
16
16
|
// Technically, an empty scalar is immediately after the last non-empty
|
|
17
17
|
// node, but it's more useful to place it after any whitespace.
|
|
18
18
|
st = before[++i];
|
|
19
|
-
while (
|
|
19
|
+
while (st?.type === 'space') {
|
|
20
20
|
offset += st.source.length;
|
|
21
21
|
st = before[++i];
|
|
22
22
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utilContainsNewline = require('./util-contains-newline.js');
|
|
4
|
+
|
|
5
|
+
function flowIndentCheck(indent, fc, onError) {
|
|
6
|
+
if (fc?.type === 'flow-collection') {
|
|
7
|
+
const end = fc.end[0];
|
|
8
|
+
if (end.indent === indent &&
|
|
9
|
+
(end.source === ']' || end.source === '}') &&
|
|
10
|
+
utilContainsNewline.containsNewline(fc)) {
|
|
11
|
+
const msg = 'Flow end indicator should be more indented than parent';
|
|
12
|
+
onError(end, 'BAD_INDENT', msg, true);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.flowIndentCheck = flowIndentCheck;
|