@loomble/cli v1.0.0
Loom: Loomble CLI (Command Line Interface)
Getting started
Loomble and the Loomble CLI requires Node.js
>=6.2.2 and npm
>=3.9.5.
Install
Run the following command in your terminal:
npm install @loomble/cli -g
After the installation finishes, you'll have a new loom
command available globally in your system terminal.
Create a Loomble app
Run the following command in your terminal:
loom init YourAppName
A single instance of Loomble can process multiple apps, just run the command each time you want to add a new app.
When you initialize your first app, Loomble will be installed in node_modules
and a package.json
file will be created in the directory the command is issued from.
Run Loomble
After your first app has been setup, run loom env
to get instructions for the environment variables that will need to be set before Loomble can run.
Once you have the environment variables set, run one of the following commands: To run in development mode:
loom dev
or run in production mode:
loom prod
Create custom commands in your Loomble instance
Loomble CLI uses commander under the hood, so you can easily add commands to your Loomble setup by placing files in a directory named @cli
at the root of your project.
Every root file in your @cli
directory will be loaded automatically.
These files are not processed by Babel, you are limited to the JavaScript support of your current version of Node.js.
Custom commands must adhere to the following format:
'use strict'
module.exports = function(cli) {
cli
.command('command_name')
.description('Command description')
.action((options) => {
/*
// YOUR CODE HERE
// If you need Babel, you can use Loomble's babel register hook:
require('loomble/babel/register')
require('./commands/some-file-that-needs-babel')
*/
})
}
For more documentation on available features, see commander. To view all of the available commands for your project, just run help:
loom -h
The cli
argument passed to each command function is an object which contains the following properties:
envName
: The environment name,development
orproduction
.spinner(message)
: Creates a spinner in the terminal with the specified message.Usage:
const spin = cli.spinner('Loading') spin.start() // Run some code spin.stop()
chalk
: See chalk on npmconsole
: An object that contains the following console helpers:errorText(msg)
warnText(msg)
infoText(msg)
boldText(msg)
refText(msg)
(for a code reference)wrapText(msg)
(wrap text to 80 characters per line)
Usage:
const { infoText } = cli.console console.log(`Hello ${infoText('World')}`)
spawn
: See cross-spawn on npmspawnSync
: ^ Fromcross-spawn
config
: The processed Loomble instance configuration object
License
Loom (Loomble-CLI) is licensed under the standard BSD 3-Clause License. We also provide an additional patent grant.
8 years ago