Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add "bundle" target that will create a tarball for uploading
It builds and tests the project in cwd to reveal its dependencies, tries to get its hands on the distribution name and description, and proposes a META.info file with this just collected information. Sadly the used prompt() segfaults on moar and besides that we need to autodiscover the types it is going to provide, similar to the dependency check.
- Loading branch information
Showing
5 changed files
with
121 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| class Panda::Bundler; | ||
| use Panda::Common; | ||
| use Panda::Project; | ||
|
|
||
| sub guess-project($where) { | ||
| my $name; | ||
| my $description; | ||
| my $source-url; | ||
|
|
||
| indir $where, { | ||
| if 'META.info'.IO.e { | ||
| try my $json = from-json 'META.info'.IO.slurp; | ||
| if $json { | ||
| $name = $json<name> if $json<name>; | ||
| $description = $json<description> if $json<description>; | ||
| $source-url = $json<source-url> if $json<source-url>; | ||
| } | ||
| } | ||
| unless $name { | ||
| $name = $where.parts<basename>.subst(/:i ^'p' 'erl'? '6-'/, '').split(/<[\-_]>+/, :g)>>.tc.join('::'); | ||
| } | ||
| unless $description { | ||
| $description = '.git/description'.IO.slurp if '.git/description'.IO.e | ||
| } | ||
| unless $source-url { | ||
| try my $git = qx{git remote show origin}.lines.first(/\.git$/); | ||
| if $git && $git ~~ /$<url>=\S+$/ { | ||
| $source-url = $<url>; | ||
| if $source-url ~~ m/'git@' $<host>=[.+] ':' $<repo>=[<-[:]>+] $/ { | ||
| $source-url = "git://$<host>/$<repo>" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| Panda::Project.new( :$name, :metainfo( :$description, :$source-url ) ) | ||
| } | ||
|
|
||
| method bundle($panda, :$notests) { | ||
| my $dir = cwd.absolute; | ||
| my $bone = guess-project($dir); | ||
|
|
||
| temp $*EXECUTABLE_NAME = "$*EXECUTABLE_NAME -MPanda::DepTracker"; | ||
| %*ENV<PANDA_DEPTRACKER_FILE> = "$dir/deptracker-$*PID"; | ||
|
|
||
| $panda.announce('building', $bone); | ||
| unless $_ = $panda.builder.build($dir) { | ||
| die X::Panda.new($bone.name, 'build', $_) | ||
| } | ||
| if %*ENV<PANDA_DEPTRACKER_FILE>.IO.e { | ||
| my $test = EVAL %*ENV<PANDA_DEPTRACKER_FILE>.IO.slurp; | ||
| for $test.list -> $m { | ||
| $bone.metainfo<build-depends>.push: $m<module_name> # XXX :auth/:ver/:from/... | ||
| } | ||
| %*ENV<PANDA_DEPTRACKER_FILE>.IO.spurt: '' | ||
| } | ||
|
|
||
| unless $notests { | ||
| temp $*EXECUTABLE_NAME = "\"$*EXECUTABLE_NAME -MPanda::DepTracker\""; | ||
| $panda.announce('testing', $bone); | ||
| unless $_ = $panda.tester.test($dir) { | ||
| die X::Panda.new($bone.name, 'test', $_) | ||
| } | ||
| if %*ENV<PANDA_DEPTRACKER_FILE>.IO.e { | ||
| my $test = EVAL %*ENV<PANDA_DEPTRACKER_FILE>.IO.slurp; | ||
| for $test.list -> $m { | ||
| $bone.metainfo<test-depends>.push: $m<module_name> # XXX :auth/:ver/:from/... | ||
| } | ||
| %*ENV<PANDA_DEPTRACKER_FILE>.IO.spurt: '' | ||
| } | ||
| } | ||
|
|
||
| $bone.metainfo<depends> = [($bone.metainfo<test-depends> (&) $bone.metainfo<build-depends>).list.flat]; | ||
|
|
||
| $bone.metainfo<version> = prompt "Please enter version number (example: v1.2.3): "; | ||
|
|
||
| $panda.announce('Creating META.info.proposed'); | ||
| 'META.info.proposed'.IO.spurt: to-json { | ||
| name => $bone.name, | ||
| description => $bone.metainfo<description>, | ||
| version => $bone.metainfo<version>, | ||
| build-depends => $bone.metainfo<build-depends>, | ||
| test-depends => $bone.metainfo<test-depends>, | ||
| depends => $bone.metainfo<depends>, | ||
| # XXX provides section | ||
| source-url => $bone.metainfo<source-url>, | ||
| }; | ||
|
|
||
| try unlink %*ENV<PANDA_DEPTRACKER_FILE> if %*ENV<PANDA_DEPTRACKER_FILE>.IO.e; | ||
|
|
||
| return True; | ||
| } | ||
|
|
||
| # vim: ft=perl6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| class DepTracker is CompUnitRepo { | ||
| method load_module($module_name, %opts, *@GLOBALish is rw, :$line, :$file) { | ||
| if %*ENV<PANDA_DEPTRACKER_FILE> && $module_name ne 'Panda::DepTracker' { | ||
| %*ENV<PANDA_DEPTRACKER_FILE>.IO.spurt: { :$module_name, :%opts }.perl ~ ",\n", :append; | ||
| } | ||
| nextsame; | ||
| } | ||
| } | ||
| nqp::bindhllsym('perl6', 'ModuleLoader', DepTracker); |