mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 03:43:34 +00:00 
			
		
		
		
	fix(CLI-Generator): ♻️ validate plugin/middleware/policy during generation and do not allow empty names
This commit is contained in:
		
							parent
							
								
									f4311d5d31
								
							
						
					
					
						commit
						73c86d7d60
					
				@ -1,6 +1,7 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
const getDestinationPrompts = require('./prompts/get-destination-prompts');
 | 
			
		||||
const validateInput = require('./utils/validate-input');
 | 
			
		||||
 | 
			
		||||
module.exports = plop => {
 | 
			
		||||
  // middleware generator
 | 
			
		||||
@ -11,6 +12,7 @@ module.exports = plop => {
 | 
			
		||||
        type: 'input',
 | 
			
		||||
        name: 'name',
 | 
			
		||||
        message: 'Middleware name',
 | 
			
		||||
        validate: input => validateInput(input),
 | 
			
		||||
      },
 | 
			
		||||
      ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),
 | 
			
		||||
    ],
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const validateInput = require('./utils/validate-input');
 | 
			
		||||
 | 
			
		||||
const logInstructions = pluginName => {
 | 
			
		||||
  const maxLength = `    resolve: './src/plugins/${pluginName}'`.length;
 | 
			
		||||
@ -32,6 +33,7 @@ module.exports = plop => {
 | 
			
		||||
        type: 'input',
 | 
			
		||||
        name: 'pluginName',
 | 
			
		||||
        message: 'Plugin name',
 | 
			
		||||
        validate: input => validateInput(input),
 | 
			
		||||
      },
 | 
			
		||||
    ],
 | 
			
		||||
    actions(answers) {
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
const getDestinationPrompts = require('./prompts/get-destination-prompts');
 | 
			
		||||
const validateInput = require('./utils/validate-input');
 | 
			
		||||
 | 
			
		||||
module.exports = plop => {
 | 
			
		||||
  // Policy generator
 | 
			
		||||
@ -11,6 +12,7 @@ module.exports = plop => {
 | 
			
		||||
        type: 'input',
 | 
			
		||||
        name: 'id',
 | 
			
		||||
        message: 'Policy name',
 | 
			
		||||
        validate: input => validateInput(input),
 | 
			
		||||
      },
 | 
			
		||||
      ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),
 | 
			
		||||
    ],
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user