@nocobase/cli 1.2.38-alpha → 1.2.39-alpha
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/package.json +4 -4
- package/src/util.js +36 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.39-alpha",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"nocobase": "./bin/index.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@nocobase/app": "1.2.
|
|
11
|
+
"@nocobase/app": "1.2.39-alpha",
|
|
12
12
|
"@types/fs-extra": "^11.0.1",
|
|
13
13
|
"@umijs/utils": "3.5.20",
|
|
14
14
|
"chalk": "^4.1.1",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"tsx": "^4.6.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@nocobase/devtools": "1.2.
|
|
28
|
+
"@nocobase/devtools": "1.2.39-alpha"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
32
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
33
33
|
"directory": "packages/core/cli"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "ed76c0c552c58bff45b85601cebff4c4bd80c8cd"
|
|
36
36
|
}
|
package/src/util.js
CHANGED
|
@@ -16,6 +16,7 @@ const { readFile, writeFile } = require('fs').promises;
|
|
|
16
16
|
const { existsSync, mkdirSync, cpSync, writeFileSync } = require('fs');
|
|
17
17
|
const dotenv = require('dotenv');
|
|
18
18
|
const fs = require('fs');
|
|
19
|
+
const moment = require('moment-timezone');
|
|
19
20
|
|
|
20
21
|
exports.isPackageValid = (pkg) => {
|
|
21
22
|
try {
|
|
@@ -296,6 +297,25 @@ function buildIndexHtml(force = false) {
|
|
|
296
297
|
|
|
297
298
|
exports.buildIndexHtml = buildIndexHtml;
|
|
298
299
|
|
|
300
|
+
function getTimezonesByOffset(offset) {
|
|
301
|
+
if (!/^[+-]\d{1,2}:\d{2}$/.test(offset)) {
|
|
302
|
+
return offset;
|
|
303
|
+
}
|
|
304
|
+
const offsetMinutes = moment.duration(offset).asMinutes();
|
|
305
|
+
return moment.tz.names().find((timezone) => {
|
|
306
|
+
return moment.tz(timezone).utcOffset() === offsetMinutes;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function areTimeZonesEqual(timeZone1, timeZone2) {
|
|
311
|
+
if (timeZone1 === timeZone2) {
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
timeZone1 = getTimezonesByOffset(timeZone1);
|
|
315
|
+
timeZone2 = getTimezonesByOffset(timeZone2);
|
|
316
|
+
return moment.tz(timeZone1).format() === moment.tz(timeZone2).format();
|
|
317
|
+
}
|
|
318
|
+
|
|
299
319
|
exports.initEnv = function initEnv() {
|
|
300
320
|
const env = {
|
|
301
321
|
APP_ENV: 'development',
|
|
@@ -305,7 +325,7 @@ exports.initEnv = function initEnv() {
|
|
|
305
325
|
API_CLIENT_STORAGE_PREFIX: 'NOCOBASE_',
|
|
306
326
|
DB_DIALECT: 'sqlite',
|
|
307
327
|
DB_STORAGE: 'storage/db/nocobase.sqlite',
|
|
308
|
-
DB_TIMEZONE: '+00:00',
|
|
328
|
+
// DB_TIMEZONE: '+00:00',
|
|
309
329
|
DB_UNDERSCORED: parseEnv('DB_UNDERSCORED'),
|
|
310
330
|
DEFAULT_STORAGE_TYPE: 'local',
|
|
311
331
|
LOCAL_STORAGE_DEST: 'storage/uploads',
|
|
@@ -376,4 +396,19 @@ exports.initEnv = function initEnv() {
|
|
|
376
396
|
process.env.API_BASE_URL = process.env.APP_SERVER_BASE_URL + process.env.API_BASE_PATH;
|
|
377
397
|
process.env.__env_modified__ = true;
|
|
378
398
|
}
|
|
399
|
+
|
|
400
|
+
if (!process.env.TZ) {
|
|
401
|
+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
402
|
+
process.env.TZ = getTimezonesByOffset(process.env.DB_TIMEZONE || timeZone);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (!process.env.DB_TIMEZONE) {
|
|
406
|
+
process.env.DB_TIMEZONE = process.env.TZ;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (!areTimeZonesEqual(process.env.DB_TIMEZONE, process.env.TZ)) {
|
|
410
|
+
throw new Error(
|
|
411
|
+
`process.env.DB_TIMEZONE="${process.env.DB_TIMEZONE}" and process.env.TZ="${process.env.TZ}" are different`,
|
|
412
|
+
);
|
|
413
|
+
}
|
|
379
414
|
};
|