commit 02c01ce8b1213e4804fa7b78ee0c054e780a8e67 Author: LukaDev <47296785+lukadev-0@users.noreply.github.com> Date: Sat Oct 12 18:56:33 2024 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2022de8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +packages/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..17eb63b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "luau-lsp.require.mode": "relativeToFile", + "luau-lsp.require.directoryAliases": { + "@lune/": "~/.lune/.typedefs/0.8.9/" + } +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ebc44bf --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-present LukaDev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6a684c5 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# pesde/hello + +A pesde package that prints hello. This package is intended to be used in +examples. + +## Library + +The library contains a single function that prints hello. + +```luau +local hello = require("./packages/hello") + +hello() +``` + +## Binary + +The binary prints hello. + +```sh +pesde x pesde/hello +``` + +## Building + +The packages for different targets are generated with a script. + +```sh +pesde run build +``` + +The generated packages will appear in the `build` directory. diff --git a/bin.luau b/bin.luau new file mode 100644 index 0000000..1324264 --- /dev/null +++ b/bin.luau @@ -0,0 +1,5 @@ +--!strict + +local hello = require("./lib") + +hello() diff --git a/lib.luau b/lib.luau new file mode 100644 index 0000000..b00731d --- /dev/null +++ b/lib.luau @@ -0,0 +1,7 @@ +--!strict + +local function hello() + print("<< PRINT MESSAGE >>") +end + +return hello diff --git a/pesde-base.toml b/pesde-base.toml new file mode 100644 index 0000000..ccd0105 --- /dev/null +++ b/pesde-base.toml @@ -0,0 +1,10 @@ +name = "pesde/hello" +version = "1.0.0" +description = "Prints hello. Intended for use in examples." +authors = ["LukaDev (lukadev.me)"] +repository = "https://github.com/lukadev-0/pesde-hello" +license = "MIT" +includes = [] + +[indices] +default = "https://github.com/daimond113/pesde-index" diff --git a/pesde.lock b/pesde.lock new file mode 100644 index 0000000..ff3200d --- /dev/null +++ b/pesde.lock @@ -0,0 +1,8 @@ +name = "pesde/hello_root" +version = "1.0.0" +target = "lune" + +[workspace."pesde/hello"] +roblox = "build/roblox" +lune = "build/lune" +luau = "build/luau" diff --git a/pesde.toml b/pesde.toml new file mode 100644 index 0000000..da5d2b4 --- /dev/null +++ b/pesde.toml @@ -0,0 +1,14 @@ +name = "pesde/hello_root" +version = "1.0.0" +license = "MIT" +workspace_members = ["build/*"] +private = true + +[target] +environment = "lune" + +[scripts] +build = "scripts/build.luau" + +[indices] +default = "https://github.com/daimond113/pesde-index" diff --git a/rokit.toml b/rokit.toml new file mode 100644 index 0000000..7322ade --- /dev/null +++ b/rokit.toml @@ -0,0 +1,2 @@ +[tools] +lune = "lune-org/lune@0.8.9" diff --git a/scripts/build.luau b/scripts/build.luau new file mode 100644 index 0000000..6b65666 --- /dev/null +++ b/scripts/build.luau @@ -0,0 +1,77 @@ +--!strict + +local fs = require("@lune/fs") +local serde = require("@lune/serde") + +type Target = { + environment: string, + lib: string, + bin: string?, + build_files: { string }?, +} + +local TARGETS: { [string]: Target } = { + luau = { + environment = "luau", + lib = "lib.luau", + bin = "bin.luau", + }, + lune = { + environment = "lune", + lib = "lib.luau", + bin = "bin.luau", + }, + roblox = { + environment = "roblox", + lib = "lib.luau", + build_files = { "lib.luau" }, + }, +} + +local baseManifest = fs.readFile("pesde-base.toml") +local binScript = fs.readFile("bin.luau") +local libTemplate = fs.readFile("lib.luau") + +local manifest = serde.decode("toml", baseManifest) + +if fs.isDir("build") then + fs.removeDir("build") +end +fs.writeDir("build") + +for targetName, target in TARGETS do + local outDir = `build/{targetName}` + + fs.writeDir(outDir) + + local includes = { + "pesde.toml", + "README.md", + "LICENSE", + } + + fs.copy("LICENSE", `{outDir}/LICENSE`) + fs.copy("README.md", `{outDir}/README.md`) + + if target.lib then + local message = `Hello, pesde! ({manifest.name}@{manifest.version}, {targetName})` + local file = string.gsub(libTemplate, "<< PRINT MESSAGE >>", message) + + fs.writeFile(`{outDir}/{target.lib}`, file) + table.insert(includes, target.lib) + end + + if target.bin then + fs.writeFile(`{outDir}/{target.bin}`, binScript) + table.insert(includes, target.bin) + end + + local targetSection = serde.encode("toml", { target = target }, true) + local includesSection = serde.encode("toml", { includes = includes }, true) + + local manifestFile = baseManifest + manifestFile ..= "\n" .. targetSection + manifestFile = string.gsub(manifestFile, "includes = %[%]\n", includesSection) + + fs.writeFile(`{outDir}/pesde.toml`, manifestFile) +end