@nocobase/cli 0.19.0-alpha.3 → 0.19.0-alpha.5

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": "0.19.0-alpha.3",
3
+ "version": "0.19.0-alpha.5",
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.19.0-alpha.3",
11
+ "@nocobase/app": "0.19.0-alpha.5",
12
12
  "@types/fs-extra": "^11.0.1",
13
13
  "@umijs/utils": "3.5.20",
14
14
  "chalk": "^4.1.1",
@@ -21,15 +21,16 @@
21
21
  "pm2": "^5.2.0",
22
22
  "portfinder": "^1.0.28",
23
23
  "serve": "^13.0.2",
24
+ "tree-kill": "^1.2.2",
24
25
  "tsx": "^4.6.2"
25
26
  },
26
27
  "devDependencies": {
27
- "@nocobase/devtools": "0.19.0-alpha.3"
28
+ "@nocobase/devtools": "0.19.0-alpha.5"
28
29
  },
29
30
  "repository": {
30
31
  "type": "git",
31
32
  "url": "git+https://github.com/nocobase/nocobase.git",
32
33
  "directory": "packages/core/cli"
33
34
  },
34
- "gitHead": "3cee597df101a3f8f0f1e2a6f75fc2dddd02ac74"
35
+ "gitHead": "580eca25451ec731d17ddef285d0b8c52c48d501"
35
36
  }
@@ -106,7 +106,9 @@ module.exports = (cli) => {
106
106
  env: {
107
107
  PORT: clientPort,
108
108
  APP_ROOT: `${APP_PACKAGE_ROOT}/client`,
109
- WEBSOCKET_URL: process.env.WEBSOCKET_URL || (serverPort ? `ws://localhost:${serverPort}/ws` : undefined),
109
+ WEBSOCKET_URL:
110
+ process.env.WEBSOCKET_URL ||
111
+ (serverPort ? `ws://localhost:${serverPort}${process.env.WS_PATH}` : undefined),
110
112
  PROXY_TARGET_URL:
111
113
  process.env.PROXY_TARGET_URL || (serverPort ? `http://127.0.0.1:${serverPort}` : undefined),
112
114
  },
@@ -4,6 +4,8 @@ const { execSync } = require('node:child_process');
4
4
  const axios = require('axios');
5
5
  const { pTest } = require('./p-test');
6
6
  const os = require('os');
7
+ const treeKill = require('tree-kill');
8
+ const chalk = require('chalk');
7
9
 
8
10
  /**
9
11
  * 检查服务是否启动成功
@@ -91,6 +93,17 @@ async function runApp(options = {}) {
91
93
  run('nocobase', [process.env.APP_ENV === 'production' ? 'start' : 'dev'], options);
92
94
  }
93
95
 
96
+ process.on('SIGINT', async () => {
97
+ treeKill(process.pid, (error) => {
98
+ if (error) {
99
+ console.error(error);
100
+ } else {
101
+ console.log(chalk.yellow('Force killing...'));
102
+ }
103
+ process.exit();
104
+ });
105
+ });
106
+
94
107
  const commonConfig = {
95
108
  stdio: 'inherit',
96
109
  };
@@ -150,6 +163,7 @@ module.exports = (cli) => {
150
163
  console.log('APP_BASE_URL:', process.env.APP_BASE_URL);
151
164
  }
152
165
  });
166
+
153
167
  e2e
154
168
  .command('test')
155
169
  .allowUnknownOption()
@@ -3,7 +3,7 @@ const { run, isDev, isPackageValid, generatePlaywrightPath } = require('../util'
3
3
  const { resolve } = require('path');
4
4
  const { existsSync } = require('fs');
5
5
  const { readFile, writeFile } = require('fs').promises;
6
- const { createStoragePluginsSymlink } = require('@nocobase/utils/plugin-symlink');
6
+ const { createStoragePluginsSymlink, createDevPluginsSymlink } = require('@nocobase/utils/plugin-symlink');
7
7
 
8
8
  /**
9
9
  * @param {Command} cli
@@ -13,12 +13,14 @@ module.exports = (cli) => {
13
13
  cli
14
14
  .command('postinstall')
15
15
  .allowUnknownOption()
16
- .action(async () => {
16
+ .option('--skip-umi')
17
+ .action(async (options) => {
17
18
  generatePlaywrightPath(true);
18
19
  await createStoragePluginsSymlink();
19
20
  if (!isDev()) {
20
21
  return;
21
22
  }
23
+ await createDevPluginsSymlink();
22
24
  const cwd = process.cwd();
23
25
  if (!existsSync(resolve(cwd, '.env')) && existsSync(resolve(cwd, '.env.example'))) {
24
26
  const content = await readFile(resolve(cwd, '.env.example'), 'utf-8');
@@ -31,11 +33,13 @@ module.exports = (cli) => {
31
33
  if (!isPackageValid('umi')) {
32
34
  return;
33
35
  }
34
- run('umi', ['generate', 'tmp'], {
35
- stdio: 'pipe',
36
- env: {
37
- APP_ROOT: `${APP_PACKAGE_ROOT}/client`,
38
- },
39
- });
36
+ if (!options.skipUmi) {
37
+ run('umi', ['generate', 'tmp'], {
38
+ stdio: 'pipe',
39
+ env: {
40
+ APP_ROOT: `${APP_PACKAGE_ROOT}/client`,
41
+ },
42
+ });
43
+ }
40
44
  });
41
45
  };
@@ -29,9 +29,10 @@ async function getProjectVersion() {
29
29
 
30
30
  class PluginGenerator extends Generator {
31
31
  constructor(options) {
32
- const { context = {}, ...opts } = options;
32
+ const { log, context = {}, ...opts } = options;
33
33
  super(opts);
34
34
  this.context = context;
35
+ this.log = log || console.log;
35
36
  }
36
37
 
37
38
  async getContext() {
@@ -51,20 +52,19 @@ class PluginGenerator extends Generator {
51
52
  const { name } = this.context;
52
53
  const target = resolve(process.cwd(), 'packages/plugins/', name);
53
54
  if (existsSync(target)) {
54
- console.log(chalk.red(`[${name}] plugin already exists.`));
55
+ this.log(chalk.red(`[${name}] plugin already exists.`));
55
56
  return;
56
57
  }
57
- console.log('Creating plugin');
58
+ this.log('Creating plugin');
58
59
  this.copyDirectory({
59
60
  target,
60
61
  context: await this.getContext(),
61
62
  path: join(__dirname, '../templates/plugin'),
62
63
  });
63
- console.log('');
64
+ this.log('');
64
65
  genTsConfigPaths();
65
- execa.sync('yarn', ['install'], { shell: true, stdio: 'inherit' });
66
- // execa.sync('yarn', ['build', `plugins/${name}`], { shell: true, stdio: 'inherit' });
67
- console.log(`The plugin folder is in ${chalk.green(`packages/plugins/${name}`)}`);
66
+ execa.sync('yarn', ['postinstall', '--skip-umi'], { shell: true, stdio: 'inherit' });
67
+ this.log(`The plugin folder is in ${chalk.green(`packages/plugins/${name}`)}`);
68
68
  }
69
69
  }
70
70
 
package/src/util.js CHANGED
@@ -271,6 +271,7 @@ exports.initEnv = function initEnv() {
271
271
  LOCAL_STORAGE_DEST: 'storage/uploads',
272
272
  PLUGIN_STORAGE_PATH: resolve(process.cwd(), 'storage/plugins'),
273
273
  MFSU_AD: 'none',
274
+ WS_PATH: '/ws',
274
275
  NODE_MODULES_PATH: resolve(process.cwd(), 'node_modules'),
275
276
  PM2_HOME: resolve(process.cwd(), './storage/.pm2'),
276
277
  PLUGIN_PACKAGE_PREFIX: '@nocobase/plugin-,@nocobase/plugin-sample-,@nocobase/preset-',
@@ -1,13 +1,13 @@
1
- import { InstallOptions, Plugin } from '@nocobase/server';
1
+ import { Plugin } from '@nocobase/server';
2
2
 
3
3
  export class {{{pascalCaseName}}}Server extends Plugin {
4
- afterAdd() {}
4
+ async afterAdd() {}
5
5
 
6
- beforeLoad() {}
6
+ async beforeLoad() {}
7
7
 
8
8
  async load() {}
9
9
 
10
- async install(options?: InstallOptions) {}
10
+ async install() {}
11
11
 
12
12
  async afterEnable() {}
13
13