Skip to content
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

node patterns #2

Open
isaacs opened this issue Aug 4, 2011 · 6 comments
Open

node patterns #2

isaacs opened this issue Aug 4, 2011 · 6 comments

Comments

@isaacs
Copy link

isaacs commented Aug 4, 2011

  1. There should be a package.json file so that it can be published and installed via npm.
  2. The dependencies should be loaded as dependencies in the node_modules folder in the node case, and listed in the package.json file. (npm install can pick them all up.)
  3. Don't modify require.paths, which is deprecated as of node 0.3, and completely gone in 0.5.
  4. Prefer using exports rather than globals.
  5. It's be nice to have a node client as well as a server, perhaps even more valuable. (In particular, it'd be really nice to use this in npm for a few things, where I'm instead shelling out to the command line git program.)

It may be worthwhile to check out requirejs or browserify to be able to use exactly the same patterns in both the browser and Node.

@danlucraft
Copy link
Owner

Thanks for this. This was next on my list but I don't have any experience of this so it's really helpful.

I'm including a wrapper for shelling out in this too (it will be useful for generating test repos), so if you can point me at your use cases in npm I can implement those first.

Cheers.

@isaacs
Copy link
Author

isaacs commented Aug 4, 2011

Right now, the npm submodule command will look up a package's repository information, and then create a submodule. https://github.com/isaacs/npm/blob/master/lib/submodule.js

Other commands simply abort when they encounter a .git folder, and refuse to clobber it. So, once you submodule something, you must use git to update it from then on. It'd be nice if npm update could detect git submodules and update them by pulling from the appropriate remote ref. (This is planned, but it's yet another point where I have to shell out to a random cli util.)

To use this in npm, however, it can't depend on underscore, use global variables, or modify require.paths, and the client should be easier to get at programmatically, not through the cli.

@isaacs
Copy link
Author

isaacs commented Aug 4, 2011

Also, I'd like to be able to install packages from git:// urls as well as https?:// urls, and either clone into ./node_modules/pkgname if it's missing, or fetch the specified commit from the remote if it's already there. A lot of people have asked for this repeatedly, and it'd be a pretty nice feature, I just didn't want to increase my dependence on having git installed at the target. HTTP is easier, since that's built into node.

@chrisdickinson
Copy link

@danlucraft I'd love to help out with this. I've got some experience with the git internals (was working on my own implementation of git in javascript previously) -- it'd be super helpful if we could split this into discrete issues so I could work on tiny bits on my own and submit changes to you via pull requests (e.g., "add git wire protocol support", "add loose object write support", "add pack file write support", "npm-ify module"). Only if you have the time though! Great work!

@danlucraft
Copy link
Owner

Hi Chris,

of course, tempusfugit wasn't it? Sounds like a plan :)

@chrisdickinson
Copy link

Apologies for the patchbomb bombardment; I put in a fair amount of work in this evening on refactoring this to use commonjs idioms: https://github.com/chrisdickinson/git.js/tree/feature/commonjs. Putting together an in-browser build script plus tests is my next step.

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

No branches or pull requests

3 participants