tego 1.3.54-alpha.6 → 1.3.54-alpha.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/lib/constants.js +4 -1
- package/lib/utils.js +1 -1
- package/package.json +16 -16
- package/src/constants.ts +8 -2
- package/src/utils.ts +1 -1
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") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tego",
|
|
3
|
-
"version": "1.3.54-alpha.
|
|
3
|
+
"version": "1.3.54-alpha.8",
|
|
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.3.54-alpha.
|
|
53
|
-
"@tachybase/
|
|
54
|
-
"@tachybase/
|
|
55
|
-
"@tachybase/cache": "1.3.54-alpha.
|
|
56
|
-
"@tachybase/data-source": "1.3.54-alpha.
|
|
57
|
-
"@tachybase/database": "1.3.54-alpha.
|
|
58
|
-
"@tachybase/evaluators": "1.3.54-alpha.
|
|
59
|
-
"@tachybase/globals": "1.3.54-alpha.
|
|
60
|
-
"@tachybase/
|
|
61
|
-
"@tachybase/resourcer": "1.3.54-alpha.
|
|
62
|
-
"@tachybase/schema": "1.3.54-alpha.
|
|
63
|
-
"@tachybase/
|
|
64
|
-
"@tachybase/utils": "1.3.54-alpha.
|
|
65
|
-
"@tego/core": "1.3.54-alpha.
|
|
66
|
-
"@tego/server": "1.3.54-alpha.
|
|
52
|
+
"@tachybase/acl": "1.3.54-alpha.8",
|
|
53
|
+
"@tachybase/actions": "1.3.54-alpha.8",
|
|
54
|
+
"@tachybase/auth": "1.3.54-alpha.8",
|
|
55
|
+
"@tachybase/cache": "1.3.54-alpha.8",
|
|
56
|
+
"@tachybase/data-source": "1.3.54-alpha.8",
|
|
57
|
+
"@tachybase/database": "1.3.54-alpha.8",
|
|
58
|
+
"@tachybase/evaluators": "1.3.54-alpha.8",
|
|
59
|
+
"@tachybase/globals": "1.3.54-alpha.8",
|
|
60
|
+
"@tachybase/loader": "1.3.54-alpha.8",
|
|
61
|
+
"@tachybase/resourcer": "1.3.54-alpha.8",
|
|
62
|
+
"@tachybase/schema": "1.3.54-alpha.8",
|
|
63
|
+
"@tachybase/logger": "1.3.54-alpha.8",
|
|
64
|
+
"@tachybase/utils": "1.3.54-alpha.8",
|
|
65
|
+
"@tego/core": "1.3.54-alpha.8",
|
|
66
|
+
"@tego/server": "1.3.54-alpha.8"
|
|
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();
|