Skip to main content
This page documents the key functions used by the Exon CLI in src.

Database Templates

resolveDbTemplate

a
Object
An object containing language (TypeScript | JavaScript) and database (Mongoose | Prisma | Drizzle | None).
return value
string | null
Returns a relative template path string like mongoose/ts or prisma/js. Returns null when None.
Determines which local database template path to use. Reference: src/resolveDbTemplates.ts

Configuration Merging

mergeDeps

targetDir
string
Path to the generated project root.
depsPath
string
Path to a deps.json file inside the template folder.
Merges deps.json into the new project’s package.json. It reads package.json at targetDir, merges dependencies, devDependencies, and scripts from depsPath, and writes back.

appendEnv

targetDir
string
Path to the generated project root.
envPath
string
Path to the environment variables block.
Appends contents of env.append to the project’s .env if present.

mergeDbConfigToRoot

targetDir
string
required
Path to the generated project root.
templateDir
string
required
Path to the selected DB template folder.
Copies database config files from templateDir into targetDir, filtering out CLI internal files such as env.append, deps.json, template entrypoints, and Prisma schema (if present). Reference: src/dbHelper.ts

Docker Support

addDocker

options
Object
Command-line options including docker.
language
string
Selected language (TypeScript | JavaScript).
targetDir
string
Path to the generated project root.
Handles the Docker setup logic. It checks for the --docker flag and, if not present, prompts the user to enable Docker support.

createDockerFile

language
string
Selected language (TypeScript | JavaScript).
targetDir
string
Path to the generated project root.
Generates an optimized Dockerfile and .dockerignore based on the project’s language in targetDir.

Main CLI Flow

index (CLI entry)

src/index.ts orchestrates the entire flow using commander and @clack/prompts:
  1. Build template path from language
  2. Copy template to target folder
  3. Resolve and copy DB template (if selected)
  4. Generate Docker configuration (if enabled)
  5. Merge deps, append env, merge DB config, and run npm install