[Autotag] Add autotag

This commit is contained in:
Ducko 2021-02-14 18:30:46 +00:00
parent c5b7c6b93c
commit 4bed56b913
2 changed files with 15 additions and 2 deletions

12
src/autoTag.js Normal file
View File

@ -0,0 +1,12 @@
const basicIncludes = (bundleCode, code, display = (code[0].toUpperCase() + code.substring(1))) => {
if (bundleCode.includes(code)) return display;
};
export default (bundleCode) => { // Scans final bundle JS to try and auto-detect things, then adding tags
const tags = [
basicIncludes(bundleCode, 'react'),
basicIncludes(bundleCode, 'document', 'DOM'),
].filter((x) => x !== undefined);
return tags;
};

View File

@ -1,4 +1,5 @@
import ModuleRepos from './modules/index.js';
import AutoTag from './autoTag.js';
import Parcel from 'parcel-bundler';
import axios from 'axios';
@ -161,7 +162,7 @@ for (const parentRepo of ModuleRepos) {
version: manifest.version,
tags: manifest.tags,
tags: manifest.tags.concat(AutoTag(jsCode)),
authors: manifest.authors,
@ -182,7 +183,7 @@ for (const parentRepo of ModuleRepos) {
// console.log(lastHash);
if (lastHash !== commitHash) {
if (commitHash !== '' && lastHash !== commitHash) {
console.log('[Warning] Commit hash in modules does not match latest commit in repo');
}
}