Skip to content

Add step to normalize, fix logging bug, remove backward compatibility tests#144

Merged
wraithgar merged 10 commits intomainfrom
gar/rpj-root
Jul 15, 2025
Merged

Add step to normalize, fix logging bug, remove backward compatibility tests#144
wraithgar merged 10 commits intomainfrom
gar/rpj-root

Conversation

@wraithgar
Copy link
Member

@wraithgar wraithgar commented Mar 12, 2025

This adds binDir to the normalize step. See the individual commit for the full story.

While adding that I noticed another bug where the bundledDependencies logging warning was always being emitted, even if there was nothing being done. This bug is now fixed.

@wraithgar wraithgar requested a review from a team as a code owner March 12, 2025 16:38
@wraithgar wraithgar force-pushed the gar/rpj-root branch 2 times, most recently from 2d054de to 675beab Compare March 12, 2025 17:37
@wraithgar
Copy link
Member Author

It's time to stop doing parallel read-package-json-fast test. That package doesn't re-normalize directories.bin entries which makes our parity tests fail. @npmcli/package-json is now more correct than read-package-json-fast is.

@wraithgar wraithgar changed the title Add step to normalize, fix logging bug Add step to normalize, fix logging bug, remove backward compatibility tests Jul 2, 2025
owlstronaut
owlstronaut previously approved these changes Jul 2, 2025
This was always logging, not just only if it was doing the action
This adds the `binDir` step to `.normalize()`.  This will translate `directories.bin` into a `.bin` entry.

`read-package-json-fast` technically had TWO apis.  You could call it as exported, or you could call `.normalize`.  The only difference between the two was that `.normalize` did not include the translation of `directories.bin` into `.bin`.  We don't need another top level api for this package.  Adding `binDir` to the `normalize` step is the right one.  That's part of preparing a package for local consumption.  I'm relatively certain we have bugs we've missed here because of this.  This also means any bugs we fix in `binDir` will be fixed in all use cases.  The existing `binDir` step (using glob) is also preferable to the code that `read-package-json-fast` was using (using manual recursive directory walking).

Ultimately this will help us finish porting existing code that uses `read-package-json-fast` to this library.
Also tweaked logging statement to help w/ debugging
read-package-json and read-package-json-fast test were initially put in place to ensure this package was fully compatible.

This package is now used almost everywhere in npm, and the things we are adding to finish the removal of those other packages is MORE correct here than in those old packages, so the tests won't even work anymore.
This is a prepare step.  In normalize it currently just changes it to an empty array which is fine
This is an affordance so that arborist can stop using read-package-json-fast.

It currently calls read-package-json.normalize which is a synchronous function, different than read-package-json-fast() itself.  We need this package to have an equivalent that skips the directories.bin expansion (which is asynchronous) and the _attribute stripping (which would break arborist)
@wraithgar wraithgar merged commit dbc9ef1 into main Jul 15, 2025
21 checks passed
@wraithgar wraithgar deleted the gar/rpj-root branch July 15, 2025 19:58
owlstronaut pushed a commit that referenced this pull request Aug 28, 2025
🤖 I have created a release *beep* *boop*
---


## [7.0.0](v6.2.0...v7.0.0)
(2025-07-25)
### ⚠️ BREAKING CHANGES
* `package-json` now supports node `^20.17.0 || >=22.9.0`
### Features
*
[`9dd0eb5`](9dd0eb5)
[#144](#144) add syncNormalize
(@wraithgar)
*
[`08eae47`](08eae47)
[#144](#144) add binDir step to
normalize function (@wraithgar)
### Bug Fixes
*
[`a5e4ac3`](a5e4ac3)
[#152](#152) align to npm 11
node engine range (@owlstronaut)
*
[`4695e87`](4695e87)
[#150](#150) use `URL.canParse`
instead of runtime deprecated `url.parse` api (#150) (@SuperchupuDev)
*
[`dbc9ef1`](dbc9ef1)
[#144](#144) require an object
in fromContent() (@wraithgar)
*
[`f06eb18`](f06eb18)
[#144](#144) remove unused
bundleDependenciesFalse (@wraithgar)
*
[`a8b1cc9`](a8b1cc9)
[#144](#144) secure and unixify
paths discovered via directories.bin (@wraithgar)
*
[`23c29a9`](23c29a9)
[#144](#144) remove erroneous
bundledDependencies log (@wraithgar)
### Documentation
*
[`14f8141`](14f8141)
[#147](#147) adding sort option
docs to README (#147) (@idhard)
### Dependencies
*
[`a0dcfde`](a0dcfde)
[#152](#152)
`hosted-git-info@9.0.0`
*
[`41128c1`](41128c1)
[#152](#152) `glob@11.0.3`
### Chores
*
[`a179a87`](a179a87)
[#144](#144) fix tests to await
async normalize (@wraithgar)
*
[`203fec8`](203fec8)
[#144](#144) remove
read-package-json (@wraithgar)
*
[`7bde184`](7bde184)
[#144](#144) remove
read-package-json-fast (@wraithgar)
*
[`394192d`](394192d)
[#144](#144) remove backward
compatiblity tests (@wraithgar)
*
[`6e89e39`](6e89e39)
[#148](#148) bump
@npmcli/template-oss from 4.23.6 to 4.25.0 (#148) (@dependabot[bot],
@owlstronaut)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants