From 17e9c12ee41da640cc0bc0403b416bdbe792c48e Mon Sep 17 00:00:00 2001 From: Erlend Oftedal Date: Thu, 12 Dec 2024 15:18:41 +0100 Subject: [PATCH] Improve extractor for vue --- repository/jsrepository-master.json | 5 ++++- repository/jsrepository-v2.json | 5 ++++- repository/jsrepository-v3.json | 5 ++++- repository/jsrepository-v4.json | 5 ++++- repository/jsrepository.json | 5 ++++- repository/test-detection.js | 18 ++++++++++++------ repository/testcases.json | 10 ++++++++++ 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/repository/jsrepository-master.json b/repository/jsrepository-master.json index 490a08f8..1742f0d1 100644 --- a/repository/jsrepository-master.json +++ b/repository/jsrepository-master.json @@ -4573,13 +4573,16 @@ "filename": ["vue-(§§version§§)(\\.min)?\\.js"], "filecontent": [ "/\\*!\\n \\* Vue.js v(§§version§§)", + "/\\*\\*?!?\\n ?\\* vue v(§§version§§)", "Vue.version = '(§§version§§)';", "'(§§version§§)'[^\\n]{0,8000}Vue compiler", "\\* Original file: /npm/vue@(§§version§§)/dist/vue.(global|common).js", "const version[ ]*=[ ]*\"(§§version§§)\";[\\s]*/\\*\\*[\\s]*\\* SSR utils for \\\\@vue/server-renderer", "\\.__vue_app__=.{0,8000}?const [a-z]+=\"(§§version§§)\",", "let [A-Za-z]+=\"(§§version§§)\",..=\"undefined\"!=typeof window&&window.trustedTypes;if\\(..\\)try\\{.=..\\.createPolicy\\(\"vue\",", - "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"" + "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"", + "\"(§§version§§)\"[\\s\\S]{0,150}\\.createPolicy\\(\"vue\"", + "devtoolsFormatters[\\s\\S]{50,180}\"(§§version§§)\"[\\s\\S]{50,180}\\.createElement\\(\"template\"\\)" ], "func": ["Vue.version"] }, diff --git a/repository/jsrepository-v2.json b/repository/jsrepository-v2.json index 2e4fa65c..26d12277 100644 --- a/repository/jsrepository-v2.json +++ b/repository/jsrepository-v2.json @@ -5965,13 +5965,16 @@ ], "filecontent": [ "/\\*!\\n \\* Vue.js v(§§version§§)", + "/\\*\\*?!?\\n ?\\* vue v(§§version§§)", "Vue.version = '(§§version§§)';", "'(§§version§§)'[^\\n]{0,8000}Vue compiler", "\\* Original file: /npm/vue@(§§version§§)/dist/vue.(global|common).js", "const version[ ]*=[ ]*\"(§§version§§)\";[\\s]*/\\*\\*[\\s]*\\* SSR utils for \\\\@vue/server-renderer", "\\.__vue_app__=.{0,8000}?const [a-z]+=\"(§§version§§)\",", "let [A-Za-z]+=\"(§§version§§)\",..=\"undefined\"!=typeof window&&window.trustedTypes;if\\(..\\)try\\{.=..\\.createPolicy\\(\"vue\",", - "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"" + "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"", + "\"(§§version§§)\"[\\s\\S]{0,150}\\.createPolicy\\(\"vue\"", + "devtoolsFormatters[\\s\\S]{50,180}\"(§§version§§)\"[\\s\\S]{50,180}\\.createElement\\(\"template\"\\)" ], "func": [ "Vue.version" diff --git a/repository/jsrepository-v3.json b/repository/jsrepository-v3.json index 657a22a7..766630ec 100644 --- a/repository/jsrepository-v3.json +++ b/repository/jsrepository-v3.json @@ -6102,13 +6102,16 @@ ], "filecontent": [ "/\\*!\\n \\* Vue.js v(§§version§§)", + "/\\*\\*?!?\\n ?\\* vue v(§§version§§)", "Vue.version = '(§§version§§)';", "'(§§version§§)'[^\\n]{0,8000}Vue compiler", "\\* Original file: /npm/vue@(§§version§§)/dist/vue.(global|common).js", "const version[ ]*=[ ]*\"(§§version§§)\";[\\s]*/\\*\\*[\\s]*\\* SSR utils for \\\\@vue/server-renderer", "\\.__vue_app__=.{0,8000}?const [a-z]+=\"(§§version§§)\",", "let [A-Za-z]+=\"(§§version§§)\",..=\"undefined\"!=typeof window&&window.trustedTypes;if\\(..\\)try\\{.=..\\.createPolicy\\(\"vue\",", - "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"" + "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"", + "\"(§§version§§)\"[\\s\\S]{0,150}\\.createPolicy\\(\"vue\"", + "devtoolsFormatters[\\s\\S]{50,180}\"(§§version§§)\"[\\s\\S]{50,180}\\.createElement\\(\"template\"\\)" ], "func": [ "Vue.version" diff --git a/repository/jsrepository-v4.json b/repository/jsrepository-v4.json index a730126e..703e4459 100644 --- a/repository/jsrepository-v4.json +++ b/repository/jsrepository-v4.json @@ -6101,13 +6101,16 @@ ], "filecontent": [ "/\\*!\\n \\* Vue.js v(§§version§§)", + "/\\*\\*?!?\\n ?\\* vue v(§§version§§)", "Vue.version = '(§§version§§)';", "'(§§version§§)'[^\\n]{0,8000}Vue compiler", "\\* Original file: /npm/vue@(§§version§§)/dist/vue.(global|common).js", "const version[ ]*=[ ]*\"(§§version§§)\";[\\s]*/\\*\\*[\\s]*\\* SSR utils for \\\\@vue/server-renderer", "\\.__vue_app__=.{0,8000}?const [a-z]+=\"(§§version§§)\",", "let [A-Za-z]+=\"(§§version§§)\",..=\"undefined\"!=typeof window&&window.trustedTypes;if\\(..\\)try\\{.=..\\.createPolicy\\(\"vue\",", - "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"" + "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"", + "\"(§§version§§)\"[\\s\\S]{0,150}\\.createPolicy\\(\"vue\"", + "devtoolsFormatters[\\s\\S]{50,180}\"(§§version§§)\"[\\s\\S]{50,180}\\.createElement\\(\"template\"\\)" ], "func": [ "Vue.version" diff --git a/repository/jsrepository.json b/repository/jsrepository.json index cb98121d..0e2b4f72 100644 --- a/repository/jsrepository.json +++ b/repository/jsrepository.json @@ -5913,13 +5913,16 @@ ], "filecontent": [ "/\\*!\\n \\* Vue.js v(§§version§§)", + "/\\*\\*?!?\\n ?\\* vue v(§§version§§)", "Vue.version = '(§§version§§)';", "'(§§version§§)'[^\\n]{0,8000}Vue compiler", "\\* Original file: /npm/vue@(§§version§§)/dist/vue.(global|common).js", "const version[ ]*=[ ]*\"(§§version§§)\";[\\s]*/\\*\\*[\\s]*\\* SSR utils for \\\\@vue/server-renderer", "\\.__vue_app__=.{0,8000}?const [a-z]+=\"(§§version§§)\",", "let [A-Za-z]+=\"(§§version§§)\",..=\"undefined\"!=typeof window&&window.trustedTypes;if\\(..\\)try\\{.=..\\.createPolicy\\(\"vue\",", - "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"" + "isCustomElement.{1,5}?compilerOptions.{0,500}exposeProxy.{0,700}\"(§§version§§)\"", + "\"(§§version§§)\"[\\s\\S]{0,150}\\.createPolicy\\(\"vue\"", + "devtoolsFormatters[\\s\\S]{50,180}\"(§§version§§)\"[\\s\\S]{50,180}\\.createElement\\(\"template\"\\)" ], "func": [ "Vue.version" diff --git a/repository/test-detection.js b/repository/test-detection.js index 8495df46..eb89f17f 100755 --- a/repository/test-detection.js +++ b/repository/test-detection.js @@ -87,6 +87,7 @@ async function runTests(jsRepo) { additionalVersions, allowedOtherComponents, allowAstMiss, + allowContentMiss, } = tcontent; if (limit) { versions = Array.from( @@ -150,12 +151,15 @@ async function runTests(jsRepo) { contentResults = contentResults.filter( (x) => !allowedOtherComponents.includes(x.component) ); - if (contentResults.length == 0) { + const canSkipContent = + allowContentMiss && allowContentMiss.includes(version); + if (contentResults.length == 0 && !canSkipContent) { exitWithError( `Did not detect ${version} of ${name} using content on ${t}` ); } if ( + !canSkipContent && contentResults.length > 1 && contentResults[0].component != "jquery-ui" ) { @@ -166,12 +170,15 @@ async function runTests(jsRepo) { .join(", ")}` ); } - if (contentResults[0].component != name) { + if (!canSkipContent && contentResults[0].component != name) { exitWithError( `Wrong component for ${version} of ${name} using uri or filename on ${t}: ${contentResults[0].component}` ); } - if (!contentResults[0].version.startsWith(version)) { + if ( + !canSkipContent && + !contentResults[0].version.startsWith(version) + ) { exitWithError( `Wrong version for ${version} of ${name} using content on ${t}: ${contentResults[0].version}` ); @@ -218,9 +225,8 @@ async function runTests(jsRepo) { ); } } - success( - ` - ${contentResults[0].component} @ ${contentResults[0].version} C: ${cRt}ms B: ${bRt}ms` - ); + + success(` - ${name} @ ${version} C: ${cRt}ms B: ${bRt}ms`); } } } diff --git a/repository/testcases.json b/repository/testcases.json index de4dd0b2..6e6f7e57 100644 --- a/repository/testcases.json +++ b/repository/testcases.json @@ -196,6 +196,9 @@ } }, "vue": { + "https://cdnjs.cloudflare.com/ajax/libs/vue/§§version§§/vue.runtime.global.min.js": { + "versions": ["3.5.12", "3.4.27", "3.2.37", "3.2.36", "3.2.45"] + }, "https://cdn.jsdelivr.net/npm/vue@§§version§§": { "versions": [ "3.5.12", @@ -207,6 +210,13 @@ "1.0.28" ] }, + "https://cdnjs.cloudflare.com/ajax/libs/vue/§§version§§/vue.cjs.js": { + "versions": ["3.5.12", "3.4.27"], + "allowAstMiss": ["3.5.12", "3.4.27"] + }, + "https://cdnjs.cloudflare.com/ajax/libs/vue/§§version§§/vue.runtime.global.prod.min.js": { + "versions": ["3.5.12", "3.4.27"] + }, "https://cdnjs.cloudflare.com/ajax/libs/vue/§§version§§/vue.global.prod.min.js": { "versions": ["3.5.12", "3.4.27", "3.2.37", "3.2.36", "3.2.45"], "additionalVersions": [