@nocobase/cli 1.7.0-beta.2 → 1.7.0-beta.21
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 +7 -6
- package/src/commands/dev.js +2 -1
- package/src/commands/e2e.js +2 -1
- package/src/commands/global.js +2 -1
- package/src/commands/index.js +1 -0
- package/src/commands/locale/cronstrue.js +122 -0
- package/src/commands/locale/react-js-cron/en-US.json +75 -0
- package/src/commands/locale/react-js-cron/index.js +17 -0
- package/src/commands/locale/react-js-cron/zh-CN.json +33 -0
- package/src/commands/locale/react-js-cron/zh-TW.json +33 -0
- package/src/commands/locale.js +81 -0
- package/src/commands/start.js +24 -12
- package/src/commands/test-coverage.js +3 -1
- package/src/commands/test.js +2 -1
- package/src/commands/upgrade.js +14 -1
- package/src/util.js +17 -1
- package/templates/create-app-package.json +39 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "1.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.21",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -8,29 +8,30 @@
|
|
|
8
8
|
"nocobase": "./bin/index.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@nocobase/app": "1.7.0-beta.
|
|
11
|
+
"@nocobase/app": "1.7.0-beta.21",
|
|
12
12
|
"@types/fs-extra": "^11.0.1",
|
|
13
13
|
"@umijs/utils": "3.5.20",
|
|
14
14
|
"chalk": "^4.1.1",
|
|
15
15
|
"commander": "^9.2.0",
|
|
16
|
+
"deepmerge": "^4.3.1",
|
|
16
17
|
"dotenv": "^16.0.0",
|
|
17
18
|
"execa": "^5.1.1",
|
|
18
19
|
"fast-glob": "^3.3.1",
|
|
19
20
|
"fs-extra": "^11.1.1",
|
|
20
21
|
"p-all": "3.0.0",
|
|
21
|
-
"pm2": "^
|
|
22
|
+
"pm2": "^6.0.5",
|
|
22
23
|
"portfinder": "^1.0.28",
|
|
23
|
-
"
|
|
24
|
+
"tar": "^7.4.3",
|
|
24
25
|
"tree-kill": "^1.2.2",
|
|
25
26
|
"tsx": "^4.19.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@nocobase/devtools": "1.7.0-beta.
|
|
29
|
+
"@nocobase/devtools": "1.7.0-beta.21"
|
|
29
30
|
},
|
|
30
31
|
"repository": {
|
|
31
32
|
"type": "git",
|
|
32
33
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
33
34
|
"directory": "packages/core/cli"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "845f6124b170717387ba9d7ebf3cc2df7a861bc3"
|
|
36
37
|
}
|
package/src/commands/dev.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
const _ = require('lodash');
|
|
10
10
|
const { Command } = require('commander');
|
|
11
|
-
const { generatePlugins, run, postCheck, nodeCheck, promptForTs, isPortReachable } = require('../util');
|
|
11
|
+
const { generatePlugins, run, postCheck, nodeCheck, promptForTs, isPortReachable, checkDBDialect } = require('../util');
|
|
12
12
|
const { getPortPromise } = require('portfinder');
|
|
13
13
|
const chokidar = require('chokidar');
|
|
14
14
|
const { uid } = require('@formily/shared');
|
|
@@ -36,6 +36,7 @@ module.exports = (cli) => {
|
|
|
36
36
|
.option('-i, --inspect [port]')
|
|
37
37
|
.allowUnknownOption()
|
|
38
38
|
.action(async (opts) => {
|
|
39
|
+
checkDBDialect();
|
|
39
40
|
let subprocess;
|
|
40
41
|
const runDevClient = () => {
|
|
41
42
|
console.log('starting client', 1 * clientPort);
|
package/src/commands/e2e.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
const { Command } = require('commander');
|
|
11
|
-
const { run, isPortReachable } = require('../util');
|
|
11
|
+
const { run, isPortReachable, checkDBDialect } = require('../util');
|
|
12
12
|
const { execSync } = require('node:child_process');
|
|
13
13
|
const axios = require('axios');
|
|
14
14
|
const { pTest } = require('./p-test');
|
|
@@ -165,6 +165,7 @@ const filterArgv = () => {
|
|
|
165
165
|
*/
|
|
166
166
|
module.exports = (cli) => {
|
|
167
167
|
const e2e = cli.command('e2e').hook('preAction', () => {
|
|
168
|
+
checkDBDialect();
|
|
168
169
|
if (process.env.APP_BASE_URL) {
|
|
169
170
|
process.env.APP_BASE_URL = process.env.APP_BASE_URL.replace('localhost', '127.0.0.1');
|
|
170
171
|
console.log('APP_BASE_URL:', process.env.APP_BASE_URL);
|
package/src/commands/global.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
const { Command } = require('commander');
|
|
11
|
-
const { run, isDev, isProd, promptForTs, downloadPro } = require('../util');
|
|
11
|
+
const { run, isDev, isProd, promptForTs, downloadPro, checkDBDialect } = require('../util');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
@@ -21,6 +21,7 @@ module.exports = (cli) => {
|
|
|
21
21
|
.option('-h, --help')
|
|
22
22
|
.option('--ts-node-dev')
|
|
23
23
|
.action(async (options) => {
|
|
24
|
+
checkDBDialect();
|
|
24
25
|
const cmd = process.argv.slice(2)?.[0];
|
|
25
26
|
if (cmd === 'install') {
|
|
26
27
|
await downloadPro();
|
package/src/commands/index.js
CHANGED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const methods = [
|
|
11
|
+
'atX0SecondsPastTheMinuteGt20',
|
|
12
|
+
'atX0MinutesPastTheHourGt20',
|
|
13
|
+
'commaMonthX0ThroughMonthX1',
|
|
14
|
+
'commaYearX0ThroughYearX1',
|
|
15
|
+
'use24HourTimeFormatByDefault',
|
|
16
|
+
'anErrorOccuredWhenGeneratingTheExpressionD',
|
|
17
|
+
'everyMinute',
|
|
18
|
+
'everyHour',
|
|
19
|
+
'atSpace',
|
|
20
|
+
'everyMinuteBetweenX0AndX1',
|
|
21
|
+
'at',
|
|
22
|
+
'spaceAnd',
|
|
23
|
+
'everySecond',
|
|
24
|
+
'everyX0Seconds',
|
|
25
|
+
'secondsX0ThroughX1PastTheMinute',
|
|
26
|
+
'atX0SecondsPastTheMinute',
|
|
27
|
+
'everyX0Minutes',
|
|
28
|
+
'minutesX0ThroughX1PastTheHour',
|
|
29
|
+
'atX0MinutesPastTheHour',
|
|
30
|
+
'everyX0Hours',
|
|
31
|
+
'betweenX0AndX1',
|
|
32
|
+
'atX0',
|
|
33
|
+
'commaEveryDay',
|
|
34
|
+
'commaEveryX0DaysOfTheWeek',
|
|
35
|
+
'commaX0ThroughX1',
|
|
36
|
+
'commaAndX0ThroughX1',
|
|
37
|
+
'first',
|
|
38
|
+
'second',
|
|
39
|
+
'third',
|
|
40
|
+
'fourth',
|
|
41
|
+
'fifth',
|
|
42
|
+
'commaOnThe',
|
|
43
|
+
'spaceX0OfTheMonth',
|
|
44
|
+
'lastDay',
|
|
45
|
+
'commaOnTheLastX0OfTheMonth',
|
|
46
|
+
'commaOnlyOnX0',
|
|
47
|
+
'commaAndOnX0',
|
|
48
|
+
'commaEveryX0Months',
|
|
49
|
+
'commaOnlyInX0',
|
|
50
|
+
'commaOnTheLastDayOfTheMonth',
|
|
51
|
+
'commaOnTheLastWeekdayOfTheMonth',
|
|
52
|
+
'commaDaysBeforeTheLastDayOfTheMonth',
|
|
53
|
+
'firstWeekday',
|
|
54
|
+
'weekdayNearestDayX0',
|
|
55
|
+
'commaOnTheX0OfTheMonth',
|
|
56
|
+
'commaEveryX0Days',
|
|
57
|
+
'commaBetweenDayX0AndX1OfTheMonth',
|
|
58
|
+
'commaOnDayX0OfTheMonth',
|
|
59
|
+
'commaEveryHour',
|
|
60
|
+
'commaEveryX0Years',
|
|
61
|
+
'commaStartingX0',
|
|
62
|
+
'daysOfTheWeek',
|
|
63
|
+
'monthsOfTheYear',
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const langs = {
|
|
67
|
+
af: 'af',
|
|
68
|
+
ar: 'ar',
|
|
69
|
+
be: 'be',
|
|
70
|
+
ca: 'ca',
|
|
71
|
+
cs: 'cs',
|
|
72
|
+
da: 'da',
|
|
73
|
+
de: 'de',
|
|
74
|
+
'en-US': 'en',
|
|
75
|
+
es: 'es',
|
|
76
|
+
fa: 'fa',
|
|
77
|
+
fi: 'fi',
|
|
78
|
+
fr: 'fr',
|
|
79
|
+
he: 'he',
|
|
80
|
+
hu: 'hu',
|
|
81
|
+
id: 'id',
|
|
82
|
+
it: 'it',
|
|
83
|
+
'ja-JP': 'ja',
|
|
84
|
+
ko: 'ko',
|
|
85
|
+
nb: 'nb',
|
|
86
|
+
nl: 'nl',
|
|
87
|
+
pl: 'pl',
|
|
88
|
+
pt_BR: 'pt_BR',
|
|
89
|
+
pt_PT: 'pt_PT',
|
|
90
|
+
ro: 'ro',
|
|
91
|
+
'ru-RU': 'ru',
|
|
92
|
+
sk: 'sk',
|
|
93
|
+
sl: 'sl',
|
|
94
|
+
sv: 'sv',
|
|
95
|
+
sw: 'sw',
|
|
96
|
+
'th-TH': 'th',
|
|
97
|
+
'tr-TR': 'tr',
|
|
98
|
+
uk: 'uk',
|
|
99
|
+
'zh-CN': 'zh_CN',
|
|
100
|
+
'zh-TW': 'zh_TW',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
exports.getCronstrueLocale = (lang) => {
|
|
104
|
+
const lng = langs[lang] || 'en';
|
|
105
|
+
const Locale = require(`cronstrue/locales/${lng}`);
|
|
106
|
+
let locale;
|
|
107
|
+
if (Locale?.default) {
|
|
108
|
+
locale = Locale.default.locales[lng];
|
|
109
|
+
} else {
|
|
110
|
+
const L = Locale[lng];
|
|
111
|
+
locale = new L();
|
|
112
|
+
}
|
|
113
|
+
const items = {};
|
|
114
|
+
for (const method of methods) {
|
|
115
|
+
try {
|
|
116
|
+
items[method] = locale[method]();
|
|
117
|
+
} catch (error) {
|
|
118
|
+
// empty
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return items;
|
|
122
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"everyText": "every",
|
|
3
|
+
"emptyMonths": "every month",
|
|
4
|
+
"emptyMonthDays": "every day of the month",
|
|
5
|
+
"emptyMonthDaysShort": "day of the month",
|
|
6
|
+
"emptyWeekDays": "every day of the week",
|
|
7
|
+
"emptyWeekDaysShort": "day of the week",
|
|
8
|
+
"emptyHours": "every hour",
|
|
9
|
+
"emptyMinutes": "every minute",
|
|
10
|
+
"emptyMinutesForHourPeriod": "every",
|
|
11
|
+
"yearOption": "year",
|
|
12
|
+
"monthOption": "month",
|
|
13
|
+
"weekOption": "week",
|
|
14
|
+
"dayOption": "day",
|
|
15
|
+
"hourOption": "hour",
|
|
16
|
+
"minuteOption": "minute",
|
|
17
|
+
"rebootOption": "reboot",
|
|
18
|
+
"prefixPeriod": "Every",
|
|
19
|
+
"prefixMonths": "in",
|
|
20
|
+
"prefixMonthDays": "on",
|
|
21
|
+
"prefixWeekDays": "on",
|
|
22
|
+
"prefixWeekDaysForMonthAndYearPeriod": "and",
|
|
23
|
+
"prefixHours": "at",
|
|
24
|
+
"prefixMinutes": ":",
|
|
25
|
+
"prefixMinutesForHourPeriod": "at",
|
|
26
|
+
"suffixMinutesForHourPeriod": "minute(s)",
|
|
27
|
+
"errorInvalidCron": "Invalid cron expression",
|
|
28
|
+
"clearButtonText": "Clear",
|
|
29
|
+
"weekDays": [
|
|
30
|
+
"Sunday",
|
|
31
|
+
"Monday",
|
|
32
|
+
"Tuesday",
|
|
33
|
+
"Wednesday",
|
|
34
|
+
"Thursday",
|
|
35
|
+
"Friday",
|
|
36
|
+
"Saturday"
|
|
37
|
+
],
|
|
38
|
+
"months": [
|
|
39
|
+
"January",
|
|
40
|
+
"February",
|
|
41
|
+
"March",
|
|
42
|
+
"April",
|
|
43
|
+
"May",
|
|
44
|
+
"June",
|
|
45
|
+
"July",
|
|
46
|
+
"August",
|
|
47
|
+
"September",
|
|
48
|
+
"October",
|
|
49
|
+
"November",
|
|
50
|
+
"December"
|
|
51
|
+
],
|
|
52
|
+
"altWeekDays": [
|
|
53
|
+
"SUN",
|
|
54
|
+
"MON",
|
|
55
|
+
"TUE",
|
|
56
|
+
"WED",
|
|
57
|
+
"THU",
|
|
58
|
+
"FRI",
|
|
59
|
+
"SAT"
|
|
60
|
+
],
|
|
61
|
+
"altMonths": [
|
|
62
|
+
"JAN",
|
|
63
|
+
"FEB",
|
|
64
|
+
"MAR",
|
|
65
|
+
"APR",
|
|
66
|
+
"MAY",
|
|
67
|
+
"JUN",
|
|
68
|
+
"JUL",
|
|
69
|
+
"AUG",
|
|
70
|
+
"SEP",
|
|
71
|
+
"OCT",
|
|
72
|
+
"NOV",
|
|
73
|
+
"DEC"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
exports.getReactJsCron = (lang) => {
|
|
11
|
+
const langs = {
|
|
12
|
+
'en-US': require('./en-US.json'),
|
|
13
|
+
'zh-CN': require('./zh-CN.json'),
|
|
14
|
+
'z-TW': require('./zh-TW.json'),
|
|
15
|
+
}
|
|
16
|
+
return langs[lang] || langs['en-US'];
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"everyText": "每",
|
|
3
|
+
"emptyMonths": "每月",
|
|
4
|
+
"emptyMonthDays": "每日(月)",
|
|
5
|
+
"emptyMonthDaysShort": "每日",
|
|
6
|
+
"emptyWeekDays": "每天(周)",
|
|
7
|
+
"emptyWeekDaysShort": "每天(周)",
|
|
8
|
+
"emptyHours": "每小时",
|
|
9
|
+
"emptyMinutes": "每分钟",
|
|
10
|
+
"emptyMinutesForHourPeriod": "每",
|
|
11
|
+
"yearOption": "年",
|
|
12
|
+
"monthOption": "月",
|
|
13
|
+
"weekOption": "周",
|
|
14
|
+
"dayOption": "天",
|
|
15
|
+
"hourOption": "小时",
|
|
16
|
+
"minuteOption": "分钟",
|
|
17
|
+
"rebootOption": "重启",
|
|
18
|
+
"prefixPeriod": "每",
|
|
19
|
+
"prefixMonths": "的",
|
|
20
|
+
"prefixMonthDays": "的",
|
|
21
|
+
"prefixWeekDays": "的",
|
|
22
|
+
"prefixWeekDaysForMonthAndYearPeriod": "或者",
|
|
23
|
+
"prefixHours": "的",
|
|
24
|
+
"prefixMinutes": ":",
|
|
25
|
+
"prefixMinutesForHourPeriod": "的",
|
|
26
|
+
"suffixMinutesForHourPeriod": "分钟",
|
|
27
|
+
"errorInvalidCron": "不符合 cron 规则的表达式",
|
|
28
|
+
"clearButtonText": "清空",
|
|
29
|
+
"weekDays": ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
|
|
30
|
+
"months": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
|
31
|
+
"altWeekDays": ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
|
|
32
|
+
"altMonths": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
|
|
33
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"everyText": "每",
|
|
3
|
+
"emptyMonths": "每月",
|
|
4
|
+
"emptyMonthDays": "每日(月)",
|
|
5
|
+
"emptyMonthDaysShort": "每日",
|
|
6
|
+
"emptyWeekDays": "每天(週)",
|
|
7
|
+
"emptyWeekDaysShort": "每天(週)",
|
|
8
|
+
"emptyHours": "每小時",
|
|
9
|
+
"emptyMinutes": "每分鐘",
|
|
10
|
+
"emptyMinutesForHourPeriod": "每",
|
|
11
|
+
"yearOption": "年",
|
|
12
|
+
"monthOption": "月",
|
|
13
|
+
"weekOption": "週",
|
|
14
|
+
"dayOption": "天",
|
|
15
|
+
"hourOption": "小時",
|
|
16
|
+
"minuteOption": "分鐘",
|
|
17
|
+
"rebootOption": "重啟",
|
|
18
|
+
"prefixPeriod": "每",
|
|
19
|
+
"prefixMonths": "的",
|
|
20
|
+
"prefixMonthDays": "的",
|
|
21
|
+
"prefixWeekDays": "的",
|
|
22
|
+
"prefixWeekDaysForMonthAndYearPeriod": "或者",
|
|
23
|
+
"prefixHours": "的",
|
|
24
|
+
"prefixMinutes": ":",
|
|
25
|
+
"prefixMinutesForHourPeriod": "的",
|
|
26
|
+
"suffixMinutesForHourPeriod": "分鐘",
|
|
27
|
+
"errorInvalidCron": "不符合 cron 規則的表示式",
|
|
28
|
+
"clearButtonText": "清空",
|
|
29
|
+
"weekDays": ["週日", "週一", "週二", "週三", "週四", "週五", "週六"],
|
|
30
|
+
"months": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
|
31
|
+
"altWeekDays": ["週日", "週一", "週二", "週三", "週四", "週五", "週六"],
|
|
32
|
+
"altMonths": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
|
|
33
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { Command } = require('commander');
|
|
11
|
+
const fg = require('fast-glob');
|
|
12
|
+
const fs = require('fs-extra');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const _ = require('lodash');
|
|
15
|
+
const deepmerge = require('deepmerge');
|
|
16
|
+
const { getCronstrueLocale } = require('./locale/cronstrue');
|
|
17
|
+
const { getReactJsCron } = require('./locale/react-js-cron');
|
|
18
|
+
|
|
19
|
+
function sortJSON(json) {
|
|
20
|
+
if (Array.isArray(json)) {
|
|
21
|
+
return json.map(sortJSON);
|
|
22
|
+
} else if (typeof json === 'object' && json !== null) {
|
|
23
|
+
const sortedKeys = Object.keys(json).sort();
|
|
24
|
+
const sortedObject = {};
|
|
25
|
+
sortedKeys.forEach((key) => {
|
|
26
|
+
sortedObject[key] = sortJSON(json[key]);
|
|
27
|
+
});
|
|
28
|
+
return sortedObject;
|
|
29
|
+
}
|
|
30
|
+
return json;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {Command} cli
|
|
36
|
+
*/
|
|
37
|
+
module.exports = (cli) => {
|
|
38
|
+
const locale = cli.command('locale');
|
|
39
|
+
locale.command('generate').action(async (options) => {
|
|
40
|
+
const cwd = path.resolve(process.cwd(), 'node_modules', '@nocobase');
|
|
41
|
+
const files = await fg('./*/src/locale/*.json', {
|
|
42
|
+
cwd,
|
|
43
|
+
});
|
|
44
|
+
let locales = {};
|
|
45
|
+
await fs.mkdirp(path.resolve(process.cwd(), 'storage/locales'));
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
const locale = path.basename(file, '.json');
|
|
48
|
+
const pkg = path.basename(path.dirname(path.dirname(path.dirname(file))));
|
|
49
|
+
_.set(locales, [locale.replace(/_/g, '-'), `@nocobase/${pkg}`], await fs.readJSON(path.resolve(cwd, file)));
|
|
50
|
+
if (locale.includes('_')) {
|
|
51
|
+
await fs.rename(
|
|
52
|
+
path.resolve(cwd, file),
|
|
53
|
+
path.resolve(cwd, path.dirname(file), `${locale.replace(/_/g, '-')}.json`),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const zhCN = locales['zh-CN'];
|
|
58
|
+
const enUS = locales['en-US'];
|
|
59
|
+
for (const key1 in zhCN) {
|
|
60
|
+
for (const key2 in zhCN[key1]) {
|
|
61
|
+
if (!_.get(enUS, [key1, key2])) {
|
|
62
|
+
_.set(enUS, [key1, key2], key2);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const locale of Object.keys(locales)) {
|
|
67
|
+
locales[locale] = deepmerge(enUS, locales[locale]);
|
|
68
|
+
locales[locale]['cronstrue'] = getCronstrueLocale(locale);
|
|
69
|
+
locales[locale]['react-js-cron'] = getReactJsCron(locale);
|
|
70
|
+
}
|
|
71
|
+
locales = sortJSON(locales);
|
|
72
|
+
for (const locale of Object.keys(locales)) {
|
|
73
|
+
await fs.writeFile(
|
|
74
|
+
path.resolve(process.cwd(), 'storage/locales', `${locale}.json`),
|
|
75
|
+
JSON.stringify(sortJSON(locales[locale]), null, 2),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
locale.command('sync').action(async (options) => {});
|
|
81
|
+
};
|
package/src/commands/start.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
const _ = require('lodash');
|
|
10
10
|
const { Command } = require('commander');
|
|
11
|
-
const { run, postCheck, downloadPro, promptForTs } = require('../util');
|
|
11
|
+
const { run, postCheck, downloadPro, promptForTs, checkDBDialect } = require('../util');
|
|
12
12
|
const { existsSync, rmSync } = require('fs');
|
|
13
13
|
const { resolve, isAbsolute } = require('path');
|
|
14
14
|
const chalk = require('chalk');
|
|
@@ -48,8 +48,10 @@ module.exports = (cli) => {
|
|
|
48
48
|
.option('-i, --instances [instances]')
|
|
49
49
|
.option('--db-sync')
|
|
50
50
|
.option('--quickstart')
|
|
51
|
+
.option('--launch-mode [launchMode]')
|
|
51
52
|
.allowUnknownOption()
|
|
52
53
|
.action(async (opts) => {
|
|
54
|
+
checkDBDialect();
|
|
53
55
|
if (opts.quickstart) {
|
|
54
56
|
await downloadPro();
|
|
55
57
|
}
|
|
@@ -118,17 +120,27 @@ module.exports = (cli) => {
|
|
|
118
120
|
]);
|
|
119
121
|
process.exit();
|
|
120
122
|
} else {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
'
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
const launchMode = opts.launchMode || process.env.APP_LAUNCH_MODE || 'pm2';
|
|
124
|
+
if (launchMode === 'pm2') {
|
|
125
|
+
run(
|
|
126
|
+
'pm2-runtime',
|
|
127
|
+
[
|
|
128
|
+
'start',
|
|
129
|
+
...instancesArgs,
|
|
130
|
+
`${APP_PACKAGE_ROOT}/lib/index.js`,
|
|
131
|
+
NODE_ARGS ? `--node-args="${NODE_ARGS}"` : undefined,
|
|
132
|
+
'--',
|
|
133
|
+
...process.argv.slice(2),
|
|
134
|
+
].filter(Boolean),
|
|
135
|
+
);
|
|
136
|
+
} else {
|
|
137
|
+
run(
|
|
138
|
+
'node',
|
|
139
|
+
[`${APP_PACKAGE_ROOT}/lib/index.js`, ...(NODE_ARGS || '').split(' '), ...process.argv.slice(2)].filter(
|
|
140
|
+
Boolean,
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
132
144
|
}
|
|
133
145
|
});
|
|
134
146
|
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const { run } = require('../util');
|
|
10
|
+
const { run, checkDBDialect } = require('../util');
|
|
11
11
|
const fg = require('fast-glob');
|
|
12
12
|
|
|
13
13
|
const coreClientPackages = ['packages/core/client', 'packages/core/sdk'];
|
|
@@ -30,6 +30,7 @@ const getPackagesDir = (isClient) => {
|
|
|
30
30
|
|
|
31
31
|
module.exports = (cli) => {
|
|
32
32
|
cli.command('test-coverage:server').action(async () => {
|
|
33
|
+
checkDBDialect();
|
|
33
34
|
const packageRoots = getPackagesDir(false);
|
|
34
35
|
for (const dir of packageRoots) {
|
|
35
36
|
try {
|
|
@@ -41,6 +42,7 @@ module.exports = (cli) => {
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
cli.command('test-coverage:client').action(async () => {
|
|
45
|
+
checkDBDialect();
|
|
44
46
|
const packageRoots = getPackagesDir(true);
|
|
45
47
|
for (const dir of packageRoots) {
|
|
46
48
|
try {
|
package/src/commands/test.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
const { Command } = require('commander');
|
|
11
|
-
const { run } = require('../util');
|
|
11
|
+
const { run, checkDBDialect } = require('../util');
|
|
12
12
|
const path = require('path');
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -29,6 +29,7 @@ function addTestCommand(name, cli) {
|
|
|
29
29
|
.arguments('[paths...]')
|
|
30
30
|
.allowUnknownOption()
|
|
31
31
|
.action(async (paths, opts) => {
|
|
32
|
+
checkDBDialect();
|
|
32
33
|
if (name === 'test:server') {
|
|
33
34
|
process.env.TEST_ENV = 'server-side';
|
|
34
35
|
} else if (name === 'test:client') {
|
package/src/commands/upgrade.js
CHANGED
|
@@ -10,8 +10,19 @@
|
|
|
10
10
|
const chalk = require('chalk');
|
|
11
11
|
const { Command } = require('commander');
|
|
12
12
|
const { resolve } = require('path');
|
|
13
|
-
const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode } = require('../util');
|
|
13
|
+
const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode, checkDBDialect } = require('../util');
|
|
14
14
|
const { existsSync, rmSync } = require('fs');
|
|
15
|
+
const { readJSON, writeJSON } = require('fs-extra');
|
|
16
|
+
const deepmerge = require('deepmerge');
|
|
17
|
+
|
|
18
|
+
async function updatePackage() {
|
|
19
|
+
const sourcePath = resolve(__dirname, '../../templates/create-app-package.json');
|
|
20
|
+
const descPath = resolve(process.cwd(), 'package.json');
|
|
21
|
+
const sourceJson = await readJSON(sourcePath, 'utf8');
|
|
22
|
+
const descJson = await readJSON(descPath, 'utf8');
|
|
23
|
+
const json = deepmerge(descJson, sourceJson);
|
|
24
|
+
await writeJSON(descPath, json, { spaces: 2, encoding: 'utf8' });
|
|
25
|
+
}
|
|
15
26
|
|
|
16
27
|
/**
|
|
17
28
|
*
|
|
@@ -26,6 +37,7 @@ module.exports = (cli) => {
|
|
|
26
37
|
.option('--next')
|
|
27
38
|
.option('-S|--skip-code-update')
|
|
28
39
|
.action(async (options) => {
|
|
40
|
+
checkDBDialect();
|
|
29
41
|
if (hasTsNode()) promptForTs();
|
|
30
42
|
if (hasCorePackages()) {
|
|
31
43
|
// await run('yarn', ['install']);
|
|
@@ -69,6 +81,7 @@ module.exports = (cli) => {
|
|
|
69
81
|
return;
|
|
70
82
|
}
|
|
71
83
|
await run('yarn', ['add', `@nocobase/cli@${distTag}`, `@nocobase/devtools@${distTag}`, '-W']);
|
|
84
|
+
await updatePackage();
|
|
72
85
|
await run('yarn', ['install']);
|
|
73
86
|
await downloadPro();
|
|
74
87
|
await runAppCommand('upgrade');
|
package/src/util.js
CHANGED
|
@@ -360,7 +360,7 @@ exports.initEnv = function initEnv() {
|
|
|
360
360
|
API_BASE_PATH: '/api/',
|
|
361
361
|
API_CLIENT_STORAGE_PREFIX: 'NOCOBASE_',
|
|
362
362
|
API_CLIENT_STORAGE_TYPE: 'localStorage',
|
|
363
|
-
DB_DIALECT: 'sqlite',
|
|
363
|
+
// DB_DIALECT: 'sqlite',
|
|
364
364
|
DB_STORAGE: 'storage/db/nocobase.sqlite',
|
|
365
365
|
// DB_TIMEZONE: '+00:00',
|
|
366
366
|
DB_UNDERSCORED: parseEnv('DB_UNDERSCORED'),
|
|
@@ -460,6 +460,22 @@ exports.initEnv = function initEnv() {
|
|
|
460
460
|
process.env.SOCKET_PATH = generateGatewayPath();
|
|
461
461
|
fs.mkdirpSync(dirname(process.env.SOCKET_PATH), { force: true, recursive: true });
|
|
462
462
|
fs.mkdirpSync(process.env.PM2_HOME, { force: true, recursive: true });
|
|
463
|
+
const pkgs = [
|
|
464
|
+
'@nocobase/plugin-multi-app-manager',
|
|
465
|
+
'@nocobase/plugin-departments',
|
|
466
|
+
'@nocobase/plugin-field-attachment-url',
|
|
467
|
+
'@nocobase/plugin-workflow-response-message',
|
|
468
|
+
];
|
|
469
|
+
for (const pkg of pkgs) {
|
|
470
|
+
const pkgDir = resolve(process.cwd(), 'storage/plugins', pkg);
|
|
471
|
+
fs.existsSync(pkgDir) && fs.rmdirSync(pkgDir, { recursive: true, force: true });
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
exports.checkDBDialect = function () {
|
|
476
|
+
if (!process.env.DB_DIALECT) {
|
|
477
|
+
throw new Error('DB_DIALECT is required.');
|
|
478
|
+
}
|
|
463
479
|
};
|
|
464
480
|
|
|
465
481
|
exports.generatePlugins = function () {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"workspaces": ["packages/*/*", "packages/*/*/*"],
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=18"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"nocobase": "nocobase",
|
|
9
|
+
"pm": "nocobase pm",
|
|
10
|
+
"pm2": "nocobase pm2",
|
|
11
|
+
"dev": "nocobase dev",
|
|
12
|
+
"start": "nocobase start",
|
|
13
|
+
"clean": "nocobase clean",
|
|
14
|
+
"build": "nocobase build",
|
|
15
|
+
"test": "nocobase test",
|
|
16
|
+
"e2e": "nocobase e2e",
|
|
17
|
+
"tar": "nocobase tar",
|
|
18
|
+
"postinstall": "nocobase postinstall",
|
|
19
|
+
"lint": "eslint ."
|
|
20
|
+
},
|
|
21
|
+
"resolutions": {
|
|
22
|
+
"cytoscape": "3.28.0",
|
|
23
|
+
"@types/react": "18.3.18",
|
|
24
|
+
"@types/react-dom": "^18.0.0",
|
|
25
|
+
"react-router-dom": "6.28.1",
|
|
26
|
+
"react-router": "6.28.1",
|
|
27
|
+
"async": "^3.2.6",
|
|
28
|
+
"antd": "5.12.8",
|
|
29
|
+
"rollup": "4.24.0",
|
|
30
|
+
"semver": "^7.7.1"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"pm2": "^6.0.5",
|
|
34
|
+
"mysql2": "^3.14.0",
|
|
35
|
+
"mariadb": "^3.4.1",
|
|
36
|
+
"pg": "^8.14.1",
|
|
37
|
+
"pg-hstore": "^2.3.4"
|
|
38
|
+
}
|
|
39
|
+
}
|