« blib/lib/Dist/Zilla/Plugin/DBIO/GatherSkills.pm
↑ Summary
blib/lib/Pod/Weaver/PluginBundle/DBIO.pm »
| 1 | package Dist::Zilla::PluginBundle::DBIO; | ||||||||||||||||||||
| 2 | # ABSTRACT: Dist::Zilla plugin bundle for DBIO distributions | ||||||||||||||||||||
| 3 | 6 | our $VERSION = '0.900004'; | |||||||||||||||||||
| 4 | 6 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 6 | ▶ | use Dist::Zilla; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 6 | with 'Dist::Zilla::Role::PluginBundle::Easy'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 6 | ▶ | use Dist::Zilla::PluginBundle::Basic; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 6 | ▶ | use Dist::Zilla::PluginBundle::Git; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 6 | ▶ | use Dist::Zilla::PluginBundle::Git::VersionManager; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | has core => ( | ||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||
| 15 | isa => 'Bool', | ||||||||||||||||||||
| 16 | lazy => 1, | ||||||||||||||||||||
| 17 | 21 | ▶ | default => sub { $_[0]->payload->{core} }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 6 | ); | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | has heritage => ( | ||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||
| 23 | isa => 'Bool', | ||||||||||||||||||||
| 24 | lazy => 1, | ||||||||||||||||||||
| 25 | 21 | ▶ | default => sub { $_[0]->payload->{heritage} || 0 }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 6 | ); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | has copyright_holder => ( | ||||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||
| 31 | isa => 'Maybe[Str]', | ||||||||||||||||||||
| 32 | lazy => 1, | ||||||||||||||||||||
| 33 | 21 | ▶ | default => sub { $_[0]->payload->{copyright_holder} }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | 6 | ); | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | has share_skill => ( | ||||||||||||||||||||
| 38 | is => 'ro', | ||||||||||||||||||||
| 39 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||
| 40 | lazy => 1, | ||||||||||||||||||||
| 41 | # Normalise to an arrayref. A direct [@DBIO] section aggregates repeated | ||||||||||||||||||||
| 42 | # keys via mvp_multivalue_args, but when the bundle is wrapped in [@Filter] | ||||||||||||||||||||
| 43 | # (the async drivers) the reader uses @Filter's multivalue list instead, so | ||||||||||||||||||||
| 44 | # a lone share_skill arrives as a plain scalar — accept both. | ||||||||||||||||||||
| 45 | 21 | ▶ | default => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||
| 46 | 21 | my $v = $_[0]->payload->{share_skill}; | |||||||||||||||||||
| 47 | 21 | ▶ | return [] unless defined $v; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | 1 | ▶ | return ref $v eq 'ARRAY' ? $v : [$v]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | }, | ||||||||||||||||||||
| 50 | 6 | ); | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 21 | ▶ | sub mvp_multivalue_args { qw(share_skill) } | ||||||||||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | has coverage_threshold => ( | ||||||||||||||||||||
| 56 | is => 'ro', | ||||||||||||||||||||
| 57 | isa => 'Int', | ||||||||||||||||||||
| 58 | lazy => 1, | ||||||||||||||||||||
| 59 | 21 | ▶ | default => sub { $_[0]->payload->{coverage_threshold} // 80 }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]->payload->{"coverage_threshold"} // 80
MC/DC100%1/1
$_[0]->payload->{"coverage_threshold"} // 80
$_[0]->payload->{"coverage_threshold"}
Truth table100%2/2
A
A= $_[0]->payload->{"coverage_threshold"}
| |||||||||||||||||||||
| 60 | 6 | ); | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 21 | ▶ | sub configure { | ||||||||||||||||||
|
Subroutine
configure: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||
| 63 | 21 | my ($self) = @_; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | # Set author and copyright_holder via an inner BeforeBuild plugin — bundles have no $self->zilla | ||||||||||||||||||||
| 66 | 21 | ▶ | my $author = $self->heritage ? 'DBIO & DBIx::Class Authors' : 'DBIO Authors'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | 21 | ▶ | my $holder = $self->copyright_holder // $author; | ||||||||||||||||||
|
Condition33%1/3
$self->copyright_holder // $author
MC/DC0%0/2
$self->copyright_holder // $author
$self->copyright_holder
$author
Truth table33%1/3
A // B
A= $self->copyright_holderB= $author
| |||||||||||||||||||||
| 68 | 21 | $self->add_plugins([ 'DBIO::SetMeta' => { author => $author, holder => $holder } ]); | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | # What is tracked in git ships; only build products stay out. LICENSE is a | ||||||||||||||||||||
| 71 | # committed file gathered here and checked by DBIO::LicenseFile. | ||||||||||||||||||||
| 72 | 21 | $self->add_plugins([ 'Git::GatherDir' => { | |||||||||||||||||||
| 73 | include_dotfiles => 1, | ||||||||||||||||||||
| 74 | exclude_filename => [qw( META.yml META.json MANIFEST README README.md .karr )], | ||||||||||||||||||||
| 75 | }]); | ||||||||||||||||||||
| 76 | 21 | $self->add_plugins([ 'DBIO::LicenseFile' => { heritage => $self->heritage } ]); | |||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | # Ship this dist's own agent skills as a sharedir (see DBIO::Skills). | ||||||||||||||||||||
| 79 | # Authored under .claude/skills/, copied into share/skills/ at build time. | ||||||||||||||||||||
| 80 | $self->add_plugins([ 'DBIO::GatherSkills' => | ||||||||||||||||||||
| 81 | 21 | ▶ | @{ $self->share_skill } ? { skill => $self->share_skill } : {} ]); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | 21 | $self->add_plugins('ShareDir'); | |||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | # Snapshot the full agent context (.claude/.codex/CLAUDE.md/...) into the build | ||||||||||||||||||||
| 85 | # under misc/agent-context/ for build provenance (not installed). This is | ||||||||||||||||||||
| 86 | # separate from GatherSkills above: GatherSkills ships only the owned dbio-* | ||||||||||||||||||||
| 87 | # skills as an installed runtime sharedir; GatherAgentContext records the whole | ||||||||||||||||||||
| 88 | # as-built context, including skilletor-installed (git-ignored) skills. | ||||||||||||||||||||
| 89 | 21 | $self->add_plugins('GatherAgentContext'); | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | # Metadata | ||||||||||||||||||||
| 92 | 21 | $self->add_plugins(qw( | |||||||||||||||||||
| 93 | MetaJSON | ||||||||||||||||||||
| 94 | MetaYAML | ||||||||||||||||||||
| 95 | MetaConfig | ||||||||||||||||||||
| 96 | MetaProvides::Package | ||||||||||||||||||||
| 97 | Prereqs::FromCPANfile | ||||||||||||||||||||
| 98 | )); | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | # Version — core uses VersionFromMainModule, drivers use @Git::VersionManager | ||||||||||||||||||||
| 101 | 21 | ▶ | if ($self->core) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 102 | 5 | $self->add_plugins('VersionFromMainModule'); | |||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||
| 104 | 16 | $self->add_bundle('@Git::VersionManager' => { | |||||||||||||||||||
| 105 | 'RewriteVersion::Transitional.global' => 1, | ||||||||||||||||||||
| 106 | 'RewriteVersion::Transitional.finder' => [':InstallModules'], | ||||||||||||||||||||
| 107 | 'BumpVersionAfterRelease.finder' => [':InstallModules'], | ||||||||||||||||||||
| 108 | 'RewriteVersion::Transitional.fallback_version_provider' => 'Git::NextVersion', | ||||||||||||||||||||
| 109 | 'Git::NextVersion.first_version' => '0.900000', | ||||||||||||||||||||
| 110 | 'Git::Tag.tag_format' => 'v%V', | ||||||||||||||||||||
| 111 | 'NextRelease.format' => '%-9v %{yyyy-MM-dd}d', | ||||||||||||||||||||
| 112 | }); | ||||||||||||||||||||
| 113 | } | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | # POD — heritage uses @DBIO::Heritage which adds DBIx::Class attribution | ||||||||||||||||||||
| 116 | 21 | ▶ | $self->add_plugins([ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 117 | PodWeaver => { | ||||||||||||||||||||
| 118 | config_plugin => $self->heritage ? '@DBIO::Heritage' : '@DBIO', | ||||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | ]); | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | # Tests | ||||||||||||||||||||
| 123 | # ExtraTests promotes the xt/ files gathered by CoverageTest and | ||||||||||||||||||||
| 124 | # PodCheckerTest into t/. The order here is only for readability: munging | ||||||||||||||||||||
| 125 | # runs after all gathering. | ||||||||||||||||||||
| 126 | 21 | $self->add_plugins([ 'DBIO::CoverageTest' => { | |||||||||||||||||||
| 127 | coverage_threshold => $self->coverage_threshold, | ||||||||||||||||||||
| 128 | }]); | ||||||||||||||||||||
| 129 | # PodCheckerTest gathers xt/author/pod-checker.t, promoted the same way: a | ||||||||||||||||||||
| 130 | # Pod::Checker run over the built (woven) POD under AUTHOR_TESTING. | ||||||||||||||||||||
| 131 | 21 | $self->add_plugins('DBIO::PodCheckerTest'); | |||||||||||||||||||
| 132 | # Core only: nothing rewrites the modules other than the main one, so a | ||||||||||||||||||||
| 133 | # test fails when one deviates from the main module's $VERSION (k14). | ||||||||||||||||||||
| 134 | 21 | ▶ | $self->add_plugins('DBIO::VersionLockstepTest') if $self->core; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 135 | 21 | $self->add_plugins('ExtraTests'); | |||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | # Build — core uses MakeMaker::Awesome | ||||||||||||||||||||
| 138 | 21 | ▶ | if ($self->core) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 139 | 5 | $self->add_plugins([ 'MakeMaker::Awesome' => { eumm_version => '6.78' } ]); | |||||||||||||||||||
| 140 | 5 | $self->add_plugins([ 'ExecDir' => { dir => 'bin' } ]); | |||||||||||||||||||
| 141 | } else { | ||||||||||||||||||||
| 142 | 16 | $self->add_plugins('MakeMaker'); | |||||||||||||||||||
| 143 | } | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | 21 | $self->add_plugins(qw( | |||||||||||||||||||
| 146 | Readme | ||||||||||||||||||||
| 147 | ManifestSkip | ||||||||||||||||||||
| 148 | Manifest | ||||||||||||||||||||
| 149 | )); | ||||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | # Repository metadata — derived offline from the git remote | ||||||||||||||||||||
| 152 | # (Codeberg, or a Forgejo instance via host=), no API token. Replaces [GithubMeta] and the | ||||||||||||||||||||
| 153 | # external Dist::Zilla::Plugin::Codeberg::Meta. | ||||||||||||||||||||
| 154 | 21 | $self->add_plugins([ 'DBIO::CodebergMeta' => { issues => 1 } ]); | |||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | # IRC channel — fixed for the whole DBIO family (one source of truth), set | ||||||||||||||||||||
| 157 | # for every distribution rather than per-dist. No x_IRC_user. | ||||||||||||||||||||
| 158 | 21 | $self->add_plugins([ 'MetaResources' => { 'x_IRC' => 'irc://irc.perl.org/#dbio' } ]); | |||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | # Git checks | ||||||||||||||||||||
| 161 | 21 | $self->add_plugins([ 'Git::Check' => { | |||||||||||||||||||
| 162 | allow_dirty => [qw( dist.ini Changes cpanfile )], | ||||||||||||||||||||
| 163 | }]); | ||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | 21 | $self->add_plugins([ | |||||||||||||||||||
| 166 | 'Git::CheckFor::CorrectBranch' => { release_branch => 'main' }, | ||||||||||||||||||||
| 167 | ]); | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | # Release workflow | ||||||||||||||||||||
| 170 | 21 | my @release_checks = ( | |||||||||||||||||||
| 171 | 'TestRelease', | ||||||||||||||||||||
| 172 | 'Test::ChangesHasContent', | ||||||||||||||||||||
| 173 | [ 'InstallRelease' => { install_command => 'cpanm .' } ], | ||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||
| 175 | 21 | ▶ | if ($self->core) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 176 | 5 | $self->add_plugins([ 'NextRelease' => { | |||||||||||||||||||
| 177 | format => '%-9v %{yyyy-MM-dd}d', | ||||||||||||||||||||
| 178 | }]); | ||||||||||||||||||||
| 179 | 5 | $self->add_plugins( | |||||||||||||||||||
| 180 | @release_checks, | ||||||||||||||||||||
| 181 | 'ConfirmRelease', | ||||||||||||||||||||
| 182 | 'UploadToCPAN', | ||||||||||||||||||||
| 183 | [ 'Git::Commit' => { allow_dirty => [qw( dist.ini Changes cpanfile )] } ], | ||||||||||||||||||||
| 184 | [ 'Git::Tag' => { tag_format => 'v%V' } ], | ||||||||||||||||||||
| 185 | 'Git::Push', | ||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||
| 187 | } else { | ||||||||||||||||||||
| 188 | 16 | $self->add_plugins( | |||||||||||||||||||
| 189 | @release_checks, | ||||||||||||||||||||
| 190 | 'ConfirmRelease', | ||||||||||||||||||||
| 191 | 'UploadToCPAN', | ||||||||||||||||||||
| 192 | [ 'Git::Push' => { push_to => 'origin' } ], | ||||||||||||||||||||
| 193 | ); | ||||||||||||||||||||
| 194 | } | ||||||||||||||||||||
| 195 | } | ||||||||||||||||||||
| 196 | |||||||||||||||||||||
| 197 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 198 | |||||||||||||||||||||
| 199 | 6 | ▶ | no Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | __END__ | ||||||||||||||||||||