@nocobase/cli 2.1.0-alpha.16 → 2.1.0-alpha.17

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 (105) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +134 -63
  3. package/bin/run.cmd +3 -0
  4. package/bin/run.js +87 -0
  5. package/dist/commands/api/index.js +8 -0
  6. package/dist/commands/env/add.js +53 -0
  7. package/dist/commands/env/auth.js +36 -0
  8. package/dist/commands/env/index.js +27 -0
  9. package/dist/commands/env/list.js +31 -0
  10. package/dist/commands/env/remove.js +54 -0
  11. package/dist/commands/env/update.js +58 -0
  12. package/dist/commands/env/use.js +26 -0
  13. package/dist/commands/resource/create.js +15 -0
  14. package/dist/commands/resource/destroy.js +15 -0
  15. package/dist/commands/resource/get.js +15 -0
  16. package/dist/commands/resource/index.js +7 -0
  17. package/dist/commands/resource/list.js +16 -0
  18. package/dist/commands/resource/query.js +15 -0
  19. package/dist/commands/resource/update.js +15 -0
  20. package/dist/generated/command-registry.js +88 -0
  21. package/dist/lib/api-client.js +199 -0
  22. package/dist/lib/auth-store.js +155 -0
  23. package/dist/lib/bootstrap.js +349 -0
  24. package/dist/lib/build-config.js +10 -0
  25. package/dist/lib/cli-home.js +30 -0
  26. package/dist/lib/env-auth.js +405 -0
  27. package/dist/lib/generated-command.js +142 -0
  28. package/dist/lib/naming.js +70 -0
  29. package/dist/lib/openapi.js +254 -0
  30. package/dist/lib/post-processors.js +23 -0
  31. package/dist/lib/resource-command.js +335 -0
  32. package/dist/lib/resource-request.js +104 -0
  33. package/dist/lib/runtime-generator.js +408 -0
  34. package/dist/lib/runtime-store.js +56 -0
  35. package/dist/lib/ui.js +169 -0
  36. package/dist/post-processors/data-modeling.js +66 -0
  37. package/dist/post-processors/data-source-manager.js +114 -0
  38. package/dist/post-processors/index.js +19 -0
  39. package/nocobase-ctl.config.json +327 -0
  40. package/package.json +50 -25
  41. package/LICENSE +0 -201
  42. package/bin/index.js +0 -39
  43. package/nocobase.conf.tpl +0 -184
  44. package/src/cli.js +0 -28
  45. package/src/commands/benchmark.js +0 -73
  46. package/src/commands/build.js +0 -81
  47. package/src/commands/clean.js +0 -30
  48. package/src/commands/client.js +0 -168
  49. package/src/commands/create-nginx-conf.js +0 -53
  50. package/src/commands/create-plugin.js +0 -33
  51. package/src/commands/dev.js +0 -290
  52. package/src/commands/doc.js +0 -76
  53. package/src/commands/e2e.js +0 -265
  54. package/src/commands/global.js +0 -43
  55. package/src/commands/index.js +0 -45
  56. package/src/commands/instance-id.js +0 -47
  57. package/src/commands/locale/cronstrue.js +0 -122
  58. package/src/commands/locale/react-js-cron/en-US.json +0 -75
  59. package/src/commands/locale/react-js-cron/index.js +0 -17
  60. package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
  61. package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
  62. package/src/commands/locale.js +0 -81
  63. package/src/commands/p-test.js +0 -88
  64. package/src/commands/perf.js +0 -63
  65. package/src/commands/pkg.js +0 -321
  66. package/src/commands/pm2.js +0 -37
  67. package/src/commands/postinstall.js +0 -88
  68. package/src/commands/start.js +0 -148
  69. package/src/commands/tar.js +0 -36
  70. package/src/commands/test-coverage.js +0 -55
  71. package/src/commands/test.js +0 -107
  72. package/src/commands/umi.js +0 -33
  73. package/src/commands/update-deps.js +0 -72
  74. package/src/commands/upgrade.js +0 -47
  75. package/src/commands/view-license-key.js +0 -44
  76. package/src/index.js +0 -14
  77. package/src/license.js +0 -76
  78. package/src/logger.js +0 -75
  79. package/src/plugin-generator.js +0 -80
  80. package/src/util.js +0 -607
  81. package/templates/bundle-status.html +0 -338
  82. package/templates/create-app-package.json +0 -39
  83. package/templates/plugin/.npmignore.tpl +0 -2
  84. package/templates/plugin/README.md.tpl +0 -1
  85. package/templates/plugin/client-v2.d.ts +0 -2
  86. package/templates/plugin/client-v2.js +0 -1
  87. package/templates/plugin/client.d.ts +0 -2
  88. package/templates/plugin/client.js +0 -1
  89. package/templates/plugin/package.json.tpl +0 -12
  90. package/templates/plugin/server.d.ts +0 -2
  91. package/templates/plugin/server.js +0 -1
  92. package/templates/plugin/src/client/client.d.ts +0 -249
  93. package/templates/plugin/src/client/index.tsx.tpl +0 -1
  94. package/templates/plugin/src/client/locale.ts +0 -21
  95. package/templates/plugin/src/client/models/index.ts +0 -12
  96. package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
  97. package/templates/plugin/src/client-v2/client.d.ts +0 -103
  98. package/templates/plugin/src/client-v2/index.tsx.tpl +0 -1
  99. package/templates/plugin/src/client-v2/plugin.tsx.tpl +0 -7
  100. package/templates/plugin/src/index.ts +0 -2
  101. package/templates/plugin/src/locale/en-US.json +0 -1
  102. package/templates/plugin/src/locale/zh-CN.json +0 -1
  103. package/templates/plugin/src/server/collections/.gitkeep +0 -0
  104. package/templates/plugin/src/server/index.ts.tpl +0 -1
  105. package/templates/plugin/src/server/plugin.ts.tpl +0 -19
@@ -1,88 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- const { Command } = require('commander');
11
- const { run, isDev, isPackageValid, generatePlaywrightPath, generatePlugins } = require('../util');
12
- const { dirname, resolve } = require('path');
13
- const { existsSync, mkdirSync, readFileSync, appendFileSync } = require('fs');
14
- const { readFile, writeFile } = require('fs').promises;
15
- const { createStoragePluginsSymlink, createDevPluginsSymlink } = require('@nocobase/utils/plugin-symlink');
16
-
17
- function runPatchPackage() {
18
- // run yarn patch-package
19
- // console.log('patching third party packages...');
20
- run('yarn', ['patch-package'], {
21
- stdio: 'pipe',
22
- });
23
- }
24
-
25
- function writeToExclude() {
26
- const excludePath = resolve(process.cwd(), '.git', 'info', 'exclude');
27
- const content = 'packages/pro-plugins/\n';
28
- const dirPath = dirname(excludePath);
29
-
30
- if (!existsSync(dirPath)) {
31
- try {
32
- mkdirSync(dirPath, { recursive: true });
33
- } catch (e) {
34
- console.log(`${e.message}, ignore write to git exclude`);
35
- return;
36
- }
37
- }
38
-
39
- let fileContent = '';
40
- if (existsSync(excludePath)) {
41
- fileContent = readFileSync(excludePath, 'utf-8');
42
- }
43
- if (!fileContent.includes(content)) {
44
- appendFileSync(excludePath, content);
45
- }
46
- }
47
-
48
- /**
49
- * @param {Command} cli
50
- */
51
- module.exports = (cli) => {
52
- const { APP_PACKAGE_ROOT } = process.env;
53
- cli
54
- .command('postinstall')
55
- .allowUnknownOption()
56
- .option('--skip-umi')
57
- .action(async (options) => {
58
- runPatchPackage();
59
- writeToExclude();
60
- generatePlugins();
61
- generatePlaywrightPath(true);
62
- await createStoragePluginsSymlink();
63
- if (!isDev()) {
64
- return;
65
- }
66
- await createDevPluginsSymlink();
67
- const cwd = process.cwd();
68
- if (!existsSync(resolve(cwd, '.env')) && existsSync(resolve(cwd, '.env.example'))) {
69
- const content = await readFile(resolve(cwd, '.env.example'), 'utf-8');
70
- await writeFile(resolve(cwd, '.env'), content, 'utf-8');
71
- }
72
- if (!existsSync(resolve(cwd, '.env.test')) && existsSync(resolve(cwd, '.env.test.example'))) {
73
- const content = await readFile(resolve(cwd, '.env.test.example'), 'utf-8');
74
- await writeFile(resolve(cwd, '.env.test'), content, 'utf-8');
75
- }
76
- if (!isPackageValid('umi')) {
77
- return;
78
- }
79
- if (!options.skipUmi) {
80
- run('umi', ['generate', 'tmp'], {
81
- stdio: 'pipe',
82
- env: {
83
- APP_ROOT: `${APP_PACKAGE_ROOT}/client`,
84
- },
85
- });
86
- }
87
- });
88
- };
@@ -1,148 +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 { run, postCheck, downloadPro, promptForTs, checkDBDialect } = require('../util');
12
- const { existsSync, rmSync } = require('fs');
13
- const { resolve, isAbsolute } = require('path');
14
- const chalk = require('chalk');
15
- const chokidar = require('chokidar');
16
-
17
- function getSocketPath() {
18
- const { SOCKET_PATH } = process.env;
19
-
20
- if (isAbsolute(SOCKET_PATH)) {
21
- return SOCKET_PATH;
22
- }
23
-
24
- return resolve(process.cwd(), SOCKET_PATH);
25
- }
26
-
27
- function deleteSockFiles() {
28
- const { PM2_HOME } = process.env;
29
- if (existsSync(PM2_HOME)) {
30
- rmSync(PM2_HOME, { recursive: true });
31
- }
32
- const socketPath = getSocketPath();
33
- if (existsSync(socketPath)) {
34
- rmSync(socketPath);
35
- }
36
- }
37
-
38
- /**
39
- *
40
- * @param {Command} cli
41
- */
42
- module.exports = (cli) => {
43
- const { APP_PACKAGE_ROOT, NODE_ARGS } = process.env;
44
- cli
45
- .command('start')
46
- .option('-p, --port [port]')
47
- .option('-d, --daemon')
48
- .option('-i, --instances [instances]')
49
- .option('--db-sync')
50
- .option('--quickstart')
51
- .option('--launch-mode [launchMode]')
52
- .allowUnknownOption()
53
- .action(async (opts) => {
54
- checkDBDialect();
55
- if (opts.quickstart) {
56
- await downloadPro();
57
- }
58
-
59
- if (process.env.NO_WATCH_PLUGINS === true || process.env.NO_WATCH_PLUGINS === 'true') {
60
- const restart = _.debounce(async () => {
61
- console.log('restarting...');
62
- await run('yarn', ['nocobase', 'pm2-restart']);
63
- }, 500);
64
-
65
- const watcher = chokidar.watch('./storage/plugins/**/*', {
66
- cwd: process.cwd(),
67
- ignoreInitial: true,
68
- ignored: /(^|[\/\\])\../, // 忽略隐藏文件
69
- persistent: true,
70
- depth: 1, // 只监听第一层目录
71
- });
72
-
73
- watcher
74
- .on('ready', () => {
75
- isReady = true;
76
- })
77
- .on('addDir', async (pathname) => {
78
- if (!isReady) return;
79
- restart();
80
- })
81
- .on('unlinkDir', async (pathname) => {
82
- if (!isReady) return;
83
- restart();
84
- });
85
- }
86
-
87
- if (opts.port) {
88
- process.env.APP_PORT = opts.port;
89
- }
90
- if (process.argv.includes('-h') || process.argv.includes('--help')) {
91
- promptForTs();
92
- run('ts-node', [
93
- '-P',
94
- process.env.SERVER_TSCONFIG_PATH,
95
- '-r',
96
- 'tsconfig-paths/register',
97
- `${APP_PACKAGE_ROOT}/src/index.ts`,
98
- ...process.argv.slice(2),
99
- ]);
100
- return;
101
- }
102
- if (!existsSync(resolve(process.cwd(), `${APP_PACKAGE_ROOT}/lib/index.js`))) {
103
- console.log('The code is not compiled, please execute it first');
104
- console.log(chalk.yellow('$ yarn build'));
105
- console.log('If you want to run in development mode, please execute');
106
- console.log(chalk.yellow('$ yarn dev'));
107
- return;
108
- }
109
- await postCheck(opts);
110
- if (!opts.daemon) {
111
- deleteSockFiles();
112
- }
113
- const instances = opts.instances || process.env.CLUSTER_MODE;
114
- const instancesArgs = instances ? ['-i', instances] : [];
115
- if (opts.daemon) {
116
- await run('pm2', [
117
- 'start',
118
- ...instancesArgs,
119
- `${APP_PACKAGE_ROOT}/lib/index.js`,
120
- '--',
121
- ...process.argv.slice(2),
122
- ]);
123
- process.exit();
124
- } else {
125
- const launchMode = opts.launchMode || process.env.APP_LAUNCH_MODE || 'pm2';
126
- if (launchMode === 'pm2') {
127
- run(
128
- 'pm2-runtime',
129
- [
130
- 'start',
131
- ...instancesArgs,
132
- `${APP_PACKAGE_ROOT}/lib/index.js`,
133
- NODE_ARGS ? `--node-args="${NODE_ARGS}"` : undefined,
134
- '--',
135
- ...process.argv.slice(2),
136
- ].filter(Boolean),
137
- );
138
- } else {
139
- run(
140
- 'node',
141
- [`${APP_PACKAGE_ROOT}/lib/index.js`, ...(NODE_ARGS || '').split(' '), ...process.argv.slice(2)].filter(
142
- Boolean,
143
- ),
144
- );
145
- }
146
- }
147
- });
148
- };
@@ -1,36 +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 } = require('../util');
13
-
14
- /**
15
- *
16
- * @param {Command} cli
17
- */
18
- module.exports = (cli) => {
19
- cli
20
- .command('tar')
21
- .allowUnknownOption()
22
- .argument('[packages...]')
23
- .option('-v, --version', 'print version')
24
- .option('-c, --compile', 'compile the @nocobase/build package')
25
- .option('-w, --watch', 'watch compile the @nocobase/build package')
26
- .action(async (pkgs, options) => {
27
- nodeCheck();
28
- if (options.compile || options.watch || isPackageValid('@nocobase/build/src/index.ts')) {
29
- await run('yarn', ['build', options.watch ? '--watch' : ''], {
30
- cwd: resolve(process.cwd(), 'packages/core/build'),
31
- });
32
- if (options.watch) return;
33
- }
34
- await run('nocobase-build', [...pkgs, '--only-tar', options.version ? '--version' : '']);
35
- });
36
- };
@@ -1,55 +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 { run, checkDBDialect } = require('../util');
11
- const fg = require('fast-glob');
12
-
13
- const coreClientPackages = ['packages/core/client', 'packages/core/sdk'];
14
- const isCore = (dir) => dir.startsWith('packages/core');
15
-
16
- const getPackagesDir = (isClient) => {
17
- if (process.argv.length > 3 && !process.argv[3].startsWith('-')) {
18
- return [process.argv[3]];
19
- }
20
-
21
- const allPackageJson = fg.sync(['packages/*/*/package.json', 'packages/*/*/*/package.json'], {
22
- cwd: process.cwd(),
23
- onlyFiles: true,
24
- });
25
- const res = allPackageJson.map((pkg) => pkg.replace('/package.json', ''));
26
- return isClient
27
- ? res.filter((dir) => (isCore(dir) ? coreClientPackages.includes(dir) : true))
28
- : res.filter((dir) => (isCore(dir) ? !coreClientPackages.includes(dir) : true));
29
- };
30
-
31
- module.exports = (cli) => {
32
- cli.command('test-coverage:server').action(async () => {
33
- checkDBDialect();
34
- const packageRoots = getPackagesDir(false);
35
- for (const dir of packageRoots) {
36
- try {
37
- await run('yarn', ['test:server', dir, '--coverage']);
38
- } catch (e) {
39
- continue;
40
- }
41
- }
42
- });
43
-
44
- cli.command('test-coverage:client').action(async () => {
45
- checkDBDialect();
46
- const packageRoots = getPackagesDir(true);
47
- for (const dir of packageRoots) {
48
- try {
49
- await run('yarn', ['test:client', dir, '--coverage']);
50
- } catch (e) {
51
- continue;
52
- }
53
- }
54
- });
55
- };
@@ -1,107 +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, checkDBDialect } = require('../util');
12
- const path = require('path');
13
-
14
- /**
15
- *
16
- * @param {String} name
17
- * @param {Command} cli
18
- */
19
- function addTestCommand(name, cli) {
20
- return cli
21
- .command(name)
22
- .option('-w, --watch')
23
- .option('--run')
24
- .option('--allowOnly')
25
- .option('--bail')
26
- .option('--coverage')
27
- .option('-h, --help')
28
- .option('--single-thread [singleThread]')
29
- .arguments('[paths...]')
30
- .allowUnknownOption()
31
- .action(async (paths, opts) => {
32
- checkDBDialect();
33
- if (name === 'test:server') {
34
- process.env.TEST_ENV = 'server-side';
35
- } else if (name === 'test:client') {
36
- process.env.TEST_ENV = 'client-side';
37
- }
38
- if (opts.server) {
39
- process.env.TEST_ENV = 'server-side';
40
- process.argv.splice(process.argv.indexOf('--server'), 1);
41
- }
42
-
43
- if (opts.client) {
44
- process.env.TEST_ENV = 'client-side';
45
- process.argv.splice(process.argv.indexOf('--client'), 1);
46
- }
47
-
48
- process.env.NODE_ENV = 'test';
49
-
50
- if (!opts.watch && !opts.run) {
51
- process.argv.push('--run');
52
- }
53
-
54
- const first = paths?.[0];
55
- if (!process.env.TEST_ENV && first) {
56
- const key = first.split(path.sep).join('/');
57
- if (key.includes('/client/') || key.includes('/client-v2/') || key.includes('/flow-engine/')) {
58
- process.env.TEST_ENV = 'client-side';
59
- } else {
60
- process.env.TEST_ENV = 'server-side';
61
- }
62
- }
63
-
64
- if (process.env.TEST_ENV === 'server-side' && opts.singleThread !== 'false') {
65
- process.argv.push('--poolOptions.threads.singleThread=true');
66
- }
67
-
68
- if (opts.singleThread === 'false') {
69
- process.argv.splice(process.argv.indexOf('--single-thread=false'), 1);
70
- }
71
-
72
- const cliArgs = ['--max_old_space_size=14096', './node_modules/vitest/vitest.mjs', ...process.argv.slice(3)];
73
-
74
- if (process.argv.includes('-h') || process.argv.includes('--help')) {
75
- await run('node', cliArgs);
76
- return;
77
- }
78
-
79
- if (process.env.TEST_ENV) {
80
- console.log('process.env.TEST_ENV', process.env.TEST_ENV, cliArgs);
81
- await run('node', cliArgs);
82
- } else {
83
- await Promise.all([
84
- run('node', cliArgs, {
85
- env: {
86
- TEST_ENV: 'client-side',
87
- },
88
- }),
89
- run('node', cliArgs, {
90
- env: {
91
- TEST_ENV: 'server-side',
92
- },
93
- }),
94
- ]);
95
- }
96
- });
97
- }
98
-
99
- /**
100
- *
101
- * @param {Command} cli
102
- */
103
- module.exports = (cli) => {
104
- addTestCommand('test:server', cli);
105
- addTestCommand('test:client', cli);
106
- addTestCommand('test', cli).option('--client').option('--server');
107
- };
@@ -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 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
- const { APP_PACKAGE_ROOT } = process.env;
20
- cli
21
- .command('umi')
22
- .allowUnknownOption()
23
- .action(() => {
24
- if (!isDev()) {
25
- return;
26
- }
27
- run('umi', process.argv.slice(3), {
28
- env: {
29
- APP_ROOT: `${APP_PACKAGE_ROOT}/client`,
30
- },
31
- });
32
- });
33
- };
@@ -1,72 +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 { resolve } = require('path');
13
- const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode, checkDBDialect } = require('../util');
14
- const { existsSync, rmSync } = require('fs');
15
- const { readJSON, writeJSON } = require('fs-extra');
16
- const deepmerge = require('deepmerge');
17
-
18
- const rmAppDir = () => {
19
- // If ts-node is not installed, do not do the following
20
- const appDevDir = resolve(process.cwd(), './storage/.app-dev');
21
- if (existsSync(appDevDir)) {
22
- rmSync(appDevDir, { recursive: true, force: true });
23
- }
24
- };
25
-
26
- /**
27
- *
28
- * @param {Command} cli
29
- */
30
- module.exports = (cli) => {
31
- cli
32
- .command('update-deps')
33
- .option('--force')
34
- .allowUnknownOption()
35
- .action(async (options) => {
36
- if (hasCorePackages() || !hasTsNode()) {
37
- await downloadPro();
38
- return;
39
- }
40
- const pkg = require('../../package.json');
41
- let distTag = 'latest';
42
- if (pkg.version.includes('alpha')) {
43
- distTag = 'alpha';
44
- } else if (pkg.version.includes('beta')) {
45
- distTag = 'beta';
46
- }
47
- const { stdout } = await run('npm', ['info', `@nocobase/cli@${distTag}`, 'version'], {
48
- stdio: 'pipe',
49
- });
50
- if (!options.force && pkg.version === stdout) {
51
- await downloadPro();
52
- rmAppDir();
53
- return;
54
- }
55
- const descPath = resolve(process.cwd(), 'package.json');
56
- const descJson = await readJSON(descPath, 'utf8');
57
- const sourcePath = resolve(__dirname, '../../templates/create-app-package.json');
58
- const sourceJson = await readJSON(sourcePath, 'utf8');
59
- if (descJson['dependencies']?.['@nocobase/cli']) {
60
- descJson['dependencies']['@nocobase/cli'] = stdout;
61
- }
62
- if (descJson['devDependencies']?.['@nocobase/devtools']) {
63
- descJson['devDependencies']['@nocobase/devtools'] = stdout;
64
- }
65
- descJson['resolutions'] = sourceJson['resolutions'];
66
- const json = deepmerge(descJson, sourceJson);
67
- await writeJSON(descPath, json, { spaces: 2, encoding: 'utf8' });
68
- await run('yarn', ['install']);
69
- await downloadPro();
70
- rmAppDir();
71
- });
72
- };
@@ -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 { resolve } = require('path');
13
- const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode, checkDBDialect } = require('../util');
14
- const { existsSync, rmSync } = require('fs');
15
- const { readJSON, writeJSON } = require('fs-extra');
16
- const deepmerge = require('deepmerge');
17
-
18
- async function updatePackage() {
19
- const sourcePath = resolve(__dirname, '../../templates/create-app-package.json');
20
- const descPath = resolve(process.cwd(), 'package.json');
21
- const sourceJson = await readJSON(sourcePath, 'utf8');
22
- const descJson = await readJSON(descPath, 'utf8');
23
- const json = deepmerge(descJson, sourceJson);
24
- await writeJSON(descPath, json, { spaces: 2, encoding: 'utf8' });
25
- }
26
-
27
- /**
28
- *
29
- * @param {Command} cli
30
- */
31
- module.exports = (cli) => {
32
- cli
33
- .command('upgrade')
34
- .allowUnknownOption()
35
- .option('--raw')
36
- .option('--next')
37
- .option('-S|--skip-code-update')
38
- .action(async (options) => {
39
- checkDBDialect();
40
- if (options.skipCodeUpdate) {
41
- await runAppCommand('upgrade');
42
- } else {
43
- await run('nocobase', ['update-deps']);
44
- await run('nocobase', ['upgrade', '--skip-code-update']);
45
- }
46
- });
47
- };
@@ -1,44 +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 { keyDecrypt } = require('@nocobase/license-kit');
13
- const path = require('path');
14
- const fs = require('fs');
15
-
16
- /**
17
- *
18
- * @param {Command} cli
19
- */
20
- module.exports = (cli) => {
21
- cli
22
- .command('view-license-key')
23
- .description('View License Key')
24
- .action(async (options) => {
25
- const dir = path.resolve(process.cwd(), 'storage/.license');
26
- const filePath = path.resolve(dir, 'license-key');
27
- if (!fs.existsSync(filePath)) {
28
- console.log('License key not found at ' + filePath);
29
- return;
30
- }
31
- const key = fs.readFileSync(filePath, 'utf-8');
32
- let keyDataStr;
33
- try {
34
- keyDataStr = keyDecrypt(key);
35
- } catch (e) {
36
- console.log('License key decrypt failed', e);
37
- return;
38
- }
39
- const keyData = JSON.parse(keyDataStr);
40
- const { accessKeyId, accessKeySecret } = keyData;
41
- console.log(chalk.greenBright(`Access Key ID: ${accessKeyId}`));
42
- console.log(chalk.greenBright(`Access Key Secret: ${accessKeySecret}`));
43
- });
44
- };
package/src/index.js DELETED
@@ -1,14 +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 util = require('./util');
11
-
12
- module.exports = {
13
- ...util,
14
- };