masterrecord 0.3.52 → 0.3.54
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/Entity/entityModel.js +5 -0
- package/context.js +27 -15
- package/package.json +1 -1
package/Entity/entityModel.js
CHANGED
package/context.js
CHANGED
|
@@ -663,8 +663,16 @@ class context {
|
|
|
663
663
|
*/
|
|
664
664
|
env(rootFolderLocationOrConfig) {
|
|
665
665
|
try {
|
|
666
|
-
// Determine environment: prefer explicit, then NODE_ENV
|
|
667
|
-
|
|
666
|
+
// Determine environment: prefer explicit 'master' env var, then NODE_ENV
|
|
667
|
+
// Schema-only CLI commands (add-migration, enable-migrations) may run without
|
|
668
|
+
// an environment set — allow fallback to 'development' for those.
|
|
669
|
+
const envType = this.__environment || process.env.NODE_ENV
|
|
670
|
+
|| (process.env.MASTERRECORD_SCHEMA_ONLY === '1' ? 'development' : null);
|
|
671
|
+
if (!envType) {
|
|
672
|
+
throw new ConfigurationError(
|
|
673
|
+
"No environment specified. Set the 'master' or 'NODE_ENV' environment variable (e.g., master=production or NODE_ENV=development)."
|
|
674
|
+
);
|
|
675
|
+
}
|
|
668
676
|
const contextName = this.__name;
|
|
669
677
|
|
|
670
678
|
// Try multiple base roots for robustness
|
|
@@ -897,7 +905,12 @@ class context {
|
|
|
897
905
|
this.isPostgres = false;
|
|
898
906
|
|
|
899
907
|
const root = process.cwd();
|
|
900
|
-
const envType = this.__environment ||
|
|
908
|
+
const envType = this.__environment || process.env.NODE_ENV;
|
|
909
|
+
if (!envType) {
|
|
910
|
+
throw new ConfigurationError(
|
|
911
|
+
"No environment specified. Set the 'master' or 'NODE_ENV' environment variable (e.g., master=production or NODE_ENV=development)."
|
|
912
|
+
);
|
|
913
|
+
}
|
|
901
914
|
const contextName = this.__name;
|
|
902
915
|
const file = this.__findSettings(root, rootFolderLocation, envType);
|
|
903
916
|
const settings = require(file.file);
|
|
@@ -970,19 +983,13 @@ class context {
|
|
|
970
983
|
throw new ConfigurationError('Configuration object is missing or invalid');
|
|
971
984
|
}
|
|
972
985
|
|
|
973
|
-
// Normalize type
|
|
986
|
+
// Normalize type — require explicit type, no silent inference
|
|
974
987
|
let type = (options.type || '').toString().toLowerCase();
|
|
975
988
|
if (!type) {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
} else if (options.host || options.user || options.database) {
|
|
981
|
-
type = DB_TYPES.MYSQL;
|
|
982
|
-
options.type = DB_TYPES.MYSQL;
|
|
983
|
-
} else {
|
|
984
|
-
throw new ConfigurationError('Cannot infer database type from configuration. Please specify type: "sqlite", "mysql", or "postgres".');
|
|
985
|
-
}
|
|
989
|
+
throw new ConfigurationError(
|
|
990
|
+
'Database type is required. Please specify type: "sqlite", "mysql", or "postgres" in your configuration.',
|
|
991
|
+
{ providedOptions: Object.keys(options) }
|
|
992
|
+
);
|
|
986
993
|
}
|
|
987
994
|
|
|
988
995
|
// SQLite validation
|
|
@@ -1061,7 +1068,12 @@ class context {
|
|
|
1061
1068
|
this.isSQLite = false;
|
|
1062
1069
|
this.isPostgres = false;
|
|
1063
1070
|
|
|
1064
|
-
const envType = this.__environment ||
|
|
1071
|
+
const envType = this.__environment || process.env.NODE_ENV;
|
|
1072
|
+
if (!envType) {
|
|
1073
|
+
throw new ConfigurationError(
|
|
1074
|
+
"No environment specified. Set the 'master' or 'NODE_ENV' environment variable (e.g., master=production or NODE_ENV=development)."
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1065
1077
|
const contextName = this.__name;
|
|
1066
1078
|
const root = appRoot.path;
|
|
1067
1079
|
const file = this.__findSettings(root, rootFolderLocation, envType);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masterrecord",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.54",
|
|
4
4
|
"description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
|
|
5
5
|
"main": "MasterRecord.js",
|
|
6
6
|
"bin": {
|