From bdbfc92b4228d5f154b5f6527db3329d3bd5c9de Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Fri, 28 Apr 2023 11:28:02 +0200 Subject: [PATCH] wip for removing MI catalyst plugin, and replacing with autogenerating a dist.ini --- Makefile.PL | 1 - lib/Catalyst/Devel.pm | 4 +- lib/Catalyst/Helper.pm | 19 ++--- lib/Module/Install/Catalyst.pm | 134 --------------------------------- share/Makefile.PL.tt | 26 ------- share/dist.ini.tt | 30 ++++++++ t/generated_app.t | 2 +- 7 files changed, 41 insertions(+), 175 deletions(-) delete mode 100644 lib/Module/Install/Catalyst.pm delete mode 100644 share/Makefile.PL.tt create mode 100644 share/dist.ini.tt diff --git a/Makefile.PL b/Makefile.PL index 26d24c7..4065c82 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -32,7 +32,6 @@ my %META = ( 'File::Copy::Recursive' => 0, 'Path::Class' => '0.09', 'Template' => '2.14', - 'Module::Install' => '1.02', }, }, develop => { diff --git a/lib/Catalyst/Devel.pm b/lib/Catalyst/Devel.pm index 79b0765..2d05bb1 100644 --- a/lib/Catalyst/Devel.pm +++ b/lib/Catalyst/Devel.pm @@ -24,8 +24,8 @@ them. This is intended to make it easier to deploy Catalyst apps. The runtime parts of Catalyst are now known as C. C includes the L system, which -autogenerates scripts and tests; L, a -L extension for Catalyst; and requirements for a +autogenerates scripts, tests and a starter dist.ini for releasing; +and requirements for a variety of development-related modules. The documentation remains with L. diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index d8aeac9..d23ebd5 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -107,7 +107,7 @@ sub mk_app { || 'Catalyst developer'; my $gen_scripts = ( $self->{makefile} ) ? 0 : 1; - my $gen_makefile = ( $self->{scripts} ) ? 0 : 1; + my $gen_dist_ini = ( $self->{scripts} ) ? 0 : 1; my $gen_app = ( $self->{scripts} || $self->{makefile} ) ? 0 : 1; if ($gen_app) { @@ -117,8 +117,8 @@ sub mk_app { $self->$_; } } - if ($gen_makefile) { - $self->_mk_makefile; + if ($gen_dist_ini) { + $self->_mk_dist_ini; } if ($gen_scripts) { for ( qw/ _mk_cgi _mk_fastcgi _mk_server @@ -376,19 +376,16 @@ sub _mk_rootclass { file( $self->{c}, "Root.pm" ) ); } -sub _mk_makefile { +sub _mk_dist_ini { my $self = shift; $self->{path} = join('/', 'lib', split( '::', $self->{name} ) ); $self->{path} .= '.pm'; my $dir = $self->{dir}; - $self->render_sharedir_file( 'Makefile.PL.tt', file($dir, "Makefile.PL") ); + $self->render_sharedir_file( 'dist.ini.tt', file($dir, "dist.ini") ); - if ( $self->{makefile} ) { - - # deprecate the old Build.PL file when regenerating Makefile.PL - $self->_deprecate_file( - file( $self->{dir}, 'Build.PL' ) ); - } + # deprecate the old Makefile.PL and Build.PL file when regenerating dist.ini + $self->_deprecate_file( file( $self->{dir}, 'Makefile.PL' ) ); + $self->_deprecate_file( file( $self->{dir}, 'Build.PL' ) ); } sub _mk_psgi { diff --git a/lib/Module/Install/Catalyst.pm b/lib/Module/Install/Catalyst.pm deleted file mode 100644 index edc13b3..0000000 --- a/lib/Module/Install/Catalyst.pm +++ /dev/null @@ -1,134 +0,0 @@ -package Module::Install::Catalyst; - -use strict; - -use base qw/ Module::Install::Base /; -our @ISA; -require Module::Install::Base; - -use File::Find; -use FindBin; -use File::Copy::Recursive; -use File::Spec (); -use Getopt::Long (); -use Data::Dumper; - -my $SAFETY = 0; - -our @IGNORE = - qw/Build Build.PL Changes MANIFEST META.yml Makefile.PL Makefile README - _build blib lib script t inc .*\.svn \.git _darcs \.bzr \.hg - debian build-stamp install-stamp configure-stamp/; - -=head1 NAME - - Module::Install::Catalyst - Module::Install extension for Catalyst - -=head1 SYNOPSIS - - use lib '.'; - use inc::Module::Install; - - name 'MyApp'; - all_from 'lib/MyApp.pm'; - - requires 'Catalyst::Runtime' => '5.7014'; - - catalyst_ignore('.*temp'); - catalyst_ignore('.*tmp'); - catalyst; - WriteAll; - -=head1 DESCRIPTION - -L extension for Catalyst. - -=head1 METHODS - -=head2 catalyst - -Calls L. Should be the last catalyst* -command called in C. - -=cut - -sub catalyst { - my $self = shift; - - if($Module::Install::AUTHOR) { - $self->include("File::Copy::Recursive"); - } - - print <catalyst_files; - print < and L). - -=cut - -sub catalyst_files { - my $self = shift; - - chdir $FindBin::Bin; - - my @files; - opendir CATDIR, '.'; - CATFILES: for my $name ( readdir CATDIR ) { - for my $ignore (@IGNORE) { - next CATFILES if $name =~ /^$ignore$/; - next CATFILES if $name !~ /\w/; - } - push @files, $name; - } - closedir CATDIR; - my @path = split '-', $self->name; - for my $orig (@files) { - my $path = File::Spec->catdir( 'blib', 'lib', @path, $orig ); - File::Copy::Recursive::rcopy( $orig, $path ); - } -} - -=head2 catalyst_ignore_all(\@ignore) - -This function replaces the built-in default ignore list with the given list. - -=cut - -sub catalyst_ignore_all { - my ( $self, $ignore ) = @_; - @IGNORE = @$ignore; -} - -=head2 catalyst_ignore(@ignore) - -Add a regexp to the list of ignored patterns. Can be called multiple times. - -=cut - -sub catalyst_ignore { - my ( $self, @ignore ) = @_; - push @IGNORE, @ignore; -} - -=head1 AUTHORS - -Catalyst Contributors, see Catalyst.pm - -=head1 LICENSE - -This library is free software. You can redistribute it and/or modify it under -the same terms as Perl itself. - -=cut - -1; diff --git a/share/Makefile.PL.tt b/share/Makefile.PL.tt deleted file mode 100644 index 3b8b109..0000000 --- a/share/Makefile.PL.tt +++ /dev/null @@ -1,26 +0,0 @@ -[% startperl %] -# IMPORTANT: if you delete this file your app will not work as -# expected. You have been warned. -use lib '.'; -use inc::Module::Install 1.02; -use Module::Install::Catalyst; # Complain loudly if you don't have - # Catalyst::Devel installed or haven't said - # 'make dist' to create a standalone tarball. - -name '[% dir %]'; -all_from '[% path %]'; - -requires 'Catalyst::Runtime' => '[% catalyst_version %]'; -requires 'Catalyst::Plugin::ConfigLoader'; -requires 'Catalyst::Plugin::Static::Simple'; -requires 'Catalyst::Action::RenderView'; -requires 'Moose'; -requires 'namespace::autoclean'; -requires 'Config::General'; # This should reflect the config file format you've chosen - # See Catalyst::Plugin::ConfigLoader for supported formats -test_requires 'Test::More' => '0.88'; -catalyst; - -install_script glob('script/*.pl'); -auto_install; -WriteAll; diff --git a/share/dist.ini.tt b/share/dist.ini.tt new file mode 100644 index 0000000..2b72d7d --- /dev/null +++ b/share/dist.ini.tt @@ -0,0 +1,30 @@ +; TODO +; IMPORTANT: if you delete this file your app will not work as +; expected. You have been warned. + +name '[% dir %]'; +all_from '[% path %]'; + +name = [% dir %] +author = Your Name +copyright_holder = Your Name +copyright_year = [% (localtime())[5] %] +license = Perl_5 + +[@Git::Starter] + +[Prereqs] +Catalyst::Runtime = [% catalyst_version %] +Catalyst::Plugin::ConfigLoader = 0 +Catalyst::Plugin::Static::Simple = 0 +Catalyst::Action::RenderView = 0 +Moose = 0 +namespace::autoclean = 0 +Config::General = 0 ; This should reflect the config file format you've chosen + ; See Catalyst::Plugin::ConfigLoader for supported formats + +[Prereqs / TestRequires] +Test::More = 0.88 + +[ExecDir] +dir = script diff --git a/t/generated_app.t b/t/generated_app.t index 2b50377..6bf60f0 100644 --- a/t/generated_app.t +++ b/t/generated_app.t @@ -60,7 +60,7 @@ chdir($app_dir) or die "Cannot chdir to $app_dir: $!"; lib->import(catdir($dir, 'TestApp', 'lib')); my @files = qw| - Makefile.PL + dist.ini testapp.conf testapp.psgi lib/TestApp.pm