add license metadata tag
This commit is contained in:
parent
37458356d4
commit
0d9d4822f5
3 changed files with 33 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
|||
<Description xml:space="preserve">${ description }</Description>
|
||||
<Tags>${ tags }</Tags>
|
||||
<GalleryFlags>Public</GalleryFlags>
|
||||
<% if (license) { %><License>${ license }</License><% } %>
|
||||
</Metadata>
|
||||
<Installation>
|
||||
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
|
||||
|
|
|
@ -102,17 +102,19 @@ function getLicenseFilter(manifest:Manifest): (name: string) => boolean {
|
|||
export function toVsixManifest(manifest: Manifest, files: IFile[]): Promise<string> {
|
||||
const licenseFilter = getLicenseFilter(manifest);
|
||||
|
||||
const assets = files.map<IAsset>(f => {
|
||||
const assets: IAsset[] = [];
|
||||
let license: string = null;
|
||||
|
||||
files.forEach(f => {
|
||||
if (/^extension\/README.md$/i.test(f.path)) {
|
||||
return { type: 'Microsoft.VisualStudio.Services.Content.Details', path: f.path };
|
||||
assets.push({ type: 'Microsoft.VisualStudio.Services.Content.Details', path: f.path });
|
||||
}
|
||||
|
||||
if (licenseFilter(f.path)) {
|
||||
return { type: 'Microsoft.VisualStudio.Services.Content.License', path: f.path };
|
||||
assets.push({ type: 'Microsoft.VisualStudio.Services.Content.License', path: f.path });
|
||||
license = f.path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}).filter(f => !!f);
|
||||
});
|
||||
|
||||
return readFile(vsixManifestTemplatePath, 'utf8')
|
||||
.then(vsixManifestTemplateStr => _.template(vsixManifestTemplateStr))
|
||||
|
@ -123,6 +125,7 @@ export function toVsixManifest(manifest: Manifest, files: IFile[]): Promise<stri
|
|||
publisher: manifest.publisher,
|
||||
description: manifest.description || '',
|
||||
tags: (manifest.keywords || []).concat('vscode').join(';'),
|
||||
license,
|
||||
assets
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -134,6 +134,29 @@ describe('toVsixManifest', () => {
|
|||
assert.equal(result.PackageManifest.Assets[0].Asset[1].$.Path, 'extension/thelicense.md');
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a license metadata tag', () => {
|
||||
const manifest = {
|
||||
name: 'test',
|
||||
publisher: 'mocha',
|
||||
version: '0.0.1',
|
||||
description: 'test extension',
|
||||
license: 'SEE LICENSE IN thelicense.md',
|
||||
engines: Object.create(null)
|
||||
};
|
||||
|
||||
const files = [
|
||||
{ path: 'extension/thelicense.md' }
|
||||
];
|
||||
|
||||
return toVsixManifest(manifest, files)
|
||||
.then(xml => parseXml(xml))
|
||||
.then(result => {
|
||||
assert.ok(result.PackageManifest.Metadata[0].License);
|
||||
assert.equal(result.PackageManifest.Metadata[0].License.length, 1);
|
||||
assert.equal(result.PackageManifest.Metadata[0].License[0], 'extension/thelicense.md');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('toContentTypes', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue