forked from weexteam/A-pack-tool-for-Apache-Weex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (45 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const chalk = require('chalk')
const initProject = require('./src/init/init')
const runAndroid = require('./src/run/Android')
const runIOS = require('./src/run/iOS')
const runWeb = require('./src/run/web')
/**
* Get current version
*/
function getVersion() {
return require('./package.json').version
}
/**
* Initialize a standard weex project
* @param {String} project name
* @param {String} config file path
*/
function init(projectName = '', configFile = '') {
if (projectName.match(/^[$A-Z_][0-9A-Z_-]*$/i)) {
initProject(projectName, configFile)
} else {
console.log(` ${chalk.red('Invalid project name:')} ${chalk.yellow(projectName)}`)
}
}
/**
* Run weex app on the specific platform
* @param {String} platform
*/
function run(platform = '', options = {}) {
switch (platform) {
case 'android' : runAndroid(options); break;
case 'ios' : runIOS(options); break;
case 'web' : runWeb(options); break;
default : {
console.log(` ${chalk.red('Unknown platform:')} ${chalk.yellow(platform)}`)
}
}
}
module.exports = {
getVersion,
init,
run,
runAndroid,
runIOS,
runWeb,
}