1 package Catalyst::Helper::AppGen;
4 use namespace::autoclean;
5 use Moose::Util::TypeConstraints;
6 use MooseX::Types -declare [qw/ ValidAppName ValidAppComponent Dir AppEnv/];
7 use namespace::autoclean;
9 extends { 'Catalyst::Helper' };
11 my $appname_re = qr/[\w:]+/;
12 my $regex = qr/$appname_re::(M|V|C|Model|View|Controller)::.*/;
16 where { /^$appname_re$/ && ! /$regex/ };
18 subtype ValidAppComponent,
31 from ValidAppComponent,
32 via { Catalyst::Utils::class2appclass($_); },
36 via { Catalyst::Utils::class2env($_) };
41 traits => [qw(Getopt)],
48 traits => [qw(Getopt)],
56 traits => [qw(NoGetopt)],
62 traits => [qw(NoGetopt)],
68 traits => [qw(NoGetopt)],
74 my ( $self, $name ) = @_;
76 # Needs to be here for PAR
79 if ( $name =~ /[^\w:]/ || $name =~ /^\d/ || $name =~ /\b:\b|:{3,}/) {
80 warn "Error: Invalid application name.\n";
83 $self->{name } = $name;
84 $self->{dir } = $name;
85 $self->{dir } =~ s/\:\:/-/g;
86 $self->{script } = File::Spec->catdir( $self->{dir}, 'script' );
87 $self->{appprefix } = Catalyst::Utils::appprefix($name);
88 $self->{appenv } = Catalyst::Utils::class2env($name);
89 $self->{startperl } = -r '/usr/bin/env'
90 ? '#!/usr/bin/env perl'
91 : "#!$Config{perlpath} -w";
92 $self->{scriptgen } = $Catalyst::Devel::CATALYST_SCRIPT_GEN || 4;
93 $self->{catalyst_version} = $Catalyst::VERSION;
94 $self->{author } = $self->{author} = $ENV{'AUTHOR'}
95 || eval { @{ [ getpwuid($<) ] }[6] }
96 || 'Catalyst developer';
98 my $gen_scripts = ( $self->{makefile} ) ? 0 : 1;
99 my $gen_makefile = ( $self->{scripts} ) ? 0 : 1;
100 my $gen_app = ( $self->{scripts} || $self->{makefile} ) ? 0 : 1;
102 # these die, horribly, today.
107 $self->_mk_rootclass;
127 $self->_mk_information;