Skip to content

Commit

Permalink
Add support for module group
Browse files Browse the repository at this point in the history
Fix issue #82 add for module group according to helix spec.
  • Loading branch information
istern authored and Saturate committed Mar 7, 2017
1 parent fc86b8a commit 91602d4
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 8 deletions.
33 changes: 26 additions & 7 deletions generators/add/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,38 @@ module.exports = class extends yeoman {
}, {
name: 'Project layer?',
value: 'Project'
}]
},
],
}];

this.prompt(questions).then((answers) => {
this.layer = answers.layer;



if (this.settings.VendorPrefix === '' || this.settings.VendorPrefix === undefined ) {
this.settings.LayerPrefixedProjectName = `${this.layer}.${this.settings.ProjectName}`
this.settings.LayerPrefixedProjectName = `${this.layer}.${this.settings.ProjectName}`;
} else {
this.settings.LayerPrefixedProjectName = `${this.settings.VendorPrefix}.${this.layer}.${this.settings.ProjectName}`
this.settings.LayerPrefixedProjectName = `${this.settings.VendorPrefix}.${this.layer}.${this.settings.ProjectName}`;
}

done();
});
}

askForModuleGroup() {
const done = this.async();
const questions = [{
type:'input',
name: 'modulegroup',
message: 'Enter optional Module Group '
}];

this.prompt(questions).then((answers) => {
this.modulegroup = answers.modulegroup ? answers.modulegroup : '';
done();
});
}

askTargetFrameworkVersion() {
const done = this.async();
const questions = [{
Expand Down Expand Up @@ -117,7 +133,7 @@ module.exports = class extends yeoman {
this.templatedata.vendorprefix = this.settings.VendorPrefix;
this.templatedata.projectguid = guid.v4();
this.templatedata.layer = this.layer;
this.templatedata.lowercasedlayer = this.layer.toLowerCase();;
this.templatedata.lowercasedlayer = this.layer.toLowerCase();
this.templatedata.target = this.target;
}

Expand Down Expand Up @@ -168,7 +184,10 @@ module.exports = class extends yeoman {
}

_copySolutionSpecificItems(){
this.fs.copyTpl(this.destinationPath('helix-template/**/*'), this.destinationPath(this.settings.ProjectPath), this.templatedata);
this.fs.copyTpl(
this.destinationPath('helix-template/**/*'),
this.destinationPath(this.settings.ProjectPath),
this.templatedata);
}

_renameProjectFile() {
Expand Down Expand Up @@ -197,7 +216,7 @@ module.exports = class extends yeoman {
}

writing() {
this.settings.ProjectPath = path.join(this.settings.sourceFolder, this.layer, this.settings.ProjectName, 'code' );
this.settings.ProjectPath = path.join(this.settings.sourceFolder, this.layer, this.modulegroup, this.settings.ProjectName, 'code' );
this._copyProjectItems();

if(this.settings.serialization) {
Expand Down
69 changes: 69 additions & 0 deletions test/test-add-modulegroup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*global describe, it*/
'use strict';

var path = require('path');
var helpers = require('yeoman-test');
var assert = require('yeoman-assert');

describe('yo helix:add modulegroup', function () {

it('Can add on a emptyhelix solution with modulegroup', function checkFiles (done) {
helpers.run(path.join(__dirname, '../generators/add'))
.inTmpDir(function () {
var doneParent = this.async(); // `this` is the RunContext object.
helpers.run(path.join(__dirname, '../generators/app'))
.withPrompts({
SolutionType: 'emptyhelix',
SolutionName: 'UnitTest',
target: 'v4.6.1'
}).then(() => {
doneParent();
});
})
.withPrompts({
ProjectName: 'AddedProjectFeatureName',
VendorPrefix: 'Acme',
layer: 'Feature',
modulegroup: 'Login'
}).then(() => {

assert.file([
'./src/Feature/Login/AddedProjectFeatureName/code/Acme.Feature.AddedProjectFeatureName.csproj'
]);

done();
});

});

it('Can add on a pentia solution with empty modulegroup', function checkFiles (done) {
// This test might seem unnecessary. But when you run the code normally an empty value from the prompt is an empty string,
// but in a test context it's 'undefined'
helpers.run(path.join(__dirname, '../generators/add'))
.inTmpDir(function () {
var doneParent = this.async(); // `this` is the RunContext object.
helpers.run(path.join(__dirname, '../generators/app'))
.withPrompts({
SolutionType: 'pentiahelix',
SolutionName: 'UnitTest',
target: 'v4.6.1'
}).then(() => {
doneParent();
});
})
.withPrompts({
ProjectName: 'AddedProjectFeatureName',
VendorPrefix: '',
layer: 'Feature',
modulegroup: 'Login'
}).then(() => {

assert.file([
'./src/Feature/Login/AddedProjectFeatureName/code/Feature.AddedProjectFeatureName.csproj'
]);

done();
});

});
});
1 change: 0 additions & 1 deletion test/test-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,5 @@ describe('yo helix:add', function () {

done();
});

});
});

0 comments on commit 91602d4

Please sign in to comment.