chore: Make jecs a dependency, bump jecs to v0.3.0
+ Make jecs a wally dependency instead of a file in lib. This wasn't done earlier due to wally packages not being able to be used outside of Roblox without dynamically requiring them. Now, a script is used to download the latest source of jecsfrom Github associated with the version in the manifest. + Bump jecs-utils to v0.1.3 and release
This commit is contained in:
parent
ae3042a1ab
commit
cab13e4213
23 changed files with 117 additions and 1916 deletions
|
@ -5,7 +5,7 @@
|
|||
"current": {
|
||||
"name": "path",
|
||||
"sources": {
|
||||
"@jecs": "lib/jecs"
|
||||
"@jecs": "Packages/jecs"
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
|
|
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
|
@ -64,6 +64,15 @@ jobs:
|
|||
- name: Install Luau
|
||||
uses: encodedvenom/install-luau@v2.1
|
||||
|
||||
- name: Install Rokit
|
||||
uses: CompeyDev/setup-rokit@v0.1.2
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Download Jecs
|
||||
run: |
|
||||
lune run download-jecs
|
||||
|
||||
- name: Run Unit Tests
|
||||
run: |
|
||||
output=$(luau test/tests.luau)
|
||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -55,3 +55,7 @@ WallyPatches
|
|||
roblox.toml
|
||||
sourcemap.json
|
||||
globalTypes.d.luau
|
||||
# Used for testing, unfortunately we can't just install it with wally and expect it to work in vanilla luau
|
||||
jecs.luau
|
||||
# Stores Github PAT
|
||||
.env
|
||||
|
|
2
.luaurc
2
.luaurc
|
@ -3,6 +3,6 @@
|
|||
"aliases": {
|
||||
"jecs_utils": "lib",
|
||||
"testkit": "test/testkit",
|
||||
"jecs": "lib/jecs"
|
||||
"jecs": "jecs"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
--!strict
|
||||
local spawn = require("util/spawn")
|
||||
|
||||
spawn.start("lune run install-packages")
|
||||
spawn.start("rojo sourcemap dev.project.json -o sourcemap.json")
|
||||
spawn.start(
|
||||
"luau-lsp analyze --base-luaurc=.luaurc --sourcemap=sourcemap.json --settings=luau_lsp_settings.json --no-strict-dm-types --ignore Packages/**/*.lua --ignore Packages/**/*.luau --ignore lib/jecs.luau lib/"
|
||||
"luau-lsp analyze --base-luaurc=.luaurc --sourcemap=sourcemap.json --settings=luau_lsp_settings.json --no-strict-dm-types --ignore Packages/**/*.lua --ignore Packages/**/*.luau --ignore Packages/*.lua --ignore Packages/*.luau lib/"
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
--!strict
|
||||
local spawn = require("util/spawn")
|
||||
|
||||
spawn.start("lune run install-packages")
|
||||
spawn.start("rojo sourcemap dev.project.json -o sourcemap.json")
|
||||
spawn.start("darklua process --config .darklua.json lib/ dist/", { env = { ROBLOX_DEV = "false" } })
|
||||
spawn.start("rojo build default.project.json -o build.rbxm")
|
||||
|
|
|
@ -4,4 +4,5 @@ local spawn = require("util/spawn")
|
|||
spawn.start("lune run analyze")
|
||||
spawn.start("stylua lib/")
|
||||
spawn.start("selene lib/")
|
||||
spawn.start("lune run download-jecs")
|
||||
spawn.start("luau test/tests.luau")
|
||||
|
|
|
@ -4,11 +4,17 @@ local stdio = require("@lune/stdio")
|
|||
local task = require("@lune/task")
|
||||
|
||||
local spawn = require("util/spawn")
|
||||
local watch = require("util/watch")
|
||||
|
||||
task.spawn(watch, "wally.toml", function()
|
||||
spawn.spawn("lune run install-packages")
|
||||
end, false)
|
||||
spawn.start("lune run install-packages")
|
||||
|
||||
spawn.spawn("rojo sourcemap dev.project.json -o sourcemap.json --watch")
|
||||
spawn.spawn("darklua process --config .darklua.json --watch lib/ dist/", { env = { ROBLOX_DEV = "true" } })
|
||||
|
||||
task.wait(1)
|
||||
task.wait(2.5)
|
||||
|
||||
while true do
|
||||
local start_commit = stdio.prompt("confirm", "Start commit? -- `y` to start a commit, `n` to exit the script")
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
local spawn = require("util/spawn")
|
||||
|
||||
spawn.start("rojo sourcemap dev.project.json -o sourcemap.json")
|
||||
spawn.start("lune run install-packages")
|
||||
spawn.start("darklua process --config .darklua.json lib/ dist/", { env = { ROBLOX_DEV = "false" } })
|
||||
|
|
67
.lune/download-jecs.luau
Normal file
67
.lune/download-jecs.luau
Normal file
|
@ -0,0 +1,67 @@
|
|||
--!strict
|
||||
local fs = require("@lune/fs")
|
||||
local net = require("@lune/net")
|
||||
local process = require("@lune/process")
|
||||
local serde = require("@lune/serde")
|
||||
local spawn = require("util/spawn")
|
||||
|
||||
type wally_manifest = {
|
||||
package: {
|
||||
name: string,
|
||||
version: string,
|
||||
registry: string,
|
||||
realm: string,
|
||||
license: string?,
|
||||
exclude: { string }?,
|
||||
include: { string }?,
|
||||
},
|
||||
dependencies: {
|
||||
[string]: string,
|
||||
},
|
||||
}
|
||||
|
||||
local github_token: string = process.args[1]
|
||||
|
||||
if not github_token then
|
||||
local env_exists = fs.metadata(".env").exists
|
||||
if not env_exists then
|
||||
error("Usage: lune run download-jecs [GITHUB_PAT]\nAlternatively, put the PAT in an .env file under GITHUB_PAT")
|
||||
end
|
||||
|
||||
local env = serde.decode("toml", fs.readFile(".env"))
|
||||
local pat = env.GITHUB_PAT or error("Couldn't read GITHUB_PAT from .env")
|
||||
github_token = pat
|
||||
end
|
||||
|
||||
local manifest_contents = fs.readFile("wally.toml") or error("Couldn't read manifest.")
|
||||
local manifest: wally_manifest = serde.decode("toml", manifest_contents) or error("Couldn't decode manifest.")
|
||||
local jecs_version = string.match(manifest.dependencies.jecs, "%d.%d.%d") or error("Couldn't find jecs version.")
|
||||
|
||||
type gh_api_tag = {
|
||||
ref: string,
|
||||
node_id: string,
|
||||
url: string,
|
||||
object: {
|
||||
sha: string,
|
||||
type: string,
|
||||
url: string,
|
||||
},
|
||||
}
|
||||
|
||||
local response = net.request({
|
||||
url = `https://api.github.com/repos/ukendio/jecs/git/refs/tags/v{jecs_version}`,
|
||||
method = "GET",
|
||||
headers = {
|
||||
Accept = "application/vnd.github+json",
|
||||
Authorization = `Bearer {github_token}`,
|
||||
["X-GitHub-Api-Version"] = "2022-11-28",
|
||||
},
|
||||
})
|
||||
|
||||
if not response.ok then
|
||||
error(`Github api response not ok:\n{response.statusCode} @ {response.statusMessage}\n{response.body}`)
|
||||
end
|
||||
|
||||
local gh_api_tag: gh_api_tag = serde.decode("json", response.body)
|
||||
|
||||
spawn.start(`curl https://raw.githubusercontent.com/ukendio/jecs/{gh_api_tag.object.sha}/src/init.luau -o jecs.luau`)
|
|
@ -2,18 +2,20 @@
|
|||
local fs = require("@lune/fs")
|
||||
local task = require("@lune/task")
|
||||
|
||||
local function watch(path: string, on_change: (path: string, contents: string) -> ())
|
||||
local function watch(path: string, on_change: (path: string, contents: string) -> (), run_initially: boolean?)
|
||||
local initial_metadata = fs.metadata(path)
|
||||
if not initial_metadata.exists then
|
||||
return
|
||||
end
|
||||
|
||||
local initial_contents = fs.readFile(path)
|
||||
if run_initially then
|
||||
local initial_contents = fs.readFile(path)
|
||||
|
||||
local initial_success, why = pcall(on_change :: any, path, initial_contents) -- :: any because otherwise it shits itself and the type doesn't give (boolean, string)??
|
||||
if not initial_success then
|
||||
warn(`There was an error while trying to start the watcher thread:\n{why}`)
|
||||
return
|
||||
local initial_success, why = pcall(on_change :: any, path, initial_contents) -- :: any because otherwise it shits itself and the type doesn't give (boolean, string)??
|
||||
if not initial_success then
|
||||
warn(`There was an error while trying to start the watcher thread:\n{why}`)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local last_modification = initial_metadata.modifiedAt
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"mode": "relativeToFile",
|
||||
"fileAliases": {
|
||||
"@jecs_utils": "lib",
|
||||
"@jecs": "lib/jecs",
|
||||
"@jecs": "Packages/jecs",
|
||||
"@testkit": "test/testkit"
|
||||
},
|
||||
"directoryAliases": {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"ReplicatedStorage": {
|
||||
"Packages": {
|
||||
"$className": "Folder",
|
||||
"$path": "Packages",
|
||||
"jecs_utils": {
|
||||
"$path": "lib"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--!strict
|
||||
--!optimize 2
|
||||
local jecs = require("./jecs")
|
||||
local jecs = require("@jecs")
|
||||
type entity<T = nil> = jecs.Entity<T>
|
||||
type id<T = nil> = jecs.Id<T>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--!strict
|
||||
--!optimize 2
|
||||
local jecs = require("./jecs")
|
||||
local jecs = require("@jecs")
|
||||
type entity<T = nil> = jecs.Entity<T>
|
||||
type id<T = nil> = entity<T> | jecs.Pair
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--!strict
|
||||
--!optimize 2
|
||||
local jecs = require("./jecs")
|
||||
local jecs = require("@jecs")
|
||||
|
||||
local WORLD = require("./world")
|
||||
local collect = require("./collect")
|
||||
|
|
1894
lib/jecs.luau
1894
lib/jecs.luau
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,10 @@
|
|||
--!strict
|
||||
--!optimize 2
|
||||
local handle = require("./handle")
|
||||
local jecs = require("./jecs")
|
||||
local jecs = require("@jecs")
|
||||
local WORLD = require("./world").get
|
||||
|
||||
local refs: { [jecs.World]: { [any]: jecs.Entity } } = {}
|
||||
local refs: { [jecs.World]: { [any]: jecs.Entity<any> } } = {}
|
||||
|
||||
--- Gets an entity the given key references to.
|
||||
--- If the key is nil, an entirely new entity is created and returned.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--!strict
|
||||
--!optimize 2
|
||||
local jecs = require("./jecs")
|
||||
local jecs = require("@jecs")
|
||||
type entity<T = nil> = jecs.Entity<T>
|
||||
type i53 = number
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--!strict
|
||||
--!optimize 2
|
||||
local jecs = require("./jecs")
|
||||
local jecs = require("@jecs")
|
||||
|
||||
local WORLD: jecs.World
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
},
|
||||
"luau-lsp.require.mode": "relativeToFile",
|
||||
"luau-lsp.require.fileAliases": {
|
||||
"@jecs": "lib/jecs"
|
||||
}
|
||||
"@jecs": "Packages/jecs"
|
||||
},
|
||||
"luau-lsp.platform.type": "roblox"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--!strict
|
||||
-- stylua: ignore start
|
||||
local jecs = require("@jecs")
|
||||
local jecs = require("../jecs")
|
||||
local jecs_utils = require("@jecs_utils")
|
||||
local testkit = require("@testkit")
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mark-marks/jecs-utils"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
registry = "https://github.com/UpliftGames/wally-index"
|
||||
realm = "shared"
|
||||
license = "MIT"
|
||||
|
@ -15,3 +15,4 @@ include = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
jecs = "ukendio/jecs@0.3.0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue