mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
organize code
This commit is contained in:
32
apps/cli/src/utils/display-config.ts
Normal file
32
apps/cli/src/utils/display-config.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import pc from "picocolors";
|
||||
import type { ProjectConfig } from "../types";
|
||||
|
||||
export function displayConfig(config: Partial<ProjectConfig>) {
|
||||
const configDisplay = [];
|
||||
|
||||
if (config.projectName) {
|
||||
configDisplay.push(`${pc.blue("Project Name:")} ${config.projectName}`);
|
||||
}
|
||||
if (config.database) {
|
||||
configDisplay.push(`${pc.blue("Database:")} ${config.database}`);
|
||||
}
|
||||
if (config.orm) {
|
||||
configDisplay.push(`${pc.blue("ORM:")} ${config.orm}`);
|
||||
}
|
||||
if (config.auth !== undefined) {
|
||||
configDisplay.push(`${pc.blue("Authentication:")} ${config.auth}`);
|
||||
}
|
||||
if (config.features?.length) {
|
||||
configDisplay.push(`${pc.blue("Features:")} ${config.features.join(", ")}`);
|
||||
}
|
||||
if (config.git !== undefined) {
|
||||
configDisplay.push(`${pc.blue("Git Init:")} ${config.git}`);
|
||||
}
|
||||
if (config.packageManager) {
|
||||
configDisplay.push(
|
||||
`${pc.blue("Package Manager:")} ${config.packageManager}`,
|
||||
);
|
||||
}
|
||||
|
||||
return configDisplay.join("\n");
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_CONFIG } from "../consts";
|
||||
import { DEFAULT_CONFIG } from "../constants";
|
||||
import type { ProjectConfig } from "../types";
|
||||
|
||||
export function generateReproducibleCommand(config: ProjectConfig): string {
|
||||
@@ -14,11 +14,17 @@ export function generateReproducibleCommand(config: ProjectConfig): string {
|
||||
flags.push("-y");
|
||||
}
|
||||
|
||||
// Handle database flag
|
||||
if (config.database !== DEFAULT_CONFIG.database) {
|
||||
flags.push(config.database === "sqlite" ? "--sqlite" : "--postgres");
|
||||
if (config.database === "none") {
|
||||
flags.push("--no-database");
|
||||
} else {
|
||||
flags.push(config.database === "sqlite" ? "--sqlite" : "--postgres");
|
||||
}
|
||||
}
|
||||
|
||||
if (config.orm !== DEFAULT_CONFIG.orm) {
|
||||
// Handle ORM flag only if database is not "none"
|
||||
if (config.database !== "none" && config.orm !== DEFAULT_CONFIG.orm) {
|
||||
flags.push(config.orm === "drizzle" ? "--drizzle" : "--prisma");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from "node:path";
|
||||
import fs from "fs-extra";
|
||||
import { PKG_ROOT } from "../consts";
|
||||
import { PKG_ROOT } from "../constants";
|
||||
|
||||
export const getVersion = () => {
|
||||
const packageJsonPath = path.join(PKG_ROOT, "package.json");
|
||||
|
||||
Reference in New Issue
Block a user