projen 0.92.3 → 0.92.5

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 (214) hide show
  1. package/.jsii +3 -3
  2. package/lib/awscdk/auto-discover.js +5 -5
  3. package/lib/awscdk/awscdk-app-java.js +1 -1
  4. package/lib/awscdk/awscdk-app-py.js +1 -1
  5. package/lib/awscdk/awscdk-app-ts.js +1 -1
  6. package/lib/awscdk/awscdk-construct.js +2 -2
  7. package/lib/awscdk/awscdk-deps-java.js +1 -1
  8. package/lib/awscdk/awscdk-deps-js.js +1 -1
  9. package/lib/awscdk/awscdk-deps-py.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-py.js +1 -1
  24. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  25. package/lib/cdk8s/cdk8s-construct.js +1 -1
  26. package/lib/cdk8s/cdk8s-deps-py.js +1 -1
  27. package/lib/cdk8s/cdk8s-deps.js +1 -1
  28. package/lib/cdk8s/integration-test.js +1 -1
  29. package/lib/cdktf/cdktf-construct.js +1 -1
  30. package/lib/circleci/circleci.js +1 -1
  31. package/lib/component.js +1 -1
  32. package/lib/dependencies.js +1 -1
  33. package/lib/dev-env.js +1 -1
  34. package/lib/docker-compose/docker-compose-service.js +1 -1
  35. package/lib/docker-compose/docker-compose.js +1 -1
  36. package/lib/file.js +1 -1
  37. package/lib/gitattributes.js +1 -1
  38. package/lib/github/actions-provider.js +1 -1
  39. package/lib/github/auto-approve.js +1 -1
  40. package/lib/github/auto-merge.js +1 -1
  41. package/lib/github/auto-queue.js +1 -1
  42. package/lib/github/dependabot.js +1 -1
  43. package/lib/github/github-credentials.js +1 -1
  44. package/lib/github/github-project.js +1 -1
  45. package/lib/github/github.js +1 -1
  46. package/lib/github/merge-queue.js +1 -1
  47. package/lib/github/mergify.js +1 -1
  48. package/lib/github/pr-template.js +1 -1
  49. package/lib/github/pull-request-backport.js +1 -1
  50. package/lib/github/pull-request-lint.js +1 -1
  51. package/lib/github/stale.js +1 -1
  52. package/lib/github/task-workflow-job.js +1 -1
  53. package/lib/github/task-workflow.js +1 -1
  54. package/lib/github/workflow-actions.js +1 -1
  55. package/lib/github/workflow-jobs.js +1 -1
  56. package/lib/github/workflow-steps.js +1 -1
  57. package/lib/github/workflows.js +1 -1
  58. package/lib/gitlab/configuration.js +1 -1
  59. package/lib/gitlab/gitlab-configuration.js +1 -1
  60. package/lib/gitlab/nested-configuration.js +1 -1
  61. package/lib/gitpod.js +1 -1
  62. package/lib/ignore-file.js +1 -1
  63. package/lib/ini.js +1 -1
  64. package/lib/java/java-project.js +1 -1
  65. package/lib/java/junit.js +1 -1
  66. package/lib/java/maven-compile.js +1 -1
  67. package/lib/java/maven-packaging.js +1 -1
  68. package/lib/java/maven-sample.js +1 -1
  69. package/lib/java/pom.js +2 -2
  70. package/lib/java/projenrc.js +1 -1
  71. package/lib/javascript/bundler.js +1 -1
  72. package/lib/javascript/eslint.js +1 -1
  73. package/lib/javascript/jest.js +4 -4
  74. package/lib/javascript/license-checker.js +1 -1
  75. package/lib/javascript/node-package.js +1 -1
  76. package/lib/javascript/node-project.js +1 -1
  77. package/lib/javascript/npm-config.js +1 -1
  78. package/lib/javascript/prettier.js +1 -1
  79. package/lib/javascript/projenrc.js +1 -1
  80. package/lib/javascript/typescript-config.js +2 -2
  81. package/lib/javascript/upgrade-dependencies.js +2 -2
  82. package/lib/javascript/yarnrc.js +1 -1
  83. package/lib/json-patch.js +1 -1
  84. package/lib/json.js +1 -1
  85. package/lib/license.js +1 -1
  86. package/lib/logger.js +1 -1
  87. package/lib/makefile.js +1 -1
  88. package/lib/object-file.js +1 -1
  89. package/lib/project-build.js +1 -1
  90. package/lib/project-tree.js +1 -1
  91. package/lib/project.js +1 -1
  92. package/lib/projects.js +1 -1
  93. package/lib/projenrc-json.js +2 -2
  94. package/lib/projenrc.js +1 -1
  95. package/lib/python/pip.js +1 -1
  96. package/lib/python/poetry.js +2 -2
  97. package/lib/python/projenrc.js +1 -1
  98. package/lib/python/pytest-sample.js +1 -1
  99. package/lib/python/pytest.js +1 -1
  100. package/lib/python/python-project.js +1 -1
  101. package/lib/python/python-sample.js +1 -1
  102. package/lib/python/requirements-file.js +1 -1
  103. package/lib/python/setuppy.js +1 -1
  104. package/lib/python/setuptools.js +1 -1
  105. package/lib/python/venv.js +1 -1
  106. package/lib/readme.js +1 -1
  107. package/lib/release/publisher.js +1 -1
  108. package/lib/release/release-trigger.js +1 -1
  109. package/lib/release/release.js +1 -1
  110. package/lib/renovatebot.js +1 -1
  111. package/lib/sample-file.js +2 -2
  112. package/lib/semver.js +1 -1
  113. package/lib/source-code.js +1 -1
  114. package/lib/task-runtime.js +1 -1
  115. package/lib/task.js +1 -1
  116. package/lib/tasks.js +1 -1
  117. package/lib/testing.js +1 -1
  118. package/lib/textfile.js +1 -1
  119. package/lib/toml.js +1 -1
  120. package/lib/typescript/projenrc-ts.js +1 -1
  121. package/lib/typescript/projenrc.js +1 -1
  122. package/lib/typescript/typescript-typedoc.js +1 -1
  123. package/lib/typescript/typescript.js +6 -6
  124. package/lib/version.js +2 -2
  125. package/lib/vscode/devcontainer.js +1 -1
  126. package/lib/vscode/extensions.js +1 -1
  127. package/lib/vscode/launch-config.js +1 -1
  128. package/lib/vscode/settings.js +1 -1
  129. package/lib/vscode/vscode.js +1 -1
  130. package/lib/web/next.js +3 -3
  131. package/lib/web/postcss.js +1 -1
  132. package/lib/web/react.js +4 -4
  133. package/lib/web/tailwind.js +1 -1
  134. package/lib/xmlfile.js +1 -1
  135. package/lib/yaml.js +1 -1
  136. package/node_modules/semver/bin/semver.js +2 -0
  137. package/node_modules/semver/classes/comparator.js +2 -0
  138. package/node_modules/semver/classes/index.js +2 -0
  139. package/node_modules/semver/classes/range.js +2 -0
  140. package/node_modules/semver/classes/semver.js +4 -3
  141. package/node_modules/semver/functions/clean.js +2 -0
  142. package/node_modules/semver/functions/cmp.js +2 -0
  143. package/node_modules/semver/functions/coerce.js +2 -0
  144. package/node_modules/semver/functions/compare-build.js +2 -0
  145. package/node_modules/semver/functions/compare-loose.js +2 -0
  146. package/node_modules/semver/functions/compare.js +2 -0
  147. package/node_modules/semver/functions/diff.js +2 -0
  148. package/node_modules/semver/functions/eq.js +2 -0
  149. package/node_modules/semver/functions/gt.js +2 -0
  150. package/node_modules/semver/functions/gte.js +2 -0
  151. package/node_modules/semver/functions/inc.js +2 -0
  152. package/node_modules/semver/functions/lt.js +2 -0
  153. package/node_modules/semver/functions/lte.js +2 -0
  154. package/node_modules/semver/functions/major.js +2 -0
  155. package/node_modules/semver/functions/minor.js +2 -0
  156. package/node_modules/semver/functions/neq.js +2 -0
  157. package/node_modules/semver/functions/parse.js +2 -0
  158. package/node_modules/semver/functions/patch.js +2 -0
  159. package/node_modules/semver/functions/prerelease.js +2 -0
  160. package/node_modules/semver/functions/rcompare.js +2 -0
  161. package/node_modules/semver/functions/rsort.js +2 -0
  162. package/node_modules/semver/functions/satisfies.js +2 -0
  163. package/node_modules/semver/functions/sort.js +2 -0
  164. package/node_modules/semver/functions/valid.js +2 -0
  165. package/node_modules/semver/index.js +2 -0
  166. package/node_modules/semver/internal/constants.js +2 -0
  167. package/node_modules/semver/internal/debug.js +2 -0
  168. package/node_modules/semver/internal/identifiers.js +2 -0
  169. package/node_modules/semver/internal/lrucache.js +2 -0
  170. package/node_modules/semver/internal/parse-options.js +2 -0
  171. package/node_modules/semver/internal/re.js +8 -4
  172. package/node_modules/semver/package.json +3 -3
  173. package/node_modules/semver/preload.js +2 -0
  174. package/node_modules/semver/ranges/gtr.js +2 -0
  175. package/node_modules/semver/ranges/intersects.js +2 -0
  176. package/node_modules/semver/ranges/ltr.js +2 -0
  177. package/node_modules/semver/ranges/max-satisfying.js +2 -0
  178. package/node_modules/semver/ranges/min-satisfying.js +2 -0
  179. package/node_modules/semver/ranges/min-version.js +2 -0
  180. package/node_modules/semver/ranges/outside.js +2 -0
  181. package/node_modules/semver/ranges/simplify.js +2 -0
  182. package/node_modules/semver/ranges/subset.js +2 -0
  183. package/node_modules/semver/ranges/to-comparators.js +2 -0
  184. package/node_modules/semver/ranges/valid.js +2 -0
  185. package/node_modules/yaml/browser/dist/compose/resolve-props.js +2 -4
  186. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +1 -2
  187. package/node_modules/yaml/browser/dist/doc/anchors.js +1 -2
  188. package/node_modules/yaml/browser/dist/doc/createNode.js +1 -2
  189. package/node_modules/yaml/browser/dist/nodes/Alias.js +24 -11
  190. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +1 -1
  191. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +1 -0
  192. package/node_modules/yaml/browser/dist/schema/tags.js +3 -3
  193. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +1 -2
  194. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +1 -1
  195. package/node_modules/yaml/browser/dist/stringify/stringify.js +3 -4
  196. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +3 -4
  197. package/node_modules/yaml/dist/cli.d.ts +1 -1
  198. package/node_modules/yaml/dist/cli.mjs +5 -3
  199. package/node_modules/yaml/dist/compose/composer.js +1 -1
  200. package/node_modules/yaml/dist/compose/resolve-props.js +2 -4
  201. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +1 -2
  202. package/node_modules/yaml/dist/doc/anchors.js +1 -2
  203. package/node_modules/yaml/dist/doc/createNode.js +1 -2
  204. package/node_modules/yaml/dist/log.js +1 -1
  205. package/node_modules/yaml/dist/nodes/Alias.d.ts +1 -1
  206. package/node_modules/yaml/dist/nodes/Alias.js +23 -10
  207. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +1 -0
  208. package/node_modules/yaml/dist/nodes/toJS.d.ts +2 -0
  209. package/node_modules/yaml/dist/parse/parser.js +1 -1
  210. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +2 -3
  211. package/node_modules/yaml/dist/stringify/stringify.js +3 -4
  212. package/node_modules/yaml/dist/stringify/stringifyString.js +2 -3
  213. package/node_modules/yaml/package.json +2 -2
  214. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import { anchorIsValid } from '../doc/anchors.js';
2
2
  import { visit } from '../visit.js';
3
- import { ALIAS, isAlias, isCollection, isPair } from './identity.js';
3
+ import { ALIAS, isAlias, isCollection, isPair, hasAnchor } from './identity.js';
4
4
  import { NodeBase } from './Node.js';
5
5
  import { toJS } from './toJS.js';
6
6
 
@@ -18,23 +18,36 @@ class Alias extends NodeBase {
18
18
  * Resolve the value of this alias within `doc`, finding the last
19
19
  * instance of the `source` anchor before this node.
20
20
  */
21
- resolve(doc) {
21
+ resolve(doc, ctx) {
22
+ let nodes;
23
+ if (ctx?.aliasResolveCache) {
24
+ nodes = ctx.aliasResolveCache;
25
+ }
26
+ else {
27
+ nodes = [];
28
+ visit(doc, {
29
+ Node: (_key, node) => {
30
+ if (isAlias(node) || hasAnchor(node))
31
+ nodes.push(node);
32
+ }
33
+ });
34
+ if (ctx)
35
+ ctx.aliasResolveCache = nodes;
36
+ }
22
37
  let found = undefined;
23
- visit(doc, {
24
- Node: (_key, node) => {
25
- if (node === this)
26
- return visit.BREAK;
27
- if (node.anchor === this.source)
28
- found = node;
29
- }
30
- });
38
+ for (const node of nodes) {
39
+ if (node === this)
40
+ break;
41
+ if (node.anchor === this.source)
42
+ found = node;
43
+ }
31
44
  return found;
32
45
  }
33
46
  toJSON(_arg, ctx) {
34
47
  if (!ctx)
35
48
  return { source: this.source };
36
49
  const { anchors, doc, maxAliasCount } = ctx;
37
- const source = this.resolve(doc);
50
+ const source = this.resolve(doc, ctx);
38
51
  if (!source) {
39
52
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
40
53
  throw new ReferenceError(msg);
@@ -1,7 +1,7 @@
1
1
  import { stringifyCollection } from '../stringify/stringifyCollection.js';
2
2
  import { addPairToJSMap } from './addPairToJSMap.js';
3
3
  import { Collection } from './Collection.js';
4
- import { isPair, isScalar, MAP } from './identity.js';
4
+ import { MAP, isPair, isScalar } from './identity.js';
5
5
  import { Pair, createPair } from './Pair.js';
6
6
  import { isScalarValue } from './Scalar.js';
7
7
 
@@ -37,6 +37,7 @@ function addPairToJSMap(ctx, map, { key, value }) {
37
37
  function stringifyKey(key, jsKey, ctx) {
38
38
  if (jsKey === null)
39
39
  return '';
40
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
40
41
  if (typeof jsKey !== 'object')
41
42
  return String(jsKey);
42
43
  if (isNode(key) && ctx?.doc) {
@@ -3,8 +3,8 @@ import { nullTag } from './common/null.js';
3
3
  import { seq } from './common/seq.js';
4
4
  import { string } from './common/string.js';
5
5
  import { boolTag } from './core/bool.js';
6
- import { float, floatExp, floatNaN } from './core/float.js';
7
- import { int, intHex, intOct } from './core/int.js';
6
+ import { floatNaN, floatExp, float } from './core/float.js';
7
+ import { intOct, intHex, int } from './core/int.js';
8
8
  import { schema } from './core/schema.js';
9
9
  import { schema as schema$1 } from './json/schema.js';
10
10
  import { binary } from './yaml-1.1/binary.js';
@@ -13,7 +13,7 @@ import { omap } from './yaml-1.1/omap.js';
13
13
  import { pairs } from './yaml-1.1/pairs.js';
14
14
  import { schema as schema$2 } from './yaml-1.1/schema.js';
15
15
  import { set } from './yaml-1.1/set.js';
16
- import { timestamp, floatTime, intTime } from './yaml-1.1/timestamp.js';
16
+ import { timestamp, intTime, floatTime } from './yaml-1.1/timestamp.js';
17
17
 
18
18
  const schemas = new Map([
19
19
  ['core', schema],
@@ -41,8 +41,7 @@ const binary = {
41
41
  else {
42
42
  throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
43
43
  }
44
- if (!type)
45
- type = Scalar.BLOCK_LITERAL;
44
+ type ?? (type = Scalar.BLOCK_LITERAL);
46
45
  if (type !== Scalar.QUOTE_DOUBLE) {
47
46
  const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
48
47
  const n = Math.ceil(str.length / lineWidth);
@@ -1,5 +1,5 @@
1
1
  import { isSeq, isPair, isMap } from '../../nodes/identity.js';
2
- import { Pair, createPair } from '../../nodes/Pair.js';
2
+ import { createPair, Pair } from '../../nodes/Pair.js';
3
3
  import { Scalar } from '../../nodes/Scalar.js';
4
4
  import { YAMLSeq } from '../../nodes/YAMLSeq.js';
5
5
 
@@ -68,7 +68,7 @@ function getTagObject(tags, item) {
68
68
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
69
69
  }
70
70
  if (!tagObj) {
71
- const name = obj?.constructor?.name ?? typeof obj;
71
+ const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
72
72
  throw new Error(`Tag not resolved for ${name} value`);
73
73
  }
74
74
  return tagObj;
@@ -83,7 +83,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
83
83
  anchors.add(anchor);
84
84
  props.push(`&${anchor}`);
85
85
  }
86
- const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
86
+ const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
87
87
  if (tag)
88
88
  props.push(doc.directives.tagString(tag));
89
89
  return props.join(' ');
@@ -109,8 +109,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
109
109
  const node = isNode(item)
110
110
  ? item
111
111
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
112
- if (!tagObj)
113
- tagObj = getTagObject(ctx.doc.schema.tags, node);
112
+ tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
114
113
  const props = stringifyProps(node, tagObj, ctx);
115
114
  if (props.length > 0)
116
115
  ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
@@ -1,5 +1,5 @@
1
1
  import { Scalar } from '../nodes/Scalar.js';
2
- import { foldFlowLines, FOLD_QUOTED, FOLD_FLOW, FOLD_BLOCK } from './foldFlowLines.js';
2
+ import { foldFlowLines, FOLD_FLOW, FOLD_QUOTED, FOLD_BLOCK } from './foldFlowLines.js';
3
3
 
4
4
  const getFoldOptions = (ctx, isBlock) => ({
5
5
  indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
@@ -253,10 +253,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
253
253
  (inFlow && /[[\]{},]/.test(value))) {
254
254
  return quotedString(value, ctx);
255
255
  }
256
- if (!value ||
257
- /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
256
+ if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
258
257
  // not allowed:
259
- // - empty string, '-' or '?'
258
+ // - '-' or '?'
260
259
  // - start with an indicator character (except [?:-]) or /[?-] /
261
260
  // - '\n ', ': ' or ' \n' anywhere
262
261
  // - '#' not preceded by a non-space char
@@ -1,4 +1,4 @@
1
- export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n --indent 2 Output pretty-printed data, indented by the given number of spaces.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)";
1
+ export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n --indent 2 Output pretty-printed data, indented by the given number of spaces.\n --merge, -m Enable support for \"<<\" merge keys.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)";
2
2
  export declare class UserError extends Error {
3
3
  static ARGS: number;
4
4
  static SINGLE: number;
@@ -1,5 +1,5 @@
1
- import { resolve } from 'node:path';
2
- import { parseArgs } from 'node:util';
1
+ import { resolve } from 'path';
2
+ import { parseArgs } from 'util';
3
3
  import { prettyToken } from './parse/cst.js';
4
4
  import { Lexer } from './parse/lexer.js';
5
5
  import { Parser } from './parse/parser.js';
@@ -23,6 +23,7 @@ Options:
23
23
  --help, -h Show this message.
24
24
  --json, -j Output JSON.
25
25
  --indent 2 Output pretty-printed data, indented by the given number of spaces.
26
+ --merge, -m Enable support for "<<" merge keys.
26
27
 
27
28
  Additional options for bare "yaml" command:
28
29
  --doc, -d Output pretty-printed JS Document objects.
@@ -48,6 +49,7 @@ async function cli(stdin, done, argv) {
48
49
  doc: { type: 'boolean', short: 'd' },
49
50
  help: { type: 'boolean', short: 'h' },
50
51
  indent: { type: 'string', short: 'i' },
52
+ merge: { type: 'boolean', short: 'm' },
51
53
  json: { type: 'boolean', short: 'j' },
52
54
  single: { type: 'boolean', short: '1' },
53
55
  strict: { type: 'boolean', short: 's' },
@@ -117,7 +119,7 @@ async function cli(stdin, done, argv) {
117
119
  const lineCounter = new LineCounter();
118
120
  const parser = new Parser(lineCounter.addNewLine);
119
121
  // @ts-expect-error Version is validated at runtime
120
- const composer = new Composer({ version: opt.yaml });
122
+ const composer = new Composer({ version: opt.yaml, merge: opt.merge });
121
123
  const visitor = opt.visit
122
124
  ? (await import(resolve(opt.visit))).default
123
125
  : null;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var node_process = require('node:process');
3
+ var node_process = require('process');
4
4
  var directives = require('../doc/directives.js');
5
5
  var Document = require('../doc/Document.js');
6
6
  var errors = require('../errors.js');
@@ -74,8 +74,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
74
74
  if (token.source.endsWith(':'))
75
75
  onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
76
76
  anchor = token;
77
- if (start === null)
78
- start = token.offset;
77
+ start ?? (start = token.offset);
79
78
  atNewline = false;
80
79
  hasSpace = false;
81
80
  reqSpace = true;
@@ -84,8 +83,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
84
83
  if (tag)
85
84
  onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag');
86
85
  tag = token;
87
- if (start === null)
88
- start = token.offset;
86
+ start ?? (start = token.offset);
89
87
  atNewline = false;
90
88
  hasSpace = false;
91
89
  reqSpace = true;
@@ -2,8 +2,7 @@
2
2
 
3
3
  function emptyScalarPosition(offset, before, pos) {
4
4
  if (before) {
5
- if (pos === null)
6
- pos = before.length;
5
+ pos ?? (pos = before.length);
7
6
  for (let i = pos - 1; i >= 0; --i) {
8
7
  let st = before[i];
9
8
  switch (st.type) {
@@ -41,8 +41,7 @@ function createNodeAnchors(doc, prefix) {
41
41
  return {
42
42
  onAnchor: (source) => {
43
43
  aliasObjects.push(source);
44
- if (!prevAnchors)
45
- prevAnchors = anchorNames(doc);
44
+ prevAnchors ?? (prevAnchors = anchorNames(doc));
46
45
  const anchor = findNewAnchor(prefix, prevAnchors);
47
46
  prevAnchors.add(anchor);
48
47
  return anchor;
@@ -40,8 +40,7 @@ function createNode(value, tagName, ctx) {
40
40
  if (aliasDuplicateObjects && value && typeof value === 'object') {
41
41
  ref = sourceObjects.get(value);
42
42
  if (ref) {
43
- if (!ref.anchor)
44
- ref.anchor = onAnchor(value);
43
+ ref.anchor ?? (ref.anchor = onAnchor(value));
45
44
  return new Alias.Alias(ref.anchor);
46
45
  }
47
46
  else {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var node_process = require('node:process');
3
+ var node_process = require('process');
4
4
 
5
5
  function debug(logLevel, ...messages) {
6
6
  if (logLevel === 'debug')
@@ -23,7 +23,7 @@ export declare class Alias extends NodeBase {
23
23
  * Resolve the value of this alias within `doc`, finding the last
24
24
  * instance of the `source` anchor before this node.
25
25
  */
26
- resolve(doc: Document): Scalar | YAMLMap | YAMLSeq | undefined;
26
+ resolve(doc: Document, ctx?: ToJSContext): Scalar | YAMLMap | YAMLSeq | undefined;
27
27
  toJSON(_arg?: unknown, ctx?: ToJSContext): unknown;
28
28
  toString(ctx?: StringifyContext, _onComment?: () => void, _onChompKeep?: () => void): string;
29
29
  }
@@ -20,23 +20,36 @@ class Alias extends Node.NodeBase {
20
20
  * Resolve the value of this alias within `doc`, finding the last
21
21
  * instance of the `source` anchor before this node.
22
22
  */
23
- resolve(doc) {
23
+ resolve(doc, ctx) {
24
+ let nodes;
25
+ if (ctx?.aliasResolveCache) {
26
+ nodes = ctx.aliasResolveCache;
27
+ }
28
+ else {
29
+ nodes = [];
30
+ visit.visit(doc, {
31
+ Node: (_key, node) => {
32
+ if (identity.isAlias(node) || identity.hasAnchor(node))
33
+ nodes.push(node);
34
+ }
35
+ });
36
+ if (ctx)
37
+ ctx.aliasResolveCache = nodes;
38
+ }
24
39
  let found = undefined;
25
- visit.visit(doc, {
26
- Node: (_key, node) => {
27
- if (node === this)
28
- return visit.visit.BREAK;
29
- if (node.anchor === this.source)
30
- found = node;
31
- }
32
- });
40
+ for (const node of nodes) {
41
+ if (node === this)
42
+ break;
43
+ if (node.anchor === this.source)
44
+ found = node;
45
+ }
33
46
  return found;
34
47
  }
35
48
  toJSON(_arg, ctx) {
36
49
  if (!ctx)
37
50
  return { source: this.source };
38
51
  const { anchors, doc, maxAliasCount } = ctx;
39
- const source = this.resolve(doc);
52
+ const source = this.resolve(doc, ctx);
40
53
  if (!source) {
41
54
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
42
55
  throw new ReferenceError(msg);
@@ -39,6 +39,7 @@ function addPairToJSMap(ctx, map, { key, value }) {
39
39
  function stringifyKey(key, jsKey, ctx) {
40
40
  if (jsKey === null)
41
41
  return '';
42
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
42
43
  if (typeof jsKey !== 'object')
43
44
  return String(jsKey);
44
45
  if (identity.isNode(key) && ctx?.doc) {
@@ -7,6 +7,8 @@ export interface AnchorData {
7
7
  }
8
8
  export interface ToJSContext {
9
9
  anchors: Map<Node, AnchorData>;
10
+ /** Cached anchor and alias nodes in the order they occur in the document */
11
+ aliasResolveCache?: Node[];
10
12
  doc: Document<Node, boolean>;
11
13
  keep: boolean;
12
14
  mapAsMap: boolean;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var node_process = require('node:process');
3
+ var node_process = require('process');
4
4
  var cst = require('./cst.js');
5
5
  var lexer = require('./lexer.js');
6
6
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var node_buffer = require('node:buffer');
3
+ var node_buffer = require('buffer');
4
4
  var Scalar = require('../../nodes/Scalar.js');
5
5
  var stringifyString = require('../../stringify/stringifyString.js');
6
6
 
@@ -53,8 +53,7 @@ const binary = {
53
53
  else {
54
54
  throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
55
55
  }
56
- if (!type)
57
- type = Scalar.Scalar.BLOCK_LITERAL;
56
+ type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
58
57
  if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
59
58
  const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
60
59
  const n = Math.ceil(str.length / lineWidth);
@@ -70,7 +70,7 @@ function getTagObject(tags, item) {
70
70
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
71
71
  }
72
72
  if (!tagObj) {
73
- const name = obj?.constructor?.name ?? typeof obj;
73
+ const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
74
74
  throw new Error(`Tag not resolved for ${name} value`);
75
75
  }
76
76
  return tagObj;
@@ -85,7 +85,7 @@ function stringifyProps(node, tagObj, { anchors: anchors$1, doc }) {
85
85
  anchors$1.add(anchor);
86
86
  props.push(`&${anchor}`);
87
87
  }
88
- const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
88
+ const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
89
89
  if (tag)
90
90
  props.push(doc.directives.tagString(tag));
91
91
  return props.join(' ');
@@ -111,8 +111,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
111
111
  const node = identity.isNode(item)
112
112
  ? item
113
113
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
114
- if (!tagObj)
115
- tagObj = getTagObject(ctx.doc.schema.tags, node);
114
+ tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
116
115
  const props = stringifyProps(node, tagObj, ctx);
117
116
  if (props.length > 0)
118
117
  ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
@@ -255,10 +255,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
255
255
  (inFlow && /[[\]{},]/.test(value))) {
256
256
  return quotedString(value, ctx);
257
257
  }
258
- if (!value ||
259
- /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
258
+ if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
260
259
  // not allowed:
261
- // - empty string, '-' or '?'
260
+ // - '-' or '?'
262
261
  // - start with an indicator character (except [?:-]) or /[?-] /
263
262
  // - '\n ', ': ' or ' \n' anywhere
264
263
  // - '#' not preceded by a non-space char
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaml",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "license": "ISC",
5
5
  "author": "Eemeli Aro <eemeli@gmail.com>",
6
6
  "repository": "github:eemeli/yaml",
@@ -91,6 +91,6 @@
91
91
  "typescript-eslint": "^8.4.0"
92
92
  },
93
93
  "engines": {
94
- "node": ">= 14"
94
+ "node": ">= 14.6"
95
95
  }
96
96
  }
package/package.json CHANGED
@@ -95,7 +95,7 @@
95
95
  "glob": "^8",
96
96
  "ini": "^2.0.0",
97
97
  "parse-conflict-json": "^4.0.0",
98
- "semver": "^7.7.1",
98
+ "semver": "^7.7.2",
99
99
  "shx": "^0.4.0",
100
100
  "xmlbuilder2": "^3.1.1",
101
101
  "yaml": "^2.2.2",
@@ -133,7 +133,7 @@
133
133
  "publishConfig": {
134
134
  "access": "public"
135
135
  },
136
- "version": "0.92.3",
136
+ "version": "0.92.5",
137
137
  "jest": {
138
138
  "coverageProvider": "v8",
139
139
  "coverageReporters": [