feat: dotenv confirmation

This commit is contained in:
Artemy Egorov 2023-08-21 17:56:50 +03:00
parent 3be237ae31
commit daf810ccb5
2 changed files with 20 additions and 5 deletions

View file

@ -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}}

View file

@ -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"]);
},
},
]);