简体   繁体   English

如何将 Perl 模块发布到 CPAN?

[英]How do I release a Perl module to CPAN?

I need to create a CPAN module, but I don't know where to start or how to do that.我需要创建一个 CPAN 模块,但我不知道从哪里开始或如何做。 I've already written my modules in Perl, but I don't know how to continue.我已经用 Perl 编写了我的模块,但我不知道如何继续。 Could anyone help?有人可以帮忙吗?

You need to do two main things before you can get started.在开始之前,您需要做两件主要的事情。

First of all, you need to create a PAUSE account .首先,您需要创建一个PAUSE 帐户 PAUSE is the service that maintains what goes into CPAN. PAUSE 是维护进入 CPAN 的服务。 It's a bit dated, but start here and read through it.它有点过时了,但从这里开始并通读它。 It boils down to choosing a name, creating an account and waiting to be approved.归结为选择名称、创建帐户并等待批准。

Next you have to decide how to package up your module.接下来,您必须决定如何打包您的模块。 You can choose from various tools, or build your distribution yourself.您可以从各种工具中进行选择,也可以自己构建发行版。

  • perlnewmod explains this a little, and suggests Module::Starter , which is a very bare-bones tool. perlnewmod对此进行了一些解释,并建议Module::Starter ,这是一个非常简单的工具。
  • Dist::Zilla is a very large distribution builder with a lot of plugins that do things like create docs and run various tests for you, automatically list down who contributed to your code via your git, and a host of other things. Dist::Zilla是一个非常大的发行版构建器,它有很多插件,可以为你创建文档和运行各种测试,自动列出谁通过你的 git 对你的代码做出了贡献,以及许多其他事情。 There are also a few tools in the middle.中间还有一些工具。
  • I often use Minilla , which makes a new module scaffold, runs your tests, creates a dist and uploads it to CPAN, but nothing else.我经常使用Minilla ,它制作一个新的模块脚手架,运行你的测试,创建一个 dist 并将它上传到 CPAN,但没有别的。

You might also want to read the SEE ALSO section on each of the ones I've linked.您可能还想阅读有关我链接的每个部分的另见部分。 They point to each other.他们互相指指点点。 Have a play around, and pick the one that speaks to you.玩一玩,然后选择与您交谈的那个。

Then you have to chose a name for your distribution .然后您必须为您的发行版选择一个名称 There is some guidance on this in the PAUSE page I linked above.在我上面链接的 PAUSE 页面中有一些关于此的指导。

Make sure to include useful documentation, write tests, and put your code on github.确保包含有用的文档、编写测试并将代码放在 github 上。 Put that into the meta data file .将其放入元数据文件中

Finally, you bundle it, and then upload it to PAUSE.最后,您将其打包,然后将其上传到 PAUSE。 The bundle is a tarbal with a specific name.捆绑包是具有特定名称的 tarbal。 You can create that manually or with one of the above-mentioned tools.您可以手动或使用上述工具之一进行创建。

Uploading can be done manually through the website, with a command line tool like cpan-upload , or with the bundler if it includes that feature.上传可以通过网站手动完成,使用像cpan-upload这样的命令行工具,或者使用打包器(如果它包含该功能)。 After a while you get an email from PAUSE that tells you it's there and waiting for indexing ( CPAN Upload: ... ), and then it shows up on metacpan.org .过了一会儿,你会收到一封来自 PAUSE 的电子邮件,告诉你它在那里等待索引( CPAN Upload: ... ),然后它显示在metacpan.org 上 You'll get another email from PAUSE ( PAUSE Indexer report ... ) telling you when it's ready.您会从 PAUSE 收到另一封电子邮件( PAUSE Indexer report ... ),告诉您何时准备就绪。

After some more time, you might get emails from CPAN testers , which smoke tests all new uploads against a multitude of platforms.再过一段时间,您可能会收到来自CPAN 测试人员的电子邮件,他们会针对多种平台对所有新上传的内容进行冒烟测试。 Sometimes stuff breaks, and you'll hear about it.有时东西坏了,你会听到它。 This is why having good tests is important.这就是为什么进行良好的测试很重要。

Here are some additional resources:以下是一些额外的资源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM