Skip to content

Commit

Permalink
Added addon generator type choice (closes #281)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Mar 26, 2018
1 parent 5d9cede commit a87da2b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
6 changes: 5 additions & 1 deletion generators/addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,9 @@ module.exports = Generator.make({
baseDir: __dirname,
generator: NgxAddonGenerator,
options,
prompts
prompts,
prefixRules: Object.assign(Generator.defaultPrefixRules, {
'fullstack': props => props.type === 'fullstack',
'not-fullstack': props => props.type !== 'fullstack',
})
});
20 changes: 20 additions & 0 deletions generators/addon/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ module.exports = [
message: 'Who\'s the author?',
default: 'Your name'
},
{
type: 'list',
name: 'type',
message: 'What kind of add-on do you want to create?',
choices: [
{
value: 'client',
name: 'Client'
},
{
value: 'server',
name: 'Server'
},
{
value: 'fullstack',
name: 'Full stack'
}
],
default: 'client'
},
{
type: 'confirm',
name: 'advanced',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Server template

Put your server templates in this folder
3 changes: 3 additions & 0 deletions generators/addon/templates/generators/app/_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ module.exports = Generator.make({
generator: <%= props.className %>Generator,
<% } -%>

// The type of your generator, can be 'client', 'server' or 'fullstack' (optional)
type: '<%= props.type -%>',

// Your generator prompts (optional)
// See https://github.com/sboudrias/Inquirer.js#objects for details
prompts: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# <%= props.appName // From shared properties %>

<% if (props.sayHello) { -%>
Hello <%= props.helloName %>, from an awesome ngX-Rocket add-on!
<% } else { -%>
...was not in the mood to say hello :-(
<% }-%>

0 comments on commit a87da2b

Please sign in to comment.