parent
9fb88a3aad
commit
63c927ca36
1 changed files with 41 additions and 51 deletions
|
@ -285,66 +285,56 @@ export class TagsProcessor extends BaseProcessor {
|
||||||
|
|
||||||
onEnd(): Promise<void> {
|
onEnd(): Promise<void> {
|
||||||
const keywords = this.manifest.keywords || [];
|
const keywords = this.manifest.keywords || [];
|
||||||
const trimmedKeywords = keywords.filter((keyword, index) => index < 5 || keyword === 'multi-root ready');
|
const contributes = this.manifest.contributes;
|
||||||
|
const activationEvents = this.manifest.activationEvents || [];
|
||||||
|
const doesContribute = name => contributes && contributes[name] && contributes[name].length > 0;
|
||||||
|
|
||||||
let promise = Promise.resolve(trimmedKeywords);
|
const colorThemes = doesContribute('themes') ? ['theme', 'color-theme'] : [];
|
||||||
|
const iconThemes = doesContribute('iconThemes') ? ['theme', 'icon-theme'] : [];
|
||||||
|
const snippets = doesContribute('snippets') ? ['snippet'] : [];
|
||||||
|
const keybindings = doesContribute('keybindings') ? ['keybindings'] : [];
|
||||||
|
const debuggers = doesContribute('debuggers') ? ['debuggers'] : [];
|
||||||
|
const json = doesContribute('jsonValidation') ? ['json'] : [];
|
||||||
|
|
||||||
if (keywords.length !== trimmedKeywords.length && !process.env['VSCE_IGNORE_KEYWORDS_LENGTH']) {
|
const localizationContributions = ((contributes && contributes['localizations']) || [])
|
||||||
console.warn(`The keyword list is limited to 5 keywords; only the following keywords will be in your extension: ${trimmedKeywords.join(', ')}.`);
|
.reduce((r, l) => [...r, `lp-${l.languageId}`, ...toLanguagePackTags(l.translations, l.languageId)], []);
|
||||||
promise = util.read('Do you want to continue? [y/N] ')
|
|
||||||
.then(answer => /^y$/i.test(answer) ? Promise.resolve(trimmedKeywords) : Promise.reject('Aborted'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return promise.then<any>(keywords => {
|
const languageContributions = ((contributes && contributes['languages']) || [])
|
||||||
const contributes = this.manifest.contributes;
|
.reduce((r, l) => [...r, l.id, ...(l.aliases || []), ...toExtensionTags(l.extensions || [])], []);
|
||||||
const activationEvents = this.manifest.activationEvents || [];
|
|
||||||
const doesContribute = name => contributes && contributes[name] && contributes[name].length > 0;
|
|
||||||
|
|
||||||
const colorThemes = doesContribute('themes') ? ['theme', 'color-theme'] : [];
|
const languageActivations = activationEvents
|
||||||
const iconThemes = doesContribute('iconThemes') ? ['theme', 'icon-theme'] : [];
|
.map(e => /^onLanguage:(.*)$/.exec(e))
|
||||||
const snippets = doesContribute('snippets') ? ['snippet'] : [];
|
.filter(r => !!r)
|
||||||
const keybindings = doesContribute('keybindings') ? ['keybindings'] : [];
|
.map(r => r[1]);
|
||||||
const debuggers = doesContribute('debuggers') ? ['debuggers'] : [];
|
|
||||||
const json = doesContribute('jsonValidation') ? ['json'] : [];
|
|
||||||
|
|
||||||
const localizationContributions = ((contributes && contributes['localizations']) || [])
|
const grammars = ((contributes && contributes['grammars']) || [])
|
||||||
.reduce((r, l) => [...r, `lp-${l.languageId}`, ...toLanguagePackTags(l.translations, l.languageId)], []);
|
.map(g => g.language);
|
||||||
|
|
||||||
const languageContributions = ((contributes && contributes['languages']) || [])
|
const description = this.manifest.description || '';
|
||||||
.reduce((r, l) => [...r, l.id, ...(l.aliases || []), ...toExtensionTags(l.extensions || [])], []);
|
const descriptionKeywords = Object.keys(TagsProcessor.Keywords)
|
||||||
|
.reduce((r, k) => r.concat(new RegExp('\\b(?:' + escapeRegExp(k) + ')(?!\\w)', 'gi').test(description) ? TagsProcessor.Keywords[k] : []), []);
|
||||||
|
|
||||||
const languageActivations = activationEvents
|
const tags = [
|
||||||
.map(e => /^onLanguage:(.*)$/.exec(e))
|
...keywords,
|
||||||
.filter(r => !!r)
|
...colorThemes,
|
||||||
.map(r => r[1]);
|
...iconThemes,
|
||||||
|
...snippets,
|
||||||
|
...keybindings,
|
||||||
|
...debuggers,
|
||||||
|
...json,
|
||||||
|
...localizationContributions,
|
||||||
|
...languageContributions,
|
||||||
|
...languageActivations,
|
||||||
|
...grammars,
|
||||||
|
...descriptionKeywords
|
||||||
|
];
|
||||||
|
|
||||||
const grammars = ((contributes && contributes['grammars']) || [])
|
this.vsix.tags = _(tags)
|
||||||
.map(g => g.language);
|
.uniq() // deduplicate
|
||||||
|
.compact() // remove falsey values
|
||||||
|
.join(',');
|
||||||
|
|
||||||
const description = this.manifest.description || '';
|
return Promise.resolve(null);
|
||||||
const descriptionKeywords = Object.keys(TagsProcessor.Keywords)
|
|
||||||
.reduce((r, k) => r.concat(new RegExp('\\b(?:' + escapeRegExp(k) + ')(?!\\w)', 'gi').test(description) ? TagsProcessor.Keywords[k] : []), []);
|
|
||||||
|
|
||||||
keywords = [
|
|
||||||
...keywords,
|
|
||||||
...colorThemes,
|
|
||||||
...iconThemes,
|
|
||||||
...snippets,
|
|
||||||
...keybindings,
|
|
||||||
...debuggers,
|
|
||||||
...json,
|
|
||||||
...localizationContributions,
|
|
||||||
...languageContributions,
|
|
||||||
...languageActivations,
|
|
||||||
...grammars,
|
|
||||||
...descriptionKeywords
|
|
||||||
];
|
|
||||||
|
|
||||||
this.vsix.tags = _(keywords)
|
|
||||||
.uniq() // deduplicate
|
|
||||||
.compact() // remove falsey values
|
|
||||||
.join(',');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue