首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Cordova CLI源码分析(4)——创建工程

2013-09-05 
Cordova CLI源码分析(四)——创建工程在第一篇分析我们曾经举例,创建一个新工程,cordova create hello hello

Cordova CLI源码分析(四)——创建工程

在第一篇分析我们曾经举例,创建一个新工程,

cordova create hello hellotest com.xxx.hellotest

cli.js文件分析命令行参数后,会走到

 else if (cmd == 'create' || cmd == 'serve') {

            cordova[cmd].apply(this, tokens);

        }

将会执行create函数

create.js

module.exports = {    'ios' : {        parser : require('./src/metadata/ios_parser'),        url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git',        version: '3.0.0'    },     'android' : {        parser : require('./src/metadata/android_parser'),        url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git',        version: '3.0.0'    },     'wp7' : {        parser : require('./src/metadata/wp7_parser'),        url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-wp8.git',        version: '3.0.0'    },    'wp8' : {        parser : require('./src/metadata/wp8_parser'),        url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-wp8.git',        version: '3.0.0'    },    blackberry10 : {        parser : require('./src/metadata/blackberry10_parser'),        url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-blackberry.git',        version: '3.0.0'    },    'www':{        url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-app-hello-world.git',        version: '3.0.0'    }};

platforms.js中列出了所有cordova支持的平台,每个平台包括三个参数: 

parser : 解析平台配置参数的解析文件位置;

url : 源码存在的git路径

version:版本号

lazy_load.cordova会按照传入参数在这个表中找到对应url下载文件。

lazy_load.custom与lazy_load.cordova不同之处是,从.cordova/config_json中指定的url参数下载文件

shelljs,create函数中多次用到shelljs,它是一个可移植的类似unix shell的命令行工具,支持Windows/Linux/OS X,详见https://npmjs.org/package/shelljs


热点排行