diff --git a/src/manifest.ts b/src/manifest.ts index 12406ba6..50483aa7 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -60,6 +60,7 @@ export interface Manifest { enabledApiProposals?: readonly string[]; qna?: 'marketplace' | string | false; extensionKind?: ExtensionKind | ExtensionKind[]; + sponsor?: string; // optional (npm) author?: string | Person; diff --git a/src/package.ts b/src/package.ts index 29bb1369..f6845fff 100644 --- a/src/package.ts +++ b/src/package.ts @@ -128,6 +128,7 @@ export interface VSIX { extensionKind: string; localizedLanguages: string; preRelease: boolean; + sponsorLink: string; } export class BaseProcessor implements IProcessor { @@ -453,6 +454,7 @@ export class ManifestProcessor extends BaseProcessor { .join(',') : '', preRelease: !!this.options.preRelease, + sponsorLink: manifest.sponsor || '', }; if (isGitHub) { @@ -603,6 +605,7 @@ export class TagsProcessor extends BaseProcessor { ); const webExensionTags = isWebKind(this.manifest) ? ['__web_extension'] : []; + const sponsorTags = this.manifest.sponsor ? ['__sponsor_extension'] : []; const tags = new Set([ ...keywords, @@ -620,6 +623,7 @@ export class TagsProcessor extends BaseProcessor { ...grammars, ...descriptionKeywords, ...webExensionTags, + ...sponsorTags, ]); this.tags = [...tags].filter(tag => !!tag); @@ -1299,6 +1303,11 @@ export async function toVsixManifest(vsix: VSIX): Promise { ${vsix.preRelease ? `` : ''} + ${ + vsix.sponsorLink + ? `` + : '' + } ${ !vsix.links.repository ? '' diff --git a/src/test/package.test.ts b/src/test/package.test.ts index 3cd904db..dc8eed0c 100644 --- a/src/test/package.test.ts +++ b/src/test/package.test.ts @@ -1660,6 +1660,34 @@ describe('toVsixManifest', () => { assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease', 'true'); }); + it('should add sponsor link property', () => { + const sponsor = 'https://foo.bar'; + const manifest: Manifest = { + name: 'test', + publisher: 'mocha', + version: '0.0.1', + description: 'test extension', + engines: Object.create(null), + sponsor, + }; + + return _toVsixManifest(manifest, []) + .then(parseXmlManifest) + .then(result => { + const properties = result.PackageManifest.Metadata[0].Properties[0].Property; + const sponsorLinkProp = properties.find(p => p.$.Id === 'Microsoft.VisualStudio.Code.SponsorLink'); + assert.strictEqual(sponsorLinkProp?.$.Value, sponsor); + }); + }); + + it('should automatically add sponsor tag for extension with sponsor link', async () => { + const manifest = createManifest({ sponsor: 'https://foo.bar' }); + const vsixManifest = await _toVsixManifest(manifest, []); + const result = await parseXmlManifest(vsixManifest); + + assert.ok(result.PackageManifest.Metadata[0].Tags[0].split(',').includes('__sponsor_extension')); + }); + it('should add prerelease property when --pre-release flag is passed when engine property is for insiders', async () => { const manifest = createManifest({ engines: { vscode: '>=1.64.0-insider' } });