凉亭注册本地git包 [英] bower registering local git package

查看:139
本文介绍了凉亭注册本地git包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的当前component.json如下所示:

pre $ {
name:myproject,
version:1.0.0,
dependencies:{
jquery:1.8.0,
twitter / bootstrap:2.1.1
}
}

然而,我也想添加一个我在 C:/ mypackage 中创建的包,它是一个git仓库带有标签的版本。
当我做 bower install --save C:/ mypackage 时,它会正确地将它添加到项目中,但它不会将它添加到我的component.json中。



我在尝试 bower注册mypackage C:/ mypackage 但它一直给我

  bower错误格式不正确

什么是我做错了? Bower的建立主要是以非主观的方式共享公共(客户端)代码。那么主要用例就是拥有一个公共可访问的存储库(在GitHub上),它是 register d的一个名称和git存储库url。我自己也是这样做的:

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

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

如果这是你想要做的,那么只需在github / etc上设置一个仓库,把你的代码放在那里,然后<$

选项2:私有依赖项



code> register

有许多原因不会将您的代码发布到可公开访问的存储库中。它可能不是开源的,如果你的 mypackage 代码不是公开的,那么你可能不应该是 register 在公共凉亭服务器上进行...此外,即使您可以注册本地目录,它也只能在您的机器上运行......这会破坏通过bower共享代码的目的。



如果您只想让bower管理本地,私有的依赖项,那么我将打开blockhead's 解决方案:

  {
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可以理解的东西(包括本地存储库)。但是您应该注意到,这可能会遇到任何其他人无法访问您的本地路径的问题。



最佳猜测



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



您也许正在寻找一种方法来做类似使用npm 链接操作。也就是说,在一个依赖模块上工作,而不必让你的开发周期包含一个发布。



关于有多少人参与以及你想要完成什么的一些细节方便更有针对性的答案。

How can I register a local git package in bower?

My current component.json is as follows

{
  "name": "myproject",
  "version": "1.0.0",
  "dependencies": {
    "jquery": "1.8.0",
    "twitter/bootstrap": "2.1.1"
  }
}

However I also would like to add a package I have created at C:/mypackage which is a git repository with versions tagged. When I do bower install --save C:/mypackage it properly adds it to project but it doesn't add it to my component.json.

I am trying bower register mypackage C:/mypackage but it keeps giving me

bower error Incorrect format

What am I doing wrong?

解决方案

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

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.

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.

Option 2: Private dependency

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.

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"
  }
}

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.

Best Guess

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.

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.

这篇关于凉亭注册本地git包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆