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.
35 lines (34 loc) • 1.2 kB
JavaScript
import { setupDirsFiles } from "./utils/setupFiles.js";
import { loadConfig } from "./utils/loadConfigs.js";
import path from "path";
import fs from "fs";
import { MessageFormatter } from "./shared/messageFormatter.js";
export class SetupController {
currentDir;
config = null;
constructor(currentDir) {
this.currentDir = currentDir;
}
async runSetup(withExampleData = false) {
await setupDirsFiles(withExampleData, this.currentDir);
MessageFormatter.success("Setup completed successfully", { prefix: "Setup" });
}
async loadConfig() {
if (this.hasExistingConfig()) {
try {
const appwriteDir = path.join(this.currentDir, "appwrite");
this.config = await loadConfig(appwriteDir);
return this.config;
}
catch (error) {
MessageFormatter.error("Error loading config", error, { prefix: "Setup" });
return null;
}
}
return null;
}
hasExistingConfig() {
const configPath = path.join(this.currentDir, "appwrite", "appwriteConfig.ts");
return fs.existsSync(configPath);
}
}