MCPcopy Index your code
hub / github.com/upstash/jstack / installBaseTemplate

Function installBaseTemplate

cli/src/helpers/install-base-template.ts:12–106  ·  view source on GitHub ↗
({
  projectName,
  projectDir,
  pkgManager,
  noInstall,
}: InstallerOptions)

Source from the content-addressed store, hash-verified

10
11// This bootstraps the base Next.js application
12export const installBaseTemplate = async ({
13 projectName,
14 projectDir,
15 pkgManager,
16 noInstall,
17}: InstallerOptions) => {
18 const srcDir = path.join(PKG_ROOT, "template/base")
19 const baseAssetsDir = path.join(PKG_ROOT, "template/base-assets")
20
21 if (!noInstall) {
22 logger.info(`\nUsing: ${chalk.cyan.bold(pkgManager)}\n`)
23 } else {
24 logger.info("")
25 }
26
27 const spinner = ora(`Scaffolding in: ${projectDir}...\n`).start()
28
29 if (fs.existsSync(projectDir)) {
30 if (fs.readdirSync(projectDir).length === 0) {
31 if (projectName !== ".")
32 spinner.info(
33 `${chalk.cyan.bold(projectName)} exists but is empty, continuing...\n`,
34 )
35 } else {
36 spinner.stopAndPersist()
37 const overwriteDir = await p.select({
38 message: `${chalk.redBright.bold("Warning:")} ${chalk.cyan.bold(
39 projectName,
40 )} already exists and isn't empty. How would you like to proceed?`,
41 options: [
42 {
43 label: "Abort installation (recommended)",
44 value: "abort",
45 },
46 {
47 label: "Clear the directory and continue installation",
48 value: "clear",
49 },
50 {
51 label: "Continue installation and overwrite conflicting files",
52 value: "overwrite",
53 },
54 ],
55 initialValue: "abort",
56 })
57 if (overwriteDir === "abort") {
58 spinner.fail("Aborting installation...")
59 process.exit(1)
60 }
61
62 const overwriteAction =
63 overwriteDir === "clear"
64 ? "clear the directory"
65 : "overwrite conflicting files"
66
67 const confirmOverwriteDir = await p.confirm({
68 message: `Are you sure you want to ${overwriteAction}?`,
69 initialValue: false,

Callers 1

scaffoldProjectFunction · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected