Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 58 lines (41 sloc) 1.18 KB
#!/usr/bin/perl -w
=head1 prepare-bower.pl
This is a script for preparing a snippet for adding to a Dhall file of Spacchetti package definitions.
See L<the Spachetti repository|https://github.com/justinwoo/spacchetti> for more details.
Usage:
prepare-bower.pl [package-name]
Example:
./prepare-bower.pl yargs
=> yargs = mkPackage
[
"console",
"either",
"exceptions",
"foreign",
"unsafe-coerce"
]
"https://github.com/paf31/purescript-yargs.git"
"4.0.0"
=cut
my $numArgs = $#ARGV;
if ($numArgs < 0) {
print "I need one arg for what the bower package name is without the preceding `purescript-`\n";
print "e.g. `prepare-bower.pl yargs`";
exit;
}
my $input = $ARGV[0];
my $json = $input . ".json";
unless(-e $json) {
print `bower info purescript-$input --json > $json`;
}
my $dependencies = `cat $json | jq '.latest.dependencies' | jq 'keys | map(.[11:])'`;
my $version = `cat $json | jq '.latest.version'`;
my $url = `cat $json | jq '.latest.repository.url'`;
my $from = 'git:';
my $to = "https:";
$url =~ s/$from/$to/;
my $output = <<END_TEMPLATE;
$input = mkPackage
$dependencies$url$version
END_TEMPLATE
print $output