20
20
*/
21
21
22
22
const { cd, cp, echo, exec, exit, mv, rm} = require ( 'shelljs' ) ;
23
- const spawn = require ( 'child_process' ) . spawn ;
23
+ const child_process = require ( 'child_process' ) ;
24
24
const argv = require ( 'yargs' ) . argv ;
25
25
const path = require ( 'path' ) ;
26
+ const fs = require ( 'fs' ) ;
26
27
27
28
const SCRIPTS = __dirname ;
28
29
const ROOT = path . normalize ( path . join ( __dirname , '..' ) ) ;
@@ -35,6 +36,7 @@ const REACT_NATIVE_APP_DIR = `${REACT_NATIVE_TEMP_DIR}/template`;
35
36
const numberOfRetries = argv . retries || 1 ;
36
37
let SERVER_PID ;
37
38
let APPIUM_PID ;
39
+ let VERDACCIO_PID ;
38
40
let exitCode ;
39
41
40
42
function describe ( message ) {
70
72
71
73
const REACT_NATIVE_PACKAGE = path . join ( ROOT , 'react-native-*.tgz' ) ;
72
74
75
+ describe ( 'Verdaccio' ) ;
76
+ const verdaccioProcess = child_process . spawn (
77
+ 'npx' ,
78
+ [ 'verdaccio' , '--config' , './.circleci/verdaccio/config.yml' ] ,
79
+ {
80
+ stdio : 'inherit' ,
81
+ } ,
82
+ ) ;
83
+ VERDACCIO_PID = verdaccioProcess . pid ;
84
+ exec ( 'npm set registry http://localhost:4873' ) ;
85
+
86
+ exec ( 'node ./scripts/wait-for-verdaccio.js' ) ;
87
+
88
+ echo ( 'Publish packages' ) ;
89
+ const packages = fs . readdirSync ( 'packages' ) ;
90
+ packages . forEach ( current_package => {
91
+ exec (
92
+ `cd packages/${ current_package } && npm publish --registry http://localhost:4873 --yes --access public` ,
93
+ ) ;
94
+ } ) ;
95
+
73
96
describe ( 'Scaffold a basic React Native app from template' ) ;
74
97
exec ( `rsync -a ${ ROOT } /template ${ REACT_NATIVE_TEMP_DIR } ` ) ;
75
98
cd ( REACT_NATIVE_APP_DIR ) ;
@@ -144,7 +167,9 @@ try {
144
167
}
145
168
146
169
describe ( `Start appium server, ${ APPIUM_PID } ` ) ;
147
- const appiumProcess = spawn ( 'node' , [ './node_modules/.bin/appium' ] ) ;
170
+ const appiumProcess = child_process . spawn ( 'node' , [
171
+ './node_modules/.bin/appium' ,
172
+ ] ) ;
148
173
APPIUM_PID = appiumProcess . pid ;
149
174
150
175
describe ( 'Build the app' ) ;
@@ -156,9 +181,13 @@ try {
156
181
157
182
describe ( `Start Metro, ${ SERVER_PID } ` ) ;
158
183
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
159
- const packagerProcess = spawn ( 'yarn' , [ 'start' , '--max-workers 1' ] , {
160
- env : process . env ,
161
- } ) ;
184
+ const packagerProcess = child_process . spawn (
185
+ 'yarn' ,
186
+ [ 'start' , '--max-workers 1' ] ,
187
+ {
188
+ env : process . env ,
189
+ } ,
190
+ ) ;
162
191
SERVER_PID = packagerProcess . pid ;
163
192
// wait a bit to allow packager to startup
164
193
exec ( 'sleep 15s' ) ;
@@ -185,7 +214,7 @@ try {
185
214
const packagerEnv = Object . create ( process . env ) ;
186
215
packagerEnv . REACT_NATIVE_MAX_WORKERS = 1 ;
187
216
describe ( 'Start Metro' ) ;
188
- const packagerProcess = spawn ( 'yarn' , [ 'start' ] , {
217
+ const packagerProcess = child_process . spawn ( 'yarn' , [ 'start' ] , {
189
218
stdio : 'inherit' ,
190
219
env : packagerEnv ,
191
220
} ) ;
@@ -288,5 +317,9 @@ try {
288
317
echo ( `Killing appium ${ APPIUM_PID } ` ) ;
289
318
exec ( `kill -9 ${ APPIUM_PID } ` ) ;
290
319
}
320
+ if ( VERDACCIO_PID ) {
321
+ echo ( `Killing verdaccio ${ VERDACCIO_PID } ` ) ;
322
+ exec ( `kill -9 ${ VERDACCIO_PID } ` ) ;
323
+ }
291
324
}
292
325
exit ( exitCode ) ;
0 commit comments