App-prepare4release

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for App::prepare4release

0.03    2026-04-05
        Fix Makefile.PL PREPARE4RELEASE postamble replacement: _replace_marked_postamble_block
        used s/// with the /x flag, which ignored spaces in the pattern and treated # as
        a comment, so lines like "# BEGIN PREPARE4RELEASE_POSTAMBLE" never matched and
        pod2markdown was not upgraded to pod2github under --github/--gitlab. Use a
        single-line pattern with ms only (no /x). _patch_meta_merge_block: log "patched
        existing META_MERGE" only when content actually changes.
        Tests: t/postamble-crlf.t (CRLF + LF + realistic Makefile.PL fragment).

0.02    2026-04-05
        Invalid prepare4release.json: warn and treat as {} (no fatal decode).
        Root JSON keys copied into Makefile.PL WriteMakefile: author, abstract,
        abstract_from, license, min_perl_version / perl_min, module_name / name,
        version_from, exe_files (array).
        New App::prepare4release::Deps: static scan of lib/, bin/, maint/, t/ (optional
        xt/) for use/require; optional --sync-deps / dependencies.sync merges missing
        modules into PREREQ_PM and TEST_REQUIRES; appends requires/test_requires to
        cpanfile when present (dependencies.sync_cpanfile, dependencies.skip,

README.md  view on Meta::CPAN

- Scans `lib/`, `bin/`, `maint/`, `t/`, and optionally `xt/` for `use` /
`require` and compares with `PREREQ_PM` / `TEST_REQUIRES` in `Makefile.PL`.
Core modules for the target minimum Perl are skipped unless a minimum module
version is given on the `use` line (see [Module::CoreList](https://metacpan.org/pod/Module%3A%3ACoreList)). By default only a
warning is printed; `--sync-deps` or `dependencies.sync` in
`prepare4release.json` updates `Makefile.PL` and appends to `cpanfile` when
present. `dependencies.skip` disables the check.

# README badge injector (`maint/inject-readme-badges.pl`)

The `MY::postamble` fragment cannot hold large, self-contained Perl _sub_s:
`ExtUtils::MakeMaker` expects that section to expand into Makefile rules, and
keeping badge logic only in `Makefile.PL` would either duplicate a lot of text
or imply loading this distribution at `make README.md` time. Instead,
`prepare4release` writes `maint/inject-readme-badges.pl`, a small, generated
program (core modules only) that strips prior shield lines and inserts the
frozen Markdown block computed on the last run (same flags as `--github` /
`--gitlab` / `--cpan`). Downstream distributions should _commit_ that file
with the rest of the tree so `make README.md` works in a clean clone and the
file is included in the CPAN tarball like any other tracked asset. Re-run
`prepare4release` after changing repository URLs, license, or badge-related

lib/App/prepare4release.pm  view on Meta::CPAN

	open my $out, '>:encoding(UTF-8)', $path
		or croak "Cannot write '$path': $!";
	print {$out} $text;
	close $out;
	chmod 0755, $path or warn "[prepare4release] chmod 0755 '$path': $!\n";
	warn "[prepare4release] wrote $rel (standalone README badge injector)\n"
		if $verbose;
	return;
}

# Makefile fragment: pod2* then inject README shields via generated script (no App::pm dep).
sub _postamble_block {
	my ( $class, $opts ) = @_;
	$opts = {} unless ref $opts eq 'HASH';
	my $tab = "\t";
	my $want_pod2github = $opts->{github} || $opts->{gitlab};
	my $pod_cmd         = $want_pod2github ? 'pod2github' : 'pod2markdown';
	my $inj             = $class->inject_readme_badges_relpath;

	return <<"EOF";
# BEGIN PREPARE4RELEASE_POSTAMBLE

lib/App/prepare4release.pm  view on Meta::CPAN

Core modules for the target minimum Perl are skipped unless a minimum module
version is given on the C<use> line (see L<Module::CoreList>). By default only a
warning is printed; C<--sync-deps> or C<dependencies.sync> in
F<prepare4release.json> updates F<Makefile.PL> and appends to F<cpanfile> when
present. C<dependencies.skip> disables the check.

=back

=head1 README badge injector (F<maint/inject-readme-badges.pl>)

The C<MY::postamble> fragment cannot hold large, self-contained Perl I<sub>s:
C<ExtUtils::MakeMaker> expects that section to expand into Makefile rules, and
keeping badge logic only in F<Makefile.PL> would either duplicate a lot of text
or imply loading this distribution at C<make README.md> time. Instead,
C<prepare4release> writes F<maint/inject-readme-badges.pl>, a small, generated
program (core modules only) that strips prior shield lines and inserts the
frozen Markdown block computed on the last run (same flags as C<--github> /
C<--gitlab> / C<--cpan>). Downstream distributions should I<commit> that file
with the rest of the tree so C<make README.md> works in a clean clone and the
file is included in the CPAN tarball like any other tracked asset. Re-run
C<prepare4release> after changing repository URLs, license, or badge-related

t/postamble-crlf.t  view on Meta::CPAN


	my $new = App::prepare4release->ensure_postamble(
		$lf,
		{ github => 1, gitlab => 0, cpan => 0 },
		0
	);
	like( $new, qr/pod2github\b/, 'LF: PREPARE4RELEASE block replaced (pod2github)' );
	unlike( $new, qr/pod2markdown\b/, 'LF: not left on pod2markdown' );
}

# Realistic fragment: pod2markdown in heredoc must become pod2github when --github.
{
	my $lf = <<'MAKEFILE';
# BEGIN PREPARE4RELEASE_POSTAMBLE
sub MY::postamble {
  return '' if !-e '.git';
  <<'PREPARE4RELEASE_POD2README';
pure_all :: README.md

README.md : $(VERSION_FROM)
	pod2markdown $< $@



( run in 1.368 second using v1.01-cache-2.11-cpan-b16cb0d3907 )