feat: Allow other plugin to register their own config types

pull/60/head
Boaz Poolman 2022-06-09 12:17:13 +02:00
parent fea127f7b2
commit a7bfd3fd4b
3 changed files with 19 additions and 0 deletions

View File

@ -21,12 +21,21 @@ module.exports = async () => {
const registerTypes = () => { const registerTypes = () => {
const types = {}; const types = {};
// The default types provided by the plugin.
defaultTypes(strapi).map((type) => { defaultTypes(strapi).map((type) => {
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) { if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) {
types[type.configName] = new ConfigType(type); types[type.configName] = new ConfigType(type);
} }
}); });
// The types provided by other plugins.
strapi.plugin('config-sync').pluginTypes.map((type) => {
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) {
types[type.configName] = new ConfigType(type);
}
});
// The custom types provided by the user.
strapi.config.get('plugin.config-sync.customTypes').map((type) => { strapi.config.get('plugin.config-sync.customTypes').map((type) => {
if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) { if (!strapi.config.get('plugin.config-sync.excludedTypes').includes(type.configName)) {
types[type.configName] = new ConfigType(type); types[type.configName] = new ConfigType(type);

8
server/register.js Normal file
View File

@ -0,0 +1,8 @@
'use strict';
module.exports = async ({ strapi }) => {
// Instantiate the pluginTypes array.
if (!strapi.plugin('config-sync').pluginTypes) {
strapi.plugin('config-sync').pluginTypes = [];
}
};

View File

@ -1,5 +1,6 @@
'use strict'; 'use strict';
const register = require('./server/register');
const bootstrap = require('./server/bootstrap'); const bootstrap = require('./server/bootstrap');
const services = require('./server/services'); const services = require('./server/services');
const routes = require('./server/routes'); const routes = require('./server/routes');
@ -8,6 +9,7 @@ const controllers = require('./server/controllers');
module.exports = () => { module.exports = () => {
return { return {
register,
bootstrap, bootstrap,
routes, routes,
config, config,