如何在Bower中注册本地git包? [英] How to register a local git package in Bower?

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

问题描述

如何在凉亭中注册本地git包?

How can I register a local git package in bower?

我当前的component.json如下

My current component.json is as follows

{
  "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。

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.

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

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

bower error Incorrect format

什么是我做错了吗?

推荐答案

选项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.

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

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