@nocobase/cli 1.6.21 → 1.6.22

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.6.21",
3
+ "version": "1.6.22",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./src/index.js",
@@ -8,7 +8,7 @@
8
8
  "nocobase": "./bin/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@nocobase/app": "1.6.21",
11
+ "@nocobase/app": "1.6.22",
12
12
  "@types/fs-extra": "^11.0.1",
13
13
  "@umijs/utils": "3.5.20",
14
14
  "chalk": "^4.1.1",
@@ -18,18 +18,18 @@
18
18
  "fast-glob": "^3.3.1",
19
19
  "fs-extra": "^11.1.1",
20
20
  "p-all": "3.0.0",
21
- "pm2": "^6.0.5",
22
21
  "portfinder": "^1.0.28",
22
+ "tar": "^7.4.3",
23
23
  "tree-kill": "^1.2.2",
24
24
  "tsx": "^4.19.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@nocobase/devtools": "1.6.21"
27
+ "@nocobase/devtools": "1.6.22"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
31
31
  "url": "git+https://github.com/nocobase/nocobase.git",
32
32
  "directory": "packages/core/cli"
33
33
  },
34
- "gitHead": "2538df7c081e1bb558acead3f0cd87b6a7f02c78"
34
+ "gitHead": "321c0effa18670c0c3edfa09c79d535351ef2b0d"
35
35
  }
@@ -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();
@@ -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') {
@@ -10,7 +10,7 @@
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
15
 
16
16
  /**
@@ -26,6 +26,7 @@ module.exports = (cli) => {
26
26
  .option('--next')
27
27
  .option('-S|--skip-code-update')
28
28
  .action(async (options) => {
29
+ checkDBDialect();
29
30
  if (hasTsNode()) promptForTs();
30
31
  if (hasCorePackages()) {
31
32
  // await run('yarn', ['install']);
package/src/util.js CHANGED
@@ -360,7 +360,7 @@ exports.initEnv = function initEnv() {
360
360
  API_BASE_PATH: '/api/',
361
361
  API_CLIENT_STORAGE_PREFIX: 'NOCOBASE_',
362
362
  API_CLIENT_STORAGE_TYPE: 'localStorage',
363
- DB_DIALECT: 'sqlite',
363
+ // DB_DIALECT: 'sqlite',
364
364
  DB_STORAGE: 'storage/db/nocobase.sqlite',
365
365
  // DB_TIMEZONE: '+00:00',
366
366
  DB_UNDERSCORED: parseEnv('DB_UNDERSCORED'),
@@ -472,6 +472,12 @@ exports.initEnv = function initEnv() {
472
472
  }
473
473
  };
474
474
 
475
+ exports.checkDBDialect = function () {
476
+ if (!process.env.DB_DIALECT) {
477
+ throw new Error('DB_DIALECT is required.');
478
+ }
479
+ };
480
+
475
481
  exports.generatePlugins = function () {
476
482
  try {
477
483
  require.resolve('@nocobase/devtools/umiConfig');