-
Notifications
You must be signed in to change notification settings - Fork 1
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
Remove the dependency on npm APIs #123
base: master
Are you sure you want to change the base?
Conversation
I haven't been very active at this repo lately, but I wanted to acknowledge this PR. I agree with the general approach as described in the PR body text. npm 8 does indeed remove the internal APIs, which apm had relied on for a while... So one does have to call npm 8 strictly as a CLI program. No real way around this if moving to newer npm. (Newer npm gives newer node-gyp, which is a pretty good thing to have, IMO.) We can probably safely stay on npm 6 until Node 14 goes end-of life on April 30th 2023. (See the NodeJS release scedule.) npm 6 is bundled with Node 14, and it is implicitly supported until Node 14 goes end-of-life, if I recall correctly. So I personally might be inclined to stay on npm 6 for now... But newer node-gyp does importantly come with support for newer Visual Studio versions, so it may be worth upgrading sooner rather than later. After April 2023 it would be smart to not stay on an unsupported npm version. I can't speak to the performance implications without trying this change, but it wouldn't be too hard to informally benchmark it. With apm being a CLI app that's not run super often, it should be fine. It is run in the background at Atom startup, IIRC, but there's not much that can be done to avoid the performance hit, if there is one. You have to call npm as a CLI app as of npm 8, no two ways around it that I can see. I haven't tested the code, but nothing about it stood out to me as looking wrong after a quick look. |
with the recent pr, npm 8 is used so now this is needed? |
So @icecream17, just to clarify, PR #125 fixed our CI environment only. We only "have latest npm" in terms of using it to install this repo's dependencies with apm bundles its own internal copy of npm, and this is still npm 6.x
EDIT: I misread your comment, those last two paragraphs you presumably knew about. I thought you said "not needed", but I see you said "now needed". |
requestOptions.headers ?= {} | ||
requestOptions.headers['User-Agent'] ?= userAgent | ||
callback() | ||
config.getSetting 'proxy', (proxy) -> |
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.
Edit: Invalid comment because the only way to not return is error or infinite wait, stopping execution
Cursorily, lgtm. |
Description of the Change
Since npm@8 drops programmable APIs, this PR removes references to those APIs so
apm
can be upgraded to npm@8 and Node 16. Follow changes are made to make it happen:apm.getSetting
insteadgetSetting
spawnsnpm config get
to load config instead of usingnpm.load
APIaddBuildEnvVars
andaddProxyToEnv
are converted to asynchronous to support thatAlternate Designs
Benefits
Possible Drawbacks
npm
process may have a performance impact compared to using npm API. However, this only impactsapm
which shouldn't be noticeable to users.Verification Process
I verified the change by running tests and my own atom build from this fork https://github.com/bongnv/atom/blob/master/apm/package.json#L9
Applicable Issues
Haven't noticed any issues yet.