From d3890b4b66bd7f5b607db868c867b858da9906a8 Mon Sep 17 00:00:00 2001 From: chenos Date: Mon, 6 Sep 2021 16:00:38 +0800 Subject: [PATCH] feat: add @nocobase/preset-nocobase --- packages/app/package.json | 1 + packages/app/src/api/index.ts | 21 ++------------------- packages/preset-nocobase/.npmignore | 7 +++++++ packages/preset-nocobase/package.json | 19 +++++++++++++++++++ packages/preset-nocobase/src/index.ts | 19 +++++++++++++++++++ 5 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 packages/preset-nocobase/.npmignore create mode 100644 packages/preset-nocobase/package.json create mode 100644 packages/preset-nocobase/src/index.ts diff --git a/packages/app/package.json b/packages/app/package.json index df33268be..c36b4f2b8 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -27,6 +27,7 @@ }, "dependencies": { "@nocobase/client": "^0.4.0-alpha.7", + "@nocobase/preset-nocobase": "^0.4.0-alpha.7", "@umijs/preset-react": "1.x", "umi": "^3.0.0" }, diff --git a/packages/app/src/api/index.ts b/packages/app/src/api/index.ts index 9d7f34538..da74889c3 100644 --- a/packages/app/src/api/index.ts +++ b/packages/app/src/api/index.ts @@ -41,26 +41,9 @@ const api = new Server({ }, }); -const plugins = [ - '@nocobase/plugin-collections', - '@nocobase/plugin-ui-router', - '@nocobase/plugin-ui-schema', - '@nocobase/plugin-users', - '@nocobase/plugin-action-logs', - '@nocobase/plugin-file-manager', - '@nocobase/plugin-permissions', - '@nocobase/plugin-export', - '@nocobase/plugin-system-settings', - // '@nocobase/plugin-automations', - '@nocobase/plugin-china-region', -]; +console.log(`@nocobase/preset-nocobase/${__filename.endsWith('.ts') ? 'src' : 'lib'}/index`); -for (const plugin of plugins) { - api.registerPlugin(plugin, [ - require(`${plugin}/${__filename.endsWith('.ts') ? 'src' : 'lib'}/server`) - .default, - ]); -} +api.registerPlugin('@nocobase/preset-nocobase', require(`@nocobase/preset-nocobase/${__filename.endsWith('.ts') ? 'src' : 'lib'}/index`).default); if (process.argv.length < 3) { process.argv.push('start', '--port', '2000'); diff --git a/packages/preset-nocobase/.npmignore b/packages/preset-nocobase/.npmignore new file mode 100644 index 000000000..461574b2f --- /dev/null +++ b/packages/preset-nocobase/.npmignore @@ -0,0 +1,7 @@ +node_modules +*.log +docs +__tests__ +tsconfig.json +src +.fatherrc.ts \ No newline at end of file diff --git a/packages/preset-nocobase/package.json b/packages/preset-nocobase/package.json new file mode 100644 index 000000000..c6670d8fa --- /dev/null +++ b/packages/preset-nocobase/package.json @@ -0,0 +1,19 @@ +{ + "name": "@nocobase/preset-nocobase", + "version": "0.4.0-alpha.7", + "main": "lib/index.js", + "license": "MIT", + "dependencies": { + "@nocobase/plugin-action-logs": "^0.4.0-alpha.7", + "@nocobase/plugin-automations": "^0.4.0-alpha.7", + "@nocobase/plugin-china-region": "^0.4.0-alpha.7", + "@nocobase/plugin-collections": "^0.4.0-alpha.7", + "@nocobase/plugin-file-manager": "^0.4.0-alpha.7", + "@nocobase/plugin-pages": "^0.4.0-alpha.7", + "@nocobase/plugin-permissions": "^0.4.0-alpha.7", + "@nocobase/plugin-ui-router": "^0.4.0-alpha.7", + "@nocobase/plugin-ui-schema": "^0.4.0-alpha.7", + "@nocobase/plugin-users": "^0.4.0-alpha.7" + }, + "gitHead": "f0b335ac30f29f25c95d7d137655fa64d8d67f1e" +} diff --git a/packages/preset-nocobase/src/index.ts b/packages/preset-nocobase/src/index.ts new file mode 100644 index 000000000..8f367f515 --- /dev/null +++ b/packages/preset-nocobase/src/index.ts @@ -0,0 +1,19 @@ +export default function (api) { + const plugins = [ + '@nocobase/plugin-collections', + '@nocobase/plugin-ui-router', + '@nocobase/plugin-ui-schema', + '@nocobase/plugin-users', + '@nocobase/plugin-action-logs', + '@nocobase/plugin-file-manager', + '@nocobase/plugin-permissions', + '@nocobase/plugin-export', + '@nocobase/plugin-system-settings', + // // '@nocobase/plugin-automations', + '@nocobase/plugin-china-region', + ]; + console.log(plugins); + for (const plugin of plugins) { + this.registerPlugin(plugin, [require(`${plugin}/${__filename.endsWith('.ts') ? 'src' : 'lib'}/server`).default]); + } +}