@nocobase/server 2.1.0-alpha.14 → 2.1.0-alpha.15

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.
@@ -32,9 +32,39 @@ __export(pm_exports, {
32
32
  module.exports = __toCommonJS(pm_exports);
33
33
  var import_app_supervisor = require("../app-supervisor");
34
34
  var import_plugin_command_error = require("../errors/plugin-command-error");
35
+ var import_plugin_manager = require("../plugin-manager");
36
+ var import_findPackageNames = require("../plugin-manager/findPackageNames");
35
37
  /* istanbul ignore file -- @preserve */
36
38
  var pm_default = /* @__PURE__ */ __name((app) => {
37
39
  const pm = app.command("pm");
40
+ pm.command("list").action(async () => {
41
+ const plugins1 = await (0, import_findPackageNames.findBuiltInPlugins)();
42
+ const plugins2 = await (0, import_findPackageNames.findLocalPlugins)();
43
+ let enabledPlugins = [];
44
+ try {
45
+ enabledPlugins = (await app.pm.repository.find({
46
+ filter: {
47
+ enabled: true
48
+ }
49
+ })).map((item) => item.packageName);
50
+ } catch (error) {
51
+ }
52
+ const items = await Promise.all(
53
+ [...plugins1, ...plugins2].map(async (name) => {
54
+ const item = await import_plugin_manager.PluginManager.parseName(name);
55
+ const json = await import_plugin_manager.PluginManager.getPackageJson(item.packageName);
56
+ return {
57
+ displayName: json.displayName || name,
58
+ packageName: item.packageName,
59
+ enabled: enabledPlugins.includes(item.packageName),
60
+ description: json.description
61
+ };
62
+ })
63
+ );
64
+ console.log("--- BEGIN_PLUGIN_LIST_JSON ---");
65
+ console.log(JSON.stringify(items));
66
+ console.log("--- END_PLUGIN_LIST_JSON ---");
67
+ });
38
68
  pm.command("create").argument("plugin").option("--force-recreate").action(async (plugin, options) => {
39
69
  await app.pm.create(plugin, options);
40
70
  });
@@ -13,7 +13,6 @@ import Application from '../application';
13
13
  import { Plugin } from '../plugin';
14
14
  import { PluginManagerRepository } from './plugin-manager-repository';
15
15
  import { PluginData } from './types';
16
- import { checkAndGetCompatible } from './utils';
17
16
  export declare const sleep: (timeout?: number) => Promise<unknown>;
18
17
  export interface PluginManagerOptions {
19
18
  app: Application;
@@ -29,7 +28,12 @@ export declare class AddPresetError extends Error {
29
28
  }
30
29
  export declare class PluginManager {
31
30
  options: PluginManagerOptions;
32
- static checkAndGetCompatible: typeof checkAndGetCompatible;
31
+ private static compatibleCache;
32
+ private static compatiblePending;
33
+ static checkAndGetCompatible(packageName: string): Promise<{
34
+ isCompatible: boolean;
35
+ depsCompatible: import("./utils").DepCompatible[];
36
+ }>;
33
37
  /**
34
38
  * @internal
35
39
  */
@@ -101,6 +101,23 @@ const _PluginManager = class _PluginManager {
101
101
  });
102
102
  this.app.resourceManager.use(import_middleware.uploadMiddleware, { tag: "upload", after: "acl" });
103
103
  }
104
+ static async checkAndGetCompatible(packageName) {
105
+ if (this.compatibleCache.has(packageName)) {
106
+ return this.compatibleCache.get(packageName);
107
+ }
108
+ const pending = this.compatiblePending.get(packageName);
109
+ if (pending) {
110
+ return pending;
111
+ }
112
+ const task = (0, import_utils2.checkAndGetCompatible)(packageName).then((compatible) => {
113
+ this.compatibleCache.set(packageName, compatible);
114
+ return compatible;
115
+ }).finally(() => {
116
+ this.compatiblePending.delete(packageName);
117
+ });
118
+ this.compatiblePending.set(packageName, task);
119
+ return task;
120
+ }
104
121
  /**
105
122
  * @internal
106
123
  */
@@ -1108,7 +1125,8 @@ const _PluginManager = class _PluginManager {
1108
1125
  }
1109
1126
  };
1110
1127
  __name(_PluginManager, "PluginManager");
1111
- __publicField(_PluginManager, "checkAndGetCompatible", import_utils2.checkAndGetCompatible);
1128
+ __publicField(_PluginManager, "compatibleCache", /* @__PURE__ */ new Map());
1129
+ __publicField(_PluginManager, "compatiblePending", /* @__PURE__ */ new Map());
1112
1130
  __publicField(_PluginManager, "parsedNames", {});
1113
1131
  let PluginManager = _PluginManager;
1114
1132
  var plugin_manager_default = PluginManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "2.1.0-alpha.14",
3
+ "version": "2.1.0-alpha.15",
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-alpha.14",
14
- "@nocobase/actions": "2.1.0-alpha.14",
15
- "@nocobase/ai": "2.1.0-alpha.14",
16
- "@nocobase/auth": "2.1.0-alpha.14",
17
- "@nocobase/cache": "2.1.0-alpha.14",
18
- "@nocobase/data-source-manager": "2.1.0-alpha.14",
19
- "@nocobase/database": "2.1.0-alpha.14",
20
- "@nocobase/evaluators": "2.1.0-alpha.14",
21
- "@nocobase/lock-manager": "2.1.0-alpha.14",
22
- "@nocobase/logger": "2.1.0-alpha.14",
23
- "@nocobase/resourcer": "2.1.0-alpha.14",
24
- "@nocobase/sdk": "2.1.0-alpha.14",
25
- "@nocobase/snowflake-id": "2.1.0-alpha.14",
26
- "@nocobase/telemetry": "2.1.0-alpha.14",
27
- "@nocobase/utils": "2.1.0-alpha.14",
13
+ "@nocobase/acl": "2.1.0-alpha.15",
14
+ "@nocobase/actions": "2.1.0-alpha.15",
15
+ "@nocobase/ai": "2.1.0-alpha.15",
16
+ "@nocobase/auth": "2.1.0-alpha.15",
17
+ "@nocobase/cache": "2.1.0-alpha.15",
18
+ "@nocobase/data-source-manager": "2.1.0-alpha.15",
19
+ "@nocobase/database": "2.1.0-alpha.15",
20
+ "@nocobase/evaluators": "2.1.0-alpha.15",
21
+ "@nocobase/lock-manager": "2.1.0-alpha.15",
22
+ "@nocobase/logger": "2.1.0-alpha.15",
23
+ "@nocobase/resourcer": "2.1.0-alpha.15",
24
+ "@nocobase/sdk": "2.1.0-alpha.15",
25
+ "@nocobase/snowflake-id": "2.1.0-alpha.15",
26
+ "@nocobase/telemetry": "2.1.0-alpha.15",
27
+ "@nocobase/utils": "2.1.0-alpha.15",
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": "d8735b541de0ff9557bba704de49c799b4962672"
64
+ "gitHead": "7c86e75b0af4b9f532c8ebf5ef96a7423b0ab60e"
65
65
  }