forked from t3-oss/create-t3-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
71 lines (66 loc) · 1.82 KB
/
index.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { eslint } from "./eslint.js";
import { prettier } from "./prettier.js";
import { envVariablesInstaller } from "~/installers/envVars.js";
import { nextAuthInstaller } from "~/installers/nextAuth.js";
import { prismaInstaller } from "~/installers/prisma.js";
import { tailwindInstaller } from "~/installers/tailwind.js";
import { trpcInstaller } from "~/installers/trpc.js";
import { type PackageManager } from "~/utils/getUserPkgManager.js";
// Turning this into a const allows the list to be iterated over for programatically creating prompt options
// Should increase extensability in the future
export const availablePackages = [
"nextAuth",
"prisma",
"tailwind",
"trpc",
"envVariables",
"eslint",
"prettier",
] as const;
export type AvailablePackages = (typeof availablePackages)[number];
export interface InstallerOptions {
projectDir: string;
pkgManager: PackageManager;
noInstall: boolean;
packages?: PkgInstallerMap;
projectName?: string;
}
export type Installer = (opts: InstallerOptions) => void;
export type PkgInstallerMap = {
[pkg in AvailablePackages]: {
inUse: boolean;
installer: Installer;
};
};
export const buildPkgInstallerMap = (
packages: AvailablePackages[],
): PkgInstallerMap => ({
nextAuth: {
inUse: packages.includes("nextAuth"),
installer: nextAuthInstaller,
},
prisma: {
inUse: packages.includes("prisma"),
installer: prismaInstaller,
},
tailwind: {
inUse: packages.includes("tailwind"),
installer: tailwindInstaller,
},
trpc: {
inUse: packages.includes("trpc"),
installer: trpcInstaller,
},
envVariables: {
inUse: true,
installer: envVariablesInstaller,
},
prettier: {
inUse: packages.includes("prettier"),
installer: prettier,
},
eslint: {
inUse: packages.includes("eslint"),
installer: eslint,
},
});