@nocobase/devtools 0.18.0-alpha.8 → 0.19.0-alpha.1

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 +43 -15
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/devtools",
3
- "version": "0.18.0-alpha.8",
3
+ "version": "0.19.0-alpha.1",
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.8",
9
- "@nocobase/client": "0.18.0-alpha.8",
10
- "@nocobase/test": "0.18.0-alpha.8",
8
+ "@nocobase/build": "0.19.0-alpha.1",
9
+ "@nocobase/client": "0.19.0-alpha.1",
10
+ "@nocobase/test": "0.19.0-alpha.1",
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": "727d42f6f14e5f863831da3dbf3255ba1165b567"
52
+ "gitHead": "64601944412fc4d2e2bd05f4b982118dd28247dc"
53
53
  }
package/umiConfig.js CHANGED
@@ -107,7 +107,13 @@ function resolveNocobasePackagesAlias(config) {
107
107
  }
108
108
  }
109
109
 
110
+ function getNodeModulesPath(packageDir) {
111
+ const node_modules_dir = path.join(process.cwd(), 'node_modules');
112
+ return path.join(node_modules_dir, packageDir);
113
+ }
110
114
  class IndexGenerator {
115
+ nocobaseDir = getNodeModulesPath('@nocobase');
116
+
111
117
  constructor(outputPath, pluginsPath) {
112
118
  this.outputPath = outputPath;
113
119
  this.pluginsPath = pluginsPath;
@@ -189,23 +195,45 @@ export default function devDynamicImport(packageName: string): Promise<any> {
189
195
  }
190
196
 
191
197
  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);
198
+ const pluginFolders = glob.sync(['*/package.json', '*/*/package.json'], {
199
+ cwd: pluginsPath,
200
+ onlyFiles: true,
201
+ absolute: true,
202
+ });
203
+
204
+ const storagePluginFolders = glob.sync(['*/package.json', '*/*/package.json'], {
205
+ cwd: process.env.PLUGIN_STORAGE_PATH,
206
+ onlyFiles: true,
207
+ absolute: true,
208
+ });
209
+
210
+ const nocobasePluginFolders = glob
211
+ .sync(['plugin-*/package.json'], { cwd: this.nocobaseDir, onlyFiles: true, absolute: true })
212
+ .map((item) => fs.realpathSync(item));
213
+ const pluginInfos = Array.from(new Set([...pluginFolders, ...storagePluginFolders, ...nocobasePluginFolders]))
214
+ .filter((item) => {
215
+ const dirname = path.dirname(item);
216
+ const clientJs = path.join(dirname, 'client.js');
217
+ return fs.existsSync(clientJs);
200
218
  })
201
- .map((folder) => {
202
- const pluginPackageJsonPath = path.join(folder, 'package.json');
219
+ .map((pluginPackageJsonPath) => {
203
220
  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}';`;
221
+ const pluginPathArr = pluginPackageJsonPath.replaceAll(path.sep, '/').split('/');
222
+ const hasNamespace = pluginPathArr[pluginPathArr.length - 3].startsWith('@');
223
+ const pluginFileName = (hasNamespace
224
+ ? `${pluginPathArr[pluginPathArr.length - 3].replace('@', '')}_${pluginPathArr[pluginPathArr.length - 2]}`
225
+ : pluginPathArr[pluginPathArr.length - 2]
226
+ ).replaceAll('-', '_');
227
+
228
+ let exportStatement = '';
229
+ if (pluginPackageJsonPath.includes('packages')) {
230
+ const pluginSrcClientPath = path
231
+ .relative(this.packagesPath, path.join(path.dirname(pluginPackageJsonPath), 'src', 'client'))
232
+ .replaceAll(path.sep, '/');
233
+ exportStatement = `export { default } from '${pluginSrcClientPath}';`;
234
+ } else {
235
+ exportStatement = `export { default } from '${pluginPackageJson.name}/client';`;
236
+ }
209
237
  return { exportStatement, pluginFileName, packageJsonName: pluginPackageJson.name };
210
238
  });
211
239