Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build META files if not included #250

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/App/cpm/Worker/Installer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,22 @@ sub fetch {

chdir $dir or die;

my $meta = $self->_load_metafile($distfile, 'META.json', 'META.yml');
my @accepted_meta_files = ('META.json', 'META.yml', 'MYMETA.json', 'MYMETA.yml');

if (!grep -f, \@accepted_meta_files && grep -f, [ 'Makefile.PL', 'Build.PL' ]) {
my $makefile = (-f 'Makefile.PL' ? 'Makefile' : 'Build');
$self->{logger}->log("Configuring distribution via $makefile.PL");
my @cmd = ($self->{menlo}->{perl}, "$makefile.PL");
push @cmd, 'PUREPERL_ONLY=1' if $self->{pureperl_only};
$self->_retry(sub {
$self->{menlo}->configure(\@cmd, $self->{menlo_dist}, 1);
-f $makefile;
});
}

my $meta = $self->_load_metafile($distfile, @accepted_meta_files);
if (!$meta) {
$self->{logger}->log("Distribution does not have META.json nor META.yml");
$self->{logger}->log("Distribution lacks both META.json and META.yml files, and neither MYMETA.json nor MYMETA.yml can be generated");
return;
}
my $p = $meta->{provides} || $self->menlo->extract_packages($meta, ".");
Expand Down
19 changes: 19 additions & 0 deletions xt/37_remote_tar_without_meta_or_module_name.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use strict;
use warnings;
use Test::More;
use lib "xt/lib";
use CLI;

subtest remote_tar_without_meta_or_module_name => sub {
my $r = cpm_install "-v", "https://cpan.metacpan.org/authors/id/G/GC/GCAMPBELL/Data-Diff-0.01.tar.gz";
is $r->exit, 0;
note $r->err;
};

subtest fail => sub {
my $r = cpm_install "-v", "https://cpan.metacpan.org/authors/id/G/GC/GCAMPBELL/Data-Diff-0.01.xxx";
isnt $r->exit, 0;
note $r->err;
};

done_testing;
20 changes: 20 additions & 0 deletions xt/38_git_without_meta_or_module_name.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use strict;
use warnings;
use Test::More;
use lib "xt/lib";
use CLI;

subtest git_without_meta_or_module_name => sub {
my $r = cpm_install "-v", 'https://github.com/ap/Async.git@v0.14';
is $r->exit, 0;
note $r->err;
};

subtest fail => sub {
local $ENV{GIT_TERMINAL_PROMPT} = 0;
my $r = cpm_install "-v", 'https://github.com/ap/Async.git@xxxxx';
isnt $r->exit, 0;
note $r->err;
};

done_testing;