diff --git a/packages/yonode/src/index.js b/packages/yonode/src/index.js index 4895cbb9..4979c3f7 100755 --- a/packages/yonode/src/index.js +++ b/packages/yonode/src/index.js @@ -9,14 +9,15 @@ import { execSync } from "child_process"; import fs from "fs"; -import path, { basename } from "path"; import inquirer from "inquirer"; +import path, { basename } from "path"; import "./lib/programOptions.js"; -import { databaseType } from "./lib/prompt/db.js"; +import { databaseConfirmQuestion } from "./lib/prompt/db.js"; import { languageType } from "./lib/questions.js"; export const options = { language_type: "", + database: true, database_type: "", orm_type: "", auth: false, @@ -144,7 +145,7 @@ function main() { process.exit(0); } options.language_type = answer.language_type; - databaseType(); + databaseConfirmQuestion(); }) .catch((error) => { if (error.isTtyError) { diff --git a/packages/yonode/src/lib/prompt/db.js b/packages/yonode/src/lib/prompt/db.js index dbe7b4d1..8a9abb94 100644 --- a/packages/yonode/src/lib/prompt/db.js +++ b/packages/yonode/src/lib/prompt/db.js @@ -1,28 +1,23 @@ -import inquirer from 'inquirer' -import { mongodbOrm } from '../../orm/mongoDB.js'; -import { ormType } from '../../orm/orm.js'; -import { options } from '../../index.js'; -import { databaseQuestion } from '../questions.js'; +import inquirer from "inquirer"; +import { options } from "../../index.js"; +import { dbQuestion } from "../questions.js"; +import { repoConditions } from "../repoConditions.js"; +import { databaseType } from "./dbType.js"; -export const databaseType = () => { - inquirer.prompt( - databaseQuestion - ).then(answer => { - if (answer.database_type === 'MongoDB') { - options.database_type = answer.database_type - mongodbOrm() - } else if (answer.database_type === 'MySQL') { - options.database_type = answer.database_type - ormType() - } - else { - options.database_type = answer.database_type - ormType() - } +export const databaseConfirmQuestion = () => { + inquirer + .prompt(dbQuestion) + .then((answer) => { + if (answer.dbQuestion === true) { + databaseType(); + } else if(answer.dbQuestion === false) { + options.database = answer.dbQuestion; + repoConditions(); + } }) - .catch((error) => { - if (error.isTtyError) { - } else { - } - }); -} \ No newline at end of file + .catch((error) => { + if (error.isTtyError) { + } else { + } + }); +}; diff --git a/packages/yonode/src/lib/prompt/dbType.js b/packages/yonode/src/lib/prompt/dbType.js new file mode 100644 index 00000000..dbe7b4d1 --- /dev/null +++ b/packages/yonode/src/lib/prompt/dbType.js @@ -0,0 +1,28 @@ +import inquirer from 'inquirer' +import { mongodbOrm } from '../../orm/mongoDB.js'; +import { ormType } from '../../orm/orm.js'; +import { options } from '../../index.js'; +import { databaseQuestion } from '../questions.js'; + +export const databaseType = () => { + inquirer.prompt( + databaseQuestion + ).then(answer => { + if (answer.database_type === 'MongoDB') { + options.database_type = answer.database_type + mongodbOrm() + } else if (answer.database_type === 'MySQL') { + options.database_type = answer.database_type + ormType() + } + else { + options.database_type = answer.database_type + ormType() + } + }) + .catch((error) => { + if (error.isTtyError) { + } else { + } + }); +} \ No newline at end of file diff --git a/packages/yonode/src/lib/questions.js b/packages/yonode/src/lib/questions.js index c05dee52..a6aa8d2d 100644 --- a/packages/yonode/src/lib/questions.js +++ b/packages/yonode/src/lib/questions.js @@ -6,6 +6,14 @@ export const languageType = { default: "JavaScript", } +export const dbQuestion = [ + { + type: "confirm", + name: "dbQuestion", + message: "Do you need database?", + }, +] + export const databaseQuestion = [ { type: "list", diff --git a/packages/yonode/src/lib/repoConditions.js b/packages/yonode/src/lib/repoConditions.js index 18e61189..b6f136e4 100644 --- a/packages/yonode/src/lib/repoConditions.js +++ b/packages/yonode/src/lib/repoConditions.js @@ -4,6 +4,12 @@ export const repoConditions = () => { switch (true) { // JavaScript for NoAuth + // NoDB + case options.language_type === "JavaScript" && + options.database === false: + cloneRepo(projectName, "JS-NoDB-Template"); + break; + // MongoDB case options.language_type === "JavaScript" && options.database_type === "MongoDB" &&