src/lib/install-packages.ts 1.0 K raw
1
import type { ProjectOptions } from "@/types";
2
import { setupBiome } from "./setup-biome";
3
import path from "node:path";
4
import { tanstackQueryInstaller } from "@/installers/tanstack-query";
5
import { rpcInstaller } from "@/installers/rpc";
6
import { reactRouterInstaller } from "@/installers/react-router";
7
import { tanstackRouterInstaller } from "@/installers/tanstack-router";
8
9
export async function installPackages(
10
	options: Required<ProjectOptions>,
11
): Promise<boolean> {
12
	const { projectName, rpc, router, linter, tanstackQuery } = options;
13
14
	const projectPath = path.resolve(process.cwd(), projectName);
15
16
	if (rpc) {
17
		await rpcInstaller(options);
18
	}
19
20
	if (linter === "biome") {
21
		await setupBiome(projectPath);
22
	}
23
24
	if (tanstackQuery) {
25
		await tanstackQueryInstaller(options);
26
	}
27
28
	if (router !== "none") {
29
		switch (router) {
30
			case "reactrouter": {
31
				await reactRouterInstaller(options);
32
				break;
33
			}
34
			case "tanstackrouter": {
35
				await tanstackRouterInstaller(options);
36
				break;
37
			}
38
		}
39
	}
40
41
	return false;
42
}