Plugin dev ux improvements (#992)

Co-authored-by: kennethloeffler <kenloef@gmail.com>
This commit is contained in:
boatbomber
2024-11-10 15:53:58 -08:00
committed by GitHub
parent 8c33100d7a
commit b7d3394464
14 changed files with 60 additions and 30 deletions

2
.dir-locals.el Normal file
View File

@@ -0,0 +1,2 @@
((nil . ((eglot-luau-rojo-project-path . "plugin.project.json")
(eglot-luau-rojo-sourcemap-enabled . 't))))

View File

@@ -31,7 +31,7 @@ jobs:
version: 'v0.3.0' version: 'v0.3.0'
- name: Build Plugin - name: Build Plugin
run: rojo build plugin --output Rojo.rbxm run: rojo build plugin.project.json --output Rojo.rbxm
- name: Upload Plugin to Release - name: Upload Plugin to Release
env: env:

4
.gitignore vendored
View File

@@ -10,8 +10,8 @@
/*.rbxl /*.rbxl
/*.rbxlx /*.rbxlx
# Test places for the Roblox Studio Plugin # Sourcemap for the Rojo plugin (for better intellisense)
/plugin/*.rbxlx /sourcemap.json
# Roblox Studio holds 'lock' files on places # Roblox Studio holds 'lock' files on places
*.rbxl.lock *.rbxl.lock

8
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"recommendations": [
"JohnnyMorganz.luau-lsp",
"JohnnyMorganz.stylua",
"Kampfkarren.selene-vscode",
"rust-lang.rust-analyzer"
]
}

4
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"luau-lsp.sourcemap.rojoProjectFile": "plugin.project.json",
"luau-lsp.sourcemap.autogenerate": true
}

View File

@@ -16,6 +16,23 @@ You'll want these tools to work on Rojo:
* Latest stable Rust compiler * Latest stable Rust compiler
* Latest stable [Rojo](https://github.com/rojo-rbx/rojo) * Latest stable [Rojo](https://github.com/rojo-rbx/rojo)
* [Foreman](https://github.com/Roblox/foreman) * [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 automatically 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
Documentation impacts way more people than the individual lines of code we write. Documentation impacts way more people than the individual lines of code we write.

View File

@@ -41,12 +41,12 @@ fn snapshot_from_fs_path(path: &Path) -> io::Result<VfsSnapshot> {
fn main() -> Result<(), anyhow::Error> { fn main() -> Result<(), anyhow::Error> {
let out_dir = env::var_os("OUT_DIR").unwrap(); let out_dir = env::var_os("OUT_DIR").unwrap();
let root_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap(); let root_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let plugin_root = PathBuf::from(root_dir).join("plugin"); let plugin_dir = root_dir.join("plugin");
let our_version = Version::parse(env::var_os("CARGO_PKG_VERSION").unwrap().to_str().unwrap())?; let our_version = Version::parse(env::var_os("CARGO_PKG_VERSION").unwrap().to_str().unwrap())?;
let plugin_version = 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!( assert_eq!(
our_version, plugin_version, our_version, plugin_version,
@@ -54,14 +54,16 @@ fn main() -> Result<(), anyhow::Error> {
); );
let snapshot = VfsSnapshot::dir(hashmap! { let snapshot = VfsSnapshot::dir(hashmap! {
"default.project.json" => snapshot_from_fs_path(&plugin_root.join("default.project.json"))?, "default.project.json" => snapshot_from_fs_path(&root_dir.join("plugin.project.json"))?,
"fmt" => snapshot_from_fs_path(&plugin_root.join("fmt"))?, "plugin" => VfsSnapshot::dir(hashmap! {
"http" => snapshot_from_fs_path(&plugin_root.join("http"))?, "fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?,
"log" => snapshot_from_fs_path(&plugin_root.join("log"))?, "http" => snapshot_from_fs_path(&plugin_dir.join("http"))?,
"rbx_dom_lua" => snapshot_from_fs_path(&plugin_root.join("rbx_dom_lua"))?, "log" => snapshot_from_fs_path(&plugin_dir.join("log"))?,
"src" => snapshot_from_fs_path(&plugin_root.join("src"))?, "rbx_dom_lua" => snapshot_from_fs_path(&plugin_dir.join("rbx_dom_lua"))?,
"Packages" => snapshot_from_fs_path(&plugin_root.join("Packages"))?, "src" => snapshot_from_fs_path(&plugin_dir.join("src"))?,
"Version.txt" => snapshot_from_fs_path(&plugin_root.join("Version.txt"))?, "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"); let out_path = Path::new(&out_dir).join("plugin.bincode");

View File

@@ -3,25 +3,25 @@
"tree": { "tree": {
"$className": "Folder", "$className": "Folder",
"Plugin": { "Plugin": {
"$path": "src" "$path": "plugin/src"
}, },
"Packages": { "Packages": {
"$path": "Packages", "$path": "plugin/Packages",
"Log": { "Log": {
"$path": "log" "$path": "plugin/log"
}, },
"Http": { "Http": {
"$path": "http" "$path": "plugin/http"
}, },
"Fmt": { "Fmt": {
"$path": "fmt" "$path": "plugin/fmt"
}, },
"RbxDom": { "RbxDom": {
"$path": "rbx_dom_lua" "$path": "plugin/rbx_dom_lua"
} }
}, },
"Version": { "Version": {
"$path": "Version.txt" "$path": "plugin/Version.txt"
} }
} }
} }

View File

@@ -1,6 +1,6 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage") local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TestEZ = require(ReplicatedStorage.Packages.TestEZ) local TestEZ = require(ReplicatedStorage.Packages:WaitForChild("TestEZ", 10))
local Rojo = ReplicatedStorage.Rojo local Rojo = ReplicatedStorage.Rojo

View File

@@ -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

View File

@@ -5,7 +5,7 @@
"ReplicatedStorage": { "ReplicatedStorage": {
"Rojo": { "Rojo": {
"$path": "default.project.json" "$path": "../plugin.project.json"
}, },
"Packages": { "Packages": {

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1 @@
rojo build plugin.project.json --plugin Rojo.rbxm --watch