add all link types .fixes #24
This commit is contained in:
parent
d3d40f94f6
commit
7b045444bd
4 changed files with 51 additions and 26 deletions
|
@ -7,7 +7,12 @@
|
||||||
<Tags>${ tags }</Tags>
|
<Tags>${ tags }</Tags>
|
||||||
<GalleryFlags>Public</GalleryFlags>
|
<GalleryFlags>Public</GalleryFlags>
|
||||||
<Properties>
|
<Properties>
|
||||||
<% if (links.repository) { %><Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="${ links.repository }" /><% } %>
|
<% if (links.repository) { %>
|
||||||
|
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="${ links.repository }" />
|
||||||
|
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="${ links.repository }" />
|
||||||
|
<% } %>
|
||||||
|
<% if (links.bugs) { %><Property Id="Microsoft.VisualStudio.Services.Links.Support" Value="${ links.bugs }" /><% } %>
|
||||||
|
<% if (links.homepage) { %><Property Id="Microsoft.VisualStudio.Services.Links.Learn" Value="${ links.homepage }" /><% } %>
|
||||||
<% if (galleryBanner.color) { %><Property Id="Microsoft.VisualStudio.Services.Branding.Color" Value="${ galleryBanner.color }" /><% } %>
|
<% if (galleryBanner.color) { %><Property Id="Microsoft.VisualStudio.Services.Branding.Color" Value="${ galleryBanner.color }" /><% } %>
|
||||||
<% if (galleryBanner.theme) { %><Property Id="Microsoft.VisualStudio.Services.Branding.Theme" Value="${ galleryBanner.theme }" /><% } %>
|
<% if (galleryBanner.theme) { %><Property Id="Microsoft.VisualStudio.Services.Branding.Theme" Value="${ galleryBanner.theme }" /><% } %>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
|
|
@ -30,7 +30,7 @@ export interface Manifest {
|
||||||
license?: string;
|
license?: string;
|
||||||
contributors?: string | Person[];
|
contributors?: string | Person[];
|
||||||
main?: string;
|
main?: string;
|
||||||
repository?: string | { type: string; url: string; };
|
repository?: string | { type?: string; url?: string; };
|
||||||
scripts?: { [name: string]: string; };
|
scripts?: { [name: string]: string; };
|
||||||
dependencies?: { [name: string]: string; };
|
dependencies?: { [name: string]: string; };
|
||||||
devDependencies?: { [name: string]: string; };
|
devDependencies?: { [name: string]: string; };
|
||||||
|
|
|
@ -70,6 +70,18 @@ export abstract class BaseProcessor implements IProcessor {
|
||||||
abstract onFile(file: IFile): Promise<IFile>;
|
abstract onFile(file: IFile): Promise<IFile>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUrl(url: string | { url?: string; }): string {
|
||||||
|
if (!url) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof url === 'string') {
|
||||||
|
return <string> url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<any> url).url;
|
||||||
|
}
|
||||||
|
|
||||||
class MainProcessor extends BaseProcessor {
|
class MainProcessor extends BaseProcessor {
|
||||||
constructor(manifest: Manifest) {
|
constructor(manifest: Manifest) {
|
||||||
super(manifest);
|
super(manifest);
|
||||||
|
@ -81,7 +93,11 @@ class MainProcessor extends BaseProcessor {
|
||||||
publisher: manifest.publisher,
|
publisher: manifest.publisher,
|
||||||
description: manifest.description || '',
|
description: manifest.description || '',
|
||||||
tags: (manifest.keywords || []).concat('vscode').join(','),
|
tags: (manifest.keywords || []).concat('vscode').join(','),
|
||||||
links: { repository: manifest.repository },
|
links: {
|
||||||
|
repository: getUrl(manifest.repository),
|
||||||
|
bugs: getUrl(manifest.bugs),
|
||||||
|
homepage: manifest.homepage
|
||||||
|
},
|
||||||
galleryBanner: manifest.galleryBanner || {}
|
galleryBanner: manifest.galleryBanner || {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,29 +177,6 @@ describe('toVsixManifest', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add repository link property', () => {
|
|
||||||
const manifest = {
|
|
||||||
name: 'test',
|
|
||||||
publisher: 'mocha',
|
|
||||||
version: '0.0.1',
|
|
||||||
description: 'test extension',
|
|
||||||
engines: Object.create(null),
|
|
||||||
homepage: 'https://homepage/test',
|
|
||||||
repository: 'https://repository/test'
|
|
||||||
};
|
|
||||||
|
|
||||||
return toVsixManifest(manifest, [])
|
|
||||||
.then(xml => parseXml(xml))
|
|
||||||
.then(result => {
|
|
||||||
assert.ok(result.PackageManifest.Metadata[0].Properties);
|
|
||||||
assert.equal(result.PackageManifest.Metadata[0].Properties.length, 1);
|
|
||||||
assert.ok(result.PackageManifest.Metadata[0].Properties[0].Property);
|
|
||||||
assert.equal(result.PackageManifest.Metadata[0].Properties[0].Property.length, 1);
|
|
||||||
assert.equal(result.PackageManifest.Metadata[0].Properties[0].Property[0].$.Id, 'Microsoft.VisualStudio.Services.Links.Source');
|
|
||||||
assert.equal(result.PackageManifest.Metadata[0].Properties[0].Property[0].$.Value, 'https://repository/test');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should add an icon metadata tag', () => {
|
it('should add an icon metadata tag', () => {
|
||||||
const manifest = {
|
const manifest = {
|
||||||
name: 'test',
|
name: 'test',
|
||||||
|
@ -293,6 +270,33 @@ describe('toVsixManifest', () => {
|
||||||
assert.ok(properties.some(p => p.Id === 'Microsoft.VisualStudio.Services.Branding.Theme' && p.Value === 'dark'));
|
assert.ok(properties.some(p => p.Id === 'Microsoft.VisualStudio.Services.Branding.Theme' && p.Value === 'dark'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should understand all link types', () => {
|
||||||
|
const manifest = {
|
||||||
|
name: 'test',
|
||||||
|
publisher: 'mocha',
|
||||||
|
version: '0.0.1',
|
||||||
|
engines: Object.create(null),
|
||||||
|
repository: {
|
||||||
|
type: "git",
|
||||||
|
url: "https://github.com/Microsoft/vscode-spell-check.git"
|
||||||
|
},
|
||||||
|
bugs: {
|
||||||
|
url: "https://github.com/Microsoft/vscode-spell-check/issues"
|
||||||
|
},
|
||||||
|
homepage: "https://github.com/Microsoft/vscode-spell-check",
|
||||||
|
};
|
||||||
|
|
||||||
|
return toVsixManifest(manifest, [])
|
||||||
|
.then(xml => parseXml(xml))
|
||||||
|
.then(result => {
|
||||||
|
const properties = result.PackageManifest.Metadata[0].Properties[0].Property.map(p => p.$);
|
||||||
|
assert.ok(properties.some(p => p.Id === 'Microsoft.VisualStudio.Services.Links.Source' && p.Value === 'https://github.com/Microsoft/vscode-spell-check.git'));
|
||||||
|
assert.ok(properties.some(p => p.Id === 'Microsoft.VisualStudio.Services.Links.Getstarted' && p.Value === 'https://github.com/Microsoft/vscode-spell-check.git'));
|
||||||
|
assert.ok(properties.some(p => p.Id === 'Microsoft.VisualStudio.Services.Links.Support' && p.Value === 'https://github.com/Microsoft/vscode-spell-check/issues'));
|
||||||
|
assert.ok(properties.some(p => p.Id === 'Microsoft.VisualStudio.Services.Links.Learn' && p.Value === 'https://github.com/Microsoft/vscode-spell-check'));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('toContentTypes', () => {
|
describe('toContentTypes', () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue