From e79ffc11a5587752317edfde89cacd767c3484fb Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 28 Apr 2025 21:57:45 +0200 Subject: [PATCH] Update tooling and fix analyze --- .gitignore | 5 +++++ .justfile | 1 + .lune/websocket_server.luau | 2 +- rokit.toml | 7 ++++--- scripts/analyze_copy_typedefs.luau | 14 ++++++++++++++ tests/globals/pcall.luau | 2 +- tests/net/serve/addresses.luau | 2 +- tests/net/serve/handles.luau | 2 +- tests/net/serve/non_blocking.luau | 2 +- tests/net/serve/requests.luau | 2 +- tests/net/serve/websockets.luau | 2 +- tests/process/exec/stdio.luau | 2 +- tests/require/tests/modules/self_alias/init.luau | 4 ++-- tests/roblox/instance/methods/Clone.luau | 2 +- 14 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 scripts/analyze_copy_typedefs.luau diff --git a/.gitignore b/.gitignore index 6f7b83e..f88ebb4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,12 @@ lune.yml luneDocs.json luneTypes.d.luau +# Dirs generated by runtime or build scripts + +/types + # Files generated by runtime or build scripts + scripts/brick_color.rs scripts/font_enum_map.rs scripts/physical_properties_enum_map.rs diff --git a/.justfile b/.justfile index a3752ca..5e06c52 100644 --- a/.justfile +++ b/.justfile @@ -65,6 +65,7 @@ fmt-check: analyze: #!/usr/bin/env bash set -euo pipefail + lune run scripts/analyze_copy_typedefs luau-lsp analyze \ --settings=".vscode/settings.json" \ --ignore="tests/roblox/rbx-test-files/**" \ diff --git a/.lune/websocket_server.luau b/.lune/websocket_server.luau index 4efb47d..c6f620d 100644 --- a/.lune/websocket_server.luau +++ b/.lune/websocket_server.luau @@ -32,6 +32,6 @@ print(`Listening on port {PORT} 🚀`) task.delay(10, function() print("Shutting down...") task.wait(1) - handle:stop() + handle.stop() task.wait(1) end) diff --git a/rokit.toml b/rokit.toml index 3988e56..b163dd5 100644 --- a/rokit.toml +++ b/rokit.toml @@ -1,4 +1,5 @@ [tools] -luau-lsp = "JohnnyMorganz/luau-lsp@1.33.1" -stylua = "JohnnyMorganz/StyLua@0.20.0" -just = "casey/just@1.36.0" +luau-lsp = "JohnnyMorganz/luau-lsp@1.44.1" +lune = "lune-org/lune@0.9.0" +stylua = "JohnnyMorganz/StyLua@2.1.0" +just = "casey/just@1.40.0" diff --git a/scripts/analyze_copy_typedefs.luau b/scripts/analyze_copy_typedefs.luau new file mode 100644 index 0000000..ade7b6d --- /dev/null +++ b/scripts/analyze_copy_typedefs.luau @@ -0,0 +1,14 @@ +local fs = require("@lune/fs") + +fs.writeDir("./types") + +for _, dir in fs.readDir("./crates") do + local std = string.match(dir, "^lune%-std%-(%w+)$") + if std ~= nil then + local from = `./crates/{dir}/types.d.luau` + if fs.isFile(from) then + local to = `./types/{std}.luau` + fs.copy(from, to, true) + end + end +end diff --git a/tests/globals/pcall.luau b/tests/globals/pcall.luau index 860b850..fa983cb 100644 --- a/tests/globals/pcall.luau +++ b/tests/globals/pcall.luau @@ -28,7 +28,7 @@ local handle = net.serve(PORT, function() end) task.delay(0.25, function() - handle:stop() + handle.stop() end) test(net.serve, PORT, function() end) diff --git a/tests/net/serve/addresses.luau b/tests/net/serve/addresses.luau index ac8ea11..57f591f 100644 --- a/tests/net/serve/addresses.luau +++ b/tests/net/serve/addresses.luau @@ -19,7 +19,7 @@ local handle = net.serve(PORT, { local response = net.request(`{LOCALHOST}:{PORT}`).body assert(response ~= nil, "Invalid response from server") -handle:stop() +handle.stop() -- Attempting to serve with a malformed IP address should throw an error diff --git a/tests/net/serve/handles.luau b/tests/net/serve/handles.luau index 4f823c7..b3ce418 100644 --- a/tests/net/serve/handles.luau +++ b/tests/net/serve/handles.luau @@ -12,7 +12,7 @@ end) -- Stopping is not guaranteed to happen instantly since it is async, but -- it should happen on the next yield, so we wait the minimum amount here -handle:stop() +handle.stop() task.wait() -- Sending a request to the stopped server should now error diff --git a/tests/net/serve/non_blocking.luau b/tests/net/serve/non_blocking.luau index f855e75..dea1100 100644 --- a/tests/net/serve/non_blocking.luau +++ b/tests/net/serve/non_blocking.luau @@ -21,4 +21,4 @@ end) task.cancel(thread) -handle:stop() +handle.stop() diff --git a/tests/net/serve/requests.luau b/tests/net/serve/requests.luau index a17b0f8..1505e53 100644 --- a/tests/net/serve/requests.luau +++ b/tests/net/serve/requests.luau @@ -42,4 +42,4 @@ end task.cancel(thread) -handle:stop() +handle.stop() diff --git a/tests/net/serve/websockets.luau b/tests/net/serve/websockets.luau index bf8bf56..1c169ce 100644 --- a/tests/net/serve/websockets.luau +++ b/tests/net/serve/websockets.luau @@ -64,4 +64,4 @@ assert( ) -- Stop the server to end the test -handle:stop() +handle.stop() diff --git a/tests/process/exec/stdio.luau b/tests/process/exec/stdio.luau index 524713b..d4ef388 100644 --- a/tests/process/exec/stdio.luau +++ b/tests/process/exec/stdio.luau @@ -10,7 +10,7 @@ local echoResult = process.exec("echo", { }, { env = { TEST_VAR = echoMessage }, shell = if IS_WINDOWS then "powershell" else "bash", - stdio = "inherit" :: process.SpawnOptionsStdioKind, -- FIXME: This should just work without a cast? + stdio = "inherit", }) -- Windows uses \r\n (CRLF) and unix uses \n (LF) diff --git a/tests/require/tests/modules/self_alias/init.luau b/tests/require/tests/modules/self_alias/init.luau index 5003e13..960ecae 100644 --- a/tests/require/tests/modules/self_alias/init.luau +++ b/tests/require/tests/modules/self_alias/init.luau @@ -1,10 +1,10 @@ -local inner = require("@self/module") +local inner = require("@self/module") :: any -- FIXME: luau-lsp does not yet support self alias local outer = require("./module") assert(type(outer) == "table", "Outer module is not a table") assert(type(inner) == "table", "Inner module is not a table") assert(outer.Foo == inner.Foo, "Outer and inner modules have different Foo values") -assert(inner.Bar == outer.Bar, "Outer and inner modules have different Bar values") +assert(inner.Hello == outer.Hello, "Outer and inner modules have different Hello values") return inner diff --git a/tests/roblox/instance/methods/Clone.luau b/tests/roblox/instance/methods/Clone.luau index 0472974..082c78a 100644 --- a/tests/roblox/instance/methods/Clone.luau +++ b/tests/roblox/instance/methods/Clone.luau @@ -7,7 +7,7 @@ local objValue1 = Instance.new("ObjectValue") local objValue2 = Instance.new("ObjectValue") objValue1.Name = "ObjectValue1" -objValue2.Name = "ObjectValue2"; +objValue2.Name = "ObjectValue2" (objValue1 :: any).Value = root; (objValue2 :: any).Value = child objValue1.Parent = child