Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

drop uninstall command

  • Loading branch information...
commit 76204ccce01dab0ad307d67beeda9bf3357bbfde 1 parent d9c90ee
@miyagawa miyagawa authored
View
58 lib/Carton/CLI.pm
@@ -187,64 +187,6 @@ sub cmd_install {
$self->printf("Complete! Modules were installed into %s\n", $self->carton->{path}, SUCCESS);
}
-sub cmd_uninstall {
- my($self, @args) = @_;
-
- $self->parse_options(\@args, "p|path=s", sub { $self->carton->{path} = $_[1] });
-
- my $lock = $self->find_lock
- or $self->error("Can't find carton.lock: Run `carton install`");
-
- my $index = $self->carton->build_index($lock->{modules});
-
- my @meta;
- for my $module (@args) {
- if (exists $index->{$module}) {
- push @meta, $index->{$module}{meta};
- } else {
- $self->print("Can't locate module $module\n", WARN);
- }
- }
-
- my %root;
- if ($self->has_cpanfile) {
- for my $dep ($self->carton->list_dependencies) {
- my($mod, $ver) = split /~/, $dep;
- if (exists $index->{$mod}) {
- $root{ $index->{$mod}{meta}{name} } = 1;
- }
- }
- }
-
- # only can uninstall root dependencies
- my $tree = $self->carton->build_tree($lock->{modules}, \%root);
- for my $root ($tree->children) {
- if (grep $_->{name} eq $root->key, @meta) {
- $tree->remove_child($root);
- }
- }
-
- my @missing = grep !$tree->find_child($_), keys %{$lock->{modules}};
- for my $module (@missing) {
- my $meta = $lock->{modules}{$module};
- $self->print("Uninstalling $meta->{dist}\n");
- $self->carton->uninstall($lock, $module);
- }
-
- for my $meta (@meta) {
- unless (grep $meta->{name} eq $_, @missing) {
- $self->print("$meta->{name} is dependent by some other modules. Can't uninstall it.\n", WARN);
- }
- }
-
- $self->carton->update_lock_file($self->lock_file);
-
- if (@missing) {
- $self->printf("Complete! Modules and its dependencies were uninstalled from %s\n",
- $self->carton->{path}, SUCCESS);
- }
-}
-
sub mirror_file {
my $self = shift;
return $self->work_file("02packages.details.txt");
View
25 lib/Carton/Doc/Uninstall.pod
@@ -1,25 +0,0 @@
-=head1 NAME
-
-Carton::Doc::Uninstall - uninstall modules from your local environment
-
-=head1 SYNOPSIS
-
- carton uninstall Module
-
-=head1 DESCRIPTION
-
-This command allows you to uninstall modules and its dependencies from
-your local environment.
-
-You're only allowed to uninstall modules that are not dependent by
-other modules. So if you have a dependency tree like:
-
- Dancer-2.1
- URI-1.5
- HTTP-Body-1.3
- LWP-1.2
- URI-1.4
-
-you can uninstall either I<HTTP::Body> or I<Dancer>, but when you
-uninstall I<Dancer>, because I<URI> is referenced by I<LWP>, it will
-uninstall only I<Dancer>.
View
20 xt/cli/uninstall.t
@@ -1,20 +0,0 @@
-use strict;
-use Test::More;
-use xt::CLI;
-
-{
- my $app = cli();
-
- $app->run("install", "Try::Tiny");
- $app->run("list");
- like $app->output, qr/Try-Tiny-/;
-
- $app->run("uninstall", "Try::Tiny");
- like $app->output, qr/Uninstalling Try-Tiny-/;
-
- $app->run("list");
- like $app->output, qr/^\s*$/s;
-}
-
-done_testing;
-
View
59 xt/cli/uninstall_dep.t
@@ -1,59 +0,0 @@
-use strict;
-use Test::More;
-use xt::CLI;
-use Cwd;
-
-{
- my $app = cli();
-
- $app->dir->touch("Makefile.PL", <<EOF);
-use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => 'foo',
- VERSION => '0.1',
- PREREQ_PM => {
- CGI => 3.50,
- FCGI => 0.72,
- },
-);
-EOF
-
- $app->run("install");
- $app->run("uninstall", "CGI");
-
- like $app->output, qr/Uninstalling CGI/;
- unlike $app->output, qr/Uninstalling FCGI/;
-
- $app->run("list");
- unlike $app->output, qr/^CGI-/m;
- like $app->output, qr/FCGI-/;
-
- $app->run("uninstall", "FCGI");
- like $app->output, qr/Uninstalling FCGI/;
-}
-
-{
- my $app = cli();
-
- $app->dir->touch("Makefile.PL", <<EOF);
-use ExtUtils::MakeMaker;
-WriteMakefile(
- NAME => 'foo',
- VERSION => '0.1',
- PREREQ_PM => {
- 'JSON::PP' => 0,
- 'CPAN::Meta' => 0,
- },
-);
-EOF
-
- $app->run("install");
- $app->run("uninstall", "JSON::PP");
-
- like $app->output, qr/JSON::PP is dependent by/;
-}
-
-done_testing;
-
-
-
Please sign in to comment.
Something went wrong with that request. Please try again.