chore: move @ts-dev-tools to dev deps
Some checks are pending
Internal - Main - Continuous Integration / ci (push) Waiting to run
Internal - Main - Continuous Integration / generate-readme (push) Blocked by required conditions

Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
This commit is contained in:
Emilien Escalle 2025-01-17 18:40:28 +01:00 committed by Emilien Escalle
parent e31e0d5fed
commit c4adfb9283
4 changed files with 1739 additions and 1218 deletions

269
dist/index.js generated vendored
View File

@ -36082,6 +36082,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
const opts = Object.assign({ _directives: directives }, options);
const doc = new Document.Document(undefined, opts);
const ctx = {
atKey: false,
atRoot: true,
directives: doc.directives,
options: doc.options,
@ -36126,6 +36127,7 @@ exports.composeDoc = composeDoc;
var Alias = __nccwpck_require__(4065);
var identity = __nccwpck_require__(1127);
var composeCollection = __nccwpck_require__(7349);
var composeScalar = __nccwpck_require__(5413);
var resolveEnd = __nccwpck_require__(7788);
@ -36133,6 +36135,7 @@ var utilEmptyScalarPosition = __nccwpck_require__(2599);
const CN = { composeNode, composeEmptyNode };
function composeNode(ctx, token, props, onError) {
const atKey = ctx.atKey;
const { spaceBefore, comment, anchor, tag } = props;
let node;
let isSrcToken = true;
@ -36168,6 +36171,14 @@ function composeNode(ctx, token, props, onError) {
}
if (anchor && node.anchor === '')
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
if (atKey &&
ctx.options.stringKeys &&
(!identity.isScalar(node) ||
typeof node.value !== 'string' ||
(node.tag && node.tag !== 'tag:yaml.org,2002:str'))) {
const msg = 'With stringKeys, all keys must be strings';
onError(tag ?? token, 'NON_STRING_KEY', msg);
}
if (spaceBefore)
node.spaceBefore = true;
if (comment) {
@ -36240,11 +36251,16 @@ function composeScalar(ctx, token, tagToken, onError) {
const tagName = tagToken
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
: null;
const tag = tagToken && tagName
? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
: token.type === 'scalar'
? findScalarTagByTest(ctx, value, token, onError)
: ctx.schema[identity.SCALAR];
let tag;
if (ctx.options.stringKeys && ctx.atKey) {
tag = ctx.schema[identity.SCALAR];
}
else if (tagName)
tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
else if (token.type === 'scalar')
tag = findScalarTagByTest(ctx, value, token, onError);
else
tag = ctx.schema[identity.SCALAR];
let scalar;
try {
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
@ -36292,8 +36308,9 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
return schema[identity.SCALAR];
}
function findScalarTagByTest({ directives, schema }, value, token, onError) {
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[identity.SCALAR];
function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
const tag = schema.tags.find(tag => (tag.default === true || (atKey && tag.default === 'key')) &&
tag.test?.test(value)) || schema[identity.SCALAR];
if (schema.compat) {
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
schema[identity.SCALAR];
@ -36599,12 +36616,14 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
onError(offset, 'BAD_INDENT', startColMsg);
}
// key value
ctx.atKey = true;
const keyStart = keyProps.end;
const keyNode = key
? composeNode(ctx, key, keyProps, onError)
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
if (ctx.schema.compat)
utilFlowIndentCheck.flowIndentCheck(bm.indent, key, onError);
ctx.atKey = false;
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
// value properties
@ -36887,6 +36906,8 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
const seq = new NodeClass(ctx.schema);
if (ctx.atRoot)
ctx.atRoot = false;
if (ctx.atKey)
ctx.atKey = false;
let offset = bs.offset;
let commentEnd = null;
for (const { start, value } of bs.items) {
@ -37002,6 +37023,8 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
const atRoot = ctx.atRoot;
if (atRoot)
ctx.atRoot = false;
if (ctx.atKey)
ctx.atKey = false;
let offset = fc.offset + fc.start.source.length;
for (let i = 0; i < fc.items.length; ++i) {
const collItem = fc.items[i];
@ -37081,12 +37104,14 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
else {
// item is a key+value pair
// key value
ctx.atKey = true;
const keyStart = props.end;
const keyNode = key
? composeNode(ctx, key, props, onError)
: composeEmptyNode(ctx, keyStart, start, null, props, onError);
if (isBlock(key))
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
ctx.atKey = false;
// value properties
const valueProps = resolveProps.resolveProps(sep ?? [], {
flow: fcName,
@ -37700,11 +37725,7 @@ function mapIncludes(ctx, items, search) {
return false;
const isEqual = typeof uniqueKeys === 'function'
? uniqueKeys
: (a, b) => a === b ||
(identity.isScalar(a) &&
identity.isScalar(b) &&
a.value === b.value &&
!(a.value === '<<' && ctx.schema.merge));
: (a, b) => a === b || (identity.isScalar(a) && identity.isScalar(b) && a.value === b.value);
return items.some(pair => isEqual(pair.key, search));
}
@ -37756,6 +37777,7 @@ class Document {
logLevel: 'warn',
prettyErrors: true,
strict: true,
stringKeys: false,
uniqueKeys: true,
version: '1.2'
}, options);
@ -37979,7 +38001,7 @@ class Document {
this.directives.yaml.version = '1.1';
else
this.directives = new directives.Directives({ version: '1.1' });
opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
opt = { resolveKnownTags: false, schema: 'yaml-1.1' };
break;
case '1.2':
case 'next':
@ -37987,7 +38009,7 @@ class Document {
this.directives.yaml.version = version;
else
this.directives = new directives.Directives({ version });
opt = { merge: false, resolveKnownTags: true, schema: 'core' };
opt = { resolveKnownTags: true, schema: 'core' };
break;
case null:
if (this.directives)
@ -39330,24 +39352,17 @@ exports.YAMLSeq = YAMLSeq;
var log = __nccwpck_require__(7249);
var merge = __nccwpck_require__(452);
var stringify = __nccwpck_require__(2148);
var identity = __nccwpck_require__(1127);
var Scalar = __nccwpck_require__(3301);
var toJS = __nccwpck_require__(6424);
const MERGE_KEY = '<<';
function addPairToJSMap(ctx, map, { key, value }) {
if (ctx?.doc.schema.merge && isMergeKey(key)) {
value = identity.isAlias(value) ? value.resolve(ctx.doc) : value;
if (identity.isSeq(value))
for (const it of value.items)
mergeToJSMap(ctx, map, it);
else if (Array.isArray(value))
for (const it of value)
mergeToJSMap(ctx, map, it);
else
mergeToJSMap(ctx, map, value);
}
if (identity.isNode(key) && key.addToJSMap)
key.addToJSMap(ctx, map, value);
// TODO: Should drop this special case for bare << handling
else if (merge.isMergeKey(ctx, key))
merge.addMergeToJSMap(ctx, map, value);
else {
const jsKey = toJS.toJS(key, '', ctx);
if (map instanceof Map) {
@ -39372,41 +39387,6 @@ function addPairToJSMap(ctx, map, { key, value }) {
}
return map;
}
const isMergeKey = (key) => key === MERGE_KEY ||
(identity.isScalar(key) &&
key.value === MERGE_KEY &&
(!key.type || key.type === Scalar.Scalar.PLAIN));
// If the value associated with a merge key is a single mapping node, each of
// its key/value pairs is inserted into the current mapping, unless the key
// already exists in it. If the value associated with the merge key is a
// sequence, then this sequence is expected to contain mapping nodes and each
// of these nodes is merged in turn according to its order in the sequence.
// Keys in mapping nodes earlier in the sequence override keys specified in
// later mapping nodes. -- http://yaml.org/type/merge.html
function mergeToJSMap(ctx, map, value) {
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
if (!identity.isMap(source))
throw new Error('Merge sources must be maps or map aliases');
const srcMap = source.toJSON(null, ctx, Map);
for (const [key, value] of srcMap) {
if (map instanceof Map) {
if (!map.has(key))
map.set(key, value);
}
else if (map instanceof Set) {
map.add(key);
}
else if (!Object.prototype.hasOwnProperty.call(map, key)) {
Object.defineProperty(map, key, {
value,
writable: true,
enumerable: true,
configurable: true
});
}
}
return map;
}
function stringifyKey(key, jsKey, ctx) {
if (jsKey === null)
return '';
@ -41821,6 +41801,7 @@ var composer = __nccwpck_require__(9984);
var Document = __nccwpck_require__(3021);
var errors = __nccwpck_require__(1464);
var log = __nccwpck_require__(7249);
var identity = __nccwpck_require__(1127);
var lineCounter = __nccwpck_require__(6628);
var parser = __nccwpck_require__(3456);
@ -41912,6 +41893,8 @@ function stringify(value, replacer, options) {
if (!keepUndefined)
return undefined;
}
if (identity.isDocument(value) && !_replacer)
return value.toString(options);
return new Document.Document(value, _replacer, options).toString(options);
}
@ -41943,10 +41926,9 @@ class Schema {
: compat
? tags.getTags(null, compat)
: null;
this.merge = !!merge;
this.name = (typeof schema === 'string' && schema) || 'core';
this.knownTags = resolveKnownTags ? tags.coreKnownTags : {};
this.tags = tags.getTags(customTags, this.name);
this.tags = tags.getTags(customTags, this.name, merge);
this.toStringOptions = toStringDefaults ?? null;
Object.defineProperty(this, identity.MAP, { value: map.map });
Object.defineProperty(this, identity.SCALAR, { value: string.string });
@ -42276,7 +42258,7 @@ const jsonScalars = [
identify: value => typeof value === 'boolean',
default: true,
tag: 'tag:yaml.org,2002:bool',
test: /^true|false$/,
test: /^true$|^false$/,
resolve: str => str === 'true',
stringify: stringifyJSON
},
@ -42329,6 +42311,7 @@ var int = __nccwpck_require__(9874);
var schema = __nccwpck_require__(896);
var schema$1 = __nccwpck_require__(3559);
var binary = __nccwpck_require__(6083);
var merge = __nccwpck_require__(452);
var omap = __nccwpck_require__(303);
var pairs = __nccwpck_require__(8385);
var schema$2 = __nccwpck_require__(8294);
@ -42354,6 +42337,7 @@ const tagsByName = {
intOct: int.intOct,
intTime: timestamp.intTime,
map: map.map,
merge: merge.merge,
null: _null.nullTag,
omap: omap.omap,
pairs: pairs.pairs,
@ -42363,13 +42347,20 @@ const tagsByName = {
};
const coreKnownTags = {
'tag:yaml.org,2002:binary': binary.binary,
'tag:yaml.org,2002:merge': merge.merge,
'tag:yaml.org,2002:omap': omap.omap,
'tag:yaml.org,2002:pairs': pairs.pairs,
'tag:yaml.org,2002:set': set.set,
'tag:yaml.org,2002:timestamp': timestamp.timestamp
};
function getTags(customTags, schemaName) {
let tags = schemas.get(schemaName);
function getTags(customTags, schemaName, addMergeTag) {
const schemaTags = schemas.get(schemaName);
if (schemaTags && !customTags) {
return addMergeTag && !schemaTags.includes(merge.merge)
? schemaTags.concat(merge.merge)
: schemaTags.slice();
}
let tags = schemaTags;
if (!tags) {
if (Array.isArray(customTags))
tags = [];
@ -42388,17 +42379,21 @@ function getTags(customTags, schemaName) {
else if (typeof customTags === 'function') {
tags = customTags(tags.slice());
}
return tags.map(tag => {
if (typeof tag !== 'string')
return tag;
const tagObj = tagsByName[tag];
if (tagObj)
return tagObj;
const keys = Object.keys(tagsByName)
.map(key => JSON.stringify(key))
.join(', ');
throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
});
if (addMergeTag)
tags = tags.concat(merge.merge);
return tags.reduce((tags, tag) => {
const tagObj = typeof tag === 'string' ? tagsByName[tag] : tag;
if (!tagObj) {
const tagName = JSON.stringify(tag);
const keys = Object.keys(tagsByName)
.map(key => JSON.stringify(key))
.join(', ');
throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
}
if (!tags.includes(tagObj))
tags.push(tagObj);
return tags;
}, []);
}
exports.coreKnownTags = coreKnownTags;
@ -42660,6 +42655,82 @@ exports.intHex = intHex;
exports.intOct = intOct;
/***/ }),
/***/ 452:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
var identity = __nccwpck_require__(1127);
var Scalar = __nccwpck_require__(3301);
// If the value associated with a merge key is a single mapping node, each of
// its key/value pairs is inserted into the current mapping, unless the key
// already exists in it. If the value associated with the merge key is a
// sequence, then this sequence is expected to contain mapping nodes and each
// of these nodes is merged in turn according to its order in the sequence.
// Keys in mapping nodes earlier in the sequence override keys specified in
// later mapping nodes. -- http://yaml.org/type/merge.html
const MERGE_KEY = '<<';
const merge = {
identify: value => value === MERGE_KEY ||
(typeof value === 'symbol' && value.description === MERGE_KEY),
default: 'key',
tag: 'tag:yaml.org,2002:merge',
test: /^<<$/,
resolve: () => Object.assign(new Scalar.Scalar(Symbol(MERGE_KEY)), {
addToJSMap: addMergeToJSMap
}),
stringify: () => MERGE_KEY
};
const isMergeKey = (ctx, key) => (merge.identify(key) ||
(identity.isScalar(key) &&
(!key.type || key.type === Scalar.Scalar.PLAIN) &&
merge.identify(key.value))) &&
ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
function addMergeToJSMap(ctx, map, value) {
value = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
if (identity.isSeq(value))
for (const it of value.items)
mergeValue(ctx, map, it);
else if (Array.isArray(value))
for (const it of value)
mergeValue(ctx, map, it);
else
mergeValue(ctx, map, value);
}
function mergeValue(ctx, map, value) {
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
if (!identity.isMap(source))
throw new Error('Merge sources must be maps or map aliases');
const srcMap = source.toJSON(null, ctx, Map);
for (const [key, value] of srcMap) {
if (map instanceof Map) {
if (!map.has(key))
map.set(key, value);
}
else if (map instanceof Set) {
map.add(key);
}
else if (!Object.prototype.hasOwnProperty.call(map, key)) {
Object.defineProperty(map, key, {
value,
writable: true,
enumerable: true,
configurable: true
});
}
}
return map;
}
exports.addMergeToJSMap = addMergeToJSMap;
exports.isMergeKey = isMergeKey;
exports.merge = merge;
/***/ }),
/***/ 303:
@ -42851,6 +42922,7 @@ var binary = __nccwpck_require__(6083);
var bool = __nccwpck_require__(8398);
var float = __nccwpck_require__(5782);
var int = __nccwpck_require__(873);
var merge = __nccwpck_require__(452);
var omap = __nccwpck_require__(303);
var pairs = __nccwpck_require__(8385);
var set = __nccwpck_require__(1528);
@ -42871,6 +42943,7 @@ const schema = [
float.floatExp,
float.float,
binary.binary,
merge.merge,
omap.omap,
pairs.pairs,
set.set,
@ -43091,7 +43164,7 @@ const timestamp = {
}
return new Date(date);
},
stringify: ({ value }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
stringify: ({ value }) => value.toISOString().replace(/(T00:00:00)?\.000Z$/, '')
};
exports.floatTime = floatTime;
@ -43322,7 +43395,12 @@ function getTagObject(tags, item) {
let obj;
if (identity.isScalar(item)) {
obj = item.value;
const match = tags.filter(t => t.identify?.(obj));
let match = tags.filter(t => t.identify?.(obj));
if (match.length > 1) {
const testMatch = match.filter(t => t.test);
if (testMatch.length > 0)
match = testMatch;
}
tagObj =
match.find(t => t.format === item.format) ?? match.find(t => !t.format);
}
@ -44096,23 +44174,32 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
start = start.replace(/\n+/g, `$&${indent}`);
}
const indentSize = indent ? '2' : '1'; // root is at -1
let header = (literal ? '|' : '>') + (startWithSpace ? indentSize : '') + chomp;
// Leading | or > is added later
let header = (startWithSpace ? indentSize : '') + chomp;
if (comment) {
header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
if (onComment)
onComment();
}
if (literal) {
value = value.replace(/\n+/g, `$&${indent}`);
return `${header}\n${indent}${start}${value}${end}`;
if (!literal) {
const foldedValue = value
.replace(/\n+/g, '\n$&')
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
.replace(/\n+/g, `$&${indent}`);
let literalFallback = false;
const foldOptions = getFoldOptions(ctx, true);
if (blockQuote !== 'folded' && type !== Scalar.Scalar.BLOCK_FOLDED) {
foldOptions.onOverflow = () => {
literalFallback = true;
};
}
const body = foldFlowLines.foldFlowLines(`${start}${foldedValue}${end}`, indent, foldFlowLines.FOLD_BLOCK, foldOptions);
if (!literalFallback)
return `>${header}\n${indent}${body}`;
}
value = value
.replace(/\n+/g, '\n$&')
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
.replace(/\n+/g, `$&${indent}`);
const body = foldFlowLines.foldFlowLines(`${start}${value}${end}`, indent, foldFlowLines.FOLD_BLOCK, getFoldOptions(ctx, true));
return `${header}\n${indent}${body}`;
value = value.replace(/\n+/g, `$&${indent}`);
return `|${header}\n${indent}${start}${value}${end}`;
}
function plainString(item, ctx, onComment, onChompKeep) {
const { type, value } = item;

269
dist/post.js generated vendored
View File

@ -27792,6 +27792,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
const opts = Object.assign({ _directives: directives }, options);
const doc = new Document.Document(undefined, opts);
const ctx = {
atKey: false,
atRoot: true,
directives: doc.directives,
options: doc.options,
@ -27836,6 +27837,7 @@ exports.composeDoc = composeDoc;
var Alias = __nccwpck_require__(4065);
var identity = __nccwpck_require__(1127);
var composeCollection = __nccwpck_require__(7349);
var composeScalar = __nccwpck_require__(5413);
var resolveEnd = __nccwpck_require__(7788);
@ -27843,6 +27845,7 @@ var utilEmptyScalarPosition = __nccwpck_require__(2599);
const CN = { composeNode, composeEmptyNode };
function composeNode(ctx, token, props, onError) {
const atKey = ctx.atKey;
const { spaceBefore, comment, anchor, tag } = props;
let node;
let isSrcToken = true;
@ -27878,6 +27881,14 @@ function composeNode(ctx, token, props, onError) {
}
if (anchor && node.anchor === '')
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
if (atKey &&
ctx.options.stringKeys &&
(!identity.isScalar(node) ||
typeof node.value !== 'string' ||
(node.tag && node.tag !== 'tag:yaml.org,2002:str'))) {
const msg = 'With stringKeys, all keys must be strings';
onError(tag ?? token, 'NON_STRING_KEY', msg);
}
if (spaceBefore)
node.spaceBefore = true;
if (comment) {
@ -27950,11 +27961,16 @@ function composeScalar(ctx, token, tagToken, onError) {
const tagName = tagToken
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
: null;
const tag = tagToken && tagName
? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
: token.type === 'scalar'
? findScalarTagByTest(ctx, value, token, onError)
: ctx.schema[identity.SCALAR];
let tag;
if (ctx.options.stringKeys && ctx.atKey) {
tag = ctx.schema[identity.SCALAR];
}
else if (tagName)
tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
else if (token.type === 'scalar')
tag = findScalarTagByTest(ctx, value, token, onError);
else
tag = ctx.schema[identity.SCALAR];
let scalar;
try {
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
@ -28002,8 +28018,9 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
return schema[identity.SCALAR];
}
function findScalarTagByTest({ directives, schema }, value, token, onError) {
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[identity.SCALAR];
function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
const tag = schema.tags.find(tag => (tag.default === true || (atKey && tag.default === 'key')) &&
tag.test?.test(value)) || schema[identity.SCALAR];
if (schema.compat) {
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
schema[identity.SCALAR];
@ -28309,12 +28326,14 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
onError(offset, 'BAD_INDENT', startColMsg);
}
// key value
ctx.atKey = true;
const keyStart = keyProps.end;
const keyNode = key
? composeNode(ctx, key, keyProps, onError)
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
if (ctx.schema.compat)
utilFlowIndentCheck.flowIndentCheck(bm.indent, key, onError);
ctx.atKey = false;
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
// value properties
@ -28597,6 +28616,8 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
const seq = new NodeClass(ctx.schema);
if (ctx.atRoot)
ctx.atRoot = false;
if (ctx.atKey)
ctx.atKey = false;
let offset = bs.offset;
let commentEnd = null;
for (const { start, value } of bs.items) {
@ -28712,6 +28733,8 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
const atRoot = ctx.atRoot;
if (atRoot)
ctx.atRoot = false;
if (ctx.atKey)
ctx.atKey = false;
let offset = fc.offset + fc.start.source.length;
for (let i = 0; i < fc.items.length; ++i) {
const collItem = fc.items[i];
@ -28791,12 +28814,14 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
else {
// item is a key+value pair
// key value
ctx.atKey = true;
const keyStart = props.end;
const keyNode = key
? composeNode(ctx, key, props, onError)
: composeEmptyNode(ctx, keyStart, start, null, props, onError);
if (isBlock(key))
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
ctx.atKey = false;
// value properties
const valueProps = resolveProps.resolveProps(sep ?? [], {
flow: fcName,
@ -29410,11 +29435,7 @@ function mapIncludes(ctx, items, search) {
return false;
const isEqual = typeof uniqueKeys === 'function'
? uniqueKeys
: (a, b) => a === b ||
(identity.isScalar(a) &&
identity.isScalar(b) &&
a.value === b.value &&
!(a.value === '<<' && ctx.schema.merge));
: (a, b) => a === b || (identity.isScalar(a) && identity.isScalar(b) && a.value === b.value);
return items.some(pair => isEqual(pair.key, search));
}
@ -29466,6 +29487,7 @@ class Document {
logLevel: 'warn',
prettyErrors: true,
strict: true,
stringKeys: false,
uniqueKeys: true,
version: '1.2'
}, options);
@ -29689,7 +29711,7 @@ class Document {
this.directives.yaml.version = '1.1';
else
this.directives = new directives.Directives({ version: '1.1' });
opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
opt = { resolveKnownTags: false, schema: 'yaml-1.1' };
break;
case '1.2':
case 'next':
@ -29697,7 +29719,7 @@ class Document {
this.directives.yaml.version = version;
else
this.directives = new directives.Directives({ version });
opt = { merge: false, resolveKnownTags: true, schema: 'core' };
opt = { resolveKnownTags: true, schema: 'core' };
break;
case null:
if (this.directives)
@ -31040,24 +31062,17 @@ exports.YAMLSeq = YAMLSeq;
var log = __nccwpck_require__(7249);
var merge = __nccwpck_require__(452);
var stringify = __nccwpck_require__(2148);
var identity = __nccwpck_require__(1127);
var Scalar = __nccwpck_require__(3301);
var toJS = __nccwpck_require__(6424);
const MERGE_KEY = '<<';
function addPairToJSMap(ctx, map, { key, value }) {
if (ctx?.doc.schema.merge && isMergeKey(key)) {
value = identity.isAlias(value) ? value.resolve(ctx.doc) : value;
if (identity.isSeq(value))
for (const it of value.items)
mergeToJSMap(ctx, map, it);
else if (Array.isArray(value))
for (const it of value)
mergeToJSMap(ctx, map, it);
else
mergeToJSMap(ctx, map, value);
}
if (identity.isNode(key) && key.addToJSMap)
key.addToJSMap(ctx, map, value);
// TODO: Should drop this special case for bare << handling
else if (merge.isMergeKey(ctx, key))
merge.addMergeToJSMap(ctx, map, value);
else {
const jsKey = toJS.toJS(key, '', ctx);
if (map instanceof Map) {
@ -31082,41 +31097,6 @@ function addPairToJSMap(ctx, map, { key, value }) {
}
return map;
}
const isMergeKey = (key) => key === MERGE_KEY ||
(identity.isScalar(key) &&
key.value === MERGE_KEY &&
(!key.type || key.type === Scalar.Scalar.PLAIN));
// If the value associated with a merge key is a single mapping node, each of
// its key/value pairs is inserted into the current mapping, unless the key
// already exists in it. If the value associated with the merge key is a
// sequence, then this sequence is expected to contain mapping nodes and each
// of these nodes is merged in turn according to its order in the sequence.
// Keys in mapping nodes earlier in the sequence override keys specified in
// later mapping nodes. -- http://yaml.org/type/merge.html
function mergeToJSMap(ctx, map, value) {
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
if (!identity.isMap(source))
throw new Error('Merge sources must be maps or map aliases');
const srcMap = source.toJSON(null, ctx, Map);
for (const [key, value] of srcMap) {
if (map instanceof Map) {
if (!map.has(key))
map.set(key, value);
}
else if (map instanceof Set) {
map.add(key);
}
else if (!Object.prototype.hasOwnProperty.call(map, key)) {
Object.defineProperty(map, key, {
value,
writable: true,
enumerable: true,
configurable: true
});
}
}
return map;
}
function stringifyKey(key, jsKey, ctx) {
if (jsKey === null)
return '';
@ -33531,6 +33511,7 @@ var composer = __nccwpck_require__(9984);
var Document = __nccwpck_require__(3021);
var errors = __nccwpck_require__(1464);
var log = __nccwpck_require__(7249);
var identity = __nccwpck_require__(1127);
var lineCounter = __nccwpck_require__(6628);
var parser = __nccwpck_require__(3456);
@ -33622,6 +33603,8 @@ function stringify(value, replacer, options) {
if (!keepUndefined)
return undefined;
}
if (identity.isDocument(value) && !_replacer)
return value.toString(options);
return new Document.Document(value, _replacer, options).toString(options);
}
@ -33653,10 +33636,9 @@ class Schema {
: compat
? tags.getTags(null, compat)
: null;
this.merge = !!merge;
this.name = (typeof schema === 'string' && schema) || 'core';
this.knownTags = resolveKnownTags ? tags.coreKnownTags : {};
this.tags = tags.getTags(customTags, this.name);
this.tags = tags.getTags(customTags, this.name, merge);
this.toStringOptions = toStringDefaults ?? null;
Object.defineProperty(this, identity.MAP, { value: map.map });
Object.defineProperty(this, identity.SCALAR, { value: string.string });
@ -33986,7 +33968,7 @@ const jsonScalars = [
identify: value => typeof value === 'boolean',
default: true,
tag: 'tag:yaml.org,2002:bool',
test: /^true|false$/,
test: /^true$|^false$/,
resolve: str => str === 'true',
stringify: stringifyJSON
},
@ -34039,6 +34021,7 @@ var int = __nccwpck_require__(9874);
var schema = __nccwpck_require__(896);
var schema$1 = __nccwpck_require__(3559);
var binary = __nccwpck_require__(6083);
var merge = __nccwpck_require__(452);
var omap = __nccwpck_require__(303);
var pairs = __nccwpck_require__(8385);
var schema$2 = __nccwpck_require__(8294);
@ -34064,6 +34047,7 @@ const tagsByName = {
intOct: int.intOct,
intTime: timestamp.intTime,
map: map.map,
merge: merge.merge,
null: _null.nullTag,
omap: omap.omap,
pairs: pairs.pairs,
@ -34073,13 +34057,20 @@ const tagsByName = {
};
const coreKnownTags = {
'tag:yaml.org,2002:binary': binary.binary,
'tag:yaml.org,2002:merge': merge.merge,
'tag:yaml.org,2002:omap': omap.omap,
'tag:yaml.org,2002:pairs': pairs.pairs,
'tag:yaml.org,2002:set': set.set,
'tag:yaml.org,2002:timestamp': timestamp.timestamp
};
function getTags(customTags, schemaName) {
let tags = schemas.get(schemaName);
function getTags(customTags, schemaName, addMergeTag) {
const schemaTags = schemas.get(schemaName);
if (schemaTags && !customTags) {
return addMergeTag && !schemaTags.includes(merge.merge)
? schemaTags.concat(merge.merge)
: schemaTags.slice();
}
let tags = schemaTags;
if (!tags) {
if (Array.isArray(customTags))
tags = [];
@ -34098,17 +34089,21 @@ function getTags(customTags, schemaName) {
else if (typeof customTags === 'function') {
tags = customTags(tags.slice());
}
return tags.map(tag => {
if (typeof tag !== 'string')
return tag;
const tagObj = tagsByName[tag];
if (tagObj)
return tagObj;
const keys = Object.keys(tagsByName)
.map(key => JSON.stringify(key))
.join(', ');
throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
});
if (addMergeTag)
tags = tags.concat(merge.merge);
return tags.reduce((tags, tag) => {
const tagObj = typeof tag === 'string' ? tagsByName[tag] : tag;
if (!tagObj) {
const tagName = JSON.stringify(tag);
const keys = Object.keys(tagsByName)
.map(key => JSON.stringify(key))
.join(', ');
throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
}
if (!tags.includes(tagObj))
tags.push(tagObj);
return tags;
}, []);
}
exports.coreKnownTags = coreKnownTags;
@ -34370,6 +34365,82 @@ exports.intHex = intHex;
exports.intOct = intOct;
/***/ }),
/***/ 452:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
var identity = __nccwpck_require__(1127);
var Scalar = __nccwpck_require__(3301);
// If the value associated with a merge key is a single mapping node, each of
// its key/value pairs is inserted into the current mapping, unless the key
// already exists in it. If the value associated with the merge key is a
// sequence, then this sequence is expected to contain mapping nodes and each
// of these nodes is merged in turn according to its order in the sequence.
// Keys in mapping nodes earlier in the sequence override keys specified in
// later mapping nodes. -- http://yaml.org/type/merge.html
const MERGE_KEY = '<<';
const merge = {
identify: value => value === MERGE_KEY ||
(typeof value === 'symbol' && value.description === MERGE_KEY),
default: 'key',
tag: 'tag:yaml.org,2002:merge',
test: /^<<$/,
resolve: () => Object.assign(new Scalar.Scalar(Symbol(MERGE_KEY)), {
addToJSMap: addMergeToJSMap
}),
stringify: () => MERGE_KEY
};
const isMergeKey = (ctx, key) => (merge.identify(key) ||
(identity.isScalar(key) &&
(!key.type || key.type === Scalar.Scalar.PLAIN) &&
merge.identify(key.value))) &&
ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
function addMergeToJSMap(ctx, map, value) {
value = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
if (identity.isSeq(value))
for (const it of value.items)
mergeValue(ctx, map, it);
else if (Array.isArray(value))
for (const it of value)
mergeValue(ctx, map, it);
else
mergeValue(ctx, map, value);
}
function mergeValue(ctx, map, value) {
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
if (!identity.isMap(source))
throw new Error('Merge sources must be maps or map aliases');
const srcMap = source.toJSON(null, ctx, Map);
for (const [key, value] of srcMap) {
if (map instanceof Map) {
if (!map.has(key))
map.set(key, value);
}
else if (map instanceof Set) {
map.add(key);
}
else if (!Object.prototype.hasOwnProperty.call(map, key)) {
Object.defineProperty(map, key, {
value,
writable: true,
enumerable: true,
configurable: true
});
}
}
return map;
}
exports.addMergeToJSMap = addMergeToJSMap;
exports.isMergeKey = isMergeKey;
exports.merge = merge;
/***/ }),
/***/ 303:
@ -34561,6 +34632,7 @@ var binary = __nccwpck_require__(6083);
var bool = __nccwpck_require__(8398);
var float = __nccwpck_require__(5782);
var int = __nccwpck_require__(873);
var merge = __nccwpck_require__(452);
var omap = __nccwpck_require__(303);
var pairs = __nccwpck_require__(8385);
var set = __nccwpck_require__(1528);
@ -34581,6 +34653,7 @@ const schema = [
float.floatExp,
float.float,
binary.binary,
merge.merge,
omap.omap,
pairs.pairs,
set.set,
@ -34801,7 +34874,7 @@ const timestamp = {
}
return new Date(date);
},
stringify: ({ value }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
stringify: ({ value }) => value.toISOString().replace(/(T00:00:00)?\.000Z$/, '')
};
exports.floatTime = floatTime;
@ -35032,7 +35105,12 @@ function getTagObject(tags, item) {
let obj;
if (identity.isScalar(item)) {
obj = item.value;
const match = tags.filter(t => t.identify?.(obj));
let match = tags.filter(t => t.identify?.(obj));
if (match.length > 1) {
const testMatch = match.filter(t => t.test);
if (testMatch.length > 0)
match = testMatch;
}
tagObj =
match.find(t => t.format === item.format) ?? match.find(t => !t.format);
}
@ -35806,23 +35884,32 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
start = start.replace(/\n+/g, `$&${indent}`);
}
const indentSize = indent ? '2' : '1'; // root is at -1
let header = (literal ? '|' : '>') + (startWithSpace ? indentSize : '') + chomp;
// Leading | or > is added later
let header = (startWithSpace ? indentSize : '') + chomp;
if (comment) {
header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
if (onComment)
onComment();
}
if (literal) {
value = value.replace(/\n+/g, `$&${indent}`);
return `${header}\n${indent}${start}${value}${end}`;
if (!literal) {
const foldedValue = value
.replace(/\n+/g, '\n$&')
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
.replace(/\n+/g, `$&${indent}`);
let literalFallback = false;
const foldOptions = getFoldOptions(ctx, true);
if (blockQuote !== 'folded' && type !== Scalar.Scalar.BLOCK_FOLDED) {
foldOptions.onOverflow = () => {
literalFallback = true;
};
}
const body = foldFlowLines.foldFlowLines(`${start}${foldedValue}${end}`, indent, foldFlowLines.FOLD_BLOCK, foldOptions);
if (!literalFallback)
return `>${header}\n${indent}${body}`;
}
value = value
.replace(/\n+/g, '\n$&')
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
.replace(/\n+/g, `$&${indent}`);
const body = foldFlowLines.foldFlowLines(`${start}${value}${end}`, indent, foldFlowLines.FOLD_BLOCK, getFoldOptions(ctx, true));
return `${header}\n${indent}${body}`;
value = value.replace(/\n+/g, `$&${indent}`);
return `|${header}\n${indent}${start}${value}${end}`;
}
function plainString(item, ctx, onComment, onChompKeep) {
const { type, value } = item;

2417
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -76,10 +76,10 @@
"@actions/github": "^6.0.0",
"@actions/tool-cache": "^2.0.1",
"@octokit/action": "^7.0.0",
"@ts-dev-tools/core": "^1.6.2",
"docker-compose": "^1.1.0"
},
"devDependencies": {
"@ts-dev-tools/core": "1.6.2",
"@vercel/ncc": "^0.38.1",
"eslint-plugin-github": "^5.0.1",
"eslint-plugin-jsonc": "^2.14.1"