line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: set up a basic global config file |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Dist::Zilla::Pragmas; |
4
|
4
|
|
|
4
|
|
2520
|
|
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
use Dist::Zilla::App -command; |
6
|
4
|
|
|
4
|
|
53
|
|
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
39
|
|
7
|
|
|
|
|
|
|
use namespace::autoclean; |
8
|
4
|
|
|
4
|
|
1098
|
|
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
10
|
|
|
|
|
|
|
#pod |
11
|
|
|
|
|
|
|
#pod $ dzil setup |
12
|
|
|
|
|
|
|
#pod Enter your name> Ricardo Signes |
13
|
|
|
|
|
|
|
#pod ... |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod Dist::Zilla looks for per-user configuration in F<~/.dzil/config.ini>. This |
16
|
|
|
|
|
|
|
#pod command prompts the user for some basic information that can be used to produce |
17
|
|
|
|
|
|
|
#pod the most commonly needed F<config.ini> sections. |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod B<WARNING>: PAUSE account details are stored within config.ini in plain text. |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod =cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use autodie; |
24
|
4
|
|
|
4
|
|
1186
|
|
|
4
|
|
|
|
|
25600
|
|
|
4
|
|
|
|
|
27
|
|
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
|
"This command will run through a short interactive process to set up\n" . |
27
|
|
|
|
|
|
|
"a basic Dist::Zilla configuration in ~/.dzil/config.ini" |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
0
|
1
|
|
|
30
|
|
|
|
|
|
|
my ($self, $opt, $args) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$self->usage_error('too many arguments') if @$args != 0; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
0
|
1
|
|
|
35
|
|
|
|
|
|
|
my ($self, $opt, $arg) = @_; |
36
|
0
|
0
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $chrome = $self->app->chrome; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
require Dist::Zilla::Util; |
40
|
0
|
|
|
0
|
1
|
|
my $config_root = Dist::Zilla::Util->_global_config_root; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
if ( |
43
|
|
|
|
|
|
|
-d $config_root |
44
|
0
|
|
|
|
|
|
and |
45
|
0
|
|
|
|
|
|
my @files = grep { -f and $_->basename =~ /\Aconfig\.[^.]+\z/ } |
46
|
|
|
|
|
|
|
$config_root->children |
47
|
0
|
0
|
0
|
|
|
|
) { |
48
|
|
|
|
|
|
|
$chrome->logger->log_fatal([ |
49
|
|
|
|
|
|
|
"per-user configuration files already exist in %s: %s", |
50
|
0
|
0
|
|
|
|
|
"$config_root", |
51
|
|
|
|
|
|
|
join(q{, }, @files), |
52
|
|
|
|
|
|
|
]); |
53
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return unless $chrome->prompt_yn("Continue anyway?", { default => 0 }); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $realname = $chrome->prompt_str( |
58
|
|
|
|
|
|
|
"What's your name? ", |
59
|
0
|
0
|
|
|
|
|
{ check => sub { defined $_[0] and $_[0] =~ /\S/ } }, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $email = $chrome->prompt_str( |
63
|
|
|
|
|
|
|
"What's your email address? ", |
64
|
0
|
0
|
|
0
|
|
|
{ check => sub { defined $_[0] and $_[0] =~ /\A\S+\@\S+\z/ } }, |
65
|
0
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $c_holder = $chrome->prompt_str( |
68
|
|
|
|
|
|
|
"Who, by default, holds the copyright on your code? ", |
69
|
0
|
0
|
|
0
|
|
|
{ |
70
|
0
|
|
|
|
|
|
check => sub { defined $_[0] and $_[0] =~ /\S/ }, |
71
|
|
|
|
|
|
|
default => $realname, |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
0
|
|
|
my $license = $chrome->prompt_str( |
76
|
0
|
|
|
|
|
|
"What license will you use by default (Perl_5, BSD, etc.)? ", |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
default => 'Perl_5', |
79
|
|
|
|
|
|
|
check => sub { |
80
|
|
|
|
|
|
|
my $str = String::RewritePrefix->rewrite( |
81
|
|
|
|
|
|
|
{ '' => 'Software::License::', '=' => '' }, |
82
|
|
|
|
|
|
|
$_[0], |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
|
|
return Params::Util::_CLASS($str) && eval "require $str; 1"; |
86
|
|
|
|
|
|
|
}, |
87
|
|
|
|
|
|
|
}, |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
0
|
|
|
|
my %pause; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if ( |
93
|
0
|
|
|
|
|
|
$chrome->prompt_yn( |
94
|
|
|
|
|
|
|
' |
95
|
0
|
|
|
|
|
|
* WARNING - Your account details will be stored in plain text * |
96
|
|
|
|
|
|
|
Do you want to enter your PAUSE account details? ', |
97
|
0
|
0
|
|
|
|
|
{ default => 0 }, |
98
|
|
|
|
|
|
|
) |
99
|
|
|
|
|
|
|
) { |
100
|
|
|
|
|
|
|
my $default_pause; |
101
|
|
|
|
|
|
|
if ($email =~ /\A(.+?)\@cpan\.org\z/i) { |
102
|
|
|
|
|
|
|
$default_pause = uc $1; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$pause{username} = $chrome->prompt_str( |
106
|
0
|
0
|
|
|
|
|
"What is your PAUSE id? ", |
107
|
0
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
check => sub { defined $_[0] and $_[0] =~ /\A\w+\z/ }, |
109
|
|
|
|
|
|
|
default => $default_pause, |
110
|
|
|
|
|
|
|
}, |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
0
|
|
|
$pause{password} = $chrome->prompt_str( |
114
|
0
|
|
|
|
|
|
"What is your PAUSE password? ", |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
check => sub { length $_[0] }, |
117
|
|
|
|
|
|
|
noecho => 1, |
118
|
|
|
|
|
|
|
}, |
119
|
|
|
|
|
|
|
); |
120
|
|
|
|
|
|
|
} |
121
|
0
|
|
|
0
|
|
|
|
122
|
0
|
|
|
|
|
|
$config_root->mkpath unless -d $config_root; |
123
|
|
|
|
|
|
|
$config_root->child('profiles')->mkpath |
124
|
|
|
|
|
|
|
unless -d $config_root->child('profiles'); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my $umask = umask; |
127
|
0
|
0
|
|
|
|
|
umask( $umask | 077 ); # this file might contain PAUSE pw; make it go-r |
128
|
0
|
0
|
|
|
|
|
open my $fh, '>:encoding(UTF-8)', $config_root->child('config.ini'); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$fh->print("[%User]\n"); |
131
|
0
|
|
|
|
|
|
$fh->print("name = $realname\n"); |
132
|
0
|
|
|
|
|
|
$fh->print("email = $email\n\n"); |
133
|
0
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$fh->print("[%Rights]\n"); |
135
|
0
|
|
|
|
|
|
$fh->print("license_class = $license\n"); |
136
|
0
|
|
|
|
|
|
$fh->print("copyright_holder = $c_holder\n\n"); |
137
|
0
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
if (keys %pause) { |
139
|
0
|
|
|
|
|
|
$fh->print("[%PAUSE]\n"); |
140
|
0
|
|
|
|
|
|
$fh->print("username = $pause{username}\n"); |
141
|
0
|
|
|
|
|
|
if (length $pause{password}) { |
142
|
|
|
|
|
|
|
$fh->print("password = $pause{password}\n"); |
143
|
0
|
0
|
|
|
|
|
} |
144
|
0
|
|
|
|
|
|
$fh->print("\n"); |
145
|
0
|
|
|
|
|
|
} |
146
|
0
|
0
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
close $fh; |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
umask $umask; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
$self->log("config.ini file created!"); |
152
|
0
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
1; |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=pod |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=encoding UTF-8 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 NAME |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Dist::Zilla::App::Command::setup - set up a basic global config file |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 VERSION |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
version 6.028 |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SYNOPSIS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
$ dzil setup |
172
|
|
|
|
|
|
|
Enter your name> Ricardo Signes |
173
|
|
|
|
|
|
|
... |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Dist::Zilla looks for per-user configuration in F<~/.dzil/config.ini>. This |
176
|
|
|
|
|
|
|
command prompts the user for some basic information that can be used to produce |
177
|
|
|
|
|
|
|
the most commonly needed F<config.ini> sections. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
B<WARNING>: PAUSE account details are stored within config.ini in plain text. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 PERL VERSION |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
184
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
185
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
186
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
189
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
190
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
191
|
|
|
|
|
|
|
the minimum required perl. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 AUTHOR |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo SIGNES. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
202
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |