@nocobase/devtools 1.3.38-beta → 1.4.0-alpha

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,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/devtools",
3
- "version": "1.3.38-beta",
3
+ "version": "1.4.0-alpha",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./src/index.js",
7
7
  "dependencies": {
8
- "@nocobase/build": "1.3.38-beta",
9
- "@nocobase/client": "1.3.38-beta",
10
- "@nocobase/test": "1.3.38-beta",
8
+ "@nocobase/build": "1.4.0-alpha",
9
+ "@nocobase/client": "1.4.0-alpha",
10
+ "@nocobase/test": "1.4.0-alpha",
11
11
  "@types/koa": "^2.13.4",
12
12
  "@types/koa-bodyparser": "^4.3.4",
13
13
  "@types/lodash": "^4.14.177",
@@ -49,5 +49,5 @@
49
49
  "url": "git+https://github.com/nocobase/nocobase.git",
50
50
  "directory": "packages/core/devtools"
51
51
  },
52
- "gitHead": "1b9490667c9224cd0b179cbf75e10a581c49b230"
52
+ "gitHead": "f097a2bddec152522b5645bd5d451f4c866d2060"
53
53
  }
package/umiConfig.d.ts CHANGED
@@ -24,3 +24,5 @@ export declare class IndexGenerator {
24
24
  constructor(outputPath: string, pluginsPath: string[]): void;
25
25
  generate(): void;
26
26
  };
27
+
28
+ export declare function generatePlugins(): {}
package/umiConfig.js CHANGED
@@ -8,7 +8,7 @@ const path = require('path');
8
8
  console.log('VERSION: ', packageJson.version);
9
9
 
10
10
  function getUmiConfig() {
11
- const { APP_PORT, API_BASE_URL, API_CLIENT_STORAGE_PREFIX, APP_PUBLIC_PATH } = process.env;
11
+ const { APP_PORT, API_BASE_URL, API_CLIENT_STORAGE_TYPE, API_CLIENT_STORAGE_PREFIX, APP_PUBLIC_PATH } = process.env;
12
12
  const API_BASE_PATH = process.env.API_BASE_PATH || '/api/';
13
13
  const PROXY_TARGET_URL = process.env.PROXY_TARGET_URL || `http://127.0.0.1:${APP_PORT}`;
14
14
  const LOCAL_STORAGE_BASE_URL = 'storage/uploads/';
@@ -41,6 +41,7 @@ function getUmiConfig() {
41
41
  'process.env.WS_PATH': process.env.WS_PATH,
42
42
  'process.env.API_BASE_URL': API_BASE_URL || API_BASE_PATH,
43
43
  'process.env.API_CLIENT_STORAGE_PREFIX': API_CLIENT_STORAGE_PREFIX,
44
+ 'process.env.API_CLIENT_STORAGE_TYPE': API_CLIENT_STORAGE_TYPE,
44
45
  'process.env.APP_ENV': process.env.APP_ENV,
45
46
  'process.env.VERSION': packageJson.version,
46
47
  'process.env.WEBSOCKET_URL': process.env.WEBSOCKET_URL,
@@ -53,6 +54,15 @@ function getUmiConfig() {
53
54
  target: PROXY_TARGET_URL,
54
55
  changeOrigin: true,
55
56
  pathRewrite: { [`^${API_BASE_PATH}`]: API_BASE_PATH },
57
+ onProxyRes(proxyRes, req, res) {
58
+ if (req.headers.accept === 'text/event-stream') {
59
+ res.writeHead(res.statusCode, {
60
+ 'Content-Type': 'text/event-stream',
61
+ 'Cache-Control': 'no-transform',
62
+ Connection: 'keep-alive',
63
+ });
64
+ }
65
+ },
56
66
  },
57
67
  // for local storage
58
68
  ...getLocalStorageProxy(),
@@ -137,14 +147,14 @@ class IndexGenerator {
137
147
  generate() {
138
148
  this.generatePluginContent();
139
149
  if (process.env.NODE_ENV === 'production') return;
140
- this.pluginsPath.forEach((pluginPath) => {
141
- if (!fs.existsSync(pluginPath)) {
142
- return;
143
- }
144
- fs.watch(pluginPath, { recursive: false }, () => {
145
- this.generatePluginContent();
146
- });
147
- });
150
+ // this.pluginsPath.forEach((pluginPath) => {
151
+ // if (!fs.existsSync(pluginPath)) {
152
+ // return;
153
+ // }
154
+ // fs.watch(pluginPath, { recursive: false }, () => {
155
+ // this.generatePluginContent();
156
+ // });
157
+ // });
148
158
  }
149
159
 
150
160
  get indexContent() {
@@ -156,7 +166,11 @@ function devDynamicImport(packageName: string): Promise<any> {
156
166
  if (!fileName) {
157
167
  return Promise.resolve(null);
158
168
  }
159
- return import(\`./packages/\${fileName}\`)
169
+ try {
170
+ return import(\`./packages/\${fileName}\`)
171
+ } catch (error) {
172
+ return Promise.resolve(null);
173
+ }
160
174
  }
161
175
  export default devDynamicImport;`;
162
176
  }
@@ -170,9 +184,9 @@ export default function devDynamicImport(packageName: string): Promise<any> {
170
184
 
171
185
  generatePluginContent() {
172
186
  if (fs.existsSync(this.outputPath)) {
173
- fs.rmdirSync(this.outputPath, { recursive: true, force: true });
187
+ fs.rmSync(this.outputPath, { recursive: true, force: true });
174
188
  }
175
- fs.mkdirSync(this.outputPath);
189
+ fs.mkdirSync(this.outputPath, { recursive: true, force: true });
176
190
  const validPluginPaths = this.pluginsPath.filter((pluginsPath) => fs.existsSync(pluginsPath));
177
191
  if (!validPluginPaths.length || process.env.NODE_ENV === 'production') {
178
192
  fs.writeFileSync(this.indexPath, this.emptyIndexContent);
@@ -247,3 +261,13 @@ export default function devDynamicImport(packageName: string): Promise<any> {
247
261
  exports.getUmiConfig = getUmiConfig;
248
262
  exports.resolveNocobasePackagesAlias = resolveNocobasePackagesAlias;
249
263
  exports.IndexGenerator = IndexGenerator;
264
+
265
+ exports.generatePlugins = function () {
266
+ const pluginDirs = (process.env.PLUGIN_PATH || 'packages/plugins/,packages/samples/,packages/pro-plugins/')
267
+ .split(',')
268
+ .map((item) => path.join(process.cwd(), item));
269
+
270
+ const outputPluginPath = path.join(process.env.APP_PACKAGE_ROOT, 'client', 'src', '.plugins');
271
+ const indexGenerator = new IndexGenerator(outputPluginPath, pluginDirs);
272
+ indexGenerator.generate();
273
+ };