view release on metacpan or search on metacpan
lib/App/lcpan/Cmd/changes.pm view on Meta::CPAN
unless ($dist_found) {
my $sth = $dbh->prepare("SELECT file_id FROM script WHERE name=?");
$sth->execute($mod_or_dist_or_script);
while (my ($e) = $sth->fetchrow_array) {
push @file_ids, $e;
}
}
}
return [404, "No such module/dist/script"] unless @file_ids;
push @where, "file.id IN (".join(",", @file_ids).")";
}
my $sql = "SELECT
content.path content_path,
file.cpanid author,
file.name release
FROM content
LEFT JOIN file ON content.file_id=file.id
".(@join ? join(" ", @join) : "")."
lib/App/lcpan/Cmd/changes.pm view on Meta::CPAN
}
return [200, "OK", $content, {
'func.content_path' => $row->{content_path},
'cmdline.skip_format'=>1,
"cmdline.page_result"=>1,
}];
}
if ($first_row) {
return [404, "No Changes file found in $first_row->{release}"];
} else {
return [404, "No such module or dist"];
}
}
1;
# ABSTRACT: Show Changes of distribution/module
__END__
=pod
lib/App/lcpan/Cmd/copy_mod.pm view on Meta::CPAN
my $row = $dbh->selectrow_hashref("SELECT
file.cpanid cpanid,
file.name name
FROM module
LEFT JOIN file ON module.file_id=file.id
WHERE module.name=?
ORDER BY version_numified DESC
", {}, $mod);
return [404, "No release for module '$mod'"] unless $row;
my $srcpath = App::lcpan::_fullpath(
$row->{name}, $state->{cpan}, $row->{cpanid});
my $targetpath = $row->{name};
(-f $srcpath) or return [404, "File not found: $srcpath"];
if ((-f $targetpath) && !$args{overwrite}) {
return [412, "Refusing to overwrite existing file '$targetpath'"];
}
File::Copy::syscopy($srcpath, $targetpath)
or return [500, "Can't copy '$srcpath' to '$targetpath': $!"];
[200, "OK", undef, {
'func.source_path'=>$srcpath,
lib/App/lcpan/Cmd/copy_rel.pm view on Meta::CPAN
my $rel = $args{release};
my $row = $dbh->selectrow_hashref("SELECT
cpanid,
name
FROM file
WHERE name=?
", {}, $rel);
return [404, "No such release"] unless $row;
my $srcpath = App::lcpan::_fullpath(
$row->{name}, $state->{cpan}, $row->{cpanid});
my $targetpath = $row->{name};
(-f $srcpath) or return [404, "File not found: $srcpath"];
if ((-f $targetpath) && !$args{overwrite}) {
return [412, "Refusing to overwrite existing file '$targetpath'"];
}
File::Copy::syscopy($srcpath, $targetpath)
or return [500, "Can't copy '$srcpath' to '$targetpath': $!"];
[200, "OK", undef, {
'func.source_path'=>$srcpath,
lib/App/lcpan/Cmd/copy_script.pm view on Meta::CPAN
my %mem;
while (my $row = $sth->fetchrow_hashref) {
unless ($args{all}) {
next if $mem{$row->{script}}++;
}
push @srcpaths, App::lcpan::_fullpath(
$row->{release}, $state->{cpan}, $row->{author});
push @targetpaths, $row->{release};
}
return [404, "No release for script '$script'"] unless @srcpaths;
my $envres = envresmulti();
for my $i (0..$#srcpaths) {
my $srcpath = $srcpaths[$i];
my $targetpath = $targetpaths[$i];
(-f $srcpath) or do {
$envres->add_result(
404, "File not found: $srcpath",
{item_id => $srcpath},
);
next;
};
if ((-f $targetpath) && !$args{overwrite}) {
$envres->add_result(
412, "Refusing to overwrite existing file '$targetpath'",
{item_id => $srcpath},
);
next;
lib/App/lcpan/Cmd/delete_rel.pm view on Meta::CPAN
},
tags => ['write-to-db', 'write-to-fs'],
};
sub handle_cmd {
my %args = @_;
my $state = App::lcpan::_init(\%args, 'rw');
my $dbh = $state->{dbh};
my $row = $dbh->selectrow_hashref("SELECT id,cpanid FROM file WHERE name=?", {}, $args{release})
or return [404, "No such release"];
$dbh->begin_work;
App::lcpan::_delete_releases_records($dbh, $row->{id});
$dbh->commit;
if ($args{delete_file}) {
my $path = App::lcpan::_fullpath(
$args{release}, $state->{cpan}, $row->{cpanid});
log_info("Deleting file %s ...", $path);
unlink $path;
lib/App/lcpan/Cmd/deps_by_dependent_count.pm view on Meta::CPAN
my $include_noncore = $args{include_noncore} // 1;
my $plver = $args{perl_version} // "$^V";
# first, get the file ID's of the requested modules
my @file_ids;
{
my $mods_s = join(", ", map {$dbh->quote($_)} @{$args{modules}});
my $sth = $dbh->prepare("SELECT id FROM file WHERE is_latest_dist AND id IN (SELECT file_id FROM module WHERE name IN ($mods_s))");
$sth->execute;
while (my ($id) = $sth->fetchrow_array) { push @file_ids, $id }
return [404, "No such module(s)"] unless @file_ids;
}
my @cols = (
# name, dbcolname/expr
["module", "m.name"],
["author", "m.cpanid"],
["version", "m.version"],
["is_core", undef],
["dependent_count", "COUNT(*)"],
);
lib/App/lcpan/Cmd/deps_to_other_author.pm view on Meta::CPAN
my @authors;
if ($args{dists}) {
my $sth = $dbh->prepare(
"SELECT DISTINCT cpanid FROM file WHERE dist_name IN (".
join(", ", map { $dbh->quote($_) } @{ $args{dists} }).")");
$sth->execute;
while (my @row = $sth->fetchrow_array) {
push @authors, $row[0];
}
$sth->finish;
return [404, "No such dist(s)"] unless @authors;
} else {
return [400, "Please specify dists"];
}
my $res = App::lcpan::deps(%args);
return $res unless $res->[0] == 200;
$res->[2] = [grep { my $author = $_->{author}; !defined($author) || !(grep {$author eq $_} @authors) } @{ $res->[2] }];
$res;
},
lib/App/lcpan/Cmd/dist2author.pm view on Meta::CPAN
my @res;
$sth->execute;
while (my $row = $sth->fetchrow_hashref) {
push @res, $row;
}
if (@$dists == 1) {
@res = map { $_->{author} } @res;
if (!@res) {
return [404, "No such dist"];
} elsif (@res == 1) {
return [200, "OK", $res[0]];
} else {
return [200, "OK", \@res];
}
}
[200, "OK", \@res, {'table.fields'=>[qw/dist author/]}];
}
lib/App/lcpan/Cmd/dist_contents.pm view on Meta::CPAN
args => \%cmd_args,
};
sub handle_cmd {
my %args = @_;
my $state = App::lcpan::_init(\%args, 'ro');
my $dbh = $state->{dbh};
my ($file_id) = $dbh->selectrow_array(
"SELECT id FROM file WHERE dist_name=?", {}, $args{dist});
$file_id or return [404, "No such dist '$args{dist}'"];
App::lcpan::Cmd::contents::handle_cmd(%args);
}
1;
# ABSTRACT: List contents inside a distribution
__END__
=pod
lib/App/lcpan/Cmd/dist_meta.pm view on Meta::CPAN
},
};
sub handle_cmd {
my %args = @_;
my $state = App::lcpan::_init(\%args, 'ro');
my $dbh = $state->{dbh};
my ($cpanid, $file_name, $file_id, $has_metajson, $has_metayml) = $dbh->selectrow_array(
"SELECT cpanid, name, id, has_metajson, has_metayml FROM file WHERE is_latest_dist AND dist_name=?", {}, $args{dist});
$file_id or return [404, "No such dist '$args{dist}'"];
$has_metajson || $has_metayml or return [412, "Dist does not have metadata"];
my $path = App::lcpan::_fullpath($file_name, $state->{cpan}, $cpanid);
my $la_res = App::lcpan::_list_archive_members($path, $file_name, $file_id);
return [500, "Can't read archive $path: $la_res->[1]"] unless $la_res->[0] == 200;
my $gm_res = App::lcpan::_get_meta($la_res);
return [500, "Can't extract distmeta from $path: $gm_res->[1]"] unless $gm_res->[0] == 200;
$gm_res;
}
lib/App/lcpan/Cmd/doc.pm view on Meta::CPAN
LEFT JOIN file ON script.file_id=file.id
LEFT JOIN content ON script.content_id=content.id
".(@where ? " WHERE ".join(" AND ", @where) : "")."
ORDER BY content.size DESC
LIMIT 1", {}, @bind);
last LOOK if $row;
}
}
return [404, "No such module/POD/script"] unless $row;
my $path = App::lcpan::_fullpath(
$row->{release}, $state->{cpan}, $row->{author});
# XXX needs to be refactored into common code
my $content;
if ($path =~ /\.zip$/i) {
require Archive::Zip;
my $zip = Archive::Zip->new;
$zip->read($path) == Archive::Zip::AZ_OK()
lib/App/lcpan/Cmd/extract_dist.pm view on Meta::CPAN
my $dist = $args{dist};
my $row = $dbh->selectrow_hashref("SELECT
cpanid cpanid,
name name
FROM file
WHERE dist_name=? AND is_latest_dist=1
ORDER BY dist_version_numified DESC
", {}, $dist);
return [404, "No release for distribution '$dist'"] unless $row;
my $path = App::lcpan::_fullpath(
$row->{name}, $state->{cpan}, $row->{cpanid});
(-f $path) or return [404, "File not found: $path"];
my $ae = Archive::Extract->new(archive => $path);
$ae->extract or return [500, "Can't extract: " . $ae->error];
[200, "OK", undef, {'func.release_path'=>$path}];
}
1;
# ABSTRACT: Extract a distribution's latest release file to current directory
lib/App/lcpan/Cmd/extract_mod.pm view on Meta::CPAN
my $row = $dbh->selectrow_hashref("SELECT
file.cpanid cpanid,
file.name name
FROM module
LEFT JOIN file ON module.file_id=file.id
WHERE module.name=?
ORDER BY version_numified DESC
", {}, $mod);
return [404, "No release for module '$mod'"] unless $row;
my $path = App::lcpan::_fullpath(
$row->{name}, $state->{cpan}, $row->{cpanid});
(-f $path) or return [404, "File not found: $path"];
my $ae = Archive::Extract->new(archive => $path);
$ae->extract or return [500, "Can't extract: " . $ae->error];
[200, "OK", undef, {'func.release_path'=>$path}];
}
1;
# ABSTRACT: Extract a module's latest release file to current directory
lib/App/lcpan/Cmd/extract_rel.pm view on Meta::CPAN
my $rel = $args{release};
my $row = $dbh->selectrow_hashref("SELECT
cpanid,
name
FROM file
WHERE name=?
", {}, $rel);
return [404, "No such release"] unless $row;
my $path = App::lcpan::_fullpath(
$row->{name}, $state->{cpan}, $row->{cpanid});
(-f $path) or return [404, "File not found: $path"];
my $ae = Archive::Extract->new(archive => $path);
$ae->extract or return [500, "Can't extract: " . $ae->error];
[200, "OK", undef, {'func.release_path'=>$path}];
}
1;
# ABSTRACT: Extract a release to current directory
lib/App/lcpan/Cmd/extract_script.pm view on Meta::CPAN
my @paths;
my %mem;
while (my $row = $sth->fetchrow_hashref) {
unless ($args{all}) {
next if $mem{$row->{script}}++;
}
push @paths, App::lcpan::_fullpath(
$row->{release}, $state->{cpan}, $row->{author});
}
return [404, "No release for script '$script'"] unless @paths;
my $envres = envresmulti();
for my $i (0..$#paths) {
my $path = $paths[$i];
(-f $path) or do {
$envres->add_result(
404, "File not found: $path",
{item_id => $path},
);
next;
};
my $ae = Archive::Extract->new(archive => $path);
$ae->extract or do {
$envres->add_result(
500, "Can't extract: " . $ae->error,
{item_id => $path},
);
lib/App/lcpan/Cmd/mod2author.pm view on Meta::CPAN
my @res;
$sth->execute;
while (my $row = $sth->fetchrow_hashref) {
push @res, $row;
}
if (@$mods == 1) {
@res = map { $_->{author} } @res;
if (!@res) {
return [404, "No such module"];
} elsif (@res == 1) {
return [200, "OK", $res[0]];
} else {
return [200, "OK", \@res];
}
}
[200, "OK", \@res, {'table.fields'=>[qw/module author/]}];
}
lib/App/lcpan/Cmd/mod_contents.pm view on Meta::CPAN
args => \%cmd_args,
};
sub handle_cmd {
my %args = @_;
my $state = App::lcpan::_init(\%args, 'ro');
my $dbh = $state->{dbh};
my ($file_id) = $dbh->selectrow_array(
"SELECT file_id FROM module WHERE name=?", {}, $args{module});
$file_id or return [404, "No such module '$args{module}'"];
delete $args{module};
App::lcpan::Cmd::contents::handle_cmd(
%args,
file_id => $file_id,
);
}
1;
# ABSTRACT: List contents inside a module's distribution
lib/App/lcpan/Cmd/rdeps_from_other_author.pm view on Meta::CPAN
my @authors;
if ($args{modules}) {
my $sth = $dbh->prepare(
"SELECT DISTINCT cpanid FROM module WHERE name IN (".
join(", ", map { $dbh->quote($_) } @{ $args{modules} }).")");
$sth->execute;
while (my @row = $sth->fetchrow_array) {
push @authors, $row[0];
}
$sth->finish;
return [404, "No such module(s)"] unless @authors;
} elsif ($args{dists}) {
my $sth = $dbh->prepare(
"SELECT DISTINCT cpanid FROM file WHERE dist_name IN (".
join(", ", map { $dbh->quote($_) } @{ $args{dists} }).")");
$sth->execute;
while (my @row = $sth->fetchrow_array) {
push @authors, $row[0];
}
$sth->finish;
return [404, "No such dist(s)"] unless @authors;
} else {
return [400, "Please specify either modules/dists"];
}
App::lcpan::rdeps(
%args,
authors_arent => \@authors,
);
},
);
lib/App/lcpan/Cmd/rdeps_scripts.pm view on Meta::CPAN
my @dists;
$res = App::lcpan::Cmd::mod2dist::handle_cmd(%args); # XXX subset
return [500, "Can't mod2dist: $res->[0] - $res->[1]"]
unless $res->[0] == 200;
if (ref $res->[2] eq 'HASH') {
push @dists, values %{ $res->[2] };
} else {
push @dists, $res->[2] if defined $res->[2];
}
return [404, "No dists found for the module(s) specified"] unless @dists;
$res = App::lcpan::rdeps(%args, flatten=>1);
return [500, "Can't mod2dist: $res->[0] - $res->[1]"]
unless $res->[0] == 200;
push @dists, $_->{dist} for @{ $res->[2] };
my @where;
push @where, "file.dist_name IN (".
join(",", map { $dbh->quote($_) } @dists).")";
push @where, "file.cpanid=".$dbh->quote($args{author})
lib/App/lcpan/Cmd/script2author.pm view on Meta::CPAN
while (my $row = $sth->fetchrow_hashref) {
unless ($args{all}) {
next if $mem{$row->{script}}++;
}
push @res, $row;
}
if (@$scripts == 1) {
@res = map { $_->{author} } @res;
if (!@res) {
return [404, "No such script"];
} elsif (@res == 1) {
return [200, "OK", $res[0]];
} else {
return [200, "OK", \@res];
}
}
[200, "OK", \@res, {'table.fields'=>[qw/script author/]}];
}
lib/App/lcpan/Cmd/script2dist.pm view on Meta::CPAN
while (my $row = $sth->fetchrow_hashref) {
unless ($args{all}) {
next if $mem{$row->{script}}++;
}
push @res, $row;
}
if (@$scripts == 1) {
@res = map { $_->{dist} } @res;
if (!@res) {
return [404, "No such script"];
} elsif (@res == 1) {
return [200, "OK", $res[0]];
} else {
return [200, "OK", \@res];
}
}
[200, "OK", \@res, {'table.fields'=>[qw/script dist/]}];
}
lib/App/lcpan/Cmd/script2mod.pm view on Meta::CPAN
while (my $row = $sth->fetchrow_hashref) {
unless ($args{all}) {
next if $mem{$row->{script}}++;
}
push @res, $row;
}
if (@$scripts == 1) {
@res = map { $_->{module} } @res;
if (!@res) {
return [404, "No such script"];
} elsif (@res == 1) {
return [200, "OK", $res[0]];
} else {
return [200, "OK", \@res];
}
}
[200, "OK", \@res, {'table.fields'=>[qw/script module/]}];
}
lib/App/lcpan/Cmd/script2rel.pm view on Meta::CPAN
$row->{release} = App::lcpan::_relpath(
$row->{release}, $row->{author});
}
delete $row->{author};
push @res, $row;
}
if (@$scripts == 1) {
@res = map { $_->{release} } @res;
if (!@res) {
return [404, "No such script"];
} elsif (@res == 1) {
return [200, "OK", $res[0]];
} else {
return [200, "OK", \@res];
}
}
[200, "OK", \@res, {'table.fields' => [qw/script release/]}];
}