|
|
|
@@ -1,86 +1,125 @@
|
|
|
|
|
"use strict";
|
|
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.default = grabDirNames;
|
|
|
|
|
const path_1 = __importDefault(require("path"));
|
|
|
|
|
function grabDirNames(param) {
|
|
|
|
|
import path from "path";
|
|
|
|
|
export default function grabDirNames(param) {
|
|
|
|
|
var _a;
|
|
|
|
|
const appDir = (param === null || param === void 0 ? void 0 : param.appDir) || process.env.DSQL_APP_DIR;
|
|
|
|
|
const STATIC_ROOT = process.env.DSQL_STATIC_SERVER_DIR || "/static";
|
|
|
|
|
const DATA_DIR = (param === null || param === void 0 ? void 0 : param.dataDir) || process.env.DSQL_DATA_DIR || "/data";
|
|
|
|
|
const finalUserId = ((_a = param === null || param === void 0 ? void 0 : param.user) === null || _a === void 0 ? void 0 : _a.id) || (param === null || param === void 0 ? void 0 : param.userId);
|
|
|
|
|
const publicImagesDir = path_1.default.join(STATIC_ROOT, `images`);
|
|
|
|
|
if (!appDir)
|
|
|
|
|
throw new Error("Please provide the `DSQL_APP_DIR` env variable.");
|
|
|
|
|
const schemasDir = process.env.DSQL_DB_SCHEMA_DIR ||
|
|
|
|
|
path_1.default.join(appDir, "jsonData", "dbSchemas");
|
|
|
|
|
if (!DATA_DIR)
|
|
|
|
|
throw new Error("Please provide the `DATA_DIR` env variable.");
|
|
|
|
|
const STATIC_ROOT = path.join(DATA_DIR, "static");
|
|
|
|
|
const publicImagesDir = path.join(STATIC_ROOT, `images`);
|
|
|
|
|
const publicDir = path.join(appDir, "public");
|
|
|
|
|
const publicSSLDir = path.join(publicDir, "documents", "ssl");
|
|
|
|
|
const appSSLDir = path.join(appDir, "ssl");
|
|
|
|
|
const mainSSLDir = path.join(DATA_DIR, "ssl");
|
|
|
|
|
const privateDataDir = path.join(DATA_DIR, "private");
|
|
|
|
|
/**
|
|
|
|
|
* # DB Dir names
|
|
|
|
|
* @description Database related Directories
|
|
|
|
|
*/
|
|
|
|
|
const mainDbDataDir = path.join(DATA_DIR, "db");
|
|
|
|
|
const mainDbGrastateDatFile = path.join(mainDbDataDir, "grastate.dat");
|
|
|
|
|
const replica1DbDataDir = path.join(DATA_DIR, "replica-1");
|
|
|
|
|
const mariadbMainConfigDir = path.join(DATA_DIR, "db-config", "main");
|
|
|
|
|
const mariadbReplicaConfigDir = path.join(DATA_DIR, "db-config", "replica");
|
|
|
|
|
const maxscaleConfigDir = path.join(DATA_DIR, "db-config", "maxscale");
|
|
|
|
|
const mariadbMainConfigFile = path.join(mariadbMainConfigDir, "default.cnf");
|
|
|
|
|
const mariadbReplicaConfigFile = path.join(mariadbReplicaConfigDir, "default.cnf");
|
|
|
|
|
const galeraConfigFile = path.join(mariadbMainConfigDir, "galera.cnf");
|
|
|
|
|
const galeraReplicaConfigFile = path.join(mariadbReplicaConfigDir, "galera.cnf");
|
|
|
|
|
const maxscaleConfigFile = path.join(maxscaleConfigDir, "maxscale.cnf");
|
|
|
|
|
/**
|
|
|
|
|
* # Schema Dir names
|
|
|
|
|
* @description
|
|
|
|
|
*/
|
|
|
|
|
const oldSchemasDir = path.join(appDir, "jsonData", "dbSchemas");
|
|
|
|
|
const appSchemaJSONFile = path.join(oldSchemasDir, "1.json");
|
|
|
|
|
const tempDirName = ".tmp";
|
|
|
|
|
if (!schemasDir)
|
|
|
|
|
const appConfigDir = path.join(appDir, "jsonData", "config");
|
|
|
|
|
const appConfigJSONFile = path.join(appConfigDir, "app-config.json");
|
|
|
|
|
if (!privateDataDir)
|
|
|
|
|
throw new Error("Please provide the `DSQL_DB_SCHEMA_DIR` env variable.");
|
|
|
|
|
const pakageSharedDir = path_1.default.join(appDir, `package-shared`);
|
|
|
|
|
const mainDbTypeDefFile = path_1.default.join(pakageSharedDir, `types/dsql.ts`);
|
|
|
|
|
const mainShemaJSONFilePath = path_1.default.join(schemasDir, `main.json`);
|
|
|
|
|
const defaultTableFieldsJSONFilePath = path_1.default.join(pakageSharedDir, `data/defaultFields.json`);
|
|
|
|
|
const usersSchemaDir = path_1.default.join(schemasDir, `users`);
|
|
|
|
|
const targetUserSchemaDir = finalUserId
|
|
|
|
|
? path_1.default.join(usersSchemaDir, `user-${finalUserId}`)
|
|
|
|
|
const pakageSharedDir = path.join(appDir, `package-shared`);
|
|
|
|
|
const mainDbTypeDefFile = path.join(pakageSharedDir, `types/dsql.ts`);
|
|
|
|
|
const mainShemaJSONFilePath = path.join(oldSchemasDir, `main.json`);
|
|
|
|
|
const defaultTableFieldsJSONFilePath = path.join(pakageSharedDir, `data/defaultFields.json`);
|
|
|
|
|
const usersSchemaDir = path.join(privateDataDir, `users`);
|
|
|
|
|
const targetUserPrivateDir = finalUserId
|
|
|
|
|
? path.join(usersSchemaDir, `user-${finalUserId}`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userTempSQLFilePath = targetUserSchemaDir
|
|
|
|
|
? path_1.default.join(targetUserSchemaDir, `tmp.sql`)
|
|
|
|
|
const userTempSQLFilePath = targetUserPrivateDir
|
|
|
|
|
? path.join(targetUserPrivateDir, `tmp.sql`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userDirPath = finalUserId
|
|
|
|
|
? path_1.default.join(usersSchemaDir, `user-${finalUserId}`)
|
|
|
|
|
const userMainShemaJSONFilePath = targetUserPrivateDir
|
|
|
|
|
? path.join(targetUserPrivateDir, `main.json`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userSchemaMainJSONFilePath = userDirPath
|
|
|
|
|
? path_1.default.join(userDirPath, `main.json`)
|
|
|
|
|
const userConfigJSONFilePath = targetUserPrivateDir
|
|
|
|
|
? path.join(targetUserPrivateDir, `config.json`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPrivateMediaDir = userDirPath
|
|
|
|
|
? path_1.default.join(userDirPath, `media`)
|
|
|
|
|
const userSchemaMainJSONFilePath = targetUserPrivateDir
|
|
|
|
|
? path.join(targetUserPrivateDir, `main.json`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPrivateExportsDir = userDirPath
|
|
|
|
|
? path_1.default.join(userDirPath, `export`)
|
|
|
|
|
const userPrivateMediaDir = targetUserPrivateDir
|
|
|
|
|
? path.join(targetUserPrivateDir, `media`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPrivateExportsDir = targetUserPrivateDir
|
|
|
|
|
? path.join(targetUserPrivateDir, `export`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPrivateSQLExportsDir = userPrivateExportsDir
|
|
|
|
|
? path_1.default.join(userPrivateExportsDir, `sql`)
|
|
|
|
|
? path.join(userPrivateExportsDir, `sql`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPrivateTempSQLExportsDir = userPrivateSQLExportsDir
|
|
|
|
|
? path_1.default.join(userPrivateSQLExportsDir, tempDirName)
|
|
|
|
|
? path.join(userPrivateSQLExportsDir, tempDirName)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPrivateTempJSONSchemaFilePath = userPrivateTempSQLExportsDir
|
|
|
|
|
? path_1.default.join(userPrivateTempSQLExportsDir, `schema.json`)
|
|
|
|
|
? path.join(userPrivateTempSQLExportsDir, `schema.json`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPrivateDbExportZipFileName = `db-export.zip`;
|
|
|
|
|
const userPrivateDbExportZipFilePath = userPrivateSQLExportsDir
|
|
|
|
|
? path_1.default.join(userPrivateSQLExportsDir, userPrivateDbExportZipFileName)
|
|
|
|
|
? path.join(userPrivateSQLExportsDir, userPrivateDbExportZipFileName)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPublicMediaDir = finalUserId
|
|
|
|
|
? path_1.default.join(publicImagesDir, `user-images/user-${finalUserId}`)
|
|
|
|
|
? path.join(publicImagesDir, `user-images/user-${finalUserId}`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const userPrivateDbImportZipFileName = `db-export.zip`;
|
|
|
|
|
const userPrivateDbImportZipFilePath = userPrivateSQLExportsDir
|
|
|
|
|
? path_1.default.join(userPrivateSQLExportsDir, userPrivateDbImportZipFileName)
|
|
|
|
|
? path.join(userPrivateSQLExportsDir, userPrivateDbImportZipFileName)
|
|
|
|
|
: undefined;
|
|
|
|
|
const dbNginxLoadBalancerConfigFile = path_1.default.join(appDir, "docker/services/mariadb/load-balancer/config/template/nginx.conf");
|
|
|
|
|
let dockerComposeFile = path_1.default.join(appDir, "docker-compose.yml");
|
|
|
|
|
let dockerComposeFileAlt = path_1.default.join(appDir, "docker-compose.yaml");
|
|
|
|
|
const testDockerComposeFile = path_1.default.join(appDir, "test.docker-compose.yml");
|
|
|
|
|
const testDockerComposeFileAlt = path_1.default.join(appDir, "test.docker-compose.yaml");
|
|
|
|
|
const extraDockerComposeFile = path_1.default.join(appDir, "extra.docker-compose.yml");
|
|
|
|
|
const extraDockerComposeFileAlt = path_1.default.join(appDir, "extra.docker-compose.yaml");
|
|
|
|
|
const siteSetupFile = path_1.default.join(appDir, "site-setup.json");
|
|
|
|
|
const envFile = path_1.default.join(appDir, ".env");
|
|
|
|
|
const testEnvFile = path_1.default.join(appDir, "test.env");
|
|
|
|
|
const dbNginxLoadBalancerConfigFile = path.join(appDir, "docker/services/mariadb/load-balancer/config/template/nginx.conf");
|
|
|
|
|
let dockerComposeFile = path.join(appDir, "docker-compose.yml");
|
|
|
|
|
let dockerComposeFileAlt = path.join(appDir, "docker-compose.yaml");
|
|
|
|
|
const testDockerComposeFile = path.join(appDir, "test.docker-compose.yml");
|
|
|
|
|
const testDockerComposeFileAlt = path.join(appDir, "test.docker-compose.yaml");
|
|
|
|
|
const dbDockerComposeFile = path.join(appDir, "db.docker-compose.yml");
|
|
|
|
|
const dbDockerComposeFileAlt = path.join(appDir, "db.docker-compose.yaml");
|
|
|
|
|
const extraDockerComposeFile = path.join(appDir, "extra.docker-compose.yml");
|
|
|
|
|
const extraDockerComposeFileAlt = path.join(appDir, "extra.docker-compose.yaml");
|
|
|
|
|
const siteSetupFile = path.join(appDir, "site-setup.json");
|
|
|
|
|
const envFile = path.join(appDir, ".env");
|
|
|
|
|
const testEnvFile = path.join(appDir, "test.env");
|
|
|
|
|
/**
|
|
|
|
|
* # Backup Dir names
|
|
|
|
|
* @description
|
|
|
|
|
*/
|
|
|
|
|
const mainBackupDir = path.join(DATA_DIR, "backups");
|
|
|
|
|
const userBackupDir = targetUserPrivateDir
|
|
|
|
|
? path.join(targetUserPrivateDir, `backups`)
|
|
|
|
|
: undefined;
|
|
|
|
|
const sqlBackupDirName = `sql`;
|
|
|
|
|
const schemasBackupDirName = `schema`;
|
|
|
|
|
return {
|
|
|
|
|
appDir,
|
|
|
|
|
schemasDir,
|
|
|
|
|
userDirPath,
|
|
|
|
|
privateDataDir,
|
|
|
|
|
oldSchemasDir,
|
|
|
|
|
userConfigJSONFilePath,
|
|
|
|
|
mainShemaJSONFilePath,
|
|
|
|
|
mainDbTypeDefFile,
|
|
|
|
|
tempDirName,
|
|
|
|
|
defaultTableFieldsJSONFilePath,
|
|
|
|
|
usersSchemaDir,
|
|
|
|
|
targetUserSchemaDir,
|
|
|
|
|
targetUserPrivateDir,
|
|
|
|
|
userSchemaMainJSONFilePath,
|
|
|
|
|
userPrivateMediaDir,
|
|
|
|
|
userPrivateExportsDir,
|
|
|
|
@@ -103,5 +142,32 @@ function grabDirNames(param) {
|
|
|
|
|
testEnvFile,
|
|
|
|
|
userPublicMediaDir,
|
|
|
|
|
userTempSQLFilePath,
|
|
|
|
|
STATIC_ROOT,
|
|
|
|
|
appConfigJSONFile,
|
|
|
|
|
appConfigDir,
|
|
|
|
|
mariadbMainConfigDir,
|
|
|
|
|
mariadbMainConfigFile,
|
|
|
|
|
maxscaleConfigDir,
|
|
|
|
|
mariadbReplicaConfigDir,
|
|
|
|
|
DATA_DIR,
|
|
|
|
|
publicDir,
|
|
|
|
|
publicSSLDir,
|
|
|
|
|
appSSLDir,
|
|
|
|
|
maxscaleConfigFile,
|
|
|
|
|
mariadbReplicaConfigFile,
|
|
|
|
|
mainSSLDir,
|
|
|
|
|
mainDbDataDir,
|
|
|
|
|
replica1DbDataDir,
|
|
|
|
|
galeraConfigFile,
|
|
|
|
|
galeraReplicaConfigFile,
|
|
|
|
|
dbDockerComposeFile,
|
|
|
|
|
dbDockerComposeFileAlt,
|
|
|
|
|
mainDbGrastateDatFile,
|
|
|
|
|
appSchemaJSONFile,
|
|
|
|
|
mainBackupDir,
|
|
|
|
|
userBackupDir,
|
|
|
|
|
sqlBackupDirName,
|
|
|
|
|
schemasBackupDirName,
|
|
|
|
|
userMainShemaJSONFilePath,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|