mirror of
https://github.com/strapi/strapi.git
synced 2025-08-31 12:23:05 +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 pluginId from './pluginId';
|
||||
|
||||
// TODO
|
||||
export default strapi => {
|
||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||
const icon = pluginPkg.strapi.icon;
|
||||
const name = pluginPkg.strapi.name;
|
||||
|
||||
const plugin = {
|
||||
blockerComponent: null,
|
||||
blockerComponentProps: {},
|
||||
description: pluginDescription,
|
||||
icon: pluginPkg.strapi.icon,
|
||||
id: pluginId,
|
||||
initializer: () => null,
|
||||
injectedComponents: [],
|
||||
isReady: true,
|
||||
isRequired: pluginPkg.strapi.required || false,
|
||||
leftMenuLinks: [],
|
||||
leftMenuSections: [],
|
||||
mainComponent: null,
|
||||
name: pluginPkg.strapi.name,
|
||||
preventComponentRendering: false,
|
||||
settings: null,
|
||||
trads: {},
|
||||
};
|
||||
|
||||
return strapi.registerPlugin(plugin);
|
||||
export default {
|
||||
register(app) {
|
||||
app.registerPlugin({
|
||||
description: pluginDescription,
|
||||
icon,
|
||||
id: pluginId,
|
||||
isReady: true,
|
||||
isRequired: pluginPkg.strapi.required || false,
|
||||
mainComponent: () => 'My plugin',
|
||||
name,
|
||||
settings: null,
|
||||
trads: {},
|
||||
menu: {
|
||||
pluginsSectionLinks: [
|
||||
{
|
||||
destination: `/plugins/${pluginId}`,
|
||||
icon,
|
||||
label: {
|
||||
id: `${pluginId}.plugin.name`,
|
||||
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) {
|
||||
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 = `
|
||||
module.exports = {
|
||||
${plugins
|
||||
.map(name => {
|
||||
const shortName = name.replace(/^@strapi\/plugin-/i, '');
|
||||
const req = `require('../../plugins/${name}/admin/src').default`;
|
||||
return `'${shortName}': ${req},`;
|
||||
})
|
||||
.join('\n')}
|
||||
${localPlugins
|
||||
.map(name => {
|
||||
const shortName = name.replace(/^@strapi\/plugin-/i, '');
|
||||
const req = `require('../../../plugins/${name}/admin/src').default`;
|
||||
return `'${shortName}': ${req}`;
|
||||
})
|
||||
.join(',\n')}
|
||||
}
|
||||
`;
|
||||
${appPluginsArray
|
||||
.map(({ name, shortName }) => {
|
||||
const req = `'../../plugins/${name}/admin/src'`;
|
||||
|
||||
return `import ${shortName} from ${req};`;
|
||||
})
|
||||
.join('\n')}
|
||||
${localPluginsArray
|
||||
.map(({ name, shortName }) => {
|
||||
const req = `'../../../plugins/${name}/admin/src'`;
|
||||
|
||||
return `import ${shortName} from ${req};`;
|
||||
})
|
||||
.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);
|
||||
}
|
||||
@ -123,13 +139,6 @@ async function copyPlugin(name, dest) {
|
||||
|
||||
// Copy the entire admin folder
|
||||
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');
|
||||
}
|
||||
|
||||
@ -218,7 +227,7 @@ async function watchAdmin({ dir, host, port, browser, options }) {
|
||||
// Create the cache dir containing the front-end files.
|
||||
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 env = 'development';
|
||||
|
||||
@ -234,9 +243,9 @@ async function watchAdmin({ dir, host, port, browser, options }) {
|
||||
clientLogLevel: 'silent',
|
||||
quiet: true,
|
||||
open: browser === 'true' ? true : browser,
|
||||
publicPath: options.publicPath,
|
||||
publicPath: options.adminPath,
|
||||
historyApiFallback: {
|
||||
index: options.publicPath,
|
||||
index: options.adminPath,
|
||||
disableDotRule: true,
|
||||
},
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ module.exports = async function({ browser }) {
|
||||
browser,
|
||||
options: {
|
||||
backend: getAbsoluteServerUrl(config, true),
|
||||
publicPath: addSlash(adminPath),
|
||||
adminPath: addSlash(adminPath),
|
||||
watchIgnoreFiles: adminWatchIgnoreFiles,
|
||||
features: ee.isEE ? ee.features.getEnabled() : [],
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user