feat: add command (#337)

This commit is contained in:
Aman Varshney
2025-06-22 03:20:05 +05:30
committed by GitHub
parent 198d0e7434
commit 9c7a0f0110
29 changed files with 1015 additions and 255 deletions

View File

@@ -0,0 +1,43 @@
import path from "node:path";
import fs from "fs-extra";
import type { ProjectConfig } from "../../types";
import { readBtsConfig } from "../../utils/bts-config";
export async function detectProjectConfig(
projectDir: string,
): Promise<Partial<ProjectConfig> | null> {
try {
const btsConfig = await readBtsConfig(projectDir);
if (btsConfig) {
return {
projectDir,
projectName: path.basename(projectDir),
database: btsConfig.database,
orm: btsConfig.orm,
backend: btsConfig.backend,
runtime: btsConfig.runtime,
frontend: btsConfig.frontend,
addons: btsConfig.addons,
examples: btsConfig.examples,
auth: btsConfig.auth,
packageManager: btsConfig.packageManager,
dbSetup: btsConfig.dbSetup,
api: btsConfig.api,
};
}
return null;
} catch (_error) {
return null;
}
}
export async function isBetterTStackProject(
projectDir: string,
): Promise<boolean> {
try {
return await fs.pathExists(path.join(projectDir, "bts.jsonc"));
} catch (_error) {
return false;
}
}