@nocobase/cli 2.1.0-alpha.3 → 2.1.0-alpha.31
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/LICENSE.txt +107 -0
- package/README.md +379 -19
- package/README.zh-CN.md +329 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +131 -0
- package/dist/commands/api/resource/create.js +15 -0
- package/dist/commands/api/resource/destroy.js +15 -0
- package/dist/commands/api/resource/get.js +15 -0
- package/dist/commands/api/resource/index.js +20 -0
- package/dist/commands/api/resource/list.js +16 -0
- package/dist/commands/api/resource/query.js +15 -0
- package/dist/commands/api/resource/update.js +15 -0
- package/dist/commands/app/down.js +266 -0
- package/dist/commands/app/logs.js +98 -0
- package/dist/commands/app/restart.js +75 -0
- package/dist/commands/app/start.js +253 -0
- package/dist/commands/app/stop.js +99 -0
- package/dist/commands/app/upgrade.js +582 -0
- package/{src/cli.js → dist/commands/build.js} +4 -11
- package/dist/commands/config/delete.js +30 -0
- package/dist/commands/config/get.js +29 -0
- package/dist/commands/config/index.js +20 -0
- package/dist/commands/config/list.js +29 -0
- package/dist/commands/config/set.js +35 -0
- package/dist/commands/db/check.js +238 -0
- package/dist/commands/db/logs.js +85 -0
- package/dist/commands/db/ps.js +60 -0
- package/dist/commands/db/shared.js +96 -0
- package/dist/commands/db/start.js +71 -0
- package/dist/commands/db/stop.js +71 -0
- package/{templates/plugin/src/client/models/index.ts → dist/commands/dev.js} +4 -4
- package/{src/index.js → dist/commands/down.js} +4 -6
- package/{src/commands/locale/react-js-cron/index.js → dist/commands/download.js} +4 -8
- package/dist/commands/env/add.js +312 -0
- package/dist/commands/env/auth.js +55 -0
- package/dist/commands/env/info.js +156 -0
- package/dist/commands/env/list.js +50 -0
- package/dist/commands/env/remove.js +59 -0
- package/dist/commands/env/shared.js +158 -0
- package/dist/commands/env/update.js +67 -0
- package/dist/commands/env/use.js +28 -0
- package/dist/commands/examples/prompts-stages.js +150 -0
- package/dist/commands/examples/prompts-test.js +181 -0
- package/dist/commands/init.js +1027 -0
- package/dist/commands/install.js +2206 -0
- package/dist/commands/license/activate.js +360 -0
- package/dist/commands/license/env.js +94 -0
- package/dist/commands/license/generate-id.js +108 -0
- package/dist/commands/license/id.js +56 -0
- package/dist/commands/license/index.js +20 -0
- package/dist/commands/license/plugins/clean.js +101 -0
- package/dist/commands/license/plugins/index.js +20 -0
- package/dist/commands/license/plugins/list.js +50 -0
- package/dist/commands/license/plugins/shared.js +325 -0
- package/dist/commands/license/plugins/sync.js +269 -0
- package/dist/commands/license/shared.js +414 -0
- package/dist/commands/license/status.js +50 -0
- package/dist/commands/logs.js +12 -0
- package/dist/commands/plugin/disable.js +66 -0
- package/dist/commands/plugin/enable.js +66 -0
- package/dist/commands/plugin/list.js +62 -0
- package/dist/commands/pm/disable.js +12 -0
- package/dist/commands/pm/enable.js +12 -0
- package/dist/commands/pm/list.js +12 -0
- package/dist/commands/restart.js +12 -0
- package/dist/commands/scaffold/migration.js +38 -0
- package/dist/commands/scaffold/plugin.js +37 -0
- package/dist/commands/self/check.js +71 -0
- package/dist/commands/self/index.js +20 -0
- package/dist/commands/self/update.js +86 -0
- package/dist/commands/skills/check.js +69 -0
- package/dist/commands/skills/index.js +20 -0
- package/dist/commands/skills/install.js +71 -0
- package/dist/commands/skills/remove.js +71 -0
- package/dist/commands/skills/update.js +78 -0
- package/dist/commands/source/build.js +58 -0
- package/dist/commands/source/dev.js +158 -0
- package/dist/commands/source/download.js +866 -0
- package/dist/commands/source/test.js +477 -0
- package/dist/commands/start.js +12 -0
- package/dist/commands/stop.js +12 -0
- package/dist/commands/test.js +12 -0
- package/dist/commands/upgrade.js +12 -0
- package/dist/generated/command-registry.js +133 -0
- package/dist/help/runtime-help.js +23 -0
- package/dist/lib/api-client.js +329 -0
- package/dist/lib/app-health.js +126 -0
- package/dist/lib/app-managed-resources.js +268 -0
- package/dist/lib/app-runtime.js +171 -0
- package/dist/lib/auth-store.js +328 -0
- package/dist/lib/bootstrap.js +384 -0
- package/dist/lib/build-config.js +18 -0
- package/dist/lib/builtin-db.js +86 -0
- package/dist/lib/cli-config.js +176 -0
- package/dist/lib/cli-home.js +47 -0
- package/dist/lib/cli-locale.js +129 -0
- package/dist/lib/command-discovery.js +39 -0
- package/dist/lib/db-connection-check.js +178 -0
- package/dist/lib/env-auth.js +872 -0
- package/dist/lib/env-config.js +87 -0
- package/dist/lib/generated-command.js +171 -0
- package/dist/lib/http-request.js +49 -0
- package/dist/lib/naming.js +70 -0
- package/dist/lib/openapi.js +62 -0
- package/dist/lib/plugin-storage.js +127 -0
- package/dist/lib/post-processors.js +23 -0
- package/dist/lib/prompt-catalog.js +581 -0
- package/dist/lib/prompt-validators.js +185 -0
- package/dist/lib/prompt-web-ui.js +2103 -0
- package/dist/lib/resource-command.js +343 -0
- package/dist/lib/resource-request.js +104 -0
- package/dist/lib/run-npm.js +250 -0
- package/dist/lib/runtime-env-vars.js +32 -0
- package/dist/lib/runtime-generator.js +498 -0
- package/dist/lib/runtime-store.js +56 -0
- package/dist/lib/self-manager.js +301 -0
- package/dist/lib/skills-manager.js +296 -0
- package/dist/lib/startup-update.js +281 -0
- package/dist/lib/ui.js +178 -0
- package/dist/locale/en-US.json +339 -0
- package/dist/locale/zh-CN.json +339 -0
- package/dist/post-processors/data-modeling.js +66 -0
- package/dist/post-processors/data-source-manager.js +114 -0
- package/dist/post-processors/index.js +19 -0
- package/nocobase-ctl.config.json +369 -0
- package/package.json +95 -26
- package/LICENSE +0 -661
- package/bin/index.js +0 -39
- package/nocobase.conf.tpl +0 -95
- package/src/commands/benchmark.js +0 -73
- package/src/commands/build.js +0 -49
- package/src/commands/clean.js +0 -30
- package/src/commands/client.js +0 -166
- package/src/commands/create-nginx-conf.js +0 -37
- package/src/commands/create-plugin.js +0 -33
- package/src/commands/dev.js +0 -200
- package/src/commands/doc.js +0 -76
- package/src/commands/e2e.js +0 -265
- package/src/commands/global.js +0 -43
- package/src/commands/index.js +0 -45
- package/src/commands/instance-id.js +0 -47
- package/src/commands/locale/cronstrue.js +0 -122
- package/src/commands/locale/react-js-cron/en-US.json +0 -75
- package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
- package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
- package/src/commands/locale.js +0 -81
- package/src/commands/p-test.js +0 -88
- package/src/commands/perf.js +0 -63
- package/src/commands/pkg.js +0 -321
- package/src/commands/pm2.js +0 -37
- package/src/commands/postinstall.js +0 -88
- package/src/commands/start.js +0 -148
- package/src/commands/tar.js +0 -36
- package/src/commands/test-coverage.js +0 -55
- package/src/commands/test.js +0 -107
- package/src/commands/umi.js +0 -33
- package/src/commands/update-deps.js +0 -72
- package/src/commands/upgrade.js +0 -47
- package/src/commands/view-license-key.js +0 -44
- package/src/license.js +0 -76
- package/src/logger.js +0 -75
- package/src/plugin-generator.js +0 -80
- package/src/util.js +0 -517
- package/templates/bundle-status.html +0 -338
- package/templates/create-app-package.json +0 -39
- package/templates/plugin/.npmignore.tpl +0 -2
- package/templates/plugin/README.md.tpl +0 -1
- package/templates/plugin/client.d.ts +0 -2
- package/templates/plugin/client.js +0 -1
- package/templates/plugin/package.json.tpl +0 -11
- package/templates/plugin/server.d.ts +0 -2
- package/templates/plugin/server.js +0 -1
- package/templates/plugin/src/client/client.d.ts +0 -249
- package/templates/plugin/src/client/index.tsx.tpl +0 -1
- package/templates/plugin/src/client/locale.ts +0 -21
- package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
- package/templates/plugin/src/index.ts +0 -2
- package/templates/plugin/src/locale/en-US.json +0 -1
- package/templates/plugin/src/locale/zh-CN.json +0 -1
- package/templates/plugin/src/server/collections/.gitkeep +0 -0
- package/templates/plugin/src/server/index.ts.tpl +0 -1
- package/templates/plugin/src/server/plugin.ts.tpl +0 -19
|
@@ -1,122 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
package/src/commands/locale.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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/p-test.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
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 execa = require('execa');
|
|
11
|
-
const { resolve } = require('path');
|
|
12
|
-
const pAll = require('p-all');
|
|
13
|
-
const dotenv = require('dotenv');
|
|
14
|
-
const fs = require('fs');
|
|
15
|
-
const glob = require('glob');
|
|
16
|
-
const _ = require('lodash');
|
|
17
|
-
|
|
18
|
-
let ENV_FILE = resolve(process.cwd(), '.env.e2e');
|
|
19
|
-
|
|
20
|
-
if (!fs.existsSync(ENV_FILE)) {
|
|
21
|
-
ENV_FILE = resolve(process.cwd(), '.env.e2e.example');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const data = fs.readFileSync(ENV_FILE, 'utf-8');
|
|
25
|
-
const config = {
|
|
26
|
-
...dotenv.parse(data),
|
|
27
|
-
...process.env,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
async function runApp(dir, index = 0) {
|
|
31
|
-
// 一个进程需要占用两个端口? (一个是应用端口,一个是 socket 端口)
|
|
32
|
-
index = index * 2;
|
|
33
|
-
const { Client } = require('pg');
|
|
34
|
-
const database = `nocobase${index}`;
|
|
35
|
-
const client = new Client({
|
|
36
|
-
host: config['DB_HOST'],
|
|
37
|
-
port: Number(config['DB_PORT']),
|
|
38
|
-
user: config['DB_USER'],
|
|
39
|
-
password: config['DB_PASSWORD'],
|
|
40
|
-
database: 'postgres',
|
|
41
|
-
});
|
|
42
|
-
await client.connect();
|
|
43
|
-
await client.query(`DROP DATABASE IF EXISTS "${database}"`);
|
|
44
|
-
await client.query(`CREATE DATABASE "${database}";`);
|
|
45
|
-
await client.end();
|
|
46
|
-
return execa('yarn', ['nocobase', 'e2e', 'test', dir], {
|
|
47
|
-
shell: true,
|
|
48
|
-
stdio: 'inherit',
|
|
49
|
-
env: {
|
|
50
|
-
...config,
|
|
51
|
-
CI: process.env.CI,
|
|
52
|
-
__E2E__: true,
|
|
53
|
-
APP_BASE_URL: undefined,
|
|
54
|
-
LOGGER_LEVEL: 'error',
|
|
55
|
-
APP_ENV: 'production',
|
|
56
|
-
APP_PORT: 20000 + index,
|
|
57
|
-
DB_DATABASE: `nocobase${index}`,
|
|
58
|
-
SOCKET_PATH: `storage/e2e/gateway-e2e-${index}.sock`,
|
|
59
|
-
PM2_HOME: resolve(process.cwd(), `storage/e2e/.pm2-${index}`),
|
|
60
|
-
PLAYWRIGHT_AUTH_FILE: resolve(process.cwd(), `storage/playwright/.auth/admin-${index}.json`),
|
|
61
|
-
E2E_JOB_ID: index,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
exports.pTest = async (options) => {
|
|
67
|
-
const dir = resolve(process.cwd(), 'storage/e2e');
|
|
68
|
-
|
|
69
|
-
if (!fs.existsSync(dir)) {
|
|
70
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const files = glob.sync(options.match, {
|
|
74
|
-
ignore: options.ignore,
|
|
75
|
-
root: process.cwd(),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const commands = splitArrayIntoParts(_.shuffle(files), options.concurrency || 4).map((v, i) => {
|
|
79
|
-
return () => runApp(v.join(' '), i);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
await pAll(commands, { concurrency: 4, stopOnError: false, ...options });
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
function splitArrayIntoParts(array, parts) {
|
|
86
|
-
let chunkSize = Math.ceil(array.length / parts);
|
|
87
|
-
return _.chunk(array, chunkSize);
|
|
88
|
-
}
|
package/src/commands/perf.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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 path = require('path');
|
|
11
|
-
const fs = require('fs');
|
|
12
|
-
// const init = require('@nocobase/server/__perf__/init');
|
|
13
|
-
const { Command } = require('commander');
|
|
14
|
-
const dotenv = require('dotenv');
|
|
15
|
-
const { run } = require('../util');
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Performance testing command
|
|
19
|
-
* @param {Command} cli
|
|
20
|
-
*/
|
|
21
|
-
module.exports = (cli) => {
|
|
22
|
-
const perf = cli.command('perf');
|
|
23
|
-
perf
|
|
24
|
-
.command('init')
|
|
25
|
-
.arguments('<file>')
|
|
26
|
-
.description('Initialize performance testing app')
|
|
27
|
-
.action(async (file, options) => {
|
|
28
|
-
if (!file) {
|
|
29
|
-
throw new Error('Please provide the path to the init script');
|
|
30
|
-
}
|
|
31
|
-
const f = path.isAbsolute(file) ? file : path.join(process.cwd(), file);
|
|
32
|
-
if (!fs.statSync(file).isFile()) {
|
|
33
|
-
throw new Error(`Init script file not found: ${file}`);
|
|
34
|
-
}
|
|
35
|
-
// const envFile = fs.existsSync(path.resolve(process.cwd(), '.env.test')) ? '.env.test' : '.env';
|
|
36
|
-
// const cliArgs = ['--max_old_space_size=4096'];
|
|
37
|
-
await run(`tsx`, [f]);
|
|
38
|
-
});
|
|
39
|
-
perf
|
|
40
|
-
.command('run')
|
|
41
|
-
.arguments('<file>')
|
|
42
|
-
.description('Run performance testing script')
|
|
43
|
-
.option('-e, --env-file <env>', 'Environment file to load', '.env.perf')
|
|
44
|
-
.allowUnknownOption(true)
|
|
45
|
-
.action(async (file, options, command) => {
|
|
46
|
-
const f = path.isAbsolute(file) ? file : path.join(process.cwd(), file);
|
|
47
|
-
if (!fs.statSync(f).isFile()) {
|
|
48
|
-
throw new Error(`Performance testing script file not found: ${f}`);
|
|
49
|
-
}
|
|
50
|
-
if (options.envFile) {
|
|
51
|
-
const envFilePath = path.resolve(process.cwd(), options.envFile);
|
|
52
|
-
if (fs.statSync(envFilePath).isFile()) {
|
|
53
|
-
dotenv.config({ path: envFilePath, override: true });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (!process.env.TARGET_ORIGIN) {
|
|
57
|
-
throw new Error('Please set TARGET_ORIGIN in environment variables or in .env.perf file');
|
|
58
|
-
}
|
|
59
|
-
const args = command.args.filter((arg) => arg !== file);
|
|
60
|
-
await run(`k6`, ['run', f, ...(args.length ? ['--', ...args] : [])]);
|
|
61
|
-
});
|
|
62
|
-
return perf;
|
|
63
|
-
};
|