Cordova CLI,使用Git,并保存插件/平台 [英] Cordova CLI, using Git, and saving plugins/platforms

查看:165
本文介绍了Cordova CLI,使用Git,并保存插件/平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何调和一些Cordova + git的最佳实践与我认为的现实,我希望有人能为我说明这一点。



如果我理解正确,当前的最佳实践是将这些目录添加到我的.gitignore(从使用Cordova CLI开发一书,当前版本):

  platforms / 
plugins /
node_modules /

这将删除易于下载的插件,并从版本控制中删除大多数样板平台代码,因为它可以使用简单的Cordova CLI命令轻松生成。



但是,这似乎是反直觉的,因为 - 我想像NPM或Bower - 与Cordova CLI我不能保存在配置文件中使用的平台和插件。使用NPM,我可以添加 - save 开关将包保存在 package.json 文件中。这让我不能版本控制我的node_modules文件夹,而是使用npm install。使用Cordova CLI我似乎不能使用 - save 开关(有一个等价物)来记住我打算使用的插件或平台。 p>

看起来 www / config.xml >目录不会保存添加了哪些平台或插件。



项目中是否有其他文件保存了我要使用哪些平台和插件?它是如何工作的?

解决方案

Cordova 4.3.0 +允许您保存和恢复平台和插件。保存的信息存储在 config.xml 文件中。请参见 v5.0.0发行说明官方Cordova文档



您可以在添加平台和插件时使用 - save 选项来保存平台和插件:

  cordova平台添加PLATFORM --save 
cordova插件添加PLUGIN --save
pre>

或者,您可以保存当前添加的平台和插件:

  cordova平台保存
cordova插件保存

通过这样做,在平台或插件到您的代码存储库。当运行 cordova prepare 命令时,系统会根据您的 config.xml 文件自动还原这些文件。


I'm trying to figure out how to reconcile some Cordova + git "best practices" with what I think is reality, and I'm hoping someone can shed some light on this for me.

If I understand correctly, the current "best practice" is to add these directories to my .gitignore (from the book "Developing with Cordova CLI", the current version):

platforms/
plugins/
node_modules/

This removes the easily downloadable plugins and mostly boilerplate platform code from version control because it can be easily generated with a simple Cordova CLI command.

But, this seems counter-intuitive because - and I'm thinking like NPM or Bower - with the Cordova CLI I can't save which platforms and plugins I'm using in a config file. With NPM, I can add a --save switch to save the package in the package.json file. This allows me to not version control my node_modules folder and instead use 'npm install'. With the Cordova CLI I can't seem to use the --save switch (is there an equivalent) to 'remember' the plugins or platforms I intend to use.

It seems that the config.xml file in the www/ directory doesn't save which platforms or plugins have been added.

Is there some other file in the project that keeps a memory of which platforms and plugins I want to use? How does it work?

解决方案

Cordova 4.3.0 + allows you to save and restore platforms and plugins. Saved information is stored in config.xml file. See v5.0.0 release notes and the official Cordova docs.

You can save platforms and plugins using the --save option when you add them:

cordova platforms add PLATFORM --save
cordova plugins add PLUGIN --save

Or you can save platforms and plugins that are currently added:

cordova platforms save
cordova plugins save

By doing this there is no need to check in platforms or plugins into your code repository. They will be automatically restored based on your config.xml file when cordova prepare command is run.

这篇关于Cordova CLI,使用Git,并保存插件/平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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