unit class Blin::Tester::Pakku;

has $.path;
has $.binary;
has $.output-failed;
has @.sources;


submethod TWEAK ( ) {

    note â€˜ðŸ¥ž Installing Pakku â€™;
    my $pakku-src  = â€˜data/pakku-srcâ€™.IO;

    if $pakku-src.d {
        run :cwd($pakku-src), <git pull>
    } else {
        run <git clone https://github.com/hythm7/Pakku.git>, $pakku-src
    }

    #| Where to install pakku
    my $pakku-path = â€˜data/pakkuâ€™.IO;

    run "$pakku-src/tools/install-pakku.raku", "--dest=$pakku-path"; 

    # using recman meta source here
    # can be replaced with zef sources
    @!sources       = <http://recman.pakku.org/meta/42>;

    $!path = $pakku-path;

    $!binary = $!path.add: 'bin/pakku';

    $!output-failed = 'ðŸ’€';

}

method test-command( ::?CLASS:D: :$testable!, :$install-path!, :$module-name! ) {
    $!binary,
    "verbose info",
    "yolo",
    "add",
    "force",
    ( $testable ?? "test" !! "notest" ),
    "nodeps",
    "to $install-path",
    $module-name,
}

