【问题标题】:Customizing bower packages自定义凉亭包
【发布时间】:2017-05-15 16:57:50
【问题描述】:

我在我的项目中使用了几个开源 js 库。我最近开始使用 bower 来处理所有前端依赖项。我喜欢我可以只提供一个 github url 而不是一个正确的包名称。

我已经定制了几个库。因此,为了使用 bower 管理它们,我在 Github 上的组织帐户中创建了一个名为 myLibs 的私有存储库。

我正在为每个自定义库创建分支。例如,自定义angular-bootstrap 库将在angular-bootstrap 分支中,自定义angular-material 库将在angular-material 分支中。

现在我正在为每个库中的每个版本创建标签。我使用的命名约定是branch-name/x.y.z 例如,我有angular-bootstrap/1.0.0angular-material/1.1.1 标签。

这很好,直到我不得不使用 bower 安装这些库。为了安装自定义库,我调用了以下命令(这是一个虚拟 url,不要尝试)

bower install --save-exact library-patch=https://github.com/test_org/myLibs.git#branch-name/1.0.0

该库已安装,我也可以在 bower_components 中看到它,但在我的 bower.json 中,依赖项条目如下所示 -

"library-patch":"https://github.com/test_org/myLibs.git#undefined"

这不是我想要的。我想保存正确的标签名称。我不想在每次添加自定义库时手动更改bower.json 文件。

我的第一个想法是标签的命名约定会有问题。所以我把依赖关系末尾的branch-name/x.y.z 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`标签改成了branch-name-x.y.z

这是我从终端安装库时得到的日志。

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

为什么我在发布/标签名称中未定义?我在命名标签时犯了任何错误吗?有什么办法可以从终端安装这些自定义库并将确切的标签保存在 bower.json 中?

【问题讨论】:

    标签: javascript git github bower


    【解决方案1】:

    问题的解决方案是使用--save 而不是--save-exact。我现在对此没有任何解释,但我会尽快更新答案。

    据我所知,这是因为软件包是直接从 github 安装的,而不是从 bower 注册表安装的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-12
      • 1970-01-01
      • 2017-03-14
      • 2016-05-29
      • 2014-02-24
      • 2016-03-27
      相关资源
      最近更新 更多