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

How to register a local git package in Bower?(如何在 Bower 中注册本地 git 包?)
本文介绍了如何在 Bower 中注册本地 git 包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

如何在 bower 中注册本地 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 register mypackage C:/mypackage 但它一直给我

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

bower error Incorrect format

我做错了什么?

推荐答案

选项 1:Public Bower 注册

Bower 的构建主要是为了以非自以为是"的方式共享公共(客户端)代码.那么,主要用例是拥有一个可公开访问的存储库(在 GitHub 上),该存储库是 registerd,带有名称和 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

这只是告诉 Bower 服务器,当您 install linksoup 去获取 git://github.com/automatonic/linksoup 存储库中的代码时,并放到本地项目的component目录下.

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. 上设置一个存储库,将您的代码推送到那里,然后使用生成的存储库信息 register.

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 代码不打算公开,那么您可能不应该在公共凉亭服务器上注册.. 此外,即使您可以注册一个本地目录,它也只能在您的机器上运行...这违背了通过 bower 共享代码的目的.

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.

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

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 包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
Ordinals in words javascript(javascript中的序数)
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)