@@ -28,6 +28,7 @@ const dev =
2828 baseUrl : string ;
2929 fallbackRegistryUrl : string ;
3030 hotReloading ?: boolean ;
31+ components : string [ ] ;
3132 watch ?: boolean ;
3233 verbose ?: boolean ;
3334 production ?: boolean ;
@@ -137,96 +138,101 @@ const dev =
137138 } ;
138139
139140 logger . warn ( cliMessages . SCANNING_COMPONENTS , true ) ;
140- local . getComponentsByDir ( componentsDir , ( err , components ) => {
141- if ( _ . isEmpty ( components ) ) {
142- err = cliErrors . DEV_FAIL ( cliErrors . COMPONENTS_NOT_FOUND ) as any ;
143- callback ( err , undefined as any ) ;
144- return logger . err ( String ( err ) ) ;
145- }
141+ local . getComponentsByDir (
142+ componentsDir ,
143+ opts . components as any ,
144+ ( err , components ) => {
145+ if ( _ . isEmpty ( components ) ) {
146+ err = cliErrors . DEV_FAIL ( cliErrors . COMPONENTS_NOT_FOUND ) as any ;
147+ callback ( err , undefined as any ) ;
148+ return logger . err ( String ( err ) ) ;
149+ }
146150
147- logger . ok ( 'OK' ) ;
148- _ . forEach ( components , component =>
149- logger . log ( colors . green ( '├── ' ) + component )
150- ) ;
151+ logger . ok ( 'OK' ) ;
152+ _ . forEach ( components , component =>
153+ logger . log ( colors . green ( '├── ' ) + component )
154+ ) ;
151155
152- handleDependencies ( { components, logger } , ( err , dependencies ) => {
153- if ( err ) {
154- logger . err ( err ) ;
155- return callback ( err , undefined as any ) ;
156- }
157- packageComponents ( components , ( ) => {
158- async . waterfall (
159- [
160- ( next : any ) => {
161- if ( hotReloading ) {
162- getPort ( port + 1 , ( error , otherPort ) => {
163- if ( error ) {
164- return next ( error ) ;
165- }
166- const liveReloadServer = livereload . createServer ( {
167- port : otherPort
156+ handleDependencies ( { components, logger } , ( err , dependencies ) => {
157+ if ( err ) {
158+ logger . err ( err ) ;
159+ return callback ( err , undefined as any ) ;
160+ }
161+ packageComponents ( components , ( ) => {
162+ async . waterfall (
163+ [
164+ ( next : any ) => {
165+ if ( hotReloading ) {
166+ getPort ( port + 1 , ( error , otherPort ) => {
167+ if ( error ) {
168+ return next ( error ) ;
169+ }
170+ const liveReloadServer = livereload . createServer ( {
171+ port : otherPort
172+ } ) ;
173+ const refresher = ( ) => liveReloadServer . refresh ( '/' ) ;
174+ next ( null , { refresher, port : otherPort } ) ;
168175 } ) ;
169- const refresher = ( ) => liveReloadServer . refresh ( '/' ) ;
170- next ( null , { refresher, port : otherPort } ) ;
171- } ) ;
172- } else {
173- next ( null , { refresher : _ . noop , port : null } ) ;
176+ } else {
177+ next ( null , { refresher : _ . noop , port : null } ) ;
178+ }
174179 }
175- }
176- ] ,
177- ( err , liveReload : any ) => {
178- if ( err ) {
179- logger . err ( String ( err ) ) ;
180- return callback ( err , undefined as any ) ;
181- }
182-
183- const registry = oc . Registry ( {
184- baseUrl,
185- prefix : opts . prefix || '' ,
186- dependencies : dependencies . modules ,
187- discovery : true ,
188- env : { name : 'local' } ,
189- fallbackRegistryUrl,
190- hotReloading,
191- liveReloadPort : liveReload . port ,
192- local : true ,
193- path : path . resolve ( componentsDir ) ,
194- port,
195- templates : dependencies . templates ,
196- verbosity : 1
197- } ) ;
198-
199- registerPlugins ( registry ) ;
200-
201- logger . warn ( cliMessages . REGISTRY_STARTING ( baseUrl ) ) ;
202- if ( liveReload . port ) {
203- logger . warn (
204- cliMessages . REGISTRY_LIVERELOAD_STARTING ( liveReload . port )
205- ) ;
206- }
207- registry . start ( err => {
180+ ] ,
181+ ( err , liveReload : any ) => {
208182 if ( err ) {
209- if ( ( err as any ) . code === 'EADDRINUSE' ) {
210- err = cliErrors . PORT_IS_BUSY ( port ) as any ;
211- }
212-
213183 logger . err ( String ( err ) ) ;
214184 return callback ( err , undefined as any ) ;
215185 }
216186
217- if ( optWatch ) {
218- watchForChanges (
219- { components, refreshLiveReload : liveReload . refresher } ,
220- packageComponents
187+ const registry = oc . Registry ( {
188+ baseUrl,
189+ prefix : opts . prefix || '' ,
190+ dependencies : dependencies . modules ,
191+ discovery : true ,
192+ env : { name : 'local' } ,
193+ fallbackRegistryUrl,
194+ hotReloading,
195+ liveReloadPort : liveReload . port ,
196+ local : true ,
197+ components : opts . components ,
198+ path : path . resolve ( componentsDir ) ,
199+ port,
200+ templates : dependencies . templates ,
201+ verbosity : 1
202+ } ) ;
203+
204+ registerPlugins ( registry ) ;
205+
206+ logger . warn ( cliMessages . REGISTRY_STARTING ( baseUrl ) ) ;
207+ if ( liveReload . port ) {
208+ logger . warn (
209+ cliMessages . REGISTRY_LIVERELOAD_STARTING ( liveReload . port )
221210 ) ;
222211 }
223- callback ( null , registry ) ;
224- } ) ;
225- }
226- ) ;
212+ registry . start ( err => {
213+ if ( err ) {
214+ if ( ( err as any ) . code === 'EADDRINUSE' ) {
215+ err = cliErrors . PORT_IS_BUSY ( port ) as any ;
216+ }
217+
218+ logger . err ( String ( err ) ) ;
219+ return callback ( err , undefined as any ) ;
220+ }
221+
222+ if ( optWatch ) {
223+ watchForChanges (
224+ { components, refreshLiveReload : liveReload . refresher } ,
225+ packageComponents
226+ ) ;
227+ }
228+ callback ( null , registry ) ;
229+ } ) ;
230+ }
231+ ) ;
232+ } ) ;
227233 } ) ;
228- } ) ;
229- } ) ;
234+ }
235+ ) ;
230236 } ;
231237
232238export default dev ;
0 commit comments