From 3539810f7682b47ec57a8111fa5e350ab5d85f07 Mon Sep 17 00:00:00 2001 From: Lucy Date: Fri, 26 Apr 2024 20:06:34 -0400 Subject: [PATCH] Port tgui dev server fixes (#1725) * Fixes tgui dev server [NO GBP] (#79898) ## About The Pull Request - the .js extensions were required, this is my fault. - fixes a crash "automatic publicPath is not supported in this browser" ## Why It's Good For The Game Bug fixes. Dev server is working ## Changelog N/A nothing player facing * Fix tgui dev server on Windows (#82032) ## About The Pull Request Fixes starting the tgui dev server on Windows machines. Currently on Windows when starting the tgui dev server, it will be unable to find the Byond cache at any of the predefined paths it searches, and resort to using the registry even if one of the predefined paths should successfully locate it. Then, it will fail to find the tmp# folder inside that cache folder even if it exists. The reason is that on Windows, the glob package requires forward slashes when you call its methods such as sync(), as documented in the glob module's documentation: >Note Glob patterns should always use / as a path separator, even on Windows systems, as \ is used to escape glob characters. If you wish to use \ as a path separator instead of using it as an escape character on Windows platforms, you may set windowsPathsNoEscape:true in the options. In this mode, special glob characters cannot be escaped, making it impossible to match a literal * ? and so on in filenames. The function being used to assemble the path, node's path.resolve(), uses backslashes if you call it on a Windows platform. It does not accept any arguments to alter this, nor are there any delimter-conversion functions in the path package. There is an alternative to change the delimiter, forcing POSIX-style path.resolve() by calling path.posix.resolve(), however this removes the drive letter and does not work as a valid path on Windows. For example: What we need to pass to globPkg.sync(): `C:/Users/SomeName/Documents/Byond/cache` What path.resolve() returns: `C:\Users\SomeName\Documents\Byond\cache` What path.posix.resolve() returns: `/Users/SomeName/Documents/Byond/cache` Unfortunately there is not a method in the node path module to return what we need. Instead, we use the workaround provided in glob's documentation and add the windowsPathsNoEscape option. This COULD have a negative effect when searching for * and ? literals, however a search of resolveGlob() callers shows that none of them do this. * and ? in all callers is intended to be a wildcard, not a literal, so this won't have any impact on anything. ## Why It's Good For The Game Helps development efforts for developers using Windows. * Fixes dev server... AGAIN [No GBP] (#79991) Glob package wasn't resolving tmp folder. Javascript does not clue you in that the arguments have changed at all. I downgraded the package and it works. Dev server is 100% confirmed working I swear if it breaks again I will... I will... N/A nothing player facing --------- Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> Co-authored-by: Aronai Sieyes --- tgui/packages/tgui-dev-server/package.json | 6 +- tgui/packages/tgui-dev-server/util.js | 1 + tgui/webpack.config.js | 1 + tgui/yarn.lock | 76 ++++++++++++++++++---- 4 files changed, 68 insertions(+), 16 deletions(-) diff --git a/tgui/packages/tgui-dev-server/package.json b/tgui/packages/tgui-dev-server/package.json index 2477641c7e79..f6eb37c6a85d 100644 --- a/tgui/packages/tgui-dev-server/package.json +++ b/tgui/packages/tgui-dev-server/package.json @@ -4,9 +4,9 @@ "version": "4.3.1", "type": "module", "dependencies": { - "axios": "^0.21.1", - "glob": "^7.1.7", - "source-map": "^0.7.3", + "axios": "^1.6.2", + "glob": "^7.2.0", + "source-map": "^0.7.4", "stacktrace-parser": "^0.1.10", "ws": "^7.5.3" } diff --git a/tgui/packages/tgui-dev-server/util.js b/tgui/packages/tgui-dev-server/util.js index 9d07b96c71a0..54d806a629df 100644 --- a/tgui/packages/tgui-dev-server/util.js +++ b/tgui/packages/tgui-dev-server/util.js @@ -19,6 +19,7 @@ export const resolveGlob = (...sections) => { const unsafePaths = globPkg.sync(path.resolve(...sections), { strict: false, silent: true, + windowsPathsNoEscape: true, }); const safePaths = []; for (let path of unsafePaths) { diff --git a/tgui/webpack.config.js b/tgui/webpack.config.js index 19e2975715fa..900124711b43 100644 --- a/tgui/webpack.config.js +++ b/tgui/webpack.config.js @@ -53,6 +53,7 @@ module.exports = (env = {}, argv) => { filename: '[name].bundle.js', chunkFilename: '[name].bundle.js', chunkLoadTimeout: 15000, + publicPath: '/', }, resolve: { extensions: ['.tsx', '.ts', '.js'], diff --git a/tgui/yarn.lock b/tgui/yarn.lock index c271e152be0d..6f39ba992ded 100644 --- a/tgui/yarn.lock +++ b/tgui/yarn.lock @@ -2769,12 +2769,14 @@ __metadata: languageName: node linkType: hard -"axios@npm:^0.21.1": - version: 0.21.1 - resolution: "axios@npm:0.21.1" +"axios@npm:^1.6.2": + version: 1.6.8 + resolution: "axios@npm:1.6.8" dependencies: - follow-redirects: ^1.10.0 - checksum: c87915fa0b18c15c63350112b6b3563a3e2ae524d7707de0a73d2e065e0d30c5d3da8563037bc29d4cc1b7424b5a350cb7274fa52525c6c04a615fe561c6ab11 + follow-redirects: ^1.15.6 + form-data: ^4.0.0 + proxy-from-env: ^1.1.0 + checksum: bf007fa4b207d102459300698620b3b0873503c6d47bf5a8f6e43c0c64c90035a4f698b55027ca1958f61ab43723df2781c38a99711848d232cad7accbcdfcdd languageName: node linkType: hard @@ -4731,13 +4733,13 @@ __metadata: languageName: node linkType: hard -"follow-redirects@npm:^1.10.0": - version: 1.15.2 - resolution: "follow-redirects@npm:1.15.2" +"follow-redirects@npm:^1.15.6": + version: 1.15.6 + resolution: "follow-redirects@npm:1.15.6" peerDependenciesMeta: debug: optional: true - checksum: faa66059b66358ba65c234c2f2a37fcec029dc22775f35d9ad6abac56003268baf41e55f9ee645957b32c7d9f62baf1f0b906e68267276f54ec4b4c597c2b190 + checksum: a62c378dfc8c00f60b9c80cab158ba54e99ba0239a5dd7c81245e5a5b39d10f0c35e249c3379eae719ff0285fff88c365dd446fab19dee771f1d76252df1bbf5 languageName: node linkType: hard @@ -4759,6 +4761,17 @@ __metadata: languageName: node linkType: hard +"form-data@npm:^4.0.0": + version: 4.0.0 + resolution: "form-data@npm:4.0.0" + dependencies: + asynckit: ^0.4.0 + combined-stream: ^1.0.8 + mime-types: ^2.1.12 + checksum: 01135bf8675f9d5c61ff18e2e2932f719ca4de964e3be90ef4c36aacfc7b9cb2fceb5eca0b7e0190e3383fe51c5b37f4cb80b62ca06a99aaabfcfd6ac7c9328c + languageName: node + linkType: hard + "form-data@npm:~2.3.2": version: 2.3.3 resolution: "form-data@npm:2.3.3" @@ -4927,7 +4940,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^7.1.1, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.1.6, glob@npm:^7.1.7": +"glob@npm:^7.1.1, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.1.6": version: 7.1.7 resolution: "glob@npm:7.1.7" dependencies: @@ -4941,6 +4954,20 @@ __metadata: languageName: node linkType: hard +"glob@npm:^7.2.0": + version: 7.2.3 + resolution: "glob@npm:7.2.3" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.1.1 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 + languageName: node + linkType: hard + "globals@npm:^11.1.0": version: 11.12.0 resolution: "globals@npm:11.12.0" @@ -6891,6 +6918,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:^3.1.1": + version: 3.1.2 + resolution: "minimatch@npm:3.1.2" + dependencies: + brace-expansion: ^1.1.7 + checksum: c154e566406683e7bcb746e000b84d74465b3a832c45d59912b9b55cd50dee66e5c4b1e5566dba26154040e51672f9aa450a9aef0c97cfc7336b78b7afb9540a + languageName: node + linkType: hard + "minimist@npm:1.2.5, minimist@npm:^1.2.0, minimist@npm:^1.2.5": version: 1.2.5 resolution: "minimist@npm:1.2.5" @@ -7928,6 +7964,13 @@ __metadata: languageName: node linkType: hard +"proxy-from-env@npm:^1.1.0": + version: 1.1.0 + resolution: "proxy-from-env@npm:1.1.0" + checksum: ed7fcc2ba0a33404958e34d95d18638249a68c430e30fcb6c478497d72739ba64ce9810a24f53a7d921d0c065e5b78e3822759800698167256b04659366ca4d4 + languageName: node + linkType: hard + "pseudomap@npm:^1.0.2": version: 1.0.2 resolution: "pseudomap@npm:1.0.2" @@ -8760,6 +8803,13 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"source-map@npm:^0.7.4": + version: 0.7.4 + resolution: "source-map@npm:0.7.4" + checksum: 01cc5a74b1f0e1d626a58d36ad6898ea820567e87f18dfc9d24a9843a351aaa2ec09b87422589906d6ff1deed29693e176194dc88bcae7c9a852dc74b311dbf5 + languageName: node + linkType: hard + "sprintf-js@npm:~1.0.2": version: 1.0.3 resolution: "sprintf-js@npm:1.0.3" @@ -9227,9 +9277,9 @@ resolve@^2.0.0-next.3: version: 0.0.0-use.local resolution: "tgui-dev-server@workspace:packages/tgui-dev-server" dependencies: - axios: ^0.21.1 - glob: ^7.1.7 - source-map: ^0.7.3 + axios: ^1.6.2 + glob: ^7.2.0 + source-map: ^0.7.4 stacktrace-parser: ^0.1.10 ws: ^7.5.3 languageName: unknown