Features and fixes
* Fixed async code on service * Fixed html * Creating service directly when creating module
This commit is contained in:
Родитель
78ebe713d4
Коммит
1d681756fc
|
@ -27,6 +27,8 @@ yo lasagnajs:module modulename
|
|||
yo lasagnajs:service servicename
|
||||
```
|
||||
|
||||
If you create a module you will be asked if you want a service as well. If you decide so it will do all the wiring for you.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
|
@ -14,7 +14,7 @@ module.exports = yeoman.generators.NamedBase.extend({
|
|||
));
|
||||
|
||||
var prompts = [];
|
||||
if(!this.name){
|
||||
if (!this.name) {
|
||||
prompts.push({
|
||||
type: 'string',
|
||||
name: 'name',
|
||||
|
@ -31,20 +31,31 @@ module.exports = yeoman.generators.NamedBase.extend({
|
|||
|
||||
this.prompt(prompts, function (props) {
|
||||
this.props = props;
|
||||
// To access props later use this.props.someOption;
|
||||
|
||||
done();
|
||||
var that = this;
|
||||
if (props.service) {
|
||||
this.prompt([{
|
||||
type: 'string',
|
||||
name: 'name',
|
||||
message: 'What will be the name of the service?'
|
||||
}], function(moreProps){
|
||||
console.log(moreProps);
|
||||
that.props.serviceName = moreProps.name;
|
||||
done();
|
||||
})
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
writing: function () {
|
||||
console.log(this.name);
|
||||
var name = this.name || this.props.name;
|
||||
var service = this.props.service;
|
||||
var serviceName = this.props.serviceName;
|
||||
|
||||
var context = {
|
||||
name: name,
|
||||
service: service,
|
||||
serviceName: name + 'svc'
|
||||
serviceName: serviceName
|
||||
};
|
||||
|
||||
var destination = 'modules/' + name + '/';
|
||||
|
@ -74,7 +85,8 @@ module.exports = yeoman.generators.NamedBase.extend({
|
|||
}
|
||||
|
||||
if (context.service) {
|
||||
this.composeWith('lasagnajs:service', {args: [name + 'svc'], options: {name: name + 'svc', async: true}});
|
||||
console.log(serviceName);
|
||||
this.composeWith('lasagnajs:service', {args: [serviceName], options: {async: true}});
|
||||
//var route = path.resolve(__dirname, '../service/index.js');
|
||||
//console.log(route);
|
||||
//var serviceGenerator = require(route);
|
||||
|
|
|
@ -4,12 +4,12 @@ var init = function (configurator, database, logger) {
|
|||
var start = Date.now();
|
||||
var db;
|
||||
|
||||
return database.getInstance('<%= name %>')
|
||||
return database.getCollectionAsync('<%= name %>')
|
||||
.then(function(instance){
|
||||
db = instance;
|
||||
return db.getAllDocumentsAsync();
|
||||
return db.getDocumentsAsync();
|
||||
})
|
||||
.then(function(documents){
|
||||
.tap(function(documents){
|
||||
logger.log('Service <%= name %> loaded in ' + (Date.now - start)/1000);
|
||||
return {
|
||||
foo: function(){
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "generator-lasagnajs",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"description": "Yeoman generator for lasagnajs architectures",
|
||||
"license": "MIT",
|
||||
"main": "app/index.js",
|
||||
|
|
Загрузка…
Ссылка в новой задаче