@nocobase/cli 1.7.0-beta.9 → 1.8.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "1.7.0-beta.9",
3
+ "version": "1.8.0-alpha.1",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./src/index.js",
@@ -8,29 +8,31 @@
8
8
  "nocobase": "./bin/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@nocobase/app": "1.7.0-beta.9",
11
+ "@nocobase/app": "1.8.0-alpha.1",
12
+ "@nocobase/license-kit": "^0.2.3",
12
13
  "@types/fs-extra": "^11.0.1",
13
14
  "@umijs/utils": "3.5.20",
14
15
  "chalk": "^4.1.1",
15
16
  "commander": "^9.2.0",
17
+ "deepmerge": "^4.3.1",
16
18
  "dotenv": "^16.0.0",
17
19
  "execa": "^5.1.1",
18
20
  "fast-glob": "^3.3.1",
19
21
  "fs-extra": "^11.1.1",
20
22
  "p-all": "3.0.0",
21
- "pm2": "^5.2.0",
23
+ "pm2": "^6.0.5",
22
24
  "portfinder": "^1.0.28",
23
- "serve": "^13.0.2",
25
+ "tar": "^7.4.3",
24
26
  "tree-kill": "^1.2.2",
25
27
  "tsx": "^4.19.0"
26
28
  },
27
29
  "devDependencies": {
28
- "@nocobase/devtools": "1.7.0-beta.9"
30
+ "@nocobase/devtools": "1.8.0-alpha.1"
29
31
  },
30
32
  "repository": {
31
33
  "type": "git",
32
34
  "url": "git+https://github.com/nocobase/nocobase.git",
33
35
  "directory": "packages/core/cli"
34
36
  },
35
- "gitHead": "7013a5080f3695d7750ab21005c90d2172c16480"
37
+ "gitHead": "bc81ea73ed91b18dfb7cfad0f353b825881b4cc7"
36
38
  }
@@ -0,0 +1,73 @@
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
+ };
@@ -8,7 +8,7 @@
8
8
  */
9
9
  const _ = require('lodash');
10
10
  const { Command } = require('commander');
11
- const { generatePlugins, run, postCheck, nodeCheck, promptForTs, isPortReachable } = require('../util');
11
+ const { generatePlugins, run, postCheck, nodeCheck, promptForTs, isPortReachable, checkDBDialect } = require('../util');
12
12
  const { getPortPromise } = require('portfinder');
13
13
  const chokidar = require('chokidar');
14
14
  const { uid } = require('@formily/shared');
@@ -36,6 +36,7 @@ module.exports = (cli) => {
36
36
  .option('-i, --inspect [port]')
37
37
  .allowUnknownOption()
38
38
  .action(async (opts) => {
39
+ checkDBDialect();
39
40
  let subprocess;
40
41
  const runDevClient = () => {
41
42
  console.log('starting client', 1 * clientPort);
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  const { Command } = require('commander');
11
- const { run, isPortReachable } = require('../util');
11
+ const { run, isPortReachable, checkDBDialect } = require('../util');
12
12
  const { execSync } = require('node:child_process');
13
13
  const axios = require('axios');
14
14
  const { pTest } = require('./p-test');
@@ -165,6 +165,7 @@ const filterArgv = () => {
165
165
  */
166
166
  module.exports = (cli) => {
167
167
  const e2e = cli.command('e2e').hook('preAction', () => {
168
+ checkDBDialect();
168
169
  if (process.env.APP_BASE_URL) {
169
170
  process.env.APP_BASE_URL = process.env.APP_BASE_URL.replace('localhost', '127.0.0.1');
170
171
  console.log('APP_BASE_URL:', process.env.APP_BASE_URL);
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  const { Command } = require('commander');
11
- const { run, isDev, isProd, promptForTs, downloadPro } = require('../util');
11
+ const { run, isDev, isProd, promptForTs, downloadPro, checkDBDialect } = require('../util');
12
12
 
13
13
  /**
14
14
  *
@@ -21,6 +21,7 @@ module.exports = (cli) => {
21
21
  .option('-h, --help')
22
22
  .option('--ts-node-dev')
23
23
  .action(async (options) => {
24
+ checkDBDialect();
24
25
  const cmd = process.argv.slice(2)?.[0];
25
26
  if (cmd === 'install') {
26
27
  await downloadPro();
@@ -29,10 +29,14 @@ module.exports = (cli) => {
29
29
  require('./pm2')(cli);
30
30
  require('./test')(cli);
31
31
  require('./test-coverage')(cli);
32
+ require('./benchmark')(cli);
32
33
  require('./umi')(cli);
34
+ require('./update-deps')(cli);
33
35
  require('./upgrade')(cli);
34
36
  require('./postinstall')(cli);
35
37
  require('./pkg')(cli);
38
+ require('./instance-id')(cli);
39
+ require('./view-license-key')(cli);
36
40
  if (isPackageValid('@umijs/utils')) {
37
41
  require('./create-plugin')(cli);
38
42
  }
@@ -0,0 +1,46 @@
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
+
17
+ /**
18
+ *
19
+ * @param {Command} cli
20
+ */
21
+ module.exports = (cli) => {
22
+ cli
23
+ .command('generate-instance-id')
24
+ .description('Generate InstanceID')
25
+ .option('--force', 'Force generate InstanceID')
26
+ .action(async (options) => {
27
+ console.log('Generating InstanceID...');
28
+ const dir = path.resolve(process.cwd(), 'storage/.license');
29
+ const filePath = path.resolve(dir, 'instance-id');
30
+ if (fs.existsSync(filePath) && !options.force) {
31
+ console.log('InstanceID already exists at ' + filePath);
32
+ return;
33
+ } else {
34
+ if (!fs.existsSync(dir)) {
35
+ fs.mkdirSync(dir, { recursive: true });
36
+ }
37
+ try {
38
+ const instanceId = await getInstanceIdAsync();
39
+ fs.writeFileSync(filePath, instanceId + '\n');
40
+ console.log(chalk.greenBright(`InstanceID saved to ${filePath}`));
41
+ } catch (e) {
42
+ console.log(e);
43
+ }
44
+ }
45
+ });
46
+ };
@@ -15,6 +15,7 @@ const tar = require('tar');
15
15
  const path = require('path');
16
16
  const { createStoragePluginsSymlink } = require('@nocobase/utils/plugin-symlink');
17
17
  const chalk = require('chalk');
18
+ const { getAccessKeyPair } = require('../util');
18
19
 
19
20
  class Package {
20
21
  data;
@@ -248,10 +249,13 @@ module.exports = (cli) => {
248
249
  NOCOBASE_PKG_USERNAME,
249
250
  NOCOBASE_PKG_PASSWORD,
250
251
  } = process.env;
251
- if (!(NOCOBASE_PKG_USERNAME && NOCOBASE_PKG_PASSWORD)) {
252
+ const { accessKeyId, accessKeySecret } = getAccessKeyPair();
253
+ if (!(NOCOBASE_PKG_USERNAME && NOCOBASE_PKG_PASSWORD) && !(accessKeyId && accessKeySecret)) {
252
254
  return;
253
255
  }
254
- const credentials = { username: NOCOBASE_PKG_USERNAME, password: NOCOBASE_PKG_PASSWORD };
256
+ const credentials = accessKeyId
257
+ ? { username: accessKeyId, password: accessKeySecret }
258
+ : { username: NOCOBASE_PKG_USERNAME, password: NOCOBASE_PKG_PASSWORD };
255
259
  const pm = new PackageManager({ baseURL: NOCOBASE_PKG_URL });
256
260
  await pm.login(credentials);
257
261
  const file = path.resolve(__dirname, '../../package.json');
@@ -8,7 +8,7 @@
8
8
  */
9
9
  const _ = require('lodash');
10
10
  const { Command } = require('commander');
11
- const { run, postCheck, downloadPro, promptForTs } = require('../util');
11
+ const { run, postCheck, downloadPro, promptForTs, checkDBDialect } = require('../util');
12
12
  const { existsSync, rmSync } = require('fs');
13
13
  const { resolve, isAbsolute } = require('path');
14
14
  const chalk = require('chalk');
@@ -48,8 +48,10 @@ module.exports = (cli) => {
48
48
  .option('-i, --instances [instances]')
49
49
  .option('--db-sync')
50
50
  .option('--quickstart')
51
+ .option('--launch-mode [launchMode]')
51
52
  .allowUnknownOption()
52
53
  .action(async (opts) => {
54
+ checkDBDialect();
53
55
  if (opts.quickstart) {
54
56
  await downloadPro();
55
57
  }
@@ -118,17 +120,27 @@ module.exports = (cli) => {
118
120
  ]);
119
121
  process.exit();
120
122
  } else {
121
- run(
122
- 'pm2-runtime',
123
- [
124
- 'start',
125
- ...instancesArgs,
126
- `${APP_PACKAGE_ROOT}/lib/index.js`,
127
- NODE_ARGS ? `--node-args="${NODE_ARGS}"` : undefined,
128
- '--',
129
- ...process.argv.slice(2),
130
- ].filter(Boolean),
131
- );
123
+ const launchMode = opts.launchMode || process.env.APP_LAUNCH_MODE || 'pm2';
124
+ if (launchMode === 'pm2') {
125
+ run(
126
+ 'pm2-runtime',
127
+ [
128
+ 'start',
129
+ ...instancesArgs,
130
+ `${APP_PACKAGE_ROOT}/lib/index.js`,
131
+ NODE_ARGS ? `--node-args="${NODE_ARGS}"` : undefined,
132
+ '--',
133
+ ...process.argv.slice(2),
134
+ ].filter(Boolean),
135
+ );
136
+ } else {
137
+ run(
138
+ 'node',
139
+ [`${APP_PACKAGE_ROOT}/lib/index.js`, ...(NODE_ARGS || '').split(' '), ...process.argv.slice(2)].filter(
140
+ Boolean,
141
+ ),
142
+ );
143
+ }
132
144
  }
133
145
  });
134
146
  };
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- const { run } = require('../util');
10
+ const { run, checkDBDialect } = require('../util');
11
11
  const fg = require('fast-glob');
12
12
 
13
13
  const coreClientPackages = ['packages/core/client', 'packages/core/sdk'];
@@ -30,6 +30,7 @@ const getPackagesDir = (isClient) => {
30
30
 
31
31
  module.exports = (cli) => {
32
32
  cli.command('test-coverage:server').action(async () => {
33
+ checkDBDialect();
33
34
  const packageRoots = getPackagesDir(false);
34
35
  for (const dir of packageRoots) {
35
36
  try {
@@ -41,6 +42,7 @@ module.exports = (cli) => {
41
42
  });
42
43
 
43
44
  cli.command('test-coverage:client').action(async () => {
45
+ checkDBDialect();
44
46
  const packageRoots = getPackagesDir(true);
45
47
  for (const dir of packageRoots) {
46
48
  try {
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  const { Command } = require('commander');
11
- const { run } = require('../util');
11
+ const { run, checkDBDialect } = require('../util');
12
12
  const path = require('path');
13
13
 
14
14
  /**
@@ -29,6 +29,7 @@ function addTestCommand(name, cli) {
29
29
  .arguments('[paths...]')
30
30
  .allowUnknownOption()
31
31
  .action(async (paths, opts) => {
32
+ checkDBDialect();
32
33
  if (name === 'test:server') {
33
34
  process.env.TEST_ENV = 'server-side';
34
35
  } else if (name === 'test:client') {
@@ -0,0 +1,71 @@
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
+ const json = deepmerge(descJson, sourceJson);
66
+ await writeJSON(descPath, json, { spaces: 2, encoding: 'utf8' });
67
+ await run('yarn', ['install']);
68
+ await downloadPro();
69
+ rmAppDir();
70
+ });
71
+ };
@@ -10,15 +10,25 @@
10
10
  const chalk = require('chalk');
11
11
  const { Command } = require('commander');
12
12
  const { resolve } = require('path');
13
- const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode } = require('../util');
13
+ const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode, checkDBDialect } = require('../util');
14
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
+ }
15
26
 
16
27
  /**
17
28
  *
18
29
  * @param {Command} cli
19
30
  */
20
31
  module.exports = (cli) => {
21
- const { APP_PACKAGE_ROOT } = process.env;
22
32
  cli
23
33
  .command('upgrade')
24
34
  .allowUnknownOption()
@@ -26,52 +36,12 @@ module.exports = (cli) => {
26
36
  .option('--next')
27
37
  .option('-S|--skip-code-update')
28
38
  .action(async (options) => {
29
- if (hasTsNode()) promptForTs();
30
- if (hasCorePackages()) {
31
- // await run('yarn', ['install']);
32
- await downloadPro();
33
- await runAppCommand('upgrade');
34
- return;
35
- }
39
+ checkDBDialect();
36
40
  if (options.skipCodeUpdate) {
37
- await downloadPro();
38
- await runAppCommand('upgrade');
39
- return;
40
- }
41
- // await runAppCommand('upgrade');
42
- if (!hasTsNode()) {
43
- await downloadPro();
44
- await runAppCommand('upgrade');
45
- return;
46
- }
47
- const rmAppDir = () => {
48
- // If ts-node is not installed, do not do the following
49
- const appDevDir = resolve(process.cwd(), './storage/.app-dev');
50
- if (existsSync(appDevDir)) {
51
- rmSync(appDevDir, { recursive: true, force: true });
52
- }
53
- };
54
- const pkg = require('../../package.json');
55
- let distTag = 'latest';
56
- if (pkg.version.includes('alpha')) {
57
- distTag = 'alpha';
58
- } else if (pkg.version.includes('beta')) {
59
- distTag = 'beta';
60
- }
61
- // get latest version
62
- const { stdout } = await run('npm', ['info', `@nocobase/cli@${distTag}`, 'version'], {
63
- stdio: 'pipe',
64
- });
65
- if (pkg.version === stdout) {
66
- await downloadPro();
67
41
  await runAppCommand('upgrade');
68
- await rmAppDir();
69
- return;
42
+ } else {
43
+ await run('nocobase', ['update-deps']);
44
+ await run('nocobase', ['upgrade', '--skip-code-update']);
70
45
  }
71
- await run('yarn', ['add', `@nocobase/cli@${distTag}`, `@nocobase/devtools@${distTag}`, '-W']);
72
- await run('yarn', ['install']);
73
- await downloadPro();
74
- await runAppCommand('upgrade');
75
- await rmAppDir();
76
46
  });
77
47
  };
@@ -0,0 +1,44 @@
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/util.js CHANGED
@@ -18,6 +18,7 @@ const dotenv = require('dotenv');
18
18
  const fs = require('fs-extra');
19
19
  const os = require('os');
20
20
  const moment = require('moment-timezone');
21
+ const { keyDecrypt } = require('@nocobase/license-kit');
21
22
 
22
23
  exports.isPackageValid = (pkg) => {
23
24
  try {
@@ -165,10 +166,11 @@ exports.promptForTs = () => {
165
166
  };
166
167
 
167
168
  exports.downloadPro = async () => {
168
- const { NOCOBASE_PKG_USERNAME, NOCOBASE_PKG_PASSWORD } = process.env;
169
- if (!(NOCOBASE_PKG_USERNAME && NOCOBASE_PKG_PASSWORD)) {
170
- return;
171
- }
169
+ // 此处不再判定,由pkgg命令处理
170
+ // const { NOCOBASE_PKG_USERNAME, NOCOBASE_PKG_PASSWORD } = process.env;
171
+ // if (!(NOCOBASE_PKG_USERNAME && NOCOBASE_PKG_PASSWORD)) {
172
+ // return;
173
+ // }
172
174
  await exports.run('yarn', ['nocobase', 'pkg', 'download-pro']);
173
175
  };
174
176
 
@@ -360,7 +362,7 @@ exports.initEnv = function initEnv() {
360
362
  API_BASE_PATH: '/api/',
361
363
  API_CLIENT_STORAGE_PREFIX: 'NOCOBASE_',
362
364
  API_CLIENT_STORAGE_TYPE: 'localStorage',
363
- DB_DIALECT: 'sqlite',
365
+ // DB_DIALECT: 'sqlite',
364
366
  DB_STORAGE: 'storage/db/nocobase.sqlite',
365
367
  // DB_TIMEZONE: '+00:00',
366
368
  DB_UNDERSCORED: parseEnv('DB_UNDERSCORED'),
@@ -389,7 +391,7 @@ exports.initEnv = function initEnv() {
389
391
  if (
390
392
  !process.env.APP_ENV_PATH &&
391
393
  process.argv[2] &&
392
- ['test', 'test:client', 'test:server'].includes(process.argv[2])
394
+ ['test', 'test:client', 'test:server', 'benchmark'].includes(process.argv[2])
393
395
  ) {
394
396
  if (fs.existsSync(resolve(process.cwd(), '.env.test'))) {
395
397
  process.env.APP_ENV_PATH = '.env.test';
@@ -460,8 +462,22 @@ exports.initEnv = function initEnv() {
460
462
  process.env.SOCKET_PATH = generateGatewayPath();
461
463
  fs.mkdirpSync(dirname(process.env.SOCKET_PATH), { force: true, recursive: true });
462
464
  fs.mkdirpSync(process.env.PM2_HOME, { force: true, recursive: true });
463
- const pkgDir = resolve(process.cwd(), 'storage/plugins', '@nocobase/plugin-multi-app-manager');
464
- fs.existsSync(pkgDir) && fs.rmdirSync(pkgDir, { force: true });
465
+ const pkgs = [
466
+ '@nocobase/plugin-multi-app-manager',
467
+ '@nocobase/plugin-departments',
468
+ '@nocobase/plugin-field-attachment-url',
469
+ '@nocobase/plugin-workflow-response-message',
470
+ ];
471
+ for (const pkg of pkgs) {
472
+ const pkgDir = resolve(process.cwd(), 'storage/plugins', pkg);
473
+ fs.existsSync(pkgDir) && fs.rmdirSync(pkgDir, { recursive: true, force: true });
474
+ }
475
+ };
476
+
477
+ exports.checkDBDialect = function () {
478
+ if (!process.env.DB_DIALECT) {
479
+ throw new Error('DB_DIALECT is required.');
480
+ }
465
481
  };
466
482
 
467
483
  exports.generatePlugins = function () {
@@ -473,3 +489,21 @@ exports.generatePlugins = function () {
473
489
  return;
474
490
  }
475
491
  };
492
+
493
+ exports.getAccessKeyPair = function () {
494
+ const keyFile = resolve(process.cwd(), 'storage/.license/license-key');
495
+ if (!fs.existsSync(keyFile)) {
496
+ console.log(chalk.yellow('license-key file not found', keyFile));
497
+ return {};
498
+ }
499
+ try {
500
+ const str = fs.readFileSync(keyFile, 'utf-8');
501
+ const keyDataStr = keyDecrypt(str);
502
+ const keyData = JSON.parse(keyDataStr);
503
+ const { accessKeyId, accessKeySecret } = keyData;
504
+ return { accessKeyId, accessKeySecret };
505
+ } catch (error) {
506
+ console.log(chalk.yellow('Key parse failed, please check your key'));
507
+ return {};
508
+ }
509
+ };
@@ -0,0 +1,39 @@
1
+ {
2
+ "private": true,
3
+ "workspaces": ["packages/*/*", "packages/*/*/*"],
4
+ "engines": {
5
+ "node": ">=18"
6
+ },
7
+ "scripts": {
8
+ "nocobase": "nocobase",
9
+ "pm": "nocobase pm",
10
+ "pm2": "nocobase pm2",
11
+ "dev": "nocobase dev",
12
+ "start": "nocobase start",
13
+ "clean": "nocobase clean",
14
+ "build": "nocobase build",
15
+ "test": "nocobase test",
16
+ "e2e": "nocobase e2e",
17
+ "tar": "nocobase tar",
18
+ "postinstall": "nocobase postinstall",
19
+ "lint": "eslint ."
20
+ },
21
+ "resolutions": {
22
+ "cytoscape": "3.28.0",
23
+ "@types/react": "18.3.18",
24
+ "@types/react-dom": "^18.0.0",
25
+ "react-router-dom": "6.28.1",
26
+ "react-router": "6.28.1",
27
+ "async": "^3.2.6",
28
+ "antd": "5.12.8",
29
+ "rollup": "4.24.0",
30
+ "semver": "^7.7.1"
31
+ },
32
+ "dependencies": {
33
+ "pm2": "^6.0.5",
34
+ "mysql2": "^3.14.0",
35
+ "mariadb": "^2.5.6",
36
+ "pg": "^8.14.1",
37
+ "pg-hstore": "^2.3.4"
38
+ }
39
+ }