Commit bc95336
fix(core): fix the value check for
## What's the problem this PR addresses?
This PR resolves an issue where the `publishConfig.provenance` field in
`package.json` wasn't being read correctly.
Specifically:
- When `publishConfig.provenance: true` was set in `package.json`,
Yarn's `npm publish` command wouldn't generate provenance statements
- Whilst the `PublishConfig` interface had `provenance?: boolean`
defined, the `load` method in `Manifest.ts` was missing the processing
logic for the `provenance` field when handling `publishConfig`
- Other fields (`access`, `main`, `module`, `browser`, `registry`,
`bin`, `executableFiles`) were being processed correctly, but
`provenance` was the only one being omitted
## How did you fix it?
I added the following code to the `publishConfig` processing section
within the `load` method in `packages/yarnpkg-core/sources/Manifest.ts`:
```typescript
if (typeof data.publishConfig.provenance === `boolean`)
this.publishConfig.provenance = data.publishConfig.provenance;
```
This fix ensures:
1. The `publishConfig.provenance` field in `package.json` is read
correctly when it's a boolean value
2. It becomes available as `workspace.manifest.publishConfig.provenance`
3. The existing logic in `npm publish` command (`publish.ts` lines
109-120) functions properly
Additionally, to ensure the accuracy of the fix, I added test cases to
`packages/yarnpkg-core/tests/Manifest.test.ts`:
- Test for when `provenance: true` is set
- Test for when `provenance: false` is set
- Test to verify that non-boolean values are ignored
With this fix, when `publishConfig.provenance` is configured in
`package.json`, provenance statements will be generated as expected.
## Checklist
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
---------
Signed-off-by: Sora Morimoto <sora@morimoto.io>
Co-authored-by: Maël Nison <nison.mael@gmail.com>publishConfig.provenance (#6781)1 parent 73f0354 commit bc95336
3 files changed
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
526 | 529 | | |
527 | 530 | | |
528 | 531 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
58 | 75 | | |
0 commit comments