PAX
view release on metacpan or search on metacpan
lib/PAX/CodeUnitCompiler.pm view on Meta::CPAN
skill_layers_method => $package . '::_skill_layers',
skill_env_method => $package . '::_skill_env',
prototype => $prototype,
};
}
if (
_package_tail_is($package, '')
&& $short_name eq 'exec_command'
&& $body =~ /unknown_skill_command_message/
&& $body =~ /_execute_hooks_streaming/
&& $body =~ /_exec_resolved_command/
) {
my $prototype = _sub_prototype_from_source($source, $short_name);
return {
name => $short_name,
full_name => $full_name,
op => 'skill_dispatcher_exec_command',
command_spec_method => $package . '::_command_spec',
execute_hooks_streaming_method => $package . '::_execute_hooks_streaming',
skill_layers_method => $package . '::_skill_layers',
skill_env_method => $package . '::_skill_env',
exec_resolved_method => $package . '::_exec_resolved_command',
prototype => $prototype,
};
}
if (
_package_tail_is($package, '')
&& $short_name eq 'execute_hooks'
lib/PAX/CodeUnitCompiler.pm view on Meta::CPAN
op => 'skill_dispatcher_execute_hooks',
command_spec_method => $package . '::_command_spec',
skill_layers_method => $package . '::_skill_layers',
skill_env_method => $package . '::_skill_env',
prototype => $prototype,
};
}
if (
_package_tail_is($package, '')
&& $short_name eq '_execute_hooks_streaming'
&& $body =~ /_arrayref_or_empty/
&& $body =~ /_skill_env/
&& $body =~ /_run_child_command_streaming/
) {
my $prototype = _sub_prototype_from_source($source, $short_name);
return {
name => $short_name,
full_name => $full_name,
op => 'skill_dispatcher_execute_hooks_streaming',
arrayref_or_empty_method => $package . '::_arrayref_or_empty',
skill_env_method => $package . '::_skill_env',
run_child_streaming_method => $package . '::_run_child_command_streaming',
prototype => $prototype,
};
}
if (
_package_tail_is($package, '')
&& $short_name eq '_run_child_command_streaming'
&& $body =~ /_arrayref_or_empty/
&& $body =~ /_hashref_or_empty/
&& $body =~ /_defined_or_default/
&& $body =~ /open3/
&& $body =~ /IO::Select/
) {
my $prototype = _sub_prototype_from_source($source, $short_name);
return {
name => $short_name,
full_name => $full_name,
op => 'skill_dispatcher_run_child_command_streaming',
arrayref_or_empty_method => $package . '::_arrayref_or_empty',
hashref_or_empty_method => $package . '::_hashref_or_empty',
defined_or_default_method => $package . '::_defined_or_default',
prototype => $prototype,
};
}
if (
_package_tail_is($package, '')
&& $short_name eq '_exec_resolved_command'
lib/PAX/StandaloneRuntime.pm view on Meta::CPAN
stderr => $hook_stderr . $stderr,
exit_code => $exit,
hooks => $hook_result->{hooks} || {},
};
};
return _install_sub_impl($package, $name, $sub->{prototype}, $impl);
}
if (($sub->{op} // '') eq 'skill_dispatcher_exec_command') {
my $command_spec_method = $sub->{command_spec_method} // die 'compiled sub command-spec method missing';
my $execute_hooks_streaming_method = $sub->{execute_hooks_streaming_method} // die 'compiled sub execute-hooks-streaming method missing';
my $skill_layers_method = $sub->{skill_layers_method} // die 'compiled sub skill-layers method missing';
my $skill_env_method = $sub->{skill_env_method} // die 'compiled sub skill-env method missing';
my $exec_resolved_method = $sub->{exec_resolved_method} // die 'compiled sub exec-resolved method missing';
$impl = sub {
my ($self, $skill_name, $command, @args) = @_;
return { error => 'Missing skill name' } if !$skill_name;
return { error => 'Missing command name' } if !$command;
my $skill_path = $self->{manager}->get_skill_path($skill_name, include_disabled => 1);
my $suggest = __PAX_RUNTIME_LEGACY_NAMESPACE__::CLI::Suggest->new(paths => $self->{manager}{paths}, manager => $self->{manager});
return { error => $suggest->unknown_skill_command_message($skill_name, $command) } if !$skill_path;
return { error => $suggest->unknown_skill_command_message($skill_name, $command) } if !$self->{manager}->is_enabled($skill_name);
my $command_spec = _code_for($command_spec_method)->($self, $skill_name, $command);
my $cmd_path = $command_spec ? $command_spec->{cmd_path} : undef;
my $command_skill_path = $command_spec ? $command_spec->{skill_path} : undef;
return { error => $suggest->unknown_skill_command_message($skill_name, $command) } if !$cmd_path;
my @skill_layers = $command_spec ? @{ $command_spec->{skill_layers} || [] } : _code_for($skill_layers_method)->($self, $skill_name);
my $hook_result = _code_for($execute_hooks_streaming_method)->($self, $skill_name, $command_spec ? $command_spec->{command_name} : $command, \@skill_layers, @args);
return $hook_result if $hook_result->{error};
my %env = _code_for($skill_env_method)->(
$self,
skill_name => $skill_name,
skill_path => $command_skill_path || $skill_path,
skill_layers => \@skill_layers,
command => $command_spec ? $command_spec->{command_name} : $command,
result_state => $hook_result->{result_state} || {},
);
my @command = __PAX_RUNTIME_LEGACY_NAMESPACE__::Platform::command_argv_for_path($cmd_path);
lib/PAX/StandaloneRuntime.pm view on Meta::CPAN
}
closedir($dh);
}
my %payload = ( hooks => \%results, result_state => \%results );
$payload{last_result} = $last_result if %{$last_result};
return \%payload;
};
return _install_sub_impl($package, $name, $sub->{prototype}, $impl);
}
if (($sub->{op} // '') eq 'skill_dispatcher_execute_hooks_streaming') {
my $arrayref_or_empty_method = $sub->{arrayref_or_empty_method} // die 'compiled sub arrayref-or-empty method missing';
my $skill_env_method = $sub->{skill_env_method} // die 'compiled sub skill-env method missing';
my $run_child_streaming_method = $sub->{run_child_streaming_method} // die 'compiled sub child-streaming method missing';
$impl = sub {
my ($self, $skill_name, $command, $skill_layers, @args) = @_;
return { hooks => {}, result_state => {} } if !$skill_name || !$command;
my @skill_layers = @{ _code_for($arrayref_or_empty_method)->($self, $skill_layers) };
return { hooks => {}, result_state => {} } if !@skill_layers;
my %results;
my $last_result = {};
for my $layer_path (@skill_layers) {
my $hooks_dir = File::Spec->catdir($layer_path, 'cli', "$command.d");
next if !-d $hooks_dir;
lib/PAX/StandaloneRuntime.pm view on Meta::CPAN
next unless __PAX_RUNTIME_LEGACY_NAMESPACE__::Platform::is_runnable_file($hook_path);
my %env = _code_for($skill_env_method)->(
$self,
skill_name => $skill_name,
skill_path => $layer_path,
skill_layers => \@skill_layers,
command => $command,
result_state => \%results,
);
my @hook_command = __PAX_RUNTIME_LEGACY_NAMESPACE__::Platform::command_argv_for_path($hook_path);
my $run = _code_for($run_child_streaming_method)->(
$self,
command => \@hook_command,
args => \@args,
env => \%env,
skill_layers => \@skill_layers,
result_state => \%results,
last_result => $last_result,
stdin_mode => 'null',
);
my $result_key = $entry;
lib/PAX/StandaloneRuntime.pm view on Meta::CPAN
}
closedir($dh);
}
my %payload = ( hooks => \%results, result_state => \%results );
$payload{last_result} = $last_result if %{$last_result};
return \%payload;
};
return _install_sub_impl($package, $name, $sub->{prototype}, $impl);
}
if (($sub->{op} // '') eq 'skill_dispatcher_run_child_command_streaming') {
my $arrayref_or_empty_method = $sub->{arrayref_or_empty_method} // die 'compiled sub arrayref-or-empty method missing';
my $hashref_or_empty_method = $sub->{hashref_or_empty_method} // die 'compiled sub hashref-or-empty method missing';
my $defined_or_default_method = $sub->{defined_or_default_method} // die 'compiled sub defined-or-default method missing';
$impl = sub {
my ($self, %args) = @_;
my @command = @{ _code_for($arrayref_or_empty_method)->($self, $args{command}) };
my @argv = @{ _code_for($arrayref_or_empty_method)->($self, $args{args}) };
my %env = %{ _code_for($hashref_or_empty_method)->($self, $args{env}) };
my @skill_layers = @{ _code_for($arrayref_or_empty_method)->($self, $args{skill_layers}) };
my $result_state = _code_for($hashref_or_empty_method)->($self, $args{result_state});
my $last_result = $args{last_result};
my $stdin_mode = _code_for($defined_or_default_method)->($self, $args{stdin_mode}, 'inherit');
my $stdin_spec = '<&STDIN';
my $stdin_fh;
if ($stdin_mode eq 'null') {
open $stdin_fh, '<', File::Spec->devnull() or die "Unable to open " . File::Spec->devnull() . " for streaming skill hook stdin: $!";
$stdin_spec = '<&' . fileno($stdin_fh);
}
my $stderr = Symbol::gensym();
my $stdout;
my ($stdout_text, $stderr_text) = ('', '');
my $pid;
{
local %ENV = (%ENV, %env);
__PAX_RUNTIME_LEGACY_NAMESPACE__::Runtime::Result::set_current($result_state);
if (ref($last_result) eq 'HASH' && %{$last_result}) {
t/code_unit_compiler.t view on Meta::CPAN
ok((grep { ($_->{name} // '') eq '_merge_skill_hashes' && ($_->{op} // '') eq 'skill_dispatcher_merge_skill_hashes' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles layered skill-config merge helper');
ok((grep { ($_->{name} // '') eq 'get_skill_config' && ($_->{op} // '') eq 'skill_dispatcher_get_skill_config' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles skill config loader');
ok((grep { ($_->{name} // '') eq 'config_fragment' && ($_->{op} // '') eq 'skill_dispatcher_config_fragment' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles skill config fragment helper');
ok((grep { ($_->{name} // '') eq 'get_skill_path' && ($_->{op} // '') eq 'skill_dispatcher_get_skill_path' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles skill path lookup helper');
ok((grep { ($_->{name} // '') eq 'command_path' && ($_->{op} // '') eq 'skill_dispatcher_command_path' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles command path helper');
ok((grep { ($_->{name} // '') eq 'command_hook_paths' && ($_->{op} // '') eq 'skill_dispatcher_command_hook_paths' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles command hook enumerator');
ok((grep { ($_->{name} // '') eq 'route_response' && ($_->{op} // '') eq 'skill_dispatcher_route_response' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles route response dispatcher');
ok((grep { ($_->{name} // '') eq '_load_skill_page' && ($_->{op} // '') eq 'skill_dispatcher_load_skill_page' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles skill page loader');
ok((grep { ($_->{name} // '') eq '_skill_env' && ($_->{op} // '') eq 'skill_dispatcher_skill_env' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles skill env builder');
ok((grep { ($_->{name} // '') eq 'execute_hooks' && ($_->{op} // '') eq 'skill_dispatcher_execute_hooks' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles hook execution pipeline');
ok((grep { ($_->{name} // '') eq '_execute_hooks_streaming' && ($_->{op} // '') eq 'skill_dispatcher_execute_hooks_streaming' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles streaming hook pipeline');
ok((grep { ($_->{name} // '') eq '_run_child_command_streaming' && ($_->{op} // '') eq 'skill_dispatcher_run_child_command_streaming' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles streaming child runner');
ok((grep { ($_->{name} // '') eq '_exec_replacement' && ($_->{op} // '') eq 'skill_dispatcher_exec_replacement' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles final exec replacement');
ok((grep { ($_->{name} // '') eq 'dispatch' && ($_->{op} // '') eq 'skill_dispatcher_dispatch' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles dispatch entry');
ok((grep { ($_->{name} // '') eq 'exec_command' && ($_->{op} // '') eq 'skill_dispatcher_exec_command' } @{ $skill_dispatcher_record->{subs} // [] }) >= 1, 'SkillDispatcher compiles exec-command entry');
my $docker_compose = $compiler->compile(
path => 'DD Source Code/developer-dashboard/lib/Developer/Dashboard/DockerCompose.pm',
kind => 'lib',
logical_path => 'lib/developer-dashboard/Developer/Dashboard/DockerCompose.pm',
);
is($docker_compose->{packaging}, 'compiled_pcu_v1', 'DockerCompose now compiles to PCU');
( run in 1.049 second using v1.01-cache-2.11-cpan-140bd7fdf52 )