Commit | Line | Data |
47b26c17 |
1 | #!/usr/bin/env perl |
2 | |
3 | use strict; |
4 | use warnings FATAL => 'all'; |
5 | use File::Path qw(mkpath); |
6 | |
7 | my $project = $ARGV[0] or die "No project name passed"; |
8 | |
9 | my @parts = split('-', $project); |
10 | |
11 | my $lib_file = join('/', 'lib', @parts).".pm"; |
12 | |
13 | my $author = $ENV{DISTAR_INIT_AUTHOR} or die "DISTAR_INIT_AUTHOR unset"; |
14 | |
15 | mkpath "${project}/maint"; |
16 | |
17 | mkpath join('/', $project, 'lib', @parts[0..$#parts-1]); |
18 | |
5fb57e52 |
19 | my $package_name = join('::', @parts); |
20 | |
47b26c17 |
21 | open my $mpl_main, '>', "${project}/Makefile.PL" |
22 | or die "couldn't open Makefile.PL: $!"; |
23 | |
5fb57e52 |
24 | print $mpl_main sprintf(<<'END', $package_name, $lib_file); |
47b26c17 |
25 | use strict; |
26 | use warnings FATAL => 'all'; |
27 | use ExtUtils::MakeMaker; |
28 | |
00588dde |
29 | (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; |
47b26c17 |
30 | |
31 | WriteMakefile( |
32 | NAME => '%s', |
33 | VERSION_FROM => '%s' |
34 | ); |
35 | END |
36 | |
37 | close($mpl_main); |
38 | |
39 | open my $mpl_maint, '>', "${project}/maint/Makefile.PL.include" |
40 | or die "couldn't open maint/Makefile.PL.include: $!"; |
41 | |
42 | print $mpl_maint sprintf(<<'END', $author); |
f12b221f |
43 | BEGIN { -e 'Distar' or system qw(git clone git://git.shadowcat.co.uk/p5sagit/Distar.git) } |
47b26c17 |
44 | use lib 'Distar/lib'; |
45 | use Distar; |
46 | |
47 | author '%s'; |
48 | END |
49 | |
50 | close($mpl_maint); |
51 | |
52 | open my $pm, '>', "${project}/${lib_file}" |
53 | or die "Couldn't open .pm file: $!"; |
54 | |
47b26c17 |
55 | my $year = 1900+(localtime)[5]; |
56 | |
57 | my $mod_text = sprintf(<<'END', $package_name, $package_name, $author, $year, $package_name); |
58 | package %s; |
59 | |
60 | our $VERSION = '0.000001'; # 0.0.1 |
61 | |
62 | $VERSION = eval $VERSION; |
63 | |
64 | 1; |
65 | |
66 | =head1 NAME |
67 | |
68 | %s - Description goes here |
69 | |
70 | =head1 SYNOPSIS |
71 | |
72 | =head1 DESCRIPTION |
73 | |
74 | =head1 AUTHOR |
75 | |
76 | %s |
77 | |
78 | =head1 CONTRIBUTORS |
79 | |
80 | None yet - maybe this software is perfect! (ahahahahahahahahaha) |
81 | |
82 | =head1 COPYRIGHT |
83 | |
84 | Copyright (c) %s the %s L</AUTHOR> and L</CONTRIBUTORS> |
85 | as listed above. |
a2c84d6c |
86 | |
47b26c17 |
87 | =head1 LICENSE |
a2c84d6c |
88 | |
47b26c17 |
89 | This library is free software and may be distributed under the same terms |
90 | as perl itself. |
91 | END |
92 | |
93 | $mod_text =~ s/^ //mg; |
94 | |
95 | print $pm $mod_text; |
96 | |
97 | close $mod_text; |
98 | |
99 | chdir($project); system("git init"); |