@nocobase/cli 2.1.0-beta.2 → 2.1.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +367 -19
  3. package/README.zh-CN.md +336 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +131 -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 +95 -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 +156 -0
  20. package/dist/commands/down.js +197 -0
  21. package/dist/commands/download.js +865 -0
  22. package/dist/commands/env/add.js +307 -0
  23. package/dist/commands/env/auth.js +55 -0
  24. package/dist/commands/env/list.js +36 -0
  25. package/dist/commands/env/remove.js +59 -0
  26. package/dist/commands/env/update.js +67 -0
  27. package/dist/commands/env/use.js +28 -0
  28. package/dist/commands/init.js +950 -0
  29. package/dist/commands/install.js +1927 -0
  30. package/dist/commands/logs.js +97 -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 +61 -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 +119 -0
  37. package/dist/commands/restart.js +74 -0
  38. package/dist/commands/scaffold/migration.js +38 -0
  39. package/dist/commands/scaffold/plugin.js +37 -0
  40. package/dist/commands/self/check.js +71 -0
  41. package/dist/commands/self/index.js +20 -0
  42. package/dist/commands/self/update.js +86 -0
  43. package/dist/commands/skills/check.js +69 -0
  44. package/dist/commands/skills/index.js +20 -0
  45. package/dist/commands/skills/install.js +71 -0
  46. package/dist/commands/skills/update.js +71 -0
  47. package/dist/commands/start.js +218 -0
  48. package/dist/commands/stop.js +97 -0
  49. package/dist/commands/test.js +466 -0
  50. package/dist/commands/upgrade.js +594 -0
  51. package/dist/generated/command-registry.js +133 -0
  52. package/dist/help/runtime-help.js +20 -0
  53. package/dist/lib/api-client.js +244 -0
  54. package/dist/lib/app-runtime.js +153 -0
  55. package/dist/lib/auth-store.js +357 -0
  56. package/dist/lib/bootstrap.js +388 -0
  57. package/dist/lib/build-config.js +10 -0
  58. package/dist/lib/cli-home.js +61 -0
  59. package/dist/lib/cli-locale.js +115 -0
  60. package/dist/lib/command-discovery.js +39 -0
  61. package/dist/lib/env-auth.js +872 -0
  62. package/dist/lib/generated-command.js +150 -0
  63. package/dist/lib/http-request.js +49 -0
  64. package/dist/lib/naming.js +70 -0
  65. package/dist/lib/openapi.js +62 -0
  66. package/dist/lib/post-processors.js +23 -0
  67. package/dist/lib/prompt-catalog.js +581 -0
  68. package/dist/lib/prompt-validators.js +185 -0
  69. package/dist/lib/prompt-web-ui.js +2096 -0
  70. package/dist/lib/resource-command.js +343 -0
  71. package/dist/lib/resource-request.js +104 -0
  72. package/dist/lib/run-npm.js +197 -0
  73. package/dist/lib/runtime-generator.js +419 -0
  74. package/dist/lib/runtime-store.js +56 -0
  75. package/dist/lib/self-manager.js +246 -0
  76. package/dist/lib/skills-manager.js +269 -0
  77. package/dist/lib/startup-update.js +203 -0
  78. package/dist/lib/ui.js +175 -0
  79. package/dist/locale/en-US.json +336 -0
  80. package/dist/locale/zh-CN.json +336 -0
  81. package/dist/post-processors/data-modeling.js +66 -0
  82. package/dist/post-processors/data-source-manager.js +114 -0
  83. package/dist/post-processors/index.js +19 -0
  84. package/nocobase-ctl.config.json +287 -0
  85. package/package.json +60 -26
  86. package/LICENSE +0 -661
  87. package/bin/index.js +0 -39
  88. package/nocobase.conf.tpl +0 -95
  89. package/src/cli.js +0 -19
  90. package/src/commands/benchmark.js +0 -73
  91. package/src/commands/build.js +0 -49
  92. package/src/commands/clean.js +0 -30
  93. package/src/commands/client.js +0 -166
  94. package/src/commands/create-nginx-conf.js +0 -37
  95. package/src/commands/create-plugin.js +0 -33
  96. package/src/commands/dev.js +0 -200
  97. package/src/commands/doc.js +0 -76
  98. package/src/commands/e2e.js +0 -265
  99. package/src/commands/global.js +0 -43
  100. package/src/commands/index.js +0 -45
  101. package/src/commands/instance-id.js +0 -47
  102. package/src/commands/locale/cronstrue.js +0 -122
  103. package/src/commands/locale/react-js-cron/en-US.json +0 -75
  104. package/src/commands/locale/react-js-cron/index.js +0 -17
  105. package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
  106. package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
  107. package/src/commands/locale.js +0 -81
  108. package/src/commands/p-test.js +0 -88
  109. package/src/commands/perf.js +0 -63
  110. package/src/commands/pkg.js +0 -321
  111. package/src/commands/pm2.js +0 -37
  112. package/src/commands/postinstall.js +0 -88
  113. package/src/commands/start.js +0 -148
  114. package/src/commands/tar.js +0 -36
  115. package/src/commands/test-coverage.js +0 -55
  116. package/src/commands/test.js +0 -107
  117. package/src/commands/umi.js +0 -33
  118. package/src/commands/update-deps.js +0 -72
  119. package/src/commands/upgrade.js +0 -47
  120. package/src/commands/view-license-key.js +0 -44
  121. package/src/index.js +0 -14
  122. package/src/license.js +0 -76
  123. package/src/logger.js +0 -75
  124. package/src/plugin-generator.js +0 -80
  125. package/src/util.js +0 -517
  126. package/templates/bundle-status.html +0 -338
  127. package/templates/create-app-package.json +0 -39
  128. package/templates/plugin/.npmignore.tpl +0 -2
  129. package/templates/plugin/README.md.tpl +0 -1
  130. package/templates/plugin/client.d.ts +0 -2
  131. package/templates/plugin/client.js +0 -1
  132. package/templates/plugin/package.json.tpl +0 -11
  133. package/templates/plugin/server.d.ts +0 -2
  134. package/templates/plugin/server.js +0 -1
  135. package/templates/plugin/src/client/client.d.ts +0 -249
  136. package/templates/plugin/src/client/index.tsx.tpl +0 -1
  137. package/templates/plugin/src/client/locale.ts +0 -21
  138. package/templates/plugin/src/client/models/index.ts +0 -12
  139. package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
  140. package/templates/plugin/src/index.ts +0 -2
  141. package/templates/plugin/src/locale/en-US.json +0 -1
  142. package/templates/plugin/src/locale/zh-CN.json +0 -1
  143. package/templates/plugin/src/server/collections/.gitkeep +0 -0
  144. package/templates/plugin/src/server/index.ts.tpl +0 -1
  145. package/templates/plugin/src/server/plugin.ts.tpl +0 -19
package/bin/index.js DELETED
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const chalk = require('chalk');
4
- const { initEnv, genTsConfigPaths } = require('../src/util');
5
-
6
- initEnv();
7
- genTsConfigPaths();
8
-
9
- if (require('semver').satisfies(process.version, '<16')) {
10
- console.error(chalk.red('[nocobase cli]: Node.js version must be >= 16'));
11
- process.exit(1);
12
- }
13
-
14
- if (__dirname.includes(' ')) {
15
- console.error(chalk.red(`[nocobase cli]: PathError: Invalid path "${process.cwd()}"`));
16
- console.error(
17
- chalk.red('[nocobase cli]: PathError: The path cannot contain spaces. Please modify the path and try again.'),
18
- );
19
- process.exit(1);
20
- }
21
-
22
- // if (require('semver').satisfies(process.version, '>16') && !process.env.UNSET_NODE_OPTIONS) {
23
- // if (process.env.NODE_OPTIONS) {
24
- // let opts = process.env.NODE_OPTIONS;
25
- // if (!opts.includes('--openssl-legacy-provider')) {
26
- // opts = opts + ' --openssl-legacy-provider';
27
- // }
28
- // if (!opts.includes('--no-experimental-fetch')) {
29
- // opts = opts + ' --no-experimental-fetch';
30
- // }
31
- // process.env.NODE_OPTIONS = opts;
32
- // } else {
33
- // process.env.NODE_OPTIONS = '--openssl-legacy-provider --no-experimental-fetch';
34
- // }
35
- // }
36
-
37
- const cli = require('../src/cli');
38
-
39
- cli.parse(process.argv);
package/nocobase.conf.tpl DELETED
@@ -1,95 +0,0 @@
1
- log_format apm '"$time_local" client=$remote_addr '
2
- 'method=$request_method request="$request" '
3
- 'request_length=$request_length '
4
- 'status=$status bytes_sent=$bytes_sent '
5
- 'body_bytes_sent=$body_bytes_sent '
6
- 'referer=$http_referer '
7
- 'user_agent="$http_user_agent" '
8
- 'upstream_addr=$upstream_addr '
9
- 'upstream_status=$upstream_status '
10
- 'request_time=$request_time '
11
- 'upstream_response_time=$upstream_response_time '
12
- 'upstream_connect_time=$upstream_connect_time '
13
- 'upstream_header_time=$upstream_header_time';
14
-
15
- server {
16
- listen 80;
17
- server_name _;
18
- root {{cwd}}/node_modules/@nocobase/app/dist/client;
19
- index index.html;
20
- client_max_body_size 0;
21
- access_log /var/log/nginx/nocobase.log apm;
22
-
23
- gzip on;
24
- gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
25
-
26
- location {{publicPath}}storage/uploads/ {
27
- alias {{cwd}}/storage/uploads/;
28
- add_header Cache-Control "public";
29
- access_log off;
30
- autoindex off;
31
- }
32
-
33
- location {{publicPath}}static/plugins/ {
34
- alias {{cwd}}/node_modules/;
35
- expires 365d;
36
- add_header Cache-Control "public";
37
- access_log off;
38
- autoindex off;
39
-
40
- location ~ ^/static/plugins/@([^/]+)/([^/]+)/dist/client/(.*)$ {
41
- allow all;
42
- }
43
-
44
- location ~ ^/static/plugins/([^/]+)/dist/client/(.*)$ {
45
- allow all;
46
- }
47
-
48
- location ~ ^/static/plugins/(.*)$ {
49
- deny all;
50
- }
51
- }
52
-
53
- location {{publicPath}} {
54
- alias {{cwd}}/node_modules/@nocobase/app/dist/client/;
55
- try_files $uri $uri/ /index.html;
56
- add_header Last-Modified $date_gmt;
57
- add_header Cache-Control 'no-store, no-cache';
58
- add_header X-Robots-Tag "noindex, nofollow";
59
- if_modified_since off;
60
- expires off;
61
- etag off;
62
- location ~* \.(js|css)$ {
63
- expires 365d;
64
- add_header Cache-Control "public";
65
- }
66
- }
67
-
68
- {{otherLocation}}
69
-
70
- location ^~ {{publicPath}}api/ {
71
- proxy_pass http://127.0.0.1:{{apiPort}};
72
- proxy_http_version 1.1;
73
- proxy_set_header Upgrade $http_upgrade;
74
- proxy_set_header Connection 'upgrade';
75
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
76
- proxy_set_header X-Forwarded-Proto $scheme;
77
- proxy_set_header Host $host;
78
- proxy_set_header Referer $http_referer;
79
- proxy_set_header User-Agent $http_user_agent;
80
- add_header Cache-Control 'no-cache, no-store';
81
- proxy_cache_bypass $http_upgrade;
82
- proxy_connect_timeout 600;
83
- proxy_send_timeout 600;
84
- proxy_read_timeout 600;
85
- send_timeout 600;
86
- }
87
-
88
- location {{publicPath}}ws {
89
- proxy_pass http://127.0.0.1:{{apiPort}}{{publicPath}}ws;
90
- proxy_http_version 1.1;
91
- proxy_set_header Upgrade $http_upgrade;
92
- proxy_set_header Connection "Upgrade";
93
- proxy_set_header Host $host;
94
- }
95
- }
package/src/cli.js DELETED
@@ -1,19 +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 commands = require('./commands');
12
-
13
- const cli = new Command();
14
-
15
- cli.version(require('../package.json').version);
16
-
17
- commands(cli);
18
-
19
- module.exports = cli;
@@ -1,73 +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 glob = require('fast-glob');
11
- const { Command } = require('commander');
12
- const { run } = require('../util');
13
-
14
- /**
15
- *
16
- * @param {Command} cli
17
- */
18
- module.exports = (cli) => {
19
- return (
20
- cli
21
- .command('benchmark')
22
- .description('Run benchmark tests')
23
- // .option('--single-thread [singleThread]')
24
- .option('-a, --all [all]', 'Run all benchmark files which ends with .benchmark.{js,ts}')
25
- .arguments('[paths...]')
26
- .allowUnknownOption()
27
- .action(async (paths, opts) => {
28
- process.env.NODE_ENV = 'test';
29
- process.env.LOGGER_LEVEL = 'error';
30
-
31
- const cliArgs = ['--max_old_space_size=14096'];
32
-
33
- // if (process.argv.includes('-h') || process.argv.includes('--help')) {
34
- // await run('node', cliArgs);
35
- // return;
36
- // }
37
-
38
- // if (!opts.singleThread) {
39
- // process.argv.splice(process.argv.indexOf('--single-thread=false'), 1);
40
- // } else {
41
- // process.argv.push('--poolOptions.threads.singleThread=true');
42
- // }
43
-
44
- if (!paths.length) {
45
- if (opts.all) {
46
- paths.push('**/*.benchmark.ts');
47
- } else {
48
- console.warn(
49
- 'No benchmark files specified. Please provide at least 1 benchmark file or path to run. Or use --all to run all "*.benchmark.ts".',
50
- );
51
- return;
52
- }
53
- }
54
-
55
- const files = [];
56
-
57
- for (const pattern of paths) {
58
- for (const file of glob.sync(pattern)) {
59
- files.push(file);
60
- }
61
- }
62
-
63
- if (!files.length) {
64
- console.log('No benchmark files found');
65
- return;
66
- }
67
-
68
- for (const file of files) {
69
- await run('tsx', [...cliArgs, file]);
70
- }
71
- })
72
- );
73
- };
@@ -1,49 +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 { run, nodeCheck, isPackageValid, buildIndexHtml } = require('../util');
13
-
14
- /**
15
- *
16
- * @param {Command} cli
17
- */
18
- module.exports = (cli) => {
19
- cli
20
- .command('build')
21
- .allowUnknownOption()
22
- .argument('[packages...]')
23
- .option('-v, --version', 'print version')
24
- .option('-c, --compile', 'compile the @nocobase/build package')
25
- .option('-r, --retry', 'retry the last failed package')
26
- .option('-w, --watch', 'watch compile the @nocobase/build package')
27
- .option('-s, --sourcemap', 'generate sourcemap')
28
- .option('--no-dts', 'not generate dts')
29
- .action(async (pkgs, options) => {
30
- nodeCheck();
31
- if (options.compile || options.watch || isPackageValid('@nocobase/build/src/index.ts')) {
32
- await run('yarn', ['build', options.watch ? '--watch' : ''], {
33
- cwd: resolve(process.cwd(), 'packages/core/build'),
34
- });
35
- if (options.watch) return;
36
- }
37
- process.env['VITE_CJS_IGNORE_WARNING'] = 'true';
38
- process.env.APP_ENV = 'production';
39
-
40
- await run('nocobase-build', [
41
- ...pkgs,
42
- options.version ? '--version' : '',
43
- !options.dts ? '--no-dts' : '',
44
- options.sourcemap ? '--sourcemap' : '',
45
- options.retry ? '--retry' : '',
46
- ]);
47
- buildIndexHtml(true);
48
- });
49
- };
@@ -1,30 +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
-
14
- /**
15
- *
16
- * @param {Command} cli
17
- */
18
- module.exports = (cli) => {
19
- cli
20
- .command('clean')
21
- .allowUnknownOption()
22
- .action(() => {
23
- if (!isDev()) {
24
- return;
25
- }
26
- run('rimraf', ['-rf', './storage/app-dev']);
27
- run('rimraf', ['-rf', 'packages/*/*/{lib,esm,es,dist,node_modules}']);
28
- run('rimraf', ['-rf', 'packages/*/@*/*/{lib,esm,es,dist,node_modules}']);
29
- });
30
- };
@@ -1,166 +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 fs = require('fs-extra');
13
- const { resolve } = require('path');
14
-
15
- /**
16
- * 复制主应用客户端文件
17
- * @param {string} source - 源目录路径
18
- * @param {string} target - 目标目录路径
19
- */
20
- async function copyMainClient(source, target) {
21
- if (!(await fs.exists(source))) {
22
- console.log(chalk.yellow(`Source directory does not exist: ${source}`));
23
- return;
24
- }
25
- // 确保目标目录存在且为空
26
- await fs.ensureDir(target);
27
- await fs.emptyDir(target);
28
- await fs.copy(source, target, { recursive: true });
29
- console.log(chalk.green(`Copied main client files from ${source} to ${target}`));
30
- }
31
-
32
- /**
33
- * 复制插件客户端文件
34
- * @param {string} pluginsBaseDir - 插件基础目录路径
35
- * @param {string} namespace - 命名空间(如 '@nocobase' 或 '@nocobase-example')
36
- * @param {string} target - 目标目录
37
- */
38
- async function copyPluginClients(pluginsBaseDir, namespace, target) {
39
- const pluginsDir = resolve(process.cwd(), pluginsBaseDir, namespace);
40
- if (await fs.exists(pluginsDir)) {
41
- const pluginNames = await fs.readdir(pluginsDir);
42
- for (const pluginName of pluginNames) {
43
- const pluginPath = resolve(pluginsDir, pluginName);
44
- const pluginDistClient = resolve(pluginPath, 'dist/client');
45
- if (await fs.exists(pluginDistClient)) {
46
- const pluginTarget = resolve(target, 'static/plugins', namespace, pluginName, 'dist/client');
47
- await fs.mkdir(resolve(pluginTarget, '..'), { recursive: true });
48
- await fs.copy(pluginDistClient, pluginTarget, { recursive: true });
49
- console.log(chalk.green(`Copied ${namespace}/${pluginName} client files`));
50
- }
51
- }
52
- }
53
- }
54
-
55
- /**
56
- * 递归上传目录到 OSS
57
- * @param {Client} client - OSS 客户端实例
58
- * @param {string} localDir - 本地目录路径
59
- * @param {string} ossPrefix - OSS 对象前缀(目录路径)
60
- */
61
- async function uploadDirectoryToOSS(client, localDir, ossPrefix = '') {
62
- if (!(await fs.exists(localDir))) {
63
- console.log(chalk.yellow(`Directory does not exist: ${localDir}`));
64
- return;
65
- }
66
-
67
- const stats = await fs.stat(localDir);
68
- if (!stats.isDirectory()) {
69
- throw new Error(`${localDir} is not a directory`);
70
- }
71
-
72
- const files = await fs.readdir(localDir);
73
- let uploadedCount = 0;
74
-
75
- for (const file of files) {
76
- const filePath = resolve(localDir, file);
77
- const fileStats = await fs.stat(filePath);
78
-
79
- if (fileStats.isDirectory()) {
80
- // 递归处理子目录
81
- const subOssPrefix = ossPrefix ? `${ossPrefix}/${file}` : file;
82
- const subCount = await uploadDirectoryToOSS(client, filePath, subOssPrefix);
83
- uploadedCount += subCount;
84
- } else {
85
- // 上传文件
86
- const ossKey = ossPrefix ? `${ossPrefix}/${file}` : file;
87
- try {
88
- await client.put(ossKey, filePath);
89
- // console.log(chalk.green(`Uploaded: ${ossKey}`));
90
- uploadedCount++;
91
- } catch (error) {
92
- console.error(chalk.red(`Failed to upload ${ossKey}:`), error.message);
93
- throw error;
94
- }
95
- }
96
- }
97
-
98
- return uploadedCount;
99
- }
100
-
101
- /**
102
- *
103
- * @param {Command} cli
104
- */
105
- module.exports = (cli) => {
106
- cli
107
- .command('client:extract')
108
- .allowUnknownOption()
109
- .action(async () => {
110
- const version = require('../../package.json').version;
111
- const target = resolve(process.cwd(), 'storage/dist-client', version);
112
- const mainClientSource = resolve(process.cwd(), 'node_modules/@nocobase/app/dist/client');
113
- await copyMainClient(mainClientSource, target);
114
- await copyPluginClients('packages/plugins', '@nocobase', target);
115
- await copyPluginClients('packages/plugins', '@nocobase-example', target);
116
- await copyPluginClients('packages/pro-plugins', '@nocobase', target);
117
- });
118
-
119
- cli
120
- .command('client:upload')
121
- .allowUnknownOption()
122
- .action(async () => {
123
- const version = require('../../package.json').version;
124
- const target = resolve(process.cwd(), 'storage/dist-client', version);
125
-
126
- // 检查必要的环境变量
127
- if (
128
- !process.env.CDN_ALI_OSS_ACCESS_KEY_ID ||
129
- !process.env.CDN_ALI_OSS_ACCESS_KEY_SECRET ||
130
- !process.env.CDN_ALI_OSS_BUCKET ||
131
- !process.env.CDN_ALI_OSS_REGION
132
- ) {
133
- console.error(
134
- chalk.red(
135
- 'Missing required environment variables: CDN_ALI_OSS_ACCESS_KEY_ID, CDN_ALI_OSS_ACCESS_KEY_SECRET, CDN_ALI_OSS_BUCKET, CDN_ALI_OSS_REGION',
136
- ),
137
- );
138
- process.exit(1);
139
- }
140
-
141
- const Client = require('ali-oss');
142
-
143
- const client = new Client({
144
- accessKeyId: process.env.CDN_ALI_OSS_ACCESS_KEY_ID,
145
- accessKeySecret: process.env.CDN_ALI_OSS_ACCESS_KEY_SECRET,
146
- bucket: process.env.CDN_ALI_OSS_BUCKET,
147
- region: process.env.CDN_ALI_OSS_REGION,
148
- });
149
-
150
- if (!(await fs.exists(target))) {
151
- console.error(chalk.red(`Target directory does not exist: ${target}`));
152
- console.log(chalk.yellow('Please run "client:extract" first to generate the client files.'));
153
- process.exit(1);
154
- }
155
-
156
- console.log(chalk.blue(`Uploading directory ${target} to OSS...`));
157
- const ossPrefix = `${version}`;
158
- try {
159
- const uploadedCount = await uploadDirectoryToOSS(client, target, ossPrefix);
160
- console.log(chalk.green(`Successfully uploaded ${uploadedCount} files to OSS`));
161
- } catch (error) {
162
- console.error(chalk.red('Upload failed:'), error);
163
- process.exit(1);
164
- }
165
- });
166
- };
@@ -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
- };