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
|
@@ -9,7 +9,7 @@ function includesToken(list, type) {
|
|
|
9
9
|
return true;
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function findNonEmptyIndex(list) {
|
|
13
13
|
for (let i = 0; i < list.length; ++i) {
|
|
14
14
|
switch (list[i].type) {
|
|
15
15
|
case 'space':
|
|
@@ -17,10 +17,10 @@ function includesNonEmpty(list) {
|
|
|
17
17
|
case 'newline':
|
|
18
18
|
break;
|
|
19
19
|
default:
|
|
20
|
-
return
|
|
20
|
+
return i;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return -1;
|
|
24
24
|
}
|
|
25
25
|
function isFlowToken(token) {
|
|
26
26
|
switch (token === null || token === void 0 ? void 0 : token.type) {
|
|
@@ -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';
|
|
@@ -346,7 +347,7 @@ class Parser {
|
|
|
346
347
|
!last.sep &&
|
|
347
348
|
!last.value &&
|
|
348
349
|
last.start.length > 0 &&
|
|
349
|
-
|
|
350
|
+
findNonEmptyIndex(last.start) === -1 &&
|
|
350
351
|
(token.indent === 0 ||
|
|
351
352
|
last.start.every(st => st.type !== 'comment' || st.indent < token.indent))) {
|
|
352
353
|
if (top.type === 'document')
|
|
@@ -394,7 +395,7 @@ class Parser {
|
|
|
394
395
|
return yield* this.lineEnd(doc);
|
|
395
396
|
switch (this.type) {
|
|
396
397
|
case 'doc-start': {
|
|
397
|
-
if (
|
|
398
|
+
if (findNonEmptyIndex(doc.start) !== -1) {
|
|
398
399
|
yield* this.pop();
|
|
399
400
|
yield* this.step();
|
|
400
401
|
}
|
|
@@ -488,17 +489,21 @@ class Parser {
|
|
|
488
489
|
else
|
|
489
490
|
map.items.push({ start: [this.sourceToken] });
|
|
490
491
|
}
|
|
491
|
-
else if (it.sep)
|
|
492
|
+
else if (it.sep) {
|
|
492
493
|
it.sep.push(this.sourceToken);
|
|
493
|
-
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
494
496
|
it.start.push(this.sourceToken);
|
|
497
|
+
}
|
|
495
498
|
return;
|
|
496
499
|
case 'space':
|
|
497
500
|
case 'comment':
|
|
498
|
-
if (it.value)
|
|
501
|
+
if (it.value) {
|
|
499
502
|
map.items.push({ start: [this.sourceToken] });
|
|
500
|
-
|
|
503
|
+
}
|
|
504
|
+
else if (it.sep) {
|
|
501
505
|
it.sep.push(this.sourceToken);
|
|
506
|
+
}
|
|
502
507
|
else {
|
|
503
508
|
if (this.atIndentedComment(it.start, map.indent)) {
|
|
504
509
|
const prev = map.items[map.items.length - 2];
|
|
@@ -515,33 +520,61 @@ class Parser {
|
|
|
515
520
|
return;
|
|
516
521
|
}
|
|
517
522
|
if (this.indent >= map.indent) {
|
|
518
|
-
const atNextItem = !this.onKeyLine &&
|
|
519
|
-
|
|
520
|
-
|
|
523
|
+
const atNextItem = !this.onKeyLine && this.indent === map.indent && it.sep;
|
|
524
|
+
// For empty nodes, assign newline-separated not indented empty tokens to following node
|
|
525
|
+
let start = [];
|
|
526
|
+
if (atNextItem && it.sep && !it.value) {
|
|
527
|
+
const nl = [];
|
|
528
|
+
for (let i = 0; i < it.sep.length; ++i) {
|
|
529
|
+
const st = it.sep[i];
|
|
530
|
+
switch (st.type) {
|
|
531
|
+
case 'newline':
|
|
532
|
+
nl.push(i);
|
|
533
|
+
break;
|
|
534
|
+
case 'space':
|
|
535
|
+
break;
|
|
536
|
+
case 'comment':
|
|
537
|
+
if (st.indent > map.indent)
|
|
538
|
+
nl.length = 0;
|
|
539
|
+
break;
|
|
540
|
+
default:
|
|
541
|
+
nl.length = 0;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
if (nl.length >= 2)
|
|
545
|
+
start = it.sep.splice(nl[1]);
|
|
546
|
+
}
|
|
521
547
|
switch (this.type) {
|
|
522
548
|
case 'anchor':
|
|
523
549
|
case 'tag':
|
|
524
550
|
if (atNextItem || it.value) {
|
|
525
|
-
|
|
551
|
+
start.push(this.sourceToken);
|
|
552
|
+
map.items.push({ start });
|
|
526
553
|
this.onKeyLine = true;
|
|
527
554
|
}
|
|
528
|
-
else if (it.sep)
|
|
555
|
+
else if (it.sep) {
|
|
529
556
|
it.sep.push(this.sourceToken);
|
|
530
|
-
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
531
559
|
it.start.push(this.sourceToken);
|
|
560
|
+
}
|
|
532
561
|
return;
|
|
533
562
|
case 'explicit-key-ind':
|
|
534
|
-
if (!it.sep && !includesToken(it.start, 'explicit-key-ind'))
|
|
563
|
+
if (!it.sep && !includesToken(it.start, 'explicit-key-ind')) {
|
|
535
564
|
it.start.push(this.sourceToken);
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
565
|
+
}
|
|
566
|
+
else if (atNextItem || it.value) {
|
|
567
|
+
start.push(this.sourceToken);
|
|
568
|
+
map.items.push({ start });
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
539
571
|
this.stack.push({
|
|
540
572
|
type: 'block-map',
|
|
541
573
|
offset: this.offset,
|
|
542
574
|
indent: this.indent,
|
|
543
575
|
items: [{ start: [this.sourceToken] }]
|
|
544
576
|
});
|
|
577
|
+
}
|
|
545
578
|
this.onKeyLine = true;
|
|
546
579
|
return;
|
|
547
580
|
case 'map-value-ind':
|
|
@@ -568,7 +601,7 @@ class Parser {
|
|
|
568
601
|
type: 'block-map',
|
|
569
602
|
offset: this.offset,
|
|
570
603
|
indent: this.indent,
|
|
571
|
-
items: [{ start
|
|
604
|
+
items: [{ start, key: null, sep: [this.sourceToken] }]
|
|
572
605
|
});
|
|
573
606
|
}
|
|
574
607
|
else if (isFlowToken(it.key) &&
|
|
@@ -586,6 +619,10 @@ class Parser {
|
|
|
586
619
|
items: [{ start, key, sep }]
|
|
587
620
|
});
|
|
588
621
|
}
|
|
622
|
+
else if (start.length > 0) {
|
|
623
|
+
// Not actually at next item
|
|
624
|
+
it.sep = it.sep.concat(start, this.sourceToken);
|
|
625
|
+
}
|
|
589
626
|
else {
|
|
590
627
|
it.sep.push(this.sourceToken);
|
|
591
628
|
}
|
|
@@ -595,7 +632,7 @@ class Parser {
|
|
|
595
632
|
Object.assign(it, { key: null, sep: [this.sourceToken] });
|
|
596
633
|
}
|
|
597
634
|
else if (it.value || atNextItem) {
|
|
598
|
-
map.items.push({ start
|
|
635
|
+
map.items.push({ start, key: null, sep: [this.sourceToken] });
|
|
599
636
|
}
|
|
600
637
|
else if (includesToken(it.sep, 'map-value-ind')) {
|
|
601
638
|
this.stack.push({
|
|
@@ -617,7 +654,7 @@ class Parser {
|
|
|
617
654
|
case 'double-quoted-scalar': {
|
|
618
655
|
const fs = this.flowScalar(this.type);
|
|
619
656
|
if (atNextItem || it.value) {
|
|
620
|
-
map.items.push({ start
|
|
657
|
+
map.items.push({ start, key: fs, sep: [] });
|
|
621
658
|
this.onKeyLine = true;
|
|
622
659
|
}
|
|
623
660
|
else if (it.sep) {
|
|
@@ -634,8 +671,9 @@ class Parser {
|
|
|
634
671
|
if (bv) {
|
|
635
672
|
if (atNextItem &&
|
|
636
673
|
bv.type !== 'block-seq' &&
|
|
637
|
-
includesToken(it.start, 'explicit-key-ind'))
|
|
638
|
-
map.items.push({ start
|
|
674
|
+
includesToken(it.start, 'explicit-key-ind')) {
|
|
675
|
+
map.items.push({ start });
|
|
676
|
+
}
|
|
639
677
|
this.stack.push(bv);
|
|
640
678
|
return;
|
|
641
679
|
}
|
|
@@ -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;
|
|
@@ -6,6 +6,7 @@ var Scalar = require('../../nodes/Scalar.js');
|
|
|
6
6
|
var YAMLSeq = require('../../nodes/YAMLSeq.js');
|
|
7
7
|
|
|
8
8
|
function resolvePairs(seq, onError) {
|
|
9
|
+
var _a;
|
|
9
10
|
if (Node.isSeq(seq)) {
|
|
10
11
|
for (let i = 0; i < seq.items.length; ++i) {
|
|
11
12
|
let item = seq.items[i];
|
|
@@ -20,7 +21,7 @@ function resolvePairs(seq, onError) {
|
|
|
20
21
|
? `${item.commentBefore}\n${pair.key.commentBefore}`
|
|
21
22
|
: item.commentBefore;
|
|
22
23
|
if (item.comment) {
|
|
23
|
-
const cn = pair.value
|
|
24
|
+
const cn = (_a = pair.value) !== null && _a !== void 0 ? _a : pair.key;
|
|
24
25
|
cn.comment = cn.comment
|
|
25
26
|
? `${item.comment}\n${cn.comment}`
|
|
26
27
|
: item.comment;
|
|
@@ -45,26 +45,26 @@ function createStringifyContext(doc, options) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
function getTagObject(tags, item) {
|
|
48
|
+
var _a, _b, _c, _d;
|
|
48
49
|
if (item.tag) {
|
|
49
50
|
const match = tags.filter(t => t.tag === item.tag);
|
|
50
51
|
if (match.length > 0)
|
|
51
|
-
return match.find(t => t.format === item.format)
|
|
52
|
+
return (_a = match.find(t => t.format === item.format)) !== null && _a !== void 0 ? _a : match[0];
|
|
52
53
|
}
|
|
53
54
|
let tagObj = undefined;
|
|
54
55
|
let obj;
|
|
55
56
|
if (Node.isScalar(item)) {
|
|
56
57
|
obj = item.value;
|
|
57
|
-
const match = tags.filter(t => t.identify
|
|
58
|
+
const match = tags.filter(t => { var _a; return (_a = t.identify) === null || _a === void 0 ? void 0 : _a.call(t, obj); });
|
|
58
59
|
tagObj =
|
|
59
|
-
match.find(t => t.format === item.format)
|
|
60
|
+
(_b = match.find(t => t.format === item.format)) !== null && _b !== void 0 ? _b : match.find(t => !t.format);
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
62
63
|
obj = item;
|
|
63
64
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
64
65
|
}
|
|
65
66
|
if (!tagObj) {
|
|
66
|
-
|
|
67
|
-
const name = obj && obj.constructor ? obj.constructor.name : typeof obj;
|
|
67
|
+
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;
|
|
68
68
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
69
69
|
}
|
|
70
70
|
return tagObj;
|
|
@@ -79,13 +79,13 @@ function stringifyProps(node, tagObj, { anchors: anchors$1, doc }) {
|
|
|
79
79
|
anchors$1.add(anchor);
|
|
80
80
|
props.push(`&${anchor}`);
|
|
81
81
|
}
|
|
82
|
-
const tag = node.tag
|
|
82
|
+
const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
|
|
83
83
|
if (tag)
|
|
84
84
|
props.push(doc.directives.tagString(tag));
|
|
85
85
|
return props.join(' ');
|
|
86
86
|
}
|
|
87
87
|
function stringify(item, ctx, onComment, onChompKeep) {
|
|
88
|
-
var _a;
|
|
88
|
+
var _a, _b;
|
|
89
89
|
if (Node.isPair(item))
|
|
90
90
|
return item.toString(ctx, onComment, onChompKeep);
|
|
91
91
|
if (Node.isAlias(item)) {
|
|
@@ -110,7 +110,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
110
110
|
tagObj = getTagObject(ctx.doc.schema.tags, node);
|
|
111
111
|
const props = stringifyProps(node, tagObj, ctx);
|
|
112
112
|
if (props.length > 0)
|
|
113
|
-
ctx.indentAtStart = (ctx.indentAtStart
|
|
113
|
+
ctx.indentAtStart = ((_b = ctx.indentAtStart) !== null && _b !== void 0 ? _b : 0) + props.length + 1;
|
|
114
114
|
const str = typeof tagObj.stringify === 'function'
|
|
115
115
|
? tagObj.stringify(node, ctx, onComment, onChompKeep)
|
|
116
116
|
: Node.isScalar(node)
|
|
@@ -13,9 +13,11 @@ function indentComment(comment, indent) {
|
|
|
13
13
|
return comment.substring(1);
|
|
14
14
|
return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
|
15
15
|
}
|
|
16
|
-
const lineComment = (str, indent, comment) =>
|
|
17
|
-
?
|
|
18
|
-
:
|
|
16
|
+
const lineComment = (str, indent, comment) => str.endsWith('\n')
|
|
17
|
+
? indentComment(comment, indent)
|
|
18
|
+
: comment.includes('\n')
|
|
19
|
+
? '\n' + indentComment(comment, indent)
|
|
20
|
+
: (str.endsWith(' ') ? '' : ' ') + comment;
|
|
19
21
|
|
|
20
22
|
exports.indentComment = indentComment;
|
|
21
23
|
exports.lineComment = lineComment;
|
|
@@ -98,7 +98,10 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
98
98
|
const valueStr = stringify.stringify(value, ctx, () => (valueCommentDone = true), () => (chompKeep = true));
|
|
99
99
|
let ws = ' ';
|
|
100
100
|
if (vcb || keyComment) {
|
|
101
|
-
|
|
101
|
+
if (valueStr === '' && !ctx.inFlow)
|
|
102
|
+
ws = vcb === '\n' ? '\n\n' : vcb;
|
|
103
|
+
else
|
|
104
|
+
ws = `${vcb}\n${ctx.indent}`;
|
|
102
105
|
}
|
|
103
106
|
else if (!explicitKey && Node.isCollection(value)) {
|
|
104
107
|
const flow = valueStr[0] === '[' || valueStr[0] === '{';
|
|
@@ -245,14 +245,14 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
245
245
|
// - '\n ', ': ' or ' \n' anywhere
|
|
246
246
|
// - '#' not preceded by a non-space char
|
|
247
247
|
// - end with ' ' or ':'
|
|
248
|
-
return implicitKey || inFlow || value.
|
|
248
|
+
return implicitKey || inFlow || !value.includes('\n')
|
|
249
249
|
? quotedString(value, ctx)
|
|
250
250
|
: blockString(item, ctx, onComment, onChompKeep);
|
|
251
251
|
}
|
|
252
252
|
if (!implicitKey &&
|
|
253
253
|
!inFlow &&
|
|
254
254
|
type !== Scalar.Scalar.PLAIN &&
|
|
255
|
-
value.
|
|
255
|
+
value.includes('\n')) {
|
|
256
256
|
// Where allowed & type not set explicitly, prefer block style for multiline strings
|
|
257
257
|
return blockString(item, ctx, onComment, onChompKeep);
|
|
258
258
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Eemeli Aro <eemeli@gmail.com>",
|
|
6
6
|
"repository": "github:eemeli/yaml",
|
|
@@ -89,6 +89,6 @@
|
|
|
89
89
|
"typescript": "^4.3.5"
|
|
90
90
|
},
|
|
91
91
|
"engines": {
|
|
92
|
-
"node": ">=
|
|
92
|
+
"node": ">= 14"
|
|
93
93
|
}
|
|
94
94
|
}
|
package/package.json
CHANGED
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@types/fs-extra": "^8",
|
|
53
53
|
"@types/glob": "^7.2.0",
|
|
54
54
|
"@types/ini": "^1.3.31",
|
|
55
|
-
"@types/jest": "^27.
|
|
56
|
-
"@types/node": "^
|
|
55
|
+
"@types/jest": "^27.5.0",
|
|
56
|
+
"@types/node": "^14",
|
|
57
57
|
"@types/semver": "^7.3.9",
|
|
58
58
|
"@types/yargs": "^15.0.14",
|
|
59
59
|
"@typescript-eslint/eslint-plugin": "^5",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"semver": "^7.3.7",
|
|
92
92
|
"shx": "^0.3.4",
|
|
93
93
|
"xmlbuilder2": "^2.4.1",
|
|
94
|
-
"yaml": "2.0.
|
|
94
|
+
"yaml": "^2.0.1",
|
|
95
95
|
"yargs": "^16.2.0"
|
|
96
96
|
},
|
|
97
97
|
"bundledDependencies": [
|
|
@@ -117,11 +117,11 @@
|
|
|
117
117
|
"scaffolding"
|
|
118
118
|
],
|
|
119
119
|
"engines": {
|
|
120
|
-
"node": ">=
|
|
120
|
+
"node": ">= 14.0.0"
|
|
121
121
|
},
|
|
122
122
|
"main": "lib/index.js",
|
|
123
123
|
"license": "Apache-2.0",
|
|
124
|
-
"version": "0.
|
|
124
|
+
"version": "0.55.2",
|
|
125
125
|
"jest": {
|
|
126
126
|
"testMatch": [
|
|
127
127
|
"<rootDir>/src/**/__tests__/**/*.ts?(x)",
|
package/releasetag.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v0.
|
|
1
|
+
v0.55.2
|
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.55.2
|