@nocobase/preset-nocobase 0.7.6-alpha.2 → 0.8.0-alpha.4

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/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Plugin } from '@nocobase/server';
2
- export declare class PresetNocoBase<O = any> extends Plugin {
3
- getName(): string;
2
+ export declare class PresetNocoBase extends Plugin {
3
+ addBuiltInPlugins(): Promise<void>;
4
+ afterAdd(): void;
4
5
  beforeLoad(): void;
5
6
  }
6
7
  export default PresetNocoBase;
package/lib/index.js CHANGED
@@ -15,15 +15,68 @@ function _server() {
15
15
  return data;
16
16
  }
17
17
 
18
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
19
+
20
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
21
+
18
22
  class PresetNocoBase extends _server().Plugin {
19
- getName() {
20
- return this.getPackageName(__dirname);
23
+ addBuiltInPlugins() {
24
+ var _this = this;
25
+
26
+ return _asyncToGenerator(function* () {
27
+ const plugins = ['error-handler', 'collection-manager', 'ui-schema-storage', 'ui-routes-storage', 'file-manager', 'system-settings', 'verification', 'users', 'acl', 'china-region', 'workflow', 'client', 'export', 'import', 'audit-logs'];
28
+ yield _this.app.pm.add(plugins, {
29
+ enabled: true,
30
+ builtIn: true,
31
+ installed: true
32
+ });
33
+ const samples = ['sample-command', 'sample-custom-block', 'sample-custom-page', 'sample-custom-signup-page', 'sample-hello', 'sample-ratelimit', 'sample-shop-actions', 'sample-shop-events', 'sample-shop-i18n', 'sample-shop-modeling'];
34
+ yield _this.app.pm.add(samples, {});
35
+ yield _this.app.reload();
36
+ })();
21
37
  }
22
38
 
23
- beforeLoad() {
24
- this.app.loadPluginConfig(['@nocobase/plugin-error-handler', '@nocobase/plugin-collection-manager', '@nocobase/plugin-ui-schema-storage', '@nocobase/plugin-ui-routes-storage', '@nocobase/plugin-file-manager', '@nocobase/plugin-system-settings', '@nocobase/plugin-verification', '@nocobase/plugin-users', '@nocobase/plugin-acl', '@nocobase/plugin-china-region', '@nocobase/plugin-workflow', '@nocobase/plugin-client', '@nocobase/plugin-export', '@nocobase/plugin-audit-logs']);
39
+ afterAdd() {
40
+ var _this2 = this;
41
+
42
+ this.app.on('beforeLoad', /*#__PURE__*/function () {
43
+ var _ref = _asyncToGenerator(function* (app, options) {
44
+ if ((options === null || options === void 0 ? void 0 : options.method) !== 'upgrade') {
45
+ return;
46
+ }
47
+
48
+ const result = yield _this2.app.version.satisfies('<0.8.0-alpha.1');
49
+
50
+ if (result) {
51
+ const r = yield _this2.db.collectionExistsInDb('applicationPlugins');
52
+
53
+ if (r) {
54
+ yield _this2.db.getRepository('applicationPlugins').destroy({
55
+ truncate: true
56
+ });
57
+ yield _this2.app.reload();
58
+ }
59
+ }
60
+ });
61
+
62
+ return function (_x, _x2) {
63
+ return _ref.apply(this, arguments);
64
+ };
65
+ }());
66
+ this.app.on('beforeUpgrade', /*#__PURE__*/_asyncToGenerator(function* () {
67
+ const result = yield _this2.app.version.satisfies('<0.8.0-alpha.1');
68
+
69
+ if (result) {
70
+ yield _this2.addBuiltInPlugins();
71
+ }
72
+ }));
73
+ this.app.on('beforeInstall', /*#__PURE__*/_asyncToGenerator(function* () {
74
+ yield _this2.addBuiltInPlugins();
75
+ }));
25
76
  }
26
77
 
78
+ beforeLoad() {}
79
+
27
80
  }
28
81
 
29
82
  exports.PresetNocoBase = PresetNocoBase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/preset-nocobase",
3
- "version": "0.7.6-alpha.2",
3
+ "version": "0.8.0-alpha.4",
4
4
  "license": "Apache-2.0",
5
5
  "licenses": [
6
6
  {
@@ -11,26 +11,37 @@
11
11
  "main": "./lib/index.js",
12
12
  "types": "./lib/index.d.ts",
13
13
  "dependencies": {
14
- "@nocobase/plugin-acl": "0.7.6-alpha.2",
15
- "@nocobase/plugin-audit-logs": "0.7.6-alpha.2",
16
- "@nocobase/plugin-china-region": "0.7.6-alpha.2",
17
- "@nocobase/plugin-client": "0.7.6-alpha.2",
18
- "@nocobase/plugin-collection-manager": "0.7.6-alpha.2",
19
- "@nocobase/plugin-error-handler": "0.7.6-alpha.2",
20
- "@nocobase/plugin-export": "0.7.6-alpha.2",
21
- "@nocobase/plugin-file-manager": "0.7.6-alpha.2",
22
- "@nocobase/plugin-system-settings": "0.7.6-alpha.2",
23
- "@nocobase/plugin-ui-routes-storage": "0.7.6-alpha.2",
24
- "@nocobase/plugin-ui-schema-storage": "0.7.6-alpha.2",
25
- "@nocobase/plugin-users": "0.7.6-alpha.2",
26
- "@nocobase/plugin-verification": "0.7.6-alpha.2",
27
- "@nocobase/plugin-workflow": "0.7.6-alpha.2",
28
- "@nocobase/server": "0.7.6-alpha.2"
14
+ "@nocobase/plugin-acl": "0.8.0-alpha.4",
15
+ "@nocobase/plugin-audit-logs": "0.8.0-alpha.4",
16
+ "@nocobase/plugin-china-region": "0.8.0-alpha.4",
17
+ "@nocobase/plugin-client": "0.8.0-alpha.4",
18
+ "@nocobase/plugin-collection-manager": "0.8.0-alpha.4",
19
+ "@nocobase/plugin-error-handler": "0.8.0-alpha.4",
20
+ "@nocobase/plugin-export": "0.8.0-alpha.4",
21
+ "@nocobase/plugin-file-manager": "0.8.0-alpha.4",
22
+ "@nocobase/plugin-import": "0.8.0-alpha.4",
23
+ "@nocobase/plugin-sample-command": "0.8.0-alpha.4",
24
+ "@nocobase/plugin-sample-custom-block": "0.8.0-alpha.4",
25
+ "@nocobase/plugin-sample-custom-page": "0.8.0-alpha.4",
26
+ "@nocobase/plugin-sample-custom-signup-page": "0.8.0-alpha.4",
27
+ "@nocobase/plugin-sample-hello": "0.8.0-alpha.4",
28
+ "@nocobase/plugin-sample-ratelimit": "0.8.0-alpha.4",
29
+ "@nocobase/plugin-sample-shop-actions": "0.8.0-alpha.4",
30
+ "@nocobase/plugin-sample-shop-events": "0.8.0-alpha.4",
31
+ "@nocobase/plugin-sample-shop-i18n": "0.8.0-alpha.4",
32
+ "@nocobase/plugin-sample-shop-modeling": "0.8.0-alpha.4",
33
+ "@nocobase/plugin-system-settings": "0.8.0-alpha.4",
34
+ "@nocobase/plugin-ui-routes-storage": "0.8.0-alpha.4",
35
+ "@nocobase/plugin-ui-schema-storage": "0.8.0-alpha.4",
36
+ "@nocobase/plugin-users": "0.8.0-alpha.4",
37
+ "@nocobase/plugin-verification": "0.8.0-alpha.4",
38
+ "@nocobase/plugin-workflow": "0.8.0-alpha.4",
39
+ "@nocobase/server": "0.8.0-alpha.4"
29
40
  },
30
41
  "repository": {
31
42
  "type": "git",
32
43
  "url": "git+https://github.com/nocobase/nocobase.git",
33
44
  "directory": "packages/presets/nocobase"
34
45
  },
35
- "gitHead": "2cfccff9d3ff14c521bf317fa7ee4efa18444c92"
46
+ "gitHead": "433f068ce4479a53f51d3ceac3f22b710e7bb13e"
36
47
  }
package/src/index.ts CHANGED
@@ -1,28 +1,70 @@
1
1
  import { Plugin } from '@nocobase/server';
2
2
 
3
- export class PresetNocoBase<O = any> extends Plugin {
4
- getName(): string {
5
- return this.getPackageName(__dirname);
3
+ export class PresetNocoBase extends Plugin {
4
+ async addBuiltInPlugins() {
5
+ const plugins = [
6
+ 'error-handler',
7
+ 'collection-manager',
8
+ 'ui-schema-storage',
9
+ 'ui-routes-storage',
10
+ 'file-manager',
11
+ 'system-settings',
12
+ 'verification',
13
+ 'users',
14
+ 'acl',
15
+ 'china-region',
16
+ 'workflow',
17
+ 'client',
18
+ 'export',
19
+ 'import',
20
+ 'audit-logs',
21
+ ];
22
+ await this.app.pm.add(plugins, {
23
+ enabled: true,
24
+ builtIn: true,
25
+ installed: true,
26
+ });
27
+ const samples = [
28
+ 'sample-command',
29
+ 'sample-custom-block',
30
+ 'sample-custom-page',
31
+ 'sample-custom-signup-page',
32
+ 'sample-hello',
33
+ 'sample-ratelimit',
34
+ 'sample-shop-actions',
35
+ 'sample-shop-events',
36
+ 'sample-shop-i18n',
37
+ 'sample-shop-modeling',
38
+ ];
39
+ await this.app.pm.add(samples, {});
40
+ await this.app.reload();
6
41
  }
7
42
 
8
- beforeLoad(): void {
9
- this.app.loadPluginConfig([
10
- '@nocobase/plugin-error-handler',
11
- '@nocobase/plugin-collection-manager',
12
- '@nocobase/plugin-ui-schema-storage',
13
- '@nocobase/plugin-ui-routes-storage',
14
- '@nocobase/plugin-file-manager',
15
- '@nocobase/plugin-system-settings',
16
- '@nocobase/plugin-verification',
17
- '@nocobase/plugin-users',
18
- '@nocobase/plugin-acl',
19
- '@nocobase/plugin-china-region',
20
- '@nocobase/plugin-workflow',
21
- '@nocobase/plugin-client',
22
- '@nocobase/plugin-export',
23
- '@nocobase/plugin-audit-logs',
24
- ]);
43
+ afterAdd() {
44
+ this.app.on('beforeLoad', async (app, options) => {
45
+ if (options?.method !== 'upgrade') {
46
+ return;
47
+ }
48
+ const result = await this.app.version.satisfies('<0.8.0-alpha.1');
49
+ if (result) {
50
+ const r = await this.db.collectionExistsInDb('applicationPlugins');
51
+ if (r) {
52
+ await this.db.getRepository('applicationPlugins').destroy({ truncate: true });
53
+ await this.app.reload();
54
+ }
55
+ }
56
+ });
57
+ this.app.on('beforeUpgrade', async () => {
58
+ const result = await this.app.version.satisfies('<0.8.0-alpha.1');
59
+ if (result) {
60
+ await this.addBuiltInPlugins();
61
+ }
62
+ });
63
+ this.app.on('beforeInstall', async () => {
64
+ await this.addBuiltInPlugins();
65
+ });
25
66
  }
67
+ beforeLoad() {}
26
68
  }
27
69
 
28
70
  export default PresetNocoBase;