-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
src: add --install runtime flag
#57593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
aduh95
wants to merge
1
commit into
nodejs:main
Choose a base branch
from
aduh95:dash-dash-install
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+16,457
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| 'use strict'; | ||
|
|
||
| const { | ||
| ArrayPrototypeMap, | ||
| JSONParse, | ||
| ObjectEntries, | ||
| SafePromiseAllReturnVoid, | ||
| StringPrototypeSlice, | ||
| } = primordials; | ||
|
|
||
| const { Buffer } = require('buffer'); | ||
| const { readFileSync } = require('fs'); | ||
| const { resolve } = require('path'); | ||
| const { | ||
| codes: { | ||
| ERR_MANIFEST_INTEGRITY_MISMATCH, | ||
| }, | ||
| } = require('internal/errors'); | ||
|
|
||
| const { | ||
| prepareMainThreadExecution, | ||
| markBootstrapComplete, | ||
| } = require('internal/process/pre_execution'); | ||
|
|
||
| const lockFilePath = prepareMainThreadExecution(true); | ||
| markBootstrapComplete(); | ||
|
|
||
| const { packages } = JSONParse(readFileSync(lockFilePath, 'utf-8')); | ||
|
|
||
| if (!packages) { | ||
| return; | ||
| } | ||
|
|
||
| const { download } = require('internal/deps/corepack/dist/lib/download'); | ||
| SafePromiseAllReturnVoid(ArrayPrototypeMap(ObjectEntries(packages), async ({ 0: path, 1: { resolved, integrity } }) => { | ||
| const targetDir = resolve(lockFilePath, `../${path}`); | ||
| const { tmpFolder, outputFile, hash } = await download(`${targetDir}/..`, resolved, 'sha512'); | ||
| if (Buffer.from(hash, 'hex').toString('base64') !== StringPrototypeSlice(integrity, 7)) { | ||
| throw ERR_MANIFEST_INTEGRITY_MISMATCH(); | ||
| } | ||
| const { rename } = require('fs/promises'); | ||
| await rename(outputFile ?? tmpFolder, targetDir); | ||
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "packages": { | ||
| "node_modules/corepack": { | ||
| "resolved": "https://registry.npmjs.org/corepack/-/corepack-0.32.0.tgz", | ||
| "integrity": "sha512-KhahVUFy7xL8OTty/ToY646hXMQhih8rnvUkA9/qnk/u4QUF2+SbQneX/zZnDxG1NiABFm5ojZCWnIv93oyhhQ==" | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this would make Corepack a dependency of Node.js core? I'm not sure how I feel about that. I still have concerns about how it differs so much from the Node codebase (written in TypeScript, dependent on Yarn) and it has an uncertain future. This seems to make the project responsible for Corepack's continued development. It also seems to contradict the recent vote to remove Corepack (I understand it would become a hidden dependency and no longer available as a binary, but presumably it would be accessible via
--expose-internals?)We already bundle npm and it is the canonical dependency downloader; why not use that? Or more targeted dependencies of npm like Arborist.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm has arguably an even more uncertain future, it is not maintained by us. But in any case, which code does the download matters very little (Corepack as a dep, copy the code from Corepack into core, another lib, etc.), what’s more important to establish is whether we want the feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define “the feature”. Is it installing npm's lockfile? Yarn's or pnpm's? All of them? Something else? Does it depend on the package manager being downloaded first?