tego 1.3.55-alpha.1 → 1.6.0-alpha.1
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/lib/constants.js +4 -1
- package/lib/utils.js +6 -2
- package/package.json +16 -16
- package/src/constants.ts +8 -2
- package/src/utils.ts +7 -2
package/lib/constants.js
CHANGED
|
@@ -38,13 +38,16 @@ module.exports = __toCommonJS(constants_exports);
|
|
|
38
38
|
var import_node_fs = __toESM(require("node:fs"));
|
|
39
39
|
var import_node_path = __toESM(require("node:path"));
|
|
40
40
|
var import_globals = __toESM(require("@tachybase/globals"));
|
|
41
|
+
var import_lodash = __toESM(require("lodash"));
|
|
41
42
|
var import_utils = require("./utils");
|
|
42
43
|
(0, import_utils.parseEnvironment)();
|
|
43
44
|
if (!import_node_fs.default.existsSync(`${process.env.TEGO_RUNTIME_HOME}/settings.js`)) {
|
|
44
45
|
import_node_fs.default.mkdirSync(`${process.env.TEGO_RUNTIME_HOME}`, { recursive: true });
|
|
45
46
|
import_node_fs.default.copyFileSync(import_node_path.default.join(__dirname, "../presets/settings.js"), `${process.env.TEGO_RUNTIME_HOME}/settings.js`);
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
const baseSettings = require(`${process.env.TEGO_RUNTIME_HOME}/settings.js`);
|
|
49
|
+
const envSettings = (0, import_utils.convertEnvToSettings)(process.env);
|
|
50
|
+
import_globals.default.settings = import_lodash.default.merge({}, baseSettings, envSettings);
|
|
48
51
|
for (const key in import_globals.default.settings.env) {
|
|
49
52
|
if (!process.env[key]) {
|
|
50
53
|
process.env[key] = import_globals.default.settings.env[key];
|
package/lib/utils.js
CHANGED
|
@@ -212,7 +212,7 @@ function convertEnvToSettings(flatEnv) {
|
|
|
212
212
|
};
|
|
213
213
|
for (const key in flatEnv) {
|
|
214
214
|
const value = flatEnv[key];
|
|
215
|
-
if (value === void 0) continue;
|
|
215
|
+
if (value === void 0 || value === "") continue;
|
|
216
216
|
if (key.startsWith("LOGGER_")) {
|
|
217
217
|
const subKey = key.replace("LOGGER_", "").toLowerCase();
|
|
218
218
|
if (subKey === "transport") {
|
|
@@ -235,7 +235,11 @@ function convertEnvToSettings(flatEnv) {
|
|
|
235
235
|
settings.database.ssl = settings.database.ssl || {};
|
|
236
236
|
settings.database.ssl[sslKey] = value;
|
|
237
237
|
} else {
|
|
238
|
-
|
|
238
|
+
if (subKey === "logging" || subKey === "underscored") {
|
|
239
|
+
settings.database[subKey] = value === "true";
|
|
240
|
+
} else {
|
|
241
|
+
settings.database[subKey] = value;
|
|
242
|
+
}
|
|
239
243
|
}
|
|
240
244
|
continue;
|
|
241
245
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tego",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tego",
|
|
@@ -49,21 +49,21 @@
|
|
|
49
49
|
"umzug": "3.8.2",
|
|
50
50
|
"winston": "3.17.0",
|
|
51
51
|
"winston-daily-rotate-file": "^5.0.0",
|
|
52
|
-
"@tachybase/acl": "1.
|
|
53
|
-
"@tachybase/
|
|
54
|
-
"@tachybase/
|
|
55
|
-
"@tachybase/
|
|
56
|
-
"@tachybase/
|
|
57
|
-
"@tachybase/
|
|
58
|
-
"@tachybase/
|
|
59
|
-
"@tachybase/
|
|
60
|
-
"@tachybase/
|
|
61
|
-
"@tachybase/
|
|
62
|
-
"@tachybase/
|
|
63
|
-
"@tachybase/schema": "1.
|
|
64
|
-
"@tachybase/utils": "1.
|
|
65
|
-
"@tego/core": "1.
|
|
66
|
-
"@tego/server": "1.
|
|
52
|
+
"@tachybase/acl": "1.6.0-alpha.1",
|
|
53
|
+
"@tachybase/auth": "1.6.0-alpha.1",
|
|
54
|
+
"@tachybase/database": "1.6.0-alpha.1",
|
|
55
|
+
"@tachybase/evaluators": "1.6.0-alpha.1",
|
|
56
|
+
"@tachybase/cache": "1.6.0-alpha.1",
|
|
57
|
+
"@tachybase/data-source": "1.6.0-alpha.1",
|
|
58
|
+
"@tachybase/globals": "1.6.0-alpha.1",
|
|
59
|
+
"@tachybase/actions": "1.6.0-alpha.1",
|
|
60
|
+
"@tachybase/loader": "1.6.0-alpha.1",
|
|
61
|
+
"@tachybase/logger": "1.6.0-alpha.1",
|
|
62
|
+
"@tachybase/resourcer": "1.6.0-alpha.1",
|
|
63
|
+
"@tachybase/schema": "1.6.0-alpha.1",
|
|
64
|
+
"@tachybase/utils": "1.6.0-alpha.1",
|
|
65
|
+
"@tego/core": "1.6.0-alpha.1",
|
|
66
|
+
"@tego/server": "1.6.0-alpha.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/lodash": "4.17.20",
|
package/src/constants.ts
CHANGED
|
@@ -2,7 +2,9 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import TachybaseGlobal from '@tachybase/globals';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
|
|
7
|
+
import { convertEnvToSettings, parseEnvironment } from './utils';
|
|
6
8
|
|
|
7
9
|
// 解析环境变量
|
|
8
10
|
parseEnvironment();
|
|
@@ -12,7 +14,11 @@ if (!fs.existsSync(`${process.env.TEGO_RUNTIME_HOME}/settings.js`)) {
|
|
|
12
14
|
fs.mkdirSync(`${process.env.TEGO_RUNTIME_HOME}`, { recursive: true });
|
|
13
15
|
fs.copyFileSync(path.join(__dirname, '../presets/settings.js'), `${process.env.TEGO_RUNTIME_HOME}/settings.js`);
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
const baseSettings = require(`${process.env.TEGO_RUNTIME_HOME}/settings.js`);
|
|
18
|
+
|
|
19
|
+
// 用环境变量覆盖 settings.js 的配置 (环境变量优先)
|
|
20
|
+
const envSettings = convertEnvToSettings(process.env as any);
|
|
21
|
+
TachybaseGlobal.settings = _.merge({}, baseSettings, envSettings);
|
|
16
22
|
|
|
17
23
|
for (const key in TachybaseGlobal.settings.env) {
|
|
18
24
|
if (!process.env[key]) {
|
package/src/utils.ts
CHANGED
|
@@ -224,7 +224,7 @@ export function convertEnvToSettings(flatEnv: Record<string, string | undefined>
|
|
|
224
224
|
// LOGGER_
|
|
225
225
|
for (const key in flatEnv) {
|
|
226
226
|
const value = flatEnv[key];
|
|
227
|
-
if (value === undefined) continue;
|
|
227
|
+
if (value === undefined || value === '') continue;
|
|
228
228
|
|
|
229
229
|
if (key.startsWith('LOGGER_')) {
|
|
230
230
|
const subKey = key.replace('LOGGER_', '').toLowerCase();
|
|
@@ -251,7 +251,12 @@ export function convertEnvToSettings(flatEnv: Record<string, string | undefined>
|
|
|
251
251
|
settings.database.ssl = settings.database.ssl || {};
|
|
252
252
|
settings.database.ssl[sslKey] = value;
|
|
253
253
|
} else {
|
|
254
|
-
|
|
254
|
+
// Convert boolean-like strings to actual boolean
|
|
255
|
+
if (subKey === 'logging' || subKey === 'underscored') {
|
|
256
|
+
settings.database[subKey] = value === 'true';
|
|
257
|
+
} else {
|
|
258
|
+
settings.database[subKey] = value;
|
|
259
|
+
}
|
|
255
260
|
}
|
|
256
261
|
continue;
|
|
257
262
|
}
|