Skip to content

Commit

Permalink
Updated @iarna/toml version to 3.0.0 (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
priya-kinthali authored Jul 22, 2024
1 parent 39cd149 commit cb68456
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .licenses/npm/@iarna/toml.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

134 changes: 75 additions & 59 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46726,14 +46726,15 @@ function makeParserClass (Parser) {
let target = this.ctx
let finalKey = kv.key.pop()
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"))
}
target = target[kw] = target[kw] || Table()
}
if (hasKey(target, finalKey)) {
throw this.error(new TomlError("Can't redefine existing key"))
}
target[_declared] = true
// unbox our numbers
if (isInteger(kv.value) || isFloat(kv.value)) {
target[finalKey] = kv.value.valueOf()
Expand Down Expand Up @@ -46791,6 +46792,8 @@ function makeParserClass (Parser) {
do {
if (this.char === Parser.END || this.char === CTRL_J) {
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())
}
Expand Down Expand Up @@ -47004,7 +47007,7 @@ function makeParserClass (Parser) {
} else if (this.atEndOfLine()) {
throw this.error(new TomlError('Unterminated string'))
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) {
throw this.errorControlCharInString()
throw this.errorControlCharIn('strings')
} else {
this.consume()
}
Expand Down Expand Up @@ -47033,7 +47036,7 @@ function makeParserClass (Parser) {
} else if (this.char === Parser.END) {
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)) {
throw this.errorControlCharInString()
throw this.errorControlCharIn('strings')
} else {
this.consume()
}
Expand All @@ -47049,12 +47052,28 @@ function makeParserClass (Parser) {
}
parseLiteralMultiEnd2 () {
if (this.char === CHAR_APOS) {
return this.return()
return this.next(this.parseLiteralMultiEnd3)
} else {
this.state.buf += "''"
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 */
parseDoubleString () {
Expand All @@ -47073,7 +47092,7 @@ function makeParserClass (Parser) {
} else if (this.atEndOfLine()) {
throw this.error(new TomlError('Unterminated string'))
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) {
throw this.errorControlCharInString()
throw this.errorControlCharIn('strings')
} else {
this.consume()
}
Expand Down Expand Up @@ -47108,20 +47127,20 @@ function makeParserClass (Parser) {
} else if (this.char === Parser.END) {
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)) {
throw this.errorControlCharInString()
throw this.errorControlCharIn('strings')
} else {
this.consume()
}
} while (this.nextChar())
}
errorControlCharInString () {
errorControlCharIn (type) {
let displayCode = '\\u00'
if (this.char < 16) {
displayCode += '0'
}
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) {
this.state.buf += replacement
Expand All @@ -47137,12 +47156,28 @@ function makeParserClass (Parser) {
}
parseMultiEnd2 () {
if (this.char === CHAR_QUOT) {
return this.return()
return this.next(this.parseMultiEnd3)
} else {
this.state.buf += '""'
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 () {
if (this.char === CTRL_M || this.char === CTRL_J) {
return this.next(this.parseMultiTrim)
Expand Down Expand Up @@ -47704,13 +47739,7 @@ function makeParserClass (Parser) {
}
}
recordInlineListValue (value) {
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 {
if (!this.state.resultArr) {
this.state.resultArr = InlineList(tomlType(value))
}
if (isFloat(value) || isInteger(value)) {
Expand Down Expand Up @@ -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) {
throw this.error(new TomlError('Unterminated inline array'))
} else if (this.char === CHAR_COMMA) {
return this.next(this.parseInlineTable)
return this.next(this.parseInlineTablePostComma)
} else if (this.char === CHAR_RCUB) {
return this.goto(this.parseInlineTable)
} else {
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
}
Expand Down Expand Up @@ -48017,10 +48059,6 @@ function typeError (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) {
return Object.keys(obj).filter(key => isInline(obj[key]))
}
Expand All @@ -48042,20 +48080,20 @@ function toJSON (obj) {

function stringifyObject (prefix, indent, obj) {
obj = toJSON(obj)
var inlineKeys
var complexKeys
let inlineKeys
let complexKeys
inlineKeys = getInlineKeys(obj)
complexKeys = getComplexKeys(obj)
var result = []
var inlineIndent = indent || ''
const result = []
const inlineIndent = indent || ''
inlineKeys.forEach(key => {
var type = tomlType(obj[key])
if (type !== 'undefined' && type !== 'null') {
result.push(inlineIndent + stringifyKey(key) + ' = ' + stringifyAnyInline(obj[key], true))
}
})
if (result.length > 0) result.push('')
var complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : ''
const complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : ''
complexKeys.forEach(key => {
result.push(stringifyComplex(prefix, complexIndent, key, obj[key]))
})
Expand Down Expand Up @@ -48107,7 +48145,7 @@ function tomlType (value) {
}

function stringifyKey (key) {
var keyStr = String(key)
const keyStr = String(key)
if (/^[-A-Za-z0-9_]+$/.test(keyStr)) {
return keyStr
} else {
Expand Down Expand Up @@ -48203,9 +48241,7 @@ function stringifyFloat (value) {
} else if (Object.is(value, -0)) {
return '-0.0'
}
var chunks = String(value).split('.')
var int = chunks[0]
var dec = chunks[1] || 0
const [int, dec] = String(value).split('.')
return stringifyInteger(int) + '.' + dec
}

Expand All @@ -48217,29 +48253,10 @@ function stringifyDatetime (value) {
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) {
values = toJSON(values)
const type = validateArray(values)
var result = '['
var stringified = values.map(_ => stringifyInline(_, type))
let result = '['
const stringified = values.map(_ => stringifyInline(_))
if (stringified.join(', ').length > 60 || /\n/.test(stringified)) {
result += '\n ' + stringified.join(',\n ') + '\n'
} else {
Expand All @@ -48250,15 +48267,15 @@ function stringifyInlineArray (values) {

function stringifyInlineTable (value) {
value = toJSON(value)
var result = []
const result = []
Object.keys(value).forEach(key => {
result.push(stringifyKey(key) + ' = ' + stringifyAnyInline(value[key], false))
})
return '{ ' + result.join(', ') + (result.length > 0 ? ' ' : '') + '}'
}

function stringifyComplex (prefix, indent, key, value) {
var valueType = tomlType(value)
const valueType = tomlType(value)
/* istanbul ignore else */
if (valueType === 'array') {
return stringifyArrayOfTables(prefix, indent, key, value)
Expand All @@ -48271,12 +48288,11 @@ function stringifyComplex (prefix, indent, key, value) {

function stringifyArrayOfTables (prefix, indent, key, values) {
values = toJSON(values)
validateArray(values)
var firstValueType = tomlType(values[0])
const firstValueType = tomlType(values[0])
/* istanbul ignore if */
if (firstValueType !== 'table') throw typeError(firstValueType)
var fullKey = prefix + stringifyKey(key)
var result = ''
const fullKey = prefix + stringifyKey(key)
let result = ''
values.forEach(table => {
if (result.length > 0) result += '\n'
result += indent + '[[' + fullKey + ']]\n'
Expand All @@ -48286,8 +48302,8 @@ function stringifyArrayOfTables (prefix, indent, key, values) {
}

function stringifyComplexTable (prefix, indent, key, value) {
var fullKey = prefix + stringifyKey(key)
var result = ''
const fullKey = prefix + stringifyKey(key)
let result = ''
if (getInlineKeys(value).length > 0) {
result += indent + '[' + fullKey + ']\n'
}
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@actions/http-client": "^2.2.1",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.1",
"@iarna/toml": "^2.2.5",
"@iarna/toml": "^3.0.0",
"semver": "^7.6.0"
},
"devDependencies": {
Expand Down

0 comments on commit cb68456

Please sign in to comment.