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 ( 'npx' , [
77
+ 'verdaccio' ,
78
+ '--config' ,
79
+ './.circleci/verdaccio/config.yml' ,
80
+ ] ) ;
81
+ VERDACCIO_PID = verdaccioProcess . pid ;
82
+ exec ( 'npm set registry http://localhost:4873' ) ;
83
+
84
+ exec ( 'node ./scripts/wait-for-verdaccio.js' ) ;
85
+
86
+ echo ( 'Publish packages' ) ;
87
+ const packages = fs . readdirSync ( 'packages' ) ;
88
+ packages . forEach ( current_package => {
89
+ exec (
90
+ `cd packages/${ current_package } && npm publish --registry http://localhost:4873 --yes --access public` ,
91
+ ) ;
92
+ } ) ;
93
+
73
94
describe ( 'Scaffold a basic React Native app from template' ) ;
74
95
exec ( `rsync -a ${ ROOT } /template ${ REACT_NATIVE_TEMP_DIR } ` ) ;
75
96
cd ( REACT_NATIVE_APP_DIR ) ;
@@ -144,7 +165,9 @@ try {
144
165
}
145
166
146
167
describe ( `Start appium server, ${ APPIUM_PID } ` ) ;
147
- const appiumProcess = spawn ( 'node' , [ './node_modules/.bin/appium' ] ) ;
168
+ const appiumProcess = child_process . spawn ( 'node' , [
169
+ './node_modules/.bin/appium' ,
170
+ ] ) ;
148
171
APPIUM_PID = appiumProcess . pid ;
149
172
150
173
describe ( 'Build the app' ) ;
@@ -156,9 +179,13 @@ try {
156
179
157
180
describe ( `Start Metro, ${ SERVER_PID } ` ) ;
158
181
// 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
- } ) ;
182
+ const packagerProcess = child_process . spawn (
183
+ 'yarn' ,
184
+ [ 'start' , '--max-workers 1' ] ,
185
+ {
186
+ env : process . env ,
187
+ } ,
188
+ ) ;
162
189
SERVER_PID = packagerProcess . pid ;
163
190
// wait a bit to allow packager to startup
164
191
exec ( 'sleep 15s' ) ;
@@ -185,7 +212,7 @@ try {
185
212
const packagerEnv = Object . create ( process . env ) ;
186
213
packagerEnv . REACT_NATIVE_MAX_WORKERS = 1 ;
187
214
describe ( 'Start Metro' ) ;
188
- const packagerProcess = spawn ( 'yarn' , [ 'start' ] , {
215
+ const packagerProcess = child_process . spawn ( 'yarn' , [ 'start' ] , {
189
216
stdio : 'inherit' ,
190
217
env : packagerEnv ,
191
218
} ) ;
@@ -288,5 +315,9 @@ try {
288
315
echo ( `Killing appium ${ APPIUM_PID } ` ) ;
289
316
exec ( `kill -9 ${ APPIUM_PID } ` ) ;
290
317
}
318
+ if ( VERDACCIO_PID ) {
319
+ echo ( `Killing verdaccio ${ VERDACCIO_PID } ` ) ;
320
+ exec ( `kill -9 ${ VERDACCIO_PID } ` ) ;
321
+ }
291
322
}
292
323
exit ( exitCode ) ;
0 commit comments