@nocobase/devtools 0.13.0-alpha.9 → 0.14.0-alpha.2
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 +5 -4
- package/umiConfig.js +35 -27
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@nocobase/build": "0.
|
|
9
|
-
"@nocobase/client": "0.
|
|
8
|
+
"@nocobase/build": "0.14.0-alpha.2",
|
|
9
|
+
"@nocobase/client": "0.14.0-alpha.2",
|
|
10
10
|
"@testing-library/react": "^14.0.0",
|
|
11
11
|
"@types/jest": "^29.0.0",
|
|
12
12
|
"@types/koa": "^2.13.4",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"eslint-plugin-promise": "^6.1.1",
|
|
29
29
|
"eslint-plugin-react": "^7.33.0",
|
|
30
30
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
31
|
+
"fast-glob": "^3.3.1",
|
|
31
32
|
"jest": "^29.0.0",
|
|
32
33
|
"jest-cli": "^29.0.0",
|
|
33
34
|
"jest-dom": "^3.1.2",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
54
55
|
"directory": "packages/core/devtools"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ea841d4a1e8c37aa77b4fbae6a6a4937e2aa3c0a"
|
|
57
58
|
}
|
package/umiConfig.js
CHANGED
|
@@ -2,7 +2,7 @@ const { existsSync } = require('fs');
|
|
|
2
2
|
const { resolve, sep } = require('path');
|
|
3
3
|
const packageJson = require('./package.json');
|
|
4
4
|
const fs = require('fs');
|
|
5
|
-
const glob = require('glob');
|
|
5
|
+
const glob = require('fast-glob');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
|
|
8
8
|
console.log('VERSION: ', packageJson.version);
|
|
@@ -11,7 +11,8 @@ function getUmiConfig() {
|
|
|
11
11
|
const { APP_PORT, API_BASE_URL } = 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
|
-
const LOCAL_STORAGE_BASE_URL =
|
|
14
|
+
const LOCAL_STORAGE_BASE_URL = '/storage/uploads/';
|
|
15
|
+
const STATIC_PATH = '/static/';
|
|
15
16
|
|
|
16
17
|
function getLocalStorageProxy() {
|
|
17
18
|
if (LOCAL_STORAGE_BASE_URL.startsWith('http')) {
|
|
@@ -23,6 +24,10 @@ function getUmiConfig() {
|
|
|
23
24
|
target: PROXY_TARGET_URL,
|
|
24
25
|
changeOrigin: true,
|
|
25
26
|
},
|
|
27
|
+
[STATIC_PATH]: {
|
|
28
|
+
target: PROXY_TARGET_URL,
|
|
29
|
+
changeOrigin: true,
|
|
30
|
+
},
|
|
26
31
|
};
|
|
27
32
|
}
|
|
28
33
|
|
|
@@ -68,24 +73,25 @@ function getPackagePaths() {
|
|
|
68
73
|
const pkgs = [];
|
|
69
74
|
for (const key in paths) {
|
|
70
75
|
if (Object.hasOwnProperty.call(paths, key)) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
for (let dir of paths[key]) {
|
|
77
|
+
if (dir.includes('*')) {
|
|
78
|
+
const files = glob.sync(dir, { cwd: process.cwd(), onlyDirectories: true });
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
const dirname = resolve(process.cwd(), file);
|
|
81
|
+
if (existsSync(dirname)) {
|
|
82
|
+
const re = new RegExp(dir.replace('*', '(.+)'));
|
|
83
|
+
const p = dirname
|
|
84
|
+
.substring(process.cwd().length + 1)
|
|
85
|
+
.split(sep)
|
|
86
|
+
.join('/');
|
|
87
|
+
const match = re.exec(p);
|
|
88
|
+
pkgs.push([key.replace('*', match?.[1]), dirname]);
|
|
89
|
+
}
|
|
84
90
|
}
|
|
91
|
+
} else {
|
|
92
|
+
const dirname = resolve(process.cwd(), dir);
|
|
93
|
+
pkgs.push([key, dirname]);
|
|
85
94
|
}
|
|
86
|
-
} else {
|
|
87
|
-
const dirname = resolve(process.cwd(), dir);
|
|
88
|
-
pkgs.push([key, dirname]);
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
}
|
|
@@ -157,13 +163,13 @@ export default function devDynamicImport(packageName: string): Promise<any> {
|
|
|
157
163
|
fs.rmdirSync(this.outputPath, { recursive: true, force: true });
|
|
158
164
|
}
|
|
159
165
|
fs.mkdirSync(this.outputPath);
|
|
160
|
-
const validPluginPaths = this.pluginsPath.filter((
|
|
166
|
+
const validPluginPaths = this.pluginsPath.filter((pluginsPath) => fs.existsSync(pluginsPath));
|
|
161
167
|
if (!validPluginPaths.length || process.env.NODE_ENV === 'production') {
|
|
162
168
|
fs.writeFileSync(this.indexPath, this.emptyIndexContent);
|
|
163
169
|
return;
|
|
164
170
|
}
|
|
165
171
|
|
|
166
|
-
const pluginInfos = validPluginPaths.map((
|
|
172
|
+
const pluginInfos = validPluginPaths.map((pluginsPath) => this.getContent(pluginsPath)).flat();
|
|
167
173
|
|
|
168
174
|
// index.ts
|
|
169
175
|
fs.writeFileSync(this.indexPath, this.indexContent);
|
|
@@ -181,21 +187,23 @@ export default function devDynamicImport(packageName: string): Promise<any> {
|
|
|
181
187
|
});
|
|
182
188
|
}
|
|
183
189
|
|
|
184
|
-
getContent(
|
|
185
|
-
const pluginFolders =
|
|
190
|
+
getContent(pluginsPath) {
|
|
191
|
+
const pluginFolders = glob
|
|
192
|
+
.sync(['*/package.json', '*/*/package.json'], { cwd: pluginsPath, onlyFiles: true, absolute: true })
|
|
193
|
+
.map((item) => path.dirname(item));
|
|
186
194
|
const pluginInfos = pluginFolders
|
|
187
195
|
.filter((folder) => {
|
|
188
|
-
const pluginPackageJsonPath = path.join(
|
|
189
|
-
const pluginSrcClientPath = path.join(
|
|
196
|
+
const pluginPackageJsonPath = path.join(folder, 'package.json');
|
|
197
|
+
const pluginSrcClientPath = path.join(folder, 'src', 'client');
|
|
190
198
|
return fs.existsSync(pluginPackageJsonPath) && fs.existsSync(pluginSrcClientPath);
|
|
191
199
|
})
|
|
192
200
|
.map((folder) => {
|
|
193
|
-
const pluginPackageJsonPath = path.join(
|
|
201
|
+
const pluginPackageJsonPath = path.join(folder, 'package.json');
|
|
194
202
|
const pluginPackageJson = require(pluginPackageJsonPath);
|
|
195
203
|
const pluginSrcClientPath = path
|
|
196
|
-
.relative(this.packagesPath, path.join(
|
|
204
|
+
.relative(this.packagesPath, path.join(folder, 'src', 'client'))
|
|
197
205
|
.replaceAll('\\', '/');
|
|
198
|
-
const pluginFileName = `${path.basename(
|
|
206
|
+
const pluginFileName = `${path.basename(pluginsPath)}_${path.basename(folder).replaceAll('-', '_')}`;
|
|
199
207
|
const exportStatement = `export { default } from '${pluginSrcClientPath}';`;
|
|
200
208
|
return { exportStatement, pluginFileName, packageJsonName: pluginPackageJson.name };
|
|
201
209
|
});
|