-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
envVars.ts
35 lines (28 loc) · 878 Bytes
/
envVars.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type { Installer } from "./index.js";
import path from "path";
import fs from "fs-extra";
import { PKG_ROOT } from "../consts.js";
export const envVariblesInstaller: Installer = async ({
projectDir,
packages,
}) => {
const usingAuth = packages?.nextAuth.inUse;
const usingPrisma = packages?.prisma.inUse;
const envAssetDir = path.join(PKG_ROOT, "template/addons/env");
let envFile = "";
switch (true) {
case usingAuth && usingPrisma:
envFile = "env-prisma-auth.js";
break;
case usingAuth:
envFile = "env-auth.js";
break;
case usingPrisma:
envFile = "env-prisma.js";
break;
}
if (!envFile) return;
const envSchemaSrc = path.join(envAssetDir, envFile);
const envSchemaDest = path.join(projectDir, "src/server/env-schema.js");
await fs.copy(envSchemaSrc, envSchemaDest, { overwrite: true });
};