Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin dev ux improvements #992

Merged
merged 7 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((nil . ((eglot-luau-rojo-project-path . "plugin.project.json")
(eglot-luau-rojo-sourcemap-enabled . 't))))
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"JohnnyMorganz.luau-lsp",
"JohnnyMorganz.stylua",
"Kampfkarren.selene-vscode",
"rust-lang.rust-analyzer"
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"luau-lsp.sourcemap.rojoProjectFile": "plugin.project.json",
"luau-lsp.sourcemap.autogenerate": true
}
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ 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 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 impacts way more people than the individual lines of code we write.
Expand Down
24 changes: 13 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,29 @@ fn snapshot_from_fs_path(path: &Path) -> io::Result<VfsSnapshot> {
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,
"plugin version does not match Cargo version"
);

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"))?,
"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");
Expand Down
16 changes: 8 additions & 8 deletions plugin/default.project.json → plugin.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
2 changes: 1 addition & 1 deletion plugin/run-tests.server.lua
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 0 additions & 4 deletions plugin/test

This file was deleted.

2 changes: 1 addition & 1 deletion plugin/test-place.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

"ReplicatedStorage": {
"Rojo": {
"$path": "default.project.json"
"$path": "../plugin.project.json"
},

"Packages": {
Expand Down
2 changes: 0 additions & 2 deletions plugin/watch-build.sh

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/unit-test-plugin.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions scripts/watch-build-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rojo build plugin.project.json --plugin Rojo.rbxm --watch
Loading