From d6332d2bc723f9aa60f2c886564bef49a6b91b84 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 14 Feb 2021 20:25:41 -0500 Subject: Test html script ordering (#1396) * Simplify getAllFiles * Add test to validate script order * Update script include order * Update content script order * Update sw.js and corresponding lint * Update manifest --- dev/build.js | 2 +- dev/data/manifest-variants.json | 26 +++++----- dev/lint/global-declarations.js | 6 +-- dev/lint/html-scripts.js | 102 ++++++++++++++++++++++++++++++++++++++-- dev/util.js | 6 +-- 5 files changed, 117 insertions(+), 25 deletions(-) (limited to 'dev') diff --git a/dev/build.js b/dev/build.js index 9cbbd518..55358e59 100644 --- a/dev/build.js +++ b/dev/build.js @@ -62,7 +62,7 @@ async function createZip(directory, excludeFiles, outputFileName, sevenZipExes, async function createJSZip(directory, excludeFiles, outputFileName, onUpdate, dryRun) { const JSZip = util.JSZip; - const files = getAllFiles(directory, directory); + const files = getAllFiles(directory); removeItemsFromArray(files, excludeFiles); const zip = new JSZip(); for (const fileName of files) { diff --git a/dev/data/manifest-variants.json b/dev/data/manifest-variants.json index 178f1395..3b50b0f3 100644 --- a/dev/data/manifest-variants.json +++ b/dev/data/manifest-variants.json @@ -41,23 +41,23 @@ "js": [ "js/core.js", "js/yomichan.js", - "js/comm/cross-frame-api.js", - "js/comm/api.js", - "js/script/dynamic-loader.js", - "js/comm/frame-client.js", - "js/language/text-scanner.js", - "js/dom/document-util.js", - "js/input/hotkey-handler.js", - "js/dom/dom-text-scanner.js", + "js/app/frontend.js", "js/app/popup.js", - "js/dom/text-source-range.js", - "js/dom/text-source-element.js", "js/app/popup-factory.js", - "js/comm/frame-ancestry-handler.js", - "js/comm/frame-offset-forwarder.js", "js/app/popup-proxy.js", "js/app/popup-window.js", - "js/app/frontend.js", + "js/comm/api.js", + "js/comm/cross-frame-api.js", + "js/comm/frame-ancestry-handler.js", + "js/comm/frame-client.js", + "js/comm/frame-offset-forwarder.js", + "js/dom/dom-text-scanner.js", + "js/dom/document-util.js", + "js/dom/text-source-element.js", + "js/dom/text-source-range.js", + "js/input/hotkey-handler.js", + "js/language/text-scanner.js", + "js/script/dynamic-loader.js", "js/app/content-script-main.js" ], "match_about_blank": true, diff --git a/dev/lint/global-declarations.js b/dev/lint/global-declarations.js index 61739c42..914d1266 100644 --- a/dev/lint/global-declarations.js +++ b/dev/lint/global-declarations.js @@ -117,10 +117,10 @@ function main() { const fix = (process.argv.length >= 2 && process.argv[2] === '--fix'); const directory = path.resolve(__dirname, '..', '..', 'ext'); const pattern = /\.js$/; - const ignorePattern = /[\\/]ext[\\/]lib[\\/]/; - const fileNames = getAllFiles(directory, null, (f) => pattern.test(f) && !ignorePattern.test(f)); + const ignorePattern = /^lib[\\/]/; + const fileNames = getAllFiles(directory, (f) => pattern.test(f) && !ignorePattern.test(f)); for (const fileName of fileNames) { - if (!validateGlobals(fileName, fix)) { + if (!validateGlobals(path.join(directory, fileName), fix)) { process.exit(-1); return; } diff --git a/dev/lint/html-scripts.js b/dev/lint/html-scripts.js index dec8a3dd..41263d96 100644 --- a/dev/lint/html-scripts.js +++ b/dev/lint/html-scripts.js @@ -41,18 +41,110 @@ function validatePath(src, fileName, extDir) { assert.ok(stats.isFile(), `