| 1 | package Enbld::Command::Deploy; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use 5.010001; | ||
| 7 | |||
| 8 | use parent qw/Enbld::Command/; | ||
| 9 | |||
| 10 | use Try::Lite; | ||
| 11 | use File::Spec; | ||
| 12 | |||
| 13 | require Enbld::Feature; | ||
| 14 | require Enbld::Home; | ||
| 15 | require Enbld::Logger; | ||
| 16 | require Enbld::App::Configuration; | ||
| 17 | require Enbld::Target; | ||
| 18 | require Enbld::Deployed; | ||
| 19 | |||
| 20 | sub do { | ||
| 21 | my $self = shift; | ||
| 22 | |||
| 23 | my $deploy_path = shift @{ $self->{argv} }; | ||
| 24 | |||
| 25 | unless ( $deploy_path ) { | ||
| 26 | die( "ERROR:'deploy' command requires directory path argument.\n" ); | ||
| 27 | } | ||
| 28 | |||
| 29 | ### to absolute path | ||
| 30 | unless ( File::Spec->file_name_is_absolute( $deploy_path ) ) { | ||
| 31 | $deploy_path = File::Spec->rel2abs( $deploy_path ); | ||
| 32 | } | ||
| 33 | |||
| 34 | Enbld::Feature->set_deploy_mode( $deploy_path ); | ||
| 35 | Enbld::Home->initialize; | ||
| 36 | Enbld::Home->create_build_directory; | ||
| 37 | Enbld::Logger->rotate( Enbld::Home->log ); | ||
| 38 | |||
| 39 | Enbld::App::Configuration->read_file; | ||
| 40 | |||
| 41 | foreach my $name ( keys %{ Enbld::App::Configuration->config } ) { | ||
| 42 | my $config = Enbld::App::Configuration->search_config( $name ); | ||
| 43 | |||
| 44 | next unless $config->enabled; | ||
| 45 | |||
| 46 | my $target = Enbld::Target->new( $name, $config ); | ||
| 47 | my $condition = { | ||
| 48 | $name => $config->condition( $config->enabled ), | ||
| 49 | }; | ||
| 50 | |||
| 51 | my $installed = try { | ||
| 52 | return $target->deploy_declared( $condition ); | ||
| 53 | } ( 'Enbld::Error' => sub { | ||
| 54 | Enbld::Message->alert( $@ ); | ||
| 55 | say "Please check build logile:" . Enbld::Logger->logfile; | ||
| 56 | |||
| 57 | return; | ||
| 58 | } | ||
| 59 | ); | ||
| 60 | |||
| 61 | # installed | ||
| 62 | if ( $installed ) { | ||
| 63 | Enbld::Deployed->add( $installed ); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | 1; |