projen 0.54.57 → 0.55.1
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 +6 -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/xmlbuilder2/node_modules/@types/node/README.md +1 -1
- package/node_modules/xmlbuilder2/node_modules/@types/node/diagnostics_channel.d.ts +18 -0
- package/node_modules/xmlbuilder2/node_modules/@types/node/package.json +2 -2
- 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 +2 -2
- 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 +1 -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 +50 -14
- 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 +2 -2
- 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 +1 -1
- package/node_modules/yaml/dist/compose/resolve-props.js +1 -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 +50 -14
- 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 +4 -4
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
|
@@ -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 !== null && tagToken !== void 0 ? 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 !== null && tagToken !== void 0 ? tagToken : token, 'TAG_RESOLVE_FAILED', msg);
|
|
28
28
|
scalar = new Scalar.Scalar(value);
|
|
29
29
|
}
|
|
30
30
|
scalar.range = range;
|
|
@@ -66,10 +66,10 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
66
66
|
return schema[Node.SCALAR];
|
|
67
67
|
}
|
|
68
68
|
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
69
|
+
var _a;
|
|
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];
|
|
70
71
|
if (schema.compat) {
|
|
71
|
-
const compat = schema.compat.find(tag => { var _a; return tag.default && ((_a = tag.test) === null || _a === void 0 ? void 0 : _a.test(value)); })
|
|
72
|
-
schema[Node.SCALAR];
|
|
72
|
+
const compat = (_a = schema.compat.find(tag => { var _a; return tag.default && ((_a = tag.test) === null || _a === void 0 ? void 0 : _a.test(value)); })) !== null && _a !== void 0 ? _a : schema[Node.SCALAR];
|
|
73
73
|
if (tag.tag !== compat.tag) {
|
|
74
74
|
const ts = directives.tagString(tag.tag);
|
|
75
75
|
const cs = directives.tagString(compat.tag);
|
|
@@ -69,6 +69,7 @@ class Composer {
|
|
|
69
69
|
else
|
|
70
70
|
this.errors.push(new errors.YAMLParseError(pos, code, message));
|
|
71
71
|
};
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
72
73
|
this.directives = new directives.Directives({ version: options.version || '1.2' });
|
|
73
74
|
this.options = options;
|
|
74
75
|
}
|
|
@@ -19,7 +19,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
19
19
|
// key properties
|
|
20
20
|
const keyProps = resolveProps.resolveProps(start, {
|
|
21
21
|
indicator: 'explicit-key-ind',
|
|
22
|
-
next: key
|
|
22
|
+
next: key !== null && key !== void 0 ? key : sep === null || sep === void 0 ? void 0 : sep[0],
|
|
23
23
|
offset,
|
|
24
24
|
onError,
|
|
25
25
|
startOnNewline: true
|
|
@@ -58,7 +58,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
58
58
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
59
59
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
60
60
|
// value properties
|
|
61
|
-
const valueProps = resolveProps.resolveProps(sep
|
|
61
|
+
const valueProps = resolveProps.resolveProps(sep !== null && sep !== void 0 ? sep : [], {
|
|
62
62
|
indicator: 'map-value-ind',
|
|
63
63
|
next: value,
|
|
64
64
|
offset: keyNode.range[2],
|
|
@@ -184,7 +184,9 @@ 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 = m
|
|
187
|
+
const line0 = (m === null || m === void 0 ? void 0 : m[1])
|
|
188
|
+
? [m[1], first.slice(m[1].length)]
|
|
189
|
+
: ['', first];
|
|
188
190
|
const lines = [line0];
|
|
189
191
|
for (let i = 1; i < split.length; i += 2)
|
|
190
192
|
lines.push([split[i], split[i + 1]]);
|
|
@@ -12,6 +12,7 @@ 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;
|
|
15
16
|
const isMap = fc.start.source === '{';
|
|
16
17
|
const fcName = isMap ? 'flow map' : 'flow sequence';
|
|
17
18
|
const coll = isMap
|
|
@@ -28,7 +29,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
28
29
|
const props = resolveProps.resolveProps(start, {
|
|
29
30
|
flow: fcName,
|
|
30
31
|
indicator: 'explicit-key-ind',
|
|
31
|
-
next: key
|
|
32
|
+
next: key !== null && key !== void 0 ? key : sep === null || sep === void 0 ? void 0 : sep[0],
|
|
32
33
|
offset,
|
|
33
34
|
onError,
|
|
34
35
|
startOnNewline: false
|
|
@@ -76,7 +77,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
76
77
|
if (prevItemComment) {
|
|
77
78
|
let prev = coll.items[coll.items.length - 1];
|
|
78
79
|
if (Node.isPair(prev))
|
|
79
|
-
prev = prev.value
|
|
80
|
+
prev = (_a = prev.value) !== null && _a !== void 0 ? _a : prev.key;
|
|
80
81
|
if (prev.comment)
|
|
81
82
|
prev.comment += '\n' + prevItemComment;
|
|
82
83
|
else
|
|
@@ -106,7 +107,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
106
107
|
if (isBlock(key))
|
|
107
108
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
108
109
|
// value properties
|
|
109
|
-
const valueProps = resolveProps.resolveProps(sep
|
|
110
|
+
const valueProps = resolveProps.resolveProps(sep !== null && sep !== void 0 ? sep : [], {
|
|
110
111
|
flow: fcName,
|
|
111
112
|
indicator: 'map-value-ind',
|
|
112
113
|
next: value,
|
|
@@ -74,6 +74,7 @@ function singleQuotedValue(source, onError) {
|
|
|
74
74
|
return foldLines(source.slice(1, -1)).replace(/''/g, "'");
|
|
75
75
|
}
|
|
76
76
|
function foldLines(source) {
|
|
77
|
+
var _a;
|
|
77
78
|
/**
|
|
78
79
|
* The negative lookbehind here and in the `re` RegExp is to
|
|
79
80
|
* prevent causing a polynomial search time in certain cases.
|
|
@@ -113,7 +114,7 @@ function foldLines(source) {
|
|
|
113
114
|
const last = /[ \t]*(.*)/sy;
|
|
114
115
|
last.lastIndex = pos;
|
|
115
116
|
match = last.exec(source);
|
|
116
|
-
return res + sep + ((match
|
|
117
|
+
return res + sep + ((_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : '');
|
|
117
118
|
}
|
|
118
119
|
function doubleQuotedValue(source, onError) {
|
|
119
120
|
let res = '';
|
|
@@ -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;
|
|
@@ -86,7 +86,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
|
|
|
86
86
|
if (anchor || tag)
|
|
87
87
|
onError(token, 'BAD_PROP_ORDER', `Anchors and tags must be after the ${token.source} indicator`);
|
|
88
88
|
if (found)
|
|
89
|
-
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow
|
|
89
|
+
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow !== null && flow !== void 0 ? flow : 'collection'}`);
|
|
90
90
|
found = token;
|
|
91
91
|
atNewline = false;
|
|
92
92
|
hasSpace = false;
|
|
@@ -122,7 +122,7 @@ export declare class Document<T = unknown> {
|
|
|
122
122
|
*
|
|
123
123
|
* Overrides all previously set schema options.
|
|
124
124
|
*/
|
|
125
|
-
setSchema(version: '1.1' | '1.2' | null, options?: SchemaOptions): void;
|
|
125
|
+
setSchema(version: '1.1' | '1.2' | 'next' | null, options?: SchemaOptions): void;
|
|
126
126
|
/** A plain JavaScript representation of the document `contents`. */
|
|
127
127
|
toJS(opt?: ToJSOptions & {
|
|
128
128
|
[ignored: string]: unknown;
|
|
@@ -104,6 +104,7 @@ class Document {
|
|
|
104
104
|
if (!node.anchor) {
|
|
105
105
|
const prev = anchors.anchorNames(this);
|
|
106
106
|
node.anchor =
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
107
108
|
!name || prev.has(name) ? anchors.findNewAnchor(name || 'a', prev) : name;
|
|
108
109
|
}
|
|
109
110
|
return new Alias.Alias(node.anchor);
|
|
@@ -125,8 +126,10 @@ class Document {
|
|
|
125
126
|
options = replacer;
|
|
126
127
|
replacer = undefined;
|
|
127
128
|
}
|
|
128
|
-
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options
|
|
129
|
-
const { onAnchor, setAnchors, sourceObjects } = anchors.createNodeAnchors(this,
|
|
129
|
+
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options !== null && options !== void 0 ? options : {};
|
|
130
|
+
const { onAnchor, setAnchors, sourceObjects } = anchors.createNodeAnchors(this,
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
132
|
+
anchorPrefix || 'a');
|
|
130
133
|
const ctx = {
|
|
131
134
|
aliasDuplicateObjects: aliasDuplicateObjects !== null && aliasDuplicateObjects !== void 0 ? aliasDuplicateObjects : true,
|
|
132
135
|
keepUndefined: keepUndefined !== null && keepUndefined !== void 0 ? keepUndefined : false,
|
|
@@ -257,10 +260,11 @@ class Document {
|
|
|
257
260
|
opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
258
261
|
break;
|
|
259
262
|
case '1.2':
|
|
263
|
+
case 'next':
|
|
260
264
|
if (this.directives)
|
|
261
|
-
this.directives.yaml.version =
|
|
265
|
+
this.directives.yaml.version = version;
|
|
262
266
|
else
|
|
263
|
-
this.directives = new directives.Directives({ version
|
|
267
|
+
this.directives = new directives.Directives({ version });
|
|
264
268
|
opt = { merge: false, resolveKnownTags: true, schema: 'core' };
|
|
265
269
|
break;
|
|
266
270
|
case null:
|
|
@@ -292,7 +296,7 @@ class Document {
|
|
|
292
296
|
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100,
|
|
293
297
|
stringify: stringify.stringify
|
|
294
298
|
};
|
|
295
|
-
const res = toJS.toJS(this.contents, jsonArg
|
|
299
|
+
const res = toJS.toJS(this.contents, jsonArg !== null && jsonArg !== void 0 ? jsonArg : '', ctx);
|
|
296
300
|
if (typeof onAnchor === 'function')
|
|
297
301
|
for (const { count, res } of ctx.anchors.values())
|
|
298
302
|
onAnchor(res, count);
|
|
@@ -10,13 +10,13 @@ export declare function anchorNames(root: Document | Node): Set<string>;
|
|
|
10
10
|
/** Find a new anchor name with the given `prefix` and a one-indexed suffix. */
|
|
11
11
|
export declare function findNewAnchor(prefix: string, exclude: Set<string>): string;
|
|
12
12
|
export declare function createNodeAnchors(doc: Document, prefix: string): {
|
|
13
|
-
onAnchor(source: unknown)
|
|
13
|
+
onAnchor: (source: unknown) => string;
|
|
14
14
|
/**
|
|
15
15
|
* With circular references, the source node is only resolved after all
|
|
16
16
|
* of its child nodes are. This is why anchors are set only after all of
|
|
17
17
|
* the nodes have been created.
|
|
18
18
|
*/
|
|
19
|
-
setAnchors()
|
|
19
|
+
setAnchors: () => void;
|
|
20
20
|
sourceObjects: Map<unknown, {
|
|
21
21
|
anchor: string | null;
|
|
22
22
|
node: Node | null;
|
|
@@ -39,7 +39,7 @@ function createNodeAnchors(doc, prefix) {
|
|
|
39
39
|
const sourceObjects = new Map();
|
|
40
40
|
let prevAnchors = null;
|
|
41
41
|
return {
|
|
42
|
-
onAnchor(source) {
|
|
42
|
+
onAnchor: (source) => {
|
|
43
43
|
aliasObjects.push(source);
|
|
44
44
|
if (!prevAnchors)
|
|
45
45
|
prevAnchors = anchorNames(doc);
|
|
@@ -52,7 +52,7 @@ function createNodeAnchors(doc, prefix) {
|
|
|
52
52
|
* of its child nodes are. This is why anchors are set only after all of
|
|
53
53
|
* the nodes have been created.
|
|
54
54
|
*/
|
|
55
|
-
setAnchors() {
|
|
55
|
+
setAnchors: () => {
|
|
56
56
|
for (const source of aliasObjects) {
|
|
57
57
|
const ref = sourceObjects.get(source);
|
|
58
58
|
if (typeof ref === 'object' &&
|
|
@@ -5,7 +5,7 @@ import type { Replacer } from './Document.js';
|
|
|
5
5
|
export interface CreateNodeContext {
|
|
6
6
|
aliasDuplicateObjects: boolean;
|
|
7
7
|
keepUndefined: boolean;
|
|
8
|
-
onAnchor(source: unknown)
|
|
8
|
+
onAnchor: (source: unknown) => string;
|
|
9
9
|
onTagObj?: (tagObj: ScalarTag | CollectionTag) => void;
|
|
10
10
|
sourceObjects: Map<unknown, {
|
|
11
11
|
anchor: string | null;
|
|
@@ -6,14 +6,15 @@ var Scalar = require('../nodes/Scalar.js');
|
|
|
6
6
|
|
|
7
7
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
8
8
|
function findTagObject(value, tagName, tags) {
|
|
9
|
+
var _a;
|
|
9
10
|
if (tagName) {
|
|
10
11
|
const match = tags.filter(t => t.tag === tagName);
|
|
11
|
-
const tagObj = match.find(t => !t.format)
|
|
12
|
+
const tagObj = (_a = match.find(t => !t.format)) !== null && _a !== void 0 ? _a : match[0];
|
|
12
13
|
if (!tagObj)
|
|
13
14
|
throw new Error(`Tag ${tagName} not found`);
|
|
14
15
|
return tagObj;
|
|
15
16
|
}
|
|
16
|
-
return tags.find(t => t.identify
|
|
17
|
+
return tags.find(t => { var _a; return ((_a = t.identify) === null || _a === void 0 ? void 0 : _a.call(t, value)) && !t.format; });
|
|
17
18
|
}
|
|
18
19
|
function createNode(value, tagName, ctx) {
|
|
19
20
|
var _a, _b;
|
|
@@ -50,12 +51,14 @@ function createNode(value, tagName, ctx) {
|
|
|
50
51
|
sourceObjects.set(value, ref);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
|
-
if (tagName
|
|
54
|
+
if (tagName === null || tagName === void 0 ? void 0 : tagName.startsWith('!!'))
|
|
54
55
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
55
56
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
56
57
|
if (!tagObj) {
|
|
57
|
-
if (value && typeof value.toJSON === 'function')
|
|
58
|
+
if (value && typeof value.toJSON === 'function') {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
58
60
|
value = value.toJSON();
|
|
61
|
+
}
|
|
59
62
|
if (!value || typeof value !== 'object') {
|
|
60
63
|
const node = new Scalar.Scalar(value);
|
|
61
64
|
if (ref)
|
|
@@ -25,11 +25,11 @@ class Pair {
|
|
|
25
25
|
return new Pair(key, value);
|
|
26
26
|
}
|
|
27
27
|
toJSON(_, ctx) {
|
|
28
|
-
const pair = ctx
|
|
28
|
+
const pair = (ctx === null || ctx === void 0 ? void 0 : ctx.mapAsMap) ? new Map() : {};
|
|
29
29
|
return addPairToJSMap.addPairToJSMap(ctx, pair, this);
|
|
30
30
|
}
|
|
31
31
|
toString(ctx, onComment, onChompKeep) {
|
|
32
|
-
return ctx
|
|
32
|
+
return (ctx === null || ctx === void 0 ? void 0 : ctx.doc)
|
|
33
33
|
? stringifyPair.stringifyPair(this, ctx, onComment, onChompKeep)
|
|
34
34
|
: JSON.stringify(this);
|
|
35
35
|
}
|
|
@@ -10,7 +10,7 @@ class Scalar extends Node.NodeBase {
|
|
|
10
10
|
this.value = value;
|
|
11
11
|
}
|
|
12
12
|
toJSON(arg, ctx) {
|
|
13
|
-
return ctx
|
|
13
|
+
return (ctx === null || ctx === void 0 ? void 0 : ctx.keep) ? this.value : toJS.toJS(this.value, arg, ctx);
|
|
14
14
|
}
|
|
15
15
|
toString() {
|
|
16
16
|
return String(this.value);
|
|
@@ -36,6 +36,8 @@ export declare class YAMLMap<K = unknown, V = unknown> extends Collection {
|
|
|
36
36
|
* @param {Class} Type - If set, forces the returned collection type
|
|
37
37
|
* @returns Instance of Type, Map, or Object
|
|
38
38
|
*/
|
|
39
|
-
toJSON(_?: unknown, ctx?: ToJSContext, Type?:
|
|
39
|
+
toJSON<T = unknown>(_?: unknown, ctx?: ToJSContext, Type?: {
|
|
40
|
+
new (): T;
|
|
41
|
+
}): any;
|
|
40
42
|
toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
|
41
43
|
}
|
|
@@ -34,6 +34,7 @@ class YAMLMap extends Collection.Collection {
|
|
|
34
34
|
* collection will throw. Otherwise, overwrites the previous value.
|
|
35
35
|
*/
|
|
36
36
|
add(pair, overwrite) {
|
|
37
|
+
var _a;
|
|
37
38
|
let _pair;
|
|
38
39
|
if (Node.isPair(pair))
|
|
39
40
|
_pair = pair;
|
|
@@ -44,7 +45,7 @@ class YAMLMap extends Collection.Collection {
|
|
|
44
45
|
else
|
|
45
46
|
_pair = new Pair.Pair(pair.key, pair.value);
|
|
46
47
|
const prev = findPair(this.items, _pair.key);
|
|
47
|
-
const sortEntries = this.schema
|
|
48
|
+
const sortEntries = (_a = this.schema) === null || _a === void 0 ? void 0 : _a.sortMapEntries;
|
|
48
49
|
if (prev) {
|
|
49
50
|
if (!overwrite)
|
|
50
51
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -74,7 +75,7 @@ class YAMLMap extends Collection.Collection {
|
|
|
74
75
|
}
|
|
75
76
|
get(key, keepScalar) {
|
|
76
77
|
const it = findPair(this.items, key);
|
|
77
|
-
const node = it
|
|
78
|
+
const node = it === null || it === void 0 ? void 0 : it.value;
|
|
78
79
|
return !keepScalar && Node.isScalar(node) ? node.value : node;
|
|
79
80
|
}
|
|
80
81
|
has(key) {
|
|
@@ -89,8 +90,8 @@ class YAMLMap extends Collection.Collection {
|
|
|
89
90
|
* @returns Instance of Type, Map, or Object
|
|
90
91
|
*/
|
|
91
92
|
toJSON(_, ctx, Type) {
|
|
92
|
-
const map = Type ? new Type() : ctx
|
|
93
|
-
if (ctx
|
|
93
|
+
const map = Type ? new Type() : (ctx === null || ctx === void 0 ? void 0 : ctx.mapAsMap) ? new Map() : {};
|
|
94
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.onCreate)
|
|
94
95
|
ctx.onCreate(map);
|
|
95
96
|
for (const item of this.items)
|
|
96
97
|
addPairToJSMap.addPairToJSMap(ctx, map, item);
|
|
@@ -8,7 +8,7 @@ var toJS = require('./toJS.js');
|
|
|
8
8
|
|
|
9
9
|
const MERGE_KEY = '<<';
|
|
10
10
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
11
|
-
if (ctx
|
|
11
|
+
if ((ctx === null || ctx === void 0 ? void 0 : ctx.doc.schema.merge) && isMergeKey(key)) {
|
|
12
12
|
value = Node.isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
13
13
|
if (Node.isSeq(value))
|
|
14
14
|
for (const it of value.items)
|
|
@@ -13,9 +13,11 @@ var Node = require('./Node.js');
|
|
|
13
13
|
* stringification.
|
|
14
14
|
*/
|
|
15
15
|
function toJS(value, arg, ctx) {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
16
17
|
if (Array.isArray(value))
|
|
17
18
|
return value.map((v, i) => toJS(v, String(i), ctx));
|
|
18
19
|
if (value && typeof value.toJSON === 'function') {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
19
21
|
if (!ctx || !Node.hasAnchor(value))
|
|
20
22
|
return value.toJSON(arg, ctx);
|
|
21
23
|
const data = { aliasCount: 0, count: 1, res: undefined };
|
|
@@ -29,7 +31,7 @@ function toJS(value, arg, ctx) {
|
|
|
29
31
|
ctx.onCreate(res);
|
|
30
32
|
return res;
|
|
31
33
|
}
|
|
32
|
-
if (typeof value === 'bigint' && !(ctx
|
|
34
|
+
if (typeof value === 'bigint' && !(ctx === null || ctx === void 0 ? void 0 : ctx.keep))
|
|
33
35
|
return Number(value);
|
|
34
36
|
return value;
|
|
35
37
|
}
|
|
@@ -49,7 +49,7 @@ visit.REMOVE = REMOVE;
|
|
|
49
49
|
visit.itemAtPath = (cst, path) => {
|
|
50
50
|
let item = cst;
|
|
51
51
|
for (const [field, index] of path) {
|
|
52
|
-
const tok = item
|
|
52
|
+
const tok = item === null || item === void 0 ? void 0 : item[field];
|
|
53
53
|
if (tok && 'items' in tok) {
|
|
54
54
|
item = tok.items[index];
|
|
55
55
|
}
|
|
@@ -66,7 +66,7 @@ visit.itemAtPath = (cst, path) => {
|
|
|
66
66
|
visit.parentCollection = (cst, path) => {
|
|
67
67
|
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
68
68
|
const field = path[path.length - 1][0];
|
|
69
|
-
const coll = parent
|
|
69
|
+
const coll = parent === null || parent === void 0 ? void 0 : parent[field];
|
|
70
70
|
if (coll && 'items' in coll)
|
|
71
71
|
return coll;
|
|
72
72
|
throw new Error('Parent collection not found');
|
|
@@ -150,12 +150,13 @@ class Lexer {
|
|
|
150
150
|
* @returns A generator of lexical tokens
|
|
151
151
|
*/
|
|
152
152
|
*lex(source, incomplete = false) {
|
|
153
|
+
var _a;
|
|
153
154
|
if (source) {
|
|
154
155
|
this.buffer = this.buffer ? this.buffer + source : source;
|
|
155
156
|
this.lineEndPos = null;
|
|
156
157
|
}
|
|
157
158
|
this.atEnd = !incomplete;
|
|
158
|
-
let next = this.next
|
|
159
|
+
let next = (_a = this.next) !== null && _a !== void 0 ? _a : 'stream';
|
|
159
160
|
while (next && (incomplete || this.hasChars(1)))
|
|
160
161
|
next = yield* this.parseNext(next);
|
|
161
162
|
}
|
|
@@ -35,12 +35,13 @@ function isFlowToken(token) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
function getPrevProps(parent) {
|
|
38
|
+
var _a;
|
|
38
39
|
switch (parent.type) {
|
|
39
40
|
case 'document':
|
|
40
41
|
return parent.start;
|
|
41
42
|
case 'block-map': {
|
|
42
43
|
const it = parent.items[parent.items.length - 1];
|
|
43
|
-
return it.sep
|
|
44
|
+
return (_a = it.sep) !== null && _a !== void 0 ? _a : it.start;
|
|
44
45
|
}
|
|
45
46
|
case 'block-seq':
|
|
46
47
|
return parent.items[parent.items.length - 1].start;
|
|
@@ -269,7 +270,7 @@ class Parser {
|
|
|
269
270
|
return this.stack[this.stack.length - n];
|
|
270
271
|
}
|
|
271
272
|
*pop(error) {
|
|
272
|
-
const token = error
|
|
273
|
+
const token = error !== null && error !== void 0 ? error : this.stack.pop();
|
|
273
274
|
/* istanbul ignore if should not happen */
|
|
274
275
|
if (!token) {
|
|
275
276
|
const message = 'Tried to pop an empty stack';
|
|
@@ -518,30 +519,60 @@ class Parser {
|
|
|
518
519
|
const atNextItem = !this.onKeyLine &&
|
|
519
520
|
this.indent === map.indent &&
|
|
520
521
|
(it.sep || includesNonEmpty(it.start));
|
|
522
|
+
// For empty nodes, assign newline-separated not indented empty tokens to following node
|
|
523
|
+
let start = [];
|
|
524
|
+
if (atNextItem && it.sep && !it.value) {
|
|
525
|
+
const nl = [];
|
|
526
|
+
for (let i = 0; i < it.sep.length; ++i) {
|
|
527
|
+
const st = it.sep[i];
|
|
528
|
+
switch (st.type) {
|
|
529
|
+
case 'newline':
|
|
530
|
+
nl.push(i);
|
|
531
|
+
break;
|
|
532
|
+
case 'space':
|
|
533
|
+
break;
|
|
534
|
+
case 'comment':
|
|
535
|
+
if (st.indent > map.indent)
|
|
536
|
+
nl.length = 0;
|
|
537
|
+
break;
|
|
538
|
+
default:
|
|
539
|
+
nl.length = 0;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (nl.length >= 2)
|
|
543
|
+
start = it.sep.splice(nl[1]);
|
|
544
|
+
}
|
|
521
545
|
switch (this.type) {
|
|
522
546
|
case 'anchor':
|
|
523
547
|
case 'tag':
|
|
524
548
|
if (atNextItem || it.value) {
|
|
525
|
-
|
|
549
|
+
start.push(this.sourceToken);
|
|
550
|
+
map.items.push({ start });
|
|
526
551
|
this.onKeyLine = true;
|
|
527
552
|
}
|
|
528
|
-
else if (it.sep)
|
|
553
|
+
else if (it.sep) {
|
|
529
554
|
it.sep.push(this.sourceToken);
|
|
530
|
-
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
531
557
|
it.start.push(this.sourceToken);
|
|
558
|
+
}
|
|
532
559
|
return;
|
|
533
560
|
case 'explicit-key-ind':
|
|
534
|
-
if (!it.sep && !includesToken(it.start, 'explicit-key-ind'))
|
|
561
|
+
if (!it.sep && !includesToken(it.start, 'explicit-key-ind')) {
|
|
535
562
|
it.start.push(this.sourceToken);
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
563
|
+
}
|
|
564
|
+
else if (atNextItem || it.value) {
|
|
565
|
+
start.push(this.sourceToken);
|
|
566
|
+
map.items.push({ start });
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
539
569
|
this.stack.push({
|
|
540
570
|
type: 'block-map',
|
|
541
571
|
offset: this.offset,
|
|
542
572
|
indent: this.indent,
|
|
543
573
|
items: [{ start: [this.sourceToken] }]
|
|
544
574
|
});
|
|
575
|
+
}
|
|
545
576
|
this.onKeyLine = true;
|
|
546
577
|
return;
|
|
547
578
|
case 'map-value-ind':
|
|
@@ -568,7 +599,7 @@ class Parser {
|
|
|
568
599
|
type: 'block-map',
|
|
569
600
|
offset: this.offset,
|
|
570
601
|
indent: this.indent,
|
|
571
|
-
items: [{ start
|
|
602
|
+
items: [{ start, key: null, sep: [this.sourceToken] }]
|
|
572
603
|
});
|
|
573
604
|
}
|
|
574
605
|
else if (isFlowToken(it.key) &&
|
|
@@ -586,6 +617,10 @@ class Parser {
|
|
|
586
617
|
items: [{ start, key, sep }]
|
|
587
618
|
});
|
|
588
619
|
}
|
|
620
|
+
else if (start.length > 0) {
|
|
621
|
+
// Not actually at next item
|
|
622
|
+
it.sep = it.sep.concat(start, this.sourceToken);
|
|
623
|
+
}
|
|
589
624
|
else {
|
|
590
625
|
it.sep.push(this.sourceToken);
|
|
591
626
|
}
|
|
@@ -595,7 +630,7 @@ class Parser {
|
|
|
595
630
|
Object.assign(it, { key: null, sep: [this.sourceToken] });
|
|
596
631
|
}
|
|
597
632
|
else if (it.value || atNextItem) {
|
|
598
|
-
map.items.push({ start
|
|
633
|
+
map.items.push({ start, key: null, sep: [this.sourceToken] });
|
|
599
634
|
}
|
|
600
635
|
else if (includesToken(it.sep, 'map-value-ind')) {
|
|
601
636
|
this.stack.push({
|
|
@@ -617,7 +652,7 @@ class Parser {
|
|
|
617
652
|
case 'double-quoted-scalar': {
|
|
618
653
|
const fs = this.flowScalar(this.type);
|
|
619
654
|
if (atNextItem || it.value) {
|
|
620
|
-
map.items.push({ start
|
|
655
|
+
map.items.push({ start, key: fs, sep: [] });
|
|
621
656
|
this.onKeyLine = true;
|
|
622
657
|
}
|
|
623
658
|
else if (it.sep) {
|
|
@@ -634,8 +669,9 @@ class Parser {
|
|
|
634
669
|
if (bv) {
|
|
635
670
|
if (atNextItem &&
|
|
636
671
|
bv.type !== 'block-seq' &&
|
|
637
|
-
includesToken(it.start, 'explicit-key-ind'))
|
|
638
|
-
map.items.push({ start
|
|
672
|
+
includesToken(it.start, 'explicit-key-ind')) {
|
|
673
|
+
map.items.push({ start });
|
|
674
|
+
}
|
|
639
675
|
this.stack.push(bv);
|
|
640
676
|
return;
|
|
641
677
|
}
|
|
@@ -77,6 +77,7 @@ function parse(src, reviver, options) {
|
|
|
77
77
|
return doc.toJS(Object.assign({ reviver: _reviver }, options));
|
|
78
78
|
}
|
|
79
79
|
function stringify(value, replacer, options) {
|
|
80
|
+
var _a;
|
|
80
81
|
let _replacer = null;
|
|
81
82
|
if (typeof replacer === 'function' || Array.isArray(replacer)) {
|
|
82
83
|
_replacer = replacer;
|
|
@@ -91,7 +92,7 @@ function stringify(value, replacer, options) {
|
|
|
91
92
|
options = indent < 1 ? undefined : indent > 8 ? { indent: 8 } : { indent };
|
|
92
93
|
}
|
|
93
94
|
if (value === undefined) {
|
|
94
|
-
const { keepUndefined } = options
|
|
95
|
+
const { keepUndefined } = (_a = options !== null && options !== void 0 ? options : replacer) !== null && _a !== void 0 ? _a : {};
|
|
95
96
|
if (!keepUndefined)
|
|
96
97
|
return undefined;
|
|
97
98
|
}
|
|
@@ -18,13 +18,17 @@ class Schema {
|
|
|
18
18
|
this.name = (typeof schema === 'string' && schema) || 'core';
|
|
19
19
|
this.knownTags = resolveKnownTags ? tags.coreKnownTags : {};
|
|
20
20
|
this.tags = tags.getTags(customTags, this.name);
|
|
21
|
-
this.toStringOptions = toStringDefaults
|
|
21
|
+
this.toStringOptions = toStringDefaults !== null && toStringDefaults !== void 0 ? toStringDefaults : null;
|
|
22
22
|
Object.defineProperty(this, Node.MAP, { value: map.map });
|
|
23
23
|
Object.defineProperty(this, Node.SCALAR, { value: string.string });
|
|
24
24
|
Object.defineProperty(this, Node.SEQ, { value: seq.seq });
|
|
25
25
|
// Used by createMap()
|
|
26
26
|
this.sortMapEntries =
|
|
27
|
-
sortMapEntries ===
|
|
27
|
+
typeof sortMapEntries === 'function'
|
|
28
|
+
? sortMapEntries
|
|
29
|
+
: sortMapEntries === true
|
|
30
|
+
? sortMapEntriesByKey
|
|
31
|
+
: null;
|
|
28
32
|
}
|
|
29
33
|
clone() {
|
|
30
34
|
const copy = Object.create(Schema.prototype, Object.getOwnPropertyDescriptors(this));
|
|
@@ -24,7 +24,7 @@ class YAMLOMap extends YAMLSeq.YAMLSeq {
|
|
|
24
24
|
if (!ctx)
|
|
25
25
|
return super.toJSON(_);
|
|
26
26
|
const map = new Map();
|
|
27
|
-
if (ctx
|
|
27
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.onCreate)
|
|
28
28
|
ctx.onCreate(map);
|
|
29
29
|
for (const pair of this.items) {
|
|
30
30
|
let key, value;
|