App-Dest
view release on metacpan or search on metacpan
lib/App/Dest.pm view on Meta::CPAN
my $redeploy = delete $self->{redeploy};
my $execute_stack = $self->_build_execute_stack( $action, 'deploy', undef, $redeploy );
die "Action already deployed\n" if (
not @$execute_stack or
not scalar( grep { $_->{action} eq $action and $_->{type} eq 'deploy' } @$execute_stack )
);
unless ($dry_run) {
$self->_execute_action($_) for (@$execute_stack);
}
else {
_dry_run_report($execute_stack);
}
return 0;
}
sub redeploy {
my $self = _new(shift);
$self->{redeploy} = 1;
return $self->deploy(@_);
}
sub revdeploy {
my $self = _new(shift);
my ($action) = @_;
$self->revert($action);
return $self->deploy($action);
}
sub verify {
my $self = _new(shift);
my ($action) = @_;
return $self->_execute_action( $self->_build_execute_stack( $action, 'verify' )->[0] );
}
sub revert {
my $self = _new(shift);
my ( $dry_run, $action ) = _dry_check(@_);
die "File to revert required; usage: dest revert file\n" unless ($action);
my $execute_stack = $self->_build_execute_stack( $action, 'revert' );
die "Action not deployed\n" if (
not @$execute_stack or
not scalar( grep { $_->{action} eq $action and $_->{type} eq 'revert' } @$execute_stack )
);
unless ($dry_run) {
$self->_execute_action($_) for (@$execute_stack);
}
else {
_dry_run_report($execute_stack);
}
return 0;
}
sub update {
my $self = _new(shift);
my ( $dry_run, @incs ) = _dry_check(@_);
my $seen_action = {};
my $execute_stack;
for (
sort {
( $b->{modified} || 0 ) <=> ( $a->{modified} || 0 ) ||
$a->{action} cmp $b->{action}
}
grep { not $_->{matches} }
values %{ $self->_status_data->{actions} }
) {
push( @$execute_stack, @{ $self->_build_execute_stack( $_->{action}, 'revert' ) } ) if (
$_->{modified} or $_->{deployed}
);
push( @$execute_stack, @{ $self->_build_execute_stack( $_->{action}, 'deploy', $seen_action ) } );
}
$execute_stack = [
grep {
my $execution = $_;
my $match = 0;
for (@incs) {
if ( index( $execution->{file}, $_ ) > -1 ) {
$match = 1;
last;
}
}
$match;
}
@$execute_stack
] if (@incs);
unless ($dry_run) {
$self->_execute_action($_) for (@$execute_stack);
}
else {
_dry_run_report($execute_stack);
}
return 0;
}
sub version {
print 'dest version ', $__PACKAGE__::VERSION || 0, "\n";
return 0;
}
sub _new {
my ( $self, $expect_no_root_dir ) = @_;
if ( not ref $self ) {
$self = bless( {}, __PACKAGE__ );
$self->{root_dir} = Path::Tiny->cwd;
( run in 2.176 seconds using v1.01-cache-2.11-cpan-d06a3f9ecfd )