Dist::Zilla

Post on 18-Jan-2015

4.416 views 1 download

Tags:

description

Dist::Zilla is a tool for writing less crap and more code when building CPAN distributions.

Transcript of Dist::Zilla

Dist::Zillaraaaaaaaaar!

you @ cpan . org

This talk is about your life as a CPAN author.

CPAN == Dists

The CPAN is just a bunch of dists (distributions).

YourApp-1.0.tar.gz isa Dist

and a distribution is just an archive file

dists contain files

~/code/YourApp$ find ../Changes./LICENSE./MANIFEST.SKIP./Makefile.PL./README./lib/YourApp.pm./lib/YourApp/Reticulator.pm./lib/YourApp/Util/mtfnpy.pm./lib/YourApp/Xyzzy.pm./t/unit-tests.t./t/pod-coverage.t./t/pod.t

this is all the crap in your working copy where you write this distmaking all these is a boring pain in the ass

being a dist author is hard!let’s go gemming!

Module::Starter

Module::StarterSUCKS!

only gets you to a starting point

can’t rebuild from templates post facto

can’t add files to your dist

no good for files that need to be rebuilt a lot

Module::Install

generates some files when running ‘make’

Makefile.PL

takes the usually short Makefile.PL

Makefile.PL

makes it slightly smaller

Module::Install

Module::InstallSUCKS!

relies on ExtUtils::MakeMaker

relies on ExtUtils::MakeMakerSUCKS

!

puts insane complexity on user’s computer

bundles scary, versioned code in the dist

when bugs are fixed, everybody re-releases

...to review...

writing code == fun

writing =head1 LICENSE

NOT FUN

Dist::Zillaraaaaaaaaar!

~/code/YourApp$ find ../Changes./LICENSE./MANIFEST.SKIP./Makefile.PL./README./lib/YourApp.pm./lib/YourApp/Reticulator.pm./lib/YourApp/Util/mtfnpy.pm./lib/YourApp/Xyzzy.pm./t/unit-tests.t./t/pod-coverage.t./t/pod.t

So, back to this list of files....

~/code/YourApp$ find .

./lib/YourApp.pm

./lib/YourApp/Reticulator.pm

./lib/YourApp/Util/mtfnpy.pm

./lib/YourApp/Xyzzy.pm

./t/unit-tests.t

Let’s get rid of all the crap

~/code/YourApp$ find .

dist.conf

./lib/YourApp.pm

./lib/YourApp/Reticulator.pm

./lib/YourApp/Util/mtfnpy.pm

./lib/YourApp/Xyzzy.pm

./t/unit-tests.t

and replace it with a little config for Dist::Zilla

package YourApp;

=head1 NAME

YourApp - my awesome app

=head1 VERSION

version 1.001

=cut

our $VERSION = 0.001;

=head1 DESCRIPTION

This app is awesome.

=head1 METHODS

=head2 this_method

This method does stuff.

=cut

method this_method { ... }

=head2 that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

Here’s a .pm file

package YourApp;

=head1 NAME

YourApp - my awesome app

=head1 VERSION

version 1.001

=cut

our $VERSION = 0.001;

=head1 DESCRIPTION

This app is awesome.

=head1 METHODS

=head2 this_method

This method does stuff.

=cut

method this_method { ... }

=head2 that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

The =name section is annoying.

package YourApp;# ABSTRACT: my awesome app

=head1 VERSION

version 1.001

=cut

our $VERSION = 0.001;

=head1 DESCRIPTION

This app is awesome.

=head1 METHODS

=head2 this_method

This method does stuff.

=cut

method this_method { ... }

=head2 that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

We’ll replace it with a comment.

package YourApp;# ABSTRACT: my awesome app

=head1 VERSION

version 1.001

=cut

our $VERSION = 0.001;

=head1 DESCRIPTION

This app is awesome.

=head1 METHODS

=head2 this_method

This method does stuff.

=cut

method this_method { ... }

=head2 that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

The =version section is redundant.

package YourApp;# ABSTRACT: my awesome app

our $VERSION = 0.001;

=head1 DESCRIPTION

This app is awesome.

=head1 METHODS

=head2 this_method

This method does stuff.

=cut

method this_method { ... }

=head2 that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

Drop it.

package YourApp;# ABSTRACT: my awesome app

our $VERSION = 0.001;

=head1 DESCRIPTION

This app is awesome.

=head1 METHODS

=head2 this_method

This method does stuff.

=cut

method this_method { ... }

=head2 that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

Even the $VERSION is redundant, since we want it constant across the dist.

package YourApp;# ABSTRACT: my awesome app

=head1 DESCRIPTION

This app is awesome.

=head1 METHODS

=head2 this_method

This method does stuff.

=cut

method this_method { ... }

=head2 that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

our overarching METHOD section is dumb

package YourApp;# ABSTRACT: my awesome app

=head1 DESCRIPTION

This app is awesome.

=method this_method

This method does stuff.

=cut

method this_method { ... }

=method that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

let’s just use =method for them all

package YourApp;# ABSTRACT: my awesome app

=head1 DESCRIPTION

This app is awesome.

=method this_method

This method does stuff.

=cut

method this_method { ... }

=method that_method

Also stuff.

method that_method { ... }

=head1 AUTHOR

Margo Yapp <myapp@example.com>

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

Repeating the author everywhere is annoying, too.

package YourApp;# ABSTRACT: my awesome app

=head1 DESCRIPTION

This app is awesome.

=method this_method

This method does stuff.

=cut

method this_method { ... }

=method that_method

Also stuff.

method that_method { ... }

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

Drop it, use author info found in DZ config.

package YourApp;# ABSTRACT: my awesome app

=head1 DESCRIPTION

This app is awesome.

=method this_method

This method does stuff.

=cut

method this_method { ... }

=method that_method

Also stuff.

method that_method { ... }

=head1 LICENSE

Copyright (C) 2008, Margo Yapp.

This is distributed under the terms of the accidental death and dismemberment license and if you redistribuet this document youwill be “accidentally” deathed or dismembered. You have been told.

=cut

1;

The license is gigantic! Ugh!

package YourApp;# ABSTRACT: my awesome app

=head1 DESCRIPTION

This app is awesome.

=method this_method

This method does stuff.

=cut

method this_method { ... }

=method that_method

Also stuff.

method that_method { ... }

1;

Drop it.

package YourApp;# ABSTRACT: my awesome app

=head1 DESCRIPTION

This app is awesome.

=method this_method

This method does stuff.

=cut

method this_method { ... }

=method that_method

Also stuff.

method that_method { ... }

1;

Now our file is simple, just the unique docs and code it needs. It fits on one legible slide!

package YourApp;# ABSTRACT: my awesome app

=head1 DESCRIPTION

This app is awesome.

=method this_method

This method does stuff.

=cut

method this_method { ... }

=method that_method

Also stuff.

method that_method { ... }

1;

And is about half Perl.

the CLI interface

dzil new

the CLI interface

dzil new

dzil test

the CLI interface

dzil new

dzil test

dzil build

the CLI interface

dzil new

dzil test

dzil build

dzil release

the CLI interface

CPAN::Uploader

Pod::Weaver

Pod::Eventual

Software::License

String::RewritePrefix

Config::INI::MVP::Reader

Mixin::Linewise

Data::Section

spin-off modules

String::Flogger Pod::Elemental

lots of spin-off modules

lots of prereqs

...but that’s okay...

dzil replaces “make dist”

...and the dist is boring

plain old Makefile.PL(or Build.PL)

users don’t notice that you used Dist::Zilla

they just notice how productive you are

Dist::Zillaraaaaaaaaar!