@nocobase/server 2.1.0-beta.34 → 2.1.0-beta.36
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/lib/gateway/index.js
CHANGED
|
@@ -294,6 +294,7 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
294
294
|
__nocobase_api_client_share_token__: import_node_process.default.env.API_CLIENT_SHARE_TOKEN === "true",
|
|
295
295
|
__nocobase_ws_url__: import_node_process.default.env.WEBSOCKET_URL || "",
|
|
296
296
|
__nocobase_ws_path__: import_node_process.default.env.WS_PATH,
|
|
297
|
+
__nocobase_app_dev__: import_node_process.default.env.NOCOBASE_APP_DEV === "true",
|
|
297
298
|
__esm_cdn_base_url__: import_node_process.default.env.ESM_CDN_BASE_URL || "https://esm.sh",
|
|
298
299
|
__esm_cdn_suffix__: import_node_process.default.env.ESM_CDN_SUFFIX || ""
|
|
299
300
|
};
|
|
@@ -12,6 +12,7 @@ export declare class PackageUrls {
|
|
|
12
12
|
static clear(): void;
|
|
13
13
|
static getCacheKey(packageName: string, lane: PluginClientLane): string;
|
|
14
14
|
static get(packageName: string, lane?: PluginClientLane): Promise<string>;
|
|
15
|
+
static getAppDevUrl(packageName: string, lane: PluginClientLane): string;
|
|
15
16
|
static hasClientEntry(packageName: string, lane: PluginClientLane): Promise<boolean>;
|
|
16
17
|
static fetch(packageName: string, lane?: PluginClientLane): Promise<string>;
|
|
17
18
|
}
|
|
@@ -48,6 +48,7 @@ var import_crypto = __toESM(require("crypto"));
|
|
|
48
48
|
var import_fs = __toESM(require("fs"));
|
|
49
49
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
50
50
|
var import_path = __toESM(require("path"));
|
|
51
|
+
var import_plugin_manager = __toESM(require("../plugin-manager"));
|
|
51
52
|
var import_utils2 = require("../utils");
|
|
52
53
|
var import_package = __toESM(require("../../../package.json"));
|
|
53
54
|
const PLUGIN_CLIENT_ENTRY_FILES = {
|
|
@@ -58,6 +59,32 @@ const PLUGIN_CLIENT_MARKER_FILES = {
|
|
|
58
59
|
client: "client.js",
|
|
59
60
|
"client-v2": "client-v2.js"
|
|
60
61
|
};
|
|
62
|
+
function getAppDevPluginUrls() {
|
|
63
|
+
if (process.env.NOCOBASE_APP_DEV !== "true" || !process.env.NOCOBASE_APP_DEV_PLUGIN_URLS) {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(process.env.NOCOBASE_APP_DEV_PLUGIN_URLS);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
__name(getAppDevPluginUrls, "getAppDevPluginUrls");
|
|
73
|
+
function getAppDevPluginDependencies(packageJson2, lane) {
|
|
74
|
+
const appDevPluginUrls = getAppDevPluginUrls();
|
|
75
|
+
const deps = {
|
|
76
|
+
...packageJson2.dependencies,
|
|
77
|
+
...packageJson2.peerDependencies,
|
|
78
|
+
...packageJson2.devDependencies
|
|
79
|
+
};
|
|
80
|
+
return Object.keys(deps).filter(
|
|
81
|
+
(packageName) => {
|
|
82
|
+
var _a;
|
|
83
|
+
return ((_a = appDevPluginUrls[packageName]) == null ? void 0 : _a[lane]) || packageName.startsWith("@nocobase/plugin-") || packageName.startsWith("@nocobase/preset-");
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
__name(getAppDevPluginDependencies, "getAppDevPluginDependencies");
|
|
61
88
|
const _PackageUrls = class _PackageUrls {
|
|
62
89
|
static clear() {
|
|
63
90
|
this.items = {};
|
|
@@ -66,6 +93,10 @@ const _PackageUrls = class _PackageUrls {
|
|
|
66
93
|
return `${lane}:${packageName}`;
|
|
67
94
|
}
|
|
68
95
|
static async get(packageName, lane = "client") {
|
|
96
|
+
const appDevUrl = this.getAppDevUrl(packageName, lane);
|
|
97
|
+
if (appDevUrl) {
|
|
98
|
+
return appDevUrl;
|
|
99
|
+
}
|
|
69
100
|
const cacheKey = this.getCacheKey(packageName, lane);
|
|
70
101
|
const cached = this.items[cacheKey];
|
|
71
102
|
if (cached) {
|
|
@@ -79,7 +110,14 @@ const _PackageUrls = class _PackageUrls {
|
|
|
79
110
|
}
|
|
80
111
|
return nextUrl;
|
|
81
112
|
}
|
|
113
|
+
static getAppDevUrl(packageName, lane) {
|
|
114
|
+
var _a;
|
|
115
|
+
return (_a = getAppDevPluginUrls()[packageName]) == null ? void 0 : _a[lane];
|
|
116
|
+
}
|
|
82
117
|
static async hasClientEntry(packageName, lane) {
|
|
118
|
+
if (this.getAppDevUrl(packageName, lane)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
83
121
|
const pkgPath = import_path.default.resolve(process.env.NODE_MODULES_PATH, packageName);
|
|
84
122
|
if (!await import_fs_extra.default.exists(pkgPath)) {
|
|
85
123
|
return false;
|
|
@@ -141,6 +179,11 @@ async function listEnabledPlugins(ctx, lane = "client") {
|
|
|
141
179
|
options,
|
|
142
180
|
url
|
|
143
181
|
};
|
|
182
|
+
if (PackageUrls.getAppDevUrl(packageName, lane)) {
|
|
183
|
+
const packageJson2 = await import_plugin_manager.default.getPackageJson(packageName);
|
|
184
|
+
entry.devMode = "esm";
|
|
185
|
+
entry.appDevDependencies = getAppDevPluginDependencies(packageJson2, lane);
|
|
186
|
+
}
|
|
144
187
|
if (lane === "client" && await PackageUrls.hasClientEntry(packageName, "client-v2")) {
|
|
145
188
|
const clientV2Url = await PackageUrls.get(packageName, "client-v2");
|
|
146
189
|
if (clientV2Url) {
|
|
@@ -155,7 +155,11 @@ const _PluginManager = class _PluginManager {
|
|
|
155
155
|
*/
|
|
156
156
|
static async getPackageJson(nameOrPkg) {
|
|
157
157
|
const { packageName } = await this.parseName(nameOrPkg);
|
|
158
|
-
const
|
|
158
|
+
const nodeModulesPath = String(process.env.NODE_MODULES_PATH ?? "").trim();
|
|
159
|
+
if (!nodeModulesPath) {
|
|
160
|
+
throw new Error("NODE_MODULES_PATH is not configured");
|
|
161
|
+
}
|
|
162
|
+
const packageFile = (0, import_path.resolve)(nodeModulesPath, packageName, "package.json");
|
|
159
163
|
if (!await import_fs_extra.default.exists(packageFile)) {
|
|
160
164
|
throw new Error(`Cannot find plugin '${nameOrPkg}'`);
|
|
161
165
|
}
|
|
@@ -297,8 +301,8 @@ const _PluginManager = class _PluginManager {
|
|
|
297
301
|
}
|
|
298
302
|
/* istanbul ignore next -- @preserve */
|
|
299
303
|
async create(pluginName, options) {
|
|
300
|
-
const createPlugin = /* @__PURE__ */ __name(async (
|
|
301
|
-
const pluginDir = (0, import_path.resolve)(process.cwd(), "packages/plugins",
|
|
304
|
+
const createPlugin = /* @__PURE__ */ __name(async (name) => {
|
|
305
|
+
const pluginDir = (0, import_path.resolve)(process.cwd(), "packages/plugins", name);
|
|
302
306
|
if (options == null ? void 0 : options.forceRecreate) {
|
|
303
307
|
await import_fs_extra.default.rm(pluginDir, { recursive: true, force: true });
|
|
304
308
|
}
|
|
@@ -307,21 +311,13 @@ const _PluginManager = class _PluginManager {
|
|
|
307
311
|
cwd: process.cwd(),
|
|
308
312
|
args: {},
|
|
309
313
|
context: {
|
|
310
|
-
name
|
|
314
|
+
name
|
|
311
315
|
}
|
|
312
316
|
});
|
|
313
317
|
await generator.run();
|
|
314
318
|
}, "createPlugin");
|
|
315
319
|
await createPlugin(pluginName);
|
|
316
320
|
this.app.log.info("attempt to add the plugin to the app");
|
|
317
|
-
const { name, packageName } = await _PluginManager.parseName(pluginName);
|
|
318
|
-
const json = await _PluginManager.getPackageJson(packageName);
|
|
319
|
-
this.app.log.info(`add plugin [${packageName}]`, {
|
|
320
|
-
name,
|
|
321
|
-
packageName,
|
|
322
|
-
version: json.version
|
|
323
|
-
});
|
|
324
|
-
await (0, import_helper.tsxRerunning)();
|
|
325
321
|
}
|
|
326
322
|
async addOrThrow(plugin, options = {}, insert = false, isUpgrade = false) {
|
|
327
323
|
if (!isUpgrade && this.has(plugin)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.36",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"@koa/cors": "^5.0.0",
|
|
11
11
|
"@koa/multer": "^3.1.0",
|
|
12
12
|
"@koa/router": "^13.1.0",
|
|
13
|
-
"@nocobase/acl": "2.1.0-beta.
|
|
14
|
-
"@nocobase/actions": "2.1.0-beta.
|
|
15
|
-
"@nocobase/ai": "2.1.0-beta.
|
|
16
|
-
"@nocobase/auth": "2.1.0-beta.
|
|
17
|
-
"@nocobase/cache": "2.1.0-beta.
|
|
18
|
-
"@nocobase/data-source-manager": "2.1.0-beta.
|
|
19
|
-
"@nocobase/database": "2.1.0-beta.
|
|
20
|
-
"@nocobase/evaluators": "2.1.0-beta.
|
|
21
|
-
"@nocobase/lock-manager": "2.1.0-beta.
|
|
22
|
-
"@nocobase/logger": "2.1.0-beta.
|
|
23
|
-
"@nocobase/resourcer": "2.1.0-beta.
|
|
24
|
-
"@nocobase/sdk": "2.1.0-beta.
|
|
25
|
-
"@nocobase/snowflake-id": "2.1.0-beta.
|
|
26
|
-
"@nocobase/telemetry": "2.1.0-beta.
|
|
27
|
-
"@nocobase/utils": "2.1.0-beta.
|
|
13
|
+
"@nocobase/acl": "2.1.0-beta.36",
|
|
14
|
+
"@nocobase/actions": "2.1.0-beta.36",
|
|
15
|
+
"@nocobase/ai": "2.1.0-beta.36",
|
|
16
|
+
"@nocobase/auth": "2.1.0-beta.36",
|
|
17
|
+
"@nocobase/cache": "2.1.0-beta.36",
|
|
18
|
+
"@nocobase/data-source-manager": "2.1.0-beta.36",
|
|
19
|
+
"@nocobase/database": "2.1.0-beta.36",
|
|
20
|
+
"@nocobase/evaluators": "2.1.0-beta.36",
|
|
21
|
+
"@nocobase/lock-manager": "2.1.0-beta.36",
|
|
22
|
+
"@nocobase/logger": "2.1.0-beta.36",
|
|
23
|
+
"@nocobase/resourcer": "2.1.0-beta.36",
|
|
24
|
+
"@nocobase/sdk": "2.1.0-beta.36",
|
|
25
|
+
"@nocobase/snowflake-id": "2.1.0-beta.36",
|
|
26
|
+
"@nocobase/telemetry": "2.1.0-beta.36",
|
|
27
|
+
"@nocobase/utils": "2.1.0-beta.36",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/serve-handler": "^6.1.1",
|
|
62
62
|
"@types/ws": "^8.5.5"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "397d45c744f6eb48b3a0cd785c87cbf1257c3513"
|
|
65
65
|
}
|