Skip to content

Commit

Permalink
* implemented 'yo duraark' with an informal message
Browse files Browse the repository at this point in the history
* small code refactoring for 'service' subgenerator
  • Loading branch information
Martin Hecher committed Feb 4, 2015
1 parent 9387b35 commit 54a6133
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 67 deletions.
80 changes: 41 additions & 39 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,52 @@ module.exports = yeoman.generators.Base.extend({

// Have Yeoman greet the user.
this.log(yosay(
'Welcome to the super-excellent' + chalk.red('Duraark') + ' generator!'
'Welcome to the super-excellent' + chalk.green('DURAARK') + ' generator.'
));

var prompts = [{
type: 'confirm',
name: 'someOption',
message: 'Would you like to enable this option?',
default: true
}];
this.log('Create a new directory and execute "yo duraark:service $NAME" to setup a SailsJS based microservice there!\n');

this.prompt(prompts, function (props) {
this.someOption = props.someOption;
// var prompts = [{
// type: 'confirm',
// name: 'someOption',
// message: 'Would you like to enable this option?',
// default: true
// }];

done();
}.bind(this));
},
// this.prompt(prompts, function (props) {
// this.someOption = props.someOption;

writing: {
app: function () {
this.fs.copy(
this.templatePath('_package.json'),
this.destinationPath('package.json')
);
this.fs.copy(
this.templatePath('_bower.json'),
this.destinationPath('bower.json')
);
},

projectfiles: function () {
this.fs.copy(
this.templatePath('editorconfig'),
this.destinationPath('.editorconfig')
);
this.fs.copy(
this.templatePath('jshintrc'),
this.destinationPath('.jshintrc')
);
}
// done();
// }.bind(this));
},

install: function () {
this.installDependencies({
skipInstall: this.options['skip-install']
});
}
// writing: {
// app: function () {
// this.fs.copy(
// this.templatePath('_package.json'),
// this.destinationPath('package.json')
// );
// this.fs.copy(
// this.templatePath('_bower.json'),
// this.destinationPath('bower.json')
// );
// },

// projectfiles: function () {
// this.fs.copy(
// this.templatePath('editorconfig'),
// this.destinationPath('.editorconfig')
// );
// this.fs.copy(
// this.templatePath('jshintrc'),
// this.destinationPath('.jshintrc')
// );
// }
// },

// install: function () {
// this.installDependencies({
// skipInstall: this.options['skip-install']
// });
// }
});
62 changes: 34 additions & 28 deletions service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var yeoman = require('yeoman-generator'),

module.exports = yeoman.generators.NamedBase.extend({
initializing: function() {
this.log('You called the Duraark subgenerator with the argument ' + this.name + '.');
this.log('Bootstrapping a SailsJS based microservice named ' + this.name + ':');

// this.argument('name', {
// required: true,
Expand All @@ -15,46 +15,52 @@ module.exports = yeoman.generators.NamedBase.extend({
this.bootstrapRoot = this.destinationRoot();
},

writing: function() {
var templateRoot = path.join(__dirname, '..', 'node_modules', 'duraark-microservice-base', 'src') + '/**',
deploymentScriptsRoot = path.join(__dirname, '..', 'node_modules', 'duraark-microservice-base', 'deployment') + '/**',
developmentScriptsRoot = path.join(__dirname, '..', 'node_modules', 'duraark-microservice-base', 'src', 'scripts') + '/**';
writing: {
copyTemplateFiles: function() {
var templateRoot = path.join(__dirname, '..', 'node_modules', 'duraark-microservice-base', 'src') + '/**';

console.log('Copying template files from "' + templateRoot + '" to "' + this.bootstrapRoot + '"');
console.log('Copying template files from "' + templateRoot + '" to "' + this.bootstrapRoot + '"');

this.fs.copy(
templateRoot,
this.bootstrapRoot
);
this.fs.copy(
templateRoot,
this.bootstrapRoot
);
},

var deploymentTarget = this.bootstrapRoot + '/deployment';
setupDeployment: function() {
var deploymentTarget = this.bootstrapRoot + '/deployment',
deploymentScriptsRoot = path.join(__dirname, '..', 'node_modules', 'duraark-microservice-base', 'deployment') + '/**';

console.log('Copying deployment scripts from "' + deploymentScriptsRoot + '" to "' + deploymentTarget + '"');
console.log('Copying deployment scripts from "' + deploymentScriptsRoot + '" to "' + deploymentTarget + '"');

this.fs.copy(
deploymentScriptsRoot,
deploymentTarget
);
this.fs.copy(
deploymentScriptsRoot,
deploymentTarget
);

var serviceInfoPath = path.join(deploymentTarget, 'service-info.txt');
var serviceInfoPath = path.join(deploymentTarget, 'service-info.txt');

console.log('Configuring deployment scripts ...');
console.log('Configuring deployment scripts ...');

this.write(serviceInfoPath, this.name);
this.write(serviceInfoPath, this.name);
},

var developmentTarget = this.bootstrapRoot + '/scripts';
setupDevelopment: function() {
var developmentTarget = this.bootstrapRoot + '/scripts',
developmentScriptsRoot = path.join(__dirname, '..', 'node_modules', 'duraark-microservice-base', 'src', 'scripts') + '/**';

console.log('Copying development scripts from "' + developmentScriptsRoot + '" to "' + developmentTarget + '"');
console.log('Copying development scripts from "' + developmentScriptsRoot + '" to "' + developmentTarget + '"');

this.fs.copy(
developmentScriptsRoot,
developmentTarget
);
this.fs.copy(
developmentScriptsRoot,
developmentTarget
);

console.log('Configuring development scripts ...');
console.log('Configuring development scripts ...');

serviceInfoPath = path.join(developmentTarget, 'service-info.txt');
var serviceInfoPath = path.join(developmentTarget, 'service-info.txt');

this.write(serviceInfoPath, this.name);
this.write(serviceInfoPath, this.name);
}
}
});

0 comments on commit 54a6133

Please sign in to comment.