3
0
Fork 0
mirror of https://gitea.com/actions/setup-python.git synced 2024-11-25 19:49:35 +01:00

Updated @iarna/toml version to 3.0.0 (#912)

This commit is contained in:
priya-kinthali 2024-07-23 00:20:49 +05:30 committed by GitHub
parent 39cd14951b
commit cb68456441
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 81 additions and 65 deletions

View file

@ -1,6 +1,6 @@
--- ---
name: "@iarna/toml" name: "@iarna/toml"
version: 2.2.5 version: 3.0.0
type: npm type: npm
summary: Better TOML parsing and stringifying all in that familiar JSON interface. summary: Better TOML parsing and stringifying all in that familiar JSON interface.
homepage: https://github.com/iarna/iarna-toml#readme homepage: https://github.com/iarna/iarna-toml#readme

134
dist/setup/index.js vendored
View file

@ -46726,7 +46726,7 @@ function makeParserClass (Parser) {
let target = this.ctx let target = this.ctx
let finalKey = kv.key.pop() let finalKey = kv.key.pop()
for (let kw of kv.key) { for (let kw of kv.key) {
if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) { if (hasKey(target, kw) && !isTable(target[kw])) {
throw this.error(new TomlError("Can't redefine existing key")) throw this.error(new TomlError("Can't redefine existing key"))
} }
target = target[kw] = target[kw] || Table() target = target[kw] = target[kw] || Table()
@ -46734,6 +46734,7 @@ function makeParserClass (Parser) {
if (hasKey(target, finalKey)) { if (hasKey(target, finalKey)) {
throw this.error(new TomlError("Can't redefine existing key")) throw this.error(new TomlError("Can't redefine existing key"))
} }
target[_declared] = true
// unbox our numbers // unbox our numbers
if (isInteger(kv.value) || isFloat(kv.value)) { if (isInteger(kv.value) || isFloat(kv.value)) {
target[finalKey] = kv.value.valueOf() target[finalKey] = kv.value.valueOf()
@ -46791,6 +46792,8 @@ function makeParserClass (Parser) {
do { do {
if (this.char === Parser.END || this.char === CTRL_J) { if (this.char === Parser.END || this.char === CTRL_J) {
return this.return() return this.return()
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) {
throw this.errorControlCharIn('comments')
} }
} while (this.nextChar()) } while (this.nextChar())
} }
@ -47004,7 +47007,7 @@ function makeParserClass (Parser) {
} else if (this.atEndOfLine()) { } else if (this.atEndOfLine()) {
throw this.error(new TomlError('Unterminated string')) throw this.error(new TomlError('Unterminated string'))
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) { } else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) {
throw this.errorControlCharInString() throw this.errorControlCharIn('strings')
} else { } else {
this.consume() this.consume()
} }
@ -47033,7 +47036,7 @@ function makeParserClass (Parser) {
} else if (this.char === Parser.END) { } else if (this.char === Parser.END) {
throw this.error(new TomlError('Unterminated multi-line string')) throw this.error(new TomlError('Unterminated multi-line string'))
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)) { } else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)) {
throw this.errorControlCharInString() throw this.errorControlCharIn('strings')
} else { } else {
this.consume() this.consume()
} }
@ -47049,12 +47052,28 @@ function makeParserClass (Parser) {
} }
parseLiteralMultiEnd2 () { parseLiteralMultiEnd2 () {
if (this.char === CHAR_APOS) { if (this.char === CHAR_APOS) {
return this.return() return this.next(this.parseLiteralMultiEnd3)
} else { } else {
this.state.buf += "''" this.state.buf += "''"
return this.goto(this.parseLiteralMultiStringContent) return this.goto(this.parseLiteralMultiStringContent)
} }
} }
parseLiteralMultiEnd3 () {
if (this.char === CHAR_APOS) {
this.state.buf += "'"
return this.next(this.parseLiteralMultiEnd4)
} else {
return this.returnNow()
}
}
parseLiteralMultiEnd4 () {
if (this.char === CHAR_APOS) {
this.state.buf += "'"
return this.return()
} else {
return this.returnNow()
}
}
/* STRINGS double quoted */ /* STRINGS double quoted */
parseDoubleString () { parseDoubleString () {
@ -47073,7 +47092,7 @@ function makeParserClass (Parser) {
} else if (this.atEndOfLine()) { } else if (this.atEndOfLine()) {
throw this.error(new TomlError('Unterminated string')) throw this.error(new TomlError('Unterminated string'))
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) { } else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) {
throw this.errorControlCharInString() throw this.errorControlCharIn('strings')
} else { } else {
this.consume() this.consume()
} }
@ -47108,20 +47127,20 @@ function makeParserClass (Parser) {
} else if (this.char === Parser.END) { } else if (this.char === Parser.END) {
throw this.error(new TomlError('Unterminated multi-line string')) throw this.error(new TomlError('Unterminated multi-line string'))
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)) { } else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)) {
throw this.errorControlCharInString() throw this.errorControlCharIn('strings')
} else { } else {
this.consume() this.consume()
} }
} while (this.nextChar()) } while (this.nextChar())
} }
errorControlCharInString () { errorControlCharIn (type) {
let displayCode = '\\u00' let displayCode = '\\u00'
if (this.char < 16) { if (this.char < 16) {
displayCode += '0' displayCode += '0'
} }
displayCode += this.char.toString(16) displayCode += this.char.toString(16)
return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`)) return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in ${type}, use ${displayCode} instead`))
} }
recordMultiEscapeReplacement (replacement) { recordMultiEscapeReplacement (replacement) {
this.state.buf += replacement this.state.buf += replacement
@ -47137,12 +47156,28 @@ function makeParserClass (Parser) {
} }
parseMultiEnd2 () { parseMultiEnd2 () {
if (this.char === CHAR_QUOT) { if (this.char === CHAR_QUOT) {
return this.return() return this.next(this.parseMultiEnd3)
} else { } else {
this.state.buf += '""' this.state.buf += '""'
return this.goto(this.parseMultiStringContent) return this.goto(this.parseMultiStringContent)
} }
} }
parseMultiEnd3 () {
if (this.char === CHAR_QUOT) {
this.state.buf += '"'
return this.next(this.parseMultiEnd4)
} else {
return this.returnNow()
}
}
parseMultiEnd4 () {
if (this.char === CHAR_QUOT) {
this.state.buf += '"'
return this.return()
} else {
return this.returnNow()
}
}
parseMultiEscape () { parseMultiEscape () {
if (this.char === CTRL_M || this.char === CTRL_J) { if (this.char === CTRL_M || this.char === CTRL_J) {
return this.next(this.parseMultiTrim) return this.next(this.parseMultiTrim)
@ -47704,13 +47739,7 @@ function makeParserClass (Parser) {
} }
} }
recordInlineListValue (value) { recordInlineListValue (value) {
if (this.state.resultArr) { if (!this.state.resultArr) {
const listType = this.state.resultArr[_contentType]
const valueType = tomlType(value)
if (listType !== valueType) {
throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`))
}
} else {
this.state.resultArr = InlineList(tomlType(value)) this.state.resultArr = InlineList(tomlType(value))
} }
if (isFloat(value) || isInteger(value)) { if (isFloat(value) || isInteger(value)) {
@ -47773,13 +47802,26 @@ function makeParserClass (Parser) {
} else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) { } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
throw this.error(new TomlError('Unterminated inline array')) throw this.error(new TomlError('Unterminated inline array'))
} else if (this.char === CHAR_COMMA) { } else if (this.char === CHAR_COMMA) {
return this.next(this.parseInlineTable) return this.next(this.parseInlineTablePostComma)
} else if (this.char === CHAR_RCUB) { } else if (this.char === CHAR_RCUB) {
return this.goto(this.parseInlineTable) return this.goto(this.parseInlineTable)
} else { } else {
throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])')) throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'))
} }
} }
parseInlineTablePostComma () {
if (this.char === CHAR_SP || this.char === CTRL_I) {
return null
} else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
throw this.error(new TomlError('Unterminated inline array'))
} else if (this.char === CHAR_COMMA) {
throw this.error(new TomlError('Empty elements in inline tables are not permitted'))
} else if (this.char === CHAR_RCUB) {
throw this.error(new TomlError('Trailing commas in inline tables are not permitted'))
} else {
return this.goto(this.parseInlineTable)
}
}
} }
return TOMLParser return TOMLParser
} }
@ -48017,10 +48059,6 @@ function typeError (type) {
return new Error('Can only stringify objects, not ' + type) return new Error('Can only stringify objects, not ' + type)
} }
function arrayOneTypeError () {
return new Error("Array values can't have mixed types")
}
function getInlineKeys (obj) { function getInlineKeys (obj) {
return Object.keys(obj).filter(key => isInline(obj[key])) return Object.keys(obj).filter(key => isInline(obj[key]))
} }
@ -48042,12 +48080,12 @@ function toJSON (obj) {
function stringifyObject (prefix, indent, obj) { function stringifyObject (prefix, indent, obj) {
obj = toJSON(obj) obj = toJSON(obj)
var inlineKeys let inlineKeys
var complexKeys let complexKeys
inlineKeys = getInlineKeys(obj) inlineKeys = getInlineKeys(obj)
complexKeys = getComplexKeys(obj) complexKeys = getComplexKeys(obj)
var result = [] const result = []
var inlineIndent = indent || '' const inlineIndent = indent || ''
inlineKeys.forEach(key => { inlineKeys.forEach(key => {
var type = tomlType(obj[key]) var type = tomlType(obj[key])
if (type !== 'undefined' && type !== 'null') { if (type !== 'undefined' && type !== 'null') {
@ -48055,7 +48093,7 @@ function stringifyObject (prefix, indent, obj) {
} }
}) })
if (result.length > 0) result.push('') if (result.length > 0) result.push('')
var complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : '' const complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : ''
complexKeys.forEach(key => { complexKeys.forEach(key => {
result.push(stringifyComplex(prefix, complexIndent, key, obj[key])) result.push(stringifyComplex(prefix, complexIndent, key, obj[key]))
}) })
@ -48107,7 +48145,7 @@ function tomlType (value) {
} }
function stringifyKey (key) { function stringifyKey (key) {
var keyStr = String(key) const keyStr = String(key)
if (/^[-A-Za-z0-9_]+$/.test(keyStr)) { if (/^[-A-Za-z0-9_]+$/.test(keyStr)) {
return keyStr return keyStr
} else { } else {
@ -48203,9 +48241,7 @@ function stringifyFloat (value) {
} else if (Object.is(value, -0)) { } else if (Object.is(value, -0)) {
return '-0.0' return '-0.0'
} }
var chunks = String(value).split('.') const [int, dec] = String(value).split('.')
var int = chunks[0]
var dec = chunks[1] || 0
return stringifyInteger(int) + '.' + dec return stringifyInteger(int) + '.' + dec
} }
@ -48217,29 +48253,10 @@ function stringifyDatetime (value) {
return value.toISOString() return value.toISOString()
} }
function isNumber (type) {
return type === 'float' || type === 'integer'
}
function arrayType (values) {
var contentType = tomlType(values[0])
if (values.every(_ => tomlType(_) === contentType)) return contentType
// mixed integer/float, emit as floats
if (values.every(_ => isNumber(tomlType(_)))) return 'float'
return 'mixed'
}
function validateArray (values) {
const type = arrayType(values)
if (type === 'mixed') {
throw arrayOneTypeError()
}
return type
}
function stringifyInlineArray (values) { function stringifyInlineArray (values) {
values = toJSON(values) values = toJSON(values)
const type = validateArray(values) let result = '['
var result = '[' const stringified = values.map(_ => stringifyInline(_))
var stringified = values.map(_ => stringifyInline(_, type))
if (stringified.join(', ').length > 60 || /\n/.test(stringified)) { if (stringified.join(', ').length > 60 || /\n/.test(stringified)) {
result += '\n ' + stringified.join(',\n ') + '\n' result += '\n ' + stringified.join(',\n ') + '\n'
} else { } else {
@ -48250,7 +48267,7 @@ function stringifyInlineArray (values) {
function stringifyInlineTable (value) { function stringifyInlineTable (value) {
value = toJSON(value) value = toJSON(value)
var result = [] const result = []
Object.keys(value).forEach(key => { Object.keys(value).forEach(key => {
result.push(stringifyKey(key) + ' = ' + stringifyAnyInline(value[key], false)) result.push(stringifyKey(key) + ' = ' + stringifyAnyInline(value[key], false))
}) })
@ -48258,7 +48275,7 @@ function stringifyInlineTable (value) {
} }
function stringifyComplex (prefix, indent, key, value) { function stringifyComplex (prefix, indent, key, value) {
var valueType = tomlType(value) const valueType = tomlType(value)
/* istanbul ignore else */ /* istanbul ignore else */
if (valueType === 'array') { if (valueType === 'array') {
return stringifyArrayOfTables(prefix, indent, key, value) return stringifyArrayOfTables(prefix, indent, key, value)
@ -48271,12 +48288,11 @@ function stringifyComplex (prefix, indent, key, value) {
function stringifyArrayOfTables (prefix, indent, key, values) { function stringifyArrayOfTables (prefix, indent, key, values) {
values = toJSON(values) values = toJSON(values)
validateArray(values) const firstValueType = tomlType(values[0])
var firstValueType = tomlType(values[0])
/* istanbul ignore if */ /* istanbul ignore if */
if (firstValueType !== 'table') throw typeError(firstValueType) if (firstValueType !== 'table') throw typeError(firstValueType)
var fullKey = prefix + stringifyKey(key) const fullKey = prefix + stringifyKey(key)
var result = '' let result = ''
values.forEach(table => { values.forEach(table => {
if (result.length > 0) result += '\n' if (result.length > 0) result += '\n'
result += indent + '[[' + fullKey + ']]\n' result += indent + '[[' + fullKey + ']]\n'
@ -48286,8 +48302,8 @@ function stringifyArrayOfTables (prefix, indent, key, values) {
} }
function stringifyComplexTable (prefix, indent, key, value) { function stringifyComplexTable (prefix, indent, key, value) {
var fullKey = prefix + stringifyKey(key) const fullKey = prefix + stringifyKey(key)
var result = '' let result = ''
if (getInlineKeys(value).length > 0) { if (getInlineKeys(value).length > 0) {
result += indent + '[' + fullKey + ']\n' result += indent + '[' + fullKey + ']\n'
} }

8
package-lock.json generated
View file

@ -16,7 +16,7 @@
"@actions/http-client": "^2.2.1", "@actions/http-client": "^2.2.1",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@iarna/toml": "^2.2.5", "@iarna/toml": "^3.0.0",
"semver": "^7.6.0" "semver": "^7.6.0"
}, },
"devDependencies": { "devDependencies": {
@ -1084,9 +1084,9 @@
"dev": true "dev": true
}, },
"node_modules/@iarna/toml": { "node_modules/@iarna/toml": {
"version": "2.2.5", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz", "resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-3.0.0.tgz",
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" "integrity": "sha512-td6ZUkz2oS3VeleBcN+m//Q6HlCFCPrnI0FZhrt/h4XqLEdOyYp2u21nd8MdsR+WJy5r9PTDaHTDDfhf4H4l6Q=="
}, },
"node_modules/@istanbuljs/load-nyc-config": { "node_modules/@istanbuljs/load-nyc-config": {
"version": "1.1.0", "version": "1.1.0",

View file

@ -32,7 +32,7 @@
"@actions/http-client": "^2.2.1", "@actions/http-client": "^2.2.1",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@iarna/toml": "^2.2.5", "@iarna/toml": "^3.0.0",
"semver": "^7.6.0" "semver": "^7.6.0"
}, },
"devDependencies": { "devDependencies": {