@nocobase/cli 0.12.0-alpha.5 → 0.13.0-alpha.10

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/bin/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const dotenv = require('dotenv');
4
4
  const { resolve } = require('path');
5
5
  const { existsSync } = require('fs');
6
+ const chalk = require('chalk');
6
7
 
7
8
  const env = {
8
9
  APP_ENV: 'development',
@@ -35,6 +36,11 @@ for (const key in env) {
35
36
  }
36
37
  }
37
38
 
39
+ if (require('semver').satisfies(process.version, '<16')) {
40
+ console.error(chalk.red('[nocobase cli]: Node.js version must be >= 16'));
41
+ process.exit(1);
42
+ }
43
+
38
44
  if (require('semver').satisfies(process.version, '>16') && !process.env.UNSET_NODE_OPTIONS) {
39
45
  if (process.env.NODE_OPTIONS) {
40
46
  let opts = process.env.NODE_OPTIONS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "0.12.0-alpha.5",
3
+ "version": "0.13.0-alpha.10",
4
4
  "description": "",
5
5
  "license": "Apache-2.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": "0.12.0-alpha.5",
11
+ "@nocobase/app": "0.13.0-alpha.10",
12
12
  "@types/fs-extra": "^11.0.1",
13
13
  "@umijs/utils": "3.5.20",
14
14
  "chalk": "^4.1.1",
@@ -23,12 +23,12 @@
23
23
  "tsx": "^3.12.7"
24
24
  },
25
25
  "devDependencies": {
26
- "@nocobase/devtools": "0.12.0-alpha.5"
26
+ "@nocobase/devtools": "0.13.0-alpha.10"
27
27
  },
28
28
  "repository": {
29
29
  "type": "git",
30
30
  "url": "git+https://github.com/nocobase/nocobase.git",
31
31
  "directory": "packages/core/cli"
32
32
  },
33
- "gitHead": "689cc16e83361c4d0b91907e0deac30bdb907692"
33
+ "gitHead": "5360ed81650f6895f3ed39aede2706467d55862c"
34
34
  }
@@ -1,41 +1,34 @@
1
- const { resolve, dirname } = require('path');
1
+ const { resolve } = require('path');
2
2
  const { Command } = require('commander');
3
- const { run, nodeCheck, isPackageValid, promptForTs, hasCorePackages } = require('../util');
3
+ const { run, nodeCheck, isPackageValid } = require('../util');
4
4
 
5
5
  /**
6
6
  *
7
7
  * @param {Command} cli
8
8
  */
9
9
  module.exports = (cli) => {
10
- const { APP_PACKAGE_ROOT } = process.env;
11
- const clientPackage = `core/app`;
12
10
  cli
13
11
  .command('build')
14
12
  .allowUnknownOption()
15
13
  .argument('[packages...]')
14
+ .option('-v, --version', 'print version')
16
15
  .option('-c, --compile', 'compile the @nocobase/build package')
16
+ .option('-w, --watch', 'watch compile the @nocobase/build package')
17
+ .option('-s, --sourcemap', 'generate sourcemap')
18
+ .option('--no-dts', 'not generate dts')
17
19
  .action(async (pkgs, options) => {
18
- promptForTs();
19
20
  nodeCheck();
20
- if (isPackageValid('umi-tools/cli')) {
21
- if (options.compile || !isPackageValid('@nocobase/build/lib')) {
22
- await run('umi-tools', ['build'], {
23
- cwd: resolve(process.cwd(), 'packages/core/build'),
24
- });
25
- }
26
- }
27
- await run('nocobase-build', process.argv.slice(3));
28
- if (!hasCorePackages()) {
29
- return;
30
- }
31
- if (!pkgs.length || pkgs.includes(clientPackage)) {
32
- const file = require.resolve('@nocobase/app');
33
- await run('umi', ['build'], {
34
- env: {
35
- APP_ROOT: `${dirname(dirname(file))}/client`,
36
- NODE_ENV: 'production',
37
- },
21
+ if (options.compile || options.watch || isPackageValid('@nocobase/build/src/index.ts')) {
22
+ await run('yarn', ['build', options.watch ? '--watch' : ''], {
23
+ cwd: resolve(process.cwd(), 'packages/core/build'),
38
24
  });
25
+ if (options.watch) return;
39
26
  }
27
+ await run('nocobase-build', [
28
+ ...pkgs,
29
+ options.version ? '--version' : '',
30
+ !options.dts ? '--no-dts' : '',
31
+ options.sourcemap ? '--sourcemap' : '',
32
+ ]);
40
33
  });
41
34
  };
@@ -15,7 +15,6 @@ module.exports = (cli) => {
15
15
  return;
16
16
  }
17
17
  run('rimraf', ['-rf', './storage/app-dev']);
18
- run('rimraf', ['-rf', './**/{.umi,.umi-production}']);
19
18
  run('rimraf', ['-rf', 'packages/*/*/{lib,esm,es,dist,node_modules}']);
20
19
  });
21
20
  };
@@ -54,8 +54,6 @@ module.exports = (cli) => {
54
54
  });
55
55
  }
56
56
 
57
- await runAppCommand('install', ['--silent']);
58
-
59
57
  if (server || !client) {
60
58
  console.log('starting server', serverPort);
61
59
 
@@ -99,6 +97,7 @@ module.exports = (cli) => {
99
97
  env: {
100
98
  PORT: clientPort,
101
99
  APP_ROOT: `${APP_PACKAGE_ROOT}/client`,
100
+ WEBSOCKET_URL: process.env.WEBSOCKET_URL || (serverPort ? `ws://localhost:${serverPort}/ws` : undefined),
102
101
  PROXY_TARGET_URL:
103
102
  process.env.PROXY_TARGET_URL || (serverPort ? `http://127.0.0.1:${serverPort}` : undefined),
104
103
  },
@@ -12,11 +12,10 @@ module.exports = (cli) => {
12
12
  .option('-h, --help')
13
13
  .option('--ts-node-dev')
14
14
  .action((options) => {
15
- const { tsNodeDev } = options;
16
15
  if (isDev()) {
17
16
  promptForTs();
18
- run(tsNodeDev ? 'ts-node-dev' : 'ts-node', [
19
- '-P',
17
+ run('tsx', [
18
+ '--tsconfig',
20
19
  './tsconfig.server.json',
21
20
  '-r',
22
21
  'tsconfig-paths/register',
@@ -41,16 +41,6 @@ module.exports = (cli) => {
41
41
  return;
42
42
  }
43
43
  await postCheck(opts);
44
- const restartMark = resolve(process.cwd(), 'storage', 'restart');
45
- if (!existsSync(restartMark)) {
46
- if (opts.quickstart) {
47
- await run('node', [`${APP_PACKAGE_ROOT}/lib/index.js`, 'install', '--ignore-installed']);
48
- await run('node', [`${APP_PACKAGE_ROOT}/lib/index.js`, 'upgrade']);
49
- }
50
- if (opts.dbSync) {
51
- await run('node', [`${APP_PACKAGE_ROOT}/lib/index.js`, 'db:sync']);
52
- }
53
- }
54
44
  if (opts.daemon) {
55
45
  run('pm2', ['start', `${APP_PACKAGE_ROOT}/lib/index.js`, '--', ...process.argv.slice(2)]);
56
46
  } else {