From daf810ccb5a8a6885a5d1491c799384222cce3a5 Mon Sep 17 00:00:00 2001 From: Artemy Egorov Date: Mon, 21 Aug 2023 17:56:50 +0300 Subject: [PATCH] feat: dotenv confirmation --- files/src/app.ts | 6 ++++++ index.js | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/files/src/app.ts b/files/src/app.ts index c9b5e2c..9745027 100644 --- a/files/src/app.ts +++ b/files/src/app.ts @@ -1,16 +1,22 @@ +{{#if dotenv}} import { IConfigService } from "./config/config.interface"; import { ConfigService } from "./config/config.service"; +{{/if}} {{#if prisma}} import { PrismaClient } from "@prisma/client"; {{/if}} class App { + {{#if dotenv}} config: IConfigService; + {{/if}} {{#if prisma}} prisma: PrismaClient; {{/if}} constructor() { + {{#if dotenv}} this.config = new ConfigService(); + {{/if}} {{#if prisma}} this.prisma = new PrismaClient(); {{/if}} diff --git a/index.js b/index.js index e040697..487ca39 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,7 @@ const config = { "@typescript-eslint/parser", "@typescript-eslint/eslint-plugin", ], - dep: ["dotenv"], + dep: [], }, }; @@ -30,6 +30,11 @@ async function run() { name: "prisma", message: "Do you want to install Prisma?", }, + { + type: "confirm", + name: "dotenv", + message: "Do you want to install dotenv?", + }, ]); let tasks = new Listr([ @@ -56,6 +61,7 @@ async function run() { const files = await glob("**/*", { cwd: path.join(__dirname, "files"), nodir: true, + ignore: [resp.dotenv ? "./config/**" : ""], }); for (const file of files) { const content = fs.readFileSync( @@ -101,10 +107,13 @@ async function run() { "--datasource-provider", "sqlite", ]); - - fs.cpSync(path.join(__dirname, "files_options/prisma"), "./", { - recursive: true, - }); + }, + }, + { + title: "Install Dotenv", + enabled: () => resp.dotenv, + task: async () => { + await execa("npm", ["i", "dotenv"]); }, }, ]);