Skip to content

Commit 9ba6b4e

Browse files
committed
fix(core): fix the value check for publishConfig.provenance
Signed-off-by: Sora Morimoto <sora@morimoto.io>
1 parent 8661aac commit 9ba6b4e

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

.yarn/versions/d2747135.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
releases:
2+
"@yarnpkg/core": patch
3+
4+
declined:
5+
- "@yarnpkg/plugin-compat"
6+
- "@yarnpkg/plugin-constraints"
7+
- "@yarnpkg/plugin-dlx"
8+
- "@yarnpkg/plugin-essentials"
9+
- "@yarnpkg/plugin-exec"
10+
- "@yarnpkg/plugin-file"
11+
- "@yarnpkg/plugin-git"
12+
- "@yarnpkg/plugin-github"
13+
- "@yarnpkg/plugin-http"
14+
- "@yarnpkg/plugin-init"
15+
- "@yarnpkg/plugin-interactive-tools"
16+
- "@yarnpkg/plugin-jsr"
17+
- "@yarnpkg/plugin-link"
18+
- "@yarnpkg/plugin-nm"
19+
- "@yarnpkg/plugin-npm"
20+
- "@yarnpkg/plugin-npm-cli"
21+
- "@yarnpkg/plugin-pack"
22+
- "@yarnpkg/plugin-patch"
23+
- "@yarnpkg/plugin-pnp"
24+
- "@yarnpkg/plugin-pnpm"
25+
- "@yarnpkg/plugin-stage"
26+
- "@yarnpkg/plugin-typescript"
27+
- "@yarnpkg/plugin-version"
28+
- "@yarnpkg/plugin-workspace-tools"
29+
- "@yarnpkg/builder"
30+
- "@yarnpkg/cli"
31+
- "@yarnpkg/doctor"
32+
- "@yarnpkg/extensions"
33+
- "@yarnpkg/nm"
34+
- "@yarnpkg/pnpify"
35+
- "@yarnpkg/sdks"

packages/yarnpkg-core/sources/Manifest.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@ export class Manifest {
523523
if (typeof data.publishConfig.registry === `string`)
524524
this.publishConfig.registry = data.publishConfig.registry;
525525

526+
if (typeof data.publishConfig.provenance === `boolean`)
527+
this.publishConfig.provenance = data.publishConfig.provenance;
528+
526529
if (typeof data.publishConfig.bin === `string`) {
527530
if (this.name !== null) {
528531
this.publishConfig.bin = new Map([[this.name.name, normalizeSlashes(data.publishConfig.bin)]]);

packages/yarnpkg-core/tests/Manifest.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,21 @@ describe(`Manifest`, () => {
5555
expect(manifest.exportTo({}).bin).toEqual({bin2: `./bin2.js`});
5656
});
5757
});
58+
59+
describe(`publishConfig`, () => {
60+
it(`should parse provenance field when set to true`, () => {
61+
const manifest = Manifest.fromText(`{ "publishConfig": { "provenance": true } }`);
62+
expect(manifest.publishConfig?.provenance).toBe(true);
63+
});
64+
65+
it(`should parse provenance field when set to false`, () => {
66+
const manifest = Manifest.fromText(`{ "publishConfig": { "provenance": false } }`);
67+
expect(manifest.publishConfig?.provenance).toBe(false);
68+
});
69+
70+
it(`should ignore non-boolean provenance values`, () => {
71+
const manifest = Manifest.fromText(`{ "publishConfig": { "provenance": "true" } }`);
72+
expect(manifest.publishConfig?.provenance).toBeUndefined();
73+
});
74+
});
5875
});

0 commit comments

Comments
 (0)