projen 0.54.56 → 0.55.0

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.
Files changed (187) hide show
  1. package/.jsii +3 -3
  2. package/changelog.md +5 -3
  3. package/lib/awscdk/auto-discover.js +4 -4
  4. package/lib/awscdk/awscdk-app-java.js +1 -1
  5. package/lib/awscdk/awscdk-app-py.js +1 -1
  6. package/lib/awscdk/awscdk-app-ts.js +1 -1
  7. package/lib/awscdk/awscdk-construct.js +2 -2
  8. package/lib/awscdk/awscdk-deps-java.js +1 -1
  9. package/lib/awscdk/awscdk-deps-js.js +1 -1
  10. package/lib/awscdk/awscdk-deps.js +1 -1
  11. package/lib/awscdk/cdk-config.js +1 -1
  12. package/lib/awscdk/cdk-tasks.js +1 -1
  13. package/lib/awscdk/integration-test.js +1 -1
  14. package/lib/awscdk/lambda-extension.js +1 -1
  15. package/lib/awscdk/lambda-function.js +2 -2
  16. package/lib/build/build-workflow.js +1 -1
  17. package/lib/cdk/auto-discover-base.js +2 -2
  18. package/lib/cdk/construct-lib.js +1 -1
  19. package/lib/cdk/integration-test-base.js +1 -1
  20. package/lib/cdk/jsii-docgen.js +1 -1
  21. package/lib/cdk/jsii-project.js +1 -1
  22. package/lib/cdk8s/auto-discover.js +2 -2
  23. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  24. package/lib/cdk8s/cdk8s-construct.js +1 -1
  25. package/lib/cdk8s/integration-test.js +1 -1
  26. package/lib/cdktf/cdktf-construct.js +1 -1
  27. package/lib/component.js +1 -1
  28. package/lib/dependencies.js +1 -1
  29. package/lib/dev-env.js +1 -1
  30. package/lib/docker-compose.js +2 -2
  31. package/lib/file.js +1 -1
  32. package/lib/gitattributes.js +1 -1
  33. package/lib/github/auto-approve.js +1 -1
  34. package/lib/github/auto-merge.js +1 -1
  35. package/lib/github/dependabot.js +1 -1
  36. package/lib/github/github-credentials.js +1 -1
  37. package/lib/github/github-project.js +1 -1
  38. package/lib/github/github.js +1 -1
  39. package/lib/github/mergify.js +1 -1
  40. package/lib/github/pr-template.js +1 -1
  41. package/lib/github/pull-request-lint.js +1 -1
  42. package/lib/github/stale.js +1 -1
  43. package/lib/github/task-workflow.js +1 -1
  44. package/lib/github/workflows.js +1 -1
  45. package/lib/gitlab/configuration.js +1 -1
  46. package/lib/gitlab/gitlab-configuration.js +1 -1
  47. package/lib/gitlab/nested-configuration.js +1 -1
  48. package/lib/gitpod.js +1 -1
  49. package/lib/ignore-file.js +1 -1
  50. package/lib/ini.js +1 -1
  51. package/lib/java/java-project.js +1 -1
  52. package/lib/java/junit.js +1 -1
  53. package/lib/java/maven-compile.js +1 -1
  54. package/lib/java/maven-packaging.js +1 -1
  55. package/lib/java/maven-sample.js +1 -1
  56. package/lib/java/pom.js +1 -1
  57. package/lib/java/projenrc.js +1 -1
  58. package/lib/javascript/bundler.js +1 -1
  59. package/lib/javascript/eslint.js +1 -1
  60. package/lib/javascript/jest.js +1 -1
  61. package/lib/javascript/node-package.js +1 -1
  62. package/lib/javascript/node-project.js +1 -1
  63. package/lib/javascript/npm-config.js +1 -1
  64. package/lib/javascript/prettier.js +1 -1
  65. package/lib/javascript/projenrc.js +1 -1
  66. package/lib/javascript/typescript-config.js +1 -1
  67. package/lib/javascript/upgrade-dependencies.js +2 -2
  68. package/lib/json.js +1 -1
  69. package/lib/license.js +1 -1
  70. package/lib/logger.js +1 -1
  71. package/lib/makefile.js +1 -1
  72. package/lib/object-file.js +1 -1
  73. package/lib/project-build.js +1 -1
  74. package/lib/project.js +1 -1
  75. package/lib/projects.js +1 -1
  76. package/lib/projenrc-json.js +1 -1
  77. package/lib/python/pip.js +1 -1
  78. package/lib/python/poetry.js +2 -2
  79. package/lib/python/projenrc.js +1 -1
  80. package/lib/python/pytest-sample.js +1 -1
  81. package/lib/python/pytest.js +1 -1
  82. package/lib/python/python-project.js +1 -1
  83. package/lib/python/python-sample.js +1 -1
  84. package/lib/python/requirements-file.js +1 -1
  85. package/lib/python/setuppy.js +1 -1
  86. package/lib/python/setuptools.js +1 -1
  87. package/lib/python/venv.js +1 -1
  88. package/lib/readme.js +1 -1
  89. package/lib/release/publisher.js +1 -1
  90. package/lib/release/release-trigger.js +1 -1
  91. package/lib/release/release.js +1 -1
  92. package/lib/run-task.js +1813 -0
  93. package/lib/sample-file.js +2 -2
  94. package/lib/semver.js +1 -1
  95. package/lib/source-code.js +1 -1
  96. package/lib/task-runtime.js +1 -1
  97. package/lib/task.js +1 -1
  98. package/lib/tasks.js +1 -1
  99. package/lib/testing.js +1 -1
  100. package/lib/textfile.js +1 -1
  101. package/lib/toml.js +1 -1
  102. package/lib/typescript/projenrc.js +1 -1
  103. package/lib/typescript/typescript-typedoc.js +1 -1
  104. package/lib/typescript/typescript.js +5 -5
  105. package/lib/util.d.ts +1 -1
  106. package/lib/version.js +1 -1
  107. package/lib/vscode/devcontainer.js +1 -1
  108. package/lib/vscode/launch-config.js +1 -1
  109. package/lib/vscode/vscode.js +1 -1
  110. package/lib/web/next.js +3 -3
  111. package/lib/web/postcss.js +1 -1
  112. package/lib/web/react.js +4 -4
  113. package/lib/web/tailwind.js +1 -1
  114. package/lib/xmlfile.js +1 -1
  115. package/lib/yaml.js +1 -1
  116. package/node_modules/xmlbuilder2/node_modules/@types/node/README.md +1 -1
  117. package/node_modules/xmlbuilder2/node_modules/@types/node/diagnostics_channel.d.ts +18 -0
  118. package/node_modules/xmlbuilder2/node_modules/@types/node/package.json +2 -2
  119. package/node_modules/yaml/README.md +1 -1
  120. package/node_modules/yaml/browser/dist/compose/compose-doc.js +1 -1
  121. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +4 -4
  122. package/node_modules/yaml/browser/dist/compose/composer.js +1 -0
  123. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +2 -2
  124. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +3 -1
  125. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +4 -3
  126. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +2 -1
  127. package/node_modules/yaml/browser/dist/compose/resolve-props.js +1 -1
  128. package/node_modules/yaml/browser/dist/doc/Document.js +9 -5
  129. package/node_modules/yaml/browser/dist/doc/anchors.js +2 -2
  130. package/node_modules/yaml/browser/dist/doc/createNode.js +7 -4
  131. package/node_modules/yaml/browser/dist/nodes/Pair.js +2 -2
  132. package/node_modules/yaml/browser/dist/nodes/Scalar.js +1 -1
  133. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +5 -4
  134. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +1 -1
  135. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +1 -1
  136. package/node_modules/yaml/browser/dist/nodes/toJS.js +3 -1
  137. package/node_modules/yaml/browser/dist/parse/cst-visit.js +2 -2
  138. package/node_modules/yaml/browser/dist/parse/lexer.js +2 -1
  139. package/node_modules/yaml/browser/dist/parse/parser.js +50 -14
  140. package/node_modules/yaml/browser/dist/public-api.js +2 -1
  141. package/node_modules/yaml/browser/dist/schema/Schema.js +6 -2
  142. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +1 -1
  143. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +2 -1
  144. package/node_modules/yaml/browser/dist/stringify/stringify.js +8 -8
  145. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +5 -3
  146. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +4 -1
  147. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +2 -2
  148. package/node_modules/yaml/dist/compose/compose-doc.js +1 -1
  149. package/node_modules/yaml/dist/compose/compose-scalar.js +4 -4
  150. package/node_modules/yaml/dist/compose/composer.js +1 -0
  151. package/node_modules/yaml/dist/compose/resolve-block-map.js +2 -2
  152. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +3 -1
  153. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +4 -3
  154. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +2 -1
  155. package/node_modules/yaml/dist/compose/resolve-props.d.ts +1 -1
  156. package/node_modules/yaml/dist/compose/resolve-props.js +1 -1
  157. package/node_modules/yaml/dist/doc/Document.d.ts +1 -1
  158. package/node_modules/yaml/dist/doc/Document.js +9 -5
  159. package/node_modules/yaml/dist/doc/anchors.d.ts +2 -2
  160. package/node_modules/yaml/dist/doc/anchors.js +2 -2
  161. package/node_modules/yaml/dist/doc/createNode.d.ts +1 -1
  162. package/node_modules/yaml/dist/doc/createNode.js +7 -4
  163. package/node_modules/yaml/dist/doc/directives.d.ts +1 -1
  164. package/node_modules/yaml/dist/nodes/Pair.js +2 -2
  165. package/node_modules/yaml/dist/nodes/Scalar.js +1 -1
  166. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +3 -1
  167. package/node_modules/yaml/dist/nodes/YAMLMap.js +5 -4
  168. package/node_modules/yaml/dist/nodes/YAMLSeq.js +1 -1
  169. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +1 -1
  170. package/node_modules/yaml/dist/nodes/toJS.js +3 -1
  171. package/node_modules/yaml/dist/options.d.ts +1 -1
  172. package/node_modules/yaml/dist/parse/cst-visit.js +2 -2
  173. package/node_modules/yaml/dist/parse/lexer.js +2 -1
  174. package/node_modules/yaml/dist/parse/parser.js +50 -14
  175. package/node_modules/yaml/dist/public-api.js +2 -1
  176. package/node_modules/yaml/dist/schema/Schema.js +6 -2
  177. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +1 -1
  178. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +2 -1
  179. package/node_modules/yaml/dist/stringify/stringify.js +8 -8
  180. package/node_modules/yaml/dist/stringify/stringifyComment.js +5 -3
  181. package/node_modules/yaml/dist/stringify/stringifyPair.js +4 -1
  182. package/node_modules/yaml/dist/stringify/stringifyString.js +2 -2
  183. package/node_modules/yaml/dist/test-events.js +1 -1
  184. package/node_modules/yaml/package.json +2 -2
  185. package/package.json +4 -4
  186. package/releasetag.txt +1 -1
  187. package/version.txt +1 -1
@@ -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?: any): any;
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 && this.schema.sortMapEntries;
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 && it.value;
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 && ctx.mapAsMap ? new Map() : {};
93
- if (ctx && ctx.onCreate)
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);
@@ -76,7 +76,7 @@ class YAMLSeq extends Collection.Collection {
76
76
  }
77
77
  toJSON(_, ctx) {
78
78
  const seq = [];
79
- if (ctx && ctx.onCreate)
79
+ if (ctx === null || ctx === void 0 ? void 0 : ctx.onCreate)
80
80
  ctx.onCreate(seq);
81
81
  let i = 0;
82
82
  for (const item of this.items)
@@ -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 && ctx.doc.schema.merge && isMergeKey(key)) {
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 && ctx.keep))
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
  }
@@ -73,7 +73,7 @@ export declare type DocumentOptions = {
73
73
  *
74
74
  * Default: `"1.2"`
75
75
  */
76
- version?: '1.1' | '1.2';
76
+ version?: '1.1' | '1.2' | 'next';
77
77
  };
78
78
  export declare type SchemaOptions = {
79
79
  /**
@@ -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 && item[field];
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 && parent[field];
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 || 'stream';
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 || it.start;
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 || this.stack.pop();
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
- map.items.push({ start: [this.sourceToken] });
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
- else
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
- else if (atNextItem || it.value)
537
- map.items.push({ start: [this.sourceToken] });
538
- else
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: [], key: null, sep: [this.sourceToken] }]
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: [], key: null, sep: [this.sourceToken] });
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: [], key: fs, sep: [] });
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 || replacer || {};
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 || null;
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 === true ? sortMapEntriesByKey : sortMapEntries || null;
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 && ctx.onCreate)
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 || pair.key;
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) || match[0];
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 && t.identify(obj));
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) || match.find(t => !t.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
- // @ts-ignore
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 || (tagObj.default ? null : tagObj.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 || 0) + props.length + 1;
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) => comment.includes('\n')
17
- ? '\n' + indentComment(comment, indent)
18
- : (str.endsWith(' ') ? '' : ' ') + comment;
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
- ws = valueStr === '' && !ctx.inFlow ? vcb : `${vcb}\n${ctx.indent}`;
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.indexOf('\n') === -1
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.indexOf('\n') !== -1) {
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
  }
@@ -57,7 +57,7 @@ function testEvents(src) {
57
57
  }
58
58
  }
59
59
  catch (e) {
60
- return { events, error: error || e };
60
+ return { events, error: error !== null && error !== void 0 ? error : e };
61
61
  }
62
62
  events.push('-STR');
63
63
  return { events, error };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaml",
3
- "version": "2.0.0-11",
3
+ "version": "2.0.0",
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": ">= 12"
92
+ "node": ">= 14"
93
93
  }
94
94
  }
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  "@types/glob": "^7.2.0",
54
54
  "@types/ini": "^1.3.31",
55
55
  "@types/jest": "^27.4.1",
56
- "@types/node": "^12",
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.0-11",
94
+ "yaml": "^2.0.0",
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": ">= 12.7.0"
120
+ "node": ">= 14.0.0"
121
121
  },
122
122
  "main": "lib/index.js",
123
123
  "license": "Apache-2.0",
124
- "version": "0.54.56",
124
+ "version": "0.55.0",
125
125
  "jest": {
126
126
  "testMatch": [
127
127
  "<rootDir>/src/**/__tests__/**/*.ts?(x)",
package/releasetag.txt CHANGED
@@ -1 +1 @@
1
- v0.54.56
1
+ v0.55.0
package/version.txt CHANGED
@@ -1 +1 @@
1
- 0.54.56
1
+ 0.55.0