@nocobase/cli 2.1.0-alpha.2 → 2.1.0-alpha.20

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.
Files changed (116) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +165 -19
  3. package/bin/run.cmd +3 -0
  4. package/bin/run.js +95 -0
  5. package/dist/commands/api/resource/create.js +15 -0
  6. package/dist/commands/api/resource/destroy.js +15 -0
  7. package/dist/commands/api/resource/get.js +15 -0
  8. package/dist/commands/api/resource/index.js +20 -0
  9. package/dist/commands/api/resource/list.js +16 -0
  10. package/dist/commands/api/resource/query.js +15 -0
  11. package/dist/commands/api/resource/update.js +15 -0
  12. package/dist/commands/build.js +51 -0
  13. package/dist/commands/db/start.js +22 -0
  14. package/dist/commands/dev.js +58 -0
  15. package/dist/commands/download.js +293 -0
  16. package/dist/commands/env/add.js +198 -0
  17. package/dist/commands/env/auth.js +61 -0
  18. package/dist/commands/env/list.js +41 -0
  19. package/dist/commands/env/remove.js +65 -0
  20. package/dist/commands/env/update.js +73 -0
  21. package/dist/commands/env/use.js +36 -0
  22. package/dist/commands/init.js +186 -0
  23. package/dist/commands/install.js +703 -0
  24. package/dist/commands/pm/disable.js +31 -0
  25. package/dist/commands/pm/enable.js +31 -0
  26. package/dist/commands/pm/list.js +21 -0
  27. package/dist/commands/restart.js +32 -0
  28. package/dist/commands/scaffold/migration.js +38 -0
  29. package/dist/commands/scaffold/plugin.js +37 -0
  30. package/dist/commands/start.js +55 -0
  31. package/dist/commands/upgrade.js +35 -0
  32. package/dist/generated/command-registry.js +133 -0
  33. package/dist/help/runtime-help.js +20 -0
  34. package/dist/lib/api-client.js +199 -0
  35. package/dist/lib/auth-store.js +200 -0
  36. package/dist/lib/bootstrap.js +383 -0
  37. package/dist/lib/build-config.js +10 -0
  38. package/dist/lib/cli-home.js +30 -0
  39. package/dist/lib/command-discovery.js +39 -0
  40. package/dist/lib/env-auth.js +527 -0
  41. package/dist/lib/generated-command.js +142 -0
  42. package/dist/lib/init-browser-wizard.js +431 -0
  43. package/dist/lib/naming.js +70 -0
  44. package/dist/lib/openapi.js +62 -0
  45. package/dist/lib/post-processors.js +23 -0
  46. package/dist/lib/resource-command.js +335 -0
  47. package/dist/lib/resource-request.js +104 -0
  48. package/dist/lib/run-npm.js +59 -0
  49. package/dist/lib/runtime-generator.js +408 -0
  50. package/dist/lib/runtime-store.js +56 -0
  51. package/dist/lib/ui.js +175 -0
  52. package/dist/post-processors/data-modeling.js +66 -0
  53. package/dist/post-processors/data-source-manager.js +114 -0
  54. package/dist/post-processors/index.js +19 -0
  55. package/nocobase-ctl.config.json +287 -0
  56. package/package.json +52 -26
  57. package/LICENSE +0 -661
  58. package/bin/index.js +0 -39
  59. package/nocobase.conf.tpl +0 -95
  60. package/src/cli.js +0 -19
  61. package/src/commands/benchmark.js +0 -73
  62. package/src/commands/build.js +0 -49
  63. package/src/commands/clean.js +0 -30
  64. package/src/commands/client.js +0 -166
  65. package/src/commands/create-nginx-conf.js +0 -37
  66. package/src/commands/create-plugin.js +0 -33
  67. package/src/commands/dev.js +0 -200
  68. package/src/commands/doc.js +0 -76
  69. package/src/commands/e2e.js +0 -265
  70. package/src/commands/global.js +0 -43
  71. package/src/commands/index.js +0 -45
  72. package/src/commands/instance-id.js +0 -47
  73. package/src/commands/locale/cronstrue.js +0 -122
  74. package/src/commands/locale/react-js-cron/en-US.json +0 -75
  75. package/src/commands/locale/react-js-cron/index.js +0 -17
  76. package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
  77. package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
  78. package/src/commands/locale.js +0 -81
  79. package/src/commands/p-test.js +0 -88
  80. package/src/commands/perf.js +0 -63
  81. package/src/commands/pkg.js +0 -321
  82. package/src/commands/pm2.js +0 -37
  83. package/src/commands/postinstall.js +0 -88
  84. package/src/commands/start.js +0 -148
  85. package/src/commands/tar.js +0 -36
  86. package/src/commands/test-coverage.js +0 -55
  87. package/src/commands/test.js +0 -107
  88. package/src/commands/umi.js +0 -33
  89. package/src/commands/update-deps.js +0 -72
  90. package/src/commands/upgrade.js +0 -47
  91. package/src/commands/view-license-key.js +0 -44
  92. package/src/index.js +0 -14
  93. package/src/license.js +0 -76
  94. package/src/logger.js +0 -75
  95. package/src/plugin-generator.js +0 -80
  96. package/src/util.js +0 -517
  97. package/templates/bundle-status.html +0 -338
  98. package/templates/create-app-package.json +0 -39
  99. package/templates/plugin/.npmignore.tpl +0 -2
  100. package/templates/plugin/README.md.tpl +0 -1
  101. package/templates/plugin/client.d.ts +0 -2
  102. package/templates/plugin/client.js +0 -1
  103. package/templates/plugin/package.json.tpl +0 -11
  104. package/templates/plugin/server.d.ts +0 -2
  105. package/templates/plugin/server.js +0 -1
  106. package/templates/plugin/src/client/client.d.ts +0 -249
  107. package/templates/plugin/src/client/index.tsx.tpl +0 -1
  108. package/templates/plugin/src/client/locale.ts +0 -21
  109. package/templates/plugin/src/client/models/index.ts +0 -12
  110. package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
  111. package/templates/plugin/src/index.ts +0 -2
  112. package/templates/plugin/src/locale/en-US.json +0 -1
  113. package/templates/plugin/src/locale/zh-CN.json +0 -1
  114. package/templates/plugin/src/server/collections/.gitkeep +0 -0
  115. package/templates/plugin/src/server/index.ts.tpl +0 -1
  116. package/templates/plugin/src/server/plugin.ts.tpl +0 -19
@@ -1,200 +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
- const _ = require('lodash');
10
- const { Command } = require('commander');
11
- const { generatePlugins, run, postCheck, nodeCheck, promptForTs, isPortReachable, checkDBDialect } = require('../util');
12
- const { getPortPromise } = require('portfinder');
13
- const chokidar = require('chokidar');
14
- const { uid } = require('@formily/shared');
15
- const path = require('path');
16
- const fs = require('fs');
17
-
18
- function sleep(ms = 1000) {
19
- return new Promise((resolve) => {
20
- setTimeout(resolve, ms);
21
- });
22
- }
23
-
24
- async function buildBundleStatusHtml() {
25
- const data = await fs.promises.readFile(path.resolve(__dirname, '../../templates/bundle-status.html'), 'utf-8');
26
- await fs.promises.writeFile(
27
- path.resolve(process.cwd(), 'node_modules/@umijs/preset-umi/assets/bundle-status.html'),
28
- data,
29
- 'utf-8',
30
- );
31
- }
32
-
33
- /**
34
- *
35
- * @param {Command} cli
36
- */
37
- module.exports = (cli) => {
38
- const { APP_PACKAGE_ROOT } = process.env;
39
- cli
40
- .command('dev')
41
- .option('-p, --port [port]')
42
- .option('-c, --client')
43
- .option('-s, --server')
44
- .option('--db-sync')
45
- .option('-i, --inspect [port]')
46
- .allowUnknownOption()
47
- .action(async (opts) => {
48
- checkDBDialect();
49
- await buildBundleStatusHtml();
50
- let subprocess;
51
- const runDevClient = () => {
52
- console.log('starting client', 1 * clientPort);
53
- subprocess = run('umi', ['dev'], {
54
- env: {
55
- ...process.env,
56
- stdio: 'inherit',
57
- shell: true,
58
- PORT: clientPort,
59
- APP_ROOT: `${APP_PACKAGE_ROOT}/client`,
60
- WEBSOCKET_URL:
61
- process.env.WEBSOCKET_URL ||
62
- (serverPort ? `ws://localhost:${serverPort}${process.env.WS_PATH}` : undefined),
63
- PROXY_TARGET_URL:
64
- process.env.PROXY_TARGET_URL || (serverPort ? `http://127.0.0.1:${serverPort}` : undefined),
65
- },
66
- });
67
- };
68
- const watcher = chokidar.watch('./storage/plugins/**/*', {
69
- cwd: process.cwd(),
70
- ignored: /(^|[\/\\])\../, // 忽略隐藏文件
71
- persistent: true,
72
- depth: 1, // 只监听第一层目录
73
- });
74
-
75
- await fs.promises.mkdir(path.dirname(process.env.WATCH_FILE), { recursive: true });
76
- let isReady = false;
77
-
78
- const restartClient = _.debounce(async () => {
79
- if (!isReady) return;
80
- generatePlugins();
81
- if (subprocess) {
82
- console.log('client restarting...');
83
- subprocess.cancel();
84
- let i = 0;
85
- while (true) {
86
- ++i;
87
- const result = await isPortReachable(clientPort);
88
- if (!result) {
89
- break;
90
- }
91
- await sleep(500);
92
- if (i > 10) {
93
- break;
94
- }
95
- }
96
- runDevClient();
97
- await fs.promises.writeFile(process.env.WATCH_FILE, `export const watchId = '${uid()}';`, 'utf-8');
98
- }
99
- }, 500);
100
-
101
- watcher
102
- .on('ready', () => {
103
- isReady = true;
104
- })
105
- .on('addDir', async (pathname) => {
106
- if (!isReady) return;
107
- restartClient();
108
- })
109
- .on('unlinkDir', async (pathname) => {
110
- if (!isReady) return;
111
- restartClient();
112
- });
113
-
114
- promptForTs();
115
- const { SERVER_TSCONFIG_PATH } = process.env;
116
- process.env.IS_DEV_CMD = true;
117
-
118
- if (process.argv.includes('-h') || process.argv.includes('--help')) {
119
- run('ts-node', [
120
- '-P',
121
- SERVER_TSCONFIG_PATH,
122
- '-r',
123
- 'tsconfig-paths/register',
124
- `${APP_PACKAGE_ROOT}/src/index.ts`,
125
- ...process.argv.slice(2),
126
- ]);
127
- return;
128
- }
129
-
130
- const { port, client, server, inspect } = opts;
131
-
132
- if (port) {
133
- process.env.APP_PORT = opts.port;
134
- }
135
-
136
- const { APP_PORT } = process.env;
137
-
138
- let clientPort = APP_PORT;
139
- let serverPort;
140
-
141
- nodeCheck();
142
-
143
- await postCheck(opts);
144
-
145
- if (server) {
146
- serverPort = APP_PORT;
147
- } else if (!server && !client) {
148
- serverPort = await getPortPromise({
149
- port: 1 * clientPort + 1,
150
- });
151
- }
152
-
153
- if (server || !client) {
154
- console.log('starting server', serverPort);
155
-
156
- const filteredArgs = process.argv.filter(
157
- (item, i) => !item.startsWith('--inspect') && !(process.argv[i - 1] === '--inspect' && Number.parseInt(item)),
158
- );
159
-
160
- const argv = [
161
- 'watch',
162
- ...(inspect ? [`--inspect=${inspect === true ? 9229 : inspect}`] : []),
163
- '--ignore=./storage/plugins/**',
164
- '--tsconfig',
165
- SERVER_TSCONFIG_PATH,
166
- '-r',
167
- 'tsconfig-paths/register',
168
- `${APP_PACKAGE_ROOT}/src/index.ts`,
169
- 'start',
170
- ...filteredArgs.slice(3),
171
- `--port=${serverPort}`,
172
- ];
173
-
174
- if (opts.dbSync) {
175
- argv.push('--db-sync');
176
- }
177
-
178
- const runDevServer = () => {
179
- run('tsx', argv, {
180
- env: {
181
- APP_PORT: serverPort,
182
- },
183
- }).catch((err) => {
184
- if (err.exitCode == 100) {
185
- console.log('Restarting server...');
186
- runDevServer();
187
- } else {
188
- console.error(err);
189
- }
190
- });
191
- };
192
-
193
- runDevServer();
194
- }
195
-
196
- if (client || !server) {
197
- runDevClient();
198
- }
199
- });
200
- };
@@ -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
- };
@@ -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
- };
@@ -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
- };
@@ -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
- };