Skip to content

Commit

Permalink
Merge pull request #17 from massa/master
Browse files Browse the repository at this point in the history
  • Loading branch information
FCO authored Mar 1, 2024
2 parents fd070b8 + 94a70fd commit 6e7d1c9
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 36 deletions.
18 changes: 2 additions & 16 deletions META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,17 @@
},
"bin": {
"6pm": "bin/6pm"
},
"emulates": {

},
"perl": "v6.*",
"resources": {

},
"build-depends": [

],
"scripts": {
"test": "zef test ."
},
"excludes": {

},
"superseded-by": {

},
"depends": [
"zef",
"JSON::Class"
"JSON::Class:auth<zef:jonathanstowe>"
],
"tags": [
"PACKAGE",
Expand All @@ -52,10 +40,8 @@
},
"production": false,
"version": "0.0.11",
"supersedes": {
},
"authors": [
"Fernando Correa de Oliveira"
],
"description": "Perl6 module dependency manager (aka npm for Perl6)"
"description": "Raku module dependency manager (aka npm for Raku)"
}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![](https://github.com/FCO/6pm/workflows/linux/badge.svg)
# 🕕 - 6pm

6pm is a NPM for perl6
6pm is a NPM for raku

## Create META6.json

Expand All @@ -11,7 +11,7 @@ $ cd TestProject/
$ 6pm init
Project name [TestProject]:
Project tags:
perl6 version [6.*]:
raku version [6.*]:
```

## Locally install a Module
Expand All @@ -37,7 +37,7 @@ $ 6pm install Heap --save
## Run code using the local dependencies

```
$ 6pm exec -- perl6 -MHeap -e 'say Heap.new: <q w e r>'
$ 6pm exec -- raku -MHeap -e 'say Heap.new: <q w e r>'
Heap.new: [e r q w]
```

Expand All @@ -53,7 +53,7 @@ Heap.new: [e r q w]

```
$ echo "use SixPM; use Heap; say Heap.new: <q w e r>" > bla.p6
$ perl6 bla.p6
$ raku bla.p6
Heap.new: [e r q w]
```

Expand All @@ -72,7 +72,7 @@ $ cat META6.json
],
"scripts": {
"test": "zef test .",
"my-script": "perl6 -MHeap -e 'say Heap.new: ^10'"
"my-script": "raku -MHeap -e 'say Heap.new: ^10'"
},
"depends": [
Expand Down
6 changes: 3 additions & 3 deletions bin/6pm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env perl6
#!/usr/bin/env raku
use v6;
use App::six-pm::SixPM;
my $*MAIN-ALLOW-NAMED-ANYWHERE = True;

my $*DEBUG = so %*ENV<_6PM_DEBUG>;

my IO::Path $base-dir = ".".IO.resolve;
my IO::Path $default-to = $base-dir.child: "perl6-modules";
my IO::Path $default-to = $base-dir.child: "raku-modules";

my $six-pm = SixPM.new: :$base-dir, :$default-to;

Expand All @@ -31,7 +31,7 @@ multi MAIN("exec", +@argv) {
}

multi MAIN("exec-file", $file, +@argv) {
$six-pm.exec: ["perl6", $file, |@argv], :path($file.IO);
$six-pm.exec: ["raku", $file, |@argv], :path($file.IO);
}

multi MAIN("run", Str() $script) {
Expand Down
2 changes: 1 addition & 1 deletion lib/App/six-pm/Meta6.pm6
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use JSON::Class;
use JSON::Class:auth<zef:jonathanstowe>;

unit class App::six-pm::Meta6 does JSON::Class;

Expand Down
12 changes: 6 additions & 6 deletions lib/App/six-pm/SixPM.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SixPM {

method get-project-name { prompt "Project name [{$!meta.name}]: " }
method get-project-tags { prompt("Project tags (separated by space): ") }
method get-perl6-version { prompt "perl6 version [{$!meta.perl}]: " }
method get-raku-version { prompt "raku version [{$!meta.perl}]: " }

method init(:$name, :@tags, :$perl-version) {
unless $!meta {
Expand All @@ -27,7 +27,7 @@ class SixPM {
with $perl-version -> $perl {
$!meta.perl = $perl
} else {
if $.get-perl6-version -> $perl {
if $.get-raku-version -> $perl {
$!meta.perl = $perl
}
}
Expand All @@ -41,7 +41,7 @@ class SixPM {
}

method install-deps(Bool :f(:$force)) {
%*ENV<PERL6LIB> = "inst#{$!default-to.absolute}";
%*ENV<RAKULIB> = "inst#{$!default-to.absolute}";
%*ENV<PATH> ~= ":{$!default-to.absolute}/bin";
if
$!meta and
Expand All @@ -58,7 +58,7 @@ class SixPM {
}

method install(+@modules, Bool :f(:$force), Bool :$save, Bool :$save-test, Bool :$save-build) {
%*ENV<PERL6LIB> = "inst#{$!default-to.absolute}";
%*ENV<RAKULIB> = "inst#{$!default-to.absolute}";
%*ENV<PATH> ~= ":{$!default-to.absolute}/bin";
if $.installer.install(|@modules, :to($!default-to.absolute), :$force) {
if $save {
Expand All @@ -78,13 +78,13 @@ class SixPM {
} else {
$!default-to.absolute
}
%*ENV<PERL6LIB> = "inst#{$inst}";
%*ENV<RAKULIB> = "inst#{$inst}";
%*ENV<PATH> ~= ":{$inst}/bin";
run |@argv
}

method run(Str() $script) {
%*ENV<PERL6LIB> = "inst#{$!default-to.absolute}";
%*ENV<RAKULIB> = "inst#{$!default-to.absolute}";
%*ENV<PATH> ~= ":{$!default-to.absolute}/bin";
shell $_ with $!meta.scripts{$script}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/SixPM.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ no precompilation;
sub find-sixpm-path($cwd is copy = $*PROGRAM.resolve.parent) {
repeat {
last if $++ > 10;
my $p6m = $cwd.child("perl6-modules");
my $p6m = $cwd.child("raku-modules");
return $p6m.resolve if $p6m.d;
$cwd .= parent
} while $cwd.resolve.absolute !~~ "/";
"./perl6-modules".IO
"./raku-modules".IO
}

sub EXPORT($find-path?) {
Expand All @@ -16,7 +16,7 @@ sub EXPORT($find-path?) {
use MONKEY-SEE-NO-EVAL;
EVAL "use lib 'inst#{$path.absolute}'";
} else {
die "'perl6-modules' not found";
die "'raku-modules' not found";
}
}

Expand Down
2 changes: 1 addition & 1 deletion t/00-test-meta.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!perl6
#!raku

use v6;
use lib 'lib';
Expand Down
2 changes: 1 addition & 1 deletion t/01-six-pm.t
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sub name is rw { state $a }
$_6pm does role :: {
has $.get-project-name is rw = "my_test";
has $.get-project-tags is rw = "bla ble bli";
has $.get-perl6-version is rw = "v6.*";
has $.get-raku-version is rw = "v6.*";
};

$_6pm.init;
Expand Down

0 comments on commit 6e7d1c9

Please sign in to comment.