mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Reorganize project. Add folder for shared code between backend/dashboard. Switch from jest to ava for tests.
This commit is contained in:
parent
80a82fe348
commit
16111bbe84
162 changed files with 11056 additions and 9900 deletions
40
backend/src/migrateConfigsToDB.ts
Normal file
40
backend/src/migrateConfigsToDB.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
// tslint:disable:no-console
|
||||
import { connect } from "./data/db";
|
||||
import { Configs } from "./data/Configs";
|
||||
import path from "path";
|
||||
import * as _fs from "fs";
|
||||
const fs = _fs.promises;
|
||||
|
||||
const authorId = process.argv[2];
|
||||
if (!authorId) {
|
||||
console.error("No author id specified");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("Connecting to database");
|
||||
connect().then(async () => {
|
||||
const configs = new Configs();
|
||||
|
||||
console.log("Loading config files");
|
||||
const configDir = path.join(__dirname, "..", "config");
|
||||
const configFiles = await fs.readdir(configDir);
|
||||
|
||||
console.log("Looping through config files");
|
||||
for (const configFile of configFiles) {
|
||||
const parts = configFile.split(".");
|
||||
const ext = parts[parts.length - 1];
|
||||
if (ext !== "yml") continue;
|
||||
|
||||
const id = parts.slice(0, -1).join(".");
|
||||
const key = id === "global" ? "global" : `guild-${id}`;
|
||||
if (await configs.hasConfig(key)) continue;
|
||||
|
||||
const content = await fs.readFile(path.join(configDir, configFile), { encoding: "utf8" });
|
||||
|
||||
console.log(`Migrating config for ${key}`);
|
||||
await configs.saveNewRevision(key, content, authorId);
|
||||
}
|
||||
|
||||
console.log("Done!");
|
||||
process.exit(0);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue