interpret icon #7
This commit is contained in:
parent
b3955b5929
commit
2d1bd25b39
4 changed files with 56 additions and 6 deletions
|
@ -6,10 +6,11 @@
|
|||
<Description xml:space="preserve">${ description }</Description>
|
||||
<Tags>${ tags }</Tags>
|
||||
<GalleryFlags>Public</GalleryFlags>
|
||||
<% if (license) { %><License>${ license }</License><% } %>
|
||||
<Properties>
|
||||
<% if (links.homepage) { %><Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="${ links.homepage }" /><% } %>
|
||||
</Properties>
|
||||
<% if (license) { %><License>${ license }</License><% } %>
|
||||
<% if (icon) { %><Icon>${ icon }</Icon><% } %>
|
||||
</Metadata>
|
||||
<Installation>
|
||||
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
|
||||
|
|
|
@ -12,6 +12,7 @@ export interface Manifest {
|
|||
|
||||
// vscode
|
||||
publisher: string;
|
||||
icon?: string;
|
||||
contributes?: { [contributionType: string]: any; };
|
||||
activationEvents?: string[];
|
||||
extensionDependencies?: string[];
|
||||
|
|
|
@ -102,9 +102,11 @@ function getLicenseFilter(manifest:Manifest): (name: string) => boolean {
|
|||
|
||||
export function toVsixManifest(manifest: Manifest, files: IFile[]): Promise<string> {
|
||||
const licenseFilter = getLicenseFilter(manifest);
|
||||
const icon = manifest.icon ? `extension/${ manifest.icon }` : null;
|
||||
|
||||
const assets: IAsset[] = [];
|
||||
let license: string = null;
|
||||
let foundIcon: boolean = false;
|
||||
|
||||
files.forEach(f => {
|
||||
if (/^extension\/README.md$/i.test(f.path)) {
|
||||
|
@ -115,12 +117,13 @@ export function toVsixManifest(manifest: Manifest, files: IFile[]): Promise<stri
|
|||
assets.push({ type: 'Microsoft.VisualStudio.Services.Content.License', path: f.path });
|
||||
license = f.path;
|
||||
}
|
||||
|
||||
if (f.path === icon) {
|
||||
assets.push({ type: 'Microsoft.VisualStudio.Services.Icons.Default', path: f.path });
|
||||
foundIcon = true;
|
||||
}
|
||||
});
|
||||
|
||||
const links = {
|
||||
homepage: manifest.homepage
|
||||
};
|
||||
|
||||
return readFile(vsixManifestTemplatePath, 'utf8')
|
||||
.then(vsixManifestTemplateStr => _.template(vsixManifestTemplateStr))
|
||||
.then(vsixManifestTemplate => vsixManifestTemplate({
|
||||
|
@ -132,7 +135,8 @@ export function toVsixManifest(manifest: Manifest, files: IFile[]): Promise<stri
|
|||
tags: (manifest.keywords || []).concat('vscode').join(';'),
|
||||
license,
|
||||
assets,
|
||||
links
|
||||
links: { homepage: manifest.homepage },
|
||||
icon: foundIcon ? icon : null
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -179,6 +179,50 @@ describe('toVsixManifest', () => {
|
|||
assert.equal(result.PackageManifest.Metadata[0].Properties[0].Property[0].$.Value, 'https://homepage/test');
|
||||
});
|
||||
});
|
||||
|
||||
it('should add an icon metadata tag', () => {
|
||||
const manifest = {
|
||||
name: 'test',
|
||||
publisher: 'mocha',
|
||||
version: '0.0.1',
|
||||
description: 'test extension',
|
||||
engines: Object.create(null),
|
||||
icon: 'fake.png'
|
||||
};
|
||||
|
||||
const files = [
|
||||
{ path: 'extension/fake.png' }
|
||||
];
|
||||
|
||||
return toVsixManifest(manifest, files)
|
||||
.then(xml => parseXml(xml))
|
||||
.then(result => {
|
||||
assert.ok(result.PackageManifest.Metadata[0].Icon);
|
||||
assert.equal(result.PackageManifest.Metadata[0].Icon.length, 1);
|
||||
assert.equal(result.PackageManifest.Metadata[0].Icon[0], 'extension/fake.png');
|
||||
});
|
||||
});
|
||||
|
||||
it('should add an icon asset', () => {
|
||||
const manifest = {
|
||||
name: 'test',
|
||||
publisher: 'mocha',
|
||||
version: '0.0.1',
|
||||
description: 'test extension',
|
||||
engines: Object.create(null),
|
||||
icon: 'fake.png'
|
||||
};
|
||||
|
||||
const files = [
|
||||
{ path: 'extension/fake.png' }
|
||||
];
|
||||
|
||||
return toVsixManifest(manifest, files)
|
||||
.then(xml => parseXml(xml))
|
||||
.then(result => {
|
||||
assert.ok(result.PackageManifest.Assets[0].Asset.some(d => d.$.Type === 'Microsoft.VisualStudio.Services.Icons.Default' && d.$.Path === 'extension/fake.png'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('toContentTypes', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue