Create new plop generator

This commit is contained in:
Rémi de Juvigny 2021-08-18 18:10:24 +02:00 committed by Mark Kaylor
parent 918b0fad17
commit b32e68c9f1
4 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,10 @@
{
"name": "service-plop",
"version": "3.6.6",
"description": "Generate a service for a Strapi API.",
"main": "index.js",
"license": "MIT",
"dependencies": {
"plop": "2.7.4"
}
}

View File

@ -0,0 +1,24 @@
'use strict';
const { join } = require('path');
module.exports = function(plop) {
// Service generator
plop.setGenerator('service', {
description: 'application service logic',
prompts: [
{
type: 'input',
name: 'id',
message: 'service name please',
},
],
actions: [
{
type: 'add',
path: join(process.cwd(), 'api/{{id}}/services/{{id}}.js'),
templateFile: 'templates/service.js.hbs',
},
],
});
};

View File

@ -0,0 +1,11 @@
'use strict';
/**
* {{id}} service.
*/
module.exports = {
// exampleService: (arg1, arg2) => {
// return isUserOnline(arg1, arg2);
// }
};