npm
is very good at supporting packages publishes to the global/central npm
repo, which doesn't work well for private, application code. npm
also supports adding a git repo as a dependency, which lets you have a private dependency.
npm非常擅长于支持包发布到global/central npm repo,这对于私有的应用程序代码并不适用。npm还支持将git repo添加为依赖项,使您拥有一个私有依赖项。
The problem is, as I understand to be best practice, my npm
packages tend to be very tight and small, whereas my git repos tend to be larger, and will include several npm
packages. I do not know any way to attain this granularity while pointing to a github URL. How to solve this?
问题是,正如我所理解的最佳实践,我的npm包往往非常紧凑和小,而我的git repos往往更大,并且将包含几个npm包。我不知道在指向github URL时如何达到这种粒度。如何解决呢?
UPDATE
更新
I accepted the answer that says "don't do this, stay on the rails." I agree with this recommendation, but YMMV.
我接受了这样的回答:“不要这么做,坚持下去。”我同意这个建议,但是YMMV。
2 个解决方案
#1
12
I would suggest that one repo with multiple packages is a bad idea to start with for several reasons. You should be viewing a package as its own entity: independently built, tested, and deployed. All that to say, each package should live in its own repo.
我认为,一个带有多个包的repo开头不是个好主意,原因有以下几个。您应该将包视为它自己的实体:独立构建、测试和部署。话虽如此,每个包裹都应该有自己的“回购”。
That being said, I definitely understand the benefit of being able to do an npm install <package-group>
of one "commons" package and have it grab all the packages you need in one shot. I would suggest looking at the grunt-contrib model for accomplishing this. In short, they have a bunch of grunt-contrib- packages (ex. grunt-contrib-coffee) each living in their own repositories. They then create a separate repository that defines the parent "grunt-contrib" package. All this parent package does is specify dependencies on all of the sub-packages. This allows you to do an npm install grunt-contrib-coffee
(for example) and get just the grunt-contrib-coffee package; or you can do npm install grunt-contrib
and get their entire suite all in one shot.
话虽如此,我绝对理解能够在一个“commons”包中执行npm安装
Hope this helps!
希望这可以帮助!
#2
1
You could also set up your own local npm repository.
您还可以设置自己的本地npm存储库。
- Instructions for *nix/OSX
- * nix / OSX的指令
- Instructions for Windows
- 说明窗户
#1
12
I would suggest that one repo with multiple packages is a bad idea to start with for several reasons. You should be viewing a package as its own entity: independently built, tested, and deployed. All that to say, each package should live in its own repo.
我认为,一个带有多个包的repo开头不是个好主意,原因有以下几个。您应该将包视为它自己的实体:独立构建、测试和部署。话虽如此,每个包裹都应该有自己的“回购”。
That being said, I definitely understand the benefit of being able to do an npm install <package-group>
of one "commons" package and have it grab all the packages you need in one shot. I would suggest looking at the grunt-contrib model for accomplishing this. In short, they have a bunch of grunt-contrib- packages (ex. grunt-contrib-coffee) each living in their own repositories. They then create a separate repository that defines the parent "grunt-contrib" package. All this parent package does is specify dependencies on all of the sub-packages. This allows you to do an npm install grunt-contrib-coffee
(for example) and get just the grunt-contrib-coffee package; or you can do npm install grunt-contrib
and get their entire suite all in one shot.
话虽如此,我绝对理解能够在一个“commons”包中执行npm安装
Hope this helps!
希望这可以帮助!
#2
1
You could also set up your own local npm repository.
您还可以设置自己的本地npm存储库。
- Instructions for *nix/OSX
- * nix / OSX的指令
- Instructions for Windows
- 说明窗户