diff --git a/dist/index.js b/dist/index.js index 39242224d..42a1efcd5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -63614,10 +63614,23 @@ function resolveCollection(CN, ctx, token, onError, tagName, tag) { coll.tag = tagName; return coll; } -function composeCollection(CN, ctx, token, tagToken, onError) { +function composeCollection(CN, ctx, token, props, onError) { + const tagToken = props.tag; const tagName = !tagToken ? null : ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg)); + if (token.type === 'block-seq') { + const { anchor, newlineAfterProp: nl } = props; + const lastProp = anchor && tagToken + ? anchor.offset > tagToken.offset + ? anchor + : tagToken + : (anchor ?? tagToken); + if (lastProp && (!nl || nl.offset < lastProp.offset)) { + const message = 'Missing newline after block sequence props'; + onError(lastProp, 'MISSING_CHAR', message); + } + } const expType = token.type === 'block-map' ? 'map' : token.type === 'block-seq' @@ -63631,8 +63644,7 @@ function composeCollection(CN, ctx, token, tagToken, onError) { !tagName || tagName === '!' || (tagName === YAMLMap.YAMLMap.tagName && expType === 'map') || - (tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq') || - !expType) { + (tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq')) { return resolveCollection(CN, ctx, token, onError, tagName); } let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType); @@ -63755,7 +63767,7 @@ function composeNode(ctx, token, props, onError) { case 'block-map': case 'block-seq': case 'flow-collection': - node = composeCollection.composeCollection(CN, ctx, token, tag, onError); + node = composeCollection.composeCollection(CN, ctx, token, props, onError); if (anchor) node.anchor = anchor.source.substring(1); break; @@ -64193,7 +64205,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta } continue; } - if (keyProps.hasNewlineAfterProp || utilContainsNewline.containsNewline(key)) { + if (keyProps.newlineAfterProp || utilContainsNewline.containsNewline(key)) { onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); } } @@ -65035,11 +65047,11 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn let comment = ''; let commentSep = ''; let hasNewline = false; - let hasNewlineAfterProp = false; let reqSpace = false; let tab = null; let anchor = null; let tag = null; + let newlineAfterProp = null; let comma = null; let found = null; let start = null; @@ -65093,7 +65105,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn atNewline = true; hasNewline = true; if (anchor || tag) - hasNewlineAfterProp = true; + newlineAfterProp = token; hasSpace = true; break; case 'anchor': @@ -65167,9 +65179,9 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn spaceBefore, comment, hasNewline, - hasNewlineAfterProp, anchor, tag, + newlineAfterProp, end, start: start ?? end }; @@ -66508,7 +66520,6 @@ class Collection extends Node.NodeBase { } } } -Collection.maxFlowStringSingleLineLength = 60; exports.Collection = Collection; exports.collectionFromPath = collectionFromPath; @@ -67969,15 +67980,11 @@ class Lexer { if (!this.atEnd && !this.hasChars(4)) return this.setNext('line-start'); const s = this.peek(3); - if (s === '---' && isEmpty(this.charAt(3))) { + if ((s === '---' || s === '...') && isEmpty(this.charAt(3))) { yield* this.pushCount(3); this.indentValue = 0; this.indentNext = 0; - return 'doc'; - } - else if (s === '...' && isEmpty(this.charAt(3))) { - yield* this.pushCount(3); - return 'stream'; + return s === '---' ? 'doc' : 'stream'; } } this.indentValue = yield* this.pushSpaces(false); @@ -70722,6 +70729,8 @@ const FOLD_QUOTED = 'quoted'; function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) { if (!lineWidth || lineWidth < 0) return text; + if (lineWidth < minContentWidth) + minContentWidth = 0; const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); if (text.length <= endStep) return text; diff --git a/package-lock.json b/package-lock.json index 0ba8e913a..b7d4eab4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@actions/core": "^1.10.1", "@aws-sdk/client-codedeploy": "^3.598.0", "@aws-sdk/client-ecs": "^3.594.0", - "yaml": "^2.4.5" + "yaml": "^2.5.0" }, "devDependencies": { "@eslint/js": "^9.6.0", @@ -6082,9 +6082,9 @@ "dev": true }, "node_modules/yaml": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.5.tgz", - "integrity": "sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", + "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", "bin": { "yaml": "bin.mjs" }, diff --git a/package.json b/package.json index 1c8f08214..addeaa07b 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@actions/core": "^1.10.1", "@aws-sdk/client-codedeploy": "^3.598.0", "@aws-sdk/client-ecs": "^3.594.0", - "yaml": "^2.4.5" + "yaml": "^2.5.0" }, "devDependencies": { "@eslint/js": "^9.6.0",