From 2e3e3bc1e4aa4661ec3ade9893ddb4e9f53a0a7e Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Thu, 18 Jul 2024 12:55:43 +0530 Subject: [PATCH] add executes code property (#1024) --- src/package.ts | 3 +++ src/test/package.test.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/package.ts b/src/package.ts index 70c74d21..3748df9a 100644 --- a/src/package.ts +++ b/src/package.ts @@ -200,6 +200,7 @@ export interface VSIX { preRelease: boolean; sponsorLink: string; pricing: string; + executesCode:boolean; } export class BaseProcessor implements IProcessor { @@ -547,6 +548,7 @@ export class ManifestProcessor extends BaseProcessor { : '', enabledApiProposals: manifest.enabledApiProposals ? manifest.enabledApiProposals.join(',') : '', preRelease: !!this.options.preRelease, + executesCode: !!(manifest.main ?? manifest.browser), sponsorLink: manifest.sponsor?.url || '', }; @@ -1482,6 +1484,7 @@ export async function toVsixManifest(vsix: VSIX): Promise { ${vsix.preRelease ? `` : ''} + ${vsix.executesCode ? `` : ''} ${vsix.sponsorLink ? `` : '' diff --git a/src/test/package.test.ts b/src/test/package.test.ts index f842fb27..52d206a6 100644 --- a/src/test/package.test.ts +++ b/src/test/package.test.ts @@ -1848,6 +1848,35 @@ describe('toVsixManifest', () => { assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease', 'true'); }); + it('should add executes code property when main is passed', async () => { + const manifest = createManifest({ main: 'main.js' }); + const files = [{ path: 'extension/main.js', contents: Buffer.from('') }]; + + const raw = await _toVsixManifest(manifest, files); + const xmlManifest = await parseXmlManifest(raw); + + assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.ExecutesCode', 'true'); + }); + + it('should add executes code property when browser is passed', async () => { + const manifest = createManifest({ browser: 'browser.js' }); + const files = [{ path: 'extension/browser.js', contents: Buffer.from('') }]; + + const raw = await _toVsixManifest(manifest, files); + const xmlManifest = await parseXmlManifest(raw); + + assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.ExecutesCode', 'true'); + }); + + it('should not add executes code property when neither main nor browser is passed', async () => { + const manifest = createManifest(); + + const raw = await _toVsixManifest(manifest, []); + const xmlManifest = await parseXmlManifest(raw); + + assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Code.ExecutesCode'); + }); + it('should add sponsor link property', () => { const sponsor = { url: 'https://foo.bar' }; const manifest: Manifest = {