Merge pull request #17135 from boazpoolman/feature/list-components-cli

This commit is contained in:
Christian 2023-07-14 08:35:25 +02:00 committed by GitHub
commit 19ea3a3934
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,23 @@
'use strict';
const CLITable = require('cli-table3');
const chalk = require('chalk');
const strapi = require('../../../../index');
module.exports = async () => {
const appContext = await strapi.compile();
const app = await strapi(appContext).register();
const list = Object.keys(app.components);
const infoTable = new CLITable({
head: [chalk.blue('Name')],
});
list.forEach((name) => infoTable.push([name]));
console.log(infoTable.toString());
await app.destroy();
};

View File

@ -0,0 +1,14 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
/**
* `$ strapi components:list`
* @param {import('../../../../types/core/commands').AddCommandOptions} options
*/
module.exports = ({ command }) => {
command
.command('components:list')
.description('List all the application components')
.action(getLocalScript('components/list'));
};

View File

@ -6,6 +6,7 @@ const strapiCommands = {
'admin/create-user': require('./actions/admin/create-user/command'),
'admin/reset-user-password': require('./actions/admin/reset-user-password/command'),
build: require('./actions/build-command/command'), // in 'build-command' to avoid problems with 'build' being commonly ignored
'components/list': require('./actions/components/list/command'),
'configuration/dump': require('./actions/configuration/dump/command'),
'configuration/restore': require('./actions/configuration/restore/command'),
console: require('./actions/console/command'),