lcpan tips 003: Who depends on my modules?

About this series: a collection of short, daily blog posts about lcpan tips/recipes. Some posts will also end up in the upcoming App::lcpan::Manual::Cookbook POD to be included in the App-lcpan distribution.

About lcpan: an application to download and index a mini CPAN mirror on your local filesystem, so in effect you will have something like your own CPAN with a command-line tool (or perl API) to query and extract information from your mirror. I find it perfect for my own personal use when working offline.

When you maintain a module on CPAN, it’s good to know who (which other CPAN distributions) declares dependencies on your module so when you update your module, you can test your downstreams to find out whether you break them. Or perhaps you just want to know “how popular” or “how important” your module is by looking at how many people are using your modules (although actually this only gives a partial picture because people can use your modules in their scripts or private modules, and they won’t be listed here).

This information is available on MetaCPAN by clicking on the “Reverse dependencies” link. Example for one of my modules. But you can also use lcpan rdeps to view this information, with some options available.

% lcpan rdeps Color::ANSI::Util
+---------+----------+------------------------------------------+-----------+--------------+-------------+
| phase   | rel      | dist                                     | author    | dist_version | req_version |
+---------+----------+------------------------------------------+-----------+--------------+-------------+
| runtime | requires | App-256colors                            | CALID     | 0.001        | 0           |
| runtime | requires | App-riap                                 | PERLANCAR | 0.34         | 0           |
| runtime | requires | Color-Theme                              | PERLANCAR | 0.01         | 0           |
| runtime | requires | Games-ArrangeNumber                      | PERLANCAR | 0.05         | 0           |
| runtime | requires | Perinci-Result-Format                    | PERLANCAR | 0.45         | 0           |
| runtime | requires | Progress-Any-Output-TermProgressBarColor | PERLANCAR | 0.21         | 0           |
+---------+----------+------------------------------------------+-----------+--------------+-------------+

To show more than one level of information (e.g. you want to know your downstreams’ downstreams, and so on), use the -l (--level) option or -R.

To show only certain phases or relationship, use the options --phase and --rel respectively. For example, to show which dists declare an optional (rel=recommends) runtime dependency of my module App::lcpan::Call:

% lcpan rdeps --phase runtime --rel recommends App::lcpan::Call
+-------------------+-----------+--------------+-------------+
| dist              | author    | dist_version | req_version |
+-------------------+-----------+--------------+-------------+
| App-GamesWordlist | PERLANCAR | 0.15         | 0           |
| App-wordlist      | PERLANCAR | 0.20         | 0           |
+-------------------+-----------+--------------+-------------+

There’s also another subcommand author-rdeps which shows you downstream dists for all of your modules. For example, to list all other people who are using my modules:

% lcpan author-rdeps PERLANCAR --user-author-isnt PERLANCAR --user-author-isnt SHARYANTO
+---------+------------+---------------------------------------------+---------------------------------------------------+-----------+--------------+-------------+
| phase   | rel        | module                                      | dist                                              | author    | dist_version | req_version |
+---------+------------+---------------------------------------------+---------------------------------------------------+-----------+--------------+-------------+
| develop | requires   | Pod::Weaver::Section::Source::DefaultGitHub | Acme-Resume                                       | CSSON     | 0.0102       | 0           |
| runtime | requires   | Color::ANSI::Util                           | App-256colors                                     | CALID     | 0.001        | 0           |
| runtime | requires   | Web::Detect                                 | App-Kit                                           | DMUEY     | 0.62         | 0           |
| runtime | requires   | JSON::Color                                 | App-LJ                                            | SONGMU    | 0.02         | 0           |
...
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s