App-CPANMetaUtils

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- No functional changes.

	- Use JSON::MaybeXS in all instances, remove dependency on JSON.

	- Tweak Abstract for gen-cpan-meta.


0.007   2017-03-04  Released-By: PERLANCAR

	- [Incompatible] Merge
	  validate-cpan-meta-with-{sah,cpan-meta-validator} into
	  validate-cpan-meta.


0.006   2017-03-03  Released-By: PERLANCAR

        - Add utility: convert-cpan-meta.


0.005   2017-03-03  Released-By: PERLANCAR

	- Tweak Rinci metadata.

	- [Bugfix] gen-cpan-meta: We haven't validated the generated CPAN
	  META.


0.004   2017-03-02  Released-By: PERLANCAR

        - Add utility: gen-cpan-meta.


0.003   2017-03-02  Released-By: PERLANCAR

	- [Incompatible] Rename dist from App-ValidateCPANMetaWithSah to
	  App-CPANMetaUtils.

        - Add script: validate-cpan-meta-with-cpan-meta-validator.

        - [ux] When file is not specified, look at current dir's
          META.json/META.yml.


0.002   2017-01-08  Released-By: PERLANCAR

	- No functional changes.

	- [doc] Mention CPAN::Meta, CPAN::Meta::Validator.

MANIFEST  view on Meta::CPAN

LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
dist.ini
lib/App/CPANMetaUtils.pm
script/convert-cpan-meta
script/gen-cpan-meta
script/validate-cpan-meta
t/00-compile.t
t/author-critic.t
t/author-pod-coverage.t
t/author-pod-syntax.t
t/release-rinci.t
weaver.ini

Makefile.PL  view on Meta::CPAN

my %WriteMakefileArgs = (
  "ABSTRACT" => "CLI utilities related to CPAN Meta",
  "AUTHOR" => "perlancar <perlancar\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "App-CPANMetaUtils",
  "EXE_FILES" => [
    "script/convert-cpan-meta",
    "script/gen-cpan-meta",
    "script/validate-cpan-meta"
  ],
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.010001",
  "NAME" => "App::CPANMetaUtils",
  "PREREQ_PM" => {
    "App::ScanPrereqs" => 0,
    "CPAN::Meta::Converter" => 0,
    "CPAN::Meta::Validator" => 0,
    "Data::Sah" => "0.907",
    "ExtUtils::MakeMaker" => 0,

README  view on Meta::CPAN

    This document describes version 0.011 of App::CPANMetaUtils (from Perl
    distribution App-CPANMetaUtils), released on 2020-08-27.

DESCRIPTION
    This distribution contains CLI utilities related to CPAN Meta:

    *   convert-cpan-meta

    *   gen-cpan-meta

    *   validate-cpan-meta

HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/App-CPANMetaUtils>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-App-CPANMetaUtils>.

BUGS

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

=head1 DESCRIPTION

This distribution contains CLI utilities related to CPAN Meta:

=over

=item * L<convert-cpan-meta>

=item * L<gen-cpan-meta>

=item * L<validate-cpan-meta>

=back

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-CPANMetaUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-CPANMetaUtils>.

script/gen-cpan-meta  view on Meta::CPAN

    v => 1.1,
    summary => 'Generate CPAN META for a distribution',
    description => <<'_',

NOTE: EARLY VERSION.

This utility assumes it is run in the top-level directory of a Perl distribution
and will try to generate a CPAN META structure for the distribution. For
example: `abstract` will be searched from POD, `name` from the shortest package
name, `version` from the main module, `prereqs` using <pm:App::ScanPrereqs> and
so on. Finally it will validate its generated META.json first before outputing
it, printing found errors to stderr.

This utility can be used to generate (at least the preliminary version of)
`META.json` for Perl distributions that do not yet have `META.json`. It is
usually not useful for distributions that use a distribution builder tool like
<pm:Dist::Zilla>, because in that case the tool will generate `META.json` for
you.

_
    args => {

script/gen-cpan-meta  view on Meta::CPAN


    # release_status (assumed to be stable)
    {
        $meta->{release_status} = 'stable';
    }

    # XXX resources

    # XXX x_authority?

    # let's validate it first
    {
        my $cmv = CPAN::Meta::Validator->new($meta);
        unless ($cmv->is_valid) {
            print "WARN: Error from validator: $_\n" for $cmv->errors;
        }
    }

    [200, "OK", JSON::MaybeXS->new->canonical(1)->pretty->encode($meta)];
}

script/gen-cpan-meta  view on Meta::CPAN

     [--no-env] [--page-result[=program]] [dir]

=head1 DESCRIPTION

NOTE: EARLY VERSION.

This utility assumes it is run in the top-level directory of a Perl distribution
and will try to generate a CPAN META structure for the distribution. For
example: C<abstract> will be searched from POD, C<name> from the shortest package
name, C<version> from the main module, C<prereqs> using L<App::ScanPrereqs> and
so on. Finally it will validate its generated META.json first before outputing
it, printing found errors to stderr.

This utility can be used to generate (at least the preliminary version of)
C<META.json> for Perl distributions that do not yet have C<META.json>. It is
usually not useful for distributions that use a distribution builder tool like
L<Dist::Zilla>, because in that case the tool will generate C<META.json> for
you.

=head1 OPTIONS

script/validate-cpan-meta  view on Meta::CPAN

our $VERSION = '0.011'; # VERSION

use 5.010001;
use strict;
use warnings;

use Perinci::CmdLine::Any;

our %SPEC;

$SPEC{validate_cpan_meta} = {
    v => 1.1,
    summary => 'Validate CPAN META',
    description => <<'_',

This utility can check your CPAN META file using one of the available methods.

_
    args => {
        file => {
            schema => 'filename*',

script/validate-cpan-meta  view on Meta::CPAN

            description => <<'_',

`cmv` (which is the default) means to use <pm:CPAN::Meta::Validator> which is
the "official way". Another alternative is to use <pm:Data::Sah> and the schema
<pm:Sah::Schema::cpan::meta20>.

_
        },
    },
};
sub validate_cpan_meta {
    require File::Slurper;

    my %args = @_;
    my $method = $args{method} // 'cmv';
    my $file = $args{file};
    unless (defined $file) {
        if (-f "META.json") {
            $file = "META.json";
        } elsif (-f "META.yml") {
            $file = "META.yml";

script/validate-cpan-meta  view on Meta::CPAN

            for my $loc (sort keys %{ $raw_res->{warnings} }) {
                warn "WARN: $raw_res->{warnings}{$loc}\n";
            }
        }
    } else {
        return [400, "Unknown method '$method'"];
    }

    [
        $is_error ? 400:200,
        $is_error ? "Does not validate":"Validates",
        undef,
        {
            ("func.raw"=>$raw_res) x !!defined($raw_res),
        },
    ];
}

Perinci::CmdLine::Any->new(
        url => '/main/validate_cpan_meta',
)->run;

# ABSTRACT: Validate CPAN META
# PODNAME: validate-cpan-meta

__END__

=pod

=encoding UTF-8

=head1 NAME

validate-cpan-meta - Validate CPAN META

=head1 VERSION

This document describes version 0.011 of validate-cpan-meta (from Perl distribution App-CPANMetaUtils), released on 2020-08-27.

=head1 SYNOPSIS

 % validate-cpan-meta path/to/META.json; # or path/to/META.yml
 % validate-cpan-meta path/to/META.json --method sah ;# use Sah schema instead of CPAN::Meta::Validator to validate

=head1 DESCRIPTION

This utility can check your CPAN META file using one of the available methods.

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

script/validate-cpan-meta  view on Meta::CPAN


=head1 COMPLETION

This script has shell tab completion capability with support for several
shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C validate-cpan-meta validate-cpan-meta

in your bash startup (e.g. F<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete validate-cpan-meta 'p/*/`validate-cpan-meta`/'

in your tcsh startup (e.g. F<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is also recommended to install L<shcompgen> (see above).

=head2 other shells

For fish and zsh, install L<shcompgen> as described above.

=head1 CONFIGURATION FILE

This script can read configuration files. Configuration files are in the format of L<IOD>, which is basically INI with some extra features.

By default, these names are searched for configuration filenames (can be changed using C<--config-path>): F<~/.config/validate-cpan-meta.conf>, F<~/validate-cpan-meta.conf>, or F</etc/validate-cpan-meta.conf>.

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

Finally, you can filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOME...

script/validate-cpan-meta  view on Meta::CPAN

 naked_res (see --naked-res)

=head1 ENVIRONMENT

=head2 VALIDATE_CPAN_META_OPT => str

Specify additional command-line options.

=head1 FILES

F<~/.config/validate-cpan-meta.conf>

F<~/validate-cpan-meta.conf>

F</etc/validate-cpan-meta.conf>

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-CPANMetaUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-CPANMetaUtils>.

=head1 BUGS

t/00-compile.t  view on Meta::CPAN


plan tests => 4 + ($ENV{AUTHOR_TESTING} ? 1 : 0);

my @module_files = (
    'App/CPANMetaUtils.pm'
);

my @scripts = (
    'script/convert-cpan-meta',
    'script/gen-cpan-meta',
    'script/validate-cpan-meta'
);

# no fake home requested

my @switches = (
    -d 'blib' ? '-Mblib' : '-Ilib',
);

use File::Spec;
use IPC::Open3;

t/author-critic.t  view on Meta::CPAN

}


use strict;
use warnings;

# this test was generated with Dist::Zilla::Plugin::Test::Perl::Critic::Subset 3.001.005

use Test::Perl::Critic (-profile => "") x!! -e "";

my $filenames = ['lib/App/CPANMetaUtils.pm','script/convert-cpan-meta','script/gen-cpan-meta','script/validate-cpan-meta'];
unless ($filenames && @$filenames) {
    $filenames = -d "blib" ? ["blib"] : ["lib"];
}

all_critic_ok(@$filenames);



( run in 0.802 second using v1.01-cache-2.11-cpan-a5abf4f5562 )