@nocobase/devtools 0.18.0-alpha.9 → 0.19.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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/umiConfig.js +44 -15
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/devtools",
3
- "version": "0.18.0-alpha.9",
3
+ "version": "0.19.0-alpha.10",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./src/index.js",
7
7
  "dependencies": {
8
- "@nocobase/build": "0.18.0-alpha.9",
9
- "@nocobase/client": "0.18.0-alpha.9",
10
- "@nocobase/test": "0.18.0-alpha.9",
8
+ "@nocobase/build": "0.19.0-alpha.10",
9
+ "@nocobase/client": "0.19.0-alpha.10",
10
+ "@nocobase/test": "0.19.0-alpha.10",
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": "34ca0df4eede2e83fc86297b0fe19eba970e2b1b"
52
+ "gitHead": "d09d81eba67339da36bcec27939a85b35d180770"
53
53
  }
package/umiConfig.js CHANGED
@@ -37,6 +37,7 @@ function getUmiConfig() {
37
37
  return memo;
38
38
  }, {}),
39
39
  define: {
40
+ 'process.env.WS_PATH': process.env.WS_PATH,
40
41
  'process.env.API_BASE_URL': API_BASE_URL || API_BASE_PATH,
41
42
  'process.env.APP_ENV': process.env.APP_ENV,
42
43
  'process.env.VERSION': packageJson.version,
@@ -107,7 +108,13 @@ function resolveNocobasePackagesAlias(config) {
107
108
  }
108
109
  }
109
110
 
111
+ function getNodeModulesPath(packageDir) {
112
+ const node_modules_dir = path.join(process.cwd(), 'node_modules');
113
+ return path.join(node_modules_dir, packageDir);
114
+ }
110
115
  class IndexGenerator {
116
+ nocobaseDir = getNodeModulesPath('@nocobase');
117
+
111
118
  constructor(outputPath, pluginsPath) {
112
119
  this.outputPath = outputPath;
113
120
  this.pluginsPath = pluginsPath;
@@ -189,23 +196,45 @@ export default function devDynamicImport(packageName: string): Promise<any> {
189
196
  }
190
197
 
191
198
  getContent(pluginsPath) {
192
- const pluginFolders = glob
193
- .sync(['*/package.json', '*/*/package.json'], { cwd: pluginsPath, onlyFiles: true, absolute: true })
194
- .map((item) => path.dirname(item));
195
- const pluginInfos = pluginFolders
196
- .filter((folder) => {
197
- const pluginPackageJsonPath = path.join(folder, 'package.json');
198
- const pluginSrcClientPath = path.join(folder, 'src', 'client');
199
- return fs.existsSync(pluginPackageJsonPath) && fs.existsSync(pluginSrcClientPath);
199
+ const pluginFolders = glob.sync(['*/package.json', '*/*/package.json'], {
200
+ cwd: pluginsPath,
201
+ onlyFiles: true,
202
+ absolute: true,
203
+ });
204
+
205
+ const storagePluginFolders = glob.sync(['*/package.json', '*/*/package.json'], {
206
+ cwd: process.env.PLUGIN_STORAGE_PATH,
207
+ onlyFiles: true,
208
+ absolute: true,
209
+ });
210
+
211
+ const nocobasePluginFolders = glob
212
+ .sync(['plugin-*/package.json'], { cwd: this.nocobaseDir, onlyFiles: true, absolute: true })
213
+ .map((item) => fs.realpathSync(item));
214
+ const pluginInfos = Array.from(new Set([...pluginFolders, ...storagePluginFolders, ...nocobasePluginFolders]))
215
+ .filter((item) => {
216
+ const dirname = path.dirname(item);
217
+ const clientJs = path.join(dirname, 'client.js');
218
+ return fs.existsSync(clientJs);
200
219
  })
201
- .map((folder) => {
202
- const pluginPackageJsonPath = path.join(folder, 'package.json');
220
+ .map((pluginPackageJsonPath) => {
203
221
  const pluginPackageJson = require(pluginPackageJsonPath);
204
- const pluginSrcClientPath = path
205
- .relative(this.packagesPath, path.join(folder, 'src', 'client'))
206
- .replaceAll('\\', '/');
207
- const pluginFileName = `${path.basename(pluginsPath)}_${path.basename(folder).replaceAll('-', '_')}`;
208
- const exportStatement = `export { default } from '${pluginSrcClientPath}';`;
222
+ const pluginPathArr = pluginPackageJsonPath.replaceAll(path.sep, '/').split('/');
223
+ const hasNamespace = pluginPathArr[pluginPathArr.length - 3].startsWith('@');
224
+ const pluginFileName = (hasNamespace
225
+ ? `${pluginPathArr[pluginPathArr.length - 3].replace('@', '')}_${pluginPathArr[pluginPathArr.length - 2]}`
226
+ : pluginPathArr[pluginPathArr.length - 2]
227
+ ).replaceAll('-', '_');
228
+
229
+ let exportStatement = '';
230
+ if (pluginPackageJsonPath.includes('packages')) {
231
+ const pluginSrcClientPath = path
232
+ .relative(this.packagesPath, path.join(path.dirname(pluginPackageJsonPath), 'src', 'client'))
233
+ .replaceAll(path.sep, '/');
234
+ exportStatement = `export { default } from '${pluginSrcClientPath}';`;
235
+ } else {
236
+ exportStatement = `export { default } from '${pluginPackageJson.name}/client';`;
237
+ }
209
238
  return { exportStatement, pluginFileName, packageJsonName: pluginPackageJson.name };
210
239
  });
211
240