@@ -304,25 +304,13 @@ pub async fn deploy_contracts(
304304 } ,
305305 ) ;
306306
307- if handler_json_exists. is_ok ( ) {
308- if let Some ( progress_bar) = & optional_progress_bar {
309- progress_bar. finish_and_clear ( ) ;
310- }
311-
312- verbose ( "✅ Successfully deployed the contracts" ) ;
313- let options = fs_extra:: file:: CopyOptions :: new ( ) . overwrite ( true ) ;
314- std:: fs:: create_dir_all ( project_root_path. join ( "cardano/gateway/src/deployment/" ) ) ?;
315- copy (
316- project_root_path. join ( "cardano/offchain/deployments/handler.json" ) ,
317- project_root_path. join ( "cardano/gateway/src/deployment/handler.json" ) ,
318- & options,
319- ) ?;
307+ if let Some ( progress_bar) = & optional_progress_bar {
308+ progress_bar. finish_and_clear ( ) ;
309+ }
320310
311+ if handler_json_exists. is_ok ( ) {
321312 Ok ( ( ) )
322313 } else {
323- if let Some ( progress_bar) = & optional_progress_bar {
324- progress_bar. finish_and_clear ( ) ;
325- }
326314 Err ( "❌ Failed to start Cardano services. The handler.json file should have been created, but it doesn't exist. Consider running the start command again using --verbose 5." . into ( ) )
327315 }
328316}
@@ -1191,19 +1179,21 @@ pub fn wait_and_start_mithril_genesis(
11911179 Ok ( ( ) )
11921180}
11931181
1194- pub fn start_gateway ( gateway_dir : & Path ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
1195- let options = fs_extra:: file:: CopyOptions :: new ( ) . overwrite ( true ) ;
1196- copy (
1197- gateway_dir. join ( ".env.example" ) ,
1198- gateway_dir. join ( ".env" ) ,
1199- & options,
1200- ) ?;
1182+ pub fn start_gateway ( gateway_dir : & Path , clean : bool ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
1183+ if ( gateway_dir. join ( ".env" ) . exists ( ) && clean) || !gateway_dir. join ( ".env" ) . exists ( ) {
1184+ let options = fs_extra:: file:: CopyOptions :: new ( ) . overwrite ( true ) ;
1185+ copy (
1186+ gateway_dir. join ( ".env.example" ) ,
1187+ gateway_dir. join ( ".env" ) ,
1188+ & options,
1189+ ) ?;
1190+ }
1191+
1192+ let mut script_args = vec ! [ "compose" , "up" , "-d" ] ;
1193+ if clean {
1194+ script_args. push ( "--build" ) ;
1195+ }
12011196 execute_script ( & gateway_dir, "docker" , Vec :: from ( [ "compose" , "stop" ] ) , None ) ?;
1202- execute_script (
1203- & gateway_dir,
1204- "docker" ,
1205- Vec :: from ( [ "compose" , "up" , "-d" , "--build" ] ) ,
1206- None ,
1207- ) ?;
1197+ execute_script ( & gateway_dir, "docker" , script_args, None ) ?;
12081198 Ok ( ( ) )
12091199}
0 commit comments