@nocobase/cli 2.1.0-alpha.16 → 2.1.0-alpha.18
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 +134 -63
- package/bin/run.cmd +3 -0
- package/bin/run.js +87 -0
- package/dist/commands/api/index.js +8 -0
- package/dist/commands/env/add.js +53 -0
- package/dist/commands/env/auth.js +36 -0
- package/dist/commands/env/index.js +27 -0
- package/dist/commands/env/list.js +31 -0
- package/dist/commands/env/remove.js +54 -0
- package/dist/commands/env/update.js +58 -0
- package/dist/commands/env/use.js +26 -0
- package/dist/commands/resource/create.js +15 -0
- package/dist/commands/resource/destroy.js +15 -0
- package/dist/commands/resource/get.js +15 -0
- package/dist/commands/resource/index.js +7 -0
- package/dist/commands/resource/list.js +16 -0
- package/dist/commands/resource/query.js +15 -0
- package/dist/commands/resource/update.js +15 -0
- package/dist/generated/command-registry.js +88 -0
- package/dist/lib/api-client.js +199 -0
- package/dist/lib/auth-store.js +155 -0
- package/dist/lib/bootstrap.js +349 -0
- package/dist/lib/build-config.js +10 -0
- package/dist/lib/cli-home.js +30 -0
- package/dist/lib/env-auth.js +405 -0
- package/dist/lib/generated-command.js +142 -0
- package/dist/lib/naming.js +70 -0
- package/dist/lib/openapi.js +254 -0
- package/dist/lib/post-processors.js +23 -0
- package/dist/lib/resource-command.js +335 -0
- package/dist/lib/resource-request.js +104 -0
- package/dist/lib/runtime-generator.js +408 -0
- package/dist/lib/runtime-store.js +56 -0
- package/dist/lib/ui.js +169 -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 +327 -0
- package/package.json +50 -25
- package/LICENSE +0 -201
- package/bin/index.js +0 -39
- package/nocobase.conf.tpl +0 -184
- package/src/cli.js +0 -28
- package/src/commands/benchmark.js +0 -73
- package/src/commands/build.js +0 -81
- package/src/commands/clean.js +0 -30
- package/src/commands/client.js +0 -168
- package/src/commands/create-nginx-conf.js +0 -53
- package/src/commands/create-plugin.js +0 -33
- package/src/commands/dev.js +0 -290
- 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/index.js +0 -17
- 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/index.js +0 -14
- package/src/license.js +0 -76
- package/src/logger.js +0 -75
- package/src/plugin-generator.js +0 -80
- package/src/util.js +0 -607
- 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-v2.d.ts +0 -2
- package/templates/plugin/client-v2.js +0 -1
- package/templates/plugin/client.d.ts +0 -2
- package/templates/plugin/client.js +0 -1
- package/templates/plugin/package.json.tpl +0 -12
- 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/models/index.ts +0 -12
- package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
- package/templates/plugin/src/client-v2/client.d.ts +0 -103
- package/templates/plugin/src/client-v2/index.tsx.tpl +0 -1
- package/templates/plugin/src/client-v2/plugin.tsx.tpl +0 -7
- 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
package/src/commands/doc.js
DELETED
|
@@ -1,76 +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 { resolve, isAbsolute } = require('path');
|
|
12
|
-
const { run, isDev } = require('../util');
|
|
13
|
-
const fs = require('fs-extra');
|
|
14
|
-
const glob = require('fast-glob');
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {Command} cli
|
|
19
|
-
*/
|
|
20
|
-
module.exports = (cli) => {
|
|
21
|
-
cli
|
|
22
|
-
.command('doc')
|
|
23
|
-
.argument('[dev|build|serve]')
|
|
24
|
-
.argument('[packages]')
|
|
25
|
-
.option('--lang [lang]')
|
|
26
|
-
.allowUnknownOption()
|
|
27
|
-
.action((command, pkg, options) => {
|
|
28
|
-
if (!isDev()) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 指定项目目录
|
|
33
|
-
let cwd = process.cwd();
|
|
34
|
-
if (command === undefined && pkg === undefined) {
|
|
35
|
-
command = 'dev';
|
|
36
|
-
} else if (!['dev', 'build', 'serve'].includes(command) && pkg === undefined) {
|
|
37
|
-
pkg = command;
|
|
38
|
-
command = 'dev';
|
|
39
|
-
cwd = resolve(process.cwd(), 'packages', pkg);
|
|
40
|
-
}
|
|
41
|
-
if (pkg !== undefined) {
|
|
42
|
-
process.env.APP_ROOT = `packages/${pkg}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// 删除 tmp 目录
|
|
46
|
-
const tmpDir = glob.sync(
|
|
47
|
-
['.dumi/tmp', '.dumi/tmp-production', 'packages/*/*/.dumi/tmp', 'packages/*/*.dumi/tmp-production'],
|
|
48
|
-
{
|
|
49
|
-
cwd: process.cwd(),
|
|
50
|
-
onlyDirectories: true,
|
|
51
|
-
},
|
|
52
|
-
);
|
|
53
|
-
tmpDir.forEach((dir) => {
|
|
54
|
-
fs.removeSync(dir);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// 设置语言
|
|
58
|
-
process.env.DOC_LANG = options.lang || 'en-US';
|
|
59
|
-
|
|
60
|
-
if (command === 'serve') {
|
|
61
|
-
// 如果是多语言,则需要进入内部,如果不是多语言,则直接进入 docs/dist
|
|
62
|
-
let dir = resolve(cwd, 'docs/dist', process.env.DOC_LANG);
|
|
63
|
-
if (!fs.existsSync(dir)) {
|
|
64
|
-
dir = resolve(cwd, 'docs/dist');
|
|
65
|
-
}
|
|
66
|
-
run('serve', [dir]);
|
|
67
|
-
} else {
|
|
68
|
-
run('dumi', [command], {
|
|
69
|
-
env: {
|
|
70
|
-
APP_ROOT: process.env.APP_ROOT || './packages/core/client',
|
|
71
|
-
DOC_LANG: process.env.DOC_LANG,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
};
|
package/src/commands/e2e.js
DELETED
|
@@ -1,265 +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 { run, isPortReachable, checkDBDialect } = require('../util');
|
|
12
|
-
const { execSync } = require('node:child_process');
|
|
13
|
-
const axios = require('axios');
|
|
14
|
-
const { pTest } = require('./p-test');
|
|
15
|
-
const os = require('os');
|
|
16
|
-
const treeKill = require('tree-kill');
|
|
17
|
-
const chalk = require('chalk');
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 检查服务是否启动成功
|
|
21
|
-
*/
|
|
22
|
-
const checkServer = async (duration = 1000, max = 60 * 10) => {
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
let count = 0;
|
|
25
|
-
const timer = setInterval(async () => {
|
|
26
|
-
if (count++ > max) {
|
|
27
|
-
clearInterval(timer);
|
|
28
|
-
return reject(new Error('Server start timeout.'));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// if (!(await checkPort(PORT))) {
|
|
32
|
-
// return;
|
|
33
|
-
// }
|
|
34
|
-
|
|
35
|
-
const url = `${process.env.APP_BASE_URL}/api/__health_check`;
|
|
36
|
-
// console.log('url', url);
|
|
37
|
-
|
|
38
|
-
axios
|
|
39
|
-
.get(url)
|
|
40
|
-
.then((response) => {
|
|
41
|
-
if (response.status === 200) {
|
|
42
|
-
clearInterval(timer);
|
|
43
|
-
resolve(true);
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
.catch((error) => {
|
|
47
|
-
console.error('Request error:', error?.response?.data?.error);
|
|
48
|
-
});
|
|
49
|
-
}, duration);
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* 检查 UI 是否启动成功
|
|
55
|
-
* @param duration
|
|
56
|
-
*/
|
|
57
|
-
const checkUI = async (duration = 1000, max = 60 * 10) => {
|
|
58
|
-
return new Promise((resolve, reject) => {
|
|
59
|
-
let count = 0;
|
|
60
|
-
const timer = setInterval(async () => {
|
|
61
|
-
if (count++ > max) {
|
|
62
|
-
clearInterval(timer);
|
|
63
|
-
return reject(new Error('UI start timeout.'));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
axios
|
|
67
|
-
.get(`${process.env.APP_BASE_URL}/__umi/api/bundle-status`)
|
|
68
|
-
.then((response) => {
|
|
69
|
-
if (response.data === 'ok') {
|
|
70
|
-
clearInterval(timer);
|
|
71
|
-
resolve(true);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (response.data.bundleStatus.done) {
|
|
75
|
-
clearInterval(timer);
|
|
76
|
-
resolve(true);
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
.catch((error) => {
|
|
80
|
-
console.error('Request error:', error.message);
|
|
81
|
-
});
|
|
82
|
-
}, duration);
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
async function appReady() {
|
|
87
|
-
console.log('check server...');
|
|
88
|
-
await checkServer();
|
|
89
|
-
console.log('server is ready, check UI...');
|
|
90
|
-
await checkUI();
|
|
91
|
-
console.log('UI is ready.');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function runApp(options = {}) {
|
|
95
|
-
console.log('installing...');
|
|
96
|
-
await run('nocobase', ['install', '-f']);
|
|
97
|
-
await run('nocobase', ['pm', 'enable-all']);
|
|
98
|
-
if (await isPortReachable(process.env.APP_PORT)) {
|
|
99
|
-
console.log('app started');
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
console.log('starting...');
|
|
103
|
-
run('nocobase', [process.env.APP_ENV === 'production' ? 'start' : 'dev'], options);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
process.on('SIGINT', async () => {
|
|
107
|
-
treeKill(process.pid, (error) => {
|
|
108
|
-
if (error) {
|
|
109
|
-
console.error(error);
|
|
110
|
-
} else {
|
|
111
|
-
console.log(chalk.yellow('Force killing...'));
|
|
112
|
-
}
|
|
113
|
-
process.exit();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const commonConfig = {
|
|
118
|
-
stdio: 'inherit',
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const runCodegenSync = () => {
|
|
122
|
-
try {
|
|
123
|
-
execSync(
|
|
124
|
-
`npx playwright codegen --load-storage=storage/playwright/.auth/codegen.auth.json ${process.env.APP_BASE_URL} --save-storage=storage/playwright/.auth/codegen.auth.json`,
|
|
125
|
-
commonConfig,
|
|
126
|
-
);
|
|
127
|
-
} catch (err) {
|
|
128
|
-
if (err.message.includes('auth.json')) {
|
|
129
|
-
execSync(
|
|
130
|
-
`npx playwright codegen ${process.env.APP_BASE_URL} --save-storage=storage/playwright/.auth/codegen.auth.json`,
|
|
131
|
-
commonConfig,
|
|
132
|
-
);
|
|
133
|
-
} else {
|
|
134
|
-
console.error(err);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const filterArgv = () => {
|
|
140
|
-
const arr = process.argv.slice(4);
|
|
141
|
-
const argv = [];
|
|
142
|
-
for (let index = 0; index < arr.length; index++) {
|
|
143
|
-
const element = arr[index];
|
|
144
|
-
if (element === '--url') {
|
|
145
|
-
index++;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (element.startsWith('--url=')) {
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
if (element === '--build') {
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (element === '--production') {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
argv.push(element);
|
|
158
|
-
}
|
|
159
|
-
return argv;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
*
|
|
164
|
-
* @param {Command} cli
|
|
165
|
-
*/
|
|
166
|
-
module.exports = (cli) => {
|
|
167
|
-
const e2e = cli.command('e2e').hook('preAction', () => {
|
|
168
|
-
checkDBDialect();
|
|
169
|
-
if (process.env.APP_BASE_URL) {
|
|
170
|
-
process.env.APP_BASE_URL = process.env.APP_BASE_URL.replace('localhost', '127.0.0.1');
|
|
171
|
-
console.log('APP_BASE_URL:', process.env.APP_BASE_URL);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
e2e
|
|
176
|
-
.command('test')
|
|
177
|
-
.allowUnknownOption()
|
|
178
|
-
.option('--url [url]')
|
|
179
|
-
.option('--build')
|
|
180
|
-
.option('--production')
|
|
181
|
-
.action(async (options) => {
|
|
182
|
-
process.env.__E2E__ = true;
|
|
183
|
-
if (options.production) {
|
|
184
|
-
process.env.APP_ENV = 'production';
|
|
185
|
-
}
|
|
186
|
-
if (options.build) {
|
|
187
|
-
process.env.APP_ENV = 'production';
|
|
188
|
-
await run('yarn', ['build']);
|
|
189
|
-
}
|
|
190
|
-
if (options.url) {
|
|
191
|
-
process.env.APP_BASE_URL = options.url.replace('localhost', '127.0.0.1');
|
|
192
|
-
} else {
|
|
193
|
-
await runApp({
|
|
194
|
-
stdio: 'ignore',
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
await appReady();
|
|
198
|
-
await run('npx', ['playwright', 'test', ...filterArgv()]);
|
|
199
|
-
process.exit();
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
e2e
|
|
203
|
-
.command('codegen')
|
|
204
|
-
.allowUnknownOption()
|
|
205
|
-
.option('--url [url]')
|
|
206
|
-
.action(async (options) => {
|
|
207
|
-
if (options.url) {
|
|
208
|
-
process.env.APP_BASE_URL = options.url.replace('localhost', '127.0.0.1');
|
|
209
|
-
} else {
|
|
210
|
-
await runApp({
|
|
211
|
-
stdio: 'ignore',
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
await appReady();
|
|
215
|
-
runCodegenSync();
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
e2e
|
|
219
|
-
.command('start-app')
|
|
220
|
-
.option('--production')
|
|
221
|
-
.option('--build')
|
|
222
|
-
.option('--port [port]')
|
|
223
|
-
.action(async (options) => {
|
|
224
|
-
process.env.__E2E__ = true;
|
|
225
|
-
if (options.build) {
|
|
226
|
-
await run('yarn', ['build']);
|
|
227
|
-
}
|
|
228
|
-
if (options.production) {
|
|
229
|
-
process.env.APP_ENV = 'production';
|
|
230
|
-
}
|
|
231
|
-
if (options.port) {
|
|
232
|
-
process.env.APP_PORT = options.port;
|
|
233
|
-
}
|
|
234
|
-
runApp();
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
e2e.command('reinstall-app').action(async (options) => {
|
|
238
|
-
await run('nocobase', ['install', '-f'], options);
|
|
239
|
-
await run('nocobase', ['pm2', 'enable-all']);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
e2e.command('install-deps').action(async () => {
|
|
243
|
-
await run('npx', ['playwright', 'install', '--with-deps']);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
e2e
|
|
247
|
-
.command('p-test')
|
|
248
|
-
.option('--stop-on-error')
|
|
249
|
-
.option('--build')
|
|
250
|
-
.option('--concurrency [concurrency]', '', os.cpus().length)
|
|
251
|
-
.option(
|
|
252
|
-
'--match [match]',
|
|
253
|
-
'Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.',
|
|
254
|
-
'packages/**/__e2e__/**/*.test.ts',
|
|
255
|
-
)
|
|
256
|
-
.option('--ignore [ignore]', 'Skip tests that match the pattern. Strings are treated as glob patterns.', undefined)
|
|
257
|
-
.action(async (options) => {
|
|
258
|
-
process.env.__E2E__ = true;
|
|
259
|
-
if (options.build) {
|
|
260
|
-
process.env.APP_ENV = 'production';
|
|
261
|
-
await run('yarn', ['build']);
|
|
262
|
-
}
|
|
263
|
-
await pTest({ ...options, concurrency: 1 * options.concurrency });
|
|
264
|
-
});
|
|
265
|
-
};
|
package/src/commands/global.js
DELETED
|
@@ -1,43 +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 { run, isDev, isProd, promptForTs, downloadPro, checkDBDialect } = require('../util');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {Command} cli
|
|
16
|
-
*/
|
|
17
|
-
module.exports = (cli) => {
|
|
18
|
-
const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env;
|
|
19
|
-
cli
|
|
20
|
-
.allowUnknownOption()
|
|
21
|
-
.option('-h, --help')
|
|
22
|
-
.option('--ts-node-dev')
|
|
23
|
-
.action(async (options) => {
|
|
24
|
-
checkDBDialect();
|
|
25
|
-
const cmd = process.argv.slice(2)?.[0];
|
|
26
|
-
if (cmd === 'install') {
|
|
27
|
-
await downloadPro();
|
|
28
|
-
}
|
|
29
|
-
if (isDev()) {
|
|
30
|
-
promptForTs();
|
|
31
|
-
await run('tsx', [
|
|
32
|
-
'--tsconfig',
|
|
33
|
-
SERVER_TSCONFIG_PATH,
|
|
34
|
-
'-r',
|
|
35
|
-
'tsconfig-paths/register',
|
|
36
|
-
`${APP_PACKAGE_ROOT}/src/index.ts`,
|
|
37
|
-
...process.argv.slice(2),
|
|
38
|
-
]);
|
|
39
|
-
} else if (isProd()) {
|
|
40
|
-
await run('node', [`${APP_PACKAGE_ROOT}/lib/index.js`, ...process.argv.slice(2)]);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
};
|
package/src/commands/index.js
DELETED
|
@@ -1,45 +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 { isPackageValid, generateAppDir } = require('../util');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {Command} cli
|
|
16
|
-
*/
|
|
17
|
-
module.exports = (cli) => {
|
|
18
|
-
generateAppDir();
|
|
19
|
-
require('./global')(cli);
|
|
20
|
-
require('./create-nginx-conf')(cli);
|
|
21
|
-
require('./locale')(cli);
|
|
22
|
-
require('./build')(cli);
|
|
23
|
-
require('./tar')(cli);
|
|
24
|
-
require('./dev')(cli);
|
|
25
|
-
require('./start')(cli);
|
|
26
|
-
require('./e2e')(cli);
|
|
27
|
-
require('./perf')(cli);
|
|
28
|
-
require('./clean')(cli);
|
|
29
|
-
require('./doc')(cli);
|
|
30
|
-
require('./pm2')(cli);
|
|
31
|
-
require('./test')(cli);
|
|
32
|
-
require('./test-coverage')(cli);
|
|
33
|
-
require('./benchmark')(cli);
|
|
34
|
-
require('./umi')(cli);
|
|
35
|
-
require('./update-deps')(cli);
|
|
36
|
-
require('./upgrade')(cli);
|
|
37
|
-
require('./postinstall')(cli);
|
|
38
|
-
require('./pkg')(cli);
|
|
39
|
-
require('./instance-id')(cli);
|
|
40
|
-
require('./view-license-key')(cli);
|
|
41
|
-
require('./client')(cli);
|
|
42
|
-
if (isPackageValid('@umijs/utils')) {
|
|
43
|
-
require('./create-plugin')(cli);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
@@ -1,47 +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 chalk = require('chalk');
|
|
11
|
-
const { Command } = require('commander');
|
|
12
|
-
const { run, isDev } = require('../util');
|
|
13
|
-
const { getInstanceIdAsync } = require('@nocobase/license-kit');
|
|
14
|
-
const path = require('path');
|
|
15
|
-
const fs = require('fs');
|
|
16
|
-
const { logger } = require('../logger');
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {Command} cli
|
|
21
|
-
*/
|
|
22
|
-
module.exports = (cli) => {
|
|
23
|
-
cli
|
|
24
|
-
.command('generate-instance-id')
|
|
25
|
-
.description('Generate InstanceID')
|
|
26
|
-
.option('--force', 'Force generate InstanceID')
|
|
27
|
-
.action(async (options) => {
|
|
28
|
-
logger.info('Generating InstanceID...');
|
|
29
|
-
const dir = path.resolve(process.cwd(), 'storage/.license');
|
|
30
|
-
const filePath = path.resolve(dir, 'instance-id');
|
|
31
|
-
if (fs.existsSync(filePath) && !options.force) {
|
|
32
|
-
logger.info('InstanceID already exists at ' + filePath);
|
|
33
|
-
return;
|
|
34
|
-
} else {
|
|
35
|
-
if (!fs.existsSync(dir)) {
|
|
36
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
const instanceId = await getInstanceIdAsync();
|
|
40
|
-
fs.writeFileSync(filePath, instanceId + '\n');
|
|
41
|
-
logger.info(`InstanceID saved to ${filePath}`);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
logger.error('Failed to generate InstanceID', e.message || e);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
};
|
|
@@ -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,17 +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
|
-
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
|
-
}
|