detect keywords in description
This commit is contained in:
parent
7f5386ef2f
commit
144911a9ac
2 changed files with 67 additions and 4 deletions
|
@ -120,6 +120,45 @@ class ManifestProcessor extends BaseProcessor {
|
|||
|
||||
export class TagsProcessor extends BaseProcessor {
|
||||
|
||||
private static Keywords = {
|
||||
'git': ['git'],
|
||||
'npm': ['node'],
|
||||
'spell': ['markdown'],
|
||||
'bootstrap': ['bootstrap'],
|
||||
'lint': ['linters'],
|
||||
'linting': ['linters'],
|
||||
'react': ['javascript'],
|
||||
'js': ['javsacript'],
|
||||
'node': ['javascript', 'node'],
|
||||
'C plus plus': ['c++'],
|
||||
'Cplusplus': ['c++'],
|
||||
'xml': ['xml'],
|
||||
'angular': ['javascript'],
|
||||
'jquery': ['javascript'],
|
||||
'php': ['php'],
|
||||
'python': ['python'],
|
||||
'latex': ['latex'],
|
||||
'ruby': ['ruby'],
|
||||
'java': ['java'],
|
||||
'erlang': ['erlang'],
|
||||
'sql': ['sql'],
|
||||
'nodejs': ['node'],
|
||||
'c#': ['c#'],
|
||||
'css': ['css'],
|
||||
'javascript': ['javascript'],
|
||||
'ftp': ['ftp'],
|
||||
'haskell': ['haskell'],
|
||||
'unity': ['unity'],
|
||||
'terminal': ['terminal'],
|
||||
'powershell': ['powershell'],
|
||||
'laravel': ['laravel'],
|
||||
'meteor': ['meteor'],
|
||||
'emmet': ['emmet'],
|
||||
'eslint': ['linters'],
|
||||
'tfs': ['tfs'],
|
||||
'rust': ['rust']
|
||||
};
|
||||
|
||||
onEnd(): Promise<void> {
|
||||
const keywords = this.manifest.keywords || [];
|
||||
const trimmedKeywords = keywords.slice(0, 5);
|
||||
|
@ -150,6 +189,10 @@ export class TagsProcessor extends BaseProcessor {
|
|||
.filter(r => !!r)
|
||||
.map(r => r[1]);
|
||||
|
||||
const description = this.manifest.description || '';
|
||||
const descriptionKeywords = Object.keys(TagsProcessor.Keywords)
|
||||
.reduce((r, k) => r.concat(new RegExp(k, 'gi').test(description) ? TagsProcessor.Keywords[k] : []), []);
|
||||
|
||||
keywords = [
|
||||
...keywords,
|
||||
...themes,
|
||||
|
@ -158,7 +201,8 @@ export class TagsProcessor extends BaseProcessor {
|
|||
...debuggers,
|
||||
...json,
|
||||
...languageContributions,
|
||||
...languageActivations
|
||||
...languageActivations,
|
||||
...descriptionKeywords
|
||||
];
|
||||
|
||||
this.vsix.tags = _.unique(keywords).join(',');
|
||||
|
|
|
@ -536,7 +536,7 @@ describe('toVsixManifest', () => {
|
|||
return _toVsixManifest(manifest, [])
|
||||
.then(parseXml)
|
||||
.then(result => {
|
||||
const tags = result.PackageManifest.Metadata[0].Tags as string[];
|
||||
const tags = result.PackageManifest.Metadata[0].Tags[0].split(',') as string[];
|
||||
assert(tags.some(tag => tag === 'keybindings'));
|
||||
});
|
||||
});
|
||||
|
@ -561,7 +561,7 @@ describe('toVsixManifest', () => {
|
|||
return _toVsixManifest(manifest, [])
|
||||
.then(parseXml)
|
||||
.then(result => {
|
||||
const tags = result.PackageManifest.Metadata[0].Tags as string[];
|
||||
const tags = result.PackageManifest.Metadata[0].Tags[0].split(',') as string[];
|
||||
assert(tags.some(tag => tag === 'debuggers'));
|
||||
});
|
||||
});
|
||||
|
@ -583,10 +583,29 @@ describe('toVsixManifest', () => {
|
|||
return _toVsixManifest(manifest, [])
|
||||
.then(parseXml)
|
||||
.then(result => {
|
||||
const tags = result.PackageManifest.Metadata[0].Tags as string[];
|
||||
const tags = result.PackageManifest.Metadata[0].Tags[0].split(',') as string[];
|
||||
assert(tags.some(tag => tag === 'json'));
|
||||
});
|
||||
});
|
||||
|
||||
it('should detect keywords in description', () => {
|
||||
const manifest = {
|
||||
name: 'test',
|
||||
publisher: 'mocha',
|
||||
version: '0.0.1',
|
||||
engines: Object.create(null),
|
||||
description: 'This C plus plus extension likes combines ftp with javascript'
|
||||
};
|
||||
|
||||
return _toVsixManifest(manifest, [])
|
||||
.then(parseXml)
|
||||
.then(result => {
|
||||
const tags = result.PackageManifest.Metadata[0].Tags[0].split(',') as string[];
|
||||
assert(tags.some(tag => tag === 'c++'), 'detect c++');
|
||||
assert(tags.some(tag => tag === 'ftp'), 'detect ftp');
|
||||
assert(tags.some(tag => tag === 'javascript'), 'detect javascript');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('toContentTypes', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue