boil-cli-tool
Version:
CLI tool - boilerplate template manager and generator
31 lines (30 loc) • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// packages
const command_1 = require("@oclif/command");
const fs_1 = require("fs");
// utils
const utils_1 = require("../utils");
const root = "./.boilerplate";
class List extends command_1.Command {
async run() {
// 1. check that '.boilerplate' directory exists
if (!utils_1.boilerplateExists()) {
return this.log(utils_1.printError(`looks like you don't have a '.boilerplate' directory - run 'boil init' to start a new project`));
}
// extract folder names from '.boilerplate' directory
const commands = fs_1.readdirSync(root).filter((src) => fs_1.lstatSync(`${root}/${src}`).isDirectory());
// 2. if no commands in boilerplate directory then prompt the user to create one
if (commands.length === 0) {
return this.log(utils_1.printError(`looks like you haven't created any commands yet - run 'boil create --help' for more information`));
}
// 3. list all commands
this.log(`\n${utils_1.bold("COMMANDS")}`);
commands.map((cmd) => this.log(` boil up ${utils_1.print(cmd, "blue")}`));
this.log(`\n${utils_1.bold("OPTIONS")}`);
this.log(` -h, --help ${utils_1.print("show CLI help", "gray")}`);
}
}
exports.default = List;
List.description = "list all boil commands";
List.flags = { help: command_1.flags.help({ char: "h" }) };