UNPKG

appwrite-utils-cli

Version:

Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.

34 lines (33 loc) 1.07 kB
import { setupDirsFiles } from "./utils/setupFiles.js"; import { loadConfig } from "./utils/loadConfigs.js"; import path from "path"; import fs from "fs"; export class SetupController { currentDir; config = null; constructor(currentDir) { this.currentDir = currentDir; } async runSetup(withExampleData = false) { await setupDirsFiles(withExampleData, this.currentDir); console.log("Setup completed successfully."); } async loadConfig() { if (this.hasExistingConfig()) { try { const appwriteDir = path.join(this.currentDir, "appwrite"); this.config = await loadConfig(appwriteDir); return this.config; } catch (error) { console.error("Error loading config:", error); return null; } } return null; } hasExistingConfig() { const configPath = path.join(this.currentDir, "appwrite", "appwriteConfig.ts"); return fs.existsSync(configPath); } }