projen 0.51.4 → 0.51.8

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 (395) hide show
  1. package/.jsii +69 -9
  2. package/API.md +12 -1
  3. package/changelog.md +1 -1
  4. package/lib/awscdk/auto-discover.js +1 -1
  5. package/lib/awscdk/awscdk-app-java.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 +9 -2
  14. package/lib/awscdk/lambda-function.js +2 -2
  15. package/lib/build/build-workflow.js +1 -1
  16. package/lib/cdk/construct-lib.js +1 -1
  17. package/lib/cdk/jsii-docgen.js +1 -1
  18. package/lib/cdk/jsii-project.js +1 -1
  19. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  20. package/lib/cdk8s/cdk8s-construct.js +1 -1
  21. package/lib/cdktf/cdktf-construct.js +1 -1
  22. package/lib/component.js +1 -1
  23. package/lib/dependencies.js +1 -1
  24. package/lib/dev-env.js +1 -1
  25. package/lib/docker-compose.js +2 -2
  26. package/lib/file.js +1 -1
  27. package/lib/gitattributes.js +1 -1
  28. package/lib/github/auto-approve.js +1 -1
  29. package/lib/github/auto-merge.js +1 -1
  30. package/lib/github/dependabot.js +1 -1
  31. package/lib/github/github-project.js +1 -1
  32. package/lib/github/github.js +1 -1
  33. package/lib/github/mergify.js +1 -1
  34. package/lib/github/pr-template.js +1 -1
  35. package/lib/github/pull-request-lint.js +1 -1
  36. package/lib/github/stale-util.js +12 -7
  37. package/lib/github/stale.d.ts +10 -1
  38. package/lib/github/stale.js +10 -2
  39. package/lib/github/task-workflow.js +1 -1
  40. package/lib/github/workflows.js +1 -1
  41. package/lib/gitlab/configuration.js +1 -1
  42. package/lib/gitlab/gitlab-configuration.js +1 -1
  43. package/lib/gitlab/nested-configuration.js +1 -1
  44. package/lib/gitpod.js +1 -1
  45. package/lib/ignore-file.js +1 -1
  46. package/lib/ini.js +1 -1
  47. package/lib/java/java-project.js +1 -1
  48. package/lib/java/junit.js +1 -1
  49. package/lib/java/maven-compile.js +1 -1
  50. package/lib/java/maven-packaging.js +1 -1
  51. package/lib/java/maven-sample.js +1 -1
  52. package/lib/java/pom.js +1 -1
  53. package/lib/java/projenrc.js +1 -1
  54. package/lib/javascript/bundler.js +1 -1
  55. package/lib/javascript/eslint.js +1 -1
  56. package/lib/javascript/jest.js +1 -1
  57. package/lib/javascript/node-package.js +1 -1
  58. package/lib/javascript/node-project.js +1 -1
  59. package/lib/javascript/npm-config.js +1 -1
  60. package/lib/javascript/prettier.js +1 -1
  61. package/lib/javascript/projenrc.js +1 -1
  62. package/lib/javascript/typescript-config.js +1 -1
  63. package/lib/javascript/upgrade-dependencies.js +2 -2
  64. package/lib/json.js +1 -1
  65. package/lib/license.js +1 -1
  66. package/lib/logger.js +1 -1
  67. package/lib/makefile.js +1 -1
  68. package/lib/object-file.js +1 -1
  69. package/lib/project-build.js +1 -1
  70. package/lib/project.js +1 -1
  71. package/lib/projects.js +1 -1
  72. package/lib/projenrc-json.js +1 -1
  73. package/lib/python/pip.js +1 -1
  74. package/lib/python/poetry.js +2 -2
  75. package/lib/python/projenrc.js +1 -1
  76. package/lib/python/pytest.js +1 -1
  77. package/lib/python/python-project.js +1 -1
  78. package/lib/python/python-sample.js +1 -1
  79. package/lib/python/requirements-file.js +1 -1
  80. package/lib/python/setuppy.js +1 -1
  81. package/lib/python/setuptools.js +1 -1
  82. package/lib/python/venv.js +1 -1
  83. package/lib/readme.js +1 -1
  84. package/lib/release/publisher.js +1 -1
  85. package/lib/release/release-trigger.js +1 -1
  86. package/lib/release/release.js +1 -1
  87. package/lib/sample-file.js +2 -2
  88. package/lib/semver.js +1 -1
  89. package/lib/source-code.js +1 -1
  90. package/lib/task-runtime.js +1 -1
  91. package/lib/task.js +1 -1
  92. package/lib/tasks.js +1 -1
  93. package/lib/testing.js +1 -1
  94. package/lib/textfile.js +1 -1
  95. package/lib/toml.js +1 -1
  96. package/lib/typescript/projenrc.js +1 -1
  97. package/lib/typescript/typescript-typedoc.js +1 -1
  98. package/lib/typescript/typescript.js +3 -3
  99. package/lib/version.js +1 -1
  100. package/lib/vscode/devcontainer.js +1 -1
  101. package/lib/vscode/launch-config.js +1 -1
  102. package/lib/vscode/vscode.js +1 -1
  103. package/lib/web/next.js +3 -3
  104. package/lib/web/postcss.js +1 -1
  105. package/lib/web/react.js +4 -4
  106. package/lib/web/tailwind.js +1 -1
  107. package/lib/xmlfile.js +1 -1
  108. package/lib/yaml.d.ts +13 -0
  109. package/lib/yaml.js +8 -3
  110. package/node_modules/{fs-extra/node_modules/universalify → universalify}/LICENSE +0 -0
  111. package/node_modules/{fs-extra/node_modules/universalify → universalify}/README.md +0 -0
  112. package/node_modules/{fs-extra/node_modules/universalify → universalify}/index.js +0 -0
  113. package/node_modules/{fs-extra/node_modules/universalify → universalify}/package.json +0 -0
  114. package/node_modules/yaml/LICENSE +1 -1
  115. package/node_modules/yaml/README.md +57 -41
  116. package/node_modules/yaml/browser/dist/compose/compose-collection.js +59 -0
  117. package/node_modules/yaml/browser/dist/compose/compose-doc.js +40 -0
  118. package/node_modules/yaml/browser/dist/compose/compose-node.js +81 -0
  119. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +81 -0
  120. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  121. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +107 -0
  122. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +185 -0
  123. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +45 -0
  124. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  125. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +200 -0
  126. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +223 -0
  127. package/node_modules/yaml/browser/dist/compose/resolve-props.js +128 -0
  128. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  129. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +27 -0
  130. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  131. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +17 -0
  132. package/node_modules/yaml/browser/dist/doc/Document.js +321 -0
  133. package/node_modules/yaml/browser/dist/doc/anchors.js +72 -0
  134. package/node_modules/yaml/browser/dist/doc/applyReviver.js +54 -0
  135. package/node_modules/yaml/browser/dist/doc/createNode.js +84 -0
  136. package/node_modules/yaml/browser/dist/doc/directives.js +166 -0
  137. package/node_modules/yaml/browser/dist/errors.js +57 -0
  138. package/node_modules/yaml/browser/dist/index.js +18 -1002
  139. package/node_modules/yaml/browser/dist/log.js +14 -0
  140. package/node_modules/yaml/browser/dist/node_modules/tslib/tslib.es6.js +164 -0
  141. package/node_modules/yaml/browser/dist/nodes/Alias.js +94 -0
  142. package/node_modules/yaml/browser/dist/nodes/Collection.js +146 -0
  143. package/node_modules/yaml/browser/dist/nodes/Node.js +48 -0
  144. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  145. package/node_modules/yaml/browser/dist/nodes/Scalar.js +23 -0
  146. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +116 -0
  147. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +105 -0
  148. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +104 -0
  149. package/node_modules/yaml/browser/dist/nodes/toJS.js +35 -0
  150. package/node_modules/yaml/browser/dist/options.js +18 -0
  151. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +215 -0
  152. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  153. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  154. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  155. package/node_modules/yaml/browser/dist/parse/lexer.js +692 -0
  156. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  157. package/node_modules/yaml/browser/dist/parse/parser.js +882 -0
  158. package/node_modules/yaml/browser/dist/public-api.js +99 -0
  159. package/node_modules/yaml/browser/dist/schema/Schema.js +34 -0
  160. package/node_modules/yaml/browser/dist/schema/common/map.js +42 -0
  161. package/node_modules/yaml/browser/dist/schema/common/null.js +13 -0
  162. package/node_modules/yaml/browser/dist/schema/common/seq.js +33 -0
  163. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  164. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  165. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  166. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  167. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  168. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  169. package/node_modules/yaml/browser/dist/schema/tags.js +83 -0
  170. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +66 -0
  171. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  172. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  173. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  174. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +73 -0
  175. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +77 -0
  176. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +37 -0
  177. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +87 -0
  178. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  179. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +135 -0
  180. package/node_modules/yaml/browser/dist/stringify/stringify.js +124 -0
  181. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +152 -0
  182. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +18 -0
  183. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +68 -0
  184. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +24 -0
  185. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +122 -0
  186. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +314 -0
  187. package/node_modules/yaml/browser/dist/util.js +9 -2
  188. package/node_modules/yaml/browser/dist/visit.js +146 -0
  189. package/node_modules/yaml/browser/index.js +5 -1
  190. package/node_modules/yaml/browser/package.json +3 -0
  191. package/node_modules/yaml/dist/compose/compose-collection.d.ts +5 -0
  192. package/node_modules/yaml/dist/compose/compose-collection.js +61 -0
  193. package/node_modules/yaml/dist/compose/compose-doc.d.ts +6 -0
  194. package/node_modules/yaml/dist/compose/compose-doc.js +42 -0
  195. package/node_modules/yaml/dist/compose/compose-node.d.ts +26 -0
  196. package/node_modules/yaml/dist/compose/compose-node.js +84 -0
  197. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  198. package/node_modules/yaml/dist/compose/compose-scalar.js +83 -0
  199. package/node_modules/yaml/dist/compose/composer.d.ts +62 -0
  200. package/node_modules/yaml/dist/compose/composer.js +223 -0
  201. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  202. package/node_modules/yaml/dist/compose/resolve-block-map.js +109 -0
  203. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +10 -0
  204. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +187 -0
  205. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +5 -0
  206. package/node_modules/yaml/dist/compose/resolve-block-seq.js +47 -0
  207. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  208. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  209. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +6 -0
  210. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +202 -0
  211. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  212. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +225 -0
  213. package/node_modules/yaml/dist/compose/resolve-props.d.ts +21 -0
  214. package/node_modules/yaml/dist/compose/resolve-props.js +130 -0
  215. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  216. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  217. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  218. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +29 -0
  219. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  220. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  221. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  222. package/node_modules/yaml/dist/compose/util-map-includes.js +19 -0
  223. package/node_modules/yaml/dist/doc/Document.d.ts +139 -0
  224. package/node_modules/yaml/dist/doc/Document.js +323 -0
  225. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  226. package/node_modules/yaml/dist/doc/anchors.js +77 -0
  227. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  228. package/node_modules/yaml/dist/doc/applyReviver.js +56 -0
  229. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  230. package/node_modules/yaml/dist/doc/createNode.js +86 -0
  231. package/node_modules/yaml/dist/doc/directives.d.ts +47 -0
  232. package/node_modules/yaml/dist/doc/directives.js +168 -0
  233. package/node_modules/yaml/dist/errors.d.ts +21 -0
  234. package/node_modules/yaml/dist/errors.js +62 -0
  235. package/node_modules/yaml/dist/index.d.ts +19 -0
  236. package/node_modules/yaml/dist/index.js +49 -77
  237. package/node_modules/yaml/dist/log.d.ts +3 -0
  238. package/node_modules/yaml/dist/log.js +17 -0
  239. package/node_modules/yaml/dist/node_modules/tslib/tslib.es6.js +76 -0
  240. package/node_modules/yaml/dist/nodes/Alias.d.ts +28 -0
  241. package/node_modules/yaml/dist/nodes/Alias.js +96 -0
  242. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  243. package/node_modules/yaml/dist/nodes/Collection.js +150 -0
  244. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  245. package/node_modules/yaml/dist/nodes/Node.js +66 -0
  246. package/node_modules/yaml/dist/nodes/Pair.d.ts +21 -0
  247. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  248. package/node_modules/yaml/dist/nodes/Scalar.d.ts +42 -0
  249. package/node_modules/yaml/dist/nodes/Scalar.js +26 -0
  250. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +41 -0
  251. package/node_modules/yaml/dist/nodes/YAMLMap.js +119 -0
  252. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +55 -0
  253. package/node_modules/yaml/dist/nodes/YAMLSeq.js +107 -0
  254. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +3 -0
  255. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +106 -0
  256. package/node_modules/yaml/dist/nodes/toJS.d.ts +30 -0
  257. package/node_modules/yaml/dist/nodes/toJS.js +37 -0
  258. package/node_modules/yaml/dist/options.d.ts +338 -0
  259. package/node_modules/yaml/dist/options.js +20 -0
  260. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  261. package/node_modules/yaml/dist/parse/cst-scalar.js +219 -0
  262. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  263. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  264. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  265. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  266. package/node_modules/yaml/dist/parse/cst.d.ts +106 -0
  267. package/node_modules/yaml/dist/parse/cst.js +112 -0
  268. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  269. package/node_modules/yaml/dist/parse/lexer.js +694 -0
  270. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  271. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  272. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  273. package/node_modules/yaml/dist/parse/parser.js +886 -0
  274. package/node_modules/yaml/dist/public-api.d.ts +43 -0
  275. package/node_modules/yaml/dist/public-api.js +104 -0
  276. package/node_modules/yaml/dist/schema/Schema.d.ts +18 -0
  277. package/node_modules/yaml/dist/schema/Schema.js +36 -0
  278. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  279. package/node_modules/yaml/dist/schema/common/map.js +44 -0
  280. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  281. package/node_modules/yaml/dist/schema/common/null.js +15 -0
  282. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  283. package/node_modules/yaml/dist/schema/common/seq.js +35 -0
  284. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  285. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  286. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  287. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  288. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  289. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  290. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  291. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  292. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  293. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  294. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  295. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  296. package/node_modules/yaml/dist/schema/tags.d.ts +40 -0
  297. package/node_modules/yaml/dist/schema/tags.js +86 -0
  298. package/node_modules/yaml/dist/schema/types.d.ts +82 -0
  299. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  300. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +68 -0
  301. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  302. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  303. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  304. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  305. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  306. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  307. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +21 -0
  308. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +76 -0
  309. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  310. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +81 -0
  311. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  312. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +39 -0
  313. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +22 -0
  314. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +90 -0
  315. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  316. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  317. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  318. package/node_modules/yaml/dist/stringify/foldFlowLines.js +140 -0
  319. package/node_modules/yaml/dist/stringify/stringify.d.ts +20 -0
  320. package/node_modules/yaml/dist/stringify/stringify.js +127 -0
  321. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  322. package/node_modules/yaml/dist/stringify/stringifyCollection.js +154 -0
  323. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  324. package/node_modules/yaml/dist/stringify/stringifyComment.js +22 -0
  325. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +3 -0
  326. package/node_modules/yaml/dist/stringify/stringifyDocument.js +70 -0
  327. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  328. package/node_modules/yaml/dist/stringify/stringifyNumber.js +26 -0
  329. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  330. package/node_modules/yaml/dist/stringify/stringifyPair.js +124 -0
  331. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +3 -0
  332. package/node_modules/yaml/dist/stringify/stringifyString.js +316 -0
  333. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  334. package/node_modules/yaml/dist/test-events.js +126 -152
  335. package/node_modules/yaml/dist/util.d.ts +9 -0
  336. package/node_modules/yaml/dist/util.js +19 -14
  337. package/node_modules/yaml/dist/visit.d.ts +63 -0
  338. package/node_modules/yaml/dist/visit.js +148 -0
  339. package/node_modules/yaml/package.json +43 -55
  340. package/node_modules/yaml/util.d.ts +3 -86
  341. package/node_modules/yaml/util.js +2 -16
  342. package/package.json +3 -3
  343. package/releasetag.txt +1 -1
  344. package/version.txt +1 -1
  345. package/node_modules/jsonfile/node_modules/universalify/LICENSE +0 -20
  346. package/node_modules/jsonfile/node_modules/universalify/README.md +0 -76
  347. package/node_modules/jsonfile/node_modules/universalify/index.js +0 -24
  348. package/node_modules/jsonfile/node_modules/universalify/package.json +0 -34
  349. package/node_modules/yaml/browser/dist/PlainValue-b8036b75.js +0 -1275
  350. package/node_modules/yaml/browser/dist/Schema-e94716c8.js +0 -682
  351. package/node_modules/yaml/browser/dist/legacy-exports.js +0 -3
  352. package/node_modules/yaml/browser/dist/package.json +0 -1
  353. package/node_modules/yaml/browser/dist/parse-cst.js +0 -1904
  354. package/node_modules/yaml/browser/dist/resolveSeq-492ab440.js +0 -2419
  355. package/node_modules/yaml/browser/dist/types.js +0 -4
  356. package/node_modules/yaml/browser/dist/warnings-df54cb69.js +0 -499
  357. package/node_modules/yaml/browser/map.js +0 -2
  358. package/node_modules/yaml/browser/pair.js +0 -2
  359. package/node_modules/yaml/browser/parse-cst.js +0 -1
  360. package/node_modules/yaml/browser/scalar.js +0 -2
  361. package/node_modules/yaml/browser/schema.js +0 -9
  362. package/node_modules/yaml/browser/seq.js +0 -2
  363. package/node_modules/yaml/browser/types/binary.js +0 -8
  364. package/node_modules/yaml/browser/types/omap.js +0 -3
  365. package/node_modules/yaml/browser/types/pairs.js +0 -3
  366. package/node_modules/yaml/browser/types/set.js +0 -3
  367. package/node_modules/yaml/browser/types/timestamp.js +0 -10
  368. package/node_modules/yaml/browser/types.js +0 -1
  369. package/node_modules/yaml/browser/util.js +0 -1
  370. package/node_modules/yaml/dist/Document-9b4560a1.js +0 -757
  371. package/node_modules/yaml/dist/PlainValue-ec8e588e.js +0 -876
  372. package/node_modules/yaml/dist/Schema-88e323a7.js +0 -525
  373. package/node_modules/yaml/dist/legacy-exports.js +0 -16
  374. package/node_modules/yaml/dist/parse-cst.js +0 -1753
  375. package/node_modules/yaml/dist/resolveSeq-d03cb037.js +0 -2161
  376. package/node_modules/yaml/dist/types.js +0 -23
  377. package/node_modules/yaml/dist/warnings-1000a372.js +0 -416
  378. package/node_modules/yaml/index.d.ts +0 -372
  379. package/node_modules/yaml/index.js +0 -1
  380. package/node_modules/yaml/map.js +0 -2
  381. package/node_modules/yaml/pair.js +0 -2
  382. package/node_modules/yaml/parse-cst.d.ts +0 -191
  383. package/node_modules/yaml/parse-cst.js +0 -1
  384. package/node_modules/yaml/scalar.js +0 -2
  385. package/node_modules/yaml/schema.js +0 -9
  386. package/node_modules/yaml/seq.js +0 -2
  387. package/node_modules/yaml/types/binary.js +0 -8
  388. package/node_modules/yaml/types/omap.js +0 -3
  389. package/node_modules/yaml/types/pairs.js +0 -3
  390. package/node_modules/yaml/types/set.js +0 -3
  391. package/node_modules/yaml/types/timestamp.js +0 -10
  392. package/node_modules/yaml/types.d.ts +0 -407
  393. package/node_modules/yaml/types.js +0 -17
  394. package/node_modules/yaml/types.mjs +0 -17
  395. package/node_modules/yaml/util.mjs +0 -18
@@ -0,0 +1,105 @@
1
+ import { stringifyCollection } from '../stringify/stringifyCollection.js';
2
+ import { Collection } from './Collection.js';
3
+ import { SEQ, isScalar } from './Node.js';
4
+ import { isScalarValue } from './Scalar.js';
5
+ import { toJS } from './toJS.js';
6
+
7
+ class YAMLSeq extends Collection {
8
+ constructor(schema) {
9
+ super(SEQ, schema);
10
+ this.items = [];
11
+ }
12
+ static get tagName() {
13
+ return 'tag:yaml.org,2002:seq';
14
+ }
15
+ add(value) {
16
+ this.items.push(value);
17
+ }
18
+ /**
19
+ * Removes a value from the collection.
20
+ *
21
+ * `key` must contain a representation of an integer for this to succeed.
22
+ * It may be wrapped in a `Scalar`.
23
+ *
24
+ * @returns `true` if the item was found and removed.
25
+ */
26
+ delete(key) {
27
+ const idx = asItemIndex(key);
28
+ if (typeof idx !== 'number')
29
+ return false;
30
+ const del = this.items.splice(idx, 1);
31
+ return del.length > 0;
32
+ }
33
+ /**
34
+ * Returns item at `key`, or `undefined` if not found. By default unwraps
35
+ * scalar values from their surrounding node; to disable set `keepScalar` to
36
+ * `true` (collections are always returned intact).
37
+ *
38
+ * `key` must contain a representation of an integer for this to succeed.
39
+ * It may be wrapped in a `Scalar`.
40
+ */
41
+ get(key, keepScalar) {
42
+ const idx = asItemIndex(key);
43
+ if (typeof idx !== 'number')
44
+ return undefined;
45
+ const it = this.items[idx];
46
+ return !keepScalar && isScalar(it) ? it.value : it;
47
+ }
48
+ /**
49
+ * Checks if the collection includes a value with the key `key`.
50
+ *
51
+ * `key` must contain a representation of an integer for this to succeed.
52
+ * It may be wrapped in a `Scalar`.
53
+ */
54
+ has(key) {
55
+ const idx = asItemIndex(key);
56
+ return typeof idx === 'number' && idx < this.items.length;
57
+ }
58
+ /**
59
+ * Sets a value in this collection. For `!!set`, `value` needs to be a
60
+ * boolean to add/remove the item from the set.
61
+ *
62
+ * If `key` does not contain a representation of an integer, this will throw.
63
+ * It may be wrapped in a `Scalar`.
64
+ */
65
+ set(key, value) {
66
+ const idx = asItemIndex(key);
67
+ if (typeof idx !== 'number')
68
+ throw new Error(`Expected a valid index, not ${key}.`);
69
+ const prev = this.items[idx];
70
+ if (isScalar(prev) && isScalarValue(value))
71
+ prev.value = value;
72
+ else
73
+ this.items[idx] = value;
74
+ }
75
+ toJSON(_, ctx) {
76
+ const seq = [];
77
+ if (ctx && ctx.onCreate)
78
+ ctx.onCreate(seq);
79
+ let i = 0;
80
+ for (const item of this.items)
81
+ seq.push(toJS(item, String(i++), ctx));
82
+ return seq;
83
+ }
84
+ toString(ctx, onComment, onChompKeep) {
85
+ if (!ctx)
86
+ return JSON.stringify(this);
87
+ return stringifyCollection(this, ctx, {
88
+ blockItemPrefix: '- ',
89
+ flowChars: { start: '[', end: ']' },
90
+ itemIndent: (ctx.indent || '') + ' ',
91
+ onChompKeep,
92
+ onComment
93
+ });
94
+ }
95
+ }
96
+ function asItemIndex(key) {
97
+ let idx = isScalar(key) ? key.value : key;
98
+ if (idx && typeof idx === 'string')
99
+ idx = Number(idx);
100
+ return typeof idx === 'number' && Number.isInteger(idx) && idx >= 0
101
+ ? idx
102
+ : null;
103
+ }
104
+
105
+ export { YAMLSeq };
@@ -0,0 +1,104 @@
1
+ import { warn } from '../log.js';
2
+ import { createStringifyContext } from '../stringify/stringify.js';
3
+ import { isAlias, isSeq, isScalar, isMap, isNode } from './Node.js';
4
+ import { Scalar } from './Scalar.js';
5
+ import { toJS } from './toJS.js';
6
+
7
+ const MERGE_KEY = '<<';
8
+ function addPairToJSMap(ctx, map, { key, value }) {
9
+ if (ctx && ctx.doc.schema.merge && isMergeKey(key)) {
10
+ value = isAlias(value) ? value.resolve(ctx.doc) : value;
11
+ if (isSeq(value))
12
+ for (const it of value.items)
13
+ mergeToJSMap(ctx, map, it);
14
+ else if (Array.isArray(value))
15
+ for (const it of value)
16
+ mergeToJSMap(ctx, map, it);
17
+ else
18
+ mergeToJSMap(ctx, map, value);
19
+ }
20
+ else {
21
+ const jsKey = toJS(key, '', ctx);
22
+ if (map instanceof Map) {
23
+ map.set(jsKey, toJS(value, jsKey, ctx));
24
+ }
25
+ else if (map instanceof Set) {
26
+ map.add(jsKey);
27
+ }
28
+ else {
29
+ const stringKey = stringifyKey(key, jsKey, ctx);
30
+ const jsValue = toJS(value, stringKey, ctx);
31
+ if (stringKey in map)
32
+ Object.defineProperty(map, stringKey, {
33
+ value: jsValue,
34
+ writable: true,
35
+ enumerable: true,
36
+ configurable: true
37
+ });
38
+ else
39
+ map[stringKey] = jsValue;
40
+ }
41
+ }
42
+ return map;
43
+ }
44
+ const isMergeKey = (key) => key === MERGE_KEY ||
45
+ (isScalar(key) &&
46
+ key.value === MERGE_KEY &&
47
+ (!key.type || key.type === Scalar.PLAIN));
48
+ // If the value associated with a merge key is a single mapping node, each of
49
+ // its key/value pairs is inserted into the current mapping, unless the key
50
+ // already exists in it. If the value associated with the merge key is a
51
+ // sequence, then this sequence is expected to contain mapping nodes and each
52
+ // of these nodes is merged in turn according to its order in the sequence.
53
+ // Keys in mapping nodes earlier in the sequence override keys specified in
54
+ // later mapping nodes. -- http://yaml.org/type/merge.html
55
+ function mergeToJSMap(ctx, map, value) {
56
+ const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
57
+ if (!isMap(source))
58
+ throw new Error('Merge sources must be maps or map aliases');
59
+ const srcMap = source.toJSON(null, ctx, Map);
60
+ for (const [key, value] of srcMap) {
61
+ if (map instanceof Map) {
62
+ if (!map.has(key))
63
+ map.set(key, value);
64
+ }
65
+ else if (map instanceof Set) {
66
+ map.add(key);
67
+ }
68
+ else if (!Object.prototype.hasOwnProperty.call(map, key)) {
69
+ Object.defineProperty(map, key, {
70
+ value,
71
+ writable: true,
72
+ enumerable: true,
73
+ configurable: true
74
+ });
75
+ }
76
+ }
77
+ return map;
78
+ }
79
+ function stringifyKey(key, jsKey, ctx) {
80
+ if (jsKey === null)
81
+ return '';
82
+ if (typeof jsKey !== 'object')
83
+ return String(jsKey);
84
+ if (isNode(key) && ctx && ctx.doc) {
85
+ const strCtx = createStringifyContext(ctx.doc, {});
86
+ strCtx.anchors = new Set();
87
+ for (const node of ctx.anchors.keys())
88
+ strCtx.anchors.add(node.anchor);
89
+ strCtx.inFlow = true;
90
+ strCtx.inStringifyKey = true;
91
+ const strKey = key.toString(strCtx);
92
+ if (!ctx.mapKeyWarned) {
93
+ let jsonStr = JSON.stringify(strKey);
94
+ if (jsonStr.length > 40)
95
+ jsonStr = jsonStr.substring(0, 36) + '..."';
96
+ warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
97
+ ctx.mapKeyWarned = true;
98
+ }
99
+ return strKey;
100
+ }
101
+ return JSON.stringify(jsKey);
102
+ }
103
+
104
+ export { addPairToJSMap };
@@ -0,0 +1,35 @@
1
+ import { hasAnchor } from './Node.js';
2
+
3
+ /**
4
+ * Recursively convert any node or its contents to native JavaScript
5
+ *
6
+ * @param value - The input value
7
+ * @param arg - If `value` defines a `toJSON()` method, use this
8
+ * as its first argument
9
+ * @param ctx - Conversion context, originally set in Document#toJS(). If
10
+ * `{ keep: true }` is not set, output should be suitable for JSON
11
+ * stringification.
12
+ */
13
+ function toJS(value, arg, ctx) {
14
+ if (Array.isArray(value))
15
+ return value.map((v, i) => toJS(v, String(i), ctx));
16
+ if (value && typeof value.toJSON === 'function') {
17
+ if (!ctx || !hasAnchor(value))
18
+ return value.toJSON(arg, ctx);
19
+ const data = { aliasCount: 0, count: 1, res: undefined };
20
+ ctx.anchors.set(value, data);
21
+ ctx.onCreate = res => {
22
+ data.res = res;
23
+ delete ctx.onCreate;
24
+ };
25
+ const res = value.toJSON(arg, ctx);
26
+ if (ctx.onCreate)
27
+ ctx.onCreate(res);
28
+ return res;
29
+ }
30
+ if (typeof value === 'bigint' && !(ctx && ctx.keep))
31
+ return Number(value);
32
+ return value;
33
+ }
34
+
35
+ export { toJS };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `yaml` defines document-specific options in three places: as an argument of
3
+ * parse, create and stringify calls, in the values of `YAML.defaultOptions`,
4
+ * and in the version-dependent `YAML.Document.defaults` object. Values set in
5
+ * `YAML.defaultOptions` override version-dependent defaults, and argument
6
+ * options override both.
7
+ */
8
+ const defaultOptions = {
9
+ intAsBigInt: false,
10
+ keepSourceTokens: false,
11
+ logLevel: 'warn',
12
+ prettyErrors: true,
13
+ strict: true,
14
+ uniqueKeys: true,
15
+ version: '1.2'
16
+ };
17
+
18
+ export { defaultOptions };
@@ -0,0 +1,215 @@
1
+ import { resolveBlockScalar } from '../compose/resolve-block-scalar.js';
2
+ import { resolveFlowScalar } from '../compose/resolve-flow-scalar.js';
3
+ import { YAMLParseError } from '../errors.js';
4
+ import { stringifyString } from '../stringify/stringifyString.js';
5
+
6
+ function resolveAsScalar(token, strict = true, onError) {
7
+ if (token) {
8
+ const _onError = (pos, code, message) => {
9
+ const offset = typeof pos === 'number' ? pos : Array.isArray(pos) ? pos[0] : pos.offset;
10
+ if (onError)
11
+ onError(offset, code, message);
12
+ else
13
+ throw new YAMLParseError([offset, offset + 1], code, message);
14
+ };
15
+ switch (token.type) {
16
+ case 'scalar':
17
+ case 'single-quoted-scalar':
18
+ case 'double-quoted-scalar':
19
+ return resolveFlowScalar(token, strict, _onError);
20
+ case 'block-scalar':
21
+ return resolveBlockScalar(token, strict, _onError);
22
+ }
23
+ }
24
+ return null;
25
+ }
26
+ /**
27
+ * Create a new scalar token with `value`
28
+ *
29
+ * Values that represent an actual string but may be parsed as a different type should use a `type` other than `'PLAIN'`,
30
+ * as this function does not support any schema operations and won't check for such conflicts.
31
+ *
32
+ * @param value The string representation of the value, which will have its content properly indented.
33
+ * @param context.end Comments and whitespace after the end of the value, or after the block scalar header. If undefined, a newline will be added.
34
+ * @param context.implicitKey Being within an implicit key may affect the resolved type of the token's value.
35
+ * @param context.indent The indent level of the token.
36
+ * @param context.inFlow Is this scalar within a flow collection? This may affect the resolved type of the token's value.
37
+ * @param context.offset The offset position of the token.
38
+ * @param context.type The preferred type of the scalar token. If undefined, the previous type of the `token` will be used, defaulting to `'PLAIN'`.
39
+ */
40
+ function createScalarToken(value, context) {
41
+ var _a;
42
+ const { implicitKey = false, indent, inFlow = false, offset = -1, type = 'PLAIN' } = context;
43
+ const source = stringifyString({ type, value }, {
44
+ implicitKey,
45
+ indent: indent > 0 ? ' '.repeat(indent) : '',
46
+ inFlow,
47
+ options: { blockQuote: true, lineWidth: -1 }
48
+ });
49
+ const end = (_a = context.end) !== null && _a !== void 0 ? _a : [
50
+ { type: 'newline', offset: -1, indent, source: '\n' }
51
+ ];
52
+ switch (source[0]) {
53
+ case '|':
54
+ case '>': {
55
+ const he = source.indexOf('\n');
56
+ const head = source.substring(0, he);
57
+ const body = source.substring(he + 1) + '\n';
58
+ const props = [
59
+ { type: 'block-scalar-header', offset, indent, source: head }
60
+ ];
61
+ if (!addEndtoBlockProps(props, end))
62
+ props.push({ type: 'newline', offset: -1, indent, source: '\n' });
63
+ return { type: 'block-scalar', offset, indent, props, source: body };
64
+ }
65
+ case '"':
66
+ return { type: 'double-quoted-scalar', offset, indent, source, end };
67
+ case "'":
68
+ return { type: 'single-quoted-scalar', offset, indent, source, end };
69
+ default:
70
+ return { type: 'scalar', offset, indent, source, end };
71
+ }
72
+ }
73
+ /**
74
+ * Set the value of `token` to the given string `value`, overwriting any previous contents and type that it may have.
75
+ *
76
+ * Best efforts are made to retain any comments previously associated with the `token`,
77
+ * though all contents within a collection's `items` will be overwritten.
78
+ *
79
+ * Values that represent an actual string but may be parsed as a different type should use a `type` other than `'PLAIN'`,
80
+ * as this function does not support any schema operations and won't check for such conflicts.
81
+ *
82
+ * @param token Any token. If it does not include an `indent` value, the value will be stringified as if it were an implicit key.
83
+ * @param value The string representation of the value, which will have its content properly indented.
84
+ * @param context.afterKey In most cases, values after a key should have an additional level of indentation.
85
+ * @param context.implicitKey Being within an implicit key may affect the resolved type of the token's value.
86
+ * @param context.inFlow Being within a flow collection may affect the resolved type of the token's value.
87
+ * @param context.type The preferred type of the scalar token. If undefined, the previous type of the `token` will be used, defaulting to `'PLAIN'`.
88
+ */
89
+ function setScalarValue(token, value, context = {}) {
90
+ let { afterKey = false, implicitKey = false, inFlow = false, type } = context;
91
+ let indent = 'indent' in token ? token.indent : null;
92
+ if (afterKey && typeof indent === 'number')
93
+ indent += 2;
94
+ if (!type)
95
+ switch (token.type) {
96
+ case 'single-quoted-scalar':
97
+ type = 'QUOTE_SINGLE';
98
+ break;
99
+ case 'double-quoted-scalar':
100
+ type = 'QUOTE_DOUBLE';
101
+ break;
102
+ case 'block-scalar': {
103
+ const header = token.props[0];
104
+ if (header.type !== 'block-scalar-header')
105
+ throw new Error('Invalid block scalar header');
106
+ type = header.source[0] === '>' ? 'BLOCK_FOLDED' : 'BLOCK_LITERAL';
107
+ break;
108
+ }
109
+ default:
110
+ type = 'PLAIN';
111
+ }
112
+ const source = stringifyString({ type, value }, {
113
+ implicitKey: implicitKey || indent === null,
114
+ indent: indent !== null && indent > 0 ? ' '.repeat(indent) : '',
115
+ inFlow,
116
+ options: { blockQuote: true, lineWidth: -1 }
117
+ });
118
+ switch (source[0]) {
119
+ case '|':
120
+ case '>':
121
+ setBlockScalarValue(token, source);
122
+ break;
123
+ case '"':
124
+ setFlowScalarValue(token, source, 'double-quoted-scalar');
125
+ break;
126
+ case "'":
127
+ setFlowScalarValue(token, source, 'single-quoted-scalar');
128
+ break;
129
+ default:
130
+ setFlowScalarValue(token, source, 'scalar');
131
+ }
132
+ }
133
+ function setBlockScalarValue(token, source) {
134
+ const he = source.indexOf('\n');
135
+ const head = source.substring(0, he);
136
+ const body = source.substring(he + 1) + '\n';
137
+ if (token.type === 'block-scalar') {
138
+ const header = token.props[0];
139
+ if (header.type !== 'block-scalar-header')
140
+ throw new Error('Invalid block scalar header');
141
+ header.source = head;
142
+ token.source = body;
143
+ }
144
+ else {
145
+ const { offset } = token;
146
+ const indent = 'indent' in token ? token.indent : -1;
147
+ const props = [
148
+ { type: 'block-scalar-header', offset, indent, source: head }
149
+ ];
150
+ if (!addEndtoBlockProps(props, 'end' in token ? token.end : undefined))
151
+ props.push({ type: 'newline', offset: -1, indent, source: '\n' });
152
+ for (const key of Object.keys(token))
153
+ if (key !== 'type' && key !== 'offset')
154
+ delete token[key];
155
+ Object.assign(token, { type: 'block-scalar', indent, props, source: body });
156
+ }
157
+ }
158
+ /** @returns `true` if last token is a newline */
159
+ function addEndtoBlockProps(props, end) {
160
+ if (end)
161
+ for (const st of end)
162
+ switch (st.type) {
163
+ case 'space':
164
+ case 'comment':
165
+ props.push(st);
166
+ break;
167
+ case 'newline':
168
+ props.push(st);
169
+ return true;
170
+ }
171
+ return false;
172
+ }
173
+ function setFlowScalarValue(token, source, type) {
174
+ switch (token.type) {
175
+ case 'scalar':
176
+ case 'double-quoted-scalar':
177
+ case 'single-quoted-scalar':
178
+ token.type = type;
179
+ token.source = source;
180
+ break;
181
+ case 'block-scalar': {
182
+ const end = token.props.slice(1);
183
+ let oa = source.length;
184
+ if (token.props[0].type === 'block-scalar-header')
185
+ oa -= token.props[0].source.length;
186
+ for (const tok of end)
187
+ tok.offset += oa;
188
+ delete token.props;
189
+ Object.assign(token, { type, source, end });
190
+ break;
191
+ }
192
+ case 'block-map':
193
+ case 'block-seq': {
194
+ const offset = token.offset + source.length;
195
+ const nl = { type: 'newline', offset, indent: token.indent, source: '\n' };
196
+ delete token.items;
197
+ Object.assign(token, { type, source, end: [nl] });
198
+ break;
199
+ }
200
+ default: {
201
+ const indent = 'indent' in token ? token.indent : -1;
202
+ const end = 'end' in token && Array.isArray(token.end)
203
+ ? token.end.filter(st => st.type === 'space' ||
204
+ st.type === 'comment' ||
205
+ st.type === 'newline')
206
+ : [];
207
+ for (const key of Object.keys(token))
208
+ if (key !== 'type' && key !== 'offset')
209
+ delete token[key];
210
+ Object.assign(token, { type, indent, source, end });
211
+ }
212
+ }
213
+ }
214
+
215
+ export { createScalarToken, resolveAsScalar, setScalarValue };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Stringify a CST document, token, or collection item
3
+ *
4
+ * Fair warning: This applies no validation whatsoever, and
5
+ * simply concatenates the sources in their logical order.
6
+ */
7
+ const stringify = (cst) => 'type' in cst ? stringifyToken(cst) : stringifyItem(cst);
8
+ function stringifyToken(token) {
9
+ switch (token.type) {
10
+ case 'block-scalar': {
11
+ let res = '';
12
+ for (const tok of token.props)
13
+ res += stringifyToken(tok);
14
+ return res + token.source;
15
+ }
16
+ case 'block-map':
17
+ case 'block-seq': {
18
+ let res = '';
19
+ for (const item of token.items)
20
+ res += stringifyItem(item);
21
+ return res;
22
+ }
23
+ case 'flow-collection': {
24
+ let res = token.start.source;
25
+ for (const item of token.items)
26
+ res += stringifyItem(item);
27
+ for (const st of token.end)
28
+ res += st.source;
29
+ return res;
30
+ }
31
+ case 'document': {
32
+ let res = stringifyItem(token);
33
+ if (token.end)
34
+ for (const st of token.end)
35
+ res += st.source;
36
+ return res;
37
+ }
38
+ default: {
39
+ let res = token.source;
40
+ if ('end' in token && token.end)
41
+ for (const st of token.end)
42
+ res += st.source;
43
+ return res;
44
+ }
45
+ }
46
+ }
47
+ function stringifyItem({ start, key, sep, value }) {
48
+ let res = '';
49
+ for (const st of start)
50
+ res += st.source;
51
+ if (key)
52
+ res += stringifyToken(key);
53
+ if (sep)
54
+ for (const st of sep)
55
+ res += st.source;
56
+ if (value)
57
+ res += stringifyToken(value);
58
+ return res;
59
+ }
60
+
61
+ export { stringify };
@@ -0,0 +1,97 @@
1
+ const BREAK = Symbol('break visit');
2
+ const SKIP = Symbol('skip children');
3
+ const REMOVE = Symbol('remove item');
4
+ /**
5
+ * Apply a visitor to a CST document or item.
6
+ *
7
+ * Walks through the tree (depth-first) starting from the root, calling a
8
+ * `visitor` function with two arguments when entering each item:
9
+ * - `item`: The current item, which included the following members:
10
+ * - `start: SourceToken[]` – Source tokens before the key or value,
11
+ * possibly including its anchor or tag.
12
+ * - `key?: Token | null` – Set for pair values. May then be `null`, if
13
+ * the key before the `:` separator is empty.
14
+ * - `sep?: SourceToken[]` – Source tokens between the key and the value,
15
+ * which should include the `:` map value indicator if `value` is set.
16
+ * - `value?: Token` – The value of a sequence item, or of a map pair.
17
+ * - `path`: The steps from the root to the current node, as an array of
18
+ * `['key' | 'value', number]` tuples.
19
+ *
20
+ * The return value of the visitor may be used to control the traversal:
21
+ * - `undefined` (default): Do nothing and continue
22
+ * - `visit.SKIP`: Do not visit the children of this token, continue with
23
+ * next sibling
24
+ * - `visit.BREAK`: Terminate traversal completely
25
+ * - `visit.REMOVE`: Remove the current item, then continue with the next one
26
+ * - `number`: Set the index of the next step. This is useful especially if
27
+ * the index of the current token has changed.
28
+ * - `function`: Define the next visitor for this item. After the original
29
+ * visitor is called on item entry, next visitors are called after handling
30
+ * a non-empty `key` and when exiting the item.
31
+ */
32
+ function visit(cst, visitor) {
33
+ if ('type' in cst && cst.type === 'document')
34
+ cst = { start: cst.start, value: cst.value };
35
+ _visit(Object.freeze([]), cst, visitor);
36
+ }
37
+ // Without the `as symbol` casts, TS declares these in the `visit`
38
+ // namespace using `var`, but then complains about that because
39
+ // `unique symbol` must be `const`.
40
+ /** Terminate visit traversal completely */
41
+ visit.BREAK = BREAK;
42
+ /** Do not visit the children of the current item */
43
+ visit.SKIP = SKIP;
44
+ /** Remove the current item */
45
+ visit.REMOVE = REMOVE;
46
+ /** Find the item at `path` from `cst` as the root */
47
+ visit.itemAtPath = (cst, path) => {
48
+ let item = cst;
49
+ for (const [field, index] of path) {
50
+ const tok = item && item[field];
51
+ if (tok && 'items' in tok) {
52
+ item = tok.items[index];
53
+ }
54
+ else
55
+ return undefined;
56
+ }
57
+ return item;
58
+ };
59
+ /**
60
+ * Get the immediate parent collection of the item at `path` from `cst` as the root.
61
+ *
62
+ * Throws an error if the collection is not found, which should never happen if the item itself exists.
63
+ */
64
+ visit.parentCollection = (cst, path) => {
65
+ const parent = visit.itemAtPath(cst, path.slice(0, -1));
66
+ const field = path[path.length - 1][0];
67
+ const coll = parent && parent[field];
68
+ if (coll && 'items' in coll)
69
+ return coll;
70
+ throw new Error('Parent collection not found');
71
+ };
72
+ function _visit(path, item, visitor) {
73
+ let ctrl = visitor(item, path);
74
+ if (typeof ctrl === 'symbol')
75
+ return ctrl;
76
+ for (const field of ['key', 'value']) {
77
+ const token = item[field];
78
+ if (token && 'items' in token) {
79
+ for (let i = 0; i < token.items.length; ++i) {
80
+ const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
81
+ if (typeof ci === 'number')
82
+ i = ci - 1;
83
+ else if (ci === BREAK)
84
+ return BREAK;
85
+ else if (ci === REMOVE) {
86
+ token.items.splice(i, 1);
87
+ i -= 1;
88
+ }
89
+ }
90
+ if (typeof ctrl === 'function' && field === 'key')
91
+ ctrl = ctrl(item, path);
92
+ }
93
+ }
94
+ return typeof ctrl === 'function' ? ctrl(item, path) : ctrl;
95
+ }
96
+
97
+ export { visit };