Skip to content

Commit

Permalink
add [MetaJSON] to [@basic]
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge committed Dec 16, 2018
1 parent 6bbe36c commit 24eac4c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Revision history for {{$dist->name}}
release test (thanks, Karen Etheridge)
- all builds now result in a .build/latest symlink (thanks again,
Karen)
- [MetaJSON] is now in [@Basic], with special handling to handle the
possibility that the plugin is loaded twice

6.012 2018-04-21 10:20:21+02:00 Europe/Oslo
- revert addition of Archive::Tar::Wrapper as a mandatory prereq (in
Expand Down
8 changes: 8 additions & 0 deletions lib/Dist/Zilla/Plugin/MetaJSON.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use Moose::Util::TypeConstraints;

use Dist::Zilla::Dialect;

use List::Util 'first';
use namespace::autoclean;

=head1 DESCRIPTION
Expand Down Expand Up @@ -54,6 +55,13 @@ has version => (
sub gather_files ($self) {
my $zilla = $self->zilla;

# gracefully handle there being more than one of us (e.g. one via [@Basic])
if ((first { $_->isa(__PACKAGE__) } $self->zilla->plugins->@*) != $self) {
$self->log('doing nothing: another [MetaJSON] already ran');
$self->log('To remove this warning, remove [MetaJSON] from your dist.ini, **and** add ":version = 7.000" underneath [@Basic]');
return;
}

require JSON::MaybeXS;
require Dist::Zilla::File::FromCode;
require CPAN::Meta::Converter;
Expand Down
2 changes: 2 additions & 0 deletions lib/Dist/Zilla/PluginBundle/Basic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sub configure ($self) {
PruneCruft
ManifestSkip
MetaYAML
MetaJSON
License
Readme
ExtraTests
Expand Down Expand Up @@ -45,6 +46,7 @@ It includes the following plugins with their default configuration:
* L<Dist::Zilla::Plugin::PruneCruft>
* L<Dist::Zilla::Plugin::ManifestSkip>
* L<Dist::Zilla::Plugin::MetaYAML>
* L<Dist::Zilla::Plugin::MetaJSON>
* L<Dist::Zilla::Plugin::License>
* L<Dist::Zilla::Plugin::Readme>
* L<Dist::Zilla::Plugin::ExtraTests>
Expand Down
36 changes: 36 additions & 0 deletions t/plugins/metajson.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use strict;
use warnings;

use Test::More 0.88;
use Test::DZil;
use Test::Fatal;
use Path::Tiny;

{
my $tzil = Builder->from_config(
{ dist_root => 'does-not-exist' },
{
add_files => {
'source/dist.ini' => simple_ini(
'@Basic',
'MetaJSON',
),
},
},
);

$tzil->chrome->logger->set_debug(1);
is(
exception { $tzil->build },
undef,
'build proceeds normally',
);

my $build_dir = path($tzil->tempdir)->child('build');
ok(-e $build_dir->child('META.json'), 'META.json was created successfully');

diag 'got log messages: ', explain $tzil->log_messages
if not Test::Builder->new->is_passing;
}

done_testing;

0 comments on commit 24eac4c

Please sign in to comment.