@nocobase/cli 2.1.0-beta.14 → 2.1.0-beta.16

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 (132) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +307 -63
  3. package/README.zh-CN.md +332 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +114 -0
  6. package/dist/commands/api/resource/create.js +15 -0
  7. package/dist/commands/api/resource/destroy.js +15 -0
  8. package/dist/commands/api/resource/get.js +15 -0
  9. package/dist/commands/api/resource/index.js +20 -0
  10. package/dist/commands/api/resource/list.js +16 -0
  11. package/dist/commands/api/resource/query.js +15 -0
  12. package/dist/commands/api/resource/update.js +15 -0
  13. package/dist/commands/build.js +57 -0
  14. package/dist/commands/db/logs.js +85 -0
  15. package/dist/commands/db/ps.js +60 -0
  16. package/dist/commands/db/shared.js +81 -0
  17. package/dist/commands/db/start.js +70 -0
  18. package/dist/commands/db/stop.js +70 -0
  19. package/dist/commands/dev.js +149 -0
  20. package/dist/commands/down.js +193 -0
  21. package/dist/commands/download.js +743 -0
  22. package/dist/commands/env/add.js +327 -0
  23. package/dist/commands/env/auth.js +62 -0
  24. package/dist/commands/env/list.js +41 -0
  25. package/dist/commands/env/remove.js +65 -0
  26. package/dist/commands/env/update.js +73 -0
  27. package/dist/commands/env/use.js +36 -0
  28. package/dist/commands/init.js +806 -0
  29. package/dist/commands/install.js +1840 -0
  30. package/dist/commands/logs.js +90 -0
  31. package/dist/commands/pm/disable.js +63 -0
  32. package/dist/commands/pm/enable.js +63 -0
  33. package/dist/commands/pm/list.js +54 -0
  34. package/dist/commands/prompts-stages.js +150 -0
  35. package/dist/commands/prompts-test.js +181 -0
  36. package/dist/commands/ps.js +116 -0
  37. package/dist/commands/scaffold/migration.js +38 -0
  38. package/dist/commands/scaffold/plugin.js +37 -0
  39. package/dist/commands/start.js +211 -0
  40. package/dist/commands/stop.js +90 -0
  41. package/dist/commands/upgrade.js +583 -0
  42. package/dist/generated/command-registry.js +133 -0
  43. package/dist/help/runtime-help.js +20 -0
  44. package/dist/lib/api-client.js +243 -0
  45. package/dist/lib/app-runtime.js +142 -0
  46. package/dist/lib/auth-store.js +241 -0
  47. package/dist/lib/bootstrap.js +387 -0
  48. package/dist/lib/build-config.js +10 -0
  49. package/dist/lib/cli-home.js +30 -0
  50. package/dist/lib/cli-locale.js +115 -0
  51. package/dist/lib/command-discovery.js +39 -0
  52. package/dist/lib/env-auth.js +872 -0
  53. package/dist/lib/generated-command.js +142 -0
  54. package/dist/lib/naming.js +70 -0
  55. package/dist/lib/openapi.js +62 -0
  56. package/dist/lib/post-processors.js +23 -0
  57. package/dist/lib/prompt-catalog.js +574 -0
  58. package/dist/lib/prompt-validators.js +185 -0
  59. package/dist/lib/prompt-web-ui.js +2061 -0
  60. package/dist/lib/resource-command.js +335 -0
  61. package/dist/lib/resource-request.js +104 -0
  62. package/dist/lib/run-npm.js +123 -0
  63. package/dist/lib/runtime-generator.js +419 -0
  64. package/dist/lib/runtime-store.js +56 -0
  65. package/dist/lib/ui.js +175 -0
  66. package/dist/locale/en-US.json +282 -0
  67. package/dist/locale/zh-CN.json +282 -0
  68. package/dist/post-processors/data-modeling.js +66 -0
  69. package/dist/post-processors/data-source-manager.js +114 -0
  70. package/dist/post-processors/index.js +19 -0
  71. package/nocobase-ctl.config.json +287 -0
  72. package/package.json +52 -25
  73. package/LICENSE +0 -201
  74. package/bin/index.js +0 -39
  75. package/nocobase.conf.tpl +0 -95
  76. package/src/cli.js +0 -19
  77. package/src/commands/benchmark.js +0 -73
  78. package/src/commands/build.js +0 -49
  79. package/src/commands/clean.js +0 -30
  80. package/src/commands/client.js +0 -166
  81. package/src/commands/create-nginx-conf.js +0 -37
  82. package/src/commands/create-plugin.js +0 -33
  83. package/src/commands/dev.js +0 -200
  84. package/src/commands/doc.js +0 -76
  85. package/src/commands/e2e.js +0 -265
  86. package/src/commands/global.js +0 -43
  87. package/src/commands/index.js +0 -45
  88. package/src/commands/instance-id.js +0 -47
  89. package/src/commands/locale/cronstrue.js +0 -122
  90. package/src/commands/locale/react-js-cron/en-US.json +0 -75
  91. package/src/commands/locale/react-js-cron/index.js +0 -17
  92. package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
  93. package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
  94. package/src/commands/locale.js +0 -81
  95. package/src/commands/p-test.js +0 -88
  96. package/src/commands/perf.js +0 -63
  97. package/src/commands/pkg.js +0 -321
  98. package/src/commands/pm2.js +0 -37
  99. package/src/commands/postinstall.js +0 -88
  100. package/src/commands/start.js +0 -148
  101. package/src/commands/tar.js +0 -36
  102. package/src/commands/test-coverage.js +0 -55
  103. package/src/commands/test.js +0 -107
  104. package/src/commands/umi.js +0 -33
  105. package/src/commands/update-deps.js +0 -72
  106. package/src/commands/upgrade.js +0 -47
  107. package/src/commands/view-license-key.js +0 -44
  108. package/src/index.js +0 -14
  109. package/src/license.js +0 -76
  110. package/src/logger.js +0 -75
  111. package/src/plugin-generator.js +0 -80
  112. package/src/util.js +0 -517
  113. package/templates/bundle-status.html +0 -338
  114. package/templates/create-app-package.json +0 -39
  115. package/templates/plugin/.npmignore.tpl +0 -2
  116. package/templates/plugin/README.md.tpl +0 -1
  117. package/templates/plugin/client.d.ts +0 -2
  118. package/templates/plugin/client.js +0 -1
  119. package/templates/plugin/package.json.tpl +0 -11
  120. package/templates/plugin/server.d.ts +0 -2
  121. package/templates/plugin/server.js +0 -1
  122. package/templates/plugin/src/client/client.d.ts +0 -249
  123. package/templates/plugin/src/client/index.tsx.tpl +0 -1
  124. package/templates/plugin/src/client/locale.ts +0 -21
  125. package/templates/plugin/src/client/models/index.ts +0 -12
  126. package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
  127. package/templates/plugin/src/index.ts +0 -2
  128. package/templates/plugin/src/locale/en-US.json +0 -1
  129. package/templates/plugin/src/locale/zh-CN.json +0 -1
  130. package/templates/plugin/src/server/collections/.gitkeep +0 -0
  131. package/templates/plugin/src/server/index.ts.tpl +0 -1
  132. package/templates/plugin/src/server/plugin.ts.tpl +0 -19
@@ -1,37 +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 { resolve, posix } = require('path');
11
- const { Command } = require('commander');
12
- const { readFileSync, writeFileSync } = require('fs');
13
-
14
- /**
15
- *
16
- * @param {Command} cli
17
- */
18
- module.exports = (cli) => {
19
- cli.command('create-nginx-conf').action(async (name, options) => {
20
- const file = resolve(__dirname, '../../nocobase.conf.tpl');
21
- const data = readFileSync(file, 'utf-8');
22
- let otherLocation = '';
23
- if (process.env.APP_PUBLIC_PATH !== '/') {
24
- otherLocation = `location / {
25
- alias ${posix.resolve(process.cwd())}/node_modules/@nocobase/app/dist/client/;
26
- try_files $uri $uri/ /index.html;
27
- }`;
28
- }
29
- const replaced = data
30
- .replace(/\{\{cwd\}\}/g, posix.resolve(process.cwd()))
31
- .replace(/\{\{publicPath\}\}/g, process.env.APP_PUBLIC_PATH)
32
- .replace(/\{\{apiPort\}\}/g, process.env.APP_PORT)
33
- .replace(/\{\{otherLocation\}\}/g, otherLocation);
34
- const targetFile = resolve(process.cwd(), 'storage', 'nocobase.conf');
35
- writeFileSync(targetFile, replaced);
36
- });
37
- };
@@ -1,33 +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 { resolve } = require('path');
11
- const { Command } = require('commander');
12
- const { PluginGenerator } = require('../plugin-generator');
13
-
14
- /**
15
- *
16
- * @param {Command} cli
17
- */
18
- module.exports = (cli) => {
19
- cli
20
- .command('create-plugin')
21
- .argument('<name>')
22
- .allowUnknownOption()
23
- .action(async (name, options) => {
24
- const generator = new PluginGenerator({
25
- cwd: resolve(process.cwd(), name),
26
- args: options,
27
- context: {
28
- name,
29
- },
30
- });
31
- await generator.run();
32
- });
33
- };
@@ -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
- };