/usr/share/perl5/Dist/Zilla.pm is in libdist-zilla-perl 5.043-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 | package Dist::Zilla;
# ABSTRACT: distribution builder; installer not included!
$Dist::Zilla::VERSION = '5.043';
use Moose 0.92; # role composition fixes
with 'Dist::Zilla::Role::ConfigDumper';
# This comment has fün̈n̈ÿ characters.
use MooseX::Types::Moose qw(ArrayRef Bool HashRef Object Str);
use MooseX::Types::Perl qw(DistName LaxVersionStr);
use MooseX::Types::Path::Class qw(Dir File);
use Moose::Util::TypeConstraints;
use Dist::Zilla::Types qw(License ReleaseStatus);
use Log::Dispatchouli 1.100712; # proxy_loggers, quiet_fatal
use Path::Class;
use Path::Tiny;
use List::Util 1.33 qw(first none);
use Software::License 0.101370; # meta2_name
use String::RewritePrefix;
use Try::Tiny;
use Dist::Zilla::Prereqs;
use Dist::Zilla::File::OnDisk;
use Dist::Zilla::Role::Plugin;
use Dist::Zilla::Util;
use namespace::autoclean;
#pod =head1 DESCRIPTION
#pod
#pod Dist::Zilla builds distributions of code to be uploaded to the CPAN. In this
#pod respect, it is like L<ExtUtils::MakeMaker>, L<Module::Build>, or
#pod L<Module::Install>. Unlike those tools, however, it is not also a system for
#pod installing code that has been downloaded from the CPAN. Since it's only run by
#pod authors, and is meant to be run on a repository checkout rather than on
#pod published, released code, it can do much more than those tools, and is free to
#pod make much more ludicrous demands in terms of prerequisites.
#pod
#pod If you have access to the web, you can learn more and find an interactive
#pod tutorial at B<L<dzil.org|http://dzil.org/>>. If not, try
#pod L<Dist::Zilla::Tutorial>.
#pod
#pod =cut
has chrome => (
is => 'rw',
isa => role_type('Dist::Zilla::Role::Chrome'),
required => 1,
);
#pod =attr name
#pod
#pod The name attribute (which is required) gives the name of the distribution to be
#pod built. This is usually the name of the distribution's main module, with the
#pod double colons (C<::>) replaced with dashes. For example: C<Dist-Zilla>.
#pod
#pod =cut
has name => (
is => 'ro',
isa => DistName,
lazy => 1,
builder => '_build_name',
);
#pod =attr version
#pod
#pod This is the version of the distribution to be created.
#pod
#pod =cut
has _version_override => (
isa => LaxVersionStr,
is => 'ro' ,
init_arg => 'version',
);
# XXX: *clearly* this needs to be really much smarter -- rjbs, 2008-06-01
has version => (
is => 'rw',
isa => LaxVersionStr,
lazy => 1,
init_arg => undef,
builder => '_build_version',
);
sub _build_name {
my ($self) = @_;
my $name;
for my $plugin (@{ $self->plugins_with(-NameProvider) }) {
next unless defined(my $this_name = $plugin->provide_name);
$self->log_fatal('attempted to set name twice') if defined $name;
$name = $this_name;
}
$self->log_fatal('no name was ever set') unless defined $name;
$name;
}
sub _build_version {
my ($self) = @_;
my $version = $self->_version_override;
for my $plugin (@{ $self->plugins_with(-VersionProvider) }) {
next unless defined(my $this_version = $plugin->provide_version);
$self->log_fatal('attempted to set version twice') if defined $version;
$version = $this_version;
}
$self->log_fatal('no version was ever set') unless defined $version;
$version;
}
#pod =attr release_status
#pod
#pod This attribute sets the release status to one of the
#pod L<CPAN::META::Spec|https://metacpan.org/pod/CPAN::Meta::Spec#release_status>
#pod values: 'stable', 'testing' or 'unstable'.
#pod
#pod If the C<$ENV{RELEASE_STATUS}> environment variable exists, its value will
#pod be used as the release status.
#pod
#pod For backwards compatibility, if C<$ENV{RELEASE_STATUS}> does not exist and
#pod the C<$ENV{TRIAL}> variable is true, the release status will be 'testing'.
#pod
#pod Otherwise, the release status will be set from a
#pod L<ReleaseStatusProvider|Dist::Zilla::Role::ReleaseStatusProvider>, if one
#pod has been configured.
#pod
#pod For backwards compatibility, setting C<is_trial> true in F<dist.ini> is
#pod equivalent to using a C<ReleaseStatusProvider>. If C<is_trial> is false,
#pod it has no effect.
#pod
#pod Only B<one> C<ReleaseStatusProvider> may be used.
#pod
#pod If no providers are used, the release status defaults to 'stable' unless there
#pod is an "_" character in the version, in which case, it defaults to 'testing'.
#pod
#pod =cut
# release status must be lazy, after files are gathered
has release_status => (
is => 'ro',
isa => ReleaseStatus,
lazy => 1,
builder => '_build_release_status',
);
sub _build_release_status {
my ($self) = @_;
# environment variables override completely
return $self->_release_status_from_env if $self->_release_status_from_env;
# other ways of setting status must not conflict
my $status;
# dist.ini is equivalent to a release provider if is_trial is true.
# If false, though, we want other providers to run or fall back to
# the version
$status = 'testing' if $self->_override_is_trial;
for my $plugin (@{ $self->plugins_with(-ReleaseStatusProvider) }) {
next unless defined(my $this_status = $plugin->provide_release_status);
$self->log_fatal('attempted to set release status twice')
if defined $status;
$status = $this_status;
}
return $status || ( $self->version =~ /_/ ? 'testing' : 'stable' );
}
# captures environment variables early during Zilla object construction
has _release_status_from_env => (
is => 'ro',
isa => Str,
builder => '_build_release_status_from_env',
);
sub _build_release_status_from_env {
my ($self) = @_;
return $ENV{RELEASE_STATUS} if $ENV{RELEASE_STATUS};
return $ENV{TRIAL} ? 'testing' : '';
}
#pod =attr abstract
#pod
#pod This is a one-line summary of the distribution. If none is given, one will be
#pod looked for in the L</main_module> of the dist.
#pod
#pod =cut
has abstract => (
is => 'rw',
isa => 'Str',
lazy => 1,
default => sub {
my ($self) = @_;
unless ($self->main_module) {
die "no abstract given and no main_module found; make sure your main module is in ./lib\n";
}
my $file = $self->main_module;
$self->log_debug("extracting distribution abstract from " . $file->name);
my $abstract = Dist::Zilla::Util->abstract_from_file($file);
if (!defined($abstract)) {
my $filename = $file->name;
die "Unable to extract an abstract from $filename. Please add the following comment to the file with your abstract:
# ABSTRACT: turns baubles into trinkets
";
}
return $abstract;
}
);
#pod =attr main_module
#pod
#pod This is the module where Dist::Zilla might look for various defaults, like
#pod the distribution abstract. By default, it's derived from the distribution
#pod name. If your distribution is Foo-Bar, and F<lib/Foo/Bar.pm> exists,
#pod that's the main_module. Otherwise, it's the shortest-named module in the
#pod distribution. This may change!
#pod
#pod You can override the default by specifying the file path explicitly,
#pod ie:
#pod
#pod main_module = lib/Foo/Bar.pm
#pod
#pod =cut
has _main_module_override => (
isa => 'Str',
is => 'ro' ,
init_arg => 'main_module',
predicate => '_has_main_module_override',
);
has main_module => (
is => 'ro',
isa => 'Dist::Zilla::Role::File',
lazy => 1,
init_arg => undef,
default => sub {
my ($self) = @_;
my $file;
my $guess;
if ( $self->_has_main_module_override ) {
$file = first { $_->name eq $self->_main_module_override }
@{ $self->files };
} else {
# We're having to guess
($guess = $self->name) =~ s{-}{/}g;
$guess = "lib/$guess.pm";
$file = (first { $_->name eq $guess } @{ $self->files })
|| (sort { length $a->name <=> length $b->name }
grep { $_->name =~ m{\.pm\z} and $_->name =~ m{\Alib/} }
@{ $self->files })[0];
$self->log("guessing dist's main_module is " . ($file ? $file->name : $guess));
}
if (not $file) {
my @errorlines;
push @errorlines, "Unable to find main_module in the distribution";
if ($self->_has_main_module_override) {
push @errorlines, "'main_module' was specified in dist.ini but the file '" . $self->_main_module_override . "' is not to be found in our dist. ( Did you add it? )";
} else {
push @errorlines,"We tried to guess '$guess' but no file like that existed";
}
if (not @{ $self->files }) {
push @errorlines, "Upon further inspection we didn't find any files in your dist, did you add any?";
} elsif ( none { $_->name =~ m{^lib/.+\.pm\z} } @{ $self->files } ){
push @errorlines, "We didn't find any .pm files in your dist, this is probably a problem.";
}
push @errorlines,"Cannot continue without a main_module";
$self->log_fatal( join qq{\n}, @errorlines );
}
$self->log_debug("dist's main_module is " . $file->name);
return $file;
},
);
#pod =attr license
#pod
#pod This is the L<Software::License|Software::License> object for this dist's
#pod license and copyright.
#pod
#pod It will be created automatically, if possible, with the
#pod C<copyright_holder> and C<copyright_year> attributes. If necessary, it will
#pod try to guess the license from the POD of the dist's main module.
#pod
#pod A better option is to set the C<license> name in the dist's config to something
#pod understandable, like C<Perl_5>.
#pod
#pod =cut
has license => (
is => 'ro',
isa => License,
lazy => 1,
init_arg => 'license_obj',
predicate => '_has_license',
builder => '_build_license',
handles => {
copyright_holder => 'holder',
copyright_year => 'year',
},
);
sub _build_license {
my ($self) = @_;
my $license_class = $self->_license_class;
my $copyright_holder = $self->_copyright_holder;
my $copyright_year = $self->_copyright_year;
my $provided_license;
for my $plugin (@{ $self->plugins_with(-LicenseProvider) }) {
my $this_license = $plugin->provide_license({
copyright_holder => $copyright_holder,
copyright_year => $copyright_year,
});
next unless defined $this_license;
$self->log_fatal('attempted to set license twice')
if defined $provided_license;
$provided_license = $this_license;
}
return $provided_license if defined $provided_license;
if ($license_class) {
$license_class = String::RewritePrefix->rewrite(
{
'=' => '',
'' => 'Software::License::'
},
$license_class,
);
} else {
require Software::LicenseUtils;
my @guess = Software::LicenseUtils->guess_license_from_pod(
$self->main_module->content
);
if (@guess != 1) {
$self->log_fatal(
"no license data in config, no %Rights stash,",
"couldn't make a good guess at license from Pod; giving up. ",
"Perhaps you need to set up a global config file (dzil setup)?"
);
}
my $filename = $self->main_module->name;
$license_class = $guess[0];
$self->log("based on POD in $filename, guessing license is $guess[0]");
}
Class::Load::load_class($license_class);
my $license = $license_class->new({
holder => $self->_copyright_holder,
year => $self->_copyright_year,
});
$self->_clear_license_class;
$self->_clear_copyright_holder;
$self->_clear_copyright_year;
return $license;
}
has _license_class => (
is => 'ro',
isa => 'Maybe[Str]',
lazy => 1,
init_arg => 'license',
clearer => '_clear_license_class',
default => sub {
my $stash = $_[0]->stash_named('%Rights');
$stash && return $stash->license_class;
return;
}
);
has _copyright_holder => (
is => 'ro',
isa => 'Maybe[Str]',
lazy => 1,
init_arg => 'copyright_holder',
clearer => '_clear_copyright_holder',
default => sub {
return unless my $stash = $_[0]->stash_named('%Rights');
$stash && return $stash->copyright_holder;
return;
}
);
has _copyright_year => (
is => 'ro',
isa => 'Str',
lazy => 1,
init_arg => 'copyright_year',
clearer => '_clear_copyright_year',
default => sub {
# Oh man. This is a terrible idea! I mean, what if by the code gets run
# around like Dec 31, 23:59:59.9 and by the time the default gets called
# it's the next year but the default was already set up? Oh man. That
# could ruin lives! I guess we could make this a sub to defer the guess,
# but think of the performance hit! I guess we'll have to suffer through
# this until we can optimize the code to not take .1s to run, right? --
# rjbs, 2008-06-13
my $stash = $_[0]->stash_named('%Rights');
my $year = $stash && $stash->copyright_year;
return defined $year ? $year : (localtime)[5] + 1900;
}
);
#pod =attr authors
#pod
#pod This is an arrayref of author strings, like this:
#pod
#pod [
#pod 'Ricardo Signes <rjbs@cpan.org>',
#pod 'X. Ample, Jr <example@example.biz>',
#pod ]
#pod
#pod This is likely to change at some point in the near future.
#pod
#pod =cut
has authors => (
is => 'ro',
isa => ArrayRef[Str],
lazy => 1,
default => sub {
my ($self) = @_;
if (my $stash = $self->stash_named('%User')) {
return $stash->authors;
}
my $author = try { $self->copyright_holder };
return [ $author ] if defined $author and length $author;
$self->log_fatal(
"No %User stash and no copyright holder;",
"can't determine dist author; configure author or a %User section",
);
},
);
#pod =attr files
#pod
#pod This is an arrayref of objects implementing L<Dist::Zilla::Role::File> that
#pod will, if left in this arrayref, be built into the dist.
#pod
#pod Non-core code should avoid altering this arrayref, but sometimes there is not
#pod other way to change the list of files. In the future, the representation used
#pod for storing files B<will be changed>.
#pod
#pod =cut
has files => (
is => 'ro',
isa => ArrayRef[ role_type('Dist::Zilla::Role::File') ],
lazy => 1,
init_arg => undef,
default => sub { [] },
);
sub prune_file {
my ($self, $file) = @_;
my @files = @{ $self->files };
for my $i (0 .. $#files) {
next unless $file == $files[ $i ];
splice @{ $self->files }, $i, 1;
return;
}
return;
}
#pod =attr root
#pod
#pod This is the root directory of the dist, as a L<Path::Class::Dir>. It will
#pod nearly always be the current working directory in which C<dzil> was run.
#pod
#pod =cut
has root => (
is => 'ro',
isa => Dir,
coerce => 1,
required => 1,
);
#pod =attr is_trial
#pod
#pod This attribute tells us whether or not the dist will be a trial release,
#pod i.e. whether it has C<release_status> 'testing' or 'unstable'.
#pod
#pod Do not set this directly, it will be derived from C<release_status>.
#pod
#pod =cut
has is_trial => (
is => 'ro',
isa => Bool,
init_arg => undef,
lazy => 1,
builder => '_build_is_trial',
);
has _override_is_trial => (
is => 'ro',
isa => Bool,
init_arg => 'is_trial',
default => 0,
);
sub _build_is_trial {
my ($self) = @_;
return $self->release_status =~ /\A(?:testing|unstable)\z/ ? 1 : 0;
}
#pod =attr plugins
#pod
#pod This is an arrayref of plugins that have been plugged into this Dist::Zilla
#pod object.
#pod
#pod Non-core code B<must not> alter this arrayref. Public access to this attribute
#pod B<may go away> in the future.
#pod
#pod =cut
has plugins => (
is => 'ro',
isa => 'ArrayRef[Dist::Zilla::Role::Plugin]',
init_arg => undef,
default => sub { [ ] },
);
#pod =attr distmeta
#pod
#pod This is a hashref containing the metadata about this distribution that will be
#pod stored in META.yml or META.json. You should not alter the metadata in this
#pod hash; use a MetaProvider plugin instead.
#pod
#pod =cut
has distmeta => (
is => 'ro',
isa => 'HashRef',
init_arg => undef,
lazy => 1,
builder => '_build_distmeta',
);
sub _build_distmeta {
my ($self) = @_;
require CPAN::Meta::Merge;
my $meta_merge = CPAN::Meta::Merge->new(default_version => 2);
my $meta = {
'meta-spec' => {
version => 2,
url => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec',
},
name => $self->name,
version => $self->version,
abstract => $self->abstract,
author => $self->authors,
license => [ $self->license->meta2_name ],
release_status => $self->release_status,
dynamic_config => 0, # problematic, I bet -- rjbs, 2010-06-04
generated_by => $self->_metadata_generator_id
. ' version '
. (defined $self->VERSION ? $self->VERSION : '(undef)')
};
for (@{ $self->plugins_with(-MetaProvider) }) {
$meta = $meta_merge->merge($meta, $_->metadata);
}
return $meta;
}
sub _metadata_generator_id { 'Dist::Zilla' }
#pod =attr prereqs
#pod
#pod This is a L<Dist::Zilla::Prereqs> object, which is a thin layer atop
#pod L<CPAN::Meta::Prereqs>, and describes the distribution's prerequisites.
#pod
#pod =method register_prereqs
#pod
#pod Allows registration of prerequisites; delegates to
#pod L<Dist::Zilla::Prereqs/register_prereqs> via our L</prereqs> attribute.
#pod
#pod =cut
has prereqs => (
is => 'ro',
isa => 'Dist::Zilla::Prereqs',
init_arg => undef,
lazy => 1,
default => sub { Dist::Zilla::Prereqs->new },
handles => [ qw(register_prereqs) ],
);
#pod =method plugin_named
#pod
#pod my $plugin = $zilla->plugin_named( $plugin_name );
#pod
#pod =cut
sub plugin_named {
my ($self, $name) = @_;
my $plugin = first { $_->plugin_name eq $name } @{ $self->plugins };
return $plugin if $plugin;
return;
}
#pod =method plugins_with
#pod
#pod my $roles = $zilla->plugins_with( -SomeRole );
#pod
#pod This method returns an arrayref containing all the Dist::Zilla object's plugins
#pod that perform the named role. If the given role name begins with a dash, the
#pod dash is replaced with "Dist::Zilla::Role::"
#pod
#pod =cut
sub plugins_with {
my ($self, $role) = @_;
$role =~ s/^-/Dist::Zilla::Role::/;
my $plugins = [ grep { $_->does($role) } @{ $self->plugins } ];
return $plugins;
}
#pod =method find_files
#pod
#pod my $files = $zilla->find_files( $finder_name );
#pod
#pod This method will look for a
#pod L<FileFinder|Dist::Zilla::Role::FileFinder>-performing plugin with the given
#pod name and return the result of calling C<find_files> on it. If no plugin can be
#pod found, an exception will be raised.
#pod
#pod =cut
sub find_files {
my ($self, $finder_name) = @_;
$self->log_fatal("no plugin named $finder_name found")
unless my $plugin = $self->plugin_named($finder_name);
$self->log_fatal("plugin $finder_name is not a FileFinder")
unless $plugin->does('Dist::Zilla::Role::FileFinder');
$plugin->find_files;
}
sub _check_dupe_files {
my ($self) = @_;
my %files_named;
my @dupes;
for my $file (@{ $self->files }) {
my $filename = $file->name;
if (my $seen = $files_named{ $filename }) {
push @{ $seen }, $file;
push @dupes, $filename if @{ $seen } == 2;
} else {
$files_named{ $filename } = [ $file ];
}
}
return unless @dupes;
for my $name (@dupes) {
$self->log("attempt to add $name multiple times; added by: "
. join('; ', map { $_->added_by } @{ $files_named{ $name } })
);
}
Carp::croak("aborting; duplicate files would be produced");
}
sub _write_out_file {
my ($self, $file, $build_root) = @_;
# Okay, this is a bit much, until we have ->debug. -- rjbs, 2008-06-13
# $self->log("writing out " . $file->name);
my $file_path = file($file->name);
my $to_dir = $build_root->subdir( $file_path->dir );
my $to = $to_dir->file( $file_path->basename );
$to_dir->mkpath unless -e $to_dir;
die "not a directory: $to_dir" unless -d $to_dir;
Carp::croak("attempted to write $to multiple times") if -e $to;
path("$to")->spew_raw( $file->encoded_content );
chmod $file->mode, "$to" or die "couldn't chmod $to: $!";
}
#pod =attr logger
#pod
#pod This attribute stores a L<Log::Dispatchouli::Proxy> object, used to log
#pod messages. By default, a proxy to the dist's L<Chrome|Dist::Zilla::Chrome> is
#pod taken.
#pod
#pod The following methods are delegated from the Dist::Zilla object to the logger:
#pod
#pod =for :list
#pod * log
#pod * log_debug
#pod * log_fatal
#pod
#pod =cut
has logger => (
is => 'ro',
isa => 'Log::Dispatchouli::Proxy', # could be duck typed, I guess
lazy => 1,
handles => [ qw(log log_debug log_fatal) ],
default => sub {
$_[0]->chrome->logger->proxy({ proxy_prefix => '[DZ] ' })
},
);
around dump_config => sub {
my ($orig, $self) = @_;
my $config = $self->$orig;
$config->{is_trial} = $self->is_trial;
return $config;
};
has _local_stashes => (
is => 'ro',
isa => HashRef[ Object ],
lazy => 1,
default => sub { {} },
);
has _global_stashes => (
is => 'ro',
isa => HashRef[ Object ],
lazy => 1,
default => sub { {} },
);
#pod =method stash_named
#pod
#pod my $stash = $zilla->stash_named( $name );
#pod
#pod This method will return the stash with the given name, or undef if none exists.
#pod It looks for a local stash (for this dist) first, then falls back to a global
#pod stash (from the user's global configuration).
#pod
#pod =cut
sub stash_named {
my ($self, $name) = @_;
return $self->_local_stashes->{ $name } if $self->_local_stashes->{$name};
return $self->_global_stashes->{ $name };
}
__PACKAGE__->meta->make_immutable;
1;
#pod =head1 STABILITY PROMISE
#pod
#pod None.
#pod
#pod I will try not to break things within any major release. Minor releases are
#pod not extensively tested before release. In major releases, anything goes,
#pod although I will try to publish a complete list of known breaking changes in any
#pod major release.
#pod
#pod If Dist::Zilla was a tool, it would have yellow and black stripes and there
#pod would be no L<UL
#pod certification|https://en.wikipedia.org/wiki/UL_(safety_organization)> on it.
#pod It is nasty, brutish, and large.
#pod
#pod =head1 SUPPORT
#pod
#pod There are usually people on C<irc.perl.org> in C<#distzilla>, even if they're
#pod idling.
#pod
#pod The L<Dist::Zilla website|http://dzil.org/> has several valuable resources for
#pod learning to use Dist::Zilla.
#pod
#pod There is a mailing list to discuss Dist::Zilla. You can L<join the
#pod list|http://www.listbox.com/subscribe/?list_id=139292> or L<browse the
#pod archives|http://listbox.com/member/archive/139292>.
#pod
#pod =head1 SEE ALSO
#pod
#pod =over 4
#pod
#pod =item *
#pod
#pod In the Dist::Zilla distribution:
#pod
#pod =over 4
#pod
#pod =item *
#pod
#pod Plugin bundles:
#pod L<@Basic|Dist::Zilla::PluginBundle::Basic>,
#pod L<@Filter|Dist::Zilla::PluginBundle::Filter>.
#pod
#pod =item *
#pod
#pod Major plugins:
#pod L<GatherDir|Dist::Zilla::Plugin::GatherDir>,
#pod L<Prereqs|Dist::Zilla::Plugin::Prereqs>,
#pod L<AutoPrereqs|Dist::Zilla::Plugin::AutoPrereqs>,
#pod L<MetaYAML|Dist::Zilla::Plugin::MetaYAML>,
#pod L<MetaJSON|Dist::Zilla::Plugin::MetaJSON>,
#pod ...
#pod
#pod =back
#pod
#pod =item *
#pod
#pod On the CPAN:
#pod
#pod =over 4
#pod
#pod =item *
#pod
#pod Search for plugins: L<https://metacpan.org/search?q=Dist::Zilla::Plugin::>
#pod
#pod =item *
#pod
#pod Search for plugin bundles: L<https://metacpan.org/search?q=Dist::Zilla::PluginBundle::>
#pod
#pod =back
#pod
#pod =back
__END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Zilla - distribution builder; installer not included!
=head1 VERSION
version 5.043
=head1 DESCRIPTION
Dist::Zilla builds distributions of code to be uploaded to the CPAN. In this
respect, it is like L<ExtUtils::MakeMaker>, L<Module::Build>, or
L<Module::Install>. Unlike those tools, however, it is not also a system for
installing code that has been downloaded from the CPAN. Since it's only run by
authors, and is meant to be run on a repository checkout rather than on
published, released code, it can do much more than those tools, and is free to
make much more ludicrous demands in terms of prerequisites.
If you have access to the web, you can learn more and find an interactive
tutorial at B<L<dzil.org|http://dzil.org/>>. If not, try
L<Dist::Zilla::Tutorial>.
=head1 ATTRIBUTES
=head2 name
The name attribute (which is required) gives the name of the distribution to be
built. This is usually the name of the distribution's main module, with the
double colons (C<::>) replaced with dashes. For example: C<Dist-Zilla>.
=head2 version
This is the version of the distribution to be created.
=head2 release_status
This attribute sets the release status to one of the
L<CPAN::META::Spec|https://metacpan.org/pod/CPAN::Meta::Spec#release_status>
values: 'stable', 'testing' or 'unstable'.
If the C<$ENV{RELEASE_STATUS}> environment variable exists, its value will
be used as the release status.
For backwards compatibility, if C<$ENV{RELEASE_STATUS}> does not exist and
the C<$ENV{TRIAL}> variable is true, the release status will be 'testing'.
Otherwise, the release status will be set from a
L<ReleaseStatusProvider|Dist::Zilla::Role::ReleaseStatusProvider>, if one
has been configured.
For backwards compatibility, setting C<is_trial> true in F<dist.ini> is
equivalent to using a C<ReleaseStatusProvider>. If C<is_trial> is false,
it has no effect.
Only B<one> C<ReleaseStatusProvider> may be used.
If no providers are used, the release status defaults to 'stable' unless there
is an "_" character in the version, in which case, it defaults to 'testing'.
=head2 abstract
This is a one-line summary of the distribution. If none is given, one will be
looked for in the L</main_module> of the dist.
=head2 main_module
This is the module where Dist::Zilla might look for various defaults, like
the distribution abstract. By default, it's derived from the distribution
name. If your distribution is Foo-Bar, and F<lib/Foo/Bar.pm> exists,
that's the main_module. Otherwise, it's the shortest-named module in the
distribution. This may change!
You can override the default by specifying the file path explicitly,
ie:
main_module = lib/Foo/Bar.pm
=head2 license
This is the L<Software::License|Software::License> object for this dist's
license and copyright.
It will be created automatically, if possible, with the
C<copyright_holder> and C<copyright_year> attributes. If necessary, it will
try to guess the license from the POD of the dist's main module.
A better option is to set the C<license> name in the dist's config to something
understandable, like C<Perl_5>.
=head2 authors
This is an arrayref of author strings, like this:
[
'Ricardo Signes <rjbs@cpan.org>',
'X. Ample, Jr <example@example.biz>',
]
This is likely to change at some point in the near future.
=head2 files
This is an arrayref of objects implementing L<Dist::Zilla::Role::File> that
will, if left in this arrayref, be built into the dist.
Non-core code should avoid altering this arrayref, but sometimes there is not
other way to change the list of files. In the future, the representation used
for storing files B<will be changed>.
=head2 root
This is the root directory of the dist, as a L<Path::Class::Dir>. It will
nearly always be the current working directory in which C<dzil> was run.
=head2 is_trial
This attribute tells us whether or not the dist will be a trial release,
i.e. whether it has C<release_status> 'testing' or 'unstable'.
Do not set this directly, it will be derived from C<release_status>.
=head2 plugins
This is an arrayref of plugins that have been plugged into this Dist::Zilla
object.
Non-core code B<must not> alter this arrayref. Public access to this attribute
B<may go away> in the future.
=head2 distmeta
This is a hashref containing the metadata about this distribution that will be
stored in META.yml or META.json. You should not alter the metadata in this
hash; use a MetaProvider plugin instead.
=head2 prereqs
This is a L<Dist::Zilla::Prereqs> object, which is a thin layer atop
L<CPAN::Meta::Prereqs>, and describes the distribution's prerequisites.
=head2 logger
This attribute stores a L<Log::Dispatchouli::Proxy> object, used to log
messages. By default, a proxy to the dist's L<Chrome|Dist::Zilla::Chrome> is
taken.
The following methods are delegated from the Dist::Zilla object to the logger:
=over 4
=item *
log
=item *
log_debug
=item *
log_fatal
=back
=head1 METHODS
=head2 register_prereqs
Allows registration of prerequisites; delegates to
L<Dist::Zilla::Prereqs/register_prereqs> via our L</prereqs> attribute.
=head2 plugin_named
my $plugin = $zilla->plugin_named( $plugin_name );
=head2 plugins_with
my $roles = $zilla->plugins_with( -SomeRole );
This method returns an arrayref containing all the Dist::Zilla object's plugins
that perform the named role. If the given role name begins with a dash, the
dash is replaced with "Dist::Zilla::Role::"
=head2 find_files
my $files = $zilla->find_files( $finder_name );
This method will look for a
L<FileFinder|Dist::Zilla::Role::FileFinder>-performing plugin with the given
name and return the result of calling C<find_files> on it. If no plugin can be
found, an exception will be raised.
=head2 stash_named
my $stash = $zilla->stash_named( $name );
This method will return the stash with the given name, or undef if none exists.
It looks for a local stash (for this dist) first, then falls back to a global
stash (from the user's global configuration).
=head1 STABILITY PROMISE
None.
I will try not to break things within any major release. Minor releases are
not extensively tested before release. In major releases, anything goes,
although I will try to publish a complete list of known breaking changes in any
major release.
If Dist::Zilla was a tool, it would have yellow and black stripes and there
would be no L<UL
certification|https://en.wikipedia.org/wiki/UL_(safety_organization)> on it.
It is nasty, brutish, and large.
=head1 SUPPORT
There are usually people on C<irc.perl.org> in C<#distzilla>, even if they're
idling.
The L<Dist::Zilla website|http://dzil.org/> has several valuable resources for
learning to use Dist::Zilla.
There is a mailing list to discuss Dist::Zilla. You can L<join the
list|http://www.listbox.com/subscribe/?list_id=139292> or L<browse the
archives|http://listbox.com/member/archive/139292>.
=head1 SEE ALSO
=over 4
=item *
In the Dist::Zilla distribution:
=over 4
=item *
Plugin bundles:
L<@Basic|Dist::Zilla::PluginBundle::Basic>,
L<@Filter|Dist::Zilla::PluginBundle::Filter>.
=item *
Major plugins:
L<GatherDir|Dist::Zilla::Plugin::GatherDir>,
L<Prereqs|Dist::Zilla::Plugin::Prereqs>,
L<AutoPrereqs|Dist::Zilla::Plugin::AutoPrereqs>,
L<MetaYAML|Dist::Zilla::Plugin::MetaYAML>,
L<MetaJSON|Dist::Zilla::Plugin::MetaJSON>,
...
=back
=item *
On the CPAN:
=over 4
=item *
Search for plugins: L<https://metacpan.org/search?q=Dist::Zilla::Plugin::>
=item *
Search for plugin bundles: L<https://metacpan.org/search?q=Dist::Zilla::PluginBundle::>
=back
=back
=head1 AUTHOR
Ricardo SIGNES <rjbs@cpan.org>
=head1 CONTRIBUTORS
=for stopwords Ævar Arnfjörð Bjarmason Alexei Znamensky Alex Vandiver ambs Andrew Rodland Andy Jack Apocalypse ben hengst Bernardo Rechea Brian Fraser Caleb Cushing Christian Walde Christopher J. Madsen Chris Weyl Cory G Watson csjewell Curtis Brandt Dagfinn Ilmari Mannsåker Damien KRotkine Danijel Tasov Dave O'Neill Rolsky David E. Wheeler Golden H. Adler Steinbrunner Zurborg Davor Cubranic Dimitar Petrov Doug Bell Fayland Lam Florian Ragwitz Fred Moyer fREW Schmidt gardnerm Gianni Ceccarelli Graham Barr Knop Ollis Grzegorz Rożniecki Hans Dieter Pearcey Ivan Bessarabov Jakob Voss jantore Jérôme Quelin Jesse Luehrs Vincent John Napiorkowski Jonathan C. Otsuka Rockway Scott Duff Yu Karen Etheridge Kent Fredric Leon Timmermans Lucas Theisen Luc St-Louis Marcel Gruenauer Martin McGrath Mateu X Hunter Michael Jemmeson Mike Doherty Mohammad S Anwar Moritz Onken Neil Bowers Nickolay Platonov Nick Tonkin nperez Olivier Mengué Paul Cochrane Pedro Melo Philippe Bruhat (BooK) Randy Stauner robertkrimen Rob Hoelz Robin Smidsrød Shawn M Moore Smylers Steffen Schwigon Steven Haryanto Tatsuhiko Miyagawa Upasana Shukla Vyacheslav Matjukhin Yanick Champoux Yuval Kogman
=over 4
=item *
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
=item *
Alexei Znamensky <russoz@cpan.org>
=item *
Alex Vandiver <alexmv@mit.edu>
=item *
ambs <ambs@cpan.org>
=item *
Andrew Rodland <andrew@hbslabs.com>
=item *
Andy Jack <andyjack@cpan.org>
=item *
Apocalypse <APOCAL@cpan.org>
=item *
ben hengst <ben.hengst@gmail.com>
=item *
Bernardo Rechea <brbpub@gmail.com>
=item *
Brian Fraser <fraserbn@gmail.com>
=item *
Caleb Cushing <xenoterracide@gmail.com>
=item *
Christian Walde <walde.christian@googlemail.com>
=item *
Christopher J. Madsen <cjm@cjmweb.net>
=item *
Chris Weyl <cweyl@alumni.drew.edu>
=item *
Cory G Watson <gphat@onemogin.com>
=item *
csjewell <perl@csjewell.fastmail.us>
=item *
Curtis Brandt <curtisjbrandt@gmail.com>
=item *
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
=item *
Damien KRotkine <dkrotkine@booking.com>
=item *
Danijel Tasov <dt@korn.shell.la>
=item *
Dave O'Neill <dmo@dmo.ca>
=item *
Dave Rolsky <autarch@urth.org>
=item *
David E. Wheeler <david@justatheory.com>
=item *
David Golden <dagolden@cpan.org>
=item *
David H. Adler <dha@pobox.com>
=item *
David Steinbrunner <dsteinbrunner@pobox.com>
=item *
David Zurborg <port@david-zurb.org>
=item *
Davor Cubranic <cubranic@stat.ubc.ca>
=item *
Dimitar Petrov <mitakaa@gmail.com>
=item *
Doug Bell <madcityzen@gmail.com>
=item *
Fayland Lam <fayland@gmail.com>
=item *
Florian Ragwitz <rafl@debian.org>
=item *
Fred Moyer <fred@redhotpenguin.com>
=item *
fREW Schmidt <frioux@gmail.com>
=item *
gardnerm <gardnerm@gsicommerce.com>
=item *
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
=item *
Graham Barr <gbarr@pobox.com>
=item *
Graham Knop <haarg@haarg.org>
=item *
Graham Ollis <perl@wdlabs.com>
=item *
Graham Ollis <plicease@cpan.org>
=item *
Grzegorz Rożniecki <xaerxess@gmail.com>
=item *
Hans Dieter Pearcey <hdp@weftsoar.net>
=item *
Ivan Bessarabov <ivan@bessarabov.ru>
=item *
Jakob Voss <jakob@nichtich.de>
=item *
jantore <jantore@32k.org>
=item *
Jérôme Quelin <jquelin@gmail.com>
=item *
Jesse Luehrs <doy@tozt.net>
=item *
Jesse Vincent <jesse@bestpractical.com>
=item *
John Napiorkowski <jjnapiork@cpan.org>
=item *
Jonathan C. Otsuka <djgoku@gmail.com>
=item *
Jonathan Rockway <jrockway@cpan.org>
=item *
Jonathan Scott Duff <duff@pobox.com>
=item *
Jonathan Yu <jawnsy@cpan.org>
=item *
Karen Etheridge <ether@cpan.org>
=item *
Kent Fredric <kentfredric@gmail.com>
=item *
Leon Timmermans <fawaka@gmail.com>
=item *
Lucas Theisen <lucastheisen@pastdev.com>
=item *
Luc St-Louis <lucs@pobox.com>
=item *
Marcel Gruenauer <hanekomu@gmail.com>
=item *
Martin McGrath <mcgrath.martin@gmail.com>
=item *
Mateu X Hunter <hunter@missoula.org>
=item *
Michael Jemmeson <mjemmeson@cpan.org>
=item *
Mike Doherty <mike@mikedoherty.ca>
=item *
Mohammad S Anwar <mohammad.anwar@yahoo.com>
=item *
Moritz Onken <onken@netcubed.de>
=item *
Neil Bowers <neil@bowers.com>
=item *
Nickolay Platonov <nickolay@desktop.(none)>
=item *
Nick Tonkin <1nickt@users.noreply.github.com>
=item *
nperez <nperez@cpan.org>
=item *
Olivier Mengué <dolmen@cpan.org>
=item *
Paul Cochrane <paul@liekut.de>
=item *
Pedro Melo <melo@simplicidade.org>
=item *
Philippe Bruhat (BooK) <book@cpan.org>
=item *
Randy Stauner <rwstauner@cpan.org>
=item *
robertkrimen <robertkrimen@gmail.com>
=item *
Rob Hoelz <rob@hoelz.ro>
=item *
Robin Smidsrød <robin@smidsrod.no>
=item *
Shawn M Moore <sartak@gmail.com>
=item *
Smylers <Smylers@stripey.com>
=item *
Steffen Schwigon <ss5@renormalist.net>
=item *
Steven Haryanto <stevenharyanto@gmail.com>
=item *
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
=item *
Upasana Shukla <me@upasana.me>
=item *
Vyacheslav Matjukhin <mmcleric@yandex-team.ru>
=item *
Yanick Champoux <yanick@babyl.dyndns.org>
=item *
Yuval Kogman <nothingmuch@woobling.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|