mirror of
https://github.com/artegoser/create-ts-prod.git
synced 2024-11-22 05:06:22 +03:00
feat: dotenv confirmation
This commit is contained in:
parent
3be237ae31
commit
daf810ccb5
2 changed files with 20 additions and 5 deletions
|
@ -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}}
|
||||
|
|
19
index.js
19
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"]);
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
|
Loading…
Add table
Reference in a new issue