Skip to content

Commit

Permalink
🔥 Now we have reduced questions for creating play
Browse files Browse the repository at this point in the history
  • Loading branch information
atapas committed Apr 13, 2022
1 parent 2051fc8 commit e389388
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 30 deletions.
4 changes: 2 additions & 2 deletions plop-templates/component.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getPlayById } from 'meta/play-meta-util';

import PlayHeader from 'common/playlists/PlayHeader';

function {{trim component}}() {
function {{pascalCase name}}() {
// Do not remove the below lines.
// The following code is to fetch the current play from the URL
const location = useLocation();
Expand Down Expand Up @@ -35,4 +35,4 @@ function {{trim component}}() {
);
}

export default {{component}};
export default {{pascalCase name}};
2 changes: 1 addition & 1 deletion plop-templates/exportPlay.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as {{trim component}} } from 'plays/{{trim folder}}/{{trim component}}';
export { default as {{pascalCase name}} } from 'plays/{{generateFolderName name}}/{{pascalCase name}}';
//add export here
2 changes: 1 addition & 1 deletion plop-templates/importToMeta.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{trim component}},
{{pascalCase name}},
//import play here
6 changes: 3 additions & 3 deletions plop-templates/play.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
id: '{{dashCase id}}',
id: '{{generateId name}}',
name: '{{titleCase name}}',
description: '{{description}}',
component: () => {return <{{trim component}} />},
path: '/plays/{{trim folder}}',
component: () => {return <{{pascalCase name}} />},
path: '/plays/{{generateFolderName name}}',
level: '{{level}}',
tags: '{{removeAllSpaces tags}}',
github: '{{github}}',
Expand Down
33 changes: 10 additions & 23 deletions plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ module.exports = plop => {
plop.setHelper('trim', str => str.trim());
plop.setHelper('removeAllSpaces', str => str.replaceAll(/\s/g,''));

plop.setHelper('generateId', str => `pl-${str.trim().replaceAll(/\s/g,'-').toLowerCase()}`);

plop.setHelper('generateFolderName', str => `${str.trim().replaceAll(/\s/g,'-').toLowerCase()}`);

// demo generator
plop.setGenerator('play', {
description: 'Steps to 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',
Expand All @@ -22,22 +20,6 @@ module.exports = plop => {
name: 'description',
message: 'Tell us more about the play(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: 'input',
name: 'cover',
message: 'Please provide the path(URL) to cover image(When the image is hosted publicly):',
},
{
type: 'list',
name: 'level',
Expand All @@ -54,6 +36,11 @@ module.exports = plop => {
name: 'github',
message: 'Enter your github username(Example: atapas):',
},
{
type: 'input',
name: 'cover',
message: 'Please provide the path(URL) to cover image(When the image is hosted publicly):',
},
{
type: 'input',
name: 'blog',
Expand All @@ -68,7 +55,7 @@ module.exports = plop => {
actions: [
{
type: 'add',
path: 'src/plays/{{trim folder}}/{{trim component}}.js',
path: 'src/plays/{{generateFolderName name}}/{{pascalCase name}}.js',
templateFile: 'plop-templates/component.hbs',
},
{
Expand Down

0 comments on commit e389388

Please sign in to comment.