refactor(CLI-Generate): ♻️ add root path support for middlewares & policies

This commit is contained in:
Marin 2022-01-21 14:39:22 +02:00
parent e1375a80e1
commit 621c75ea27
2 changed files with 11 additions and 4 deletions

View File

@ -9,10 +9,13 @@ module.exports = (action, basePath, { rootFolder = false } = {}) => {
name: 'destination',
message: `Where do you want to add this ${action}?`,
choices: [
{
name: `Add ${action} to ${rootFolder ? 'root of project' : 'new API'}`,
value: 'new',
},
...rootFolder ? [{
name: `Add ${action} to root of project`,
value: 'root'
}] : [{
name: `Add ${action} to new API`,
value: 'new'
}],
{ name: `Add ${action} to an existing API`, value: 'api' },
{ name: `Add ${action} to an existing plugin`, value: 'plugin' },
],

View File

@ -9,5 +9,9 @@ module.exports = destination => {
return `plugins/{{ plugin }}/server`;
}
if (destination === 'root') {
return './';
}
return `api/{{ id }}`;
};