mirror of
https://github.com/pesde-pkg/hello.git
synced 2024-12-12 03:10:37 +00:00
initial commit
This commit is contained in:
commit
02c01ce8b1
11 changed files with 184 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
build/
|
||||
packages/
|
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"luau-lsp.require.mode": "relativeToFile",
|
||||
"luau-lsp.require.directoryAliases": {
|
||||
"@lune/": "~/.lune/.typedefs/0.8.9/"
|
||||
}
|
||||
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -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.
|
32
README.md
Normal file
32
README.md
Normal file
|
@ -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.
|
5
bin.luau
Normal file
5
bin.luau
Normal file
|
@ -0,0 +1,5 @@
|
|||
--!strict
|
||||
|
||||
local hello = require("./lib")
|
||||
|
||||
hello()
|
7
lib.luau
Normal file
7
lib.luau
Normal file
|
@ -0,0 +1,7 @@
|
|||
--!strict
|
||||
|
||||
local function hello()
|
||||
print("<< PRINT MESSAGE >>")
|
||||
end
|
||||
|
||||
return hello
|
10
pesde-base.toml
Normal file
10
pesde-base.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
name = "pesde/hello"
|
||||
version = "1.0.0"
|
||||
description = "Prints hello. Intended for use in examples."
|
||||
authors = ["LukaDev <luka@lukadev.me> (lukadev.me)"]
|
||||
repository = "https://github.com/lukadev-0/pesde-hello"
|
||||
license = "MIT"
|
||||
includes = []
|
||||
|
||||
[indices]
|
||||
default = "https://github.com/daimond113/pesde-index"
|
8
pesde.lock
Normal file
8
pesde.lock
Normal file
|
@ -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"
|
14
pesde.toml
Normal file
14
pesde.toml
Normal file
|
@ -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"
|
2
rokit.toml
Normal file
2
rokit.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[tools]
|
||||
lune = "lune-org/lune@0.8.9"
|
77
scripts/build.luau
Normal file
77
scripts/build.luau
Normal file
|
@ -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
|
Loading…
Reference in a new issue