diff --git a/src/autoTag.js b/src/autoTag.js new file mode 100644 index 0000000..b428ee1 --- /dev/null +++ b/src/autoTag.js @@ -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; +}; \ No newline at end of file diff --git a/src/index.js b/src/index.js index 3a58642..92e91e5 100644 --- a/src/index.js +++ b/src/index.js @@ -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'); } }