projen 0.71.24 → 0.71.26
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/awscdk/auto-discover.js +5 -5
- 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-py.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-py.js +1 -1
- package/lib/cdk8s/cdk8s-app-ts.js +1 -1
- package/lib/cdk8s/cdk8s-construct.js +1 -1
- package/lib/cdk8s/cdk8s-deps-py.js +1 -1
- package/lib/cdk8s/cdk8s-deps.js +1 -1
- package/lib/cdk8s/integration-test.js +1 -1
- package/lib/cdktf/cdktf-construct.js +1 -1
- package/lib/circleci/circleci.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/docker-compose-service.js +1 -1
- package/lib/docker-compose/docker-compose.js +1 -1
- package/lib/file.js +1 -1
- package/lib/gitattributes.js +1 -1
- package/lib/github/actions-provider.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/workflow-actions.js +1 -1
- package/lib/github/workflow-jobs.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 +4 -4
- 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-patch.js +1 -1
- 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.js +1 -1
- package/lib/projects.js +1 -1
- package/lib/projenrc-json.js +2 -2
- package/lib/projenrc.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/renovatebot.js +1 -1
- package/lib/run-task.js +1 -1880
- 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-ts.js +1 -1
- package/lib/typescript/projenrc.js +1 -1
- package/lib/typescript/typescript-typedoc.js +1 -1
- package/lib/typescript/typescript.js +3 -3
- package/lib/version.js +1 -1
- package/lib/vscode/devcontainer.js +1 -1
- package/lib/vscode/extensions.js +1 -1
- package/lib/vscode/launch-config.js +1 -1
- package/lib/vscode/settings.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/xmlbuilder2/node_modules/@types/node/README.md +1 -1
- package/node_modules/xmlbuilder2/node_modules/@types/node/globals.d.ts +1 -1
- package/node_modules/xmlbuilder2/node_modules/@types/node/package.json +2 -2
- package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/v8.d.ts +94 -0
- package/node_modules/xmlbuilder2/node_modules/@types/node/v8.d.ts +94 -0
- package/node_modules/yaml/README.md +1 -1
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +1 -1
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +2 -2
- package/node_modules/yaml/browser/dist/compose/compose-node.js +4 -2
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +6 -7
- package/node_modules/yaml/browser/dist/compose/composer.js +2 -3
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +13 -10
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +1 -1
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +5 -5
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +3 -4
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +1 -2
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +6 -2
- 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 +1 -1
- package/node_modules/yaml/browser/dist/doc/Document.js +6 -6
- package/node_modules/yaml/browser/dist/doc/createNode.js +6 -8
- package/node_modules/yaml/browser/dist/errors.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/Collection.js +2 -1
- 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 +9 -10
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +4 -12
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/toJS.js +1 -1
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +1 -2
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +2 -2
- package/node_modules/yaml/browser/dist/parse/lexer.js +1 -2
- package/node_modules/yaml/browser/dist/parse/parser.js +24 -26
- package/node_modules/yaml/browser/dist/public-api.js +3 -4
- package/node_modules/yaml/browser/dist/schema/Schema.js +1 -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 -2
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +6 -1
- package/node_modules/yaml/browser/dist/stringify/stringify.js +8 -8
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +4 -5
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +1 -2
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +45 -20
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +17 -12
- package/node_modules/yaml/browser/dist/visit.js +5 -6
- package/node_modules/yaml/dist/compose/compose-collection.js +1 -1
- package/node_modules/yaml/dist/compose/compose-doc.js +2 -2
- package/node_modules/yaml/dist/compose/compose-node.d.ts +3 -2
- package/node_modules/yaml/dist/compose/compose-node.js +4 -2
- package/node_modules/yaml/dist/compose/compose-scalar.js +6 -7
- package/node_modules/yaml/dist/compose/composer.d.ts +2 -2
- package/node_modules/yaml/dist/compose/composer.js +2 -3
- package/node_modules/yaml/dist/compose/resolve-block-map.js +13 -10
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +1 -1
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +5 -5
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +3 -4
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +1 -2
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +1 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +6 -2
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +1 -1
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +1 -1
- package/node_modules/yaml/dist/doc/Document.d.ts +11 -11
- package/node_modules/yaml/dist/doc/Document.js +6 -6
- package/node_modules/yaml/dist/doc/anchors.d.ts +1 -1
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +1 -1
- package/node_modules/yaml/dist/doc/createNode.js +6 -8
- 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 +2 -0
- package/node_modules/yaml/dist/log.d.ts +1 -1
- package/node_modules/yaml/dist/nodes/Alias.d.ts +1 -1
- package/node_modules/yaml/dist/nodes/Collection.d.ts +2 -2
- package/node_modules/yaml/dist/nodes/Collection.js +2 -1
- package/node_modules/yaml/dist/nodes/Node.d.ts +17 -11
- package/node_modules/yaml/dist/nodes/Pair.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 +8 -4
- package/node_modules/yaml/dist/nodes/YAMLMap.js +9 -10
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +4 -1
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +4 -12
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +2 -1
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +1 -1
- package/node_modules/yaml/dist/nodes/toJS.js +1 -1
- package/node_modules/yaml/dist/options.d.ts +15 -7
- package/node_modules/yaml/dist/parse/cst-scalar.js +1 -2
- 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.js +1 -2
- package/node_modules/yaml/dist/parse/parser.js +24 -26
- package/node_modules/yaml/dist/public-api.js +3 -4
- package/node_modules/yaml/dist/schema/Schema.d.ts +3 -3
- package/node_modules/yaml/dist/schema/Schema.js +1 -1
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +2 -2
- package/node_modules/yaml/dist/schema/types.d.ts +1 -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 -2
- 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 +2 -1
- package/node_modules/yaml/dist/stringify/stringify.js +8 -8
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +4 -5
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +1 -2
- package/node_modules/yaml/dist/stringify/stringifyPair.js +45 -20
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +7 -1
- package/node_modules/yaml/dist/stringify/stringifyString.js +17 -12
- package/node_modules/yaml/dist/test-events.js +2 -3
- package/node_modules/yaml/dist/visit.d.ts +4 -4
- package/node_modules/yaml/dist/visit.js +5 -6
- package/node_modules/yaml/package.json +11 -11
- package/package.json +2 -2
- package/node_modules/yaml/dist/node_modules/tslib/tslib.es6.js +0 -76
|
@@ -4,8 +4,7 @@ import { stringify } from './stringify.js';
|
|
|
4
4
|
import { lineComment, indentComment } from './stringifyComment.js';
|
|
5
5
|
|
|
6
6
|
function stringifyCollection(collection, ctx, options) {
|
|
7
|
-
|
|
8
|
-
const flow = (_a = ctx.inFlow) !== null && _a !== void 0 ? _a : collection.flow;
|
|
7
|
+
const flow = ctx.inFlow ?? collection.flow;
|
|
9
8
|
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
10
9
|
return stringify(collection, ctx, options);
|
|
11
10
|
}
|
|
@@ -61,7 +60,7 @@ function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, fl
|
|
|
61
60
|
return str;
|
|
62
61
|
}
|
|
63
62
|
function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemIndent, onComment }) {
|
|
64
|
-
const { indent, indentStep, options: { commentString } } = ctx;
|
|
63
|
+
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
|
|
65
64
|
itemIndent += indentStep;
|
|
66
65
|
const itemCtx = Object.assign({}, ctx, {
|
|
67
66
|
indent: itemIndent,
|
|
@@ -130,11 +129,11 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
130
129
|
str += `\n${indent}${end}`;
|
|
131
130
|
}
|
|
132
131
|
else {
|
|
133
|
-
str = `${start}
|
|
132
|
+
str = `${start}${fcPadding}${lines.join(' ')}${fcPadding}${end}`;
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
135
|
if (comment) {
|
|
137
|
-
str += lineComment(str, commentString(comment)
|
|
136
|
+
str += lineComment(str, indent, commentString(comment));
|
|
138
137
|
if (onComment)
|
|
139
138
|
onComment();
|
|
140
139
|
}
|
|
@@ -3,7 +3,6 @@ import { createStringifyContext, stringify } from './stringify.js';
|
|
|
3
3
|
import { indentComment, lineComment } from './stringifyComment.js';
|
|
4
4
|
|
|
5
5
|
function stringifyDocument(doc, options) {
|
|
6
|
-
var _a;
|
|
7
6
|
const lines = [];
|
|
8
7
|
let hasDirectives = options.directives === true;
|
|
9
8
|
if (options.directives !== false && doc.directives) {
|
|
@@ -55,7 +54,7 @@ function stringifyDocument(doc, options) {
|
|
|
55
54
|
else {
|
|
56
55
|
lines.push(stringify(doc.contents, ctx));
|
|
57
56
|
}
|
|
58
|
-
if (
|
|
57
|
+
if (doc.directives?.docEnd) {
|
|
59
58
|
if (doc.comment) {
|
|
60
59
|
const cs = commentString(doc.comment);
|
|
61
60
|
if (cs.includes('\n')) {
|
|
@@ -63,19 +63,18 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
63
63
|
if (keyComment)
|
|
64
64
|
str += lineComment(str, ctx.indent, commentString(keyComment));
|
|
65
65
|
}
|
|
66
|
-
let vcb
|
|
67
|
-
let valueComment = null;
|
|
66
|
+
let vsb, vcb, valueComment;
|
|
68
67
|
if (isNode(value)) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (value.commentBefore) {
|
|
72
|
-
const cs = commentString(value.commentBefore);
|
|
73
|
-
vcb += `\n${indentComment(cs, ctx.indent)}`;
|
|
74
|
-
}
|
|
68
|
+
vsb = !!value.spaceBefore;
|
|
69
|
+
vcb = value.commentBefore;
|
|
75
70
|
valueComment = value.comment;
|
|
76
71
|
}
|
|
77
|
-
else
|
|
78
|
-
|
|
72
|
+
else {
|
|
73
|
+
vsb = false;
|
|
74
|
+
vcb = null;
|
|
75
|
+
valueComment = null;
|
|
76
|
+
if (value && typeof value === 'object')
|
|
77
|
+
value = doc.createNode(value);
|
|
79
78
|
}
|
|
80
79
|
ctx.implicitKey = false;
|
|
81
80
|
if (!explicitKey && !keyComment && isScalar(value))
|
|
@@ -90,24 +89,50 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
90
89
|
!value.tag &&
|
|
91
90
|
!value.anchor) {
|
|
92
91
|
// If indentSeq === false, consider '- ' as part of indentation where possible
|
|
93
|
-
ctx.indent = ctx.indent.
|
|
92
|
+
ctx.indent = ctx.indent.substring(2);
|
|
94
93
|
}
|
|
95
94
|
let valueCommentDone = false;
|
|
96
95
|
const valueStr = stringify(value, ctx, () => (valueCommentDone = true), () => (chompKeep = true));
|
|
97
96
|
let ws = ' ';
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
ws
|
|
97
|
+
if (keyComment || vsb || vcb) {
|
|
98
|
+
ws = vsb ? '\n' : '';
|
|
99
|
+
if (vcb) {
|
|
100
|
+
const cs = commentString(vcb);
|
|
101
|
+
ws += `\n${indentComment(cs, ctx.indent)}`;
|
|
102
|
+
}
|
|
103
|
+
if (valueStr === '' && !ctx.inFlow) {
|
|
104
|
+
if (ws === '\n')
|
|
105
|
+
ws = '\n\n';
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
ws += `\n${ctx.indent}`;
|
|
109
|
+
}
|
|
103
110
|
}
|
|
104
111
|
else if (!explicitKey && isCollection(value)) {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
const vs0 = valueStr[0];
|
|
113
|
+
const nl0 = valueStr.indexOf('\n');
|
|
114
|
+
const hasNewline = nl0 !== -1;
|
|
115
|
+
const flow = ctx.inFlow ?? value.flow ?? value.items.length === 0;
|
|
116
|
+
if (hasNewline || !flow) {
|
|
117
|
+
let hasPropsLine = false;
|
|
118
|
+
if (hasNewline && (vs0 === '&' || vs0 === '!')) {
|
|
119
|
+
let sp0 = valueStr.indexOf(' ');
|
|
120
|
+
if (vs0 === '&' &&
|
|
121
|
+
sp0 !== -1 &&
|
|
122
|
+
sp0 < nl0 &&
|
|
123
|
+
valueStr[sp0 + 1] === '!') {
|
|
124
|
+
sp0 = valueStr.indexOf(' ', sp0 + 1);
|
|
125
|
+
}
|
|
126
|
+
if (sp0 === -1 || nl0 < sp0)
|
|
127
|
+
hasPropsLine = true;
|
|
128
|
+
}
|
|
129
|
+
if (!hasPropsLine)
|
|
130
|
+
ws = `\n${ctx.indent}`;
|
|
131
|
+
}
|
|
108
132
|
}
|
|
109
|
-
else if (valueStr === '' || valueStr[0] === '\n')
|
|
133
|
+
else if (valueStr === '' || valueStr[0] === '\n') {
|
|
110
134
|
ws = '';
|
|
135
|
+
}
|
|
111
136
|
str += ws + valueStr;
|
|
112
137
|
if (ctx.inFlow) {
|
|
113
138
|
if (valueCommentDone && onComment)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Scalar } from '../nodes/Scalar.js';
|
|
2
2
|
import { foldFlowLines, FOLD_QUOTED, FOLD_FLOW, FOLD_BLOCK } from './foldFlowLines.js';
|
|
3
3
|
|
|
4
|
-
const getFoldOptions = (ctx) => ({
|
|
5
|
-
indentAtStart: ctx.indentAtStart,
|
|
4
|
+
const getFoldOptions = (ctx, isBlock) => ({
|
|
5
|
+
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
6
6
|
lineWidth: ctx.options.lineWidth,
|
|
7
7
|
minContentWidth: ctx.options.minContentWidth
|
|
8
8
|
});
|
|
@@ -115,7 +115,7 @@ function doubleQuotedString(value, ctx) {
|
|
|
115
115
|
str = start ? str + json.slice(start) : json;
|
|
116
116
|
return implicitKey
|
|
117
117
|
? str
|
|
118
|
-
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx));
|
|
118
|
+
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
119
119
|
}
|
|
120
120
|
function singleQuotedString(value, ctx) {
|
|
121
121
|
if (ctx.options.singleQuote === false ||
|
|
@@ -127,7 +127,7 @@ function singleQuotedString(value, ctx) {
|
|
|
127
127
|
const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
|
|
128
128
|
return ctx.implicitKey
|
|
129
129
|
? res
|
|
130
|
-
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx));
|
|
130
|
+
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx, false));
|
|
131
131
|
}
|
|
132
132
|
function quotedString(value, ctx) {
|
|
133
133
|
const { singleQuote } = ctx.options;
|
|
@@ -225,12 +225,12 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
225
225
|
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
226
226
|
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
227
227
|
.replace(/\n+/g, `$&${indent}`);
|
|
228
|
-
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx));
|
|
228
|
+
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
|
|
229
229
|
return `${header}\n${indent}${body}`;
|
|
230
230
|
}
|
|
231
231
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
232
232
|
const { type, value } = item;
|
|
233
|
-
const { actualString, implicitKey, indent, inFlow } = ctx;
|
|
233
|
+
const { actualString, implicitKey, indent, indentStep, inFlow } = ctx;
|
|
234
234
|
if ((implicitKey && /[\n[\]{},]/.test(value)) ||
|
|
235
235
|
(inFlow && /[[\]{},]/.test(value))) {
|
|
236
236
|
return quotedString(value, ctx);
|
|
@@ -254,23 +254,28 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
254
254
|
// Where allowed & type not set explicitly, prefer block style for multiline strings
|
|
255
255
|
return blockString(item, ctx, onComment, onChompKeep);
|
|
256
256
|
}
|
|
257
|
-
if (
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
if (containsDocumentMarker(value)) {
|
|
258
|
+
if (indent === '') {
|
|
259
|
+
ctx.forceBlockIndent = true;
|
|
260
|
+
return blockString(item, ctx, onComment, onChompKeep);
|
|
261
|
+
}
|
|
262
|
+
else if (implicitKey && indent === indentStep) {
|
|
263
|
+
return quotedString(value, ctx);
|
|
264
|
+
}
|
|
260
265
|
}
|
|
261
266
|
const str = value.replace(/\n+/g, `$&\n${indent}`);
|
|
262
267
|
// Verify that output will be parsed as a string, as e.g. plain numbers and
|
|
263
268
|
// booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
|
|
264
269
|
// and others in v1.1.
|
|
265
270
|
if (actualString) {
|
|
266
|
-
const test = (tag) =>
|
|
271
|
+
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && tag.test?.test(str);
|
|
267
272
|
const { compat, tags } = ctx.doc.schema;
|
|
268
|
-
if (tags.some(test) ||
|
|
273
|
+
if (tags.some(test) || compat?.some(test))
|
|
269
274
|
return quotedString(value, ctx);
|
|
270
275
|
}
|
|
271
276
|
return implicitKey
|
|
272
277
|
? str
|
|
273
|
-
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx));
|
|
278
|
+
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx, false));
|
|
274
279
|
}
|
|
275
280
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
276
281
|
const { implicitKey, inFlow } = ctx;
|
|
@@ -196,19 +196,18 @@ function initVisitor(visitor) {
|
|
|
196
196
|
return visitor;
|
|
197
197
|
}
|
|
198
198
|
function callVisitor(key, node, visitor, path) {
|
|
199
|
-
var _a, _b, _c, _d, _e;
|
|
200
199
|
if (typeof visitor === 'function')
|
|
201
200
|
return visitor(key, node, path);
|
|
202
201
|
if (isMap(node))
|
|
203
|
-
return
|
|
202
|
+
return visitor.Map?.(key, node, path);
|
|
204
203
|
if (isSeq(node))
|
|
205
|
-
return
|
|
204
|
+
return visitor.Seq?.(key, node, path);
|
|
206
205
|
if (isPair(node))
|
|
207
|
-
return
|
|
206
|
+
return visitor.Pair?.(key, node, path);
|
|
208
207
|
if (isScalar(node))
|
|
209
|
-
return
|
|
208
|
+
return visitor.Scalar?.(key, node, path);
|
|
210
209
|
if (isAlias(node))
|
|
211
|
-
return
|
|
210
|
+
return visitor.Alias?.(key, node, path);
|
|
212
211
|
return undefined;
|
|
213
212
|
}
|
|
214
213
|
function replaceNode(key, path, node) {
|
|
@@ -53,7 +53,7 @@ function composeCollection(CN, ctx, token, tagToken, onError) {
|
|
|
53
53
|
: new Scalar.Scalar(res);
|
|
54
54
|
node.range = coll.range;
|
|
55
55
|
node.tag = tagName;
|
|
56
|
-
if (tag
|
|
56
|
+
if (tag?.format)
|
|
57
57
|
node.format = tag.format;
|
|
58
58
|
return node;
|
|
59
59
|
}
|
|
@@ -6,7 +6,7 @@ var resolveEnd = require('./resolve-end.js');
|
|
|
6
6
|
var resolveProps = require('./resolve-props.js');
|
|
7
7
|
|
|
8
8
|
function composeDoc(options, directives, { offset, start, value, end }, onError) {
|
|
9
|
-
const opts = Object.assign({ directives }, options);
|
|
9
|
+
const opts = Object.assign({ _directives: directives }, options);
|
|
10
10
|
const doc = new Document.Document(undefined, opts);
|
|
11
11
|
const ctx = {
|
|
12
12
|
atRoot: true,
|
|
@@ -16,7 +16,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
|
|
|
16
16
|
};
|
|
17
17
|
const props = resolveProps.resolveProps(start, {
|
|
18
18
|
indicator: 'doc-start',
|
|
19
|
-
next: value
|
|
19
|
+
next: value ?? end?.[0],
|
|
20
20
|
offset,
|
|
21
21
|
onError,
|
|
22
22
|
startOnNewline: true
|
|
@@ -15,12 +15,13 @@ interface Props {
|
|
|
15
15
|
comment: string;
|
|
16
16
|
anchor: SourceToken | null;
|
|
17
17
|
tag: SourceToken | null;
|
|
18
|
+
end: number;
|
|
18
19
|
}
|
|
19
20
|
declare const CN: {
|
|
20
21
|
composeNode: typeof composeNode;
|
|
21
22
|
composeEmptyNode: typeof composeEmptyNode;
|
|
22
23
|
};
|
|
23
|
-
export
|
|
24
|
+
export type ComposeNode = typeof CN;
|
|
24
25
|
export declare function composeNode(ctx: ComposeContext, token: Token, props: Props, onError: ComposeErrorHandler): ParsedNode;
|
|
25
|
-
export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag }: Props, onError: ComposeErrorHandler): import("../index.js").Scalar.Parsed;
|
|
26
|
+
export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag, end }: Props, onError: ComposeErrorHandler): import("../index.js").Scalar.Parsed;
|
|
26
27
|
export {};
|
|
@@ -56,7 +56,7 @@ function composeNode(ctx, token, props, onError) {
|
|
|
56
56
|
node.srcToken = token;
|
|
57
57
|
return node;
|
|
58
58
|
}
|
|
59
|
-
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
59
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
60
60
|
const token = {
|
|
61
61
|
type: 'scalar',
|
|
62
62
|
offset: utilEmptyScalarPosition.emptyScalarPosition(offset, before, pos),
|
|
@@ -71,8 +71,10 @@ function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anch
|
|
|
71
71
|
}
|
|
72
72
|
if (spaceBefore)
|
|
73
73
|
node.spaceBefore = true;
|
|
74
|
-
if (comment)
|
|
74
|
+
if (comment) {
|
|
75
75
|
node.comment = comment;
|
|
76
|
+
node.range[2] = end;
|
|
77
|
+
}
|
|
76
78
|
return node;
|
|
77
79
|
}
|
|
78
80
|
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
@@ -19,12 +19,12 @@ function composeScalar(ctx, token, tagToken, onError) {
|
|
|
19
19
|
: ctx.schema[Node.SCALAR];
|
|
20
20
|
let scalar;
|
|
21
21
|
try {
|
|
22
|
-
const res = tag.resolve(value, msg => onError(tagToken
|
|
22
|
+
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
23
23
|
scalar = Node.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
24
24
|
}
|
|
25
25
|
catch (error) {
|
|
26
26
|
const msg = error instanceof Error ? error.message : String(error);
|
|
27
|
-
onError(tagToken
|
|
27
|
+
onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg);
|
|
28
28
|
scalar = new Scalar.Scalar(value);
|
|
29
29
|
}
|
|
30
30
|
scalar.range = range;
|
|
@@ -40,7 +40,6 @@ function composeScalar(ctx, token, tagToken, onError) {
|
|
|
40
40
|
return scalar;
|
|
41
41
|
}
|
|
42
42
|
function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
43
|
-
var _a;
|
|
44
43
|
if (tagName === '!')
|
|
45
44
|
return schema[Node.SCALAR]; // non-specific tag
|
|
46
45
|
const matchWithTest = [];
|
|
@@ -53,7 +52,7 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
for (const tag of matchWithTest)
|
|
56
|
-
if (
|
|
55
|
+
if (tag.test?.test(value))
|
|
57
56
|
return tag;
|
|
58
57
|
const kt = schema.knownTags[tagName];
|
|
59
58
|
if (kt && !kt.collection) {
|
|
@@ -66,10 +65,10 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
66
65
|
return schema[Node.SCALAR];
|
|
67
66
|
}
|
|
68
67
|
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
69
|
-
|
|
70
|
-
const tag = schema.tags.find(tag => { var _a; return tag.default && ((_a = tag.test) === null || _a === void 0 ? void 0 : _a.test(value)); }) || schema[Node.SCALAR];
|
|
68
|
+
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[Node.SCALAR];
|
|
71
69
|
if (schema.compat) {
|
|
72
|
-
const compat =
|
|
70
|
+
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
71
|
+
schema[Node.SCALAR];
|
|
73
72
|
if (tag.tag !== compat.tag) {
|
|
74
73
|
const ts = directives.tagString(tag.tag);
|
|
75
74
|
const cs = directives.tagString(compat.tag);
|
|
@@ -4,11 +4,11 @@ import { ErrorCode, YAMLParseError, YAMLWarning } from '../errors.js';
|
|
|
4
4
|
import { Range } from '../nodes/Node.js';
|
|
5
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
|
*
|
|
@@ -16,7 +16,6 @@ function getErrorPos(src) {
|
|
|
16
16
|
return [offset, offset + (typeof source === 'string' ? source.length : 1)];
|
|
17
17
|
}
|
|
18
18
|
function parsePrelude(prelude) {
|
|
19
|
-
var _a;
|
|
20
19
|
let comment = '';
|
|
21
20
|
let atComment = false;
|
|
22
21
|
let afterEmptyLine = false;
|
|
@@ -31,7 +30,7 @@ function parsePrelude(prelude) {
|
|
|
31
30
|
afterEmptyLine = false;
|
|
32
31
|
break;
|
|
33
32
|
case '%':
|
|
34
|
-
if (
|
|
33
|
+
if (prelude[i + 1]?.[0] !== '#')
|
|
35
34
|
i += 1;
|
|
36
35
|
atComment = false;
|
|
37
36
|
break;
|
|
@@ -208,7 +207,7 @@ class Composer {
|
|
|
208
207
|
this.doc = null;
|
|
209
208
|
}
|
|
210
209
|
else if (forceDoc) {
|
|
211
|
-
const opts = Object.assign({
|
|
210
|
+
const opts = Object.assign({ _directives: this.directives }, this.options);
|
|
212
211
|
const doc = new Document.Document(undefined, opts);
|
|
213
212
|
if (this.atDirectives)
|
|
214
213
|
this.onError(endOffset, 'MISSING_CHAR', 'Missing directives-end indicator line');
|
|
@@ -9,17 +9,17 @@ var utilMapIncludes = require('./util-map-includes.js');
|
|
|
9
9
|
|
|
10
10
|
const startColMsg = 'All mapping items must start at the same column';
|
|
11
11
|
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
12
|
-
var _a;
|
|
13
12
|
const map = new YAMLMap.YAMLMap(ctx.schema);
|
|
14
13
|
if (ctx.atRoot)
|
|
15
14
|
ctx.atRoot = false;
|
|
16
15
|
let offset = bm.offset;
|
|
16
|
+
let commentEnd = null;
|
|
17
17
|
for (const collItem of bm.items) {
|
|
18
18
|
const { start, key, sep, value } = collItem;
|
|
19
19
|
// key properties
|
|
20
20
|
const keyProps = resolveProps.resolveProps(start, {
|
|
21
21
|
indicator: 'explicit-key-ind',
|
|
22
|
-
next: key
|
|
22
|
+
next: key ?? sep?.[0],
|
|
23
23
|
offset,
|
|
24
24
|
onError,
|
|
25
25
|
startOnNewline: true
|
|
@@ -33,7 +33,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
33
33
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
34
34
|
}
|
|
35
35
|
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
36
|
-
|
|
36
|
+
commentEnd = keyProps.end;
|
|
37
37
|
if (keyProps.comment) {
|
|
38
38
|
if (map.comment)
|
|
39
39
|
map.comment += '\n' + keyProps.comment;
|
|
@@ -42,12 +42,13 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
42
42
|
}
|
|
43
43
|
continue;
|
|
44
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
|
+
}
|
|
45
48
|
}
|
|
46
|
-
else if (
|
|
49
|
+
else if (keyProps.found?.indent !== bm.indent) {
|
|
47
50
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
48
|
-
|
|
49
|
-
onError(key, // checked by containsNewline()
|
|
50
|
-
'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
|
51
|
+
}
|
|
51
52
|
// key value
|
|
52
53
|
const keyStart = keyProps.end;
|
|
53
54
|
const keyNode = key
|
|
@@ -58,7 +59,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
58
59
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
59
60
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
60
61
|
// value properties
|
|
61
|
-
const valueProps = resolveProps.resolveProps(sep
|
|
62
|
+
const valueProps = resolveProps.resolveProps(sep ?? [], {
|
|
62
63
|
indicator: 'map-value-ind',
|
|
63
64
|
next: value,
|
|
64
65
|
offset: keyNode.range[2],
|
|
@@ -68,7 +69,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
68
69
|
offset = valueProps.end;
|
|
69
70
|
if (valueProps.found) {
|
|
70
71
|
if (implicitKey) {
|
|
71
|
-
if (
|
|
72
|
+
if (value?.type === 'block-map' && !valueProps.hasNewline)
|
|
72
73
|
onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'Nested mappings are not allowed in compact mappings');
|
|
73
74
|
if (ctx.options.strict &&
|
|
74
75
|
keyProps.start < valueProps.found.offset - 1024)
|
|
@@ -102,7 +103,9 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
102
103
|
map.items.push(pair);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
if (commentEnd && commentEnd < offset)
|
|
107
|
+
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content');
|
|
108
|
+
map.range = [bm.offset, offset, commentEnd ?? offset];
|
|
106
109
|
return map;
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -184,7 +184,7 @@ function splitLines(source) {
|
|
|
184
184
|
const split = source.split(/\n( *)/);
|
|
185
185
|
const first = split[0];
|
|
186
186
|
const m = first.match(/^( *)/);
|
|
187
|
-
const line0 =
|
|
187
|
+
const line0 = m?.[1]
|
|
188
188
|
? [m[1], first.slice(m[1].length)]
|
|
189
189
|
: ['', first];
|
|
190
190
|
const lines = [line0];
|
|
@@ -9,6 +9,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
9
9
|
if (ctx.atRoot)
|
|
10
10
|
ctx.atRoot = false;
|
|
11
11
|
let offset = bs.offset;
|
|
12
|
+
let commentEnd = null;
|
|
12
13
|
for (const { start, value } of bs.items) {
|
|
13
14
|
const props = resolveProps.resolveProps(start, {
|
|
14
15
|
indicator: 'seq-item-ind',
|
|
@@ -17,16 +18,15 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
17
18
|
onError,
|
|
18
19
|
startOnNewline: true
|
|
19
20
|
});
|
|
20
|
-
offset = props.end;
|
|
21
21
|
if (!props.found) {
|
|
22
22
|
if (props.anchor || props.tag || value) {
|
|
23
23
|
if (value && value.type === 'block-seq')
|
|
24
|
-
onError(
|
|
24
|
+
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
25
25
|
else
|
|
26
26
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
|
|
29
|
+
commentEnd = props.end;
|
|
30
30
|
if (props.comment)
|
|
31
31
|
seq.comment = props.comment;
|
|
32
32
|
continue;
|
|
@@ -34,13 +34,13 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
34
34
|
}
|
|
35
35
|
const node = value
|
|
36
36
|
? composeNode(ctx, value, props, onError)
|
|
37
|
-
: composeEmptyNode(ctx,
|
|
37
|
+
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
38
38
|
if (ctx.schema.compat)
|
|
39
39
|
utilFlowIndentCheck.flowIndentCheck(bs.indent, value, onError);
|
|
40
40
|
offset = node.range[2];
|
|
41
41
|
seq.items.push(node);
|
|
42
42
|
}
|
|
43
|
-
seq.range = [bs.offset, offset, offset];
|
|
43
|
+
seq.range = [bs.offset, offset, commentEnd ?? offset];
|
|
44
44
|
return seq;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -12,7 +12,6 @@ var utilMapIncludes = require('./util-map-includes.js');
|
|
|
12
12
|
const blockMsg = 'Block collections are not allowed within flow collections';
|
|
13
13
|
const isBlock = (token) => token && (token.type === 'block-map' || token.type === 'block-seq');
|
|
14
14
|
function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError) {
|
|
15
|
-
var _a;
|
|
16
15
|
const isMap = fc.start.source === '{';
|
|
17
16
|
const fcName = isMap ? 'flow map' : 'flow sequence';
|
|
18
17
|
const coll = isMap
|
|
@@ -29,7 +28,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
29
28
|
const props = resolveProps.resolveProps(start, {
|
|
30
29
|
flow: fcName,
|
|
31
30
|
indicator: 'explicit-key-ind',
|
|
32
|
-
next: key
|
|
31
|
+
next: key ?? sep?.[0],
|
|
33
32
|
offset,
|
|
34
33
|
onError,
|
|
35
34
|
startOnNewline: false
|
|
@@ -77,7 +76,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
77
76
|
if (prevItemComment) {
|
|
78
77
|
let prev = coll.items[coll.items.length - 1];
|
|
79
78
|
if (Node.isPair(prev))
|
|
80
|
-
prev =
|
|
79
|
+
prev = prev.value ?? prev.key;
|
|
81
80
|
if (prev.comment)
|
|
82
81
|
prev.comment += '\n' + prevItemComment;
|
|
83
82
|
else
|
|
@@ -107,7 +106,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
107
106
|
if (isBlock(key))
|
|
108
107
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
109
108
|
// value properties
|
|
110
|
-
const valueProps = resolveProps.resolveProps(sep
|
|
109
|
+
const valueProps = resolveProps.resolveProps(sep ?? [], {
|
|
111
110
|
flow: fcName,
|
|
112
111
|
indicator: 'map-value-ind',
|
|
113
112
|
next: value,
|
|
@@ -74,7 +74,6 @@ function singleQuotedValue(source, onError) {
|
|
|
74
74
|
return foldLines(source.slice(1, -1)).replace(/''/g, "'");
|
|
75
75
|
}
|
|
76
76
|
function foldLines(source) {
|
|
77
|
-
var _a;
|
|
78
77
|
/**
|
|
79
78
|
* The negative lookbehind here and in the `re` RegExp is to
|
|
80
79
|
* prevent causing a polynomial search time in certain cases.
|
|
@@ -114,7 +113,7 @@ function foldLines(source) {
|
|
|
114
113
|
const last = /[ \t]*(.*)/sy;
|
|
115
114
|
last.lastIndex = pos;
|
|
116
115
|
match = last.exec(source);
|
|
117
|
-
return res + sep + (
|
|
116
|
+
return res + sep + (match?.[1] ?? '');
|
|
118
117
|
}
|
|
119
118
|
function doubleQuotedValue(source, onError) {
|
|
120
119
|
let res = '';
|
|
@@ -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,6 +57,8 @@ 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':
|
|
@@ -86,7 +89,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
86
89
|
if (anchor || tag)
|
|
87
90
|
onError(token, 'BAD_PROP_ORDER', `Anchors and tags must be after the ${token.source} indicator`);
|
|
88
91
|
if (found)
|
|
89
|
-
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow
|
|
92
|
+
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow ?? 'collection'}`);
|
|
90
93
|
found = token;
|
|
91
94
|
atNewline = false;
|
|
92
95
|
hasSpace = false;
|
|
@@ -122,10 +125,11 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
122
125
|
spaceBefore,
|
|
123
126
|
comment,
|
|
124
127
|
hasNewline,
|
|
128
|
+
hasNewlineAfterProp,
|
|
125
129
|
anchor,
|
|
126
130
|
tag,
|
|
127
131
|
end,
|
|
128
|
-
start: start
|
|
132
|
+
start: start ?? end
|
|
129
133
|
};
|
|
130
134
|
}
|
|
131
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
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var utilContainsNewline = require('./util-contains-newline.js');
|
|
4
4
|
|
|
5
5
|
function flowIndentCheck(indent, fc, onError) {
|
|
6
|
-
if (
|
|
6
|
+
if (fc?.type === 'flow-collection') {
|
|
7
7
|
const end = fc.end[0];
|
|
8
8
|
if (end.indent === indent &&
|
|
9
9
|
(end.source === ']' || end.source === '}') &&
|