diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/.npmignore b/packages/plugins/@nocobase/plugin-disable-pm-add/.npmignore new file mode 100644 index 000000000..c593fe9df --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/.npmignore @@ -0,0 +1,2 @@ +/node_modules +/src \ No newline at end of file diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/client.d.ts b/packages/plugins/@nocobase/plugin-disable-pm-add/client.d.ts new file mode 100644 index 000000000..6c459cbac --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/client.d.ts @@ -0,0 +1,2 @@ +export * from './dist/client'; +export { default } from './dist/client'; diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/client.js b/packages/plugins/@nocobase/plugin-disable-pm-add/client.js new file mode 100644 index 000000000..b6e3be70e --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/client.js @@ -0,0 +1 @@ +module.exports = require('./dist/client/index.js'); diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/package.json b/packages/plugins/@nocobase/plugin-disable-pm-add/package.json new file mode 100644 index 000000000..e1e2208d4 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/package.json @@ -0,0 +1,11 @@ +{ + "name": "@nocobase/plugin-disable-pm-add", + "version": "0.14.0-alpha.7", + "main": "./dist/server/index.js", + "peerDependencies": { + "@nocobase/client": "0.x", + "@nocobase/server": "0.x", + "@nocobase/test": "0.x" + }, + "gitHead": "ee5825377d8bec05f968a8365a0cdcd49878ada6" +} diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/server.d.ts b/packages/plugins/@nocobase/plugin-disable-pm-add/server.d.ts new file mode 100644 index 000000000..c41081ddc --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/server.d.ts @@ -0,0 +1,2 @@ +export * from './dist/server'; +export { default } from './dist/server'; diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/server.js b/packages/plugins/@nocobase/plugin-disable-pm-add/server.js new file mode 100644 index 000000000..972842039 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/server.js @@ -0,0 +1 @@ +module.exports = require('./dist/server/index.js'); diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/src/client/index.ts b/packages/plugins/@nocobase/plugin-disable-pm-add/src/client/index.ts new file mode 100644 index 000000000..85c9163c9 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/src/client/index.ts @@ -0,0 +1,7 @@ +import { Plugin } from '@nocobase/client'; + +class PluginDisablePmAddClient extends Plugin { + async load() {} +} + +export default PluginDisablePmAddClient; diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/src/index.ts b/packages/plugins/@nocobase/plugin-disable-pm-add/src/index.ts new file mode 100644 index 000000000..7e74612df --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/src/index.ts @@ -0,0 +1,2 @@ +export * from './server'; +export { default } from './server'; diff --git a/packages/plugins/@nocobase/plugin-disable-pm-add/src/server/index.ts b/packages/plugins/@nocobase/plugin-disable-pm-add/src/server/index.ts new file mode 100644 index 000000000..89b7fc6ca --- /dev/null +++ b/packages/plugins/@nocobase/plugin-disable-pm-add/src/server/index.ts @@ -0,0 +1,27 @@ +import { InstallOptions, Plugin } from '@nocobase/server'; + +export class PluginDisablePmAddServer extends Plugin { + beforeLoad() { + // TODO + } + + async load() { + this.app.resourcer.use(async (ctx, next) => { + const { resourceName, actionName } = ctx.action; + if (resourceName === 'pm' && actionName === 'add') { + ctx.throw(403, 'The current environment does not allow adding plugins online'); + } + await next(); + }); + } + + async disable() { + // this.app.resourcer.removeResource('testHello'); + } + + async install(options: InstallOptions) { + // TODO + } +} + +export default PluginDisablePmAddServer;