Skip to content

Commit

Permalink
feat: update help card
Browse files Browse the repository at this point in the history
  • Loading branch information
SLdragon committed Jun 27, 2023
1 parent aa6a81e commit 2686777
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
24 changes: 22 additions & 2 deletions packages/api2teams/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,29 @@ export async function parseApi(yaml: string, options: CliOptions) {
}

console.log('generate help command card');
await fs.copy(

const helpCardJson = await fs.readJSON(
__dirname + '/resources/helpCard.json',
options.output + '/src/adaptiveCards/helpCard.json'
'utf8'
);

if (requestCards?.length > 0) {
helpCardJson.body.push({
type: 'TextBlock',
text: 'Supported Commands',
weight: 'Bolder'
});
for (const card of requestCards) {
if (card.content?.body?.[0]) {
helpCardJson.body.push(card.content.body[0]);
}
}
}

await fs.outputJSON(
options.output + '/src/adaptiveCards/helpCard.json',
helpCardJson,
{ spaces: 2 }
);

console.log('generate action cards');
Expand Down
24 changes: 17 additions & 7 deletions packages/api2teams/tests/unit/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,27 @@ describe('parseApi tests', () => {
pathExistsStub = sandbox.stub(fs, 'pathExists');
mkdirStub = sandbox.stub(fs, 'mkdir');
outputFileStub = sandbox.stub(fs, 'outputFile');
readJsonStub = sandbox.stub(fs, 'readJSON').resolves({
bots: [
{
commandLists: [
readJsonStub = sandbox.stub(fs, 'readJSON');
readJsonStub.callsFake((filePath: string) => {
if (filePath.indexOf("manifest.json") >= 0) {
return Promise.resolve({
bots: [
{
commands: []
commandLists: [
{
commands: []
}
]
}
]
}
]
});
} else if (filePath.indexOf('helpCard.json')) {
return Promise.resolve({});
} else {
return Promise.resolve({});
}
});

outputJsonStub = sandbox.stub(fs, 'outputJSON');
copyFileStub = sandbox.stub(fs, 'copy');
validateStub = sandbox.stub(SwaggerParser, 'validate');
Expand Down

0 comments on commit 2686777

Please sign in to comment.