adopt qna properties

This commit is contained in:
Joao Moreno 2017-05-08 15:48:57 +02:00
parent 5601c4a0c4
commit 3d1890998d
4 changed files with 71 additions and 0 deletions

View file

@ -25,6 +25,8 @@
<% if (galleryBanner.color) { %><Property Id="Microsoft.VisualStudio.Services.Branding.Color" Value="<%- galleryBanner.color %>" /><% } %>
<% if (galleryBanner.theme) { %><Property Id="Microsoft.VisualStudio.Services.Branding.Theme" Value="<%- galleryBanner.theme %>" /><% } %>
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="<%- githubMarkdown %>" />
<Property Id="Microsoft.VisualStudio.Services.EnableMarketplaceQnA" Value="<%- enableMarketplaceQnA %>" />
<% if (customerQnALink) { %><Property Id="Microsoft.VisualStudio.Services.CustomerQnALink" Value="<%- customerQnALink %>" /><% } %>
</Properties>
<% if (license) { %><License><%- license %></License><% } %>
<% if (icon) { %><Icon><%- icon %></Icon><% } %>

View file

@ -23,6 +23,7 @@ export interface Manifest {
_bundling?: { [name: string]: string; }[];
_testing?: string;
enableProposedApi?: boolean;
qna?: string | false;
// optional (npm)
author?: string | Person;

View file

@ -118,6 +118,16 @@ class ManifestProcessor extends BaseProcessor {
const repository = getRepositoryUrl(manifest.repository);
let enableMarketplaceQnA = true;
let customerQnALink = 'https://uservoice.visualstudio.com/';
if (typeof manifest.qna === 'string') {
customerQnALink = manifest.qna;
} else if (manifest.qna === false) {
enableMarketplaceQnA = false;
customerQnALink = undefined;
}
_.assign(this.vsix, {
id: manifest.name,
displayName: manifest.displayName || manifest.name,
@ -135,6 +145,8 @@ class ManifestProcessor extends BaseProcessor {
galleryBanner: manifest.galleryBanner || {},
badges: manifest.badges,
githubMarkdown: manifest.markdown !== 'standard',
enableMarketplaceQnA,
customerQnALink,
extensionDependencies: _(manifest.extensionDependencies || []).uniq().join(',')
});

View file

@ -58,6 +58,24 @@ function _toVsixManifest(manifest: Manifest, files: IFile[]): Promise<string> {
});
}
async function toXMLManifest(manifest: Manifest, files: IFile[] = []): Promise<XMLManifest> {
const raw = await _toVsixManifest(manifest, files);
return parseXmlManifest(raw);
}
function assertProperty(manifest: XMLManifest, name: string, value: string): void {
const property = manifest.PackageManifest.Metadata[0].Properties[0].Property.filter(p => p.$.Id === name);
assert.equal(property.length, 1, `Property '${name}' should exist`);
const enableMarketplaceQnA = property[0].$.Value;
assert.equal(enableMarketplaceQnA, value, `Property '${name}' should have value '${value}'`);
}
function assertMissingProperty(manifest: XMLManifest, name: string): void {
const property = manifest.PackageManifest.Metadata[0].Properties[0].Property.filter(p => p.$.Id === name);
assert.equal(property.length, 0, `Property '${name}' should not exist`);
}
describe('collect', () => {
it('should catch all files', () => {
@ -1028,6 +1046,44 @@ describe('toVsixManifest', () => {
assert(dependencies.some(d => d === 'monkey.hello'));
});
});
it('should add a qna property by default', async () => {
const xmlManifest = await toXMLManifest({
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null)
});
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'true');
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink', 'https://uservoice.visualstudio.com/');
});
it('should handle qna=false', async () => {
const xmlManifest = await toXMLManifest({
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null),
qna: false
});
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'false');
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink');
});
it('should handle qna=string', async () => {
const xmlManifest = await toXMLManifest({
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null),
qna: 'http://myqna'
});
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'true');
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink', 'http://myqna');
});
});
describe('toContentTypes', () => {