You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): fix the value check for publishConfig.provenance (#6781)
## 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>
0 commit comments