-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
logNextSteps.ts
77 lines (68 loc) · 2.24 KB
/
logNextSteps.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
72
73
74
75
76
77
import { DEFAULT_APP_NAME } from "~/consts.js";
import { type InstallerOptions } from "~/installers/index.js";
import { getUserPkgManager } from "~/utils/getUserPkgManager.js";
import { logger } from "~/utils/logger.js";
import { isInsideGitRepo, isRootGitRepo } from "./git.js";
// This logs the next steps that the user should take in order to advance the project
export const logNextSteps = async ({
projectName = DEFAULT_APP_NAME,
packages,
appRouter,
noInstall,
projectDir,
databaseProvider,
}: Pick<
InstallerOptions,
| "projectName"
| "packages"
| "noInstall"
| "projectDir"
| "appRouter"
| "databaseProvider"
>) => {
const pkgManager = getUserPkgManager();
logger.info("Next steps:");
projectName !== "." && logger.info(` cd ${projectName}`);
if (noInstall) {
// To reflect yarn's default behavior of installing packages when no additional args provided
if (pkgManager === "yarn") {
logger.info(` ${pkgManager}`);
} else {
logger.info(` ${pkgManager} install`);
}
}
if (["postgres", "mysql"].includes(databaseProvider)) {
logger.info(" Start up a database, if needed using './start-database.sh'");
}
if (packages?.prisma.inUse || packages?.drizzle.inUse) {
if (["npm", "bun"].includes(pkgManager)) {
logger.info(` ${pkgManager} run db:push`);
} else {
logger.info(` ${pkgManager} db:push`);
}
}
if (["npm", "bun"].includes(pkgManager)) {
logger.info(` ${pkgManager} run dev`);
} else {
logger.info(` ${pkgManager} dev`);
}
if (!(await isInsideGitRepo(projectDir)) && !isRootGitRepo(projectDir)) {
logger.info(` git init`);
}
logger.info(` git commit -m "initial commit"`);
if (appRouter) {
logger.warn(
`\nThank you for trying out the App Router option. If you encounter any issues, please open an issue!`
);
}
if (packages?.drizzle.inUse) {
logger.warn(
`\nThank you for trying out the new Drizzle option. If you encounter any issues, please open an issue!`
);
}
if (databaseProvider === "planetscale") {
logger.warn(
`\nNote: We use the PlanetScale driver so that you can query your data in edge runtimes. If you want to use a different driver, you'll need to change it yourself.`
);
}
};