MCPcopy
hub / github.com/t3-oss/create-t3-app / main

Function main

cli/src/index.ts:31–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29};
30
31const main = async () => {
32 const npmVersion = await getNpmVersion();
33 const pkgManager = getUserPkgManager();
34 renderTitle();
35 if (npmVersion) {
36 renderVersionWarning(npmVersion);
37 }
38
39 const {
40 appName,
41 packages,
42 flags: { noGit, noInstall, importAlias, appRouter },
43 databaseProvider,
44 } = await runCli();
45
46 const usePackages = buildPkgInstallerMap(packages, databaseProvider);
47
48 // e.g. dir/@mono/app returns ["@mono/app", "dir/app"]
49 const [scopedAppName, appDir] = parseNameAndPath(appName);
50
51 const projectDir = await createProject({
52 projectName: appDir,
53 scopedAppName,
54 packages: usePackages,
55 databaseProvider,
56 importAlias,
57 noInstall,
58 appRouter,
59 });
60
61 // Write name to package.json
62 const pkgJson = fs.readJSONSync(
63 path.join(projectDir, "package.json")
64 ) as CT3APackageJSON;
65 pkgJson.name = scopedAppName;
66 pkgJson.ct3aMetadata = { initVersion: getVersion() };
67
68 // ? Bun doesn't support this field (yet)
69 if (pkgManager !== "bun") {
70 const { stdout } = await execa(pkgManager, ["-v"], {
71 cwd: projectDir,
72 });
73 pkgJson.packageManager = `${pkgManager}@${stdout.trim()}`;
74 }
75
76 fs.writeJSONSync(path.join(projectDir, "package.json"), pkgJson, {
77 spaces: 2,
78 });
79
80 // update import alias in any generated files if not using the default
81 if (importAlias !== "~/") {
82 setImportAlias(projectDir, importAlias);
83 }
84
85 if (!noInstall) {
86 await installDependencies({ projectDir });
87
88 if (usePackages.prisma.inUse) {

Callers 1

index.tsFile · 0.85

Calls 14

getNpmVersionFunction · 0.85
getUserPkgManagerFunction · 0.85
renderTitleFunction · 0.85
renderVersionWarningFunction · 0.85
runCliFunction · 0.85
buildPkgInstallerMapFunction · 0.85
parseNameAndPathFunction · 0.85
createProjectFunction · 0.85
getVersionFunction · 0.85
setImportAliasFunction · 0.85
installDependenciesFunction · 0.85
formatProjectFunction · 0.85

Tested by

no test coverage detected