Permalink
Browse files

convert to Dist::Zilla

  • Loading branch information...
1 parent 99619c8 commit da2b4621d15f0c6295693ff69e47677dd620e393 @haarg haarg committed Sep 1, 2010
View
@@ -12,3 +12,4 @@
/pm_to_blib
/wgd
/pod2htm*.tmp
+/.build
View
@@ -1,54 +0,0 @@
-use lib 'inc';
-use WGDev::Builder;
-my $build = WGDev::Builder->new(
- module_name => 'WGDev',
- license => 'perl',
- dynamic_config => 0,
- create_license => 1,
- create_makefile_pl => 'traditional',
- sign => 1,
- meta_merge => {
- resources => {
- bugtracker => 'http://github.com/haarg/wgdev/issues',
- repository => 'http://github.com/haarg/wgdev/tree',
- WebGUI => 'http://www.webgui.org/',
- },
- },
- requires => {
- 'perl' => '5.8.8',
- 'App::Prove' => 0,
- 'Config::JSON' => 0,
- 'Cwd' => 0,
- 'DBI' => 0,
- 'File::Copy' => 0,
- 'File::Find' => 0,
- 'File::Path' => 0,
- 'File::Spec' => 0,
- 'File::Temp' => 0.19,
- 'Getopt::Long' => 0,
- 'JSON' => '2.00',
- 'Pod::Html' => 0,
- 'Pod::Perldoc' => 0,
- 'Pod::Usage' => 0,
- 'Text::ParseWords' => 0,
- 'version' => 0,
- 'Exception::Class' => 0,
- 'Try::Tiny' => 0,
- },
-
- build_requires => {
- # for tests only
- 'Scope::Guard' => 0,
- 'Test::Builder::Module' => 0,
- 'Test::Exception' => 0,
- 'Test::MockObject::Extends' => 0,
- 'Test::MockObject' => 0,
- 'Test::More' => 0,
- 'Test::NoWarnings' => 0,
- 'Test::Warn' => 0,
- },
-
- recommends => { 'Term::ANSIColor' => 0, },
-);
-$build->create_build_script;
-
View
@@ -1,5 +1,7 @@
Change log for WGDev
+{{$NEXT}}
+
0.8.0 - Sep 01 2010
- self-upgrade no longer needs a WebGUI root
- Fix edit command for WebGUI 8
View
@@ -54,7 +54,7 @@
# Avoid archives of this distribution
\bWGDev-v?[\d\.\_]+
\bwgd-v?[\d\.\_]+
-\bwgd$
+^wgd$
# Don't include upgrade command in dist
^lib/WebGUI/Command/Self/Upgrade\.pm$
View
@@ -0,0 +1,66 @@
+name = WGDev
+version = 0.008
+author = Graham Knop <haarg@haarg.org>
+license = Perl_5
+copyright_holder = Graham Knop
+
+[GatherDir]
+[PruneCruft]
+[ManifestSkip]
+[MetaYAML]
+[License]
+[PkgVersion]
+[PodVersion]
+[PodCoverageTests]
+[PodSyntaxTests]
+[ExtraTests]
+[MakeMaker]
+[Manifest]
+[ExecDir]
+
+[Prereq]
+perl = 5.8.8
+App::Prove = 0
+Config::JSON = 0
+Cwd = 0
+DBI = 0
+File::Copy = 0
+File::Find = 0
+File::Path = 0
+File::Spec = 0
+File::Temp = 0.19
+Getopt::Long = 0
+JSON = 2.00
+Pod::Html = 0
+Pod::Perldoc = 0
+Pod::Usage = 0
+Text::ParseWords = 0
+version = 0
+Exception::Class = 0
+
+[Prereq / TestRequires]
+Scope::Guard = 0
+Test::Builder::Module = 0
+Test::Exception = 0
+Test::MockObject::Extends = 0
+Test::MockObject = 0
+Test::More = 0
+Test::NoWarnings = 0
+Test::Warn = 0
+
+[Prereq / RuntimeRecommends]
+Term::ANSIColor = 0
+
+[MetaResources]
+bugtracker.web = http://github.com/haarg/wgdev/issues
+repository.url = git://github.com/haarg/wgdev.git
+repository.web = http://github.com/haarg/wgdev
+repository.type = git
+
+[NextRelease]
+format = %-9v %{MMM dd yyyy}d
+
+[PruneFiles]
+filenames = dist.ini
+
+[=inc::Dist::Zilla::Plugin::WGDev]
@@ -0,0 +1,189 @@
+package Dist::Zilla::Plugin::WGDev;
+use Moose;
+use namespace::autoclean;
+with 'Dist::Zilla::Role::BeforeArchive';
+with 'Dist::Zilla::Role::FileMunger';
+use Path::Class::Dir ();
+use Path::Class::File ();
+use File::Temp ();
+use File::Copy::Recursive qw(dircopy);
+use File::Spec::Functions qw(catdir);
+use Cwd qw(cwd);
+
+sub munge_file {
+ my $self = shift;
+ my $file = shift;
+ if ( $file->content !~ /\n$/ ) {
+ $file->content($file->content . "\n");
+ }
+}
+
+sub before_archive {
+ my $self = shift;
+ my $build_root = $self->zilla->ensure_built;
+
+ my $pack_temp = File::Temp->newdir;
+ my $pack_root = Path::Class::Dir->new($pack_temp->dirname);
+
+ dircopy(
+ $build_root->subdir('lib')->stringify,
+ $pack_root->subdir('lib')->stringify,
+ );
+
+ $self->regenerate_fatlib($pack_root);
+
+ my $dist_script = $self->zilla->root->file('wgd');
+ $dist_script->remove;
+ my $out_fh = $dist_script->openw;
+
+ print { $out_fh } <<'END_HEADER';
+#!/usr/bin/env perl
+
+END_HEADER
+
+ my $cwd = cwd;
+ chdir $pack_root;
+
+ open my $fh, '-|', 'fatpack', 'file'
+ or die "Can't run fatpack: $!";
+ while ( my $line = <$fh> ) {
+ # hack so we can extract the list later
+ $line =~ s/\bmy %fatpacked\b/our %fatpacked/;
+ print { $out_fh } $line;
+ }
+ close $fh;
+ chdir $cwd;
+ $fh = $build_root->file('bin', 'wgd')->openr;
+ while ( my $line = <$fh> ) {
+ print { $out_fh } $line;
+ }
+ close $fh;
+ close $out_fh;
+ chmod oct(755), $dist_script;
+}
+
+my %wg_deps = map { $_ => 1 } qw(
+ Apache2::Request
+ Archive::Tar
+ Archive::Zip
+ Class::InsideOut
+ Color::Calc
+ Compress::Zlib
+ Config::JSON
+ DBD::mysql
+ DBI
+ Data::Structure::Util
+ DateTime
+ DateTime::Format::Mail
+ DateTime::Format::Strptime
+ Digest::MD5
+ Finance::Quote
+ HTML::Highlight
+ HTML::Parser
+ HTML::TagCloud
+ HTML::TagFilter
+ HTML::Template
+ HTML::Template::Expr
+ HTTP::Headers
+ HTTP::Request
+ IO::Zlib
+ Image::Magick
+ JSON
+ LWP
+ List::Util
+ Locale::US
+ Log::Log4perl
+ MIME::Tools
+ Net::LDAP
+ Net::POP3
+ Net::SMTP
+ Net::Subnets
+ POE
+ POE::Component::Client::HTTP
+ POE::Component::IKC::Server
+ POSIX
+ Parse::PlainConfig
+ Pod::Coverage
+ SOAP::Lite
+ Test::Deep
+ Test::MockObject
+ Test::More
+ Text::Aspell
+ Text::Balanced
+ Text::CSV_XS
+ Tie::CPHash
+ Tie::IxHash
+ Time::HiRes
+ URI::Escape
+ Weather::Com::Finder
+ XML::RSSLite
+ XML::Simple
+);
+
+sub regenerate_fatlib {
+ my $self = shift;
+ my $pack_root = shift;
+
+ $pack_root->subdir('fatlib')->rmtree;
+ my $temp_script = File::Temp->new(UNLINK => 0);
+ my @deps = $self->zilla->prereqs->requirements_for('runtime', 'requires')->required_modules;
+ for my $module ( @deps ) {
+ if ($module eq 'perl') {
+ }
+ elsif ( $wg_deps{$module} ) {
+ }
+ else {
+ print {$temp_script} "use $module ();\n";
+ }
+ }
+ $temp_script->flush;
+ my (undef, $trace_file) = do { local $^W; File::Temp::tempfile(OPEN => 0) };
+ open my $oldout, '>&', \*STDOUT;
+ open my $olderr, '>&', \*STDERR;
+ open STDOUT, '>', File::Spec->devnull;
+ open STDERR, '>', File::Spec->devnull;
+ system 'fatpack', 'trace', '--to=' . $trace_file, $temp_script;
+ open STDOUT, '>&=', $oldout;
+ open STDERR, '>&=', $olderr;
+ open my $trace_fh, '<', $trace_file;
+ my @modules = <$trace_fh>;
+ close $trace_fh;
+ unlink $trace_file;
+ chomp @modules;
+ @modules = grep { /\.pm$/ } @modules;
+ open my $pack_fh, '-|', 'fatpack', 'packlists-for', @modules;
+ my @packlists = <$pack_fh>;
+ chomp @packlists;
+ my $cwd = cwd;
+ chdir $pack_root;
+ system 'fatpack', 'tree', @packlists;
+ chdir $cwd;
+ require Config;
+ $pack_root->subdir('fatlib', $Config::Config{archname})->rmtree;
+ $pack_root->subdir('fatlib')->recurse( callback => sub {
+ my $item = shift;
+ if (! $item->is_dir) {
+ if ( $item =~ /\.pm$/ ) {
+ my $fh = $item->open('+<');
+ seek $fh, -1, 2;
+ read $fh, my $last_char, 1;
+ if ($last_char !~ /\n/) {
+ print {$fh} "\n";
+ }
+ close $fh;
+ }
+ else {
+ $item->remove;
+ }
+ }
+ });
+}
+
+__PACKAGE__->meta->make_immutable;
+package inc::Dist::Zilla::Plugin::WGDev;
+use Moose;
+extends 'Dist::Zilla::Plugin::WGDev';
+__PACKAGE__->meta->make_immutable;
+
+1;
+
View
@@ -1,10 +1,9 @@
package WGDev;
+# ABSTRACT: WebGUI Developer Utilities
use strict;
use warnings;
use 5.008008;
-our $VERSION = '0.8.0';
-
use File::Spec ();
use Cwd ();
use WGDev::X ();
View
@@ -3,8 +3,6 @@ use strict;
use warnings;
use 5.008008;
-our $VERSION = '0.0.1';
-
use constant LINE_LENGTH => 78;
use WGDev;
View
@@ -3,8 +3,6 @@ use strict;
use warnings;
use 5.008008;
-our $VERSION = '0.8.0';
-
use Getopt::Long ();
use File::Spec ();
use Cwd ();
@@ -3,8 +3,6 @@ use strict;
use warnings;
use 5.008008;
-our $VERSION = '0.8.0';
-
use WGDev::X ();
sub is_runnable {
@@ -3,8 +3,6 @@ use strict;
use warnings;
use 5.008008;
-our $VERSION = '0.2.0';
-
use WGDev::Command::Base;
BEGIN { our @ISA = qw(WGDev::Command::Base) }
@@ -3,8 +3,6 @@ use strict;
use warnings;
use 5.008008;
-our $VERSION = '0.2.0';
-
use WGDev::Command::Base::Verbosity;
BEGIN { our @ISA = qw(WGDev::Command::Base::Verbosity) }
@@ -3,8 +3,6 @@ use strict;
use warnings;
use 5.008008;
-our $VERSION = '0.0.1';
-
use WGDev::Command::Base;
BEGIN { our @ISA = qw(WGDev::Command::Base) }
Oops, something went wrong.

0 comments on commit da2b462

Please sign in to comment.