Cordova CLI命令行工具
2013-09-05 21:49 张智清 阅读(615) 评论(0) 编辑 收藏 举报Cordova CLI用于构建、部署和管理基于Cordova应用的命令行工具。
Cordova CLI要求的环境需求:
- nodejs
- 各个平台相应的SDK支持
安装Cordova
$ npm install -g cordova
用法:
先用全局级命令来创建项目工程:
create <directory> [<id> [<name>]]
其中可带参数id是指定包名,一般形如域名倒写的风格
然后在创建好的项目中,使用工程项目级的命令来配置编译、运行项目:
platform [ls | list]
list all platforms the project will build toplatform add <platform> [<platform> ...]
add one (or more) platforms as a build target for the projectplatform [rm | remove] <platform> [<platform> ...]
removes one (or more) platforms as a build target for the projectplugin [ls | list]
list all plugins added to the projectplugin add <path-to-plugin> [<path-to-plugin> ...]
add one (or more) plugins to the projectplugin [rm | remove] <plugin-name> [<plugin-name> ...]
remove one (or more) added pluginsprepare [platform...]
copies files into the specified platforms, or all platforms. it is then ready for building by Eclipse/Xcode/etc.compile [platform...]
compiles the app into a binary for each added platform. With no parameters, builds for all platforms, otherwise builds for the specified platforms.build [<platform> [<platform> [...]]]
an alias forcordova prepare
followed bycordova compile
emulate [<platform> [<platform> [...]]]
launch emulators and deploy app to them. With no parameters emulates for all platforms added to the project, otherwise emulates for the specified platformsserve <platform> [port]
launch a local web server for that platform's www directory on the given port (default 8000).
其它标识
-d
or--verbose
will pipe out more verbose output to your shell. You can also subscribe tolog
andwarn
events if you are consuming cordova-cli as a node module by callingcordova.on('log', function() {})
orcordova.on('warn', function() {})
.-v
or--version
will print out the version of your cordova-cli install.
用Cordova CLI创建的工程项目的目录结构(以myApp项目为例)
myApp/ |--.cordova/ |-- merges/ | | |-- android/ | | |-- blackberry10/ | | `-- ios/ |-- www/ | `-- config.xml |-- platforms/ | |-- android/ | |-- blackberry10/ | `-- ios/ `-- plugins/