UNPKG

@twyr/announce

Version:

CLI Tool and NPM Library for announcing a release on Github / Gitlab / etc. and on NPM

802 lines (797 loc) 28 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>ReleaseCommandClass - Announce CLI - API Reference</title> <meta name="description" content="Announce CLI - API Reference" /> <meta name="keywords" content="automation announce changelog cli console git github gitlab npm package publish release release-automation release-helper release-workflow semantic-release semantic-version semver semver-release terminal twyr version" /> <meta name="keyword" content="automation announce changelog cli console git github gitlab npm package publish release release-automation release-helper release-workflow semantic-release semantic-version semver semver-release terminal twyr version" /> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <script src="scripts/nav.js" defer></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav class="wrap"> <input type="text" id="nav-search" placeholder="Search" /> <h2><a href="index.html">Home</a></h2> <h2><a href="https://github.com/twyr/announce" target="_blank" class="menu-item" id="github_link">GitHub</a></h2> <h3>Classes</h3> <ul> <li><a href="GitHubWrapper.html">GitHubWrapper</a> <ul class='methods'> <li data-type='method'><a href="GitHubWrapper.html#_fetchData">_fetchData</a></li> <li data-type='method'><a href="GitHubWrapper.html#createRelease">createRelease</a></li> <li data-type='method'><a href="GitHubWrapper.html#fetchCommitAuthorInformation">fetchCommitAuthorInformation</a></li> <li data-type='method'><a href="GitHubWrapper.html#fetchCommitInformation">fetchCommitInformation</a></li> <li data-type='method'><a href="GitHubWrapper.html#fetchReleaseInformation">fetchReleaseInformation</a></li> <li data-type='method'><a href="GitHubWrapper.html#getCommitLink">getCommitLink</a></li> </ul> </li> <li><a href="GitLabWrapper.html">GitLabWrapper</a> <ul class='methods'> <li data-type='method'><a href="GitLabWrapper.html#createRelease">createRelease</a></li> <li data-type='method'><a href="GitLabWrapper.html#fetchCommitAuthorInformation">fetchCommitAuthorInformation</a></li> <li data-type='method'><a href="GitLabWrapper.html#fetchCommitInformation">fetchCommitInformation</a></li> <li data-type='method'><a href="GitLabWrapper.html#fetchReleaseInformation">fetchReleaseInformation</a></li> <li data-type='method'><a href="GitLabWrapper.html#getCommitLink">getCommitLink</a></li> </ul> </li> <li><a href="PrepareCommandClass.html">PrepareCommandClass</a> <ul class='methods'> <li data-type='method'><a href="PrepareCommandClass.html#_bumpVersion">_bumpVersion</a></li> <li data-type='method'><a href="PrepareCommandClass.html#_computeNextVersion">_computeNextVersion</a></li> <li data-type='method'><a href="PrepareCommandClass.html#_getCurrentVersion">_getCurrentVersion</a></li> <li data-type='method'><a href="PrepareCommandClass.html#_getTargetFileList">_getTargetFileList</a></li> <li data-type='method'><a href="PrepareCommandClass.html#_mergeOptions">_mergeOptions</a></li> <li data-type='method'><a href="PrepareCommandClass.html#_setupLogger">_setupLogger</a></li> <li data-type='method'><a href="PrepareCommandClass.html#_setupTasks">_setupTasks</a></li> <li data-type='method'><a href="PrepareCommandClass.html#execute">execute</a></li> </ul> </li> <li><a href="PublishCommandClass.html">PublishCommandClass</a> <ul class='methods'> <li data-type='method'><a href="PublishCommandClass.html#_getUpstreamRepositoryInfo">_getUpstreamRepositoryInfo</a></li> <li data-type='method'><a href="PublishCommandClass.html#_initializeGit">_initializeGit</a></li> <li data-type='method'><a href="PublishCommandClass.html#_mergeOptions">_mergeOptions</a></li> <li data-type='method'><a href="PublishCommandClass.html#_publishToNpm">_publishToNpm</a></li> <li data-type='method'><a href="PublishCommandClass.html#_setupLogger">_setupLogger</a></li> <li data-type='method'><a href="PublishCommandClass.html#_setupTasks">_setupTasks</a></li> <li data-type='method'><a href="PublishCommandClass.html#execute">execute</a></li> </ul> </li> <li><a href="ReleaseCommandClass.html">ReleaseCommandClass</a> <ul class='methods'> <li data-type='method'><a href="ReleaseCommandClass.html#_generateChangelog">_generateChangelog</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_generateRelease">_generateRelease</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_initializeGit">_initializeGit</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_mergeOptions">_mergeOptions</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_pushUpstream">_pushUpstream</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_restoreCode">_restoreCode</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_setupLogger">_setupLogger</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_setupTasks">_setupTasks</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_stashOrCommit">_stashOrCommit</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_summarize">_summarize</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#_tagCode">_tagCode</a></li> <li data-type='method'><a href="ReleaseCommandClass.html#execute">execute</a></li> </ul> </li> </ul> </nav> <div id="main"> <h1 class="page-title">ReleaseCommandClass</h1> <section> <header> <h2> ReleaseCommandClass </h2> <div class="class-description usertext"> <p>The command class that creates a release on a git host (Github / GitLab / BitBucket / etc.).</p> </div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="ReleaseCommandClass"><span class="type-signature"></span>new ReleaseCommandClass<span class="signature">(mode)</span><span class="type-signature"></span></h4> <p class="summary usertext">The command class that implements the &quot;release&quot; step of the workflow.</p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line17">line 17</a> </li> </ul> </dd> </dl> <div class="description usertext"> <p>The command class that implements the &quot;release&quot; step of the workflow. Please see README.md for the details of what this step involves.</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>mode</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Set the current run mode - CLI or API</p> </td> </tr> </tbody> </table> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="_generateChangelog"><span class="type-signature">(async) </span>_generateChangelog<span class="signature">(ctxt, task)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>Generates a CHANGELOG from the relevant Git Log events, and commits the modified file.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line319">line 319</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ctxt</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Task context containing the options object returned by the _mergeOptions method</p> </td> </tr> <tr> <td class="name"><code>task</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Reference to the task that is running</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="_generateRelease"><span class="type-signature">(async) </span>_generateRelease<span class="signature">(ctxt, task)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>Creates releases for each of the configured upstreams.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line493">line 493</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ctxt</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Task context containing the options object returned by the _mergeOptions method</p> </td> </tr> <tr> <td class="name"><code>task</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Reference to the task that is running</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="_initializeGit"><span class="type-signature"></span>_initializeGit<span class="signature">(ctxt, task)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>Creates a Git client instance for the current project repository and sets it on the context.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line241">line 241</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ctxt</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Task context containing the options object returned by the _mergeOptions method</p> </td> </tr> <tr> <td class="name"><code>task</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Reference to the task that is running</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="_mergeOptions"><span class="type-signature"></span>_mergeOptions<span class="signature">(configOptions, cliOptions)</span><span class="type-signature"> &rarr; {object}</span></h4> <p class="summary usertext"> <p>Merges options passed in with configured ones - and puts in sane defaults if neither is available.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line78">line 78</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>configOptions</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Options passed in from cosmiConfig / calling module</p> </td> </tr> <tr> <td class="name"><code>cliOptions</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Options passed in from the CLI</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Merged options - input options &gt; configured options.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> <h4 class="name" id="_pushUpstream"><span class="type-signature">(async) </span>_pushUpstream<span class="signature">(ctxt, task)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>Pushes new commits/tags to the configured upstream git remote.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line437">line 437</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ctxt</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Task context containing the options object returned by the _mergeOptions method</p> </td> </tr> <tr> <td class="name"><code>task</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Reference to the task that is running</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="_restoreCode"><span class="type-signature">(async) </span>_restoreCode<span class="signature">(ctxt, task)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>If code was stashed earlier in the cycle, pops it out.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line659">line 659</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ctxt</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Task context containing the options object returned by the _mergeOptions method</p> </td> </tr> <tr> <td class="name"><code>task</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Reference to the task that is running</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="_setupLogger"><span class="type-signature"></span>_setupLogger<span class="signature">(options)</span><span class="type-signature"> &rarr; {object}</span></h4> <p class="summary usertext"> <p>Logger for API mode, otherwise null</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line130">line 130</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>merged options object returned by the _mergeOptions method</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Logger object with info / error functions.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> <h4 class="name" id="_setupTasks"><span class="type-signature"></span>_setupTasks<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4> <p class="summary usertext"> <p>Setup the list of tasks to be run</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line150">line 150</a> </li> </ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>Tasks as Listr.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> <h4 class="name" id="_stashOrCommit"><span class="type-signature">(async) </span>_stashOrCommit<span class="signature">(ctxt, task)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>Depending on the configuration, stashes/commits code in the current branch - if required.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line267">line 267</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ctxt</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Task context containing the options object returned by the _mergeOptions method</p> </td> </tr> <tr> <td class="name"><code>task</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Reference to the task that is running</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="_summarize"><span class="type-signature">(async) </span>_summarize<span class="signature">(ctxt, task)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>Print success if everything went through, else print error information.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line680">line 680</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ctxt</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Task context containing the options object returned by the _mergeOptions method</p> </td> </tr> <tr> <td class="name"><code>task</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Reference to the task that is running</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="_tagCode"><span class="type-signature">(async) </span>_tagCode<span class="signature">(ctxt, task)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>Tags the codebase.</p> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line400">line 400</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ctxt</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Task context containing the options object returned by the _mergeOptions method</p> </td> </tr> <tr> <td class="name"><code>task</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Reference to the task that is running</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="execute"><span class="type-signature">(async) </span>execute<span class="signature">(configOptions, cliOptions)</span><span class="type-signature"> &rarr; {null}</span></h4> <p class="summary usertext"> <p>The main method to tag/release the codebase on Github / GitLab / etc.</p> <p>This method does 3 things:</p> <ul> <li>Generates the changelog - features/fixes added to the code since the last tag/release</li> <li>Commits, tags, pushes to Github / GitLab / etc.</li> <li>Creates a release using the tag and the generated changelog</li> </ul> </p> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="dummy"> <li> <a href="commands_release-command.js.html">commands/release-command.js</a>, <a href="commands_release-command.js.html#line36">line 36</a> </li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>configOptions</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Options via cosmiConfig, or via API</p> </td> </tr> <tr> <td class="name"><code>cliOptions</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"> <p>Options via the CLI</p> </td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> <p>Nothing.</p> </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">null</span> </dd> </dl> </article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script> prettyPrint(); </script> <script src="scripts/polyfill.js"></script> <script src="scripts/linenumber.js"></script> <script src="scripts/search.js" defer></script> </body> </html>