44 dependency:: UpdateUrl ,
55 instance:: Instance ,
66 packages:: Packages ,
7- registry_client:: { LiveRegistryClient , PackageMeta , RegistryClient , RegistryError } ,
7+ registry_client:: { PackageMeta , RegistryClient , RegistryError } ,
88 specifier:: Specifier ,
99 version_group:: VersionGroup ,
1010 } ,
@@ -33,7 +33,7 @@ pub struct Context {
3333 /// Every package.json in the project
3434 pub packages : Packages ,
3535 /// Registry client for fetching package metadata
36- pub registry_client : Arc < dyn RegistryClient > ,
36+ pub registry_client : Option < Arc < dyn RegistryClient > > ,
3737 /// All updates from the npm registry which have been chosen either by the
3838 /// user via a prompt or automatically by choosing the latest version
3939 pub updates_by_internal_name : HashMap < String , Vec < Specifier > > ,
@@ -44,7 +44,6 @@ pub struct Context {
4444impl Context {
4545 pub fn create ( config : Config , packages : Packages , registry_client : Option < Arc < dyn RegistryClient > > ) -> Self {
4646 let mut instances = vec ! [ ] ;
47- let registry_client = registry_client. unwrap_or_else ( || Arc :: new ( LiveRegistryClient :: new ( ) ) ) ;
4847 let updates_by_internal_name = HashMap :: new ( ) ;
4948 let all_dependency_types = config. rcfile . get_all_dependency_types ( ) ;
5049 let cli_filters = config. cli . get_filters ( & packages, & all_dependency_types) ;
@@ -100,7 +99,7 @@ impl Context {
10099 /// Fetch every version specifier ever published for all updateable
101100 /// dependencies in the project.
102101 pub async fn fetch_all_updates ( & mut self ) {
103- let client = Arc :: clone ( & self . registry_client ) ;
102+ let client = Arc :: clone ( self . registry_client . as_ref ( ) . expect ( "Registry client not initialized" ) ) ;
104103 let semaphore = Arc :: new ( Semaphore :: new ( self . config . rcfile . max_concurrent_requests ) ) ;
105104 let progress_bars = Arc :: new ( MultiProgress :: new ( ) ) ;
106105 let mut handles: Vec < ( String , JoinHandle < Result < PackageMeta , RegistryError > > ) > = vec ! [ ] ;
0 commit comments