mirror of
https://github.com/strapi/strapi.git
synced 2025-09-27 09:25:46 +00:00
fix: make generate command work (#22443)
This commit is contained in:
parent
75bf07970a
commit
40d132bcf8
@ -11,7 +11,13 @@ export const runCLI = async () => {
|
|||||||
},
|
},
|
||||||
(env) => {
|
(env) => {
|
||||||
const argv = process.argv.slice(2); // Extract command-line arguments
|
const argv = process.argv.slice(2); // Extract command-line arguments
|
||||||
Plop.execute(env, argv, (env, argv) => run(env, argv, true)); // Pass the third argument 'true' for passArgsBeforeDashes
|
Plop.execute(env, argv, (env, argv) => {
|
||||||
|
const options = {
|
||||||
|
...env,
|
||||||
|
dest: join(process.cwd(), 'src'), // this will make the destination path to be based on the cwd when calling the wrapper
|
||||||
|
};
|
||||||
|
return run(options, argv, true); // Pass the third argument 'true' for passArgsBeforeDashes
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@ import generateService from './plops/service';
|
|||||||
export default (plop: NodePlopAPI) => {
|
export default (plop: NodePlopAPI) => {
|
||||||
// Plop config
|
// Plop config
|
||||||
plop.setWelcomeMessage('Strapi Generators');
|
plop.setWelcomeMessage('Strapi Generators');
|
||||||
plop.addHelper('pluralize', (text: string) => pluralize(text));
|
plop.setHelper('pluralize', (text: string) => pluralize(text));
|
||||||
|
|
||||||
// Generators
|
// Generators
|
||||||
generateApi(plop);
|
generateApi(plop);
|
||||||
|
@ -29,7 +29,6 @@ export default (plop: NodePlopAPI) => {
|
|||||||
async choices() {
|
async choices() {
|
||||||
const pluginsPath = join(plop.getDestBasePath(), 'plugins');
|
const pluginsPath = join(plop.getDestBasePath(), 'plugins');
|
||||||
const exists = await fs.pathExists(pluginsPath);
|
const exists = await fs.pathExists(pluginsPath);
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
throw Error('Couldn\'t find a "plugins" directory');
|
throw Error('Couldn\'t find a "plugins" directory');
|
||||||
}
|
}
|
||||||
@ -51,7 +50,7 @@ export default (plop: NodePlopAPI) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const filePath =
|
const filePath =
|
||||||
answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}' : 'api/{{ id }}';
|
answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}/server' : 'api/{{ id }}';
|
||||||
const currentDir = process.cwd();
|
const currentDir = process.cwd();
|
||||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||||
|
|
||||||
|
@ -81,7 +81,6 @@ export default (plop: NodePlopAPI) => {
|
|||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const filePath = getFilePath(answers.destination);
|
const filePath = getFilePath(answers.destination);
|
||||||
// TODO: use basePath instead
|
|
||||||
const currentDir = process.cwd();
|
const currentDir = process.cwd();
|
||||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ export default (plop: NodePlopAPI) => {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const filePath = getFilePath(answers.destination);
|
|
||||||
const currentDir = process.cwd();
|
const currentDir = process.cwd();
|
||||||
|
const filePath = getFilePath(answers.destination);
|
||||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user