Skip to content

Instantly share code, notes, and snippets.

@ugexe
Last active June 7, 2019 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ugexe/e00ade523d152af5ca1497311d07e420 to your computer and use it in GitHub Desktop.
Save ugexe/e00ade523d152af5ca1497311d07e420 to your computer and use it in GitHub Desktop.
Generate a lookup table for **CURI** installed module metadata from their sha1 id
use nqp;
my $perl6-all-modules-repo-prefix = @*ARGS.head.IO || $*CWD;
my @dist-prefixes = $perl6-all-modules-repo-prefix.dir
.grep(*.d)
.map(*.dir.grep(*.d).Slip)
.map(*.dir.Slip);
my @dists = @dist-prefixes
.map({ try Distribution::Path.new($_) })
.grep(*.defined)
.map({ CompUnit::Repository::Distribution.new($_) });
my %sha1-lookup;
for @dists -> $dist {
for $dist.meta<provides>.keys -> $module {
my $module-id = nqp::sha1($module ~ $dist.id);
%sha1-lookup{$module-id} = %(
module-shortname => $module,
module-namepath => $dist.meta<provides>{$module},
dist-longname => $dist.Str,
dist-id => $dist.id,
all-modules-repo => $dist.prefix.relative($perl6-all-modules-repo-prefix),
);
}
}
say Rakudo::Internals::JSON.to-json(%sha1-lookup, :sorted-keys);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment