@@ -2,16 +2,16 @@ use crate::helpers::artifacts::CastStarknetContractArtifacts;
22use anyhow:: { Context , Result , anyhow} ;
33use camino:: { Utf8Path , Utf8PathBuf } ;
44use foundry_ui:: { UI , components:: warning:: WarningMessage } ;
5+ use scarb_api:: metadata:: { MetadataOpts , get_metadata_for_dir, get_metadata_with_opts} ;
56use scarb_api:: {
67 CompilationOpts , ScarbCommand , ScarbCommandError ,
78 get_contracts_artifacts_and_source_sierra_paths,
8- metadata:: { Metadata , MetadataCommand , PackageMetadata } ,
9+ metadata:: { Metadata , PackageMetadata } ,
910 target_dir_for_workspace,
1011} ;
1112use scarb_ui:: args:: PackagesFilter ;
1213use shared:: command:: CommandExt ;
1314use std:: collections:: HashMap ;
14- use std:: env;
1515use std:: str:: FromStr ;
1616
1717pub fn get_scarb_manifest ( ) -> Result < Utf8PathBuf > {
@@ -37,34 +37,21 @@ pub fn get_scarb_manifest_for(dir: &Utf8Path) -> Result<Utf8PathBuf> {
3737 Ok ( path)
3838}
3939
40- fn get_scarb_metadata_command ( manifest_path : & Utf8PathBuf ) -> Result < MetadataCommand > {
41- ScarbCommand :: new ( ) . ensure_available ( ) ?;
42-
43- let mut command = MetadataCommand :: new ( ) ;
44- command. inherit_stderr ( ) . manifest_path ( manifest_path) ;
45- Ok ( command)
46- }
47-
48- fn execute_scarb_metadata_command ( command : & MetadataCommand ) -> Result < Metadata > {
49- command. exec ( ) . context ( format ! (
50- "Failed to read the `Scarb.toml` manifest file. Doesn't exist in the current or parent directories = {}" ,
51- env:: current_dir( )
52- . expect( "Failed to access the current directory" )
53- . into_os_string( )
54- . into_string( )
55- . expect( "Failed to convert current directory into a string" )
56- ) )
57- }
58-
5940pub fn get_scarb_metadata ( manifest_path : & Utf8PathBuf ) -> Result < Metadata > {
60- let mut command = get_scarb_metadata_command ( manifest_path) ?;
61- let command = command. no_deps ( ) ;
62- execute_scarb_metadata_command ( command)
41+ get_metadata_with_opts ( MetadataOpts {
42+ current_dir : Some (
43+ manifest_path
44+ . parent ( )
45+ . expect ( "manifest should have parent" )
46+ . into ( ) ,
47+ ) ,
48+ no_deps : true ,
49+ ..MetadataOpts :: default ( )
50+ } )
6351}
6452
6553pub fn get_scarb_metadata_with_deps ( manifest_path : & Utf8PathBuf ) -> Result < Metadata > {
66- let command = get_scarb_metadata_command ( manifest_path) ?;
67- execute_scarb_metadata_command ( & command)
54+ get_metadata_for_dir ( manifest_path. parent ( ) . expect ( "manifest should have parent" ) )
6855}
6956
7057pub fn get_cairo_version ( manifest_path : & Utf8PathBuf ) -> Result < String > {
0 commit comments