mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
Merge branch 'releases/v4' into v4/ds-migration
This commit is contained in:
commit
0985c241eb
@ -9,7 +9,7 @@ const nodePlop = require('node-plop');
|
||||
*/
|
||||
const runCLI = () => {
|
||||
Plop.launch({ configPath: join(__dirname, 'plopfile.js') }, env =>
|
||||
run({ ...env, dest: process.cwd() }, undefined, true)
|
||||
run({ ...env, dest: join(process.cwd(), 'src') }, undefined, true)
|
||||
);
|
||||
};
|
||||
|
||||
@ -21,7 +21,7 @@ const runCLI = () => {
|
||||
* @param {string} plopOptions.dir base path for plop to generate the files from
|
||||
*/
|
||||
const generate = async (generatorName, options, { dir = process.cwd() } = {}) => {
|
||||
const plop = nodePlop(join(__dirname, 'plopfile.js'), { destBasePath: dir });
|
||||
const plop = nodePlop(join(__dirname, 'plopfile.js'), { destBasePath: join(dir, 'src') });
|
||||
|
||||
const generator = plop.getGenerator(generatorName);
|
||||
await generator.runActions(options, {
|
||||
|
@ -4,7 +4,7 @@ const pluralize = require('pluralize');
|
||||
|
||||
const generateApi = require('./plops/api');
|
||||
const generateController = require('./plops/controller');
|
||||
const generateModel = require('./plops/model');
|
||||
const generateContentType = require('./plops/content-type');
|
||||
const generatePlugin = require('./plops/plugin');
|
||||
const generatePolicy = require('./plops/policy');
|
||||
const generateService = require('./plops/service');
|
||||
@ -17,7 +17,7 @@ module.exports = plop => {
|
||||
// Generators
|
||||
generateApi(plop);
|
||||
generateController(plop);
|
||||
generateModel(plop);
|
||||
generateContentType(plop);
|
||||
generatePlugin(plop);
|
||||
generatePolicy(plop);
|
||||
generateService(plop);
|
||||
|
@ -32,7 +32,7 @@ const promptConfigQuestions = (plop, inquirer) => {
|
||||
{
|
||||
type: 'input',
|
||||
name: 'id',
|
||||
message: 'Model name',
|
||||
message: 'Content type name',
|
||||
validate: input => validateInput(input),
|
||||
},
|
||||
{
|
||||
@ -104,8 +104,8 @@ const promptAttributeQuestions = inquirer => {
|
||||
|
||||
module.exports = plop => {
|
||||
// Model generator
|
||||
plop.setGenerator('model', {
|
||||
description: 'Generate a model for an API',
|
||||
plop.setGenerator('content-type', {
|
||||
description: 'Generate a content type for an API',
|
||||
async prompts(inquirer) {
|
||||
const config = await promptConfigQuestions(plop, inquirer);
|
||||
|
@ -27,7 +27,7 @@ module.exports = plop => {
|
||||
return [
|
||||
{
|
||||
type: 'add',
|
||||
path: `${filePath}/config/policies/{{id}}.js`,
|
||||
path: `${filePath}/policies/{{id}}.js`,
|
||||
templateFile: 'templates/policy.js.hbs',
|
||||
},
|
||||
];
|
||||
|
@ -9,7 +9,7 @@
|
||||
"name": "{{id}}"
|
||||
},
|
||||
"options": {
|
||||
"draftAndPublish": {{useDraftAndPublish || false}},
|
||||
"draftAndPublish": {{ useDraftAndPublish }},
|
||||
"comment": ""
|
||||
},
|
||||
"attributes": {}
|
||||
|
@ -4,9 +4,15 @@
|
||||
* `{{id}}` policy.
|
||||
*/
|
||||
|
||||
module.exports = async (ctx, next) => {
|
||||
module.exports = async (ctx) => {
|
||||
// Add your own logic here.
|
||||
console.log('In {{id}} policy.');
|
||||
|
||||
await next();
|
||||
const canDoSomething = true;
|
||||
|
||||
if (canDoSomething) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user