From f4465189269dda7bed79cc1d3dd56c75285d378d Mon Sep 17 00:00:00 2001 From: juangenial452 <46355725+juangenial452@users.noreply.github.com> Date: Wed, 2 Dec 2020 12:03:07 -0300 Subject: [PATCH 1/2] Various Windows fixes Various fixes that make santa-tracker-web usable on Windows. --- build/import-utils.js | 2 +- build/modern-vfs-middleware.js | 2 +- santa-vfs.js | 6 +++--- serve.js | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build/import-utils.js b/build/import-utils.js index 4e8e05a79..5f43d1b79 100644 --- a/build/import-utils.js +++ b/build/import-utils.js @@ -14,7 +14,7 @@ * limitations under the License. */ -const path = require('path'); +const path = require('path').posix; // Windows fix: .posix makes paths use '/' instead of '\', and solves issues linked to that. const alreadyResolvedMatch = /^(\.{0,2}\/|[a-z]\w*\:)/; // matches start of './' or 'https:' etc diff --git a/build/modern-vfs-middleware.js b/build/modern-vfs-middleware.js index d85ab7f45..a4fdd66fa 100644 --- a/build/modern-vfs-middleware.js +++ b/build/modern-vfs-middleware.js @@ -16,7 +16,7 @@ const modernLoader = require('./modern-loader.js'); const mimeTypes = require('mime-types'); -const path = require('path'); +const path = require('path').posix; // Windows fix: .posix makes paths use '/' instead of '\', and solves issues linked to that. const fs = require('fs').promises; diff --git a/santa-vfs.js b/santa-vfs.js index bf8ffc053..384a0214c 100644 --- a/santa-vfs.js +++ b/santa-vfs.js @@ -15,7 +15,7 @@ */ const fsp = require('./build/fsp.js'); -const path = require('path'); +const path = require('path').posix; // Windows fix: .posix makes paths use '/' instead of '\', and solves issues linked to that. const compileStyles = require('./build/compile-santa-sass.js'); const compileScene = require('./build/compile-scene.js'); const JSON5 = require('json5'); @@ -185,9 +185,9 @@ module.exports = (staticScope, options) => { }, async load(id) { const m = closureSceneMatch.exec(id); - const sceneName = m[1]; + const sceneName = m[2]; // Was m[1] - const flags = m[2]; + const flags = m[3]; // Was m[2] if (flags) { // nb. This previously allowed e.g., ':closure-typeSafe.js'. throw new Error(`unsupported Closure flags: ${flags}`); diff --git a/serve.js b/serve.js index fd321a183..4c8776811 100755 --- a/serve.js +++ b/serve.js @@ -45,7 +45,7 @@ const yargs = require('yargs') default: false, describe: 'Serve static on network address' }) - .option('prefix', { + /*.option('prefix', { // Prefix removed to solve the issue with js files going outside of the prefix and not being able to get the files type: 'string', default: 'st', describe: 'Static prefix', @@ -53,7 +53,7 @@ const yargs = require('yargs') return v.replace(/[^a-z0-9]/g, '') || 'st'; // ensure prefix is basic ascii only }, requiresArg: true, - }) + })*/ .option('lang', { type: 'string', default: 'en', @@ -92,7 +92,7 @@ log(chalk.red(messages('santatracker')), `[${yargs.lang}]`); // nb. matches config in release.js const baseurl = `http://127.0.0.1:${yargs.port + 80}/`; const config = { - staticScope: `${baseurl}${yargs.prefix}/`, + staticScope: `${baseurl}`, // Prefix removed to solve the issue with js files going outside of the prefix and not being able to get the files version: `dev-${(new Date).toISOString().replace(/[^\d]/g, '')}`, baseurl, }; @@ -110,7 +110,7 @@ async function serve() { serveLink: true, }); const staticServer = polka(); - staticServer.use(yargs.prefix, vfsMiddleware(vfs, 'static'), staticHost); + staticServer.use('/', vfsMiddleware(vfs, 'static'), staticHost); // Prefix removed to solve the issue with js files going outside of the prefix and not being able to get the files await listen(staticServer, yargs.port + 80, yargs.all); log('Static', chalk.green(config.staticScope), yargs.all ? chalk.red('(on all interfaces)') : ''); From 8a93584ce1ab96d716a912caa4d4b338f5c46eaf Mon Sep 17 00:00:00 2001 From: juangenial452 <46355725+juangenial452@users.noreply.github.com> Date: Wed, 2 Dec 2020 14:20:28 -0300 Subject: [PATCH 2/2] Fixed closure path regex --- santa-vfs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/santa-vfs.js b/santa-vfs.js index 384a0214c..24d4c4eb7 100644 --- a/santa-vfs.js +++ b/santa-vfs.js @@ -174,7 +174,7 @@ module.exports = (staticScope, options) => { // TODO(samthor): Closure doesn't have to be tied to scenes. But, it's mostly for historic code, // so maybe it's not worth making it generic. - const closureSceneMatch = /^static\/scenes\/(\w+)\/:closure(|-\w+)\.js$/; + const closureSceneMatch = /(static\/scenes\/(\w+)\/:closure(|-\w+)\.js)/; // Old regex didn't detect closure paths correctly const closurePlugin = { match(id) { const rooted = path.relative(__dirname, id);