mirror of
https://github.com/strapi/strapi.git
synced 2025-09-01 04:42:58 +00:00
Fix generated app
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
716d2b809f
commit
ae9066bbbf
@ -1,28 +1,37 @@
|
|||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
|
|
||||||
// TODO
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||||
export default strapi => {
|
const icon = pluginPkg.strapi.icon;
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
const name = pluginPkg.strapi.name;
|
||||||
|
|
||||||
const plugin = {
|
export default {
|
||||||
blockerComponent: null,
|
register(app) {
|
||||||
blockerComponentProps: {},
|
app.registerPlugin({
|
||||||
description: pluginDescription,
|
description: pluginDescription,
|
||||||
icon: pluginPkg.strapi.icon,
|
icon,
|
||||||
id: pluginId,
|
id: pluginId,
|
||||||
initializer: () => null,
|
isReady: true,
|
||||||
injectedComponents: [],
|
isRequired: pluginPkg.strapi.required || false,
|
||||||
isReady: true,
|
mainComponent: () => 'My plugin',
|
||||||
isRequired: pluginPkg.strapi.required || false,
|
name,
|
||||||
leftMenuLinks: [],
|
settings: null,
|
||||||
leftMenuSections: [],
|
trads: {},
|
||||||
mainComponent: null,
|
menu: {
|
||||||
name: pluginPkg.strapi.name,
|
pluginsSectionLinks: [
|
||||||
preventComponentRendering: false,
|
{
|
||||||
settings: null,
|
destination: `/plugins/${pluginId}`,
|
||||||
trads: {},
|
icon,
|
||||||
};
|
label: {
|
||||||
|
id: `${pluginId}.plugin.name`,
|
||||||
return strapi.registerPlugin(plugin);
|
defaultMessage: 'My plugin',
|
||||||
|
},
|
||||||
|
name,
|
||||||
|
permissions: null,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
boot() {},
|
||||||
};
|
};
|
||||||
|
@ -79,26 +79,42 @@ async function build({ dir, env, options, optimize }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove
|
|
||||||
async function createPluginsJs(plugins, localPlugins, dest) {
|
async function createPluginsJs(plugins, localPlugins, dest) {
|
||||||
|
const createPluginsArray = plugins =>
|
||||||
|
plugins.map(name => {
|
||||||
|
const shortName = _.camelCase(name.replace(/^@strapi\/plugin-/i, ''));
|
||||||
|
|
||||||
|
return { name, shortName };
|
||||||
|
});
|
||||||
|
const appPluginsArray = createPluginsArray(plugins);
|
||||||
|
const localPluginsArray = createPluginsArray(localPlugins);
|
||||||
|
|
||||||
const content = `
|
const content = `
|
||||||
module.exports = {
|
${appPluginsArray
|
||||||
${plugins
|
.map(({ name, shortName }) => {
|
||||||
.map(name => {
|
const req = `'../../plugins/${name}/admin/src'`;
|
||||||
const shortName = name.replace(/^@strapi\/plugin-/i, '');
|
|
||||||
const req = `require('../../plugins/${name}/admin/src').default`;
|
return `import ${shortName} from ${req};`;
|
||||||
return `'${shortName}': ${req},`;
|
})
|
||||||
})
|
.join('\n')}
|
||||||
.join('\n')}
|
${localPluginsArray
|
||||||
${localPlugins
|
.map(({ name, shortName }) => {
|
||||||
.map(name => {
|
const req = `'../../../plugins/${name}/admin/src'`;
|
||||||
const shortName = name.replace(/^@strapi\/plugin-/i, '');
|
|
||||||
const req = `require('../../../plugins/${name}/admin/src').default`;
|
return `import ${shortName} from ${req};`;
|
||||||
return `'${shortName}': ${req}`;
|
})
|
||||||
})
|
.join('\n')}
|
||||||
.join(',\n')}
|
|
||||||
}
|
const plugins = {
|
||||||
`;
|
${[...appPluginsArray, ...localPluginsArray]
|
||||||
|
.map(({ name, shortName }) => {
|
||||||
|
return ` '${name}': ${shortName},`;
|
||||||
|
})
|
||||||
|
.join('\n')}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default plugins;
|
||||||
|
`;
|
||||||
|
|
||||||
return fs.writeFile(path.resolve(dest, 'admin', 'src', 'plugins.js'), content);
|
return fs.writeFile(path.resolve(dest, 'admin', 'src', 'plugins.js'), content);
|
||||||
}
|
}
|
||||||
@ -123,13 +139,6 @@ async function copyPlugin(name, dest) {
|
|||||||
|
|
||||||
// Copy the entire admin folder
|
// Copy the entire admin folder
|
||||||
await copy('admin');
|
await copy('admin');
|
||||||
|
|
||||||
// Copy the layout.js if it exists
|
|
||||||
if (await fs.exists(path.resolve(pkgFilePath, 'config', 'layout.js'))) {
|
|
||||||
await fs.ensureDir(resolveDest('config'));
|
|
||||||
await copy('config', 'layout.js');
|
|
||||||
}
|
|
||||||
|
|
||||||
await copy('package.json');
|
await copy('package.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +227,7 @@ async function watchAdmin({ dir, host, port, browser, options }) {
|
|||||||
// Create the cache dir containing the front-end files.
|
// Create the cache dir containing the front-end files.
|
||||||
await createCacheDir(dir);
|
await createCacheDir(dir);
|
||||||
|
|
||||||
const entry = path.join(dir, '.cache', 'admin', 'src', 'app.js');
|
const entry = path.join(dir, '.cache', 'admin', 'src');
|
||||||
const dest = path.join(dir, 'build');
|
const dest = path.join(dir, 'build');
|
||||||
const env = 'development';
|
const env = 'development';
|
||||||
|
|
||||||
@ -234,9 +243,9 @@ async function watchAdmin({ dir, host, port, browser, options }) {
|
|||||||
clientLogLevel: 'silent',
|
clientLogLevel: 'silent',
|
||||||
quiet: true,
|
quiet: true,
|
||||||
open: browser === 'true' ? true : browser,
|
open: browser === 'true' ? true : browser,
|
||||||
publicPath: options.publicPath,
|
publicPath: options.adminPath,
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
index: options.publicPath,
|
index: options.adminPath,
|
||||||
disableDotRule: true,
|
disableDotRule: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -27,7 +27,7 @@ module.exports = async function({ browser }) {
|
|||||||
browser,
|
browser,
|
||||||
options: {
|
options: {
|
||||||
backend: getAbsoluteServerUrl(config, true),
|
backend: getAbsoluteServerUrl(config, true),
|
||||||
publicPath: addSlash(adminPath),
|
adminPath: addSlash(adminPath),
|
||||||
watchIgnoreFiles: adminWatchIgnoreFiles,
|
watchIgnoreFiles: adminWatchIgnoreFiles,
|
||||||
features: ee.isEE ? ee.features.getEnabled() : [],
|
features: ee.isEE ? ee.features.getEnabled() : [],
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user