@nocobase/server 1.4.0-beta.4 → 1.4.0-beta.6

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.
@@ -69,6 +69,9 @@ var pm_default = /* @__PURE__ */ __name((app) => {
69
69
  try {
70
70
  await app.pm.enable(plugins);
71
71
  } catch (error) {
72
+ await app.tryReloadOrRestart({
73
+ recover: true
74
+ });
72
75
  throw new import_plugin_command_error.PluginCommandError(`Failed to enable plugin`, { cause: error });
73
76
  }
74
77
  });
@@ -119,7 +119,8 @@ var resource_default = {
119
119
  if (!filterByTk) {
120
120
  ctx.throw(400, "plugin name invalid");
121
121
  }
122
- app.runAsCLI(["pm", "enable", filterByTk], { from: "user" });
122
+ const keys = Array.isArray(filterByTk) ? filterByTk : [filterByTk];
123
+ app.runAsCLI(["pm", "enable", ...keys], { from: "user" });
123
124
  ctx.body = filterByTk;
124
125
  await next();
125
126
  },
@@ -32,6 +32,7 @@ export declare class PluginManagerRepository extends Repository {
32
32
  * @deprecated
33
33
  */
34
34
  disable(name: string | string[]): Promise<string[]>;
35
- getItems(): Promise<any>;
35
+ sort(names: string[]): Promise<string[]>;
36
+ getItems(): Promise<any[]>;
36
37
  init(): Promise<void>;
37
38
  }
@@ -40,6 +40,7 @@ __export(plugin_manager_repository_exports, {
40
40
  PluginManagerRepository: () => PluginManagerRepository
41
41
  });
42
42
  module.exports = __toCommonJS(plugin_manager_repository_exports);
43
+ var import_topo = __toESM(require("@hapi/topo"));
43
44
  var import_database = require("@nocobase/database");
44
45
  var import_lodash = __toESM(require("lodash"));
45
46
  var import_plugin_manager = require("./plugin-manager");
@@ -140,17 +141,44 @@ const _PluginManagerRepository = class _PluginManagerRepository extends import_d
140
141
  });
141
142
  return pluginNames;
142
143
  }
144
+ async sort(names) {
145
+ const pluginNames = import_lodash.default.castArray(names);
146
+ if (pluginNames.length === 1) {
147
+ return pluginNames;
148
+ }
149
+ const sorter = new import_topo.default.Sorter();
150
+ for (const pluginName of pluginNames) {
151
+ const packageJson = await import_plugin_manager.PluginManager.getPackageJson(pluginName);
152
+ const peerDependencies = Object.keys((packageJson == null ? void 0 : packageJson.peerDependencies) || {});
153
+ sorter.add(pluginName, { after: peerDependencies, group: (packageJson == null ? void 0 : packageJson.packageName) || pluginName });
154
+ }
155
+ return sorter.nodes;
156
+ }
143
157
  async getItems() {
144
158
  const exists = await this.collection.existsInDb();
145
159
  if (!exists) {
146
160
  return [];
147
161
  }
148
- return await this.find({
162
+ const items = await this.find({
149
163
  sort: "id",
150
164
  filter: {
151
165
  enabled: true
152
166
  }
153
167
  });
168
+ const sortedItems = [];
169
+ const map = {};
170
+ for (const item of items) {
171
+ if (item.packageName) {
172
+ map[item.packageName] = item;
173
+ } else {
174
+ sortedItems.push(item);
175
+ }
176
+ }
177
+ const names = await this.sort(Object.keys(map));
178
+ for (const name of names) {
179
+ sortedItems.push(map[name]);
180
+ }
181
+ return sortedItems;
154
182
  }
155
183
  async init() {
156
184
  const items = await this.getItems();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.4.0-beta.4",
3
+ "version": "1.4.0-beta.6",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,18 +10,18 @@
10
10
  "@koa/cors": "^3.1.0",
11
11
  "@koa/multer": "^3.0.2",
12
12
  "@koa/router": "^9.4.0",
13
- "@nocobase/acl": "1.4.0-beta.4",
14
- "@nocobase/actions": "1.4.0-beta.4",
15
- "@nocobase/auth": "1.4.0-beta.4",
16
- "@nocobase/cache": "1.4.0-beta.4",
17
- "@nocobase/data-source-manager": "1.4.0-beta.4",
18
- "@nocobase/database": "1.4.0-beta.4",
19
- "@nocobase/evaluators": "1.4.0-beta.4",
20
- "@nocobase/logger": "1.4.0-beta.4",
21
- "@nocobase/resourcer": "1.4.0-beta.4",
22
- "@nocobase/sdk": "1.4.0-beta.4",
23
- "@nocobase/telemetry": "1.4.0-beta.4",
24
- "@nocobase/utils": "1.4.0-beta.4",
13
+ "@nocobase/acl": "1.4.0-beta.6",
14
+ "@nocobase/actions": "1.4.0-beta.6",
15
+ "@nocobase/auth": "1.4.0-beta.6",
16
+ "@nocobase/cache": "1.4.0-beta.6",
17
+ "@nocobase/data-source-manager": "1.4.0-beta.6",
18
+ "@nocobase/database": "1.4.0-beta.6",
19
+ "@nocobase/evaluators": "1.4.0-beta.6",
20
+ "@nocobase/logger": "1.4.0-beta.6",
21
+ "@nocobase/resourcer": "1.4.0-beta.6",
22
+ "@nocobase/sdk": "1.4.0-beta.6",
23
+ "@nocobase/telemetry": "1.4.0-beta.6",
24
+ "@nocobase/utils": "1.4.0-beta.6",
25
25
  "@types/decompress": "4.2.7",
26
26
  "@types/ini": "^1.3.31",
27
27
  "@types/koa-send": "^4.1.3",
@@ -54,5 +54,5 @@
54
54
  "@types/serve-handler": "^6.1.1",
55
55
  "@types/ws": "^8.5.5"
56
56
  },
57
- "gitHead": "66efe58d0b631ffe237955a04a006c29d5d5aef0"
57
+ "gitHead": "a313b10180415ed01c954ea2ee63968c9d8ec4f4"
58
58
  }