Skip to content

Commit

Permalink
✨ Able to add the play meta info using plop
Browse files Browse the repository at this point in the history
  • Loading branch information
atapas committed Feb 16, 2022
1 parent bb8cd2d commit ec79b37
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"plop": "plop"
},
"eslintConfig": {
"extends": [
Expand Down
12 changes: 12 additions & 0 deletions plop-templates/play.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
id: '{{dashCase id}}',
name: '{{name}}',
description: '{{description}}',
component: () => {return <{{component}} />},
path: '/plays/{{folder}}',
level: '{{level}}',
tags: '{{tags}}',
github: '{{github}}',
blog: '{{blog}}',
video: '{{video}}'
}, //replace new play item here
69 changes: 69 additions & 0 deletions plopfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
module.exports = plop => {
// demo generator
plop.setGenerator('play', {
description: 'add a new play',
prompts: [
{
type: 'input',
name: 'id',
message:
'Give us a play id(Any string starts with pl and without a space(Example: pl-id-card ):',
},
{
type: 'input',
name: 'name',
message: 'Please provide the name of the play(Example: Identity Card):',
},
{
type: 'input',
name: 'description',
message: 'Tell us more about the demo(Max 1024 characters):',
},
{
type: 'input',
name: 'component',
message:
'Provide the React Component name(Example: IdentityCard):',
},
{
type: 'input',
name: 'folder',
message: 'Provide the folder name(Example: identity-card):',
},
{
type: 'list',
name: 'level',
message: 'What level is this play?(Example: Intermediate):',
choices: ['Beginner', 'Intermediate', 'Advanced']
},
{
type: 'input',
name: 'tags',
message: 'Provide the tags(Example: JSX, Hooks):',
},
{
type: 'input',
name: 'github',
message: 'Your github username(Example: atapas):',
},
{
type: 'input',
name: 'blog',
message: 'Your blog url(Example: https://blog.greenroots.info):',
},
{
type: 'input',
name: 'video',
message: 'Your video url(Example: https://www.youtube.com/watch?v=dQw4w9WgXcQ):',
},
],
actions: [
{
type: 'modify',
path: 'src/meta/play-meta.js',
pattern: /\/\/replace new play item here/gi,
templateFile: 'plop-templates/play.hbs',
},
],
});
};

0 comments on commit ec79b37

Please sign in to comment.