From 4c21273f1d322dbad95c57a15103fb4425628b3f Mon Sep 17 00:00:00 2001 From: vocksel Date: Sat, 2 Mar 2024 20:43:53 -0800 Subject: [PATCH] Fix paths in bundle (#5) I discovered that when consuming the package that the `FindFirstAncestor` paths break the way Wally sets up the instance tree --- .gitignore | 3 +++ .justfile | 8 ++++++++ .vscode/settings.json | 4 ++-- default.project.json | 2 +- example/default.project.json | 4 ++-- src/ServerEntity.luau | 4 +--- src/createReplicationSystem.lua | 12 +++++------- src/resolveServerId.luau | 6 ++---- test.project.json | 4 ++-- wally.toml | 2 ++ 10 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 0f90ec5..09f5add 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Build artifacts +build/ + # Rojo *.rbxl* *.rbxm* diff --git a/.justfile b/.justfile index 8757771..b2592fc 100644 --- a/.justfile +++ b/.justfile @@ -3,6 +3,7 @@ set dotenv-load project_dir := absolute_path("src") +build_dir := absolute_path("build") packages_dir := absolute_path("Packages") test_project := "test.project.json" @@ -19,6 +20,13 @@ build: build-example: rojo build example/default.project.json -o MatterReplicationExample.rbxl +build-package: + rm -rf {{ build_dir }} + mkdir {{ build_dir }} + wally package --output package.tar + tar -xvf package.tar -C {{ build_dir }} + rm package.tar + lint: selene {{ project_dir }} stylua --check {{ project_dir }} diff --git a/.vscode/settings.json b/.vscode/settings.json index 08c9aba..972ff8b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "luau-lsp.sourcemap.rojoProjectFile": "default.project.json", + "luau-lsp.sourcemap.rojoProjectFile": "test.project.json", "luau-lsp.ignoreGlobs": [ "**/_Index/**", "**/build/**" @@ -7,4 +7,4 @@ "files.associations": { "*.luau": "lua" } -} +} \ No newline at end of file diff --git a/default.project.json b/default.project.json index e43f1f8..1f1fa61 100644 --- a/default.project.json +++ b/default.project.json @@ -1,5 +1,5 @@ { - "name": "MatterReplication", + "name": "matter-replication", "tree": { "$path": "src" } diff --git a/example/default.project.json b/example/default.project.json index d5e7b5e..f32eb68 100644 --- a/example/default.project.json +++ b/example/default.project.json @@ -1,5 +1,5 @@ { - "name": "MatterReplication Example", + "name": "matter-replication-example", "emitLegacyScripts": false, "tree": { "$className": "DataModel", @@ -12,4 +12,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/ServerEntity.luau b/src/ServerEntity.luau index d95790f..9ce839f 100644 --- a/src/ServerEntity.luau +++ b/src/ServerEntity.luau @@ -1,6 +1,4 @@ -local Root = script:FindFirstAncestor("MatterReplication") - -local Matter = require(Root.Parent.Matter) +local Matter = require(script.Parent.Parent.Matter) export type Data = { id: number, diff --git a/src/createReplicationSystem.lua b/src/createReplicationSystem.lua index b1765a5..1f14291 100644 --- a/src/createReplicationSystem.lua +++ b/src/createReplicationSystem.lua @@ -1,14 +1,12 @@ -local Root = script:FindFirstAncestor("MatterReplication") - local Players = game:GetService("Players") local RunService = game:GetService("RunService") -local Freeze = require(Root.Parent.Freeze) -local Matter = require(Root.Parent.Matter) -local MatterTypes = require(Root.MatterTypes) -local ServerEntity = require(Root.ServerEntity) +local Freeze = require(script.Parent.Parent.Freeze) +local Matter = require(script.Parent.Parent.Matter) +local MatterTypes = require(script.Parent.MatterTypes) +local ServerEntity = require(script.Parent.ServerEntity) -local componentReplicated = Root.componentReplicated +local componentReplicated = script.Parent.componentReplicated type World = MatterTypes.World type Component = MatterTypes.Component diff --git a/src/resolveServerId.luau b/src/resolveServerId.luau index db944be..972f390 100644 --- a/src/resolveServerId.luau +++ b/src/resolveServerId.luau @@ -1,7 +1,5 @@ -local Root = script:FindFirstAncestor("MatterReplication") - -local MatterTypes = require(Root.MatterTypes) -local ServerEntity = require(Root.ServerEntity) +local MatterTypes = require(script.Parent.MatterTypes) +local ServerEntity = require(script.Parent.ServerEntity) type World = MatterTypes.World diff --git a/test.project.json b/test.project.json index fc78a96..a717cd9 100644 --- a/test.project.json +++ b/test.project.json @@ -1,5 +1,5 @@ { - "name": "MatterReplication", + "name": "matter-replication-test", "tree": { "$className": "DataModel", "ReplicatedStorage": { @@ -8,4 +8,4 @@ } } } -} +} \ No newline at end of file diff --git a/wally.toml b/wally.toml index 0c0635b..833efef 100644 --- a/wally.toml +++ b/wally.toml @@ -3,6 +3,8 @@ name = "vocksel/matter-replication" version = "0.1.0" registry = "https://github.com/UpliftGames/wally-index" realm = "shared" +exclude = [ "*" ] +include = [ "src", "src/**", "default.project.json", "README.md", "LICENSE", ] [dependencies] Matter = "matter-ecs/matter@0.7.1"