| 1 | package Dist::Zilla::PluginBundle::ATOOMIC; | ||
| 2 | |||
| 3 | use v5.10; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use autodie; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | our $VERSION = '1.00'; | ||
| 11 | |||
| 12 | use Devel::PPPort 3.42; | ||
| 13 | use Dist::Zilla 6.0; | ||
| 14 | use Path::Iterator::Rule; | ||
| 15 | |||
| 16 | # For the benefit of AutoPrereqs | ||
| 17 | use Dist::Zilla::Plugin::Authority; | ||
| 18 | use Dist::Zilla::Plugin::AutoPrereqs; | ||
| 19 | use Dist::Zilla::Plugin::BumpVersionAfterRelease; | ||
| 20 | use Dist::Zilla::Plugin::CPANFile; | ||
| 21 | use Dist::Zilla::Plugin::CheckPrereqsIndexed; | ||
| 22 | use Dist::Zilla::Plugin::CheckSelfDependency; | ||
| 23 | use Dist::Zilla::Plugin::CheckStrictVersion; | ||
| 24 | use Dist::Zilla::Plugin::CheckVersionIncrement; | ||
| 25 | use Dist::Zilla::Plugin::CopyFilesFromBuild; | ||
| 26 | use Dist::Zilla::Plugin::ATOOMIC::Contributors; | ||
| 27 | use Dist::Zilla::Plugin::ATOOMIC::License; | ||
| 28 | use Dist::Zilla::Plugin::ATOOMIC::MakeMaker; | ||
| 29 | use Dist::Zilla::Plugin::ATOOMIC::RunExtraTests; | ||
| 30 | use Dist::Zilla::Plugin::ATOOMIC::TidyAll; | ||
| 31 | use Dist::Zilla::Plugin::ATOOMIC::WeaverConfig; | ||
| 32 | use Dist::Zilla::Plugin::EnsureChangesHasContent 0.02; | ||
| 33 | use Dist::Zilla::Plugin::GenerateFile::FromShareDir 0.013; | ||
| 34 | use Dist::Zilla::Plugin::Git::Check; | ||
| 35 | use Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts; | ||
| 36 | use Dist::Zilla::Plugin::Git::Commit; | ||
| 37 | use Dist::Zilla::Plugin::Git::Contributors; | ||
| 38 | use Dist::Zilla::Plugin::Git::GatherDir; | ||
| 39 | use Dist::Zilla::Plugin::Git::Push; | ||
| 40 | use Dist::Zilla::Plugin::Git::Tag; | ||
| 41 | use Dist::Zilla::Plugin::GitHub::Meta 0.45; | ||
| 42 | use Dist::Zilla::Plugin::GitHub::Update 0.45; | ||
| 43 | use Dist::Zilla::Plugin::InstallGuide; | ||
| 44 | use Dist::Zilla::Plugin::Meta::Contributors; | ||
| 45 | use Dist::Zilla::Plugin::MetaConfig; | ||
| 46 | use Dist::Zilla::Plugin::MetaJSON; | ||
| 47 | use Dist::Zilla::Plugin::MetaProvides::Package; | ||
| 48 | use Dist::Zilla::Plugin::MetaResources; | ||
| 49 | use Dist::Zilla::Plugin::MojibakeTests; | ||
| 50 | use Dist::Zilla::Plugin::NextRelease; | ||
| 51 | use Dist::Zilla::Plugin::PPPort; | ||
| 52 | use Dist::Zilla::Plugin::PodSyntaxTests; | ||
| 53 | use Dist::Zilla::Plugin::PromptIfStale 0.050; | ||
| 54 | use Dist::Zilla::Plugin::ReadmeAnyFromPod; | ||
| 55 | use Dist::Zilla::Plugin::SurgicalPodWeaver; | ||
| 56 | use Dist::Zilla::Plugin::Test::CPAN::Changes; | ||
| 57 | use Dist::Zilla::Plugin::Test::CPAN::Meta::JSON; | ||
| 58 | use Dist::Zilla::Plugin::Test::CleanNamespaces; | ||
| 59 | use Dist::Zilla::Plugin::Test::Compile; | ||
| 60 | use Dist::Zilla::Plugin::Test::EOL 0.14; | ||
| 61 | use Dist::Zilla::Plugin::Test::NoTabs; | ||
| 62 | use Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable; | ||
| 63 | use Dist::Zilla::Plugin::Test::PodSpelling; | ||
| 64 | use Dist::Zilla::Plugin::Test::Portability; | ||
| 65 | use Dist::Zilla::Plugin::Test::ReportPrereqs; | ||
| 66 | use Dist::Zilla::Plugin::Test::Synopsis; | ||
| 67 | #use Dist::Zilla::Plugin::Test::TidyAll 0.04; | ||
| 68 | use Dist::Zilla::Plugin::Test::Version; | ||
| 69 | use Dist::Zilla::Plugin::VersionFromMainModule 0.02; | ||
| 70 | |||
| 71 | use Moose; | ||
| 72 | |||
| 73 | with 'Dist::Zilla::Role::PluginBundle::Easy', | ||
| 74 | 'Dist::Zilla::Role::PluginBundle::PluginRemover', | ||
| 75 | 'Dist::Zilla::Role::PluginBundle::Config::Slicer'; | ||
| 76 | |||
| 77 | has dist => ( | ||
| 78 | is => 'ro', | ||
| 79 | isa => 'Str', | ||
| 80 | required => 1, | ||
| 81 | ); | ||
| 82 | |||
| 83 | has make_tool => ( | ||
| 84 | is => 'ro', | ||
| 85 | isa => 'Str', | ||
| 86 | default => 'ATOOMIC::MakeMaker', | ||
| 87 | ); | ||
| 88 | |||
| 89 | has authority => ( | ||
| 90 | is => 'ro', | ||
| 91 | isa => 'Str', | ||
| 92 | default => 'ATOOMIC', | ||
| 93 | ); | ||
| 94 | |||
| 95 | has prereqs_skip => ( | ||
| 96 | traits => ['Array'], | ||
| 97 | is => 'ro', | ||
| 98 | isa => 'ArrayRef[Str]', | ||
| 99 | required => 1, | ||
| 100 | handles => { | ||
| 101 | _has_prereqs_skip => 'count', | ||
| 102 | }, | ||
| 103 | ); | ||
| 104 | |||
| 105 | has exclude_files => ( | ||
| 106 | is => 'ro', | ||
| 107 | isa => 'ArrayRef[Str]', | ||
| 108 | required => 1, | ||
| 109 | ); | ||
| 110 | |||
| 111 | has has_xs => ( | ||
| 112 | is => 'ro', | ||
| 113 | isa => 'Bool', | ||
| 114 | lazy => 1, | ||
| 115 | builder => '_build_has_xs', | ||
| 116 | ); | ||
| 117 | |||
| 118 | has _exclude => ( | ||
| 119 | is => 'ro', | ||
| 120 | isa => 'HashRef[ArrayRef]', | ||
| 121 | lazy => 1, | ||
| 122 | builder => '_build_exclude', | ||
| 123 | ); | ||
| 124 | |||
| 125 | has _exclude_filenames => ( | ||
| 126 | is => 'ro', | ||
| 127 | isa => 'ArrayRef[Str]', | ||
| 128 | lazy => 1, | ||
| 129 | default => sub { $_[0]->_exclude->{filenames} }, | ||
| 130 | ); | ||
| 131 | |||
| 132 | has _exclude_match => ( | ||
| 133 | is => 'ro', | ||
| 134 | isa => 'ArrayRef[Regexp]', | ||
| 135 | lazy => 1, | ||
| 136 | default => sub { $_[0]->_exclude->{match} }, | ||
| 137 | ); | ||
| 138 | |||
| 139 | has _allow_dirty => ( | ||
| 140 | is => 'ro', | ||
| 141 | isa => 'ArrayRef[Str]', | ||
| 142 | lazy => 1, | ||
| 143 | builder => '_build_allow_dirty', | ||
| 144 | ); | ||
| 145 | |||
| 146 | has pod_coverage_class => ( | ||
| 147 | is => 'ro', | ||
| 148 | isa => 'Str', | ||
| 149 | predicate => '_has_pod_coverage_class', | ||
| 150 | ); | ||
| 151 | |||
| 152 | has pod_coverage_skip => ( | ||
| 153 | traits => ['Array'], | ||
| 154 | is => 'ro', | ||
| 155 | isa => 'ArrayRef[Str]', | ||
| 156 | required => 1, | ||
| 157 | handles => { | ||
| 158 | _has_pod_coverage_skip => 'count', | ||
| 159 | }, | ||
| 160 | ); | ||
| 161 | |||
| 162 | has pod_coverage_trustme => ( | ||
| 163 | traits => ['Array'], | ||
| 164 | is => 'ro', | ||
| 165 | isa => 'ArrayRef[Str]', | ||
| 166 | required => 1, | ||
| 167 | handles => { | ||
| 168 | _has_pod_coverage_trustme => 'count', | ||
| 169 | }, | ||
| 170 | ); | ||
| 171 | |||
| 172 | has pod_coverage_also_private => ( | ||
| 173 | traits => ['Array'], | ||
| 174 | is => 'ro', | ||
| 175 | isa => 'ArrayRef[Str]', | ||
| 176 | required => 1, | ||
| 177 | handles => { | ||
| 178 | _has_pod_coverage_also_private => 'count', | ||
| 179 | }, | ||
| 180 | ); | ||
| 181 | |||
| 182 | has stopwords => ( | ||
| 183 | traits => ['Array'], | ||
| 184 | is => 'ro', | ||
| 185 | isa => 'ArrayRef[Str]', | ||
| 186 | required => 1, | ||
| 187 | ); | ||
| 188 | |||
| 189 | has stopwords_file => ( | ||
| 190 | is => 'ro', | ||
| 191 | isa => 'Str', | ||
| 192 | predicate => '_has_stopwords_file', | ||
| 193 | ); | ||
| 194 | |||
| 195 | has tidyall_section => ( | ||
| 196 | traits => ['Array'], | ||
| 197 | is => 'ro', | ||
| 198 | isa => 'ArrayRef[Str]', | ||
| 199 | required => 1, | ||
| 200 | handles => { | ||
| 201 | _has_tidyall_section => 'count', | ||
| 202 | }, | ||
| 203 | ); | ||
| 204 | |||
| 205 | has next_release_width => ( | ||
| 206 | is => 'ro', | ||
| 207 | isa => 'Int', | ||
| 208 | default => 8, | ||
| 209 | ); | ||
| 210 | |||
| 211 | has use_github_homepage => ( | ||
| 212 | is => 'ro', | ||
| 213 | isa => 'Bool', | ||
| 214 | default => 0, | ||
| 215 | ); | ||
| 216 | |||
| 217 | has use_github_issues => ( | ||
| 218 | is => 'ro', | ||
| 219 | isa => 'Bool', | ||
| 220 | default => 0, | ||
| 221 | ); | ||
| 222 | |||
| 223 | has _plugins => ( | ||
| 224 | is => 'ro', | ||
| 225 | isa => 'ArrayRef', | ||
| 226 | init_arg => undef, | ||
| 227 | lazy => 1, | ||
| 228 | builder => '_build_plugins', | ||
| 229 | ); | ||
| 230 | |||
| 231 | has _files_to_copy_from_build => ( | ||
| 232 | is => 'ro', | ||
| 233 | isa => 'ArrayRef[Str]', | ||
| 234 | init_arg => undef, | ||
| 235 | lazy => 1, | ||
| 236 | builder => '_build_files_to_copy_from_build', | ||
| 237 | ); | ||
| 238 | |||
| 239 | my @array_params = grep { !/^_/ } map { $_->name } | ||
| 240 | grep { | ||
| 241 | $_->has_type_constraint | ||
| 242 | && $_->type_constraint->is_a_type_of('ArrayRef') | ||
| 243 | } __PACKAGE__->meta->get_all_attributes; | ||
| 244 | |||
| 245 | sub mvp_multivalue_args { | ||
| 246 | return @array_params; | ||
| 247 | } | ||
| 248 | |||
| 249 | around BUILDARGS => sub { | ||
| 250 | my $orig = shift; | ||
| 251 | my $class = shift; | ||
| 252 | |||
| 253 | my $p = $class->$orig(@_); | ||
| 254 | |||
| 255 | my %args = ( %{ $p->{payload} }, %{$p} ); | ||
| 256 | |||
| 257 | for my $key (@array_params) { | ||
| 258 | if ( $args{$key} && !ref $args{$key} ) { | ||
| 259 | $args{$key} = [ delete $args{$key} ]; | ||
| 260 | } | ||
| 261 | $args{$key} //= []; | ||
| 262 | } | ||
| 263 | |||
| 264 | return \%args; | ||
| 265 | }; | ||
| 266 | |||
| 267 | sub configure { | ||
| 268 | my $self = shift; | ||
| 269 | $self->add_plugins( @{ $self->_plugins } ); | ||
| 270 | return; | ||
| 271 | } | ||
| 272 | |||
| 273 | sub _build_plugins { | ||
| 274 | my $self = shift; | ||
| 275 | |||
| 276 | my %make_tool_args; | ||
| 277 | if ( $self->make_tool =~ /MakeMaker/ ) { | ||
| 278 | $make_tool_args{has_xs} = $self->has_xs; | ||
| 279 | } | ||
| 280 | |||
| 281 | return [ | ||
| 282 | $self->_gather_dir_plugin, | ||
| 283 | $self->_basic_plugins, | ||
| 284 | $self->_authority_plugin, | ||
| 285 | $self->_auto_prereqs_plugin, | ||
| 286 | $self->_copy_files_from_build_plugin, | ||
| 287 | $self->_github_plugins, | ||
| 288 | $self->_meta_plugins, | ||
| 289 | $self->_next_release_plugin, | ||
| 290 | $self->_explicit_prereq_plugins, | ||
| 291 | $self->_prompt_if_stale_plugin, | ||
| 292 | $self->_pod_test_plugins, | ||
| 293 | $self->_extra_test_plugins, | ||
| 294 | $self->_contributors_plugins, | ||
| 295 | $self->_pod_weaver_plugin, | ||
| 296 | |||
| 297 | # README.md generation needs to come after pod weaving | ||
| 298 | $self->_readme_md_plugin, | ||
| 299 | $self->_contributing_md_plugin, | ||
| 300 | $self->_code_of_conduct_plugin, | ||
| 301 | 'InstallGuide', | ||
| 302 | 'CPANFile', | ||
| 303 | $self->_maybe_ppport_plugin, | ||
| 304 | 'ATOOMIC::License', | ||
| 305 | $self->_release_check_plugins, | ||
| 306 | #$self->_tidyall_plugin, | ||
| 307 | $self->_git_plugins, | ||
| 308 | |||
| 309 | # This needs to be last so that MakeMaker::Awesome can see all the | ||
| 310 | # prereqs that a distro has. If it comes first, it tries to check the | ||
| 311 | # prereqs before they've been added and makes a mess of things. | ||
| 312 | [ $self->make_tool => \%make_tool_args ], | ||
| 313 | ]; | ||
| 314 | } | ||
| 315 | |||
| 316 | sub _gather_dir_plugin { | ||
| 317 | my $self = shift; | ||
| 318 | |||
| 319 | my $match = $self->_exclude_match; | ||
| 320 | [ | ||
| 321 | 'Git::GatherDir' => { | ||
| 322 | exclude_filename => $self->_exclude_filenames, | ||
| 323 | ( @{$match} ? ( exclude_match => $match ) : () ), | ||
| 324 | }, | ||
| 325 | ]; | ||
| 326 | } | ||
| 327 | |||
| 328 | sub _build_exclude { | ||
| 329 | my $self = shift; | ||
| 330 | |||
| 331 | my @filenames = @{ $self->_files_to_copy_from_build }; | ||
| 332 | |||
| 333 | my @match; | ||
| 334 | for my $exclude ( @{ $self->exclude_files } ) { | ||
| 335 | if ( $exclude =~ m{^[\w\-\./]+$} ) { | ||
| 336 | push @filenames, $exclude; | ||
| 337 | } | ||
| 338 | else { | ||
| 339 | push @match, qr/$exclude/; | ||
| 340 | } | ||
| 341 | } | ||
| 342 | |||
| 343 | return { | ||
| 344 | filenames => \@filenames, | ||
| 345 | match => \@match, | ||
| 346 | }; | ||
| 347 | } | ||
| 348 | |||
| 349 | sub _basic_plugins { | ||
| 350 | |||
| 351 | # These are a subset of the @Basic bundle except for CheckVersionIncrement | ||
| 352 | # and VersionFromMainModule. | ||
| 353 | qw( | ||
| 354 | ManifestSkip | ||
| 355 | License | ||
| 356 | ExecDir | ||
| 357 | ShareDir | ||
| 358 | Manifest | ||
| 359 | CheckVersionIncrement | ||
| 360 | TestRelease | ||
| 361 | ConfirmRelease | ||
| 362 | UploadToCPAN | ||
| 363 | VersionFromMainModule | ||
| 364 | ); | ||
| 365 | } | ||
| 366 | |||
| 367 | sub _authority_plugin { | ||
| 368 | my $self = shift; | ||
| 369 | |||
| 370 | return [ | ||
| 371 | Authority => { | ||
| 372 | authority => 'cpan:' . $self->authority, | ||
| 373 | do_munging => 0, | ||
| 374 | }, | ||
| 375 | ]; | ||
| 376 | } | ||
| 377 | |||
| 378 | sub _auto_prereqs_plugin { | ||
| 379 | my $self = shift; | ||
| 380 | |||
| 381 | return [ | ||
| 382 | AutoPrereqs => { | ||
| 383 | $self->_has_prereqs_skip | ||
| 384 | ? ( skip => $self->prereqs_skip ) | ||
| 385 | : () | ||
| 386 | }, | ||
| 387 | ]; | ||
| 388 | } | ||
| 389 | |||
| 390 | sub _copy_files_from_build_plugin { | ||
| 391 | my $self = shift; | ||
| 392 | |||
| 393 | return [ | ||
| 394 | CopyFilesFromBuild => { | ||
| 395 | copy => $self->_files_to_copy_from_build, | ||
| 396 | }, | ||
| 397 | ]; | ||
| 398 | } | ||
| 399 | |||
| 400 | # These are files which are generated as part of the build process and then | ||
| 401 | # copied back into the git repo and checked in. | ||
| 402 | sub _build_files_to_copy_from_build { | ||
| 403 | my $self = shift; | ||
| 404 | |||
| 405 | my @files = qw( | ||
| 406 | CODE_OF_CONDUCT.md | ||
| 407 | CONTRIBUTING.md | ||
| 408 | LICENSE | ||
| 409 | README.md | ||
| 410 | cpanfile | ||
| 411 | ); | ||
| 412 | |||
| 413 | push @files, $self->make_tool =~ /MakeMaker/ ? 'Makefile.PL' : 'Build.PL'; | ||
| 414 | |||
| 415 | if ( $self->has_xs ) { | ||
| 416 | if ( $self->payload->{'PPPort.filename'} ) { | ||
| 417 | push @files, $self->payload->{'PPPort.filename'}; | ||
| 418 | } | ||
| 419 | else { | ||
| 420 | push @files, 'ppport.h'; | ||
| 421 | } | ||
| 422 | } | ||
| 423 | |||
| 424 | return \@files; | ||
| 425 | } | ||
| 426 | |||
| 427 | sub _github_plugins { | ||
| 428 | return if $ENV{TRAVIS}; | ||
| 429 | |||
| 430 | my $self = shift; | ||
| 431 | |||
| 432 | return ( | ||
| 433 | [ | ||
| 434 | 'GitHub::Meta' => { | ||
| 435 | bugs => $self->use_github_issues, | ||
| 436 | homepage => $self->use_github_homepage, | ||
| 437 | require_auth => 1, | ||
| 438 | |||
| 439 | #repo => 'gh', # ordering issue ? | ||
| 440 | }, | ||
| 441 | ], | ||
| 442 | [ 'GitHub::Update' => { metacpan => 1 } ], | ||
| 443 | ); | ||
| 444 | } | ||
| 445 | |||
| 446 | sub _meta_plugins { | ||
| 447 | my $self = shift; | ||
| 448 | |||
| 449 | return ( | ||
| 450 | [ MetaResources => $self->_meta_resources, ], | ||
| 451 | [ 'MetaProvides::Package' => { meta_noindex => 1 } ], | ||
| 452 | qw( | ||
| 453 | Meta::Contributors | ||
| 454 | MetaConfig | ||
| 455 | MetaJSON | ||
| 456 | MetaYAML | ||
| 457 | ), | ||
| 458 | ); | ||
| 459 | } | ||
| 460 | |||
| 461 | sub _meta_resources { | ||
| 462 | my $self = shift; | ||
| 463 | |||
| 464 | my %resources; | ||
| 465 | |||
| 466 | unless ( $self->use_github_homepage ) { | ||
| 467 | $resources{homepage} | ||
| 468 | = sprintf( 'http://metacpan.org/release/%s', $self->dist ); | ||
| 469 | } | ||
| 470 | |||
| 471 | unless ( $self->use_github_issues ) { | ||
| 472 | %resources = ( | ||
| 473 | %resources, | ||
| 474 | 'bugtracker.web' => sprintf( | ||
| 475 | 'http://rt.cpan.org/Public/Dist/Display.html?Name=%s', | ||
| 476 | $self->dist | ||
| 477 | ), | ||
| 478 | 'bugtracker.mailto' => | ||
| 479 | sprintf( 'bug-%s@rt.cpan.org', lc $self->dist ), | ||
| 480 | ); | ||
| 481 | } | ||
| 482 | |||
| 483 | return \%resources; | ||
| 484 | } | ||
| 485 | |||
| 486 | sub _next_release_plugin { | ||
| 487 | my $self = shift; | ||
| 488 | |||
| 489 | return [ | ||
| 490 | NextRelease => { | ||
| 491 | format => '%-' | ||
| 492 | . $self->next_release_width | ||
| 493 | . 'v %{yyyy-MM-dd}d%{ (TRIAL RELEASE)}T' | ||
| 494 | }, | ||
| 495 | ]; | ||
| 496 | } | ||
| 497 | |||
| 498 | sub _explicit_prereq_plugins { | ||
| 499 | my $self = shift; | ||
| 500 | |||
| 501 | my $test_more = $self->_dist_uses_test2 | ||
| 502 | ? [ | ||
| 503 | 'Prereqs' => 'Test::More with Test2' => { | ||
| 504 | -phase => 'test', | ||
| 505 | -type => 'requires', | ||
| 506 | 'Test::More' => '1.302015', | ||
| 507 | } | ||
| 508 | ] | ||
| 509 | : [ | ||
| 510 | 'Prereqs' => 'Test::More with subtest' => { | ||
| 511 | -phase => 'test', | ||
| 512 | -type => 'requires', | ||
| 513 | 'Test::More' => '0.96', | ||
| 514 | } | ||
| 515 | ]; | ||
| 516 | |||
| 517 | return ( | ||
| 518 | $test_more, | ||
| 519 | |||
| 520 | # Because Code::TidyAll does not depend on them | ||
| 521 | # [ | ||
| 522 | # 'Prereqs' => 'Modules for use with tidyall' => { | ||
| 523 | # -phase => 'develop', | ||
| 524 | # -type => 'requires', | ||
| 525 | # 'Code::TidyAll' => '0.56', | ||
| 526 | # 'Code::TidyAll::Plugin::SortLines::Naturally' => '0.000003', | ||
| 527 | # 'Code::TidyAll::Plugin::Test::Vars' => '0.02', | ||
| 528 | # 'Parallel::ForkManager' => '1.19', | ||
| 529 | # 'Perl::Critic' => '1.126', | ||
| 530 | # 'Perl::Tidy' => '20160302', | ||
| 531 | # 'Test::Vars' => '0.009', | ||
| 532 | # } | ||
| 533 | # ], | ||
| 534 | [ | ||
| 535 | 'Prereqs' => | ||
| 536 | 'Test::Version which fixes https://github.com/plicease/Test-Version/issues/7' | ||
| 537 | => { | ||
| 538 | -phase => 'develop', | ||
| 539 | -type => 'requires', | ||
| 540 | 'Test::Version' => '2.05', | ||
| 541 | }, | ||
| 542 | ], | ||
| 543 | ); | ||
| 544 | } | ||
| 545 | |||
| 546 | sub _dist_uses_test2 { | ||
| 547 | my $rule = Path::Iterator::Rule->new; | ||
| 548 | my $iter | ||
| 549 | = $rule->file->name(qr/\.(t|pm)/)->contents_match(qr/^use Test2/m) | ||
| 550 | ->iter('t'); | ||
| 551 | |||
| 552 | while ( my $file = $iter->() ) { | ||
| 553 | return 1; | ||
| 554 | } | ||
| 555 | |||
| 556 | return 0; | ||
| 557 | } | ||
| 558 | |||
| 559 | sub _prompt_if_stale_plugin { | ||
| 560 | my $name = __PACKAGE__; | ||
| 561 | return ( | ||
| 562 | [ | ||
| 563 | 'PromptIfStale' => $name => { | ||
| 564 | phase => 'build', | ||
| 565 | module => [__PACKAGE__], | ||
| 566 | }, | ||
| 567 | ], | ||
| 568 | [ | ||
| 569 | 'PromptIfStale' => { | ||
| 570 | phase => 'release', | ||
| 571 | check_all_plugins => 1, | ||
| 572 | check_all_prereqs => 1, | ||
| 573 | check_authordeps => 1, | ||
| 574 | skip => [ | ||
| 575 | qw( | ||
| 576 | Dist::Zilla::Plugin::ATOOMIC::Contributors | ||
| 577 | Dist::Zilla::Plugin::ATOOMIC::Git::CheckFor::CorrectBranch | ||
| 578 | Dist::Zilla::Plugin::ATOOMIC::License | ||
| 579 | Dist::Zilla::Plugin::ATOOMIC::WeaverConfig | ||
| 580 | Pod::Weaver::PluginBundle::ATOOMIC | ||
| 581 | ) | ||
| 582 | ], | ||
| 583 | } | ||
| 584 | ], | ||
| 585 | ); | ||
| 586 | } | ||
| 587 | |||
| 588 | sub _pod_test_plugins { | ||
| 589 | my $self = shift; | ||
| 590 | |||
| 591 | return ( | ||
| 592 | [ | ||
| 593 | 'Test::Pod::Coverage::Configurable' => { | ||
| 594 | ( | ||
| 595 | $self->_has_pod_coverage_also_private | ||
| 596 | ? ( also_private => $self->pod_coverage_also_private ) | ||
| 597 | : () | ||
| 598 | ), | ||
| 599 | ( | ||
| 600 | $self->_has_pod_coverage_skip | ||
| 601 | ? ( skip => $self->pod_coverage_skip ) | ||
| 602 | : () | ||
| 603 | ), | ||
| 604 | ( | ||
| 605 | $self->_has_pod_coverage_trustme | ||
| 606 | ? ( trustme => $self->pod_coverage_trustme ) | ||
| 607 | : () | ||
| 608 | ), | ||
| 609 | ( | ||
| 610 | $self->_has_pod_coverage_class | ||
| 611 | ? ( class => $self->pod_coverage_class ) | ||
| 612 | : () | ||
| 613 | ), | ||
| 614 | }, | ||
| 615 | ], | ||
| 616 | [ | ||
| 617 | 'Test::PodSpelling' => { stopwords => $self->_all_stopwords }, | ||
| 618 | ], | ||
| 619 | 'PodSyntaxTests', | ||
| 620 | ); | ||
| 621 | } | ||
| 622 | |||
| 623 | sub _all_stopwords { | ||
| 624 | my $self = shift; | ||
| 625 | |||
| 626 | my @stopwords = $self->_default_stopwords; | ||
| 627 | push @stopwords, @{ $self->stopwords }; | ||
| 628 | |||
| 629 | if ( $self->_has_stopwords_file ) { | ||
| 630 | open my $fh, '<:encoding(UTF-8)', $self->stopwords_file; | ||
| 631 | while (<$fh>) { | ||
| 632 | chomp; | ||
| 633 | next unless length $_ && $_ !~ /^\#/; | ||
| 634 | push @stopwords, $_; | ||
| 635 | } | ||
| 636 | close $fh; | ||
| 637 | } | ||
| 638 | |||
| 639 | return \@stopwords; | ||
| 640 | } | ||
| 641 | |||
| 642 | sub _default_stopwords { | ||
| 643 | return qw( | ||
| 644 | drolsky | ||
| 645 | ATOOMIC | ||
| 646 | ATOOMIC's | ||
| 647 | PayPal | ||
| 648 | Rolsky | ||
| 649 | Rolsky's | ||
| 650 | ); | ||
| 651 | } | ||
| 652 | |||
| 653 | sub _extra_test_plugins { | ||
| 654 | my $self = shift; | ||
| 655 | |||
| 656 | return ( | ||
| 657 | qw( | ||
| 658 | ATOOMIC::RunExtraTests | ||
| 659 | MojibakeTests | ||
| 660 | Test::CleanNamespaces | ||
| 661 | Test::CPAN::Changes | ||
| 662 | Test::CPAN::Meta::JSON | ||
| 663 | Test::EOL | ||
| 664 | Test::NoTabs | ||
| 665 | Test::Portability | ||
| 666 | Test::Synopsis | ||
| 667 | ), | ||
| 668 | # [ | ||
| 669 | # 'Test::TidyAll' => { | ||
| 670 | # verbose => 1, | ||
| 671 | # jobs => 4, | ||
| 672 | |||
| 673 | # # Test::Vars requires this version | ||
| 674 | # minimum_perl => '5.010', | ||
| 675 | # } | ||
| 676 | # ], | ||
| 677 | [ 'Test::Compile' => { xt_mode => 1 } ], | ||
| 678 | [ 'Test::ReportPrereqs' => { verify_prereqs => 1 } ], | ||
| 679 | [ 'Test::Version' => { is_strict => 1 } ], | ||
| 680 | ); | ||
| 681 | } | ||
| 682 | |||
| 683 | sub _contributors_plugins { | ||
| 684 | qw( | ||
| 685 | ATOOMIC::Contributors | ||
| 686 | Git::Contributors | ||
| 687 | ); | ||
| 688 | } | ||
| 689 | |||
| 690 | sub _pod_weaver_plugin { | ||
| 691 | return ( | ||
| 692 | [ | ||
| 693 | SurgicalPodWeaver => { | ||
| 694 | config_plugin => '@ATOOMIC', | ||
| 695 | }, | ||
| 696 | ], | ||
| 697 | 'ATOOMIC::WeaverConfig', | ||
| 698 | ); | ||
| 699 | } | ||
| 700 | |||
| 701 | sub _readme_md_plugin { | ||
| 702 | [ | ||
| 703 | 'ReadmeAnyFromPod' => 'README.md in build' => { | ||
| 704 | type => 'markdown', | ||
| 705 | filename => 'README.md', | ||
| 706 | location => 'build', | ||
| 707 | phase => 'build', | ||
| 708 | }, | ||
| 709 | ]; | ||
| 710 | } | ||
| 711 | |||
| 712 | sub _contributing_md_plugin { | ||
| 713 | my $self = shift; | ||
| 714 | |||
| 715 | return [ | ||
| 716 | 'GenerateFile::FromShareDir' => 'Generate CONTRIBUTING.md' => { | ||
| 717 | -dist => ( __PACKAGE__ =~ s/::/-/gr ), | ||
| 718 | -filename => 'CONTRIBUTING.md', | ||
| 719 | has_xs => $self->has_xs, | ||
| 720 | }, | ||
| 721 | ]; | ||
| 722 | } | ||
| 723 | |||
| 724 | sub _code_of_conduct_plugin { | ||
| 725 | my $self = shift; | ||
| 726 | |||
| 727 | return [ | ||
| 728 | 'GenerateFile::FromShareDir' => 'Generate CODE_OF_CONDUCT.md' => { | ||
| 729 | -dist => ( __PACKAGE__ =~ s/::/-/gr ), | ||
| 730 | -filename => 'CODE_OF_CONDUCT.md', | ||
| 731 | has_xs => $self->has_xs, | ||
| 732 | }, | ||
| 733 | ]; | ||
| 734 | } | ||
| 735 | |||
| 736 | sub _maybe_ppport_plugin { | ||
| 737 | my $self = shift; | ||
| 738 | |||
| 739 | return unless $self->has_xs; | ||
| 740 | return 'PPPort'; | ||
| 741 | } | ||
| 742 | |||
| 743 | sub _release_check_plugins { | ||
| 744 | return ( | ||
| 745 | [ CheckStrictVersion => { decimal_only => 1 } ], | ||
| 746 | qw( | ||
| 747 | CheckSelfDependency | ||
| 748 | CheckPrereqsIndexed | ||
| 749 | ATOOMIC::Git::CheckFor::CorrectBranch | ||
| 750 | EnsureChangesHasContent | ||
| 751 | Git::CheckFor::MergeConflicts | ||
| 752 | ), | ||
| 753 | ); | ||
| 754 | } | ||
| 755 | |||
| 756 | sub _tidyall_plugin { | ||
| 757 | my $self = shift; | ||
| 758 | |||
| 759 | my %tidyall_config; | ||
| 760 | $tidyall_config{sections} = $self->tidyall_section | ||
| 761 | if $self->_has_tidyall_section; | ||
| 762 | $tidyall_config{stopwords_file} = $self->stopwords_file | ||
| 763 | if $self->_has_stopwords_file; | ||
| 764 | |||
| 765 | return 'ATOOMIC::TidyAll' unless keys %tidyall_config; | ||
| 766 | return [ 'ATOOMIC::TidyAll' => \%tidyall_config ]; | ||
| 767 | } | ||
| 768 | |||
| 769 | sub _git_plugins { | ||
| 770 | my $self = shift; | ||
| 771 | |||
| 772 | # These are mostly from @Git, except for BumpVersionAfterRelease. That | ||
| 773 | # one's in here because the order of all these plugins is | ||
| 774 | # important. We want to check the release, then we ... | ||
| 775 | |||
| 776 | return ( | ||
| 777 | # Check that the working directory does not contain any surprising uncommitted | ||
| 778 | # changes (except for things we expect to be dirty like the README.md or | ||
| 779 | # Changes). | ||
| 780 | [ 'Git::Check' => { allow_dirty => $self->_allow_dirty }, ], | ||
| 781 | |||
| 782 | # Commit all the dirty files before the release. | ||
| 783 | [ | ||
| 784 | 'Git::Commit' => 'Commit generated files' => { | ||
| 785 | allow_dirty => $self->_allow_dirty, | ||
| 786 | }, | ||
| 787 | ], | ||
| 788 | |||
| 789 | # Tag the release and push both the above commit and the tag. | ||
| 790 | qw( | ||
| 791 | Git::Tag | ||
| 792 | Git::Push | ||
| 793 | ), | ||
| 794 | |||
| 795 | # Bump all module versions. | ||
| 796 | 'BumpVersionAfterRelease', | ||
| 797 | |||
| 798 | # Make another commit with just the version bump. | ||
| 799 | [ | ||
| 800 | 'Git::Commit' => 'Commit version bump' => { | ||
| 801 | allow_dirty_match => ['.+'], | ||
| 802 | commit_msg => 'Bump version after release' | ||
| 803 | }, | ||
| 804 | ], | ||
| 805 | |||
| 806 | # Push the version bump commit. | ||
| 807 | [ 'Git::Push' => 'Push version bump' ], | ||
| 808 | ); | ||
| 809 | } | ||
| 810 | |||
| 811 | sub _build_allow_dirty { | ||
| 812 | my $self = shift; | ||
| 813 | |||
| 814 | # Anything we auto-generate and check in could be dirty. We also allow any | ||
| 815 | # other file which might get munged by this bundle to be dirty. | ||
| 816 | return [ | ||
| 817 | @{ $self->_exclude_filenames }, | ||
| 818 | qw( | ||
| 819 | Changes | ||
| 820 | tidyall.ini | ||
| 821 | ) | ||
| 822 | ]; | ||
| 823 | } | ||
| 824 | |||
| 825 | sub _build_has_xs { | ||
| 826 | my $self = shift; | ||
| 827 | |||
| 828 | my $rule = Path::Iterator::Rule->new; | ||
| 829 | return $rule->skip_dirs( '.build', $self->dist . '-*', ) | ||
| 830 | ->file->name(qr/\.xs$/)->iter('.')->() ? 1 : 0; | ||
| 831 | } | ||
| 832 | |||
| 833 | __PACKAGE__->meta->make_immutable; | ||
| 834 | |||
| 835 | 1; | ||
| 836 | |||
| 837 | # ABSTRACT: ATOOMIC's plugin bundle | ||
| 838 | |||
| 839 | __END__ |