@@ -47,4 +47,53 @@ module.exports = (plop) => {
4747 } ,
4848 ] ,
4949 } ) ;
50+
51+ plop . setGenerator ( 'screen' , {
52+ description : 'Create a common screen' ,
53+ // User input prompts provided as arguments to the template
54+ prompts : [
55+ {
56+ // Raw text input
57+ type : 'input' ,
58+ // Variable name for this input
59+ name : 'name' ,
60+ // Prompt to display on command line
61+ message : 'What is your common screen name?' ,
62+ } ,
63+ ] ,
64+ actions : [
65+ {
66+ // Action type 'append' injects a template into an existing file
67+ type : 'append' ,
68+ path : 'src/screens/index.ts' ,
69+ // Pattern tells plop where in the file to inject the template
70+ pattern : `/* PLOP_INJECT_SCREEN */` ,
71+ template : `{{pascalCase name}}: { component: {{pascalCase name}}Screen },` ,
72+ } ,
73+ {
74+ // Action type 'append' injects a template into an existing file
75+ type : 'append' ,
76+ path : 'src/screens/index.ts' ,
77+ // Pattern tells plop where in the file to inject the template
78+ pattern : `/* PLOP_INJECT_IMPORT */` ,
79+ template : `import {{pascalCase name}}Screen from 'screens/{{pascalCase name}}';` ,
80+ } ,
81+ {
82+ // Action type 'append' injects a template into an existing file
83+ type : 'append' ,
84+ path : 'src/screens/index.ts' ,
85+ // Pattern tells plop where in the file to inject the template
86+ pattern : `/* PLOP_INJECT_TYPE */` ,
87+ template : `{{pascalCase name}}: undefined;` ,
88+ } ,
89+ {
90+ // Add a new file
91+ type : 'add' ,
92+ // Path for the new file
93+ path : 'src/screens/{{pascalCase name}}.tsx' ,
94+ // Handlebars template used to generate content of new file
95+ templateFile : 'plop-templates/CommonScreen.js.hbs' ,
96+ } ,
97+ ] ,
98+ } ) ;
5099} ;
0 commit comments