Skip to content

rfc: Expose arborist metadata to lifecycle scripts#51

Closed
vweevers wants to merge 1 commit into
npm:latestfrom
vweevers:arborist-lifecycle-scripts
Closed

rfc: Expose arborist metadata to lifecycle scripts#51
vweevers wants to merge 1 commit into
npm:latestfrom
vweevers:arborist-lifecycle-scripts

Conversation

@vweevers

Copy link
Copy Markdown

Following the conversation in #38 (comment).

FYI @lovell @ralphtheninja

@darcyclarke darcyclarke added Release 7.x semver:major backwards-incompatible breaking changes semver:minor new backwards-compatible feature and removed semver:major backwards-incompatible breaking changes labels Nov 19, 2019
@isaacs

isaacs commented Nov 19, 2019

Copy link
Copy Markdown
Contributor

This will be included in v7, and may require a fall-back lockfile to support cases where the user installs with --no-shrinkwrap or deletes the shrinkwrap file.

@ljharb

ljharb commented Nov 19, 2019

Copy link
Copy Markdown
Contributor

When you say a "fallback lockfile" do you mean like, a temporary npm install --package-lock --package-lock-only? That'd be great (and it's what would make npm audit work for this scenario as well).

@isaacs

isaacs commented Nov 19, 2019

Copy link
Copy Markdown
Contributor

@ljharb The idea would be a copy (or hard-link) of the lockfile at node_modules/.arborist-lock.json. It would not be authoritative during install (like a file at ./npm-shrinkwrap.json or ./package-lock.json would be), but it would give us a place to stash metadata whenever we change or read the package tree if the user is running with --no-shrinkwrap or --no-save.

That would also let us make things like npm ls and npm fund much faster, since we can be reasonably confident that bundled fallback lockfile reflects what's actually in the tree.

@isaacs

isaacs commented Nov 19, 2019

Copy link
Copy Markdown
Contributor

And yeah, it would make npm audit work even if there is no lockfile in the project root.

@ljharb

ljharb commented Nov 19, 2019

Copy link
Copy Markdown
Contributor

That sounds awesome, especially if npm install --save and friends iteratively updated it.

@isaacs

isaacs commented Nov 19, 2019

Copy link
Copy Markdown
Contributor

That sounds awesome, especially if npm install --save and friends iteratively updated it.

The idea would be that it gets updated even when --no-save is set. It'd be kept in sync 100% of the time, regardless of what we do (or don't do) to the package.json and package-lock.json.

@isaacs

isaacs commented Jan 22, 2020

Copy link
Copy Markdown
Contributor

I think the needs here are addressed by #90.

Basically, arborist will set npm_package_from, npm_package_resolved, and npm_package_integrity, for the package having its lifecycle script run.

I presume that will satisfy your needs?

@vweevers

Copy link
Copy Markdown
Author

Looks good, thanks!

I think the removal of npm_config_argv will also affect prebuild & friends, however. I'll check and then comment in #90.

@vweevers vweevers closed this Jan 22, 2020
owlstronaut pushed a commit that referenced this pull request May 29, 2026
Bot-generated follow-up to the merge of
`accepted/0000-validate-signatures.md`.

Assigns RFC number **51**, renames the file to
`accepted/0051-validate-signatures.md`, fills in front-matter (`status`,
`accepted_at`, `created`), and regenerates `INDEX.md`.

Front-matter was synthesized from the file's `# Title` heading. Edit the
front-matter or the title in this PR if you need different values, then
merge.

Co-authored-by: npm CLI robot <[email protected]>
owlstronaut pushed a commit that referenced this pull request May 29, 2026
Bot-generated transition of RFC **#51** to status `implemented`.

Moved to `implemented/0051-validate-signatures.md`. Front-matter
`status` and the relevant date field were updated. `INDEX.md` was
regenerated.

Implementation: npm/cli#4827

Co-authored-by: npm CLI robot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:minor new backwards-compatible feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants