diff --git a/resources/extension.vsixmanifest b/resources/extension.vsixmanifest index 53dd684..ba04134 100644 --- a/resources/extension.vsixmanifest +++ b/resources/extension.vsixmanifest @@ -25,7 +25,7 @@ <% if (galleryBanner.color) { %><% } %> <% if (galleryBanner.theme) { %><% } %> - + <% if (typeof enableMarketplaceQnA === 'boolean') { %><% } %> <% if (customerQnALink) { %><% } %> <% if (license) { %><%- license %><% } %> diff --git a/src/manifest.ts b/src/manifest.ts index 227e962..8c52b28 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -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; diff --git a/src/package.ts b/src/package.ts index a6b07e1..b18f1ff 100644 --- a/src/package.ts +++ b/src/package.ts @@ -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; } } diff --git a/src/test/package.test.ts b/src/test/package.test.ts index 8a19131..3233b87 100644 --- a/src/test/package.test.ts +++ b/src/test/package.test.ts @@ -1036,42 +1036,84 @@ describe('toVsixManifest', () => { }); }); - 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) + describe('qna', () => { + it('should use marketplace qna 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'); + assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink'); }); - assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'true'); - assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink', 'https://uservoice.visualstudio.com/'); - }); + 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' + }); - it('should handle qna=false', async () => { - const xmlManifest = await toXMLManifest({ - name: 'test', - publisher: 'mocha', - version: '0.0.1', - engines: Object.create(null), - qna: false + assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA'); + assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink'); }); - assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'false'); - 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' + }); - 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'); + assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink'); }); - assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA', 'true'); - assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink', 'http://myqna'); + 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 () => { + 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 custom qna', async () => { + const xmlManifest = await toXMLManifest({ + name: 'test', + publisher: 'mocha', + version: '0.0.1', + engines: Object.create(null), + qna: 'http://myqna' + }); + + assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Services.EnableMarketplaceQnA'); + assertProperty(xmlManifest, 'Microsoft.VisualStudio.Services.CustomerQnALink', 'http://myqna'); + }); }); });