Skip to content

Commit 6dd3a8d

Browse files
committed
Merge branch 'cli/scaffold-tutorial-and-other-apps'
2 parents 2aaf3f7 + 46b9acd commit 6dd3a8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+908
-35
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
[ ENHANCEMENTS ]
77
* GH #530: Make data censoring configurable (Yanick Champoux, David
88
Precious)
9+
* GH #850: Scaffold tutorial app; allow multiple apps to be scaffolded
10+
in core Dancer2 (Jason A. Crome)
911
* GH #1512: Log hook entries as they are executed (Yanick Champoux)
1012
* GH #1615: Remove Dancer2::Template::Simple from Dancer2 core (Jason
1113
A. Crome)

lib/Dancer2/CLI/Gen.pm

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ option skel => (
7979
},
8080
);
8181

82+
option skel_name => (
83+
is => 'ro',
84+
short => 'n',
85+
doc => 'skeleton name',
86+
format => 's',
87+
format_doc => 'skelname',
88+
required => 0,
89+
default => 'default',
90+
);
91+
8292
option docker => (
8393
is => 'ro',
8494
short => 'c',
@@ -154,7 +164,7 @@ sub run {
154164
$app_path = path( $self->app_path, $dir );
155165
}
156166

157-
my $files_to_copy = $self->_build_file_list( $self->skel, $app_path );
167+
my $files_to_copy = $self->_build_file_list( $self->skel . '/' . $self->skel_name, $app_path );
158168
foreach my $pair( @$files_to_copy ) {
159169
if( $pair->[0] =~ m/lib\/AppFile.pm$/ ) {
160170
$pair->[1] = path( $app_path, $app_file );
@@ -258,10 +268,12 @@ sub _how_to_run {
258268

259269
my $app_path = $vars->{ apppath };
260270
my $app_name = $vars->{ appname };
271+
272+
print "\nYour new application is ready! To run it:\n";
273+
261274
if( $vars->{ docker } ) {
262275
my $image = lc $app_name;
263276
print qq{
264-
Your new application is ready! To run it:
265277
266278
cd $app_path
267279
docker build -t ${image} .
@@ -274,18 +286,20 @@ runs on inside of the container.
274286
275287
You may also run your app without Docker:
276288
};
277-
} else {
278-
print "\nYour new application is ready! To run it:\n";
279289
}
290+
291+
my $install_deps = '';
292+
$install_deps = "\n cpanm --installdeps ."
293+
if $self->skel_name ne 'default';
294+
280295
print qq{
281-
cd $app_path
296+
cd $app_path$install_deps
282297
plackup bin/app.psgi
283298
284-
To access your application, point your browser to http://localhost:5000
299+
To access your application, point your browser to http://localhost:5000/
285300
286301
If you need community assistance, the following resources are available:
287302
- Dancer website: https://perldancer.org
288-
- Twitter: https://twitter.com/PerlDancer/
289303
- GitHub: https://github.com/PerlDancer/Dancer2/
290304
- Mailing list: https://lists.perldancer.org/mailman/listinfo/dancer-users
291305
- IRC: irc.perl.org#dancer
@@ -315,6 +329,7 @@ sub _build_file_list {
315329

316330
sub _copy_templates {
317331
my ( $self, $files, $vars, $overwrite ) = @_;
332+
my $app_name = $vars->{ appname };
318333

319334
foreach my $pair (@$files) {
320335
my ( $from, $to ) = @{$pair};
@@ -328,6 +343,7 @@ sub _copy_templates {
328343
next unless ( $res eq 'y' ) or ( $res eq 'a' );
329344
}
330345

346+
$to =~ s/AppFile/$app_name/;
331347
my $to_dir = path( $to )->parent;
332348
if ( ! $to_dir->is_dir ) {
333349
print "+ $to_dir\n";
@@ -349,7 +365,7 @@ sub _copy_templates {
349365
close $fh;
350366
}
351367

352-
if( $from !~ m/\.(ico|jpg|png|css|eot|map|swp|ttf|svg|woff|woff2|js)$/ ) {
368+
if( $from !~ m/\.(db|ico|jpg|png|css|eot|map|swp|ttf|svg|woff|woff2|js)$/ ) {
353369
$content = $self->_process_template($content, $vars);
354370
}
355371

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

share/skel/config.yml renamed to share/skel/default/config.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ charset: "UTF-8"
2424
# "engines:" block will take effect.
2525

2626
# template engine
27-
# simple: default and very basic template engine
27+
# tiny: default basic template engine
2828
# template_toolkit: TT
2929

30-
template: "simple"
30+
template: "tiny"
31+
engines:
32+
template:
33+
tiny:
34+
# Note: start_tag and end_tag are regexes
35+
start_tag: '<%'
36+
end_tag: '%>'
3137

3238
# template: "template_toolkit"
3339
# engines:
File renamed without changes.

0 commit comments

Comments
 (0)