support gallery badges

This commit is contained in:
Joao Moreno 2016-07-19 16:21:10 +02:00
parent 3ec04ebf1d
commit a6d008f1be
4 changed files with 32 additions and 2 deletions

View file

@ -7,6 +7,7 @@
<Tags><%- tags %></Tags>
<Categories><%- categories %></Categories>
<GalleryFlags><%- flags %></GalleryFlags>
<Badges><% _.forEach(badges, function (badge) { %><Badge Link="<%- badge.href %>" ImgUri="<%- badge.url %>" Description="<%- badge.description %>" /><% }); %></Badges>
<Properties>
<% if (links.repository) { %>
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="<%- links.repository %>" />

View file

@ -18,6 +18,7 @@ export interface Manifest {
extensionDependencies?: string[];
galleryBanner?: { color?: string; theme?: string; };
preview?: boolean;
badges?: { url: string; href: string; description: string; }[];
_bundling?: { [name: string]: string; }[];
_testing?: string;

View file

@ -131,7 +131,8 @@ class ManifestProcessor extends BaseProcessor {
bugs: getUrl(manifest.bugs),
homepage: manifest.homepage
},
galleryBanner: manifest.galleryBanner || {}
galleryBanner: manifest.galleryBanner || {},
badges: manifest.badges
});
if (/^https:\/\/github\.com\/|^git@github\.com:/.test(repository)) {

View file

@ -27,7 +27,8 @@ type XMLManifest = {
License: string[],
Icon: string[],
Properties: { Property: { $: { Id: string, Value: string } }[] }[],
Categories: string[]
Categories: string[],
Badges: { Badge: { $: { Link: string, ImgUri: string, Description: string } }[] }[]
}[],
Installation: { InstallationTarget: { $: { Id: string } }[] }[]
Dependencies: string[]
@ -745,6 +746,32 @@ describe('toVsixManifest', () => {
assert(tags.some(tag => tag === '__ext_golang'));
});
});
it('should understand badges', () => {
const manifest = {
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null),
badges: [
{ url: 'http://badgeurl.png', href: 'http://badgeurl', description: 'this is a badge' },
{ url: 'http://anotherbadgeurl.png', href: 'http://anotherbadgeurl', description: 'this is another badge' }
]
};
return _toVsixManifest(manifest, [])
.then(xml => parseXmlManifest(xml))
.then(result => {
const badges = result.PackageManifest.Metadata[0].Badges[0].Badge;
assert.equal(badges.length, 2);
assert.equal(badges[0].$.Link, 'http://badgeurl');
assert.equal(badges[0].$.ImgUri, 'http://badgeurl.png');
assert.equal(badges[0].$.Description, 'this is a badge');
assert.equal(badges[1].$.Link, 'http://anotherbadgeurl');
assert.equal(badges[1].$.ImgUri, 'http://anotherbadgeurl.png');
assert.equal(badges[1].$.Description, 'this is another badge');
});
});
});
describe('toContentTypes', () => {