fix qna property

This commit is contained in:
Joao Moreno 2017-05-11 09:48:09 +02:00
parent 6078d6b3e8
commit 928e70bdf5
4 changed files with 79 additions and 35 deletions

View file

@ -25,7 +25,7 @@
<% 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 (typeof enableMarketplaceQnA === 'boolean') { %><Property Id="Microsoft.VisualStudio.Services.EnableMarketplaceQnA" Value="<%- enableMarketplaceQnA %>" /><% } %>
<% if (customerQnALink) { %><Property Id="Microsoft.VisualStudio.Services.CustomerQnALink" Value="<%- customerQnALink %>" /><% } %>
</Properties>
<% if (license) { %><License><%- license %></License><% } %>

View file

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

View file

@ -117,15 +117,17 @@ class ManifestProcessor extends BaseProcessor {
}
const repository = getRepositoryUrl(manifest.repository);
const isGitHub = /^https:\/\/github\.com\/|^git@github\.com:/.test(repository || '');
let enableMarketplaceQnA = true;
let customerQnALink = 'https://uservoice.visualstudio.com/';
let enableMarketplaceQnA: boolean | undefined;
let customerQnALink: string | undefined;
if (typeof manifest.qna === 'string') {
if (manifest.qna === 'marketplace' || (typeof manifest.qna === 'undefined' && !isGitHub)) {
enableMarketplaceQnA = true;
} else if (typeof manifest.qna === 'string') {
customerQnALink = manifest.qna;
} else if (manifest.qna === false) {
enableMarketplaceQnA = false;
customerQnALink = undefined;
}
_.assign(this.vsix, {
@ -150,7 +152,7 @@ class ManifestProcessor extends BaseProcessor {
extensionDependencies: _(manifest.extensionDependencies || []).uniq().join(',')
});
if (/^https:\/\/github\.com\/|^git@github\.com:/.test(repository)) {
if (isGitHub) {
this.vsix.links.github = repository;
}
}

View file

@ -1036,7 +1036,8 @@ describe('toVsixManifest', () => {
});
});
it('should add a qna property by default', async () => {
describe('qna', () => {
it('should use marketplace qna by default', async () => {
const xmlManifest = await toXMLManifest({
name: 'test',
publisher: 'mocha',
@ -1045,7 +1046,47 @@ describe('toVsixManifest', () => {
});
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'true');
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink', 'https://uservoice.visualstudio.com/');
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink');
});
it('should not use marketplace in a github repo, without specifying it', async () => {
const xmlManifest = await toXMLManifest({
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null),
repository: 'https://github.com/username/repository'
});
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA');
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink');
});
it('should use marketplace in a github repo, when specifying it', async () => {
const xmlManifest = await toXMLManifest({
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null),
repository: 'https://github.com/username/repository',
qna: 'marketplace'
});
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'true');
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink');
});
it('should handle qna=marketplace', async () => {
const xmlManifest = await toXMLManifest({
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null),
qna: 'marketplace'
});
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'true');
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink');
});
it('should handle qna=false', async () => {
@ -1061,7 +1102,7 @@ describe('toVsixManifest', () => {
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink');
});
it('should handle qna=string', async () => {
it('should handle custom qna', async () => {
const xmlManifest = await toXMLManifest({
name: 'test',
publisher: 'mocha',
@ -1070,9 +1111,10 @@ describe('toVsixManifest', () => {
qna: 'http://myqna'
});
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'true');
assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA');
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink', 'http://myqna');
});
});
});
describe('toContentTypes', () => {