diff --git a/packages/core/cli/bin/index.js b/packages/core/cli/bin/index.js index 5e2033da7..f4fc029e2 100755 --- a/packages/core/cli/bin/index.js +++ b/packages/core/cli/bin/index.js @@ -15,6 +15,7 @@ const env = { DB_TIMEZONE: '+00:00', DEFAULT_STORAGE_TYPE: 'local', LOCAL_STORAGE_DEST: 'storage/uploads', + MFSU_AD: 'none', }; if (!process.env.APP_ENV_PATH && process.argv[2] && process.argv[2] === 'test') { diff --git a/packages/core/server/src/plugin-manager.ts b/packages/core/server/src/plugin-manager.ts index 433c333fb..ac8405119 100644 --- a/packages/core/server/src/plugin-manager.ts +++ b/packages/core/server/src/plugin-manager.ts @@ -37,6 +37,7 @@ export class PluginManager { { type: 'string', name: 'name', unique: true }, { type: 'string', name: 'version' }, { type: 'boolean', name: 'enabled' }, + { type: 'boolean', name: 'installed' }, { type: 'boolean', name: 'builtIn' }, { type: 'json', name: 'options' }, ], @@ -71,6 +72,12 @@ export class PluginManager { ctx.throw(400, 'plugin invalid'); } await app.reload(); + if (plugin.model && !plugin.model.get('installed')) { + await app.db.sync(); + await plugin.install(); + plugin.model.set('installed', true); + await plugin.model.save(); + } await app.start(); ctx.body = 'ok'; await next(); @@ -128,6 +135,7 @@ export class PluginManager { await this.collection.sync(); }); this.app.on('beforeLoadAll', async (options) => { + await this.collection.sync(); const exists = await this.app.db.collectionExistsInDb('applicationPlugins'); if (!exists) { return; @@ -184,7 +192,7 @@ export class PluginManager { for (const plugin of pluginClass) { await this.add(plugin); } - } + }; return addMultiple(); } if (typeof pluginClass === 'string') { diff --git a/packages/presets/nocobase/src/index.ts b/packages/presets/nocobase/src/index.ts index 3f88bd451..b8ff80bf2 100644 --- a/packages/presets/nocobase/src/index.ts +++ b/packages/presets/nocobase/src/index.ts @@ -28,6 +28,7 @@ export class PresetNocoBase extends Plugin { if (instance.model && plugin !== 'hello') { instance.model.enabled = true; instance.model.builtIn = true; + instance.model.installed = true; await instance.model.save(); } } diff --git a/packages/samples/hello/README.md b/packages/samples/hello/README.md index 5e4edb207..971ce5794 100644 --- a/packages/samples/hello/README.md +++ b/packages/samples/hello/README.md @@ -19,7 +19,7 @@ yarn pm enable sample-hello yarn dev # for production -yarn build samples/hello +yarn build yarn start ``` diff --git a/packages/samples/shop-modeling/README.md b/packages/samples/shop-modeling/README.md index 896e25b26..9a6d6b7d5 100644 --- a/packages/samples/shop-modeling/README.md +++ b/packages/samples/shop-modeling/README.md @@ -19,7 +19,7 @@ yarn pm enable sample-shop-modeling yarn dev # for production -yarn build samples/shop-modeling +yarn build yarn start ```