Developer-Dashboard
view release on metacpan or search on metacpan
lib/Developer/Dashboard/SkillManager.pm view on Meta::CPAN
package Developer::Dashboard::SkillManager;
use strict;
use warnings;
our $VERSION = '4.16';
use Cwd qw(realpath);
use File::Copy qw(copy);
use File::Path qw(make_path remove_tree);
use File::Spec;
use File::Basename qw(basename);
use File::Find qw(find);
use File::Temp qw(tempdir);
use Capture::Tiny qw(capture);
use IO::Select;
use IPC::Open3;
use JSON::XS qw(decode_json encode_json);
use Symbol qw(gensym);
use Developer::Dashboard::Platform qw(command_in_path);
use Developer::Dashboard::PathRegistry;
# new()
# Creates a SkillManager instance to handle skill installation, updates, uninstalls.
# Input: none.
# Output: SkillManager object.
sub new {
my ( $class, %args ) = @_;
my $paths = $args{paths}
|| Developer::Dashboard::PathRegistry->new(
home => ( $ENV{HOME} || (getpwuid($>))[7] || $ENV{USERPROFILE} || die 'Missing home directory' ),
workspace_roots => [],
project_roots => [],
);
return bless {
paths => $paths,
progress => $args{progress},
skip_tests => $args{skip_tests} ? 1 : 0,
}, $class;
}
# install_progress_tasks()
# Returns the ordered task list shown for one dashboard skills install run.
# Input: none.
# Output: array reference of progress task hashes.
sub install_progress_tasks {
return [
{ id => 'fetch_source', label => 'Fetch skill source' },
{ id => 'prepare_layout', label => 'Prepare skill layout' },
{ id => 'install_aptfile', label => 'Install aptfile dependencies' },
{ id => 'install_apkfile', label => 'Install apkfile dependencies' },
{ id => 'install_dnfile', label => 'Install dnfile dependencies' },
{ id => 'install_wingetfile', label => 'Install wingetfile dependencies' },
{ id => 'install_brewfile', label => 'Install brewfile dependencies' },
{ id => 'install_package_json', label => 'Install package.json dependencies' },
{ id => 'install_requirements_txt', label => 'Install requirements.txt dependencies' },
{ id => 'install_cpanfile', label => 'Install cpanfile dependencies' },
{ id => 'install_cpanfile_local', label => 'Install cpanfile.local dependencies' },
{ id => 'install_makefile', label => 'Install Makefile dependencies' },
{ id => 'install_dockerfile', label => 'Install dockerfile dependencies' },
{ id => 'install_ddfile', label => 'Install ddfile dependencies' },
{ id => 'install_ddfile_local', label => 'Install ddfile.local dependencies' },
];
}
# dependency_progress_tasks_for_skill_path($skill_path)
# Returns the ordered dependency-task list that should be shown for one
# installed skill after its manifest files are known on disk.
# Input: absolute skill root directory path.
# Output: array reference of applicable progress task hashes.
sub dependency_progress_tasks_for_skill_path {
my ( $self, $skill_path ) = @_;
my %wanted = map { $_ => 1 } $self->_dependency_progress_task_ids_for_skill_path($skill_path);
my @tasks = grep { $wanted{ $_->{id} || '' } } @{ install_progress_tasks() };
return \@tasks;
}
# install_progress_tasks_for_sources(@sources)
# Returns the ordered source-level task list shown for multi-skill install and
# bare update-all runs.
# Input: skill source strings in the order they will be installed.
# Output: array reference of progress task hashes.
sub install_progress_tasks_for_sources {
my ( $class, @sources ) = @_;
my @tasks;
my $idx = 0;
for my $source (@sources) {
next if !defined $source || $source eq '';
push @tasks, {
id => 'install_source_' . $idx,
( run in 0.685 second using v1.01-cache-2.11-cpan-6aa56a78535 )