-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
executable file
·146 lines (128 loc) · 3.04 KB
/
dev.js
File metadata and controls
executable file
·146 lines (128 loc) · 3.04 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const shell = require('shelljs');
const { exec } = require('child_process');
const cli = meow(
`
Usage
$ dev <command>
Options
--clean: Cleans up the React Native projects deeply:
1. Cleans up node modules
2. Cleans up all temp directories
3. Cleans up iOS folders
4. Cleans up Android folders
5. Resets the package manager cache
--simios: Displays the list of iOS simulators available. Selecting one will boot it with the app.
--simand: Displays the list of Android emulators available. Selecting one will boot it.
--relios: Build for release and run on attached iOS device.
--reland: Build for release and run on attached Android device
--deviceios: Run the RN app on attached iOS device.
--deviceand: Run the RN app on attached Android device.
--logios: Display native logs in the console from an attached iOS device.
--logand: Display native logs in the console from an attached Android device.
--update: Checks and displays the node modules needing update.
Examples
$ dev clean
`,
{
flags: {
clean: {
type: 'boolean',
alias: 'c'
},
simios: {
type: 'boolean',
alias: 'si'
},
simand: {
type: 'boolean',
alias: 'sa'
},
relios: {
type: 'boolean',
alias: 'ri'
},
reland: {
type: 'boolean',
alias: 'ra'
},
deviceios: {
type: 'boolean',
alias: 'di'
},
deviceand: {
type: 'boolean',
alias: 'da'
},
logios: {
type: 'boolean',
alias: 'li'
},
logand: {
type: 'boolean',
alias: 'la'
},
update: {
type: 'boolean',
alias: 'u'
}
}
}
);
console.log('##########################');
console.log('# React Native Dev Tools #');
console.log('##########################\n');
if (cli.flags.clean) {
shell.exec('./scripts/clean_build.sh');
return;
}
if (cli.flags.simios) {
shell.exec('./scripts/start_ios_simulator.sh');
return;
}
if (cli.flags.simand) {
shell.exec('./scripts/start_android_simulator.sh');
return;
}
if (cli.flags.relios) {
shell.exec('./scripts/run_release_ios.sh');
return;
}
if (cli.flags.reland) {
shell.exec('./scripts/run_release_android.sh');
return;
}
if (cli.flags.update) {
shell.exec('./scripts/update_modules.sh');
return;
}
var command;
if (cli.flags.logios) {
command = 'react-native log-ios';
}
if (cli.flags.logand) {
command = 'react-native log-android';
}
if (cli.flags.deviceios) {
command = 'react-native run-ios --device';
}
if (cli.flags.deviceand) {
command = 'react-native run-android';
}
command &&
exec(command, (err, stdout, stderr) => {
if (err) {
//some err occurred
console.error(err);
} else {
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
}
});
if (!command) {
console.log(cli.help);
}
return;