Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support TOML up to v1.0.0-rc.1 spec. #1837

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
});