Skip to content

Commit a3d94ee

Browse files
authored
fix: Support TOML up to v1.0.0-rc.1 spec. (#1837)
* 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>
1 parent fa92311 commit a3d94ee

4 files changed

Lines changed: 54 additions & 1 deletion

File tree

__snapshots__/generic-toml.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,25 @@ x86-64-dep = { version = "1.2.3", registry = "private", path = ".." }
6767
foobar-dep = "1.2.3"
6868
6969
`
70+
71+
exports['GenericToml updateContent updates matching entry with TOML v1.0.0 spec 1'] = `
72+
[package]
73+
version = "2.3.4"
74+
75+
[v1spec]
76+
# taken from toml.io#Arrays examples
77+
integers = [ 1, 2, 3 ]
78+
colors = [ "red", "yellow", "green" ]
79+
nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ]
80+
nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ]
81+
string_array = [ "all", 'strings', """are the same""", '''type''' ]
82+
83+
[heterogenous]
84+
# Mixed-type arrays are allowed
85+
numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]
86+
contributors = [
87+
"Foo Bar <foo@example.com>",
88+
{ name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
89+
]
90+
91+
`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"dependencies": {
7070
"@conventional-commits/parser": "^0.4.1",
7171
"@google-automations/git-file-utils": "^1.2.5",
72-
"@iarna/toml": "^2.2.5",
72+
"@iarna/toml": "^3.0.0",
7373
"@lerna/collect-updates": "^6.4.1",
7474
"@lerna/package": "^6.4.1",
7575
"@lerna/package-graph": "^6.4.1",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
version = '1.0.0'
3+
4+
[v1spec]
5+
# taken from toml.io#Arrays examples
6+
integers = [ 1, 2, 3 ]
7+
colors = [ "red", "yellow", "green" ]
8+
nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ]
9+
nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ]
10+
string_array = [ "all", 'strings', """are the same""", '''type''' ]
11+
12+
[heterogenous]
13+
# Mixed-type arrays are allowed
14+
numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]
15+
contributors = [
16+
"Foo Bar <foo@example.com>",
17+
{ name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
18+
]

test/updaters/generic-toml.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,18 @@ describe('GenericToml', () => {
7676
const newContent = updater.updateContent(oldContent);
7777
expect(newContent).to.eql(oldContent);
7878
});
79+
it('updates matching entry with TOML v1.0.0 spec', async () => {
80+
const oldContent = readFileSync(
81+
resolve(fixturesPath, './toml/v1.0.0.toml'),
82+
'utf8'
83+
).replace(/\r\n/g, '\n');
84+
const updater = new GenericToml(
85+
'$.package.version',
86+
Version.parse('v2.3.4')
87+
);
88+
const newContent = updater.updateContent(oldContent);
89+
expect(newContent).not.to.eql(oldContent);
90+
snapshot(newContent);
91+
});
7992
});
8093
});

0 commit comments

Comments
 (0)