且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Bower中注册本地git包?

更新时间:2022-05-30 05:22:03

选项1:公共凉亭注册



Bower主要用于以非自我意见的方式共享公共(客户端)代码。那么,主要的用例是拥有一个可公开访问的存储库(在GitHub上),该存储库是 register d,带有名称和git存储库url。我自己就是这样做的:

Option 1: Public Bower registration

Bower is built mostly to share public (client-side) code in a "non-opinionated" manner. The primary use case, then, is to have a publicly accessible repository (on GitHub) that is registerd with a name and git repository url. I just did this myself:

bower register linksoup git://github.com/automatonic/linksoup

这只是告诉购物者服务器当你安装linksoup 时去并获取 git://github.com/automatonic/linksoup 存储库中的代码,并将其放入本地项目的组件目录。

This is just telling the bower server that when you install linksoup to go and grab the code at the git://github.com/automatonic/linksoup repository, and put it in the local project's component directory.

如果这是你想要做的,那么只需在github / etc上设置一个存储库,在那里推送你的代码,然后注册以及生成的存储库信息。

If this is what you want to do, then just set up a repository on github/etc., push your code there, and then register with the resulting repository info.

有很多理由不将代码发布在可公开访问的存储库中。它可能不是开源等,如果您的 mypackage 代码不是公开的,那么您可能不应该 register 将它放在公共凉亭服务器上......此外,即使你可以注册一个本地目录,它也只适用于你的机器......这会使你失败通过凉亭分享代码的目的。

There are many reasons not to post your code at a publicly accessible repository. It may not be open source, etc. if your mypackage code is not meant to be public, then you should probably not be registering it on the public bower server... Further, even if you could register a local directory, it would only work on your machine...which defeats the purpose of sharing the code via bower.

如果你只是想让凉亭管理一个本地的私人依赖,那么我将重新开始blockhead 解决方案:

If you just want to have bower manage a local, private dependency, then I am going to riff off of blockhead's solution:

{
  "name": "myproject",
  "version": "1.0.0",
  "dependencies": {
    "jquery": "1.8.0",
    "twitter/bootstrap": "2.1.1",
    "mypackage": "file:///path/to/mypackage/.git"
  }
}

这只是说 myproject 需要 mypackage ,并使用git clone来检索它。我的猜测是,这可以使用git可以理解的任何东西(包括本地存储库)。但是你应该注意,对于无法访问本地路径的其他任何人来说,这可能会遇到问题。

This is just saying that myproject needs mypackage, and to use git clone to retrieve it. My guess is that this can use anything git can understand (including local repositories). But you should note that this may run into problems for anyone else working on this code that cannot access your local path.

在我看来,好像你可能认为 bower register 是一个本地操作(告诉bower如何通过某种本地注册表找到依赖项)。据我所知,这只是一个远程和公共注册,这就是为什么这是不受支持的。

It looks to me as if you may have assumed that bower register was a local operation (telling bower how to find a dependency via some sort of local registry). As far as I can tell, this is only a remote and public registration, which is why this is unsupported.

您可能也在寻找一种方法来做类似的事情与npm的链接操作。也就是说,在不依赖开发周期的情况下处理依赖模块包括发布。

You may also be looking for a way to do something like a link operation with npm. That is, work on a dependency module without always having your dev cycle include a publish.

关于涉及多少人以及你想要完成什么的一个小细节促进更有针对性的答案。

A little detail about how many people are involved and what you were trying to accomplish would facilitate a more targeted answer.