projen 0.54.58 → 0.55.2
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 +49 -19
- package/changelog.md +1 -1
- package/docs/api/API.md +14 -1
- package/docs/escape-hatches.md +19 -0
- package/lib/awscdk/auto-discover.js +4 -4
- package/lib/awscdk/awscdk-app-java.js +1 -1
- package/lib/awscdk/awscdk-app-py.js +1 -1
- package/lib/awscdk/awscdk-app-ts.js +1 -1
- package/lib/awscdk/awscdk-construct.js +2 -2
- package/lib/awscdk/awscdk-deps-java.js +1 -1
- package/lib/awscdk/awscdk-deps-js.js +1 -1
- package/lib/awscdk/awscdk-deps.js +1 -1
- package/lib/awscdk/cdk-config.js +1 -1
- package/lib/awscdk/cdk-tasks.js +1 -1
- package/lib/awscdk/integration-test.js +1 -1
- package/lib/awscdk/lambda-extension.js +1 -1
- package/lib/awscdk/lambda-function.js +2 -2
- package/lib/build/build-workflow.js +1 -1
- package/lib/cdk/auto-discover-base.js +2 -2
- package/lib/cdk/construct-lib.js +1 -1
- package/lib/cdk/integration-test-base.js +1 -1
- package/lib/cdk/jsii-docgen.js +1 -1
- package/lib/cdk/jsii-project.js +1 -1
- package/lib/cdk8s/auto-discover.js +2 -2
- package/lib/cdk8s/cdk8s-app-ts.js +1 -1
- package/lib/cdk8s/cdk8s-construct.js +1 -1
- package/lib/cdk8s/integration-test.js +1 -1
- package/lib/cdktf/cdktf-construct.js +1 -1
- package/lib/component.js +1 -1
- package/lib/dependencies.js +1 -1
- package/lib/dev-env.js +1 -1
- package/lib/docker-compose.js +2 -2
- package/lib/file.js +1 -1
- package/lib/gitattributes.js +1 -1
- package/lib/github/auto-approve.js +1 -1
- package/lib/github/auto-merge.js +1 -1
- package/lib/github/dependabot.js +1 -1
- package/lib/github/github-credentials.js +1 -1
- package/lib/github/github-project.js +1 -1
- package/lib/github/github.js +1 -1
- package/lib/github/mergify.js +1 -1
- package/lib/github/pr-template.js +1 -1
- package/lib/github/pull-request-lint.js +1 -1
- package/lib/github/stale.js +1 -1
- package/lib/github/task-workflow.js +1 -1
- package/lib/github/workflows.js +1 -1
- package/lib/gitlab/configuration.js +1 -1
- package/lib/gitlab/gitlab-configuration.js +1 -1
- package/lib/gitlab/nested-configuration.js +1 -1
- package/lib/gitpod.js +1 -1
- package/lib/ignore-file.js +1 -1
- package/lib/ini.js +1 -1
- package/lib/java/java-project.js +1 -1
- package/lib/java/junit.js +1 -1
- package/lib/java/maven-compile.js +1 -1
- package/lib/java/maven-packaging.js +1 -1
- package/lib/java/maven-sample.js +1 -1
- package/lib/java/pom.js +1 -1
- package/lib/java/projenrc.js +1 -1
- package/lib/javascript/bundler.js +1 -1
- package/lib/javascript/eslint.js +1 -1
- package/lib/javascript/jest.js +1 -1
- package/lib/javascript/node-package.js +1 -1
- package/lib/javascript/node-project.js +1 -1
- package/lib/javascript/npm-config.js +1 -1
- package/lib/javascript/prettier.js +1 -1
- package/lib/javascript/projenrc.js +1 -1
- package/lib/javascript/typescript-config.js +1 -1
- package/lib/javascript/upgrade-dependencies.js +2 -2
- package/lib/json.js +1 -1
- package/lib/license.js +1 -1
- package/lib/logger.js +1 -1
- package/lib/makefile.js +1 -1
- package/lib/object-file.js +1 -1
- package/lib/project-build.js +1 -1
- package/lib/project.d.ts +10 -0
- package/lib/project.js +28 -2
- package/lib/projects.js +1 -1
- package/lib/projenrc-json.js +1 -1
- package/lib/python/pip.js +1 -1
- package/lib/python/poetry.js +2 -2
- package/lib/python/projenrc.js +1 -1
- package/lib/python/pytest-sample.js +1 -1
- package/lib/python/pytest.js +1 -1
- package/lib/python/python-project.js +1 -1
- package/lib/python/python-sample.js +1 -1
- package/lib/python/requirements-file.js +1 -1
- package/lib/python/setuppy.js +1 -1
- package/lib/python/setuptools.js +1 -1
- package/lib/python/venv.js +1 -1
- package/lib/readme.js +1 -1
- package/lib/release/publisher.js +1 -1
- package/lib/release/release-trigger.js +1 -1
- package/lib/release/release.js +1 -1
- package/lib/sample-file.js +2 -2
- package/lib/semver.js +1 -1
- package/lib/source-code.js +1 -1
- package/lib/task-runtime.js +1 -1
- package/lib/task.js +1 -1
- package/lib/tasks.js +1 -1
- package/lib/testing.js +1 -1
- package/lib/textfile.js +1 -1
- package/lib/toml.js +1 -1
- package/lib/typescript/projenrc.js +1 -1
- package/lib/typescript/typescript-typedoc.js +1 -1
- package/lib/typescript/typescript.js +5 -5
- package/lib/util.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/vscode/devcontainer.js +1 -1
- package/lib/vscode/launch-config.js +1 -1
- package/lib/vscode/vscode.js +1 -1
- package/lib/web/next.js +3 -3
- package/lib/web/postcss.js +1 -1
- package/lib/web/react.js +4 -4
- package/lib/web/tailwind.js +1 -1
- package/lib/xmlfile.js +1 -1
- package/lib/yaml.js +1 -1
- package/node_modules/yaml/README.md +1 -1
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +1 -1
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +4 -4
- package/node_modules/yaml/browser/dist/compose/composer.js +1 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +7 -6
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +3 -1
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +4 -3
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +2 -1
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +5 -1
- package/node_modules/yaml/browser/dist/doc/Document.js +9 -5
- package/node_modules/yaml/browser/dist/doc/anchors.js +2 -2
- package/node_modules/yaml/browser/dist/doc/createNode.js +7 -4
- package/node_modules/yaml/browser/dist/nodes/Pair.js +2 -2
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +5 -4
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/toJS.js +3 -1
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +2 -2
- package/node_modules/yaml/browser/dist/parse/lexer.js +2 -1
- package/node_modules/yaml/browser/dist/parse/parser.js +64 -26
- package/node_modules/yaml/browser/dist/public-api.js +2 -1
- package/node_modules/yaml/browser/dist/schema/Schema.js +6 -2
- 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 +2 -1
- package/node_modules/yaml/browser/dist/stringify/stringify.js +8 -8
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +5 -3
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +4 -1
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +2 -2
- package/node_modules/yaml/dist/compose/compose-doc.js +1 -1
- package/node_modules/yaml/dist/compose/compose-scalar.js +4 -4
- package/node_modules/yaml/dist/compose/composer.js +1 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +7 -6
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +3 -1
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +4 -3
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +2 -1
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +2 -1
- package/node_modules/yaml/dist/compose/resolve-props.js +5 -1
- package/node_modules/yaml/dist/doc/Document.d.ts +1 -1
- package/node_modules/yaml/dist/doc/Document.js +9 -5
- package/node_modules/yaml/dist/doc/anchors.d.ts +2 -2
- package/node_modules/yaml/dist/doc/anchors.js +2 -2
- package/node_modules/yaml/dist/doc/createNode.d.ts +1 -1
- package/node_modules/yaml/dist/doc/createNode.js +7 -4
- package/node_modules/yaml/dist/doc/directives.d.ts +1 -1
- package/node_modules/yaml/dist/nodes/Pair.js +2 -2
- package/node_modules/yaml/dist/nodes/Scalar.js +1 -1
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +3 -1
- package/node_modules/yaml/dist/nodes/YAMLMap.js +5 -4
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +1 -1
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +1 -1
- package/node_modules/yaml/dist/nodes/toJS.js +3 -1
- package/node_modules/yaml/dist/options.d.ts +1 -1
- package/node_modules/yaml/dist/parse/cst-visit.js +2 -2
- package/node_modules/yaml/dist/parse/lexer.js +2 -1
- package/node_modules/yaml/dist/parse/parser.js +64 -26
- package/node_modules/yaml/dist/public-api.js +2 -1
- package/node_modules/yaml/dist/schema/Schema.js +6 -2
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +2 -1
- package/node_modules/yaml/dist/stringify/stringify.js +8 -8
- package/node_modules/yaml/dist/stringify/stringifyComment.js +5 -3
- package/node_modules/yaml/dist/stringify/stringifyPair.js +4 -1
- package/node_modules/yaml/dist/stringify/stringifyString.js +2 -2
- package/node_modules/yaml/dist/test-events.js +1 -1
- package/node_modules/yaml/package.json +2 -2
- package/package.json +5 -5
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
|
@@ -72,6 +72,7 @@ function singleQuotedValue(source, onError) {
|
|
|
72
72
|
return foldLines(source.slice(1, -1)).replace(/''/g, "'");
|
|
73
73
|
}
|
|
74
74
|
function foldLines(source) {
|
|
75
|
+
var _a;
|
|
75
76
|
/**
|
|
76
77
|
* The negative lookbehind here and in the `re` RegExp is to
|
|
77
78
|
* prevent causing a polynomial search time in certain cases.
|
|
@@ -111,7 +112,7 @@ function foldLines(source) {
|
|
|
111
112
|
const last = /[ \t]*(.*)/sy;
|
|
112
113
|
last.lastIndex = pos;
|
|
113
114
|
match = last.exec(source);
|
|
114
|
-
return res + sep + ((match
|
|
115
|
+
return res + sep + ((_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : '');
|
|
115
116
|
}
|
|
116
117
|
function doubleQuotedValue(source, onError) {
|
|
117
118
|
let res = '';
|
|
@@ -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,6 +55,8 @@ 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':
|
|
@@ -84,7 +87,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
84
87
|
if (anchor || tag)
|
|
85
88
|
onError(token, 'BAD_PROP_ORDER', `Anchors and tags must be after the ${token.source} indicator`);
|
|
86
89
|
if (found)
|
|
87
|
-
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow
|
|
90
|
+
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow !== null && flow !== void 0 ? flow : 'collection'}`);
|
|
88
91
|
found = token;
|
|
89
92
|
atNewline = false;
|
|
90
93
|
hasSpace = false;
|
|
@@ -120,6 +123,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
120
123
|
spaceBefore,
|
|
121
124
|
comment,
|
|
122
125
|
hasNewline,
|
|
126
|
+
hasNewlineAfterProp,
|
|
123
127
|
anchor,
|
|
124
128
|
tag,
|
|
125
129
|
end,
|
|
@@ -102,6 +102,7 @@ class Document {
|
|
|
102
102
|
if (!node.anchor) {
|
|
103
103
|
const prev = anchorNames(this);
|
|
104
104
|
node.anchor =
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
105
106
|
!name || prev.has(name) ? findNewAnchor(name || 'a', prev) : name;
|
|
106
107
|
}
|
|
107
108
|
return new Alias(node.anchor);
|
|
@@ -123,8 +124,10 @@ class Document {
|
|
|
123
124
|
options = replacer;
|
|
124
125
|
replacer = undefined;
|
|
125
126
|
}
|
|
126
|
-
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options
|
|
127
|
-
const { onAnchor, setAnchors, sourceObjects } = createNodeAnchors(this,
|
|
127
|
+
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options !== null && options !== void 0 ? options : {};
|
|
128
|
+
const { onAnchor, setAnchors, sourceObjects } = createNodeAnchors(this,
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
130
|
+
anchorPrefix || 'a');
|
|
128
131
|
const ctx = {
|
|
129
132
|
aliasDuplicateObjects: aliasDuplicateObjects !== null && aliasDuplicateObjects !== void 0 ? aliasDuplicateObjects : true,
|
|
130
133
|
keepUndefined: keepUndefined !== null && keepUndefined !== void 0 ? keepUndefined : false,
|
|
@@ -255,10 +258,11 @@ class Document {
|
|
|
255
258
|
opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
256
259
|
break;
|
|
257
260
|
case '1.2':
|
|
261
|
+
case 'next':
|
|
258
262
|
if (this.directives)
|
|
259
|
-
this.directives.yaml.version =
|
|
263
|
+
this.directives.yaml.version = version;
|
|
260
264
|
else
|
|
261
|
-
this.directives = new Directives({ version
|
|
265
|
+
this.directives = new Directives({ version });
|
|
262
266
|
opt = { merge: false, resolveKnownTags: true, schema: 'core' };
|
|
263
267
|
break;
|
|
264
268
|
case null:
|
|
@@ -290,7 +294,7 @@ class Document {
|
|
|
290
294
|
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100,
|
|
291
295
|
stringify
|
|
292
296
|
};
|
|
293
|
-
const res = toJS(this.contents, jsonArg
|
|
297
|
+
const res = toJS(this.contents, jsonArg !== null && jsonArg !== void 0 ? jsonArg : '', ctx);
|
|
294
298
|
if (typeof onAnchor === 'function')
|
|
295
299
|
for (const { count, res } of ctx.anchors.values())
|
|
296
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' &&
|
|
@@ -4,14 +4,15 @@ import { Scalar } from '../nodes/Scalar.js';
|
|
|
4
4
|
|
|
5
5
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
6
6
|
function findTagObject(value, tagName, tags) {
|
|
7
|
+
var _a;
|
|
7
8
|
if (tagName) {
|
|
8
9
|
const match = tags.filter(t => t.tag === tagName);
|
|
9
|
-
const tagObj = match.find(t => !t.format)
|
|
10
|
+
const tagObj = (_a = match.find(t => !t.format)) !== null && _a !== void 0 ? _a : match[0];
|
|
10
11
|
if (!tagObj)
|
|
11
12
|
throw new Error(`Tag ${tagName} not found`);
|
|
12
13
|
return tagObj;
|
|
13
14
|
}
|
|
14
|
-
return tags.find(t => t.identify
|
|
15
|
+
return tags.find(t => { var _a; return ((_a = t.identify) === null || _a === void 0 ? void 0 : _a.call(t, value)) && !t.format; });
|
|
15
16
|
}
|
|
16
17
|
function createNode(value, tagName, ctx) {
|
|
17
18
|
var _a, _b;
|
|
@@ -48,12 +49,14 @@ function createNode(value, tagName, ctx) {
|
|
|
48
49
|
sourceObjects.set(value, ref);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
if (tagName
|
|
52
|
+
if (tagName === null || tagName === void 0 ? void 0 : tagName.startsWith('!!'))
|
|
52
53
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
53
54
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
54
55
|
if (!tagObj) {
|
|
55
|
-
if (value && typeof value.toJSON === 'function')
|
|
56
|
+
if (value && typeof value.toJSON === 'function') {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
56
58
|
value = value.toJSON();
|
|
59
|
+
}
|
|
57
60
|
if (!value || typeof value !== 'object') {
|
|
58
61
|
const node = new Scalar(value);
|
|
59
62
|
if (ref)
|
|
@@ -23,11 +23,11 @@ class Pair {
|
|
|
23
23
|
return new Pair(key, value);
|
|
24
24
|
}
|
|
25
25
|
toJSON(_, ctx) {
|
|
26
|
-
const pair = ctx
|
|
26
|
+
const pair = (ctx === null || ctx === void 0 ? void 0 : ctx.mapAsMap) ? new Map() : {};
|
|
27
27
|
return addPairToJSMap(ctx, pair, this);
|
|
28
28
|
}
|
|
29
29
|
toString(ctx, onComment, onChompKeep) {
|
|
30
|
-
return ctx
|
|
30
|
+
return (ctx === null || ctx === void 0 ? void 0 : ctx.doc)
|
|
31
31
|
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
32
32
|
: JSON.stringify(this);
|
|
33
33
|
}
|
|
@@ -8,7 +8,7 @@ class Scalar extends NodeBase {
|
|
|
8
8
|
this.value = value;
|
|
9
9
|
}
|
|
10
10
|
toJSON(arg, ctx) {
|
|
11
|
-
return ctx
|
|
11
|
+
return (ctx === null || ctx === void 0 ? void 0 : ctx.keep) ? this.value : toJS(this.value, arg, ctx);
|
|
12
12
|
}
|
|
13
13
|
toString() {
|
|
14
14
|
return String(this.value);
|
|
@@ -32,6 +32,7 @@ class YAMLMap extends Collection {
|
|
|
32
32
|
* collection will throw. Otherwise, overwrites the previous value.
|
|
33
33
|
*/
|
|
34
34
|
add(pair, overwrite) {
|
|
35
|
+
var _a;
|
|
35
36
|
let _pair;
|
|
36
37
|
if (isPair(pair))
|
|
37
38
|
_pair = pair;
|
|
@@ -42,7 +43,7 @@ class YAMLMap extends Collection {
|
|
|
42
43
|
else
|
|
43
44
|
_pair = new Pair(pair.key, pair.value);
|
|
44
45
|
const prev = findPair(this.items, _pair.key);
|
|
45
|
-
const sortEntries = this.schema
|
|
46
|
+
const sortEntries = (_a = this.schema) === null || _a === void 0 ? void 0 : _a.sortMapEntries;
|
|
46
47
|
if (prev) {
|
|
47
48
|
if (!overwrite)
|
|
48
49
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -72,7 +73,7 @@ class YAMLMap extends Collection {
|
|
|
72
73
|
}
|
|
73
74
|
get(key, keepScalar) {
|
|
74
75
|
const it = findPair(this.items, key);
|
|
75
|
-
const node = it
|
|
76
|
+
const node = it === null || it === void 0 ? void 0 : it.value;
|
|
76
77
|
return !keepScalar && isScalar(node) ? node.value : node;
|
|
77
78
|
}
|
|
78
79
|
has(key) {
|
|
@@ -87,8 +88,8 @@ class YAMLMap extends Collection {
|
|
|
87
88
|
* @returns Instance of Type, Map, or Object
|
|
88
89
|
*/
|
|
89
90
|
toJSON(_, ctx, Type) {
|
|
90
|
-
const map = Type ? new Type() : ctx
|
|
91
|
-
if (ctx
|
|
91
|
+
const map = Type ? new Type() : (ctx === null || ctx === void 0 ? void 0 : ctx.mapAsMap) ? new Map() : {};
|
|
92
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.onCreate)
|
|
92
93
|
ctx.onCreate(map);
|
|
93
94
|
for (const item of this.items)
|
|
94
95
|
addPairToJSMap(ctx, map, item);
|
|
@@ -6,7 +6,7 @@ import { toJS } from './toJS.js';
|
|
|
6
6
|
|
|
7
7
|
const MERGE_KEY = '<<';
|
|
8
8
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
9
|
-
if (ctx
|
|
9
|
+
if ((ctx === null || ctx === void 0 ? void 0 : ctx.doc.schema.merge) && isMergeKey(key)) {
|
|
10
10
|
value = isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
11
11
|
if (isSeq(value))
|
|
12
12
|
for (const it of value.items)
|
|
@@ -11,9 +11,11 @@ import { hasAnchor } from './Node.js';
|
|
|
11
11
|
* stringification.
|
|
12
12
|
*/
|
|
13
13
|
function toJS(value, arg, ctx) {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
14
15
|
if (Array.isArray(value))
|
|
15
16
|
return value.map((v, i) => toJS(v, String(i), ctx));
|
|
16
17
|
if (value && typeof value.toJSON === 'function') {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
17
19
|
if (!ctx || !hasAnchor(value))
|
|
18
20
|
return value.toJSON(arg, ctx);
|
|
19
21
|
const data = { aliasCount: 0, count: 1, res: undefined };
|
|
@@ -27,7 +29,7 @@ function toJS(value, arg, ctx) {
|
|
|
27
29
|
ctx.onCreate(res);
|
|
28
30
|
return res;
|
|
29
31
|
}
|
|
30
|
-
if (typeof value === 'bigint' && !(ctx
|
|
32
|
+
if (typeof value === 'bigint' && !(ctx === null || ctx === void 0 ? void 0 : ctx.keep))
|
|
31
33
|
return Number(value);
|
|
32
34
|
return value;
|
|
33
35
|
}
|
|
@@ -47,7 +47,7 @@ visit.REMOVE = REMOVE;
|
|
|
47
47
|
visit.itemAtPath = (cst, path) => {
|
|
48
48
|
let item = cst;
|
|
49
49
|
for (const [field, index] of path) {
|
|
50
|
-
const tok = item
|
|
50
|
+
const tok = item === null || item === void 0 ? void 0 : item[field];
|
|
51
51
|
if (tok && 'items' in tok) {
|
|
52
52
|
item = tok.items[index];
|
|
53
53
|
}
|
|
@@ -64,7 +64,7 @@ visit.itemAtPath = (cst, path) => {
|
|
|
64
64
|
visit.parentCollection = (cst, path) => {
|
|
65
65
|
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
66
66
|
const field = path[path.length - 1][0];
|
|
67
|
-
const coll = parent
|
|
67
|
+
const coll = parent === null || parent === void 0 ? void 0 : parent[field];
|
|
68
68
|
if (coll && 'items' in coll)
|
|
69
69
|
return coll;
|
|
70
70
|
throw new Error('Parent collection not found');
|
|
@@ -148,12 +148,13 @@ class Lexer {
|
|
|
148
148
|
* @returns A generator of lexical tokens
|
|
149
149
|
*/
|
|
150
150
|
*lex(source, incomplete = false) {
|
|
151
|
+
var _a;
|
|
151
152
|
if (source) {
|
|
152
153
|
this.buffer = this.buffer ? this.buffer + source : source;
|
|
153
154
|
this.lineEndPos = null;
|
|
154
155
|
}
|
|
155
156
|
this.atEnd = !incomplete;
|
|
156
|
-
let next = this.next
|
|
157
|
+
let next = (_a = this.next) !== null && _a !== void 0 ? _a : 'stream';
|
|
157
158
|
while (next && (incomplete || this.hasChars(1)))
|
|
158
159
|
next = yield* this.parseNext(next);
|
|
159
160
|
}
|
|
@@ -7,7 +7,7 @@ function includesToken(list, type) {
|
|
|
7
7
|
return true;
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function findNonEmptyIndex(list) {
|
|
11
11
|
for (let i = 0; i < list.length; ++i) {
|
|
12
12
|
switch (list[i].type) {
|
|
13
13
|
case 'space':
|
|
@@ -15,10 +15,10 @@ function includesNonEmpty(list) {
|
|
|
15
15
|
case 'newline':
|
|
16
16
|
break;
|
|
17
17
|
default:
|
|
18
|
-
return
|
|
18
|
+
return i;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return -1;
|
|
22
22
|
}
|
|
23
23
|
function isFlowToken(token) {
|
|
24
24
|
switch (token === null || token === void 0 ? void 0 : token.type) {
|
|
@@ -33,12 +33,13 @@ function isFlowToken(token) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
function getPrevProps(parent) {
|
|
36
|
+
var _a;
|
|
36
37
|
switch (parent.type) {
|
|
37
38
|
case 'document':
|
|
38
39
|
return parent.start;
|
|
39
40
|
case 'block-map': {
|
|
40
41
|
const it = parent.items[parent.items.length - 1];
|
|
41
|
-
return it.sep
|
|
42
|
+
return (_a = it.sep) !== null && _a !== void 0 ? _a : it.start;
|
|
42
43
|
}
|
|
43
44
|
case 'block-seq':
|
|
44
45
|
return parent.items[parent.items.length - 1].start;
|
|
@@ -265,7 +266,7 @@ class Parser {
|
|
|
265
266
|
return this.stack[this.stack.length - n];
|
|
266
267
|
}
|
|
267
268
|
*pop(error) {
|
|
268
|
-
const token = error
|
|
269
|
+
const token = error !== null && error !== void 0 ? error : this.stack.pop();
|
|
269
270
|
/* istanbul ignore if should not happen */
|
|
270
271
|
if (!token) {
|
|
271
272
|
const message = 'Tried to pop an empty stack';
|
|
@@ -342,7 +343,7 @@ class Parser {
|
|
|
342
343
|
!last.sep &&
|
|
343
344
|
!last.value &&
|
|
344
345
|
last.start.length > 0 &&
|
|
345
|
-
|
|
346
|
+
findNonEmptyIndex(last.start) === -1 &&
|
|
346
347
|
(token.indent === 0 ||
|
|
347
348
|
last.start.every(st => st.type !== 'comment' || st.indent < token.indent))) {
|
|
348
349
|
if (top.type === 'document')
|
|
@@ -390,7 +391,7 @@ class Parser {
|
|
|
390
391
|
return yield* this.lineEnd(doc);
|
|
391
392
|
switch (this.type) {
|
|
392
393
|
case 'doc-start': {
|
|
393
|
-
if (
|
|
394
|
+
if (findNonEmptyIndex(doc.start) !== -1) {
|
|
394
395
|
yield* this.pop();
|
|
395
396
|
yield* this.step();
|
|
396
397
|
}
|
|
@@ -484,17 +485,21 @@ class Parser {
|
|
|
484
485
|
else
|
|
485
486
|
map.items.push({ start: [this.sourceToken] });
|
|
486
487
|
}
|
|
487
|
-
else if (it.sep)
|
|
488
|
+
else if (it.sep) {
|
|
488
489
|
it.sep.push(this.sourceToken);
|
|
489
|
-
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
490
492
|
it.start.push(this.sourceToken);
|
|
493
|
+
}
|
|
491
494
|
return;
|
|
492
495
|
case 'space':
|
|
493
496
|
case 'comment':
|
|
494
|
-
if (it.value)
|
|
497
|
+
if (it.value) {
|
|
495
498
|
map.items.push({ start: [this.sourceToken] });
|
|
496
|
-
|
|
499
|
+
}
|
|
500
|
+
else if (it.sep) {
|
|
497
501
|
it.sep.push(this.sourceToken);
|
|
502
|
+
}
|
|
498
503
|
else {
|
|
499
504
|
if (this.atIndentedComment(it.start, map.indent)) {
|
|
500
505
|
const prev = map.items[map.items.length - 2];
|
|
@@ -511,33 +516,61 @@ class Parser {
|
|
|
511
516
|
return;
|
|
512
517
|
}
|
|
513
518
|
if (this.indent >= map.indent) {
|
|
514
|
-
const atNextItem = !this.onKeyLine &&
|
|
515
|
-
|
|
516
|
-
|
|
519
|
+
const atNextItem = !this.onKeyLine && this.indent === map.indent && it.sep;
|
|
520
|
+
// For empty nodes, assign newline-separated not indented empty tokens to following node
|
|
521
|
+
let start = [];
|
|
522
|
+
if (atNextItem && it.sep && !it.value) {
|
|
523
|
+
const nl = [];
|
|
524
|
+
for (let i = 0; i < it.sep.length; ++i) {
|
|
525
|
+
const st = it.sep[i];
|
|
526
|
+
switch (st.type) {
|
|
527
|
+
case 'newline':
|
|
528
|
+
nl.push(i);
|
|
529
|
+
break;
|
|
530
|
+
case 'space':
|
|
531
|
+
break;
|
|
532
|
+
case 'comment':
|
|
533
|
+
if (st.indent > map.indent)
|
|
534
|
+
nl.length = 0;
|
|
535
|
+
break;
|
|
536
|
+
default:
|
|
537
|
+
nl.length = 0;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (nl.length >= 2)
|
|
541
|
+
start = it.sep.splice(nl[1]);
|
|
542
|
+
}
|
|
517
543
|
switch (this.type) {
|
|
518
544
|
case 'anchor':
|
|
519
545
|
case 'tag':
|
|
520
546
|
if (atNextItem || it.value) {
|
|
521
|
-
|
|
547
|
+
start.push(this.sourceToken);
|
|
548
|
+
map.items.push({ start });
|
|
522
549
|
this.onKeyLine = true;
|
|
523
550
|
}
|
|
524
|
-
else if (it.sep)
|
|
551
|
+
else if (it.sep) {
|
|
525
552
|
it.sep.push(this.sourceToken);
|
|
526
|
-
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
527
555
|
it.start.push(this.sourceToken);
|
|
556
|
+
}
|
|
528
557
|
return;
|
|
529
558
|
case 'explicit-key-ind':
|
|
530
|
-
if (!it.sep && !includesToken(it.start, 'explicit-key-ind'))
|
|
559
|
+
if (!it.sep && !includesToken(it.start, 'explicit-key-ind')) {
|
|
531
560
|
it.start.push(this.sourceToken);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
561
|
+
}
|
|
562
|
+
else if (atNextItem || it.value) {
|
|
563
|
+
start.push(this.sourceToken);
|
|
564
|
+
map.items.push({ start });
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
535
567
|
this.stack.push({
|
|
536
568
|
type: 'block-map',
|
|
537
569
|
offset: this.offset,
|
|
538
570
|
indent: this.indent,
|
|
539
571
|
items: [{ start: [this.sourceToken] }]
|
|
540
572
|
});
|
|
573
|
+
}
|
|
541
574
|
this.onKeyLine = true;
|
|
542
575
|
return;
|
|
543
576
|
case 'map-value-ind':
|
|
@@ -564,7 +597,7 @@ class Parser {
|
|
|
564
597
|
type: 'block-map',
|
|
565
598
|
offset: this.offset,
|
|
566
599
|
indent: this.indent,
|
|
567
|
-
items: [{ start
|
|
600
|
+
items: [{ start, key: null, sep: [this.sourceToken] }]
|
|
568
601
|
});
|
|
569
602
|
}
|
|
570
603
|
else if (isFlowToken(it.key) &&
|
|
@@ -582,6 +615,10 @@ class Parser {
|
|
|
582
615
|
items: [{ start, key, sep }]
|
|
583
616
|
});
|
|
584
617
|
}
|
|
618
|
+
else if (start.length > 0) {
|
|
619
|
+
// Not actually at next item
|
|
620
|
+
it.sep = it.sep.concat(start, this.sourceToken);
|
|
621
|
+
}
|
|
585
622
|
else {
|
|
586
623
|
it.sep.push(this.sourceToken);
|
|
587
624
|
}
|
|
@@ -591,7 +628,7 @@ class Parser {
|
|
|
591
628
|
Object.assign(it, { key: null, sep: [this.sourceToken] });
|
|
592
629
|
}
|
|
593
630
|
else if (it.value || atNextItem) {
|
|
594
|
-
map.items.push({ start
|
|
631
|
+
map.items.push({ start, key: null, sep: [this.sourceToken] });
|
|
595
632
|
}
|
|
596
633
|
else if (includesToken(it.sep, 'map-value-ind')) {
|
|
597
634
|
this.stack.push({
|
|
@@ -613,7 +650,7 @@ class Parser {
|
|
|
613
650
|
case 'double-quoted-scalar': {
|
|
614
651
|
const fs = this.flowScalar(this.type);
|
|
615
652
|
if (atNextItem || it.value) {
|
|
616
|
-
map.items.push({ start
|
|
653
|
+
map.items.push({ start, key: fs, sep: [] });
|
|
617
654
|
this.onKeyLine = true;
|
|
618
655
|
}
|
|
619
656
|
else if (it.sep) {
|
|
@@ -630,8 +667,9 @@ class Parser {
|
|
|
630
667
|
if (bv) {
|
|
631
668
|
if (atNextItem &&
|
|
632
669
|
bv.type !== 'block-seq' &&
|
|
633
|
-
includesToken(it.start, 'explicit-key-ind'))
|
|
634
|
-
map.items.push({ start
|
|
670
|
+
includesToken(it.start, 'explicit-key-ind')) {
|
|
671
|
+
map.items.push({ start });
|
|
672
|
+
}
|
|
635
673
|
this.stack.push(bv);
|
|
636
674
|
return;
|
|
637
675
|
}
|
|
@@ -75,6 +75,7 @@ function parse(src, reviver, options) {
|
|
|
75
75
|
return doc.toJS(Object.assign({ reviver: _reviver }, options));
|
|
76
76
|
}
|
|
77
77
|
function stringify(value, replacer, options) {
|
|
78
|
+
var _a;
|
|
78
79
|
let _replacer = null;
|
|
79
80
|
if (typeof replacer === 'function' || Array.isArray(replacer)) {
|
|
80
81
|
_replacer = replacer;
|
|
@@ -89,7 +90,7 @@ function stringify(value, replacer, options) {
|
|
|
89
90
|
options = indent < 1 ? undefined : indent > 8 ? { indent: 8 } : { indent };
|
|
90
91
|
}
|
|
91
92
|
if (value === undefined) {
|
|
92
|
-
const { keepUndefined } = options
|
|
93
|
+
const { keepUndefined } = (_a = options !== null && options !== void 0 ? options : replacer) !== null && _a !== void 0 ? _a : {};
|
|
93
94
|
if (!keepUndefined)
|
|
94
95
|
return undefined;
|
|
95
96
|
}
|
|
@@ -16,13 +16,17 @@ class Schema {
|
|
|
16
16
|
this.name = (typeof schema === 'string' && schema) || 'core';
|
|
17
17
|
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
18
18
|
this.tags = getTags(customTags, this.name);
|
|
19
|
-
this.toStringOptions = toStringDefaults
|
|
19
|
+
this.toStringOptions = toStringDefaults !== null && toStringDefaults !== void 0 ? toStringDefaults : null;
|
|
20
20
|
Object.defineProperty(this, MAP, { value: map });
|
|
21
21
|
Object.defineProperty(this, SCALAR, { value: string });
|
|
22
22
|
Object.defineProperty(this, SEQ, { value: seq });
|
|
23
23
|
// Used by createMap()
|
|
24
24
|
this.sortMapEntries =
|
|
25
|
-
sortMapEntries ===
|
|
25
|
+
typeof sortMapEntries === 'function'
|
|
26
|
+
? sortMapEntries
|
|
27
|
+
: sortMapEntries === true
|
|
28
|
+
? sortMapEntriesByKey
|
|
29
|
+
: null;
|
|
26
30
|
}
|
|
27
31
|
clone() {
|
|
28
32
|
const copy = Object.create(Schema.prototype, Object.getOwnPropertyDescriptors(this));
|
|
@@ -22,7 +22,7 @@ class YAMLOMap extends YAMLSeq {
|
|
|
22
22
|
if (!ctx)
|
|
23
23
|
return super.toJSON(_);
|
|
24
24
|
const map = new Map();
|
|
25
|
-
if (ctx
|
|
25
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.onCreate)
|
|
26
26
|
ctx.onCreate(map);
|
|
27
27
|
for (const pair of this.items) {
|
|
28
28
|
let key, value;
|
|
@@ -4,6 +4,7 @@ import { Scalar } from '../../nodes/Scalar.js';
|
|
|
4
4
|
import { YAMLSeq } from '../../nodes/YAMLSeq.js';
|
|
5
5
|
|
|
6
6
|
function resolvePairs(seq, onError) {
|
|
7
|
+
var _a;
|
|
7
8
|
if (isSeq(seq)) {
|
|
8
9
|
for (let i = 0; i < seq.items.length; ++i) {
|
|
9
10
|
let item = seq.items[i];
|
|
@@ -18,7 +19,7 @@ function resolvePairs(seq, onError) {
|
|
|
18
19
|
? `${item.commentBefore}\n${pair.key.commentBefore}`
|
|
19
20
|
: item.commentBefore;
|
|
20
21
|
if (item.comment) {
|
|
21
|
-
const cn = pair.value
|
|
22
|
+
const cn = (_a = pair.value) !== null && _a !== void 0 ? _a : pair.key;
|
|
22
23
|
cn.comment = cn.comment
|
|
23
24
|
? `${item.comment}\n${cn.comment}`
|
|
24
25
|
: item.comment;
|
|
@@ -43,26 +43,26 @@ function createStringifyContext(doc, options) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
function getTagObject(tags, item) {
|
|
46
|
+
var _a, _b, _c, _d;
|
|
46
47
|
if (item.tag) {
|
|
47
48
|
const match = tags.filter(t => t.tag === item.tag);
|
|
48
49
|
if (match.length > 0)
|
|
49
|
-
return match.find(t => t.format === item.format)
|
|
50
|
+
return (_a = match.find(t => t.format === item.format)) !== null && _a !== void 0 ? _a : match[0];
|
|
50
51
|
}
|
|
51
52
|
let tagObj = undefined;
|
|
52
53
|
let obj;
|
|
53
54
|
if (isScalar(item)) {
|
|
54
55
|
obj = item.value;
|
|
55
|
-
const match = tags.filter(t => t.identify
|
|
56
|
+
const match = tags.filter(t => { var _a; return (_a = t.identify) === null || _a === void 0 ? void 0 : _a.call(t, obj); });
|
|
56
57
|
tagObj =
|
|
57
|
-
match.find(t => t.format === item.format)
|
|
58
|
+
(_b = match.find(t => t.format === item.format)) !== null && _b !== void 0 ? _b : match.find(t => !t.format);
|
|
58
59
|
}
|
|
59
60
|
else {
|
|
60
61
|
obj = item;
|
|
61
62
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
62
63
|
}
|
|
63
64
|
if (!tagObj) {
|
|
64
|
-
|
|
65
|
-
const name = obj && obj.constructor ? obj.constructor.name : typeof obj;
|
|
65
|
+
const name = (_d = (_c = obj === null || obj === void 0 ? void 0 : obj.constructor) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : typeof obj;
|
|
66
66
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
67
67
|
}
|
|
68
68
|
return tagObj;
|
|
@@ -77,13 +77,13 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
|
|
|
77
77
|
anchors.add(anchor);
|
|
78
78
|
props.push(`&${anchor}`);
|
|
79
79
|
}
|
|
80
|
-
const tag = node.tag
|
|
80
|
+
const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
|
|
81
81
|
if (tag)
|
|
82
82
|
props.push(doc.directives.tagString(tag));
|
|
83
83
|
return props.join(' ');
|
|
84
84
|
}
|
|
85
85
|
function stringify(item, ctx, onComment, onChompKeep) {
|
|
86
|
-
var _a;
|
|
86
|
+
var _a, _b;
|
|
87
87
|
if (isPair(item))
|
|
88
88
|
return item.toString(ctx, onComment, onChompKeep);
|
|
89
89
|
if (isAlias(item)) {
|
|
@@ -108,7 +108,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
108
108
|
tagObj = getTagObject(ctx.doc.schema.tags, node);
|
|
109
109
|
const props = stringifyProps(node, tagObj, ctx);
|
|
110
110
|
if (props.length > 0)
|
|
111
|
-
ctx.indentAtStart = (ctx.indentAtStart
|
|
111
|
+
ctx.indentAtStart = ((_b = ctx.indentAtStart) !== null && _b !== void 0 ? _b : 0) + props.length + 1;
|
|
112
112
|
const str = typeof tagObj.stringify === 'function'
|
|
113
113
|
? tagObj.stringify(node, ctx, onComment, onChompKeep)
|
|
114
114
|
: isScalar(node)
|
|
@@ -11,8 +11,10 @@ function indentComment(comment, indent) {
|
|
|
11
11
|
return comment.substring(1);
|
|
12
12
|
return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
|
13
13
|
}
|
|
14
|
-
const lineComment = (str, indent, comment) =>
|
|
15
|
-
?
|
|
16
|
-
:
|
|
14
|
+
const lineComment = (str, indent, comment) => str.endsWith('\n')
|
|
15
|
+
? indentComment(comment, indent)
|
|
16
|
+
: comment.includes('\n')
|
|
17
|
+
? '\n' + indentComment(comment, indent)
|
|
18
|
+
: (str.endsWith(' ') ? '' : ' ') + comment;
|
|
17
19
|
|
|
18
20
|
export { indentComment, lineComment, stringifyComment };
|
|
@@ -96,7 +96,10 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
96
96
|
const valueStr = stringify(value, ctx, () => (valueCommentDone = true), () => (chompKeep = true));
|
|
97
97
|
let ws = ' ';
|
|
98
98
|
if (vcb || keyComment) {
|
|
99
|
-
|
|
99
|
+
if (valueStr === '' && !ctx.inFlow)
|
|
100
|
+
ws = vcb === '\n' ? '\n\n' : vcb;
|
|
101
|
+
else
|
|
102
|
+
ws = `${vcb}\n${ctx.indent}`;
|
|
100
103
|
}
|
|
101
104
|
else if (!explicitKey && isCollection(value)) {
|
|
102
105
|
const flow = valueStr[0] === '[' || valueStr[0] === '{';
|