Skip to content

Commit 896cc50

Browse files
committed
Update js-yaml to v4
1 parent 60512b5 commit 896cc50

6 files changed

Lines changed: 53 additions & 8 deletions

File tree

.changeset/tall-parks-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/parse": patch
3+
---
4+
5+
Update `js-yaml` to `v4`

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"@types/fs-extra": "^5.1.0",
4444
"@types/jest": "^24.0.12",
4545
"@types/jest-in-case": "^1.0.6",
46-
"@types/js-yaml": "^3.12.1",
4746
"@types/lodash": "^4.17.13",
4847
"@types/node": "^22.14.1",
4948
"@types/prettier": "^2.7.1",

packages/parse/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
"repository": "https://github.com/changesets/changesets/tree/main/packages/parse",
2121
"dependencies": {
2222
"@changesets/types": "^6.1.0",
23-
"js-yaml": "^3.13.1"
23+
"js-yaml": "^4.1.1"
2424
},
2525
"devDependencies": {
26+
"@types/js-yaml": "^4.0.9",
2627
"outdent": "^0.5.0"
2728
}
2829
}

packages/parse/src/index.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,20 @@ describe("parsing a changeset", () => {
213213
summary: "Nice simple summary",
214214
});
215215
});
216+
217+
it("should handle package name unquoted and version quoted", () => {
218+
const changesetMd = `---
219+
pkg: "minor"
220+
---
221+
222+
something`;
223+
const changeset = parse(changesetMd);
224+
expect(changeset).toEqual({
225+
releases: [{ name: "pkg", type: "minor" }],
226+
summary: "something",
227+
});
228+
});
229+
216230
it("should throw if the frontmatter is followed by non-whitespace characters on the same line", () => {
217231
const changesetMd = outdent`---
218232
"cool-package": minor
@@ -229,4 +243,21 @@ describe("parsing a changeset", () => {
229243
Nice simple summary"
230244
`);
231245
});
246+
247+
it("should throw when frontmatter hasn't a valid yml structure", () => {
248+
const changesetMd = outdent`---
249+
: minor
250+
---
251+
252+
Nice simple summary
253+
`;
254+
255+
expect(() => parse(changesetMd)).toThrowErrorMatchingInlineSnapshot(`
256+
"could not parse changeset - invalid frontmatter: ---
257+
: minor
258+
---
259+
260+
Nice simple summary"
261+
`);
262+
});
232263
});

packages/parse/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ export default function parseChangesetFile(contents: string): {
1818

1919
let releases: Release[];
2020
try {
21-
const yamlStuff: { [key: string]: VersionType } =
22-
yaml.safeLoad(roughReleases);
21+
const yamlStuff = yaml.load(roughReleases) as
22+
| Record<string, VersionType>
23+
| undefined;
24+
2325
if (yamlStuff) {
2426
releases = Object.entries(yamlStuff).map(([name, type]) => ({
2527
name,

yarn.lock

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,10 +1777,10 @@
17771777
dependencies:
17781778
"@types/jest-diff" "*"
17791779

1780-
"@types/js-yaml@^3.12.1":
1781-
version "3.12.1"
1782-
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.1.tgz#5c6f4a1eabca84792fbd916f0cb40847f123c656"
1783-
integrity sha512-SGGAhXLHDx+PK4YLNcNGa6goPf9XRWQNAUUbffkwVGGXIxmDKWyGGL4inzq2sPmExu431Ekb9aEMn9BkPqEYFA==
1780+
"@types/js-yaml@^4.0.9":
1781+
version "4.0.9"
1782+
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.9.tgz#cd82382c4f902fed9691a2ed79ec68c5898af4c2"
1783+
integrity sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==
17841784

17851785
"@types/json-schema@^7.0.9":
17861786
version "7.0.11"
@@ -4614,6 +4614,13 @@ js-yaml@^4.1.0:
46144614
dependencies:
46154615
argparse "^2.0.1"
46164616

4617+
js-yaml@^4.1.1:
4618+
version "4.1.1"
4619+
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.1.tgz#854c292467705b699476e1a2decc0c8a3458806b"
4620+
integrity sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==
4621+
dependencies:
4622+
argparse "^2.0.1"
4623+
46174624
jsesc@^3.0.2, jsesc@~3.0.2:
46184625
version "3.0.2"
46194626
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.0.2.tgz#bb8b09a6597ba426425f2e4a07245c3d00b9343e"

0 commit comments

Comments
 (0)