mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 08:04:51 +00:00
refactor(CLI-Generate): ♻️ fix getFilePath path for plugins
This commit is contained in:
parent
fc099f4f15
commit
e1375a80e1
@ -2,6 +2,7 @@
|
||||
|
||||
const { join } = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const getFilePath = require('./utils/get-file-path');
|
||||
const validateInput = require('./utils/validate-input');
|
||||
|
||||
module.exports = plop => {
|
||||
@ -45,7 +46,8 @@ module.exports = plop => {
|
||||
},
|
||||
],
|
||||
actions(answers) {
|
||||
const filePath = answers.isPluginApi && answers.plugin ? 'plugins/{{plugin}}/server' : 'api/{{id}}';
|
||||
const answerDestination = answers.isPluginApi && answers.plugin ? 'plugin' : 'api';
|
||||
const filePath = getFilePath(answerDestination);
|
||||
|
||||
const baseActions = [
|
||||
{
|
||||
|
||||
@ -18,8 +18,7 @@ module.exports = plop => {
|
||||
...getDestinationPrompts('controller', plop.getDestBasePath()),
|
||||
],
|
||||
actions(answers) {
|
||||
const resolveFilePath = (isPlugin,filePath) => isPlugin ? `${filePath}/server` : filePath;
|
||||
const filePath = resolveFilePath(answers.plugin,getFilePath(answers.destination));
|
||||
const filePath = getFilePath(answers.destination);
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
||||
const getFilePath = require('./utils/get-file-path');
|
||||
|
||||
module.exports = plop => {
|
||||
// middleware generator
|
||||
@ -15,15 +16,7 @@ module.exports = plop => {
|
||||
...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),
|
||||
],
|
||||
actions(answers) {
|
||||
let filePath;
|
||||
if (answers.destination === 'api') {
|
||||
filePath = `api/{{ api }}`;
|
||||
} else if (answers.destination === 'plugin') {
|
||||
filePath = `plugins/{{ plugin }}/server`;
|
||||
} else {
|
||||
filePath = `./`;
|
||||
}
|
||||
|
||||
const filePath = getFilePath(answers.destination);
|
||||
return [
|
||||
{
|
||||
type: 'add',
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
||||
const getFilePath = require('./utils/get-file-path');
|
||||
|
||||
module.exports = plop => {
|
||||
// Policy generator
|
||||
@ -15,14 +16,7 @@ module.exports = plop => {
|
||||
...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),
|
||||
],
|
||||
actions(answers) {
|
||||
let filePath;
|
||||
if (answers.destination === 'api') {
|
||||
filePath = `api/{{api}}`;
|
||||
} else if (answers.destination === 'plugin') {
|
||||
filePath = `plugins/{{plugin}}/server`;
|
||||
} else {
|
||||
filePath = `./`;
|
||||
}
|
||||
const filePath = getFilePath(answers.destination);
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
@ -16,8 +16,8 @@ module.exports = plop => {
|
||||
...getDestinationPrompts('service', plop.getDestBasePath()),
|
||||
],
|
||||
actions(answers) {
|
||||
const resolveFilePath = (isPlugin,filePath) => isPlugin ? `${filePath}/server` : filePath;
|
||||
const filePath = resolveFilePath(answers.plugin,getFilePath(answers.destination));
|
||||
const filePath = getFilePath(answers.destination);
|
||||
|
||||
return [
|
||||
{
|
||||
type: 'add',
|
||||
|
||||
@ -6,7 +6,7 @@ module.exports = destination => {
|
||||
}
|
||||
|
||||
if (destination === 'plugin') {
|
||||
return `plugins/{{ plugin }}`;
|
||||
return `plugins/{{ plugin }}/server`;
|
||||
}
|
||||
|
||||
return `api/{{ id }}`;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user