代码改变世界

Cordova CLI命令行工具

  张智清  阅读(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 to
  • platform add <platform> [<platform> ...] add one (or more) platforms as a build target for the project
  • platform [rm | remove] <platform> [<platform> ...] removes one (or more) platforms as a build target for the project
  • plugin [ls | list] list all plugins added to the project
  • plugin add <path-to-plugin> [<path-to-plugin> ...] add one (or more) plugins to the project
  • plugin [rm | remove] <plugin-name> [<plugin-name> ...] remove one (or more) added plugins
  • prepare [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 for cordova prepare followed by cordova 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 platforms
  • serve <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 to log andwarn events if you are consuming cordova-cli as a node module by callingcordova.on('log', function() {}) or cordova.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/

 

编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示