Skip to content

Commit

Permalink
Improve extractor for vue
Browse files Browse the repository at this point in the history
  • Loading branch information
eoftedal committed Dec 12, 2024
1 parent 7abeabc commit 17e9c12
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 11 deletions.
5 changes: 4 additions & 1 deletion repository/jsrepository-master.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
},
Expand Down
5 changes: 4 additions & 1 deletion repository/jsrepository-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion repository/jsrepository-v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion repository/jsrepository-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion repository/jsrepository.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 12 additions & 6 deletions repository/test-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async function runTests(jsRepo) {
additionalVersions,
allowedOtherComponents,
allowAstMiss,
allowContentMiss,
} = tcontent;
if (limit) {
versions = Array.from(
Expand Down Expand Up @@ -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"
) {
Expand All @@ -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}`
);
Expand Down Expand Up @@ -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`);
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions repository/testcases.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": [
Expand Down

0 comments on commit 17e9c12

Please sign in to comment.