Permalink
Browse files

Add `zef depends $idenetity` command

  • Loading branch information...
ugexe committed Sep 14, 2017
1 parent 01661a5 commit 9a1b7ee4d14374984e0624a577a98fcd31ed16f1
Showing with 58 additions and 7 deletions.
  1. +1 −0 .appveyor.yml
  2. +4 −3 .travis.yml
  3. +1 −1 META6.json
  4. +9 −0 README.pod
  5. +41 −1 lib/Zef/CLI.pm6
  6. +2 −2 lib/Zef/Client.pm6
@@ -51,6 +51,7 @@ test_script:
- zef --debug test ./zef
- zef --debug search Base64
- zef --debug rdepends Base64
- zef --debug depends Cro::SSL
- zef --debug fetch Base64
# test installing from what `fetch` put in ::LocalCache
- zef --debug --/cpan --/p6c install Base64
@@ -6,12 +6,12 @@ os:

env:
- BACKEND=moar
- BACKEND=moar-2017.05
- BACKEND=moar-2017.06
- BACKEND=jvm

matrix:
allow_failures:
- env: BACKEND=moar-2017.05
- env: BACKEND=moar-2017.06
- env: BACKEND=jvm
fast_finish: true

@@ -21,7 +21,7 @@ before_install:
- git clone https://github.com/rakudo/rakudo.git $HOME/rakudo
- cd $HOME/rakudo
- 'if [[ $BACKEND == "moar" ]]; then export OPTS="--gen-moar --gen-nqp --backends=moar"; fi'
- 'if [[ $BACKEND == "moar-2017.05" ]]; then export OPTS="--gen-moar --gen-nqp --backends=moar"; git checkout "2017.05"; fi'
- 'if [[ $BACKEND == "moar-2017.06" ]]; then export OPTS="--gen-moar --gen-nqp --backends=moar"; git checkout "2017.05"; fi'
- 'if [[ $BACKEND == "jvm" ]]; then export OPTS="--gen-nqp --backends=jvm"; fi'
- perl Configure.pl $OPTS
- make install
@@ -69,6 +69,7 @@ script:
- zef --debug test ./zef
- zef --debug search Base64
- zef --debug rdepends Base64
- zef --debug depends Cro::SSL
- zef --debug fetch Base64
# test installing from what `fetch` put in ::LocalCache
- zef --debug --/cpan --/p6c install Base64
@@ -1,7 +1,7 @@
{
"perl" : "6",
"name" : "zef",
"version" : "0.1.27",
"version" : "0.1.28",
"auth" : "github:ugexe",
"description" : "It's like [cpanm] wearing high heels with a tracksuit",
"license" : "Artistic-2.0",
@@ -254,6 +254,15 @@ B<Options>
# Additionally list the modules of discovered distributions
-v

=head4 B<depends> [$identity]

List direct and transitive dependencies to the first successful build graph for C<$identity>

$ zef depends Cro::SSL
Cro::Core:ver('0.7')
IO::Socket::Async::SSL:ver('0.3')
OpenSSL:ver('0.1.14'):auth('github:sergot')

=head4 B<rdepends> [$identity]

List available distributions that directly depend on C<$identity>
@@ -260,7 +260,46 @@ package Zef::CLI {
exit +@upgraded < +@upgradable ?? 1 !! 0;
}

#| View reverse dependencies of a distribution
#| View dependencies of a distribution
multi MAIN(
'depends',
$identity,
Bool :$depends = True,
Bool :$test-depends = True,
Bool :$build-depends = True,
) {
# TODO: refactor this stuff which was copied from 'install'
# So really we just need a function to handle separating the different identity types
# and optionally delivering a message for each section.
my @wants = ($identity,).map: *.&str2identity;
my (:@paths, :@uris, :@identities) := @wants.classify: -> $wanted {
$wanted ~~ /^[\. | \/]/ ?? <paths>
!! ?Zef::Identity($wanted) ?? <identities>
!! (my $uri = Zef::Utils::URI($wanted) and !$uri.is-relative) ?? <uris>
!! abort("Don't understand identity: {$wanted}");
}
my $client = Zef::Client.new(:config($CONFIG), :$depends, :$test-depends, :$build-depends,);

abort "The following were recognized as file paths but don't exist as such - {@paths.grep(!*.IO.e)}"
if +@paths.grep(!*.IO.e);
my @path-candidates = @paths.map(*.&path2candidate);

my @uri-candidates-to-check = $client.fetch( |@uris.map({ Candidate.new(:as($_), :uri($_)) }) ) if +@uris;
abort "No candidates found matching uri: {@uri-candidates-to-check.join(', ')}" if +@uris && +@uri-candidates-to-check == 0;
my @uri-candidates = @uri-candidates-to-check.grep: { $_ ~~ none(@path-candidates.map(*.dist.identity)) }

my @requested-identities = @identities.grep: { $_ ~~ none(@uri-candidates.map(*.dist.identity)) }
my @requested = |$client.find-candidates(@requested-identities) if +@requested-identities;
abort "No candidates found matching identity: {@requested-identities.join(', ')}"\
if +@requested-identities && +@requested == 0;

my @prereqs = |$client.find-prereq-candidates(:!skip-installed, |@path-candidates, |@uri-candidates, |@requested)\
if +@path-candidates || +@uri-candidates || +@requested;

.say for @prereqs.map(*.dist.identity);
}

#| View direct reverse dependencies of a distribution
multi MAIN(
'rdepends',
$identity,
@@ -578,6 +617,7 @@ package Zef::CLI {
info Show detailed distribution information
browse Open browser to various support urls (homepage, bugtracker, source)
list List known available distributions, or installed distributions with `--installed`
depends List all direct and transitive dependencies for a given identity
rdepends List all distributions directly depending on a given identity
locate Lookup installed module information by short-name, name-path, or sha1 (with --sha1 flag)
smoke Run smoke testing on available modules
@@ -109,7 +109,7 @@ class Zef::Client {
.unique(:as(*.dist.identity));
}

method find-prereq-candidates(Bool :$upgrade, *@candis ($, *@)) {
method find-prereq-candidates(Bool :$skip-installed = True, Bool :$upgrade, *@candis ($, *@)) {
my @skip = @candis.map(*.dist);

my $prereqs := gather {
@@ -126,7 +126,7 @@ class Zef::Client {

next unless my @needed = @specs-batch\ # The current set of specs
.grep({ not @skip.first(*.contains-spec($_)) })\ # Dists in @skip are not needed
.grep({ not self.is-installed($_) }); # Installed dists are not needed
.grep({ $skip-installed ?? self.is-installed($_).not !! True });
my @identities = @needed.map(*.identity);
self.logger.emit({
level => INFO,

0 comments on commit 9a1b7ee

Please sign in to comment.