@dbcube/schema-builder 5.2.6 → 5.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/lib/Schema.ts
|
|
2
2
|
import fs5 from "fs";
|
|
3
|
-
import { Engine, TableProcessor, Config as ConfigClass } from "@dbcube/core";
|
|
3
|
+
import { Engine, TableProcessor, Config as ConfigClass, EnvLoader } from "@dbcube/core";
|
|
4
4
|
import path4 from "path";
|
|
5
5
|
|
|
6
6
|
// src/lib/FileUtils.ts
|
|
@@ -889,7 +889,9 @@ var Schema = class {
|
|
|
889
889
|
}
|
|
890
890
|
const cubeDbName = dbResult.message;
|
|
891
891
|
const configInstance = new ConfigClass();
|
|
892
|
-
|
|
892
|
+
EnvLoader.load();
|
|
893
|
+
const cjsPath = path4.resolve(process.cwd(), "dbcube.config.cjs");
|
|
894
|
+
const configFilePath = fs5.existsSync(cjsPath) ? cjsPath : path4.resolve(process.cwd(), "dbcube.config.js");
|
|
893
895
|
const requireUrl = typeof __filename !== "undefined" ? __filename : process.cwd();
|
|
894
896
|
const require2 = createRequire(requireUrl);
|
|
895
897
|
delete require2.cache[require2.resolve(configFilePath)];
|
|
@@ -898,25 +900,16 @@ var Schema = class {
|
|
|
898
900
|
if (typeof configFn === "function") {
|
|
899
901
|
configFn(configInstance);
|
|
900
902
|
} else {
|
|
901
|
-
throw new Error("\u274C The dbcube
|
|
903
|
+
throw new Error("\u274C The dbcube config file does not export a function.");
|
|
902
904
|
}
|
|
903
905
|
const dbConfig = configInstance.getDatabase(cubeDbName);
|
|
904
906
|
if (!dbConfig) {
|
|
905
907
|
let availableDbs = [];
|
|
906
908
|
try {
|
|
907
|
-
|
|
908
|
-
for (const testName of testNames) {
|
|
909
|
-
try {
|
|
910
|
-
const testConfig = configInstance.getDatabase(testName);
|
|
911
|
-
if (testConfig) {
|
|
912
|
-
availableDbs.push(testName);
|
|
913
|
-
}
|
|
914
|
-
} catch (e) {
|
|
915
|
-
}
|
|
916
|
-
}
|
|
909
|
+
availableDbs = Object.keys(configInstance.getAllDatabases() || {});
|
|
917
910
|
} catch (e) {
|
|
918
911
|
}
|
|
919
|
-
const availableText = availableDbs.length > 0 ? availableDbs.join(", ") : "none
|
|
912
|
+
const availableText = availableDbs.length > 0 ? availableDbs.join(", ") : "none configured";
|
|
920
913
|
return {
|
|
921
914
|
isValid: false,
|
|
922
915
|
error: {
|