diff --git a/__snapshots__/generic-toml.js b/__snapshots__/generic-toml.js index 85d9d09bc..6bed582be 100644 --- a/__snapshots__/generic-toml.js +++ b/__snapshots__/generic-toml.js @@ -67,3 +67,25 @@ x86-64-dep = { version = "1.2.3", registry = "private", path = ".." } foobar-dep = "1.2.3" ` + +exports['GenericToml updateContent updates matching entry with TOML v1.0.0 spec 1'] = ` +[package] +version = "2.3.4" + +[v1spec] +# taken from toml.io#Arrays examples +integers = [ 1, 2, 3 ] +colors = [ "red", "yellow", "green" ] +nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ] +nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ] +string_array = [ "all", 'strings', """are the same""", '''type''' ] + +[heterogenous] +# Mixed-type arrays are allowed +numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] +contributors = [ + "Foo Bar ", + { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } +] + +` diff --git a/package.json b/package.json index 6572fc56c..afe11c17e 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "dependencies": { "@conventional-commits/parser": "^0.4.1", "@google-automations/git-file-utils": "^1.2.5", - "@iarna/toml": "^2.2.5", + "@iarna/toml": "^3.0.0", "@lerna/collect-updates": "^6.4.1", "@lerna/package": "^6.4.1", "@lerna/package-graph": "^6.4.1", diff --git a/test/updaters/fixtures/toml/v1.0.0.toml b/test/updaters/fixtures/toml/v1.0.0.toml new file mode 100644 index 000000000..4f51715d5 --- /dev/null +++ b/test/updaters/fixtures/toml/v1.0.0.toml @@ -0,0 +1,18 @@ +[package] +version = '1.0.0' + +[v1spec] +# taken from toml.io#Arrays examples +integers = [ 1, 2, 3 ] +colors = [ "red", "yellow", "green" ] +nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ] +nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ] +string_array = [ "all", 'strings', """are the same""", '''type''' ] + +[heterogenous] +# Mixed-type arrays are allowed +numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] +contributors = [ + "Foo Bar ", + { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } +] diff --git a/test/updaters/generic-toml.ts b/test/updaters/generic-toml.ts index 389bd0b83..dfb895ca7 100644 --- a/test/updaters/generic-toml.ts +++ b/test/updaters/generic-toml.ts @@ -76,5 +76,18 @@ describe('GenericToml', () => { const newContent = updater.updateContent(oldContent); expect(newContent).to.eql(oldContent); }); + it('updates matching entry with TOML v1.0.0 spec', async () => { + const oldContent = readFileSync( + resolve(fixturesPath, './toml/v1.0.0.toml'), + 'utf8' + ).replace(/\r\n/g, '\n'); + const updater = new GenericToml( + '$.package.version', + Version.parse('v2.3.4') + ); + const newContent = updater.updateContent(oldContent); + expect(newContent).not.to.eql(oldContent); + snapshot(newContent); + }); }); });