Skip to content

Commit

Permalink
feat(gen): prompt for module name when config.modulePrompt
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcody committed Sep 17, 2015
1 parent d70eba6 commit 3bd75b3
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 85 deletions.
2 changes: 2 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var NgComponentGenerator = yeoman.generators.Base.extend({
'serviceDirectory': this.options.serviceDirectory || 'app/components/',
'basePath': this.options.basePath || 'app',
'moduleName': this.options.moduleName || '',
'modulePrompt': this.options.hasOwnProperty('modulePrompt') ?
this.options.modulePrompt : true,
'filters': this.options.filters || ['uirouter', 'jasmine'],
'extensions': this.options.extensions || ['js', 'html', 'scss'],
'directiveSimpleTemplates': this.options.directiveSimple || '',
Expand Down
22 changes: 13 additions & 9 deletions controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ util.inherits(Generator, ScriptBase);
Generator.prototype.prompting = function askFor() {
var self = this;
var done = this.async();
var prompts = [
{
name: 'dir',
message: 'Where would you like to create this controller?',
default: self.config.get('routeDirectory')
}
];
var prompts = [{
name: 'moduleName',
message: 'What module name would you like to use?',
default: self.scriptAppName + '.' + self.name,
when: function() {return self.config.get('modulePrompt');}
}, {
name: 'dir',
message: 'Where would you like to create this controller?',
default: self.config.get('routeDirectory')
}];

this.prompt(prompts, function (props) {
this.dir = path.join(props.dir, this.name);
self.scriptAppName = props.moduleName || self.scriptAppName;
self.dir = path.join(props.dir, self.name);
done();
}.bind(this));
});
};

Generator.prototype.writing = function createFiles() {
Expand Down
22 changes: 13 additions & 9 deletions decorator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ util.inherits(Generator, ScriptBase);
Generator.prototype.prompting = function askFor() {
var self = this;
var done = this.async();
var prompts = [
{
name: 'dir',
message: 'Where would you like to create this decorator?',
default: self.config.get('serviceDirectory')
}
];
var prompts = [{
name: 'moduleName',
message: 'What module name would you like to use?',
default: self.scriptAppName + '.' + self.name,
when: function() {return self.config.get('modulePrompt');}
}, {
name: 'dir',
message: 'Where would you like to create this decorator?',
default: self.config.get('serviceDirectory')
}];

this.prompt(prompts, function (props) {
this.dir = path.join(props.dir, this.name);
self.scriptAppName = props.moduleName || self.scriptAppName;
self.dir = path.join(props.dir, self.name);
done();
}.bind(this));
});
};

Generator.prototype.writing = function createFiles() {
Expand Down
35 changes: 19 additions & 16 deletions directive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,28 @@ Generator.prototype.prompting = function askFor() {
var self = this;
var done = this.async();

var prompts = [
{
name: 'dir',
message: 'Where would you like to create this directive?',
default: self.config.get('directiveDirectory')
},
{
type:'confirm',
name: 'complex',
message: 'Does this directive need an external html file?',
default: true
}
];
var prompts = [{
name: 'moduleName',
message: 'What module name would you like to use?',
default: self.scriptAppName + '.' + self.name,
when: function() {return self.config.get('modulePrompt');}
}, {
name: 'dir',
message: 'Where would you like to create this directive?',
default: self.config.get('directiveDirectory')
}, {
type:'confirm',
name: 'complex',
message: 'Does this directive need an external html file?',
default: true
}];

this.prompt(prompts, function (props) {
this.dir = path.join(props.dir, this.name);
this.complex = props.complex;
self.scriptAppName = props.moduleName || self.scriptAppName;
self.dir = path.join(props.dir, self.name);
self.complex = props.complex;
done();
}.bind(this));
});
};

Generator.prototype.writing = function createFiles() {
Expand Down
22 changes: 13 additions & 9 deletions factory/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ util.inherits(Generator, ScriptBase);
Generator.prototype.prompting = function askFor() {
var self = this;
var done = this.async();
var prompts = [
{
name: 'dir',
message: 'Where would you like to create this factory?',
default: self.config.get('serviceDirectory')
}
];
var prompts = [{
name: 'moduleName',
message: 'What module name would you like to use?',
default: self.scriptAppName + '.' + self.name,
when: function() {return self.config.get('modulePrompt');}
}, {
name: 'dir',
message: 'Where would you like to create this factory?',
default: self.config.get('serviceDirectory')
}];

this.prompt(prompts, function (props) {
this.dir = path.join(props.dir, this.name);
self.scriptAppName = props.moduleName || self.scriptAppName;
self.dir = path.join(props.dir, self.name);
done();
}.bind(this));
});
};

Generator.prototype.writing = function createFiles() {
Expand Down
22 changes: 13 additions & 9 deletions filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ util.inherits(Generator, ScriptBase);
Generator.prototype.prompting = function askFor() {
var self = this;
var done = this.async();
var prompts = [
{
name: 'dir',
message: 'Where would you like to create this filter?',
default: self.config.get('filterDirectory')
}
];
var prompts = [{
name: 'moduleName',
message: 'What module name would you like to use?',
default: self.scriptAppName + '.' + self.name,
when: function() {return self.config.get('modulePrompt');}
}, {
name: 'dir',
message: 'Where would you like to create this filter?',
default: self.config.get('filterDirectory')
}];

this.prompt(prompts, function (props) {
this.dir = path.join(props.dir, this.name);
self.scriptAppName = props.moduleName || self.scriptAppName;
self.dir = path.join(props.dir, self.name);
done();
}.bind(this));
});
};

Generator.prototype.writing = function createFiles() {
Expand Down
22 changes: 13 additions & 9 deletions provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ util.inherits(Generator, ScriptBase);
Generator.prototype.prompting = function askFor() {
var self = this;
var done = this.async();
var prompts = [
{
name: 'dir',
message: 'Where would you like to create this provider?',
default: self.config.get('serviceDirectory')
}
];
var prompts = [{
name: 'moduleName',
message: 'What module name would you like to use?',
default: self.scriptAppName + '.' + self.name,
when: function() {return self.config.get('modulePrompt');}
}, {
name: 'dir',
message: 'Where would you like to create this provider?',
default: self.config.get('serviceDirectory')
}];

this.prompt(prompts, function (props) {
this.dir = path.join(props.dir, this.name);
self.scriptAppName = props.moduleName || self.scriptAppName;
self.dir = path.join(props.dir, self.name);
done();
}.bind(this));
});
};

Generator.prototype.writing = function createFiles() {
Expand Down
33 changes: 18 additions & 15 deletions route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,27 @@ Generator.prototype.prompting = function askFor() {
var name = this.name;

var done = this.async();
var prompts = [
{
name: 'dir',
message: 'Where would you like to create this route?',
default: self.config.get('routeDirectory')
},
{
name: 'route',
message: 'What will the url of your route be?',
default: '/' + name
}
];
var prompts = [{
name: 'moduleName',
message: 'What module name would you like to use?',
default: self.scriptAppName + '.' + self.name,
when: function() {return self.config.get('modulePrompt');}
}, {
name: 'dir',
message: 'Where would you like to create this route?',
default: self.config.get('routeDirectory')
}, {
name: 'route',
message: 'What will the url of your route be?',
default: '/' + name
}];

this.prompt(prompts, function (props) {
this.route = props.route;
this.dir = path.join(props.dir, this.name);
self.scriptAppName = props.moduleName || self.scriptAppName;
self.route = props.route;
self.dir = path.join(props.dir, self.name);
done();
}.bind(this));
});
};

Generator.prototype.writing = function createFiles() {
Expand Down
22 changes: 13 additions & 9 deletions service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ util.inherits(Generator, ScriptBase);
Generator.prototype.prompting = function askFor() {
var self = this;
var done = this.async();
var prompts = [
{
name: 'dir',
message: 'Where would you like to create this service?',
default: self.config.get('serviceDirectory')
}
];
var prompts = [{
name: 'moduleName',
message: 'What module name would you like to use?',
default: self.scriptAppName + '.' + self.name,
when: function() {return self.config.get('modulePrompt');}
}, {
name: 'dir',
message: 'Where would you like to create this service?',
default: self.config.get('serviceDirectory')
}];

this.prompt(prompts, function (props) {
this.dir = path.join(props.dir, this.name);
self.scriptAppName = props.moduleName || self.scriptAppName;
self.dir = path.join(props.dir, self.name);
done();
}.bind(this));
});
};

Generator.prototype.writing = function createFiles() {
Expand Down

0 comments on commit 3bd75b3

Please sign in to comment.