-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
createProject.ts
44 lines (38 loc) · 1.2 KB
/
createProject.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
import path from "path";
import { installPackages } from "~/helpers/installPackages.js";
import { scaffoldProject } from "~/helpers/scaffoldProject.js";
import { selectAppFile, selectIndexFile } from "~/helpers/selectBoilerplate.js";
import { type PkgInstallerMap } from "~/installers/index.js";
import { getUserPkgManager } from "~/utils/getUserPkgManager.js";
interface CreateProjectOptions {
projectName: string;
packages: PkgInstallerMap;
noInstall: boolean;
importAlias: string;
}
export const createProject = async ({
projectName,
packages,
noInstall,
}: CreateProjectOptions) => {
const pkgManager = getUserPkgManager();
const projectDir = path.resolve(process.cwd(), projectName);
// Bootstraps the base Next.js application
await scaffoldProject({
projectName,
projectDir,
pkgManager,
noInstall,
});
// Install the selected packages
installPackages({
projectDir,
pkgManager,
packages,
noInstall,
});
// TODO: Look into using handlebars or other templating engine to scaffold without needing to maintain multiple copies of the same file
selectAppFile({ projectDir, packages });
selectIndexFile({ projectDir, packages });
return projectDir;
};