[英]Customizing bower packages
I am using several open source js libraries in my project. 我在我的项目中使用了几个开源js库。 I recently moved to use bower for all the front-end dependencies.
我最近移到对所有前端依赖项使用bower。 I liked how I can just provide a github url instead of a proper package name.
我喜欢只提供一个github url而不是正确的包名的方法。
I have customized few libraries. 我已经定制了几个库。 So to manage them using bower, I created a single private repository called
myLibs
in an organization account on Github. 因此,为了使用
myLibs
管理它们,我在Github的组织帐户中创建了一个名为myLibs
私有存储库。
I am creating branches for each customized library. 我为每个自定义库创建分支。 For example, customized
angular-bootstrap
library will be in angular-bootstrap
branch and customized angular-material
library will be in angular-material
branch. 例如,定制的
angular-bootstrap
库将在angular-bootstrap
分支中,而定制的angular-material
库将在angular-material
分支中。
Now I am creating tags for each release in each library. 现在,我为每个库中的每个版本创建标签。 The naming convention that I am using is
branch-name/xyz
For example, I have angular-bootstrap/1.0.0
and angular-material/1.1.1
tags. 我使用的命名约定是
branch-name/xyz
。例如,我有angular-bootstrap/1.0.0
和angular-material/1.1.1
标签。
This was good till I had to install these libraries using bower. 直到我必须使用Bower安装这些库之前,这一直很好。 To install the custom libraries I called the following command (It's a dummy url, don't try it)
要安装自定义库,我调用了以下命令(这是一个虚拟网址,请不要尝试)
bower install --save-exact library-patch=https://github.com/test_org/myLibs.git#branch-name/1.0.0
The library gets installed and I can see it in bower_components too, but in my bower.json the dependency entry turns up like this - 库已安装,我也可以在bower_components中看到它,但是在我的bower.json中,依赖项如下所示-
"library-patch":"https://github.com/test_org/myLibs.git#undefined"
This is not what I wanted. 这不是我想要的。 I wanted to have the proper tag name to be saved.
我想保存正确的标签名称。 I don't want to manually make changes in the
bower.json
file every time I want to add a custom library. 我不想每次想添加自定义库时都手动在
bower.json
文件中进行更改。
My first thought was that the naming convention of the tags will be a problem. 我首先想到的是标签的命名约定将是一个问题。 So I changed it to
branch-name-xyz
from branch-name/xyz which allowed me to have the exact version in the bower.json to install it properly, but when trying to install the libraries using the terminal, instead of using bower.json, I am getting the
#undefined` tag in the end of the dependencies. 因此,我将其从
branch-name/xyz which allowed me to have the exact version in the bower.json to install it properly, but when trying to install the libraries using the terminal, instead of using bower.json, I am getting the
更改为branch-name-xyz
, branch-name/xyz which allowed me to have the exact version in the bower.json to install it properly, but when trying to install the libraries using the terminal, instead of using bower.json, I am getting the
在依赖项的末尾branch-name/xyz which allowed me to have the exact version in the bower.json to install it properly, but when trying to install the libraries using the terminal, instead of using bower.json, I am getting the
#undefined`标签。
Here's the log I am getting while installing the library from terminal. 这是从终端安装库时得到的日志。
bower install --save-exact library-patch=https://github.com/test_org/myLibs.git#branch-name-1.0.0
bower not-cached https://github.com/test_org/myLibs.git#branch-name-1.0.0
bower resolve https://github.com/test_org/myLibs.git#branch-name-1.0.0
bower download https://github.com/test_org/myLibs/archive/branch-name-1.0.0.tar.gz
bower retry Download of https://github.com/test_org/myLibs/archive/branch-name-1.0.0.tar.gz failed with EHTTP, trying with git..
bower checkout library-patch#branch-name-1.0.0
bower resolved https://github.com/test_org/myLibs.git#branch-name-1.0.0
bower install library-patch#branch-name-1.0.0
library-patch#branch-name-1.0.0 bower_components/library-patch
└── angular#1.4.8
Why am I getting undefined in the release/tag name? 为什么我在发行/标签名称中变得未定义? Am I making any mistake while naming the tags?
命名标签时我犯了任何错误吗? Is there any way I can install those custom libs from terminal and save the exact tag in bower.json?
有什么办法可以从终端安装这些自定义库,并将确切的标签保存在bower.json中?
The solution for the problem was to use --save
instead of --save-exact
. 解决该问题的方法是使用
--save
而不是--save-exact
。 I have no explanation for the same right now, but I'll update the answer as soon as I can. 我现在没有相同的解释,但是我会尽快更新答案。
As far as I can tell, it's because the package was getting installed from github directly, instead of from bower registry. 据我所知,这是因为该软件包是直接从github而不是Bower Registry安装的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.