bin/yukki-setup

filter: Statementstmt 60.0% 3 / 5 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 71.4% 5 / 7 CC 1 SCAR 1.4
CC
1
Cov
60%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« bin/yukki-git-init ↑ Summary blib/lib/Yukki/Settings.pm »
1 #!/usr/bin/env perl
2 3 ▶use 5.12.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 0 ▶use Yukki::Web;
Subroutine BEGIN: called CC=1 SCAR=2.6
5  
6 use autodie;
7 use File::ShareDir qw( module_dir );
8 use File::Copy::Recursive qw( dircopy );
9 use Path::Class;
10 use YAML qw( LoadFile );
11  
12 my $site_dir = shift;
13  
14 die "usage: $0 path/to/new-site-directory\n" unless $site_dir;
15 die qq[A file or directory named "$site_dir" already exists, will not overwrite.\n]
16 if -e $site_dir;
17  
18 my $module_dir = module_dir('Yukki::Web');
19 my @files = glob "$module_dir/*";
20  
21 $File::Copy::Recursive::KeepMode = 0;
22 dircopy($module_dir, $site_dir);
23  
24 my $root = dir($site_dir)->absolute;
25 my $yaml = file($root, 'etc', 'yukki.conf');
26  
27 # Don't use YAML to load the file or we'll lose spaces and comments
28 rename $yaml, "$yaml~";
29 open my $out_config, '>', $yaml;
30 open my $in_config, '<', "$yaml~";
31 while (my $line = <$in_config>) {
32 given ($line) {
33 when (/^root:/) {
34 $line = "root: $root\n";
35 }
36 }
37 print $out_config $line;
38 }
39 close $out_config;
40 close $in_config;
41 unlink "$yaml~";
42  
43 chmod 0444, "$yaml";
44  
45 my $config = LoadFile("$yaml");
46  
47 say "Please read the installation instructions if you have not:\n";
48 say "\tperldoc Yukki::Manual::Installation\n";
49  
50 say "The rest of these remarks assume you run this first:\n";
51 say "\tcd $site_dir\n";
52  
53 say "You probably want to setup your repositories by running:\n";
54 for (sort keys %{ $config->{repositories} }) {
55 when ('yukki') { say "\tyukki-git-init $_ git://github.com/zostay/yukki-help.git" }
56 default { say "\tyukki-git-init $_" }
57 }
58 print "\n";
59  
60 say "And then you'll want at least one user, so run:\n";
61 say "\tyukki-add-user\n";
62  
63 say "To start your Yukki server, run:\n";
64 say "\tcd $site_dir; plackup yukki.psgi\n";
65  
66 say "Have a nice day!";
67  
68 # ABSTRACT: constructs the boilerplate needed to start a Yukki site
69 # PODNAME: yukki-setup
70  
71 __END__
« bin/yukki-git-init ↑ Summary blib/lib/Yukki/Settings.pm »