A standalone Luau runtime
Find a file
2023-01-19 22:14:52 -05:00
.github/workflows Implement downloading of type definition files in CLI 2023-01-19 13:18:15 -05:00
.lune Implement console global 2023-01-19 22:10:34 -05:00
.vscode Fix clippy lints 2023-01-18 21:11:47 -05:00
src Fix formatting nitpick 2023-01-19 22:14:52 -05:00
.gitignore Initial commit 2023-01-18 20:47:14 -05:00
.luaurc Initial commit 2023-01-18 20:47:14 -05:00
aftman.toml Initial commit 2023-01-18 20:47:14 -05:00
Cargo.lock Version 0.0.3 2023-01-19 22:12:25 -05:00
Cargo.toml Version 0.0.3 2023-01-19 22:12:25 -05:00
CHANGELOG.md Version 0.0.3 2023-01-19 22:12:25 -05:00
LICENSE.txt Add readme, license, cargo metadata 2023-01-18 21:19:10 -05:00
lune.yml Version 0.0.3 2023-01-19 22:12:25 -05:00
luneTypes.d.luau Version 0.0.3 2023-01-19 22:12:25 -05:00
README.md Implement console global 2023-01-19 22:10:34 -05:00
selene.toml Initial commit 2023-01-18 20:47:14 -05:00
stylua.toml Initial commit 2023-01-18 20:47:14 -05:00

Lune 🌙

CI Release

A Luau script runner


🚀 Use the ergonomics and readability of Luau instead of shell scripts 🚀

Full example & walkthrough

⚙️ Installation

The preferred way of installing Lune is using Aftman.

This will add lune to an aftman.toml file in the current directory, or create one if it does not exist:

aftman add filiptibell/lune

You can also download pre-built binaries for most systems directly from the GitHub Releases page.

✏️ Writing Lune Scripts

Check out the examples of how to write a script in the .lune folder !

🔎 Full list of APIs
console - Logging & formatting
type console = {
	resetColor: () -> (),
	setColor: (color: "black" | "red" | "green" | "yellow" | "blue" | "purple" | "cyan" | "white") -> (),
	resetStyle: () -> (),
	setStyle: (color: "bold" | "dim") -> (),
	format: (...any) -> (string),
	log: (...any) -> (),
	info: (...any) -> (),
	warn: (...any) -> (),
	error: (...any) -> (),
}
fs - Filesystem
type fs = {
	readFile: (path: string) -> string,
	readDir: (path: string) -> { string },
	writeFile: (path: string, contents: string) -> (),
	writeDir: (path: string) -> (),
	removeFile: (path: string) -> (),
	removeDir: (path: string) -> (),
	isFile: (path: string) -> boolean,
	isDir: (path: string) -> boolean,
}
net - Networking
type net = {
	request: (config: string | {
		url: string,
		method: ("GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS" | "PATCH")?,
		headers: { [string]: string }?,
		body: string?,
	}) -> {
		ok: boolean,
		statusCode: number,
		statusMessage: string,
		headers: { [string]: string },
		body: string,
	},
	jsonEncode: (value: any, pretty: boolean?) -> string,
	jsonDecode: (encoded: string) -> any,
}
process - Current process & child processes
type process = {
	getEnvVars: () -> { string },
	getEnvVar: (key: string) -> string?,
	setEnvVar: (key: string, value: string) -> (),
	exit: (code: number?) -> (),
	spawn: (program: string, params: { string }?) -> {
		ok: boolean,
		code: number,
		stdout: string,
		stderr: string,
	},
}
🔀 Example translation from Bash
#!/bin/bash
VALID=true
COUNT=1
while [ $VALID ]
do
    echo $COUNT
    if [ $COUNT -eq 5 ];
    then
        break
    fi
    ((COUNT++))
done

With Lune & Luau:

local valid = true
local count = 1
while valid do
    print(count)
    if count == 5 then
        break
    end
    count += 1
end
🧑‍💻 Configuring VSCode for Lune

Lune puts developer experience first, and as such provides type definitions and configurations for several tools out of the box.

Luau LSP
  1. Use lune --download-luau-types to download Luau types (luneTypes.d.luau) to the current directory
  2. Set your definition files setting to include luneTypes.d.luau, an example can be found in the .vscode folder in this repository
Selene
  1. Use lune --download-selene-types to download Selene types (lune.yml) to the current directory
  2. Use either std = "roblox-lune" or std = "luau+lune" in your selene.toml configuration file

NOTE: It is highly recommended to add any type definition files to your .gitignore and to only download them using these commands, since this guarantees that you have type definitions compatible with your installed version of Lune.

🏃 Running Lune Scripts

When you've written a script with either a .lua or .luau extension, you can run it:

lune script-name

This will look for the script script-name in a few locations:

  • The current directory
  • The folder lune in the current directory, if it exists
  • The folder .lune in the current directory, if it exists

If you don't want Lune to look in sub-directories you can provide a full file path with the file extension included, instead of only the file name.