line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::MetaJSON 6.030; |
2
|
|
|
|
|
|
|
# ABSTRACT: produce a META.json |
3
|
|
|
|
|
|
|
|
4
|
8
|
|
|
8
|
|
7296
|
use Moose; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
111
|
|
5
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileGatherer'; |
6
|
8
|
|
|
8
|
|
58464
|
use Moose::Util::TypeConstraints; |
|
8
|
|
|
|
|
26
|
|
|
8
|
|
|
|
|
97
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
18229
|
use Dist::Zilla::Pragmas; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
75
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
69
|
use namespace::autoclean; |
|
8
|
|
|
|
|
24
|
|
|
8
|
|
|
|
|
77
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod This plugin will add a F<META.json> file to the distribution. |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod This file is meant to replace the old-style F<META.yml>. For more information |
17
|
|
|
|
|
|
|
#pod on this file, see L<Module::Build::API> and L<CPAN::Meta>. |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod =attr filename |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod If given, parameter allows you to specify an alternate name for the generated |
22
|
|
|
|
|
|
|
#pod file. It defaults, of course, to F<META.json>. |
23
|
|
|
|
|
|
|
#pod |
24
|
|
|
|
|
|
|
#pod =cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has filename => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => 'Str', |
29
|
|
|
|
|
|
|
default => 'META.json', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#pod =attr version |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod This parameter lets you pick what version of the spec to use when generating |
35
|
|
|
|
|
|
|
#pod the output. It defaults to 2 at present, but may be updated to new specs as |
36
|
|
|
|
|
|
|
#pod they are released and adopted. |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod If you want a fixed version, specify it. |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod =cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $version_type = subtype( |
43
|
|
|
|
|
|
|
as 'Num', |
44
|
|
|
|
|
|
|
where { $_ >= 2 }, |
45
|
|
|
|
|
|
|
message { "MetaJSON version must be 2 or greater" }, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has version => ( |
49
|
|
|
|
|
|
|
is => 'ro', |
50
|
|
|
|
|
|
|
isa => $version_type, |
51
|
|
|
|
|
|
|
default => '2', |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub gather_files { |
55
|
9
|
|
|
9
|
0
|
34
|
my ($self, $arg) = @_; |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
290
|
my $zilla = $self->zilla; |
58
|
|
|
|
|
|
|
|
59
|
9
|
|
|
|
|
67
|
require JSON::MaybeXS; |
60
|
9
|
|
|
|
|
1697
|
require Dist::Zilla::File::FromCode; |
61
|
9
|
|
|
|
|
2546
|
require CPAN::Meta::Converter; |
62
|
9
|
|
|
|
|
54713
|
CPAN::Meta::Converter->VERSION(2.101550); # improved downconversion |
63
|
9
|
|
|
|
|
455
|
require CPAN::Meta::Validator; |
64
|
9
|
|
|
|
|
118
|
CPAN::Meta::Validator->VERSION(2.101550); # improved downconversion |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $file = Dist::Zilla::File::FromCode->new({ |
67
|
|
|
|
|
|
|
name => $self->filename, |
68
|
|
|
|
|
|
|
encoding => 'ascii', |
69
|
|
|
|
|
|
|
code_return_type => 'text', |
70
|
|
|
|
|
|
|
code => sub { |
71
|
9
|
|
|
9
|
|
315
|
my $distmeta = $zilla->distmeta; |
72
|
|
|
|
|
|
|
|
73
|
9
|
|
|
|
|
104
|
my $validator = CPAN::Meta::Validator->new($distmeta); |
74
|
|
|
|
|
|
|
|
75
|
9
|
50
|
|
|
|
245
|
unless ($validator->is_valid) { |
76
|
0
|
|
|
|
|
0
|
my $msg = "Invalid META structure. Errors found:\n"; |
77
|
0
|
|
|
|
|
0
|
$msg .= join( "\n", $validator->errors ); |
78
|
0
|
|
|
|
|
0
|
$self->log_fatal($msg); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
9
|
|
|
|
|
5506
|
my $converter = CPAN::Meta::Converter->new($distmeta); |
82
|
9
|
|
|
|
|
755
|
my $output = $converter->convert(version => $self->version); |
83
|
|
|
|
|
|
|
|
84
|
9
|
|
|
|
|
17338
|
my $backend = JSON::MaybeXS::JSON(); |
85
|
9
|
|
|
|
|
282
|
$output->{x_serialization_backend} = sprintf '%s version %s', |
86
|
|
|
|
|
|
|
$backend, $backend->VERSION; |
87
|
|
|
|
|
|
|
|
88
|
9
|
|
|
|
|
123
|
JSON::MaybeXS->new(canonical => 1, pretty => 1, ascii => 1)->encode($output) |
89
|
|
|
|
|
|
|
. "\n"; |
90
|
|
|
|
|
|
|
}, |
91
|
9
|
|
|
|
|
398
|
}); |
92
|
|
|
|
|
|
|
|
93
|
9
|
|
|
|
|
89
|
$self->add_file($file); |
94
|
9
|
|
|
|
|
48
|
return; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
101
|
|
|
|
|
|
|
#pod |
102
|
|
|
|
|
|
|
#pod Core Dist::Zilla plugins: |
103
|
|
|
|
|
|
|
#pod L<@Basic|Dist::Zilla::PluginBundle::Basic>, |
104
|
|
|
|
|
|
|
#pod L<Manifest|Dist::Zilla::Plugin::Manifest>. |
105
|
|
|
|
|
|
|
#pod |
106
|
|
|
|
|
|
|
#pod Dist::Zilla roles: |
107
|
|
|
|
|
|
|
#pod L<FileGatherer|Dist::Zilla::Role::FileGatherer>. |
108
|
|
|
|
|
|
|
#pod |
109
|
|
|
|
|
|
|
#pod Other modules: |
110
|
|
|
|
|
|
|
#pod L<CPAN::Meta>, |
111
|
|
|
|
|
|
|
#pod L<CPAN::Meta::Spec>, L<JSON::MaybeXS>. |
112
|
|
|
|
|
|
|
#pod |
113
|
|
|
|
|
|
|
#pod =cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=pod |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=encoding UTF-8 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 NAME |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Dist::Zilla::Plugin::MetaJSON - produce a META.json |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 VERSION |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
version 6.030 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 DESCRIPTION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This plugin will add a F<META.json> file to the distribution. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This file is meant to replace the old-style F<META.yml>. For more information |
134
|
|
|
|
|
|
|
on this file, see L<Module::Build::API> and L<CPAN::Meta>. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 PERL VERSION |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
139
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
140
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
141
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
144
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
145
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
146
|
|
|
|
|
|
|
the minimum required perl. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 filename |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
If given, parameter allows you to specify an alternate name for the generated |
153
|
|
|
|
|
|
|
file. It defaults, of course, to F<META.json>. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 version |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This parameter lets you pick what version of the spec to use when generating |
158
|
|
|
|
|
|
|
the output. It defaults to 2 at present, but may be updated to new specs as |
159
|
|
|
|
|
|
|
they are released and adopted. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
If you want a fixed version, specify it. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 SEE ALSO |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Core Dist::Zilla plugins: |
166
|
|
|
|
|
|
|
L<@Basic|Dist::Zilla::PluginBundle::Basic>, |
167
|
|
|
|
|
|
|
L<Manifest|Dist::Zilla::Plugin::Manifest>. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Dist::Zilla roles: |
170
|
|
|
|
|
|
|
L<FileGatherer|Dist::Zilla::Role::FileGatherer>. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Other modules: |
173
|
|
|
|
|
|
|
L<CPAN::Meta>, |
174
|
|
|
|
|
|
|
L<CPAN::Meta::Spec>, L<JSON::MaybeXS>. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 AUTHOR |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Ricardo SIGNES. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
185
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |