mirror of
https://github.com/artegoser/create-ts-prod.git
synced 2024-11-22 13:16:21 +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 { IConfigService } from "./config/config.interface";
|
||||||
import { ConfigService } from "./config/config.service";
|
import { ConfigService } from "./config/config.service";
|
||||||
|
{{/if}}
|
||||||
{{#if prisma}}
|
{{#if prisma}}
|
||||||
import { PrismaClient } from "@prisma/client";
|
import { PrismaClient } from "@prisma/client";
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
{{#if dotenv}}
|
||||||
config: IConfigService;
|
config: IConfigService;
|
||||||
|
{{/if}}
|
||||||
{{#if prisma}}
|
{{#if prisma}}
|
||||||
prisma: PrismaClient;
|
prisma: PrismaClient;
|
||||||
{{/if}}
|
{{/if}}
|
||||||
constructor() {
|
constructor() {
|
||||||
|
{{#if dotenv}}
|
||||||
this.config = new ConfigService();
|
this.config = new ConfigService();
|
||||||
|
{{/if}}
|
||||||
{{#if prisma}}
|
{{#if prisma}}
|
||||||
this.prisma = new PrismaClient();
|
this.prisma = new PrismaClient();
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
19
index.js
19
index.js
|
@ -10,7 +10,7 @@ const config = {
|
||||||
"@typescript-eslint/parser",
|
"@typescript-eslint/parser",
|
||||||
"@typescript-eslint/eslint-plugin",
|
"@typescript-eslint/eslint-plugin",
|
||||||
],
|
],
|
||||||
dep: ["dotenv"],
|
dep: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,6 +30,11 @@ async function run() {
|
||||||
name: "prisma",
|
name: "prisma",
|
||||||
message: "Do you want to install Prisma?",
|
message: "Do you want to install Prisma?",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: "confirm",
|
||||||
|
name: "dotenv",
|
||||||
|
message: "Do you want to install dotenv?",
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let tasks = new Listr([
|
let tasks = new Listr([
|
||||||
|
@ -56,6 +61,7 @@ async function run() {
|
||||||
const files = await glob("**/*", {
|
const files = await glob("**/*", {
|
||||||
cwd: path.join(__dirname, "files"),
|
cwd: path.join(__dirname, "files"),
|
||||||
nodir: true,
|
nodir: true,
|
||||||
|
ignore: [resp.dotenv ? "./config/**" : ""],
|
||||||
});
|
});
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const content = fs.readFileSync(
|
const content = fs.readFileSync(
|
||||||
|
@ -101,10 +107,13 @@ async function run() {
|
||||||
"--datasource-provider",
|
"--datasource-provider",
|
||||||
"sqlite",
|
"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