From 96d2ddeb15f3f39d4791158616a2e97cd1bf096b Mon Sep 17 00:00:00 2001 From: boatbomber Date: Fri, 8 Nov 2024 17:51:33 -0800 Subject: [PATCH 1/7] Move project json for LSP extension, move scripts, add contribution docs --- CONTRIBUTING.md | 16 ++++++++++++++++ .../default.project.json => plugin.project.json | 16 ++++++++-------- plugin/run-tests.server.lua | 2 +- plugin/test | 4 ---- plugin/test-place.project.json | 2 +- plugin/watch-build.sh | 2 -- scripts/unit-test-plugin.sh | 2 ++ scripts/watch-build-plugin.sh | 1 + 8 files changed, 29 insertions(+), 16 deletions(-) rename plugin/default.project.json => plugin.project.json (50%) delete mode 100644 plugin/test delete mode 100644 plugin/watch-build.sh create mode 100644 scripts/unit-test-plugin.sh create mode 100644 scripts/watch-build-plugin.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f3efd19f..ddff3e494 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,6 +17,22 @@ You'll want these tools to work on Rojo: * Latest stable [Rojo](https://github.com/rojo-rbx/rojo) * [Foreman](https://github.com/Roblox/foreman) +When working on the Studio plugin, we recommend using this command to rebuild the plugin when you save a change: + +*(Make sure you've enabled the Studio setting to reload plugins on file change!)* + +```bash +bash scripts/watch-build-plugin.sh +``` + +You can also run the plugin's unit tests with the following: + +*(Make sure you have `run-in-roblox` installed first!)* + +```bash +bash scripts/unit-test-plugin.sh +``` + ## Documentation Documentation impacts way more people than the individual lines of code we write. diff --git a/plugin/default.project.json b/plugin.project.json similarity index 50% rename from plugin/default.project.json rename to plugin.project.json index 424f107e4..83265250e 100644 --- a/plugin/default.project.json +++ b/plugin.project.json @@ -3,25 +3,25 @@ "tree": { "$className": "Folder", "Plugin": { - "$path": "src" + "$path": "plugin/src" }, "Packages": { - "$path": "Packages", + "$path": "plugin/Packages", "Log": { - "$path": "log" + "$path": "plugin/log" }, "Http": { - "$path": "http" + "$path": "plugin/http" }, "Fmt": { - "$path": "fmt" + "$path": "plugin/fmt" }, "RbxDom": { - "$path": "rbx_dom_lua" + "$path": "plugin/rbx_dom_lua" } }, "Version": { - "$path": "Version.txt" + "$path": "plugin/Version.txt" } } -} \ No newline at end of file +} diff --git a/plugin/run-tests.server.lua b/plugin/run-tests.server.lua index 1e2130f57..0ab3cc05c 100644 --- a/plugin/run-tests.server.lua +++ b/plugin/run-tests.server.lua @@ -1,6 +1,6 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") -local TestEZ = require(ReplicatedStorage.Packages.TestEZ) +local TestEZ = require(ReplicatedStorage.Packages:WaitForChild("TestEZ", 10)) local Rojo = ReplicatedStorage.Rojo diff --git a/plugin/test b/plugin/test deleted file mode 100644 index caeb88743..000000000 --- a/plugin/test +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -rojo build test-place.project.json -o TestPlace.rbxlx -run-in-roblox --script run-tests.server.lua --place TestPlace.rbxlx \ No newline at end of file diff --git a/plugin/test-place.project.json b/plugin/test-place.project.json index 70875137f..f4da9815a 100644 --- a/plugin/test-place.project.json +++ b/plugin/test-place.project.json @@ -5,7 +5,7 @@ "ReplicatedStorage": { "Rojo": { - "$path": "default.project.json" + "$path": "../plugin.project.json" }, "Packages": { diff --git a/plugin/watch-build.sh b/plugin/watch-build.sh deleted file mode 100644 index 91ce6f894..000000000 --- a/plugin/watch-build.sh +++ /dev/null @@ -1,2 +0,0 @@ -# Continously build the rojo plugin into the local plugin directory on Windows -rojo build plugin/default.project.json -o $LOCALAPPDATA/Roblox/Plugins/Rojo.rbxm --watch diff --git a/scripts/unit-test-plugin.sh b/scripts/unit-test-plugin.sh new file mode 100644 index 000000000..c7ff7c798 --- /dev/null +++ b/scripts/unit-test-plugin.sh @@ -0,0 +1,2 @@ +rojo build plugin/test-place.project.json -o TestPlace.rbxl +run-in-roblox --script plugin/run-tests.server.lua --place TestPlace.rbxl \ No newline at end of file diff --git a/scripts/watch-build-plugin.sh b/scripts/watch-build-plugin.sh new file mode 100644 index 000000000..c21397f25 --- /dev/null +++ b/scripts/watch-build-plugin.sh @@ -0,0 +1 @@ +rojo build plugin.project.json --plugin Rojo.rbxm --watch \ No newline at end of file From e76533da53b11702ef398a998c325de09357470a Mon Sep 17 00:00:00 2001 From: boatbomber Date: Fri, 8 Nov 2024 17:55:50 -0800 Subject: [PATCH 2/7] Map new project json during build --- build.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build.rs b/build.rs index 9f9a606bb..7a95adf33 100644 --- a/build.rs +++ b/build.rs @@ -41,12 +41,12 @@ fn snapshot_from_fs_path(path: &Path) -> io::Result { fn main() -> Result<(), anyhow::Error> { let out_dir = env::var_os("OUT_DIR").unwrap(); - let root_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap(); - let plugin_root = PathBuf::from(root_dir).join("plugin"); + let root_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); + let plugin_dir = root_dir.join("plugin"); let our_version = Version::parse(env::var_os("CARGO_PKG_VERSION").unwrap().to_str().unwrap())?; let plugin_version = - Version::parse(fs::read_to_string(plugin_root.join("Version.txt"))?.trim())?; + Version::parse(fs::read_to_string(plugin_dir.join("Version.txt"))?.trim())?; assert_eq!( our_version, plugin_version, @@ -54,14 +54,14 @@ fn main() -> Result<(), anyhow::Error> { ); let snapshot = VfsSnapshot::dir(hashmap! { - "default.project.json" => snapshot_from_fs_path(&plugin_root.join("default.project.json"))?, - "fmt" => snapshot_from_fs_path(&plugin_root.join("fmt"))?, - "http" => snapshot_from_fs_path(&plugin_root.join("http"))?, - "log" => snapshot_from_fs_path(&plugin_root.join("log"))?, - "rbx_dom_lua" => snapshot_from_fs_path(&plugin_root.join("rbx_dom_lua"))?, - "src" => snapshot_from_fs_path(&plugin_root.join("src"))?, - "Packages" => snapshot_from_fs_path(&plugin_root.join("Packages"))?, - "Version.txt" => snapshot_from_fs_path(&plugin_root.join("Version.txt"))?, + "default.project.json" => snapshot_from_fs_path(&root_dir.join("plugin.project.json"))?, + "fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?, + "http" => snapshot_from_fs_path(&plugin_dir.join("http"))?, + "log" => snapshot_from_fs_path(&plugin_dir.join("log"))?, + "rbx_dom_lua" => snapshot_from_fs_path(&plugin_dir.join("rbx_dom_lua"))?, + "src" => snapshot_from_fs_path(&plugin_dir.join("src"))?, + "Packages" => snapshot_from_fs_path(&plugin_dir.join("Packages"))?, + "Version.txt" => snapshot_from_fs_path(&plugin_dir.join("Version.txt"))?, }); let out_path = Path::new(&out_dir).join("plugin.bincode"); From 6ca2d009595598c58f0801ef0a74ac547087b570 Mon Sep 17 00:00:00 2001 From: boatbomber Date: Fri, 8 Nov 2024 18:03:46 -0800 Subject: [PATCH 3/7] Rename to default so that the LSP works nicely --- .gitignore | 4 ++-- CONTRIBUTING.md | 3 ++- build.rs | 2 +- plugin.project.json => default.project.json | 0 plugin/test-place.project.json | 2 +- scripts/watch-build-plugin.sh | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) rename plugin.project.json => default.project.json (100%) diff --git a/.gitignore b/.gitignore index 88cdf551a..b1a5efe95 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,8 @@ /*.rbxl /*.rbxlx -# Test places for the Roblox Studio Plugin -/plugin/*.rbxlx +# Sourcemap for the Rojo plugin (for better intellisense) +/sourcemap.json # Roblox Studio holds 'lock' files on places *.rbxl.lock diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ddff3e494..7eccb0ee6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,8 +16,9 @@ You'll want these tools to work on Rojo: * Latest stable Rust compiler * Latest stable [Rojo](https://github.com/rojo-rbx/rojo) * [Foreman](https://github.com/Roblox/foreman) +* [Luau Language Server](https://github.com/JohnnyMorganz/luau-lsp) (Only needed if working on the Studio plugin.) -When working on the Studio plugin, we recommend using this command to rebuild the plugin when you save a change: +When working on the Studio plugin, we recommend using this command to automatically rebuild the plugin when you save a change: *(Make sure you've enabled the Studio setting to reload plugins on file change!)* diff --git a/build.rs b/build.rs index 7a95adf33..b66c202c1 100644 --- a/build.rs +++ b/build.rs @@ -54,7 +54,7 @@ fn main() -> Result<(), anyhow::Error> { ); let snapshot = VfsSnapshot::dir(hashmap! { - "default.project.json" => snapshot_from_fs_path(&root_dir.join("plugin.project.json"))?, + "default.project.json" => snapshot_from_fs_path(&root_dir.join("default.project.json"))?, "fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?, "http" => snapshot_from_fs_path(&plugin_dir.join("http"))?, "log" => snapshot_from_fs_path(&plugin_dir.join("log"))?, diff --git a/plugin.project.json b/default.project.json similarity index 100% rename from plugin.project.json rename to default.project.json diff --git a/plugin/test-place.project.json b/plugin/test-place.project.json index f4da9815a..c1ddd8607 100644 --- a/plugin/test-place.project.json +++ b/plugin/test-place.project.json @@ -5,7 +5,7 @@ "ReplicatedStorage": { "Rojo": { - "$path": "../plugin.project.json" + "$path": "../default.project.json" }, "Packages": { diff --git a/scripts/watch-build-plugin.sh b/scripts/watch-build-plugin.sh index c21397f25..89e95badb 100644 --- a/scripts/watch-build-plugin.sh +++ b/scripts/watch-build-plugin.sh @@ -1 +1 @@ -rojo build plugin.project.json --plugin Rojo.rbxm --watch \ No newline at end of file +rojo build default.project.json --plugin Rojo.rbxm --watch \ No newline at end of file From c49206d271482acf3316a1b9ed88579dee1608c3 Mon Sep 17 00:00:00 2001 From: boatbomber Date: Fri, 8 Nov 2024 19:10:21 -0800 Subject: [PATCH 4/7] Rename project json and set up editor configs to make it work --- .vscode/extensions.json | 8 ++++++++ .vscode/settings.json | 4 ++++ build.rs | 2 +- default.project.json => plugin.project.json | 0 plugin/test-place.project.json | 2 +- scripts/watch-build-plugin.sh | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json rename default.project.json => plugin.project.json (100%) diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..6ffebea28 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "JohnnyMorganz.luau-lsp", + "JohnnyMorganz.stylua", + "Kampfkarren.selene-vscode", + "rust-lang.rust-analyzer" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..f65783862 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "luau-lsp.sourcemap.rojoProjectFile": "plugin.project.json", + "luau-lsp.sourcemap.autogenerate": true +} diff --git a/build.rs b/build.rs index b66c202c1..7a95adf33 100644 --- a/build.rs +++ b/build.rs @@ -54,7 +54,7 @@ fn main() -> Result<(), anyhow::Error> { ); let snapshot = VfsSnapshot::dir(hashmap! { - "default.project.json" => snapshot_from_fs_path(&root_dir.join("default.project.json"))?, + "default.project.json" => snapshot_from_fs_path(&root_dir.join("plugin.project.json"))?, "fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?, "http" => snapshot_from_fs_path(&plugin_dir.join("http"))?, "log" => snapshot_from_fs_path(&plugin_dir.join("log"))?, diff --git a/default.project.json b/plugin.project.json similarity index 100% rename from default.project.json rename to plugin.project.json diff --git a/plugin/test-place.project.json b/plugin/test-place.project.json index c1ddd8607..f4da9815a 100644 --- a/plugin/test-place.project.json +++ b/plugin/test-place.project.json @@ -5,7 +5,7 @@ "ReplicatedStorage": { "Rojo": { - "$path": "../default.project.json" + "$path": "../plugin.project.json" }, "Packages": { diff --git a/scripts/watch-build-plugin.sh b/scripts/watch-build-plugin.sh index 89e95badb..c21397f25 100644 --- a/scripts/watch-build-plugin.sh +++ b/scripts/watch-build-plugin.sh @@ -1 +1 @@ -rojo build default.project.json --plugin Rojo.rbxm --watch \ No newline at end of file +rojo build plugin.project.json --plugin Rojo.rbxm --watch \ No newline at end of file From ba3caf9a9e33c91fafc8b3940e16c7785ff3ac73 Mon Sep 17 00:00:00 2001 From: boatbomber Date: Sat, 9 Nov 2024 18:58:07 -0800 Subject: [PATCH 5/7] Add emacs config --- .dir-locals.el | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 000000000..25e8e6c10 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,2 @@ +((nil . ((eglot-luau-rojo-project-path . "plugin.project.json") + (eglot-luau-rojo-sourcemap-enabled . 't)))) \ No newline at end of file From 234b2272f76e913107bac27f8cbfa21885027a84 Mon Sep 17 00:00:00 2001 From: boatbomber Date: Sun, 10 Nov 2024 14:40:00 -0800 Subject: [PATCH 6/7] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1718858a..1441c04a1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: version: 'v0.3.0' - name: Build Plugin - run: rojo build plugin --output Rojo.rbxm + run: rojo build plugin.project.json --output Rojo.rbxm - name: Upload Plugin to Release env: From d97d96714695eb6407017917d889823e1ef24802 Mon Sep 17 00:00:00 2001 From: kennethloeffler Date: Sun, 10 Nov 2024 23:01:51 +0000 Subject: [PATCH 7/7] Modify build script to include a plugin subfolder --- build.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index 7a95adf33..e423b61be 100644 --- a/build.rs +++ b/build.rs @@ -55,13 +55,15 @@ fn main() -> Result<(), anyhow::Error> { let snapshot = VfsSnapshot::dir(hashmap! { "default.project.json" => snapshot_from_fs_path(&root_dir.join("plugin.project.json"))?, - "fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?, - "http" => snapshot_from_fs_path(&plugin_dir.join("http"))?, - "log" => snapshot_from_fs_path(&plugin_dir.join("log"))?, - "rbx_dom_lua" => snapshot_from_fs_path(&plugin_dir.join("rbx_dom_lua"))?, - "src" => snapshot_from_fs_path(&plugin_dir.join("src"))?, - "Packages" => snapshot_from_fs_path(&plugin_dir.join("Packages"))?, - "Version.txt" => snapshot_from_fs_path(&plugin_dir.join("Version.txt"))?, + "plugin" => VfsSnapshot::dir(hashmap! { + "fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?, + "http" => snapshot_from_fs_path(&plugin_dir.join("http"))?, + "log" => snapshot_from_fs_path(&plugin_dir.join("log"))?, + "rbx_dom_lua" => snapshot_from_fs_path(&plugin_dir.join("rbx_dom_lua"))?, + "src" => snapshot_from_fs_path(&plugin_dir.join("src"))?, + "Packages" => snapshot_from_fs_path(&plugin_dir.join("Packages"))?, + "Version.txt" => snapshot_from_fs_path(&plugin_dir.join("Version.txt"))?, + }), }); let out_path = Path::new(&out_dir).join("plugin.bincode");