=head1 NAME Dist::Mgr - Automation for Perl distribution creation, integration, pre-release, release and post-release tasks. =for html Coverage Status =head1 DESCRIPTION For end-users, please review the L for the L program that we've installed for you as part of this distribution. This software performs a full suite of automated creation, addition, pre-release, release and post release tasks for Perl distributions. It integrates with VCS, automates the configuration of Continuous Integration, manages version numbers and Changes files, amongst a slew of other tasks. This distribution is essentially a bunch of tools that revolve around a base distribution created with C. At this time, it relies on using L for initial distribution creation, Github for repository and bugtracker, and the L build system, which utilizes C files. =head1 SYNOPSIS use Dist::Mgr qw(:all) ... =head1 EXPORT_OK We do not automatically import anything into your namespace, you must request functionality explicitly. Use the C<:all> tag, or have a peruse through the L section for what's available. =head1 FUNCTIONS =head2 add_bugtracker Adds bugtracker information to the C file. If the required C section doesn't exist, we'll create it. Currently, only Github is supported. I: After L, or any time. I: $author I: The Github username of the software author. For example, mine is C. $repository I: The name of the repository. For example, the repository name for this distribution is C. $makefile I: The path and name of the C file to use. We default to C<./Makefile.PL>. I: C<0> upon success. =head2 add_repository Adds repository information to the C file. If the required C section doesn't exist, we'll create it. Currently, only Github is supported. I: After L, or any time. I: $author I: The Github username of the software author. For example, mine is C. $repository I: The name of the repository. For example, the repository name for this distribution is C. $makefile I: The path and name of the C file to use. We default to C<./Makefile.PL>. I: C<0> upon success. =head2 changes Creates or updates the initial L C file to my custom standard format. I: After L. I: $module I: The name of the module (eg. C). $file I: The path and name of the C file to operate on. By default, we operate on the C file within the current working directory, C<.>. I The contents that were added into the file. =head2 changes_bump Prepares the C file for a new development cycle after a release. I: After L and the release has been published. I: $version I: A valid Perl version number. Must be higher than the previous release version. $file I: The name of the C file to operate on. Defaults to the one in the current working directory. =head2 changes_date Replaces the C tag with today's date, in preparation of a release. I: As part of the release cycle, before release and L. I: $file I: The name of the C file to operate on. By default, we operate on the one in the current working directory. =head2 ci_badges Inserts various CI and coverage badges into module files. I: After L, or any time. I: $author I: The repository owner (eg. mine is 'stevieb9'). $repository I: The name of the repository (eg. this one is 'dist-mgr'). $fs_entry I: The path and name of a Perl module file, or a directory that contains Perl module files. If a directory is sent in, we'll operate recursively. I: C<0> upon success. =head2 ci_github Installs a Github Actions configuration file into C<.github/workflows>. We'll create the directory if it doesn't exist. I: Any time. I: $os I: A list of the Operating Systems you want to run your tests on. I: C, C, C, where: l == Linux (Ubuntu to be specific) w == Windows m == MacOS I: Test suite will be run on Operating Systems C, C, C. Each OS will run the tests on Perls C<5.32>, C<5.24>, C<5.18>, C<5.14> and C<5.10>. I: An array of the contents of the generated file. =head2 config Writes out a default configuration file if one doesn't exist, and updates the C<%args> hash within a function. I: \%args I: Send in a reference to your C<%args> hash, and we'll update it with any directives within the configuration file before you send them off to other various routines. $file I: The name of an alternate configuration file you'd like to write out, or read from. Default is C<$ENV{USERPROFILE}/dist-mgr.json> on Windows systems, and C<$ENV{HOME}/dist-mgr.json> on Unix systems. I: The reference to the C<%args> hash you sent in as the first parameter. =head2 config_file Returns the path and filename of the default configuration file. this is C<$ENV{USERPROFILE}/dist-mgr.json> on Windows systems, and C<$ENV{HOME}/dist-mgr.json> on Unix systems. =head2 copyright_bump Finds and updates the copyright year of a Perl POD or module file, or all Perl files in a directory structure. We operate on all C<*.pl>, C<*.pm> and C<*.pod> files. I: Before publishing a release. I: $fs_entry I: The name of a file or directory to work on. If a directory, we'll work on all Perl and POD files. Defaults to C<.>. I: A hash reference with the file name as the key, and the updated year as the value. =head2 copyright_info Fetches the current copyright year in a file or all files in a directory. We operate on all C<*.pl>, C<*.pm> and C<*.pod> files. I: Anytime. I: $fs_entry I: The name of a file or directory to work on. If a directory, we'll work on all Perl and POD files. Defaults to C<.>. I: A hash reference with the file name as the key, and the current copyright year as the value. =head2 cpan_upload Uploads the distribution tarball to PAUSE. I: After L. I: $tarball_name I: The name of the distribution's tarball file. %args I: See L for full details. A couple of notes: =over =item The C and C parameters can be set in the C and C environment variables instead of passing them in with the hash. =item You can add C<< dry_run => 1 >> to the hash to skip the actual upload process. =back I: Copy of C<%args> hash on success. =head2 git_add Adds all files in the current working directory to the repository. B: Calls C internally. I: Any time. I: $verbose I: Set to true to display the Git command output. Defaults to false. I: Exit code from the C call. =head2 git_ignore Generates a C<.gitignore> file. I: Any time. I: $directory I: The directory where we'll create the file. If not specified, we'll create it in the current directory, C<.>. I: An array of the file's contents. =head2 git_commit Commits all changes to the repository. B: Calls C internally. I: Any time. I: $msg I: The commit message. $verbose I: Set to true to display the Git command output. Defaults to false. I: Exit code. =head2 git_clone Commits all changes to the repository. B: Calls C internally. I: Any time. I: $author I: Your Github username. $repository I: The name of the pre-created Github repository. $verbose I: Set to true to display the Git command output. Defaults to false. I: Exit code. =head2 git_push Pushes the repository to Github. B: Calls C internally. I: Any time. I: $verbose I: Set to true to display the Git command output. Defaults to false. I: Exit code. =head2 git_pull Does a C to fetch any update from the upstream. B: Calls C internally. I: Any time. I: $verbose I: Set to true to display the Git command output. Defaults to false. I: Exit code. =head2 git_release Commits and pushes the repository, and executes the CI test pipeline (if available). Internally, this method calls L, L then L, all with their respective C<$verbose> flags set to false. If you want to enable verbosity, instead of calling this function, call each one of those in order and set C<$verbose> to true in each one. I: After L. I: $version I: The release version of the distribution. $wait_for_ci I: Whether to wait for keyboard interaction while CI testing runs. If set, we'll wait for you to press either C to signifiy tests were successful and we should continue with the release cycle, or C to signify that we should stop and wait for you to fix any test errors before running again. I: C<1>, Enabled. I: C<1> on test success (CTRL-C), C<0> on test failure (ENTER). =head2 git_repo Attempts to retrieve the repository name from the C<.git> directory. B: Calls C internally. I: Any time. I: The string repository name on success, the exit code on failure. =head2 git_status_differs Checks whether we need to commit and push. B: Calls C internally. I: Any time. I: C<1> if the repository differs and C<0> if nothing needs to be done. =head2 git_tag Tags the current state of the repository. I: $tag I: The tag for the commit. B: Calls C internally. I: Any time. I: Exit code. =head2 init Initializes a new distribution using L. The new directory will be placed into the current working directory (C<.>). I: To create a brand new distribution skeleton. I: module => "Acme::STEVEB" I: The name of the main module of the distribution. author => "Steve Bertrand" I: The name of the distribution's author. email => "steveb@cpan.org" I: The email address of the author. license => "artistic2" I: The license to apply to the new distribution. Defaults to C. See L for valid entries. verbose => 1 I: If set, we'll display the progress of module creation. =head2 make_dist Perform a C that creates a CPAN-ready distribution tarball file in the current working directory. I: After all other release functions have been called. I: $verbose I: Set to true to display the output from the command. I: False I: C<0> on success. Anything other than C<0> is a failure. =head2 make_distclean Perform a C on the project directory. I: After all other post-release functions have been called. I: $verbose I: Set to true to display the output from the command. I: False I: C<0> on success. Anything other than C<0> is a failure. =head2 make_test Perform a C<%^X Makefile.PL> and C. I: After L and before all other release cycle functions. I: $verbose I: Set to true to display the output from the command. I: False B: Do not call this function from within the test suite, or else it'll spin off into an infinite loop. B: Always check the return value of this function before proceeding with the rest of the release cycle. Zero C<0> is success, everything else is fail. I: C<0> on success. Anything other than C<0> is a failure. =head2 make_manifest Perform a C. I: Before running the release procedures. I: $verbose I: Set to true to display the output from the command. I: False I: C<0> on success. Anything other than C<0> is a failure. =head2 manifest_skip Generates a C file. I: Any time. I: $directory I: The directory where we'll create the file. If not specified, we'll create it in the current directory, C<.>. I: An array of the file's contents. =head2 manifest_t Generates a C test file. This overrides the default created with L, as some custom C entries fail with the older version of the file. I: Any time. I: $directory I: The directory where we'll create the file. If not specified, we'll create it in the C directory within the current directory, C<.>. I: An array of the file's contents. =head2 move_distribution_files After an L, this method will scoop up all of the files and directories from within the newly created temp module directory into the current working dir, then remove the temp module directory. I: Immediately after L. I: $module I: The name of the module that was created with L, eg. C. I: C<0> upon success. =head2 remove_unwanted_files Removes unwanted file system entries. We always operate from the perspective of the current working directory (C<.>). I: Immediately after L and L. =head2 version_bump Finds and updates the version number of a Perl module file, or all Perl module files in a directory structure. I: After publishing a release. I: $version I: The new version to update to. $fs_entry I: The name of a file or directory to work on. If a directory, we'll work on all Perl module files. Defaults to C. =head3 Dry run mode The C<$version> parameter can be prepended with an optional dash (C<->), and if so, we'll operate in "dry-run" mode, where we'll return the results, but won't have written to any files. Eg: C. I: An HoH: $VAR1 = { 't/data/work/Two.pm' => { 'dry_run' => 0, 'from' => '2.66', 'to' => '2.67', 'content' => '' # Module file code (snipped for brevity) }, 't/data/work/One.pm' => { 'dry_run' => 0, 'from' => '2.66', 'to' => '2.67', 'content' => '' # Module file code (snipped for brevity) }, }; =head2 version_incr Increments a version number by C<0.01>, and returns the result. I: Any time I: $version I: A valid version number (eg: C<1.03>). I: The supplied version number incremented by C<0.01>. =head2 version_info Fetches the file version information of Perl module files. Can operate on a single file, or iterate over a directory structure. I: Any time. I: $fs_entry I: The directory or file to operate on. If a directory is sent in, we'll iterate over all files in all directories recursively. I: C I: Hash reference: $VAR1 = { 't/data/orig/One.pm' => '2.66' 't/data/orig/Two.pm' => '2.66', 't/data/orig/Three.pm' => '2.66', 't/data/orig/Bad.pm' => undef, # $VERSION can't be parsed 't/data/orig/No.pm' => undef, # No $VERSION defined }; =head1 AUTHOR Steve Bertrand, C<< >> =head1 LICENSE AND COPYRIGHT Copyright 2020-2021 Steve Bertrand. This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at: L