skaji / mi6

minimal authoring tool for Raku
https://raku.land/zef:skaji/App::Mi6
Artistic License 2.0
54 stars 18 forks source link

Empty README.md after `mi6 build` #152

Closed lizmat closed 2 years ago

lizmat commented 2 years ago

I had an issue with re-generating the README.md for App::Rak: it would not complain about anything, but the resulting README.md only contained the header.

In the end, I could fix it by nuking the .precomp in the repo.

Before that, I could fix it by doing this patch on App::Mi6:

% git diff
diff --git a/lib/App/Mi6.rakumod b/lib/App/Mi6.rakumod
index 4c34d3c..ee640f2 100644
--- a/lib/App/Mi6.rakumod
+++ b/lib/App/Mi6.rakumod
@@ -6,6 +6,7 @@ use App::Mi6::Template;
 use App::Mi6::Util;
 use CPAN::Uploader::Tiny;
 use Shell::Command;
+use Pod::To::Markdown:ver<0.1.4+>;
 use TAP;

 BEGIN { $*RAKU.compiler.version >= v2020.11 or die "App::Mi6 needs rakudo v2020.11 or later" }
@@ -253,13 +254,8 @@ method regenerate-readme($module-file) {
     return if config($section, "enabled", :$default) eq "false" ;
     my $file = config($section, "filename", :$default) || $module-file;

-    my @cmd = $*EXECUTABLE, "-I$*CWD", "--doc=Markdown", $file;
-    my $p = mi6run |@cmd, :out;
-    LEAVE $p && $p.out.close;
-    die "Failed @cmd[]" if $p.exitcode != 0;
-    my $markdown = $p.out.slurp;
-    my $header = self.readme-header();
-    spurt "README.md", $header ~ $markdown;
+    spurt "README.md",
+      self.readme-header ~ (slurp($file) ~ ";\npod2markdown(\$=pod)").EVAL;
 }

Is there a reason not to use this short-cut in the future?

skaji commented 2 years ago

I don't think

spurt "README.md",
      self.readme-header ~ (slurp($file) ~ ";\npod2markdown(\$=pod)").EVAL;

should work always.

In fact, $=pod or pod2markdown may compile/execute $file, so we need to include . in the module search paths.

skaji commented 2 years ago

https://github.com/skaji/raku-Acme-Test-Module-Zef

Here are steps to reproduce:

❯ git clone https://github.com/skaji/raku-Acme-Test-Module-Zef
❯ cd raku-Acme-Test-Module-Zef
❯ raku  -MPod::To::Markdown -e '(slurp("lib/Acme/Test/Module/Zef.rakumod") ~ ";\npod2markdown(\$=pod)").EVAL;'
===SORRY!=== Error while compiling /Users/skaji/src/github.com/skaji/raku-Acme-Test-Module-Zef/EVAL_0
Could not find Acme::Test::Module::Zef2 in:
    /Users/skaji/.raku
    /Users/skaji/env/rakuenv/versions/2022.07-01/share/perl6/site
    /Users/skaji/env/rakuenv/versions/2022.07-01/share/perl6/vendor
    /Users/skaji/env/rakuenv/versions/2022.07-01/share/perl6/core
    CompUnit::Repository::AbsolutePath<5864533872936>
    CompUnit::Repository::NQP<5864511179384>
    CompUnit::Repository::Perl5<5864511179424>
at /Users/skaji/src/github.com/skaji/raku-Acme-Test-Module-Zef/EVAL_0:2
tbrowder commented 2 years ago

I was about to enter a new issue, but it may be related. When I was in a module base directory which was NOT one created by App::Mi6, I ran "mi6 test" without thinking and it created a blank README.md file as it overwrote the existing one.

Maybe mi6 should check for the existence of a 'dist.ini' before running any of its run commands (similar to its current bevavior in a subdirectory of a valid mi6-managed module).

I can submit a PR if you wish, or a new issue, or both.

skaji commented 2 years ago

@lizmat

In the end, I could fix it by nuking the .precomp in the repo.

Then I think it is an issue of rakudo itself, not of mi6.

@tbrowder dist.ini is optional.