[英]Cordova: Exclude plugins and platforms
I would like to not include the platforms and plugins in my git repository for my cordova project.我不想在我的cordova 项目的git 存储库中包含平台和插件。 Instead, I only include
platforms/platforms.json
and plugins/fetch.json
.相反,我只包含
platforms/platforms.json
和plugins/fetch.json
。 My .gitignore
looks like this我的
.gitignore
看起来像这样
platforms/**
!platforms/platforms.json
plugins/**
!plugins/fetch.json
This ensures that only the two json files are tracked by git.这样可以确保 git 只跟踪两个 json 文件。 This is my
platforms.json
:这是我的
platforms.json
:
{
"ios": "3.9.1",
"android": "4.1.1"
}
However, I thought that a cordova prepare
would look into the platforms.json
and would install the proper version automatically for my project.但是,我认为
cordova prepare
会查看platforms.json
并为我的项目自动安装正确的版本。 The same would be very handy for the fetch.json
inside the plugins directory.对于 plugins 目录中的
fetch.json
同样非常方便。 However, I noticed that here no versions, git commit hashes... are tracked, it just looks like this:但是,我注意到这里没有版本,git commit hashes... 被跟踪,它看起来像这样:
"cordova-plugin-console": {
"source": {
"type": "registry",
"id": "cordova-plugin-console"
},
"is_top_level": true,
"variables": {}
}
So my questions are:所以我的问题是:
I would say yes, so long as you set the versions of the platforms and plugins you want to use - keeping things that the CLI can generate out of source control is a good thing我会说是的,只要您设置要使用的平台和插件的版本 - 保留 CLI 可以在源代码控制之外生成的内容是一件好事
Yes, you can use the @ notation for example:是的,您可以使用 @ 符号,例如:
cordova platform add cordova-plugin-gelocation@1.0.1 cordova 平台添加cordova-plugin-gelocation@1.0.1
This applies to platforms as well, and each version of the Cordova CLI defaults to a specific version of the Cordova platform unless you override it.这也适用于平台,并且 Cordova CLI 的每个版本默认为 Cordova 平台的特定版本,除非您覆盖它。
Regarding running a command, I use hooks for this and have a post platform add hook that runs a script that installs all my plugins using the @ notation to get exactly the version I want.关于运行命令,我为此使用了钩子,并有一个 post 平台添加钩子,它运行一个脚本,该脚本使用 @ 符号安装我的所有插件,以获得我想要的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.