From cf0a809924973618ceec5364543b0f5ba72a2675 Mon Sep 17 00:00:00 2001 From: Braden Mars Date: Sun, 29 Jan 2023 22:16:51 -0600 Subject: [PATCH 1/3] test(updaters): Failing test for updating TOML v1.0.0 spec heterogenous arrays. Signed-off-by: Braden Mars --- test/updaters/fixtures/toml/v1.0.0.toml | 18 ++++++++++++++++++ test/updaters/generic-toml.ts | 13 +++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/updaters/fixtures/toml/v1.0.0.toml 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); + }); }); }); From fd3ed95727b9e09f2abca8bfa5edb7e9b839c5cc Mon Sep 17 00:00:00 2001 From: Braden Mars Date: Sun, 29 Jan 2023 22:26:31 -0600 Subject: [PATCH 2/3] fix(deps): Update @iarna/toml to 3.0.0 for TOML v1.0.0-rc.1 spec support Signed-off-by: Braden Mars --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From bfd984c7cd2d05c79357c22c737724c8743fd9c2 Mon Sep 17 00:00:00 2001 From: Braden Mars Date: Sun, 29 Jan 2023 22:27:08 -0600 Subject: [PATCH 3/3] test(updaters): update GenericToml v1.0.0 spec snapshot. Signed-off-by: Braden Mars --- __snapshots__/generic-toml.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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" } +] + +`