Skip to content

Commit

Permalink
fix: Support TOML up to v1.0.0-rc.1 spec. (#1837)
Browse files Browse the repository at this point in the history
* test(updaters): Failing test for updating TOML v1.0.0 spec heterogenous arrays.

Signed-off-by: Braden Mars <bradenmars@bradenmars.me>

* fix(deps): Update @iarna/toml to 3.0.0 for TOML v1.0.0-rc.1 spec support

Signed-off-by: Braden Mars <bradenmars@bradenmars.me>

* test(updaters): update GenericToml v1.0.0 spec snapshot.

Signed-off-by: Braden Mars <bradenmars@bradenmars.me>

---------

Signed-off-by: Braden Mars <bradenmars@bradenmars.me>
  • Loading branch information
BradenM authored Jan 30, 2023
1 parent fa92311 commit a3d94ee
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
22 changes: 22 additions & 0 deletions __snapshots__/generic-toml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <foo@example.com>",
{ name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
]
`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions test/updaters/fixtures/toml/v1.0.0.toml
Original file line number Diff line number Diff line change
@@ -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 <foo@example.com>",
{ name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
]
13 changes: 13 additions & 0 deletions test/updaters/generic-toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

0 comments on commit a3d94ee

Please sign in to comment.