From 7cded4395a95922918a2b8abe041160b715a601b Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 1 Nov 2022 18:00:00 +0800 Subject: [PATCH] fix: remove sample plugin client files --- .../app/client/src/plugins/sample-command.ts | 1 - .../client/src/plugins/sample-custom-block.ts | 1 - .../client/src/plugins/sample-custom-page.ts | 1 - .../src/plugins/sample-custom-signup-page.ts | 1 - .../client/src/plugins/sample-ratelimit.ts | 1 - .../client/src/plugins/sample-shop-actions.ts | 1 - .../client/src/plugins/sample-shop-events.ts | 1 - .../client/src/plugins/sample-shop-i18n.ts | 1 - .../src/plugins/sample-shop-modeling.ts | 1 - packages/presets/nocobase/src/index.ts | 11 +++++++- .../src/migrations/2022-del-sample-plugins.ts | 27 +++++++++++++++++++ 11 files changed, 37 insertions(+), 10 deletions(-) delete mode 100644 packages/app/client/src/plugins/sample-command.ts delete mode 100644 packages/app/client/src/plugins/sample-custom-block.ts delete mode 100644 packages/app/client/src/plugins/sample-custom-page.ts delete mode 100644 packages/app/client/src/plugins/sample-custom-signup-page.ts delete mode 100644 packages/app/client/src/plugins/sample-ratelimit.ts delete mode 100644 packages/app/client/src/plugins/sample-shop-actions.ts delete mode 100644 packages/app/client/src/plugins/sample-shop-events.ts delete mode 100644 packages/app/client/src/plugins/sample-shop-i18n.ts delete mode 100644 packages/app/client/src/plugins/sample-shop-modeling.ts create mode 100644 packages/presets/nocobase/src/migrations/2022-del-sample-plugins.ts diff --git a/packages/app/client/src/plugins/sample-command.ts b/packages/app/client/src/plugins/sample-command.ts deleted file mode 100644 index d43b18ee7..000000000 --- a/packages/app/client/src/plugins/sample-command.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-command/client'; \ No newline at end of file diff --git a/packages/app/client/src/plugins/sample-custom-block.ts b/packages/app/client/src/plugins/sample-custom-block.ts deleted file mode 100644 index affa4dda1..000000000 --- a/packages/app/client/src/plugins/sample-custom-block.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-custom-block/client'; \ No newline at end of file diff --git a/packages/app/client/src/plugins/sample-custom-page.ts b/packages/app/client/src/plugins/sample-custom-page.ts deleted file mode 100644 index c76849a92..000000000 --- a/packages/app/client/src/plugins/sample-custom-page.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-custom-page/client'; \ No newline at end of file diff --git a/packages/app/client/src/plugins/sample-custom-signup-page.ts b/packages/app/client/src/plugins/sample-custom-signup-page.ts deleted file mode 100644 index cee372da4..000000000 --- a/packages/app/client/src/plugins/sample-custom-signup-page.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-custom-signup-page/client'; \ No newline at end of file diff --git a/packages/app/client/src/plugins/sample-ratelimit.ts b/packages/app/client/src/plugins/sample-ratelimit.ts deleted file mode 100644 index 7b138685d..000000000 --- a/packages/app/client/src/plugins/sample-ratelimit.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-ratelimit/client'; \ No newline at end of file diff --git a/packages/app/client/src/plugins/sample-shop-actions.ts b/packages/app/client/src/plugins/sample-shop-actions.ts deleted file mode 100644 index e4454a609..000000000 --- a/packages/app/client/src/plugins/sample-shop-actions.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-shop-actions/client'; \ No newline at end of file diff --git a/packages/app/client/src/plugins/sample-shop-events.ts b/packages/app/client/src/plugins/sample-shop-events.ts deleted file mode 100644 index 274df32cb..000000000 --- a/packages/app/client/src/plugins/sample-shop-events.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-shop-events/client'; \ No newline at end of file diff --git a/packages/app/client/src/plugins/sample-shop-i18n.ts b/packages/app/client/src/plugins/sample-shop-i18n.ts deleted file mode 100644 index 01dddf816..000000000 --- a/packages/app/client/src/plugins/sample-shop-i18n.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-shop-i18n/client'; \ No newline at end of file diff --git a/packages/app/client/src/plugins/sample-shop-modeling.ts b/packages/app/client/src/plugins/sample-shop-modeling.ts deleted file mode 100644 index ae46fd550..000000000 --- a/packages/app/client/src/plugins/sample-shop-modeling.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@nocobase/plugin-sample-shop-modeling/client'; \ No newline at end of file diff --git a/packages/presets/nocobase/src/index.ts b/packages/presets/nocobase/src/index.ts index 72f036e73..651f3a209 100644 --- a/packages/presets/nocobase/src/index.ts +++ b/packages/presets/nocobase/src/index.ts @@ -1,4 +1,5 @@ import { Plugin } from '@nocobase/server'; +import path from 'path'; export class PresetNocoBase extends Plugin { async addBuiltInPlugins() { @@ -53,7 +54,15 @@ export class PresetNocoBase extends Plugin { await this.addBuiltInPlugins(); }); } - beforeLoad() {} + beforeLoad() { + this.db.addMigrations({ + namespace: this.getName(), + directory: path.resolve(__dirname, './migrations'), + context: { + plugin: this, + }, + }); + } } export default PresetNocoBase; diff --git a/packages/presets/nocobase/src/migrations/2022-del-sample-plugins.ts b/packages/presets/nocobase/src/migrations/2022-del-sample-plugins.ts new file mode 100644 index 000000000..79b714e24 --- /dev/null +++ b/packages/presets/nocobase/src/migrations/2022-del-sample-plugins.ts @@ -0,0 +1,27 @@ +import { Migration } from '@nocobase/server'; + +export default class DelSamplePluginMigration extends Migration { + async up() { + const r1 = await this.app.version.satisfies('>=0.8.0-alpha.1'); + const r2 = await this.app.version.satisfies('<=0.8.0-alpha.6'); + if (r1 && r2) { + const repository = this.context.db.getRepository('applicationPlugins'); + await repository.destroy({ + filter: { + 'name.$in': [ + 'sample-command', + 'sample-shop-modeling', + 'sample-hello', + 'sample-shop-events', + 'sample-shop-i18n', + 'sample-shop-actions', + 'sample-ratelimit', + 'sample-custom-signup-page', + 'sample-custom-block', + 'sample-custom-page', + ], + }, + }); + } + } +}