From 2a66434f6b56e1736f9ad1c2b8b8821696357ef1 Mon Sep 17 00:00:00 2001 From: EwDev <74792428+ewd3v@users.noreply.github.com> Date: Tue, 30 Jun 2026 23:13:39 +0200 Subject: [PATCH 1/6] add init_from_path test --- .../build-tests/init_from_path/default.project.json | 9 +++++++++ .../build-tests/init_from_path/folder/ignore_me.luau | 1 + rojo-test/build-tests/init_from_path/folder/init.luau | 1 + tests/tests/build.rs | 1 + 4 files changed, 12 insertions(+) create mode 100644 rojo-test/build-tests/init_from_path/default.project.json create mode 100644 rojo-test/build-tests/init_from_path/folder/ignore_me.luau create mode 100644 rojo-test/build-tests/init_from_path/folder/init.luau diff --git a/rojo-test/build-tests/init_from_path/default.project.json b/rojo-test/build-tests/init_from_path/default.project.json new file mode 100644 index 00000000..aecd9d65 --- /dev/null +++ b/rojo-test/build-tests/init_from_path/default.project.json @@ -0,0 +1,9 @@ +{ + "name": "init_from_path", + "tree": { + "$className": "Folder", + "folder": { + "$path": "folder/init.luau" + } + } +} \ No newline at end of file diff --git a/rojo-test/build-tests/init_from_path/folder/ignore_me.luau b/rojo-test/build-tests/init_from_path/folder/ignore_me.luau new file mode 100644 index 00000000..0b5801fc --- /dev/null +++ b/rojo-test/build-tests/init_from_path/folder/ignore_me.luau @@ -0,0 +1 @@ +-- ignore_me.luau diff --git a/rojo-test/build-tests/init_from_path/folder/init.luau b/rojo-test/build-tests/init_from_path/folder/init.luau new file mode 100644 index 00000000..bbc821f4 --- /dev/null +++ b/rojo-test/build-tests/init_from_path/folder/init.luau @@ -0,0 +1 @@ +-- init.luau diff --git a/tests/tests/build.rs b/tests/tests/build.rs index c7873050..56315e42 100644 --- a/tests/tests/build.rs +++ b/tests/tests/build.rs @@ -66,6 +66,7 @@ gen_build_tests! { no_name_project, no_name_top_level_project, plugin_init, + init_from_path, } fn run_build_test(test_name: &str) { From 0dcd76035e28a7fdc50c4bbe3a94a77550238c96 Mon Sep 17 00:00:00 2001 From: EwDev <74792428+ewd3v@users.noreply.github.com> Date: Wed, 1 Jul 2026 20:00:18 +0200 Subject: [PATCH 2/6] allow lua_init files to be referenced in $path --- ..._to_end__tests__build__init_from_path.snap | 18 ++++++++++ src/snapshot_middleware/dir.rs | 17 ++++++++- src/snapshot_middleware/mod.rs | 36 ++++++------------- 3 files changed, 45 insertions(+), 26 deletions(-) create mode 100644 rojo-test/build-test-snapshots/end_to_end__tests__build__init_from_path.snap diff --git a/rojo-test/build-test-snapshots/end_to_end__tests__build__init_from_path.snap b/rojo-test/build-test-snapshots/end_to_end__tests__build__init_from_path.snap new file mode 100644 index 00000000..7f446250 --- /dev/null +++ b/rojo-test/build-test-snapshots/end_to_end__tests__build__init_from_path.snap @@ -0,0 +1,18 @@ +--- +source: tests/tests/build.rs +expression: contents +--- + + + + init_from_path + + + + folder + + + + + diff --git a/src/snapshot_middleware/dir.rs b/src/snapshot_middleware/dir.rs index b9f62743..2ff0b6bf 100644 --- a/src/snapshot_middleware/dir.rs +++ b/src/snapshot_middleware/dir.rs @@ -51,7 +51,7 @@ pub fn snapshot_dir_no_meta( for entry in vfs.read_dir(path)? { let entry = entry?; - if !passes_filter_rules(&entry) { + if !passes_filter_rules(&entry) || is_init_file(entry.path()).unwrap() { continue; } @@ -221,6 +221,21 @@ pub fn syncback_dir_no_meta<'sync>( }) } +fn is_init_file(path: &Path) -> anyhow::Result { + let file_name = path + .file_name() + .and_then(|n| n.to_str()) + .with_context(|| format!("file name of {} is invalid", path.display()))?; + + match file_name { + "init.server.luau" | "init.server.lua" | "init.client.luau" | "init.client.lua" + | "init.plugin.luau" | "init.plugin.lua" | "init.luau" | "init.lua" | "init.csv" => { + Ok(true) + } + _ => Ok(false), + } +} + #[cfg(test)] mod test { use super::*; diff --git a/src/snapshot_middleware/mod.rs b/src/snapshot_middleware/mod.rs index fadce5f6..b2c6faaf 100644 --- a/src/snapshot_middleware/mod.rs +++ b/src/snapshot_middleware/mod.rs @@ -72,32 +72,18 @@ pub fn snapshot_from_vfs( None => return Ok(None), }; - if meta.is_dir() { - let (middleware, dir_name, init_path) = get_dir_middleware(vfs, path)?; - // TODO: Support user defined init paths - // If and when we do, make sure to go support it in - // `Project::set_file_name`, as right now it special-cases - // `default.project.json` as an `init` path. - match middleware { - Middleware::Dir => middleware.snapshot(context, vfs, path, dir_name), - _ => middleware.snapshot(context, vfs, &init_path, dir_name), - } - } else { - let file_name = path - .file_name() - .and_then(|n| n.to_str()) - .with_context(|| format!("file name of {} is invalid", path.display()))?; + if !meta.is_dir() { + return snapshot_from_path(context, vfs, path); + } - // TODO: Is this even necessary anymore? - match file_name { - "init.server.luau" | "init.server.lua" | "init.client.luau" | "init.client.lua" - | "init.plugin.luau" | "init.plugin.lua" | "init.luau" | "init.lua" | "init.csv" => { - return Ok(None) - } - _ => {} - } - - snapshot_from_path(context, vfs, path) + let (middleware, dir_name, init_path) = get_dir_middleware(vfs, path)?; + // TODO: Support user defined init paths + // If and when we do, make sure to go support it in + // `Project::set_file_name`, as right now it special-cases + // `default.project.json` as an `init` path. + match middleware { + Middleware::Dir => middleware.snapshot(context, vfs, path, dir_name), + _ => middleware.snapshot(context, vfs, &init_path, dir_name), } } From 234fbdd6cf3befd599f7c4c3390cd59c70ed0d32 Mon Sep 17 00:00:00 2001 From: EwDev <74792428+ewd3v@users.noreply.github.com> Date: Wed, 1 Jul 2026 20:11:26 +0200 Subject: [PATCH 3/6] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 339c0c6e..b0b5af48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Making a new release? Simply add the new header with the version and date undern * Fixed `/api/serialize` returning success when a requested instance ID is missing from the serve session tree. ([#1272]) * `rojo serve` now validates the `Host`/`Origin` headers to protect the local/private server against DNS rebinding, gates `/api/open` to local clients, and warns when bound to a network-reachable address. The accepted hosts can be extended with the `--allowed-hosts` option or a project's `serveAllowedHosts` field, for example to reach a network-exposed server by hostname. ([#1270]) * Fixed syncback not removing stale `$properties` entries when Studio resets a property to its engine default. ([#1244]) +* Fixed a bug where `$path` in an instance description couldn't reference an init script (i.e init.luau, init.sever.luau, etc). ([#1285]) [#1176]: https://github.com/rojo-rbx/rojo/pull/1176 [#1179]: https://github.com/rojo-rbx/rojo/pull/1179 From 20018ba70b174a7edb7d07260216e9687cca7059 Mon Sep 17 00:00:00 2001 From: EwDev <74792428+ewd3v@users.noreply.github.com> Date: Wed, 1 Jul 2026 20:18:10 +0200 Subject: [PATCH 4/6] fix pr link --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0b5af48..dd40c8e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Making a new release? Simply add the new header with the version and date undern * Fixed syncback not removing stale `$properties` entries when Studio resets a property to its engine default. ([#1244]) * Fixed a bug where `$path` in an instance description couldn't reference an init script (i.e init.luau, init.sever.luau, etc). ([#1285]) +[#1285]: https://github.com/rojo-rbx/rojo/pull/1285 [#1176]: https://github.com/rojo-rbx/rojo/pull/1176 [#1179]: https://github.com/rojo-rbx/rojo/pull/1179 [#1192]: https://github.com/rojo-rbx/rojo/pull/1192 From a7fd48de46d01aeec54eef386877ce2b105bca8e Mon Sep 17 00:00:00 2001 From: EwDev <74792428+ewd3v@users.noreply.github.com> Date: Thu, 2 Jul 2026 14:43:31 +0200 Subject: [PATCH 5/6] move changelog to Unreleased --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b24b3796..0b70cfbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ Making a new release? Simply add the new header with the version and date undern ## Unreleased +* Fixed a bug where `$path` in an instance description couldn't reference an init script (i.e init.luau, init.sever.luau, etc). ([#1285]) + +[#1285]: https://github.com/rojo-rbx/rojo/pull/1285 + ## [7.7.0] (July 1st, 2026) * `inf` and `nan` values in properties are now synced ([#1176]) @@ -49,9 +53,7 @@ Making a new release? Simply add the new header with the version and date undern * Fixed `/api/serialize` returning success when a requested instance ID is missing from the serve session tree. ([#1272]) * `rojo serve` now validates the `Host`/`Origin` headers to protect the local/private server against DNS rebinding, gates `/api/open` to local clients, and warns when bound to a network-reachable address. The accepted hosts can be extended with the `--allowed-hosts` option or a project's `serveAllowedHosts` field, for example to reach a network-exposed server by hostname. ([#1270]) * Fixed syncback not removing stale `$properties` entries when Studio resets a property to its engine default. ([#1244]) -* Fixed a bug where `$path` in an instance description couldn't reference an init script (i.e init.luau, init.sever.luau, etc). ([#1285]) -[#1285]: https://github.com/rojo-rbx/rojo/pull/1285 [#1176]: https://github.com/rojo-rbx/rojo/pull/1176 [#1179]: https://github.com/rojo-rbx/rojo/pull/1179 [#1192]: https://github.com/rojo-rbx/rojo/pull/1192 From ce883418d4c4c88cfdabefee9d966a99cfeedee3 Mon Sep 17 00:00:00 2001 From: EwDev <74792428+ewd3v@users.noreply.github.com> Date: Thu, 2 Jul 2026 14:43:51 +0200 Subject: [PATCH 6/6] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b70cfbc..8ab04afc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ Making a new release? Simply add the new header with the version and date undern ## Unreleased -* Fixed a bug where `$path` in an instance description couldn't reference an init script (i.e init.luau, init.sever.luau, etc). ([#1285]) +* Fixed a bug where `$path` in an instance description couldn't reference an init script directly (i.e init.luau, init.sever.luau, etc). ([#1285]) [#1285]: https://github.com/rojo-rbx/rojo/pull/1285