@nocobase/devtools 2.0.22 → 2.1.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.
- package/package.json +9 -5
- package/rsbuildConfig.d.ts +1 -0
- package/rsbuildConfig.js +46 -0
- package/umiConfig.js +35 -3
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/devtools",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-alpha.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@nocobase/build": "2.0.
|
|
9
|
-
"@nocobase/client": "2.0.
|
|
10
|
-
"@nocobase/test": "2.0.
|
|
8
|
+
"@nocobase/build": "2.1.0-alpha.10",
|
|
9
|
+
"@nocobase/client": "2.1.0-alpha.10",
|
|
10
|
+
"@nocobase/test": "2.1.0-alpha.10",
|
|
11
|
+
"@rsbuild/core": "1.7.3",
|
|
12
|
+
"@rsbuild/plugin-less": "^1.6.2",
|
|
13
|
+
"@rsbuild/plugin-node-polyfill": "1.4.4",
|
|
14
|
+
"@rsbuild/plugin-react": "1.4.6",
|
|
11
15
|
"@types/koa": "^2.15.0",
|
|
12
16
|
"@types/koa-bodyparser": "^4.3.4",
|
|
13
17
|
"@types/lodash": "^4.14.177",
|
|
@@ -50,5 +54,5 @@
|
|
|
50
54
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
51
55
|
"directory": "packages/core/devtools"
|
|
52
56
|
},
|
|
53
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ce790d46c0a5768ca9618c7d0d77ab8300de75c8"
|
|
54
58
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRsbuildAlias(): Record<string, string>;
|
package/rsbuildConfig.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve, sep } from 'node:path';
|
|
3
|
+
import glob from 'fast-glob';
|
|
4
|
+
|
|
5
|
+
function getTsconfigPaths() {
|
|
6
|
+
const content = readFileSync(resolve(process.cwd(), 'tsconfig.paths.json'), 'utf-8');
|
|
7
|
+
const json = JSON.parse(content);
|
|
8
|
+
return json.compilerOptions.paths;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getPackagePaths() {
|
|
12
|
+
const paths = getTsconfigPaths();
|
|
13
|
+
const pkgs = [];
|
|
14
|
+
for (const key in paths) {
|
|
15
|
+
if (Object.hasOwnProperty.call(paths, key)) {
|
|
16
|
+
for (const dir of paths[key]) {
|
|
17
|
+
if (dir.includes('*')) {
|
|
18
|
+
const files = glob.sync(dir, { cwd: process.cwd(), onlyDirectories: true });
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const dirname = resolve(process.cwd(), file);
|
|
21
|
+
if (existsSync(dirname)) {
|
|
22
|
+
const re = new RegExp(dir.replace('*', '(.+)'));
|
|
23
|
+
const normalized = dirname
|
|
24
|
+
.substring(process.cwd().length + 1)
|
|
25
|
+
.split(sep)
|
|
26
|
+
.join('/');
|
|
27
|
+
const match = re.exec(normalized);
|
|
28
|
+
pkgs.push([key.replace('*', match?.[1]), dirname]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
const dirname = resolve(process.cwd(), dir);
|
|
33
|
+
pkgs.push([key, dirname]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return pkgs;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getRsbuildAlias() {
|
|
42
|
+
return getPackagePaths().reduce((memo, item) => {
|
|
43
|
+
memo[item[0]] = item[1];
|
|
44
|
+
return memo;
|
|
45
|
+
}, {});
|
|
46
|
+
}
|
package/umiConfig.js
CHANGED
|
@@ -4,12 +4,22 @@ const packageJson = require('./package.json');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const glob = require('fast-glob');
|
|
6
6
|
const path = require('path');
|
|
7
|
+
const { resolvePublicPath, resolveV2PublicPath } = require('../cli/src/util');
|
|
7
8
|
|
|
8
9
|
console.log('VERSION: ', packageJson.version);
|
|
9
10
|
|
|
10
11
|
function getUmiConfig() {
|
|
11
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
APP_PORT,
|
|
14
|
+
APP_V2_PORT,
|
|
15
|
+
API_BASE_URL,
|
|
16
|
+
API_CLIENT_STORAGE_TYPE,
|
|
17
|
+
API_CLIENT_STORAGE_PREFIX,
|
|
18
|
+
APP_PUBLIC_PATH,
|
|
19
|
+
} = process.env;
|
|
12
20
|
const API_BASE_PATH = process.env.API_BASE_PATH || '/api/';
|
|
21
|
+
const normalizedAppPublicPath = resolvePublicPath(APP_PUBLIC_PATH || '/');
|
|
22
|
+
const V2_PUBLIC_PATH = resolveV2PublicPath(APP_PUBLIC_PATH || '/');
|
|
13
23
|
const PROXY_TARGET_URL = process.env.PROXY_TARGET_URL || `http://127.0.0.1:${APP_PORT}`;
|
|
14
24
|
const LOCAL_STORAGE_BASE_URL = 'storage/uploads/';
|
|
15
25
|
const STATIC_PATH = 'static/';
|
|
@@ -20,17 +30,37 @@ function getUmiConfig() {
|
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
return {
|
|
23
|
-
[
|
|
33
|
+
[normalizedAppPublicPath + LOCAL_STORAGE_BASE_URL]: {
|
|
24
34
|
target: PROXY_TARGET_URL,
|
|
25
35
|
changeOrigin: true,
|
|
26
36
|
},
|
|
27
|
-
[
|
|
37
|
+
[normalizedAppPublicPath + STATIC_PATH]: {
|
|
28
38
|
target: PROXY_TARGET_URL,
|
|
29
39
|
changeOrigin: true,
|
|
30
40
|
},
|
|
31
41
|
};
|
|
32
42
|
}
|
|
33
43
|
|
|
44
|
+
function getClientV2Proxy() {
|
|
45
|
+
if (!APP_V2_PORT) {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
[V2_PUBLIC_PATH]: {
|
|
51
|
+
target: `http://127.0.0.1:${APP_V2_PORT}`,
|
|
52
|
+
changeOrigin: true,
|
|
53
|
+
ws: true,
|
|
54
|
+
pathRewrite: { [`^${V2_PUBLIC_PATH}`]: V2_PUBLIC_PATH },
|
|
55
|
+
onProxyReq: (proxyReq, req, res) => {
|
|
56
|
+
if (req?.ip) {
|
|
57
|
+
proxyReq.setHeader('X-Forwarded-For', req.ip);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
34
64
|
return {
|
|
35
65
|
alias: getPackagePaths().reduce((memo, item) => {
|
|
36
66
|
memo[item[0]] = item[1];
|
|
@@ -72,6 +102,8 @@ function getUmiConfig() {
|
|
|
72
102
|
},
|
|
73
103
|
// for local storage
|
|
74
104
|
...getLocalStorageProxy(),
|
|
105
|
+
// v2 shell dev server proxy
|
|
106
|
+
...getClientV2Proxy(),
|
|
75
107
|
},
|
|
76
108
|
};
|
|
77
109
|
}
|