mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Fix error when compiling ormconfig
This commit is contained in:
parent
e760654c54
commit
6b44027eb4
4 changed files with 19 additions and 30 deletions
|
@ -1,38 +1,23 @@
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const pkgUp = require("pkg-up");
|
const pkgUp = require("pkg-up");
|
||||||
|
const { backendDir } = require("./dist/backend/src/paths");
|
||||||
const closestPackageJson = pkgUp.sync();
|
const { env } = require("./dist/backend/src/env");
|
||||||
if (!closestPackageJson) {
|
|
||||||
throw new Error("Could not find project root from ormconfig.js");
|
|
||||||
}
|
|
||||||
const backendRoot = path.dirname(closestPackageJson);
|
|
||||||
|
|
||||||
try {
|
|
||||||
fs.accessSync(path.resolve(backendRoot, "bot.env"));
|
|
||||||
require("dotenv").config({ path: path.resolve(backendRoot, "bot.env") });
|
|
||||||
} catch {
|
|
||||||
try {
|
|
||||||
fs.accessSync(path.resolve(backendRoot, "api.env"));
|
|
||||||
require("dotenv").config({ path: path.resolve(backendRoot, "api.env") });
|
|
||||||
} catch {
|
|
||||||
throw new Error("bot.env or api.env required");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const moment = require("moment-timezone");
|
const moment = require("moment-timezone");
|
||||||
moment.tz.setDefault("UTC");
|
moment.tz.setDefault("UTC");
|
||||||
|
|
||||||
const entities = path.relative(process.cwd(), path.resolve(backendRoot, "dist/backend/src/data/entities/*.js"));
|
const entities = path.relative(process.cwd(), path.resolve(backendDir, "dist/backend/src/data/entities/*.js"));
|
||||||
const migrations = path.relative(process.cwd(), path.resolve(backendRoot, "dist/backend/src/migrations/*.js"));
|
const migrations = path.relative(process.cwd(), path.resolve(backendDir, "dist/backend/src/migrations/*.js"));
|
||||||
const migrationsDir = path.relative(process.cwd(), path.resolve(backendRoot, "src/migrations"));
|
const migrationsDir = path.relative(process.cwd(), path.resolve(backendDir, "src/migrations"));
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
type: "mysql",
|
type: "mysql",
|
||||||
host: process.env.DB_HOST,
|
host: env.DB_HOST,
|
||||||
username: process.env.DB_USER,
|
port: env.DB_PORT,
|
||||||
password: process.env.DB_PASSWORD,
|
username: env.DB_USER,
|
||||||
database: process.env.DB_DATABASE,
|
password: env.DB_PASSWORD,
|
||||||
|
database: env.DB_DATABASE,
|
||||||
charset: "utf8mb4",
|
charset: "utf8mb4",
|
||||||
supportBigNumbers: true,
|
supportBigNumbers: true,
|
||||||
bigNumberStrings: true,
|
bigNumberStrings: true,
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
import { Connection, createConnection } from "typeorm";
|
import { Connection, createConnection } from "typeorm";
|
||||||
import { SimpleError } from "../SimpleError";
|
import { SimpleError } from "../SimpleError";
|
||||||
import connectionOptions from "../../ormconfig";
|
|
||||||
import { QueryLogger } from "./queryLogger";
|
import { QueryLogger } from "./queryLogger";
|
||||||
|
import path from "path";
|
||||||
|
import { backendDir } from "../paths";
|
||||||
|
|
||||||
|
const ormconfigPath = path.join(backendDir, "ormconfig.js");
|
||||||
|
const connectionOptions = require(ormconfigPath);
|
||||||
|
|
||||||
let connectionPromise: Promise<Connection>;
|
let connectionPromise: Promise<Connection>;
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import { z } from "zod";
|
||||||
const envType = z.object({
|
const envType = z.object({
|
||||||
KEY: z.string().length(32),
|
KEY: z.string().length(32),
|
||||||
|
|
||||||
CLIENT_ID: z.string(),
|
CLIENT_ID: z.string().min(16),
|
||||||
CLIENT_SECRET: z.string(),
|
CLIENT_SECRET: z.string().length(32),
|
||||||
BOT_TOKEN: z.string(),
|
BOT_TOKEN: z.string().min(50),
|
||||||
|
|
||||||
OAUTH_CALLBACK_URL: z.string().url(),
|
OAUTH_CALLBACK_URL: z.string().url(),
|
||||||
DASHBOARD_DOMAIN: z.string(),
|
DASHBOARD_DOMAIN: z.string(),
|
||||||
|
|
|
@ -24,5 +24,5 @@
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
"allowJs": true
|
"allowJs": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "ormconfig.js"]
|
"include": ["src/**/*.ts"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue