Vanilla CLI Overview (Deprecated) - HL Vanilla Community
<main> <article class="userContent"> <p>Vanilla provides a <a href="https://github.com/vanilla/vanilla-cli" rel="nofollow noreferrer ugc">command line tool</a> to make various tasks easier for developers working on Vanilla Forums core or addons.</p><p>Current functionalities include:</p><ul><li>Building frontend assets (scripts, stylesheets, and images).</li><li>Generating cache files for addons.</li><li>Converting addons’ <a href="https://docs.vanillaforums.com/developer/addons/plugin-theme-info" rel="nofollow noreferrer ugc">PluginInfo/ThemeInfo</a> to the <a href="https://docs.vanillaforums.com/developer/addons/addon-info" rel="nofollow noreferrer ugc">addon.json format</a>.</li><li>Validate addons in a Vanilla installation.</li></ul><h2 data-id="getting-started">Getting Started</h2><p>Follow the <a href="https://success.vanillaforums.com/kb/articles/241-vanilla-cli-installation" rel="nofollow noreferrer ugc">setup guide</a>.</p><h2 data-id="build-tools">Build Tools</h2><p>The Vanilla CLI bundles it’s own build tool to make starting and maintaining your Vanilla Forums addons easier.</p><p>Many Vanilla addons often have their own tools to build their frontend dependencies. Normally these tools bundle, concatenate, and/or minify the javascript and styles, compress images and other assets, and may include a CSS authoring tool such as <a href="http://sass-lang.com/" rel="nofollow noreferrer ugc">Sass</a> or <a href="http://lesscss.org/" rel="nofollow noreferrer ugc">Less</a>. Many of these build toolchains accomplish the same objective but in different ways.</p><p>The Vanilla Build Tool aims to provide a consistent experience to building frontend assets for Vanilla. If you specify a build process in your <a href="https://docs.vanillaforums.com/developer/addons/addon-info/#build" rel="nofollow noreferrer ugc">addon.json</a> it will use that process automatically, but falls back to <a href="https://docs.vanillaforums.com/developer/vanilla-cli/build-process-legacy" rel="nofollow noreferrer ugc">legacy build process</a> for older projects. This is to try to smooth the edges of working with older addons, but is not as simple as using one of the built in processes.</p><h3 data-id="usage">Usage</h3><p><code class="code codeInline" spellcheck="false" tabindex="0">vanilla build [<options>]</code></p><h3 data-id="options">Options</h3><h4 data-id="-watch"><code class="code codeInline" spellcheck="false" tabindex="0">--watch</code></h4><p>Run the build process in watch mode. This will listen for changes in your code and recompile the parts that have changed. It spawns a local server meant to hook into the <a href="http://livereload.com/extensions/" rel="nofollow noreferrer ugc">livereload</a> browser extension for <a href="https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei" rel="nofollow noreferrer ugc">Chrome</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/livereload/" rel="nofollow noreferrer ugc">Firefox</a>, and <a href="http://livereload.com/extensions/" rel="nofollow noreferrer ugc">Safari</a>. This is officially supported by the <code class="code codeInline" spellcheck="false" tabindex="0">1.0</code> build process only. It may also work with the <code class="code codeInline" spellcheck="false" tabindex="0">legacy</code> build process if the addon supports it.</p><h4 data-id="-verbose"><code class="code codeInline" spellcheck="false" tabindex="0">--verbose</code></h4><p>Log additional output to stdout. This is helpful for finding out what might be wrong in your build process and outlines each step as they occur.</p><h4 data-id="-reinitialize"><code class="code codeInline" spellcheck="false" tabindex="0">--reinitialize</code></h4><p>This tool has its own javascript dependencies that it relies on to function properly. Some of these are native modules and may require recompilation if your OS or Node.js installation get upgraded. This flags clears all cached modules and reinstall/recompiles them. The tool will attempt to do this automatically if necessary, but this command can be useful for fixing dependency related issues.</p><h2 data-id="addon-utilities">Addon Utilities</h2><p>The Vanilla CLI offers a few utilities to make managing your addons easier. They only work with addons currently installed in a Vanilla installation and function by using Vanilla’s built in addon manager to do the heavy lifting. As a result, these commands require you to point them to the vanilla directory with the <code class="code codeInline" spellcheck="false" tabindex="0">--vanillasrc</code> parameter.</p><p>Alternatively you can set the the environmental variable <code class="code codeInline" spellcheck="false" tabindex="0">VANILLACLI_VANILLA_SRC_DIR</code> to the installation path.</p><h2 data-id="vanilla-addon-cache-options"><code class="code codeInline" spellcheck="false" tabindex="0">vanilla addon-cache [<options>]</code></h2><p>Reads the vanilla’s addon-cache.</p><h3 data-id="options-1">Options</h3><h4 data-id="-vanillasrc"><code class="code codeInline" spellcheck="false" tabindex="0">--vanillasrc</code></h4><p>You vanilla installation’s source directory.</p><h4 data-id="-regenerate"><code class="code codeInline" spellcheck="false" tabindex="0">--regenerate</code></h4><p>Will clear the addon-cache and regenerate it. This is useful for priming the cache without needing to load a page.</p><h2 data-id="vanilla-addon-doctor-options"><code class="code codeInline" spellcheck="false" tabindex="0">vanilla addon-doctor [<options>]</code></h2><p>Scans for issues in your addons.</p><h3 data-id="options-2">Options</h3><h4 data-id="-vanillasrc-1"><code class="code codeInline" spellcheck="false" tabindex="0">--vanillasrc</code></h4><p>You vanilla installation’s source directory.</p><h2 data-id="vanilla-addon-json-options"><code class="code codeInline" spellcheck="false" tabindex="0">vanilla addon-json [<options>]</code></h2><p>Convert addons from using <code class="code codeInline" spellcheck="false" tabindex="0">$PluginInfo</code> / <code class="code codeInline" spellcheck="false" tabindex="0">$ThemeInfo</code> / <code class="code codeInline" spellcheck="false" tabindex="0">about.php</code> metadata declaration to the <a href="https://docs.vanillaforums.com/developer/addons/addon-info" rel="nofollow noreferrer ugc">newer addon.json format</a>. This will convert all addons linked to you vanilla installation.</p><h3 data-id="options-3">Options</h3><h4 data-id="-vanillasrc-2"><code class="code codeInline" spellcheck="false" tabindex="0">--vanillasrc</code></h4><p>You vanilla installation’s source directory.</p><h2 data-id="common-issues">Common Issues</h2><p>There are a few common issues that people run into.</p><h3 data-id="im-having-trouble-getting-the-parameters-right.">I’m having trouble getting the parameters right.</h3><p>The CLI tool has some help baked right into the tool! By appending <code class="code codeInline" spellcheck="false" tabindex="0">--help</code> to any command you can list subcommands or parameters right in your console.</p><pre class="code codeBlock" spellcheck="false" tabindex="0">$ vanilla build --help $ vanilla addon-json --help </pre><h3 data-id="im-trying-to-resolve-an-issue-with-my-build-myself-but-there-is-not-enough-output-to-figure-out-whats-going-on.">I’m trying to resolve an issue with my build myself but there is not enough output to figure out what’s going on.</h3><p>The CLI tool has a verbose mode which can output additional information to the console. Use it by adding the <code class="code codeInline" spellcheck="false" tabindex="0">--verbose</code> flag.</p><pre class="code codeBlock" spellcheck="false" tabindex="0">vanilla build --verbose </pre><h3 data-id="im-having-an-issue-with-the-clis-own-node_module-dependancies.">I’m having an issue with the CLI’s own node_module dependancies.</h3><p>Try running your command with the <code class="code codeInline" spellcheck="false" tabindex="0">--reinitialize</code> flag. This will force-reinstall the node_modules required for your particular command.</p><pre class="code codeBlock" spellcheck="false" tabindex="0">vanilla build --reinitialize </pre><h3 data-id="im-getting-an-error-related-to-composer-autoloader-or-some-php-function-not-being-available.">I’m getting an error related to composer, autoloader, or some PHP function not being available.</h3><p>This applies only to manual installations of <code class="code codeInline" spellcheck="false" tabindex="0">vanilla-cli</code>. Navigate to your <code class="code codeInline" spellcheck="false" tabindex="0">vanilla-cli</code> directory and run <code class="code codeInline" spellcheck="false" tabindex="0">composer install</code>.</p> </article> </main>