import * as _ from "lodash"; // import * as chalk from "chalk"; import { showWelcomeHeader, grabInputArguments, grabCommandFromArguments, showHelpScreen, } from "../../scripts"; import { getFileContents } from "../../lib/files"; import { generateReadMeFile } from "./readme"; import { generateFeatureStory } from "./story"; import { generateComponents } from "./components"; import { generateModules } from "./modules"; import { generateTests } from "./tests"; import { generateAPI } from "./api"; import { generateDb } from "./db"; import { endProgram } from "./end"; // const inquirer = require("inquirer"); const chalk = require("chalk"); // const myChalk: any = chalk; const command: string = grabCommandFromArguments(3); const args: any = grabInputArguments(); const inputPath = args["in"] || args["i"]; const outputPath = args["out"] || args["o"]; export const scaffold = () => { console.log(""); if ( command === "help" || _.has(args, "help") || _.has(args, "h") || !inputPath ) { showHelpScreen("scaffold"); process.exit(1); } // const prompt = inquirer.createPromptModule(); // if (directoryExists(outputPath)) { // console.log( // myChalk.red(` // Sorry, that folder already exists. // `) // ); // prompt([ // { // name: "answer", // type: "input", // message: "Overwrite and Proceed? [y/N] " // } // ]).then((answer: any) => console.log({ answer })); // // process.exit(1); // } getFileContents(inputPath, (err: any, res: any) => { if (res) { showWelcomeHeader(); const fileContent = JSON.parse(res); // Generate a ReadMe file generateReadMeFile(fileContent, outputPath); // Generate Feature Story generateFeatureStory(fileContent, outputPath); // Generate components generateComponents(fileContent, outputPath); // Generate modules generateModules(fileContent, outputPath); // Generate tests generateTests(fileContent, outputPath); // // Generate the API generateAPI(fileContent, outputPath); // Generate db schema generateDb(fileContent, outputPath); // End Program endProgram(outputPath); } else { console.log(chalk.red("Something went wrong", err)); } }); };