Skip to content

Commit

Permalink
Merge pull request #10 from tbrowder/new-ver
Browse files Browse the repository at this point in the history
New ver
  • Loading branch information
tbrowder authored Oct 25, 2023
2 parents 15e8b09 + a332c54 commit 47ad636
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 28 deletions.
6 changes: 5 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Revision history for Mi6-Helper

{{$NEXT}}
- Fix dist.ini to show correct windows workflows file.
- Major improvements:
+ Fix dist.ini to show correct windows workflows file.
+ Eliminate spurious .github/workflows/test.yml file.
+ Add dependency File::Find
+ Solved problem of incomplete commits

0.11.0 2023-10-23T14:14:48-05:00
- Corrected handling of .github/workflow files by
Expand Down
1 change: 1 addition & 0 deletions META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"JSON::Fast",
"App::Mi6:ver<3.0.2+>",
"Text::Utils",
"File::Find",
"Proc::Easier"
],
"description": "An aid for converting Raku modules to use App::Mi6",
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ SYNOPSIS

* User choice of the 'provides' text

* `README.md` file source removed from the base module and placed in a new `docs/README.rakudoc file`
* `README.md` file source removed from the base module and placed in a new `docs/README.rakudoc` file

* Uses three separate OS tests in `.github/workflows` and shows results of each in the `README.md` file

Special installation requirements
---------------------------------
Expand Down Expand Up @@ -156,6 +158,8 @@ The very useful Raku modules used herein:

* `Proc::Easier` by **zef:sdondley**

* `File::Find` by **zef:raku-community-modules**

COPYRIGHT AND LICENSE
=====================

Expand Down
15 changes: 10 additions & 5 deletions bin/mi6-helper
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if not @*ARGS.elems {
to produce 'README.md'. Note extra preparation is REQUIRED
by the user before using it.
debug - For developer use
debug2 - For developer use
HERE

Expand All @@ -59,9 +60,10 @@ if not @*ARGS.elems {
my $old = 0;
my $new = 0;
# options
my $force = 0;
my $debug = 0;
my $docs = 0;
my $force = 0;
my $debug = 0;
my $debug2 = 0;
my $docs = 0;
my $provides;
my $provides-hidden = 1;

Expand All @@ -87,6 +89,9 @@ for @*ARGS {
$parent-dir = ~$0;
}
when / ^do[cs]? / { ++$docs }
when / ^de[bug]2? / {
++$debug2;
}
when / ^de[bug]? / {
++$debug;
# check for this module's workflows file(s'
Expand All @@ -100,7 +105,7 @@ for @*ARGS {
say " did NOT find '$path'";
}
}
exit;
#exit;
}
when /^v[ersion]? / {
# check for this module's version
Expand Down Expand Up @@ -165,7 +170,7 @@ die "FATAL: Path '$parent-dir' is not a directory."
say "Using directory '$parent-dir' as the working directory.";

if $new {
mi6-helper-new :$parent-dir, :$module-name, :$provides, :$debug;
mi6-helper-new :$parent-dir, :$module-name, :$provides, :$debug, :$debug2;
say qq:to/HERE/;
Exit after 'new' mode run. See new module repo '$module-name'
in parent dir '$parent-dir'.
Expand Down
5 changes: 4 additions & 1 deletion docs/README.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ management by C<App::Mi6> with modifications including:

=item Published in the B<Zef> Raku module ecosystem
=item User choice of the 'provides' text
=item C<README.md> file source removed from the base module and placed in a new C<docs/README.rakudoc file>
=item C<README.md> file source removed from the base module and placed in a new C<docs/README.rakudoc> file
=item Uses three separate OS tests in C<.github/workflows> and shows results of each in the C<README.md> file

=head2 Special installation requirements

Expand Down Expand Up @@ -83,6 +84,7 @@ files:
=end item

=head2 Modified files for mode B<new>

=head3 Files with replaced, modified, or added lines:

=begin code
Expand Down Expand Up @@ -171,6 +173,7 @@ The very useful Raku modules used herein:
=item C<File::Directory::Tree> by B<github:labster>
=item C<File::Temp> by B<zef:rbt>
=item C<Proc::Easier> by B<zef:sdondley>
=item C<File::Find> by B<zef:raku-community-modules>

=head1 COPYRIGHT AND LICENSE

Expand Down
69 changes: 51 additions & 18 deletions lib/Mi6/Helper.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,37 @@ unit class Mi6::Helper;
use App::Mi6;
use JSON::Fast;
use Proc::Easier;
use File::Find;

has $.parent-dir = '.';
has $.module-name; #= e.g., 'Foo::Bar'
has $.provides; #= text to replace 'blah blah blah'
has $.mode; #= "old" or "new"
has $.module-base; #= e.g., 'Foo-Bar'
has $.module-name; #= as known to Zef, e.g., 'Foo::Bar::Baz'
has $.module-base; #= as known to git, e.g., 'Foo-Bar-Baz'
# libs are determined by the '::' separators in the module name
has @.libdirs is rw; #= 'lib/Foo/Bar/Baz.rakumod'
#= 'lib
#= 'lib/Foo
#= 'lib/Foo/Bar
has $.libfile is rw; #= 'lib/Foo/Bar/Baz.rakumod;

=begin comment
e.g., Foo-Baz::Bar
=end comment

has $.provides is rw; #= text to replace 'blah blah blah'
has $.mode is rw; #= "old" or "new"

submethod TWEAK {
return if not $!module-name.defined;
$!module-base = $!module-name;
$!module-base ~~ s:g/'::'/-/;
}

method mi6-new-cmd(:$parent-dir!, :$module-name!, :$debug) {
method mi6-new-cmd(:$parent-dir!, :$module-name!, :$debug, :$debug2) {
chdir $parent-dir;
cmd "mi6 new --zef $module-name";
self.libdirs = find :dir(self.module-base), :type<dir>;
my $dir = "$!module-base/lib";
self.libfile = find :$dir, :type<file>;
}

method git-status {
Expand Down Expand Up @@ -61,28 +76,27 @@ sub get-hidden-name(:$module-name) is export {
$s ~ '.' ~ $s;
}

sub mi6-helper-old(:$parent-dir!, :$module-name!, :$provides, :$debug) is export {
sub mi6-helper-old(:$parent-dir!, :$module-name!, :$provides, :$debug, :$debug2) is export {
}

sub get-file-content($fnam --> Str) is export {
#$?DISTRIBUTION.content("resources/$fnam").open.slurp;
%?RESOURCES{$fnam}.slurp;
}

sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug) is export {
sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug, :$debug2) is export {

# test module is "Foo::Bar"
# method mi6-cmd(:$parent-dir, :$module-name) {
my $o = Mi6::Helper.new: :$module-name;
$o.mi6-new-cmd(:$parent-dir, :$module-name, :$debug);
$o.mi6-new-cmd(:$parent-dir, :$module-name, :$debug, :$debug2);

# get the name of the module file to change and move content
my $modpdir = $module-name;
my $modpath = $module-name;
$modpdir ~~ s:g/'::'/-/;
$modpath ~~ s:g/'::'/\//;
my $mpath = "$modpdir/lib/$modpath";
say "DEBUG: Foo::Bar path: '$mpath'" if $debug;
#say "DEBUG: Foo::Bar path: '$mpath'" if $debug;

$mpath ~= '.rakumod';

Expand Down Expand Up @@ -164,6 +178,8 @@ sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug) is export
my $Mstr = get-file-content($Mf);
my $Wstr = get-file-content($Wf);

#note "DEBUG: \$Lstr = $Lstr";

my $Lfil = "$modpdir/.github/workflows/$Lf";
my $Mfil = "$modpdir/.github/workflows/$Mf";
my $Wfil = "$modpdir/.github/workflows/$Wf";
Expand Down Expand Up @@ -288,16 +304,33 @@ sub mi6-helper-new(:$parent-dir!, :$module-name!, :$provides, :$debug) is export

if is-git-repo $modpdir {
# need to change dirs
note "$modpdir IS a git repo" if $debug;
temp $*CWD = $modpdir.IO;
cmd "git add '.github/workflows/linux.yml'";
cmd "git add '.github/workflows/windows.yml'";
cmd "git add '.github/workflows/macos.yml'";
cmd "git add docs/README.rakudoc";
my $d = $modpdir.IO.absolute;
#note "'$d' IS a git repo" if 1; #$debug;
#temp $*CWD = $modpdir.IO;
#autodie(:on);
chdir $modpdir;
cmd("git add .github/workflows/linux.yml");
cmd("git add .github/workflows/macos.yml");
cmd("git add .github/workflows/windows.yml");
cmd("git rm -f .github/workflows/test.yml");
cmd("git add docs/README.rakudoc");

# finish the repo to be ready for pushing
cmd "mi6 build";
cmd "git commit -a -m'initial commit'";
cmd("mi6 build");

cmd("git add META6.json");
cmd("git add README.md");
cmd("git add dist.ini");
cmd("git add lib/*");

cmd("git add t/*");
cmd("git add docs/*");

#note cmd('git commit -m"initial commit" ').err; # this fails
run("git", "commit", "-a", "-m'initial'");
}
else {
die "FATAL: Directory '$modpdir' is NOT a git repo!";
}

} # sub mi6-helper-new
Expand Down
7 changes: 5 additions & 2 deletions xt/3-helper-new.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use Ask;
use Mi6::Helper;
use File::Temp;
use App::Mi6;
use JSON::Fast;
use File::Directory::Tree;
use Proc::Easier;

Expand Down Expand Up @@ -53,14 +54,15 @@ ok $tempdir.IO.d;
cmd "touch '.Foo-Bar'";

my $module-name = 'Foo::Bar';
my $parent-dir = $tempdir;
my $parent-dir = "."; #$tempdir;
my $provides = "Provides a framistan";

if $debug {
note "DEBUG: module-name: $module-name";
note "DEBUG: parent-dir: $parent-dir";
}

=begin comment
mi6-helper-new(:$parent-dir, :$module-name, :$provides, :$debug);
my $moddir = $module-name;
$moddir ~~ s:g/'::'/-/;
Expand All @@ -69,7 +71,8 @@ ok $tempdir.IO.d;
# check the meta file for known values
my %meta = App::Mi6::JSON.decode(slurp "$moddir/META6.json");
is %meta<auth>, $auth, "is auth $auth?";
is @(%meta<authors>)[0], $author, "is author 1 $author?";
#is @(%meta<authors>)[0], $author, "is author 1 $author?";
=end comment
}

done-testing;

0 comments on commit 47ad636

Please sign in to comment.