(options: {
name?: string;
packageManager?: PackageManagerName;
disableGit?: boolean;
branch?: string;
})
| 223 | }; |
| 224 | |
| 225 | export const initialize = async (options: { |
| 226 | name?: string; |
| 227 | packageManager?: PackageManagerName; |
| 228 | disableGit?: boolean; |
| 229 | branch?: string; |
| 230 | }) => { |
| 231 | try { |
| 232 | intro("Let's start a next-forge project!"); |
| 233 | |
| 234 | const cwd = process.cwd(); |
| 235 | const name = options.name || (await getName()); |
| 236 | const packageManager = |
| 237 | options.packageManager || (await getPackageManager()); |
| 238 | |
| 239 | if (!supportedPackageManagers.includes(packageManager)) { |
| 240 | throw new Error("Invalid package manager"); |
| 241 | } |
| 242 | |
| 243 | const s = spinner(); |
| 244 | const projectDir = join(cwd, name); |
| 245 | |
| 246 | s.start("Cloning next-forge..."); |
| 247 | cloneNextForge(name, packageManager, options.branch); |
| 248 | |
| 249 | s.message("Moving into repository..."); |
| 250 | process.chdir(projectDir); |
| 251 | |
| 252 | if (packageManager !== "bun") { |
| 253 | s.message("Updating package manager configuration..."); |
| 254 | await updatePackageManagerConfiguration(projectDir, packageManager); |
| 255 | |
| 256 | s.message("Updating workspace config..."); |
| 257 | await updateWorkspaceConfiguration(projectDir, packageManager); |
| 258 | |
| 259 | if (packageManager !== "pnpm") { |
| 260 | s.message("Updating workspace dependencies..."); |
| 261 | await updateInternalDependencies(projectDir); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | s.message("Setting up environment variable files..."); |
| 266 | await setupEnvironmentVariables(); |
| 267 | |
| 268 | s.message("Deleting internal content..."); |
| 269 | await deleteInternalContent(); |
| 270 | |
| 271 | s.message("Installing dependencies..."); |
| 272 | await installDependencies(packageManager); |
| 273 | |
| 274 | s.message("Setting up ORM..."); |
| 275 | setupOrm(packageManager); |
| 276 | |
| 277 | if (!options.disableGit) { |
| 278 | s.message("Initializing Git repository..."); |
| 279 | initializeGit(); |
| 280 | } |
| 281 | |
| 282 | s.stop("Project initialized successfully!"); |
nothing calls this directly
no test coverage detected