Skip to content

Commit

Permalink
Merge pull request #68 from SAP/homepage
Browse files Browse the repository at this point in the history
Show 'Generator Documentation' link in generator selection
  • Loading branch information
tomer-epstein authored Dec 25, 2019
2 parents 9abb741 + 514e7ca commit 9ddae3d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions backend/src/yeomanui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface IGeneratorChoice {
name: string;
prettyName: string;
message: string;
homepage: string;
imageUrl?: string;
}

Expand Down Expand Up @@ -268,11 +269,13 @@ export class YeomanUI {

const genMessage = _.get(packageJson, "description", YeomanUI.defaultMessage);
const genPrettyName = titleize(humanizeString(genName));
const genHomepage = _.get(packageJson, "homepage", '');

return {
name: genName,
prettyName: genPrettyName,
message: genMessage,
homepage: genHomepage,
imageUrl: genImageUrl
};
}
Expand Down
30 changes: 30 additions & 0 deletions backend/tests/yeomanui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,36 @@ describe('yeomanui unit test', () => {
expect(test2Choice.prettyName).to.be.equal("Test2 Module");
expect(test3Choice.prettyName).to.be.equal("Test3");
});

it("get generators with homepage", async () => {
envMock.expects("getGeneratorsMeta").returns({
"test1-project:app": {
packagePath: "test1Path"
},
"test2-module:app": {
packagePath: "test2Path"
},
"test3:app": {
packagePath: "test3Path"
}
});
envMock.expects("getGeneratorNames").returns(["test1-project", "test2-module", "test3"]);

fsExtraMock.expects("readFile").withExactArgs(path.join("test1Path", PACKAGE_JSON), UTF8).resolves(`{"generator-filter": {"type": "project"}, "description": "test1Description", "homepage": "https://myhomepage.com/ANY/generator-test1-project#readme"}`);
fsExtraMock.expects("readFile").withExactArgs(path.join("test2Path", PACKAGE_JSON), UTF8).resolves(`{"generator-filter": {"type": "module"}, "homepage": "https://myhomepage.com/ANY/generator-test2-module#readme"}`);
fsExtraMock.expects("readFile").withExactArgs(path.join("test3Path", PACKAGE_JSON), UTF8).resolves(`{"description": "test3Description"}`);

yeomanUi.setGenFilter(GeneratorFilter.create());
const result = await yeomanUi.getGenerators();

expect(result.questions[0].choices).to.have.lengthOf(3);
const test1Choice = result.questions[0].choices[0];
const test2Choice = result.questions[0].choices[1];
const test3Choice = result.questions[0].choices[2];
expect(test1Choice.homepage).to.be.equal("https://myhomepage.com/ANY/generator-test1-project#readme");
expect(test2Choice.homepage).to.be.equal("https://myhomepage.com/ANY/generator-test2-module#readme");
expect(test3Choice.homepage).to.be.equal("");
});
});

describe("getEnv", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
tag="article"
>
<b-card-text>{{item.message}}</b-card-text>
<b-card-text class="templateDocumentationClass">Template Documentation</b-card-text>
<b-card-text class="templateDocumentationClass"><b-link :href="item.homepage">Generator Documentation</b-link></b-card-text>
<b-card-img :src="getImageUrl(item)"></b-card-img>
</b-card>
</b-col>
Expand Down
1 change: 1 addition & 0 deletions generator-foodq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Food questionnaire",
"version": "0.0.1",
"license": "Apache 2.0",
"homepage": "https://github.com/SAP/yeoman-ui/tree/master/generator-foodq#readme",
"repository": {
"type": "git",
"url": "https://github.com/SAP/yeoman-ui",
Expand Down

0 comments on commit 9ddae3d

Please sign in to comment.