-
Notifications
You must be signed in to change notification settings - Fork 7.6k
use npm to download extension dependencies after installing from registry #10602
Conversation
Is this being considered for merging? I think it's a great addition speaking as some who has published a node-based extension with dependencies. |
@mackenza not sure if this will make its way into Brackets, but I've been playing with a concept of going around Brackets' extension registry altogether and download whole extensions from npm. It works conceptually, but needs more testing and polishing, see here: https://github.com/zaggino/brackets-npm-registry |
ah, I see. That would closely resemble what Atom does with APM wrapping On Tue, Mar 17, 2015 at 5:10 AM, Martin Zagora notifications@github.com
|
To be honest, I've no idea what Atom does or doesn't do, never had time to take a closer look at it. |
Yeah, basically this is what they do. The have the Atom Package Manager Atom is a hot mess, honestly. Truly an editor without an identity. On Tue, Mar 17, 2015 at 6:22 PM, Martin Zagora notifications@github.com
|
@zaggino Thanks for putting up this PR! Great work and thinking. I like the idea of keeping the node extensions lean and downloading the dependencies using npm. Couple of things to consider for this PR.
Talking about the third point, how about downloading the extension itself from just a link? Something like, the registry will only have links (mostly to GitHub repositories) and we download the extension itself from Github repository/external link followed by installing the dependencies(which this PR is about), if any. |
@nethip I would think point 2 is a concern for any dependency manager and not unique to this PR's application of NPM. If a package author doesn't want to "roll the dice" on having package updates break their extension, they should be explicit about the dependency. i.e. On 3, NPM is quickly becoming the dependency manager to rule them all. Certainly it's not restricted to Node modules anymore. I can find most of the modules I use for front end JS in there, as well. I think what @zaggino is suggesting is we use the current package registry to download the actual extension zip (as we do today) but as part of the installation, rather than just unzipping the files, we also run |
b1ebb31
to
16f4bc8
Compare
@ficristo @petetnt @abose @ingorichter this would be worth a second look, it's no magic and it'd help a lot for extensions so they wouldn't have to bundle everything in a .zip file |
package.json
Outdated
@@ -12,6 +12,9 @@ | |||
"branch": "", | |||
"SHA": "" | |||
}, | |||
"dependencies": { | |||
"npm": "2.15.10" |
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.
Have you tested this out with npm@3
. I didn't have much issues (if any) from moving to 2->3
when 3 started rolling out but I don't know if it has some troubles with how Brackets resolves the extension dependencies.
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.
No, I could test/fix this to work with 3 but original PR was put together when 2 was latest and I don't think it's worth spending time on it if it won't be merged before npm 4 comes out.
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.
Fair enough. @3
would bring some nice benefits, but I do see how testing for it might be unfeasible at this point. I'd like to see this land sooner than the later though, preferably with 3
😼
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.
The review I asked for is more about the idea of this then the code (I'm happy to fix/update it), when I first put up this PR there wasn't enough will to merge this and potentially deal with problems like invalid dependencies in package.json and etc. But I still believe this would help a lot of extension authors to move forward.
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.
Oh, and npm@3
doesn't play well with node 0.10
so we need to merge two other PRs first.
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.
Yeah, good catch on that one. I'd love to get rid of both of those ancient dependencies at the same time 👍
Looks good to me with some minor nits about personal preferences. |
I like the idea but I defer the final decision to others, I'm not confident on how this will interact with the registry. A part the following few questions, LGTM. I suppose we can start to using |
16f4bc8
to
fdd83da
Compare
var packageJson; | ||
|
||
try { | ||
packageJson = JSON.parse(fs.readFileSync(path.join(installDirectory, "package.json"), { |
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.
Cannot you use require
instead of JSON.parse(fs.readFileSync
?
I didn't expect to become complex like this, but I believe is better than using npm API. Thank you @zaggino. |
refactor refactor 2
93a5604
to
3f1ed5d
Compare
note: original bundled |
IMHO if we change extensibility/node in this way we should wait for #12933 first. |
#12933 depends on the access to the registry machine and I don't know what else, so it might take a year or two to fix that... |
d939b00
to
66eb334
Compare
removed |
Great work as always @zaggino 👍 . |
Merging now ... |
I bet it's better late than never 👍 |
Seems to be working fine. Tests included, but currently they are disabled in Gruntfile so they need to be run manually, wasn't investigating what was the reason for disabling the tests.