Skip to content

Commit cb68456

Browse files
Updated @iarna/toml version to 3.0.0 (#912)
1 parent 39cd149 commit cb68456

File tree

4 files changed

+81
-65
lines changed

4 files changed

+81
-65
lines changed

Diff for: .licenses/npm/@iarna/toml.dep.yml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/setup/index.js

+75-59
Original file line numberDiff line numberDiff line change
@@ -46726,14 +46726,15 @@ function makeParserClass (Parser) {
4672646726
let target = this.ctx
4672746727
let finalKey = kv.key.pop()
4672846728
for (let kw of kv.key) {
46729-
if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
46729+
if (hasKey(target, kw) && !isTable(target[kw])) {
4673046730
throw this.error(new TomlError("Can't redefine existing key"))
4673146731
}
4673246732
target = target[kw] = target[kw] || Table()
4673346733
}
4673446734
if (hasKey(target, finalKey)) {
4673546735
throw this.error(new TomlError("Can't redefine existing key"))
4673646736
}
46737+
target[_declared] = true
4673746738
// unbox our numbers
4673846739
if (isInteger(kv.value) || isFloat(kv.value)) {
4673946740
target[finalKey] = kv.value.valueOf()
@@ -46791,6 +46792,8 @@ function makeParserClass (Parser) {
4679146792
do {
4679246793
if (this.char === Parser.END || this.char === CTRL_J) {
4679346794
return this.return()
46795+
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) {
46796+
throw this.errorControlCharIn('comments')
4679446797
}
4679546798
} while (this.nextChar())
4679646799
}
@@ -47004,7 +47007,7 @@ function makeParserClass (Parser) {
4700447007
} else if (this.atEndOfLine()) {
4700547008
throw this.error(new TomlError('Unterminated string'))
4700647009
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) {
47007-
throw this.errorControlCharInString()
47010+
throw this.errorControlCharIn('strings')
4700847011
} else {
4700947012
this.consume()
4701047013
}
@@ -47033,7 +47036,7 @@ function makeParserClass (Parser) {
4703347036
} else if (this.char === Parser.END) {
4703447037
throw this.error(new TomlError('Unterminated multi-line string'))
4703547038
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)) {
47036-
throw this.errorControlCharInString()
47039+
throw this.errorControlCharIn('strings')
4703747040
} else {
4703847041
this.consume()
4703947042
}
@@ -47049,12 +47052,28 @@ function makeParserClass (Parser) {
4704947052
}
4705047053
parseLiteralMultiEnd2 () {
4705147054
if (this.char === CHAR_APOS) {
47052-
return this.return()
47055+
return this.next(this.parseLiteralMultiEnd3)
4705347056
} else {
4705447057
this.state.buf += "''"
4705547058
return this.goto(this.parseLiteralMultiStringContent)
4705647059
}
4705747060
}
47061+
parseLiteralMultiEnd3 () {
47062+
if (this.char === CHAR_APOS) {
47063+
this.state.buf += "'"
47064+
return this.next(this.parseLiteralMultiEnd4)
47065+
} else {
47066+
return this.returnNow()
47067+
}
47068+
}
47069+
parseLiteralMultiEnd4 () {
47070+
if (this.char === CHAR_APOS) {
47071+
this.state.buf += "'"
47072+
return this.return()
47073+
} else {
47074+
return this.returnNow()
47075+
}
47076+
}
4705847077

4705947078
/* STRINGS double quoted */
4706047079
parseDoubleString () {
@@ -47073,7 +47092,7 @@ function makeParserClass (Parser) {
4707347092
} else if (this.atEndOfLine()) {
4707447093
throw this.error(new TomlError('Unterminated string'))
4707547094
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)) {
47076-
throw this.errorControlCharInString()
47095+
throw this.errorControlCharIn('strings')
4707747096
} else {
4707847097
this.consume()
4707947098
}
@@ -47108,20 +47127,20 @@ function makeParserClass (Parser) {
4710847127
} else if (this.char === Parser.END) {
4710947128
throw this.error(new TomlError('Unterminated multi-line string'))
4711047129
} else if (this.char === CHAR_DEL || (this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)) {
47111-
throw this.errorControlCharInString()
47130+
throw this.errorControlCharIn('strings')
4711247131
} else {
4711347132
this.consume()
4711447133
}
4711547134
} while (this.nextChar())
4711647135
}
47117-
errorControlCharInString () {
47136+
errorControlCharIn (type) {
4711847137
let displayCode = '\\u00'
4711947138
if (this.char < 16) {
4712047139
displayCode += '0'
4712147140
}
4712247141
displayCode += this.char.toString(16)
4712347142

47124-
return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`))
47143+
return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in ${type}, use ${displayCode} instead`))
4712547144
}
4712647145
recordMultiEscapeReplacement (replacement) {
4712747146
this.state.buf += replacement
@@ -47137,12 +47156,28 @@ function makeParserClass (Parser) {
4713747156
}
4713847157
parseMultiEnd2 () {
4713947158
if (this.char === CHAR_QUOT) {
47140-
return this.return()
47159+
return this.next(this.parseMultiEnd3)
4714147160
} else {
4714247161
this.state.buf += '""'
4714347162
return this.goto(this.parseMultiStringContent)
4714447163
}
4714547164
}
47165+
parseMultiEnd3 () {
47166+
if (this.char === CHAR_QUOT) {
47167+
this.state.buf += '"'
47168+
return this.next(this.parseMultiEnd4)
47169+
} else {
47170+
return this.returnNow()
47171+
}
47172+
}
47173+
parseMultiEnd4 () {
47174+
if (this.char === CHAR_QUOT) {
47175+
this.state.buf += '"'
47176+
return this.return()
47177+
} else {
47178+
return this.returnNow()
47179+
}
47180+
}
4714647181
parseMultiEscape () {
4714747182
if (this.char === CTRL_M || this.char === CTRL_J) {
4714847183
return this.next(this.parseMultiTrim)
@@ -47704,13 +47739,7 @@ function makeParserClass (Parser) {
4770447739
}
4770547740
}
4770647741
recordInlineListValue (value) {
47707-
if (this.state.resultArr) {
47708-
const listType = this.state.resultArr[_contentType]
47709-
const valueType = tomlType(value)
47710-
if (listType !== valueType) {
47711-
throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`))
47712-
}
47713-
} else {
47742+
if (!this.state.resultArr) {
4771447743
this.state.resultArr = InlineList(tomlType(value))
4771547744
}
4771647745
if (isFloat(value) || isInteger(value)) {
@@ -47773,13 +47802,26 @@ function makeParserClass (Parser) {
4777347802
} else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
4777447803
throw this.error(new TomlError('Unterminated inline array'))
4777547804
} else if (this.char === CHAR_COMMA) {
47776-
return this.next(this.parseInlineTable)
47805+
return this.next(this.parseInlineTablePostComma)
4777747806
} else if (this.char === CHAR_RCUB) {
4777847807
return this.goto(this.parseInlineTable)
4777947808
} else {
4778047809
throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'))
4778147810
}
4778247811
}
47812+
parseInlineTablePostComma () {
47813+
if (this.char === CHAR_SP || this.char === CTRL_I) {
47814+
return null
47815+
} else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
47816+
throw this.error(new TomlError('Unterminated inline array'))
47817+
} else if (this.char === CHAR_COMMA) {
47818+
throw this.error(new TomlError('Empty elements in inline tables are not permitted'))
47819+
} else if (this.char === CHAR_RCUB) {
47820+
throw this.error(new TomlError('Trailing commas in inline tables are not permitted'))
47821+
} else {
47822+
return this.goto(this.parseInlineTable)
47823+
}
47824+
}
4778347825
}
4778447826
return TOMLParser
4778547827
}
@@ -48017,10 +48059,6 @@ function typeError (type) {
4801748059
return new Error('Can only stringify objects, not ' + type)
4801848060
}
4801948061

48020-
function arrayOneTypeError () {
48021-
return new Error("Array values can't have mixed types")
48022-
}
48023-
4802448062
function getInlineKeys (obj) {
4802548063
return Object.keys(obj).filter(key => isInline(obj[key]))
4802648064
}
@@ -48042,20 +48080,20 @@ function toJSON (obj) {
4804248080

4804348081
function stringifyObject (prefix, indent, obj) {
4804448082
obj = toJSON(obj)
48045-
var inlineKeys
48046-
var complexKeys
48083+
let inlineKeys
48084+
let complexKeys
4804748085
inlineKeys = getInlineKeys(obj)
4804848086
complexKeys = getComplexKeys(obj)
48049-
var result = []
48050-
var inlineIndent = indent || ''
48087+
const result = []
48088+
const inlineIndent = indent || ''
4805148089
inlineKeys.forEach(key => {
4805248090
var type = tomlType(obj[key])
4805348091
if (type !== 'undefined' && type !== 'null') {
4805448092
result.push(inlineIndent + stringifyKey(key) + ' = ' + stringifyAnyInline(obj[key], true))
4805548093
}
4805648094
})
4805748095
if (result.length > 0) result.push('')
48058-
var complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : ''
48096+
const complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : ''
4805948097
complexKeys.forEach(key => {
4806048098
result.push(stringifyComplex(prefix, complexIndent, key, obj[key]))
4806148099
})
@@ -48107,7 +48145,7 @@ function tomlType (value) {
4810748145
}
4810848146

4810948147
function stringifyKey (key) {
48110-
var keyStr = String(key)
48148+
const keyStr = String(key)
4811148149
if (/^[-A-Za-z0-9_]+$/.test(keyStr)) {
4811248150
return keyStr
4811348151
} else {
@@ -48203,9 +48241,7 @@ function stringifyFloat (value) {
4820348241
} else if (Object.is(value, -0)) {
4820448242
return '-0.0'
4820548243
}
48206-
var chunks = String(value).split('.')
48207-
var int = chunks[0]
48208-
var dec = chunks[1] || 0
48244+
const [int, dec] = String(value).split('.')
4820948245
return stringifyInteger(int) + '.' + dec
4821048246
}
4821148247

@@ -48217,29 +48253,10 @@ function stringifyDatetime (value) {
4821748253
return value.toISOString()
4821848254
}
4821948255

48220-
function isNumber (type) {
48221-
return type === 'float' || type === 'integer'
48222-
}
48223-
function arrayType (values) {
48224-
var contentType = tomlType(values[0])
48225-
if (values.every(_ => tomlType(_) === contentType)) return contentType
48226-
// mixed integer/float, emit as floats
48227-
if (values.every(_ => isNumber(tomlType(_)))) return 'float'
48228-
return 'mixed'
48229-
}
48230-
function validateArray (values) {
48231-
const type = arrayType(values)
48232-
if (type === 'mixed') {
48233-
throw arrayOneTypeError()
48234-
}
48235-
return type
48236-
}
48237-
4823848256
function stringifyInlineArray (values) {
4823948257
values = toJSON(values)
48240-
const type = validateArray(values)
48241-
var result = '['
48242-
var stringified = values.map(_ => stringifyInline(_, type))
48258+
let result = '['
48259+
const stringified = values.map(_ => stringifyInline(_))
4824348260
if (stringified.join(', ').length > 60 || /\n/.test(stringified)) {
4824448261
result += '\n ' + stringified.join(',\n ') + '\n'
4824548262
} else {
@@ -48250,15 +48267,15 @@ function stringifyInlineArray (values) {
4825048267

4825148268
function stringifyInlineTable (value) {
4825248269
value = toJSON(value)
48253-
var result = []
48270+
const result = []
4825448271
Object.keys(value).forEach(key => {
4825548272
result.push(stringifyKey(key) + ' = ' + stringifyAnyInline(value[key], false))
4825648273
})
4825748274
return '{ ' + result.join(', ') + (result.length > 0 ? ' ' : '') + '}'
4825848275
}
4825948276

4826048277
function stringifyComplex (prefix, indent, key, value) {
48261-
var valueType = tomlType(value)
48278+
const valueType = tomlType(value)
4826248279
/* istanbul ignore else */
4826348280
if (valueType === 'array') {
4826448281
return stringifyArrayOfTables(prefix, indent, key, value)
@@ -48271,12 +48288,11 @@ function stringifyComplex (prefix, indent, key, value) {
4827148288

4827248289
function stringifyArrayOfTables (prefix, indent, key, values) {
4827348290
values = toJSON(values)
48274-
validateArray(values)
48275-
var firstValueType = tomlType(values[0])
48291+
const firstValueType = tomlType(values[0])
4827648292
/* istanbul ignore if */
4827748293
if (firstValueType !== 'table') throw typeError(firstValueType)
48278-
var fullKey = prefix + stringifyKey(key)
48279-
var result = ''
48294+
const fullKey = prefix + stringifyKey(key)
48295+
let result = ''
4828048296
values.forEach(table => {
4828148297
if (result.length > 0) result += '\n'
4828248298
result += indent + '[[' + fullKey + ']]\n'
@@ -48286,8 +48302,8 @@ function stringifyArrayOfTables (prefix, indent, key, values) {
4828648302
}
4828748303

4828848304
function stringifyComplexTable (prefix, indent, key, value) {
48289-
var fullKey = prefix + stringifyKey(key)
48290-
var result = ''
48305+
const fullKey = prefix + stringifyKey(key)
48306+
let result = ''
4829148307
if (getInlineKeys(value).length > 0) {
4829248308
result += indent + '[' + fullKey + ']\n'
4829348309
}

Diff for: package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@actions/http-client": "^2.2.1",
3333
"@actions/io": "^1.0.2",
3434
"@actions/tool-cache": "^2.0.1",
35-
"@iarna/toml": "^2.2.5",
35+
"@iarna/toml": "^3.0.0",
3636
"semver": "^7.6.0"
3737
},
3838
"devDependencies": {

0 commit comments

Comments
 (0)