tego 1.3.26 → 1.3.27

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.
@@ -1,12 +1,12 @@
1
1
  import { Plugin } from '@tachybase/server';
2
2
  export declare class PluginPresets extends Plugin {
3
- #private;
4
- get builtInPlugins(): string[];
5
- get localPlugins(): (string | boolean)[][];
6
3
  splitNames(name: string): string[];
7
4
  getBuiltInPlugins(): string[];
8
5
  parseNames(plugins: string): string[][];
9
- getLocalPlugins(): any[];
6
+ getExternalPlugins(): {
7
+ installedPlugins: string[];
8
+ disabledPlugins: string[];
9
+ };
10
10
  getPackageJson(name: any): Promise<any>;
11
11
  allPlugins(): Promise<any[]>;
12
12
  getPluginToBeUpgraded(): Promise<any[]>;
@@ -1,12 +1,7 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __typeError = (msg) => {
8
- throw TypeError(msg);
9
- };
10
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
6
  var __export = (target, all) => {
12
7
  for (var name in all)
@@ -20,18 +15,7 @@ var __copyProps = (to, from, except, desc) => {
20
15
  }
21
16
  return to;
22
17
  };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
19
  var plugin_presets_exports = {};
36
20
  __export(plugin_presets_exports, {
37
21
  PluginPresets: () => PluginPresets,
@@ -39,142 +23,34 @@ __export(plugin_presets_exports, {
39
23
  });
40
24
  module.exports = __toCommonJS(plugin_presets_exports);
41
25
  var import_server = require("@tachybase/server");
42
- var import_lodash = __toESM(require("lodash"));
43
- var _builtInPlugins, _localPlugins;
44
26
  const _PluginPresets = class _PluginPresets extends import_server.Plugin {
45
- constructor() {
46
- super(...arguments);
47
- __privateAdd(this, _builtInPlugins, [
48
- "acl",
49
- "app-info",
50
- "auth",
51
- "backup",
52
- "cloud-component",
53
- "collection",
54
- "cron",
55
- "data-source",
56
- "error-handler",
57
- "event-source",
58
- "file",
59
- "workflow",
60
- "message",
61
- "pdf",
62
- "ui-schema",
63
- "user",
64
- "web",
65
- "worker-thread",
66
- "env-secrets"
67
- ]);
68
- __privateAdd(this, _localPlugins, [
69
- // [name, version, enabled]
70
- ["action-bulk-edit", "0.22.7", true],
71
- ["action-bulk-update", "0.22.7", true],
72
- ["action-custom-request", "0.22.7", true],
73
- ["action-duplicate", "0.22.7", true],
74
- ["action-export", "0.22.7", true],
75
- ["action-import", "0.22.7", true],
76
- ["action-print", "0.22.7", true],
77
- ["block-calendar", "0.22.7", true],
78
- ["block-charts", "0.22.7", true],
79
- ["block-gantt", "0.22.7", true],
80
- ["block-kanban", "0.22.7", true],
81
- ["block-presentation", "0.22.7", true],
82
- ["field-china-region", "0.22.7", true],
83
- ["field-formula", "0.22.7", true],
84
- ["field-sequence", "0.22.7", true],
85
- ["field-encryption", "0.23.8", true],
86
- ["log-viewer", "0.22.67", true],
87
- ["otp", "0.22.67", true],
88
- ["instrumentation", "1.0.18", true],
89
- ["full-text-search", "0.23.24", true],
90
- ["password-policy", "0.23.65", true],
91
- ["auth-pages", "0.23.65", true],
92
- ["manual-notification", "1.0.4", true],
93
- ["auth-main-app", "1.3.17", true],
94
- // default disable
95
- ["adapter-bullmq", "0.21.76", false],
96
- ["adapter-red-node", "0.22.8", false],
97
- ["adapter-remix", "0.22.9", false],
98
- ["api-keys", "0.10.1", false],
99
- ["audit-logs", "0.22.7", false],
100
- ["auth-cas", "0.13.0", false],
101
- ["auth-dingtalk", "0.21.76", false],
102
- ["auth-lark", "0.22.42", false],
103
- ["auth-oidc", "0.9.2", false],
104
- ["auth-saml", "0.8.1", false],
105
- ["auth-sms", "0.10.0", false],
106
- ["auth-wechat", "0.21.89", false],
107
- ["auth-wecom", "0.21.76", false],
108
- ["block-comments", "0.22.6", false],
109
- ["block-map", "0.8.1", false],
110
- ["block-step-form", "1.0.0", false],
111
- ["data-source-common", "0.22.5", false],
112
- ["demos-game-runesweeper", "0.22.20", false],
113
- ["devtools", "0.22.82", false],
114
- ["field-markdown-vditor", "0.22.6", false],
115
- ["field-snapshot", "0.8.1", false],
116
- ["hera", "0.22.6", false],
117
- ["i18n-editor", "0.11.1", false],
118
- ["multi-app", "0.7.0", false],
119
- ["multi-app-share-collection", "0.9.2", false],
120
- ["online-user", "0.22.7", false],
121
- ["simple-cms", "0.22.6", false],
122
- ["sub-accounts", "0.22.56", false],
123
- ["theme-editor", "0.11.1", false],
124
- ["workflow-approval", "0.22.37", false],
125
- ["ai-chat", "0.23.8", false],
126
- ["department", "0.23.22", false],
127
- ["workflow-analysis", "0.23.41", false],
128
- ["api-logs", "0.23.49", false],
129
- ["ocr-convert", "1.0.12", false],
130
- ["text-copy", "1.2.11", false],
131
- ["user-manual-feishu", "1.3.21", false]
132
- ]);
133
- }
134
- get builtInPlugins() {
135
- return __privateGet(this, _builtInPlugins);
136
- }
137
- get localPlugins() {
138
- return __privateGet(this, _localPlugins);
139
- }
140
27
  splitNames(name) {
141
28
  return (name || "").split(",").filter(Boolean);
142
29
  }
143
30
  getBuiltInPlugins() {
144
- const { PRESETS_CORE_PLUGINS } = process.env;
145
- const [addPlugins, removedPlugins] = this.parseNames(PRESETS_CORE_PLUGINS);
146
- return import_lodash.default.uniq(this.builtInPlugins.concat(addPlugins).filter((name) => !removedPlugins.includes(name)));
31
+ const { PRESETS_BULTIN_PLUGINS } = process.env;
32
+ if (!PRESETS_BULTIN_PLUGINS) {
33
+ throw new Error(
34
+ "PRESETS_BUILTIN_PLUGINS is not defined! Please refer to the .env.example file for the correct configuration."
35
+ );
36
+ }
37
+ const [installedPlugins] = this.parseNames(PRESETS_BULTIN_PLUGINS);
38
+ return installedPlugins;
147
39
  }
148
40
  parseNames(plugins) {
149
- const addPlugins = this.splitNames(plugins).filter((name) => !name.startsWith("!") && !name.startsWith("|"));
150
- const removedPlugins = this.splitNames(plugins).filter((name) => name.startsWith("!")).map((name) => name.slice(1));
151
- const addDisabledPlugins = this.splitNames(plugins).filter((name) => name.startsWith("|")).map((name) => name.slice(1));
152
- return [addPlugins, removedPlugins, addDisabledPlugins];
153
- }
154
- getLocalPlugins() {
155
- const { PRESETS_LOCAL_PLUGINS } = process.env;
156
- let plugins = [].concat(this.localPlugins);
157
- const [addPlugins, removedPlugins, addDisabledPlugins] = this.parseNames(PRESETS_LOCAL_PLUGINS);
158
- addPlugins.forEach((plugin) => {
159
- const found = plugins.find((p) => p[0] === plugin);
160
- if (found) {
161
- found[2] = true;
162
- } else {
163
- plugins.push([plugin, "0.0.0", true]);
164
- }
165
- });
166
- removedPlugins.forEach((plugin) => {
167
- plugins = plugins.filter((p) => p[0] !== plugin);
168
- });
169
- addDisabledPlugins.forEach((plugin) => {
170
- const found = plugins.find((p) => p[0] === plugin);
171
- if (found) {
172
- found[2] = false;
173
- } else {
174
- plugins.push([plugin, "0.0.0", false]);
175
- }
176
- });
177
- return plugins;
41
+ const installedPlugins = this.splitNames(plugins).filter((name) => !name.startsWith("!"));
42
+ const disabledPlugins = this.splitNames(plugins).filter((name) => name.startsWith("!")).map((name) => name.slice(1));
43
+ return [installedPlugins, disabledPlugins];
44
+ }
45
+ getExternalPlugins() {
46
+ const { PRESETS_EXTERNAL_PLUGINS } = process.env;
47
+ if (!PRESETS_EXTERNAL_PLUGINS) {
48
+ throw new Error(
49
+ "PRESETS_EXTERNAL_PLUGINS is not defined! Please refer to the .env.example file for the correct configuration."
50
+ );
51
+ }
52
+ const [installedPlugins, disabledPlugins] = this.parseNames(PRESETS_EXTERNAL_PLUGINS);
53
+ return { installedPlugins, disabledPlugins };
178
54
  }
179
55
  async getPackageJson(name) {
180
56
  let packageName = name;
@@ -200,12 +76,21 @@ const _PluginPresets = class _PluginPresets extends import_server.Plugin {
200
76
  })
201
77
  )).concat(
202
78
  await Promise.all(
203
- this.getLocalPlugins().map(async (plugin) => {
204
- const name = plugin[0];
205
- const enabled = plugin[2];
79
+ this.getExternalPlugins().installedPlugins.map(async (name) => {
206
80
  const packageJson = await this.getPackageJson(name);
207
- return { name, packageName: packageJson.name, version: packageJson.version, enabled };
208
- })
81
+ return { name, packageName: packageJson.name, version: packageJson.version, enabled: true, builtIn: false };
82
+ }).concat(
83
+ this.getExternalPlugins().disabledPlugins.map(async (name) => {
84
+ const packageJson = await this.getPackageJson(name);
85
+ return {
86
+ name,
87
+ packageName: packageJson.name,
88
+ version: packageJson.version,
89
+ enabled: false,
90
+ builtIn: false
91
+ };
92
+ })
93
+ )
209
94
  )
210
95
  );
211
96
  }
@@ -224,15 +109,27 @@ const _PluginPresets = class _PluginPresets extends import_server.Plugin {
224
109
  };
225
110
  })
226
111
  );
227
- for (const plugin of this.getLocalPlugins()) {
228
- if (plugin[1]) {
229
- if (!items.includes(plugin[0]) && await this.app.version.satisfies(`>${plugin[1]}`)) {
230
- continue;
231
- }
112
+ for (const name of this.getExternalPlugins().installedPlugins) {
113
+ const packageJson = await this.getPackageJson(name);
114
+ if (items.includes(name)) {
115
+ plugins.push({
116
+ name,
117
+ packageName: packageJson.name,
118
+ version: packageJson.version
119
+ });
120
+ } else {
121
+ plugins.push({
122
+ name,
123
+ packageName: packageJson.name,
124
+ version: packageJson.version,
125
+ enabled: true,
126
+ builtIn: false
127
+ });
232
128
  }
233
- const name = plugin[0];
129
+ }
130
+ for (const name of this.getExternalPlugins().disabledPlugins) {
234
131
  const packageJson = await this.getPackageJson(name);
235
- if (items.includes(plugin[0])) {
132
+ if (items.includes(name)) {
236
133
  plugins.push({
237
134
  name,
238
135
  packageName: packageJson.name,
@@ -243,7 +140,7 @@ const _PluginPresets = class _PluginPresets extends import_server.Plugin {
243
140
  name,
244
141
  packageName: packageJson.name,
245
142
  version: packageJson.version,
246
- enabled: plugin[2],
143
+ enabled: false,
247
144
  builtIn: false
248
145
  });
249
146
  }
@@ -330,8 +227,6 @@ const _PluginPresets = class _PluginPresets extends import_server.Plugin {
330
227
  });
331
228
  }
332
229
  };
333
- _builtInPlugins = new WeakMap();
334
- _localPlugins = new WeakMap();
335
230
  __name(_PluginPresets, "PluginPresets");
336
231
  let PluginPresets = _PluginPresets;
337
232
  var plugin_presets_default = PluginPresets;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tego",
3
- "version": "1.3.26",
3
+ "version": "1.3.27",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "tego",
@@ -50,20 +50,20 @@
50
50
  "umzug": "3.8.2",
51
51
  "winston": "3.17.0",
52
52
  "winston-daily-rotate-file": "^5.0.0",
53
- "@tachybase/actions": "1.3.26",
54
- "@tachybase/auth": "1.3.26",
55
- "@tachybase/data-source": "1.3.26",
56
- "@tachybase/database": "1.3.26",
57
- "@tachybase/evaluators": "1.3.26",
58
- "@tachybase/acl": "1.3.26",
59
- "@tachybase/globals": "1.3.26",
60
- "@tachybase/logger": "1.3.26",
61
- "@tachybase/cache": "1.3.26",
62
- "@tachybase/loader": "1.3.26",
63
- "@tachybase/resourcer": "1.3.26",
64
- "@tachybase/schema": "1.3.26",
65
- "@tachybase/server": "1.3.26",
66
- "@tachybase/utils": "1.3.26"
53
+ "@tachybase/auth": "1.3.27",
54
+ "@tachybase/acl": "1.3.27",
55
+ "@tachybase/actions": "1.3.27",
56
+ "@tachybase/cache": "1.3.27",
57
+ "@tachybase/data-source": "1.3.27",
58
+ "@tachybase/database": "1.3.27",
59
+ "@tachybase/evaluators": "1.3.27",
60
+ "@tachybase/globals": "1.3.27",
61
+ "@tachybase/logger": "1.3.27",
62
+ "@tachybase/loader": "1.3.27",
63
+ "@tachybase/schema": "1.3.27",
64
+ "@tachybase/server": "1.3.27",
65
+ "@tachybase/utils": "1.3.27",
66
+ "@tachybase/resourcer": "1.3.27"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/lodash": "4.17.20",
@@ -60,10 +60,16 @@ ENCRYPTION_FIELD_KEY=
60
60
 
61
61
  ##### PRESETS #####
62
62
 
63
- # 单写名称:添加指定插件且默认启用 名称前加!:移除指定插件 名称前加|:添加指定插件但默认禁用
64
- # PRESETS_CORE_PLUGINS=api-doc,api-keys,!messages
65
- PRESETS_LOCAL_PLUGINS=!adapter-bullmq,!adapter-red-node,!adapter-remix,!api-keys,!audit-logs,!auth-cas,!auth-dingtalk,!auth-lark,!auth-oidc,!auth-saml,!auth-sms,!auth-wechat,!auth-wecom,!block-comments,!block-map,!block-step-form,!data-source-common,!demos-game-runesweeper,!devtools,!field-markdown-vditor,!field-snapshot,!hera,!i18n-editor,!multi-app,!multi-app-share-collection,!online-user,!simple-cms,!sub-accounts,!theme-editor,!workflow-approval,!ai-chat,!department,!workflow-analysis,!api-logs,!ocr-convert,!text-copy
66
- # 运行时插件,插件不写入数据库,且优先加载
63
+ # Built-in plugins: Enabled by default.
64
+ # When the plugin list is updated, any plugins no longer in the list will be removed,(TODO)
65
+ # and newly added plugins will be included to stay aligned with the latest configuration.
66
+ PRESETS_BULTIN_PLUGINS=acl,app-info,auth,backup,cloud-component,collection,cron,data-source,error-handler,event-source,file,workflow,message,pdf,ui-schema,user,web,worker-thread,env-secrets
67
+ # External plugins: Enabled by default.
68
+ # Prefixing a plugin name with ! marks it as disabled.
69
+ # When the plugin list is updated, only newly added plugins will be included;
70
+ # existing plugin states will remain unchanged.
71
+ PRESETS_EXTERNAL_PLUGINS=action-bulk-edit,action-bulk-update,action-custom-request,action-duplicate,action-export,action-import,action-print,block-calendar,block-charts,block-gantt,block-kanban,block-presentation,field-china-region,field-formula,field-sequence,field-encryption,log-viewer,otp,instrumentation,full-text-search,password-policy,auth-pages,manual-notification,auth-main-app,!adapter-bullmq,!adapter-red-node,!adapter-remix,!api-keys,!audit-logs,!auth-cas,!auth-dingtalk,!auth-lark,!auth-oidc,!auth-saml,!auth-sms,!auth-wechat,!auth-wecom,!block-comments,!block-map,!block-step-form,!data-source-common,!demos-game-runesweeper,!devtools,!field-markdown-vditor,!field-snapshot,!hera,!i18n-editor,!multi-app,!multi-app-share-collection,!online-user,!simple-cms,!sub-accounts,!theme-editor,!workflow-approval,!ai-chat,!department,!workflow-analysis,!api-logs,!ocr-convert,!text-copy,!user-manual-feishu
72
+ # Runtime plugins: Not persisted to the database and are loaded with the highest priority among all plugins.
67
73
  # RUNTIME_PLUGINS=
68
74
 
69
75
  # 主应用工作线程默认数量
@@ -3,153 +3,40 @@ import { Plugin, PluginManager } from '@tachybase/server';
3
3
  import _ from 'lodash';
4
4
 
5
5
  export class PluginPresets extends Plugin {
6
- #builtInPlugins = [
7
- 'acl',
8
- 'app-info',
9
- 'auth',
10
- 'backup',
11
- 'cloud-component',
12
- 'collection',
13
- 'cron',
14
- 'data-source',
15
- 'error-handler',
16
- 'event-source',
17
- 'file',
18
- 'workflow',
19
- 'message',
20
- 'pdf',
21
- 'ui-schema',
22
- 'user',
23
- 'web',
24
- 'worker-thread',
25
- 'env-secrets',
26
- ];
27
-
28
- get builtInPlugins() {
29
- return this.#builtInPlugins;
30
- }
31
-
32
- #localPlugins = [
33
- // [name, version, enabled]
34
- ['action-bulk-edit', '0.22.7', true],
35
- ['action-bulk-update', '0.22.7', true],
36
- ['action-custom-request', '0.22.7', true],
37
- ['action-duplicate', '0.22.7', true],
38
- ['action-export', '0.22.7', true],
39
- ['action-import', '0.22.7', true],
40
- ['action-print', '0.22.7', true],
41
- ['block-calendar', '0.22.7', true],
42
- ['block-charts', '0.22.7', true],
43
- ['block-gantt', '0.22.7', true],
44
- ['block-kanban', '0.22.7', true],
45
- ['block-presentation', '0.22.7', true],
46
- ['field-china-region', '0.22.7', true],
47
- ['field-formula', '0.22.7', true],
48
- ['field-sequence', '0.22.7', true],
49
- ['field-encryption', '0.23.8', true],
50
- ['log-viewer', '0.22.67', true],
51
- ['otp', '0.22.67', true],
52
- ['instrumentation', '1.0.18', true],
53
- ['full-text-search', '0.23.24', true],
54
- ['password-policy', '0.23.65', true],
55
- ['auth-pages', '0.23.65', true],
56
- ['manual-notification', '1.0.4', true],
57
- ['auth-main-app', '1.3.17', true],
58
- // default disable
59
- ['adapter-bullmq', '0.21.76', false],
60
- ['adapter-red-node', '0.22.8', false],
61
- ['adapter-remix', '0.22.9', false],
62
- ['api-keys', '0.10.1', false],
63
- ['audit-logs', '0.22.7', false],
64
- ['auth-cas', '0.13.0', false],
65
- ['auth-dingtalk', '0.21.76', false],
66
- ['auth-lark', '0.22.42', false],
67
- ['auth-oidc', '0.9.2', false],
68
- ['auth-saml', '0.8.1', false],
69
- ['auth-sms', '0.10.0', false],
70
- ['auth-wechat', '0.21.89', false],
71
- ['auth-wecom', '0.21.76', false],
72
- ['block-comments', '0.22.6', false],
73
- ['block-map', '0.8.1', false],
74
- ['block-step-form', '1.0.0', false],
75
- ['data-source-common', '0.22.5', false],
76
- ['demos-game-runesweeper', '0.22.20', false],
77
- ['devtools', '0.22.82', false],
78
- ['field-markdown-vditor', '0.22.6', false],
79
- ['field-snapshot', '0.8.1', false],
80
- ['hera', '0.22.6', false],
81
- ['i18n-editor', '0.11.1', false],
82
- ['multi-app', '0.7.0', false],
83
- ['multi-app-share-collection', '0.9.2', false],
84
- ['online-user', '0.22.7', false],
85
- ['simple-cms', '0.22.6', false],
86
- ['sub-accounts', '0.22.56', false],
87
- ['theme-editor', '0.11.1', false],
88
- ['workflow-approval', '0.22.37', false],
89
- ['ai-chat', '0.23.8', false],
90
- ['department', '0.23.22', false],
91
- ['workflow-analysis', '0.23.41', false],
92
- ['api-logs', '0.23.49', false],
93
- ['ocr-convert', '1.0.12', false],
94
- ['text-copy', '1.2.11', false],
95
- ['user-manual-feishu', '1.3.21', false],
96
- ];
97
-
98
- get localPlugins() {
99
- return this.#localPlugins;
100
- }
101
-
102
6
  splitNames(name: string) {
103
7
  return (name || '').split(',').filter(Boolean);
104
8
  }
105
9
 
106
10
  getBuiltInPlugins() {
107
- const { PRESETS_CORE_PLUGINS } = process.env;
108
- const [addPlugins, removedPlugins] = this.parseNames(PRESETS_CORE_PLUGINS);
109
- return _.uniq(this.builtInPlugins.concat(addPlugins).filter((name) => !removedPlugins.includes(name)));
11
+ const { PRESETS_BULTIN_PLUGINS } = process.env;
12
+ if (!PRESETS_BULTIN_PLUGINS) {
13
+ throw new Error(
14
+ 'PRESETS_BUILTIN_PLUGINS is not defined! Please refer to the .env.example file for the correct configuration.',
15
+ );
16
+ }
17
+ const [installedPlugins] = this.parseNames(PRESETS_BULTIN_PLUGINS);
18
+ return installedPlugins;
110
19
  }
111
20
 
112
21
  parseNames(plugins: string) {
113
- const addPlugins = this.splitNames(plugins).filter((name) => !name.startsWith('!') && !name.startsWith('|'));
114
- const removedPlugins = this.splitNames(plugins)
22
+ const installedPlugins = this.splitNames(plugins).filter((name) => !name.startsWith('!'));
23
+ const disabledPlugins = this.splitNames(plugins)
115
24
  .filter((name) => name.startsWith('!'))
116
25
  .map((name) => name.slice(1));
117
26
 
118
- const addDisabledPlugins = this.splitNames(plugins)
119
- .filter((name) => name.startsWith('|'))
120
- .map((name) => name.slice(1));
121
-
122
- return [addPlugins, removedPlugins, addDisabledPlugins];
27
+ return [installedPlugins, disabledPlugins];
123
28
  }
124
29
 
125
- getLocalPlugins() {
126
- const { PRESETS_LOCAL_PLUGINS } = process.env;
127
- let plugins = [].concat(this.localPlugins);
128
- const [addPlugins, removedPlugins, addDisabledPlugins] = this.parseNames(PRESETS_LOCAL_PLUGINS);
129
-
130
- addPlugins.forEach((plugin) => {
131
- const found = plugins.find((p) => p[0] === plugin);
132
- if (found) {
133
- found[2] = true;
134
- } else {
135
- plugins.push([plugin, '0.0.0', true]);
136
- }
137
- });
138
-
139
- removedPlugins.forEach((plugin) => {
140
- plugins = plugins.filter((p) => p[0] !== plugin);
141
- });
142
-
143
- addDisabledPlugins.forEach((plugin) => {
144
- const found = plugins.find((p) => p[0] === plugin);
145
- if (found) {
146
- found[2] = false;
147
- } else {
148
- plugins.push([plugin, '0.0.0', false]);
149
- }
150
- });
30
+ getExternalPlugins() {
31
+ const { PRESETS_EXTERNAL_PLUGINS } = process.env;
32
+ if (!PRESETS_EXTERNAL_PLUGINS) {
33
+ throw new Error(
34
+ 'PRESETS_EXTERNAL_PLUGINS is not defined! Please refer to the .env.example file for the correct configuration.',
35
+ );
36
+ }
37
+ const [installedPlugins, disabledPlugins] = this.parseNames(PRESETS_EXTERNAL_PLUGINS);
151
38
 
152
- return plugins;
39
+ return { installedPlugins, disabledPlugins };
153
40
  }
154
41
 
155
42
  async getPackageJson(name) {
@@ -179,12 +66,23 @@ export class PluginPresets extends Plugin {
179
66
  )
180
67
  ).concat(
181
68
  await Promise.all(
182
- this.getLocalPlugins().map(async (plugin) => {
183
- const name = plugin[0];
184
- const enabled = plugin[2];
185
- const packageJson = await this.getPackageJson(name);
186
- return { name, packageName: packageJson.name, version: packageJson.version, enabled };
187
- }),
69
+ this.getExternalPlugins()
70
+ .installedPlugins.map(async (name) => {
71
+ const packageJson = await this.getPackageJson(name);
72
+ return { name, packageName: packageJson.name, version: packageJson.version, enabled: true, builtIn: false };
73
+ })
74
+ .concat(
75
+ this.getExternalPlugins().disabledPlugins.map(async (name) => {
76
+ const packageJson = await this.getPackageJson(name);
77
+ return {
78
+ name,
79
+ packageName: packageJson.name,
80
+ version: packageJson.version,
81
+ enabled: false,
82
+ builtIn: false,
83
+ };
84
+ }),
85
+ ),
188
86
  ),
189
87
  );
190
88
  }
@@ -204,16 +102,27 @@ export class PluginPresets extends Plugin {
204
102
  } as any;
205
103
  }),
206
104
  );
207
- for (const plugin of this.getLocalPlugins()) {
208
- if (plugin[1]) {
209
- // 不在插件列表,并且插件最低版本小于当前应用版本,跳过不处理
210
- if (!items.includes(plugin[0]) && (await this.app.version.satisfies(`>${plugin[1]}`))) {
211
- continue;
212
- }
105
+ for (const name of this.getExternalPlugins().installedPlugins) {
106
+ const packageJson = await this.getPackageJson(name);
107
+ if (items.includes(name)) {
108
+ plugins.push({
109
+ name,
110
+ packageName: packageJson.name,
111
+ version: packageJson.version,
112
+ });
113
+ } else {
114
+ plugins.push({
115
+ name,
116
+ packageName: packageJson.name,
117
+ version: packageJson.version,
118
+ enabled: true,
119
+ builtIn: false,
120
+ });
213
121
  }
214
- const name = plugin[0];
122
+ }
123
+ for (const name of this.getExternalPlugins().disabledPlugins) {
215
124
  const packageJson = await this.getPackageJson(name);
216
- if (items.includes(plugin[0])) {
125
+ if (items.includes(name)) {
217
126
  plugins.push({
218
127
  name,
219
128
  packageName: packageJson.name,
@@ -224,7 +133,7 @@ export class PluginPresets extends Plugin {
224
133
  name,
225
134
  packageName: packageJson.name,
226
135
  version: packageJson.version,
227
- enabled: plugin[2],
136
+ enabled: false,
228
137
  builtIn: false,
229
138
  });
230
139
  }