1 | var readline = require('readline'),
|
2 | path = require('path'),
|
3 | logger = require('../../utils/logger'),
|
4 | Process = require('child_process');
|
5 |
|
6 |
|
7 | function readSyncByRl(tips) {
|
8 | tips = tips || '> ';
|
9 | return new Promise((resolve) => {
|
10 | const rl = readline.createInterface({
|
11 | input: process.stdin,
|
12 | output: process.stdout
|
13 | });
|
14 | rl.question(tips, (answer) => {
|
15 | rl.close();
|
16 | resolve(answer.trim());
|
17 | });
|
18 | });
|
19 | }
|
20 |
|
21 |
|
22 | function installIosDep() {
|
23 | logger.log('installing ios sdk...');
|
24 | console.time('[' + 'eros'.blue + '] ' + 'ios installing time consuming: '.green);
|
25 | var build = Process.exec(path.resolve(process.cwd(), './platforms/ios/WeexEros/install.sh'), { cwd: path.resolve(process.cwd(), './platforms/ios/WeexEros/') }, function(error, stdout, stderr) {
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | console.timeEnd('[' + 'eros'.blue + '] ' + 'ios installing time consuming: '.green);
|
32 | });
|
33 | build.stdout.on('data', function(data) {
|
34 | console.log(data)
|
35 | });
|
36 | build.stderr.on('data', function(data) {
|
37 | console.log(data)
|
38 | });
|
39 | };
|
40 |
|
41 | function installAndroidDep() {
|
42 | logger.log('installing android sdk...')
|
43 | console.time('[' + 'eros'.blue + '] ' + 'android installing time consuming: '.green);
|
44 | var build = Process.exec(path.resolve(process.cwd(), './platforms/android/WeexFrameworkWrapper/install.sh'), { cwd: path.resolve(process.cwd(), './platforms/android/WeexFrameworkWrapper/') }, function(error, stdout, stderr) {
|
45 | console.timeEnd('[' + 'eros'.blue + '] ' + 'android installing time consuming: '.green);
|
46 | });
|
47 | build.stdout.on('data', function(data) {
|
48 | console.log(data)
|
49 | });
|
50 | build.stderr.on('data', function(data) {
|
51 | console.log(data)
|
52 | });
|
53 | };
|
54 |
|
55 | function runiOSInstallScript (callback) {
|
56 | console.time('[' + 'eros'.blue + '] ' + 'ios installing time consuming: '.green);
|
57 | var build = Process.exec(path.resolve(process.cwd(), './scripts/install.ios.sh'), { cwd: process.cwd() }, function(error, stdout, stderr) {
|
58 | console.timeEnd('[' + 'eros'.blue + '] ' + 'ios installing time consuming: '.green);
|
59 | callback && callback();
|
60 | });
|
61 | build.stdout.on('data', function(data) {
|
62 | console.log(data)
|
63 | });
|
64 | build.stderr.on('data', function(data) {
|
65 | console.log(data)
|
66 | });
|
67 | }
|
68 | function runAndroidInstallScript (callback) {
|
69 | console.time('[' + 'eros'.blue + '] ' + 'android installing time consuming: '.green);
|
70 | var build = Process.exec(path.resolve(process.cwd(), './scripts/install.android.sh'), { cwd: process.cwd() }, function(error, stdout, stderr) {
|
71 | console.timeEnd('[' + 'eros'.blue + '] ' + 'android installing time consuming: '.green);
|
72 | callback && callback();
|
73 | });
|
74 | build.stdout.on('data', function(data) {
|
75 | console.log(data)
|
76 | });
|
77 | build.stderr.on('data', function(data) {
|
78 | console.log(data)
|
79 | });
|
80 | }
|
81 |
|
82 | function runAllInstallScript () {
|
83 | runiOSInstallScript(runAndroidInstallScript);
|
84 | }
|
85 |
|
86 | function runiOSUpdateScript () {
|
87 | console.time('[' + 'eros'.blue + '] ' + 'ios updating time consuming: '.green);
|
88 | var build = Process.exec(path.resolve(process.cwd(), './scripts/update.ios.sh'), { cwd: process.cwd() }, function(error, stdout, stderr) {
|
89 | console.timeEnd('[' + 'eros'.blue + '] ' + 'ios updating time consuming: '.green);
|
90 | });
|
91 | build.stdout.on('data', function(data) {
|
92 | console.log(data)
|
93 | });
|
94 | build.stderr.on('data', function(data) {
|
95 | console.log(data)
|
96 | });
|
97 | }
|
98 | function runAndroidUpdateScript () {
|
99 | console.time('[' + 'eros'.blue + '] ' + 'android updating time consuming: '.green);
|
100 | var build = Process.exec(path.resolve(process.cwd(), './scripts/update.android.sh'), { cwd: process.cwd() }, function(error, stdout, stderr) {
|
101 | console.timeEnd('[' + 'eros'.blue + '] ' + 'android updating time consuming: '.green);
|
102 | });
|
103 | build.stdout.on('data', function(data) {
|
104 | console.log(data)
|
105 | });
|
106 | build.stderr.on('data', function(data) {
|
107 | console.log(data)
|
108 | });
|
109 | }
|
110 | module.exports = {
|
111 | readSyncByRl: readSyncByRl,
|
112 | installIosDep: installIosDep,
|
113 | installAndroidDep: installAndroidDep,
|
114 | runiOSInstallScript: runiOSInstallScript,
|
115 | runAndroidInstallScript: runAndroidInstallScript,
|
116 | runAllInstallScript: runAllInstallScript,
|
117 | runiOSUpdateScript: runiOSUpdateScript,
|
118 | runAndroidUpdateScript: runAndroidUpdateScript
|
119 | } |
\ | No newline at end of file |