boil-cli-tool
Version:
CLI tool - boilerplate template manager and generator
45 lines (44 loc) • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// packages
const fs_1 = require("fs");
const command_1 = require("@oclif/command");
// utils
const utils_1 = require("../utils");
// constants
const init_spec_1 = require("./init.spec");
const rootPath = "./.boilerplate";
const generateFilesAndFolders = () => {
// create .boilerplate folder
fs_1.mkdirSync(rootPath);
// create readme
fs_1.writeFileSync(`${rootPath}/readme.txt`, init_spec_1.readmeContent);
// create global args yml file
fs_1.writeFileSync(`${rootPath}/global.args.yml`, init_spec_1.globalYaml);
// create template function
fs_1.writeFileSync(`${rootPath}/timestamp.js`, init_spec_1.templateFunctionContent);
// create component directory (example template out-of-the-box)
fs_1.mkdirSync(`${rootPath}/component`);
// create local args yml file
fs_1.writeFileSync(`${rootPath}/component/local.args.yml`, init_spec_1.localYaml);
// folder with template arg name
fs_1.mkdirSync(`${rootPath}/component/___name___`);
// file with template arg name and filetype
fs_1.writeFileSync(`${rootPath}/component/___name___/___name___.___filetype___`, init_spec_1.placeholderContent);
};
class Init extends command_1.Command {
async run() {
if (utils_1.boilerplateExists()) {
this.log(utils_1.printError(`looks like you already have a '.boilerplate' folder`));
}
else {
generateFilesAndFolders();
this.log(`${utils_1.emojis([":tropical_drink:", ":dancer:"])} ${utils_1.print(`'.boilerplate' folder has been created in the root of the current directory`)}`);
}
}
}
exports.default = Init;
Init.description = "create a new boilerplate directory";
Init.flags = {
help: command_1.flags.help({ char: "h" }),
};