merge: origin/main -> feature/process-stdin

This commit is contained in:
Erica Marigold 2023-09-29 19:05:25 +05:30
commit ac87772e61
33 changed files with 381 additions and 228 deletions

3
.gitattributes vendored
View file

@ -7,3 +7,6 @@
# Ensure all lua files use LF
*.lua eol=lf
*.luau eol=lf
# Ensure all txt files within tests use LF
tests/**/*.txt eol=lf

View file

@ -17,16 +17,37 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Install Just
uses: extractions/setup-just@v1
- name: Install Tooling
uses: ok-nick/setup-aftman@v0.4.2
- name: Check Formatting
run: cargo fmt -- --check
run: just fmt-check
analyze:
needs: ["fmt"]
name: Analyze and lint Luau files
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Just
uses: extractions/setup-just@v1
- name: Install Tooling
uses: ok-nick/setup-aftman@v0.4.2
- name: Analyze
run: just analyze
ci:
needs: ["fmt"]

View file

@ -10,9 +10,6 @@ defaults:
run:
shell: bash
env:
CARGO_TARGET_DIR: output
jobs:
init:
name: Init
@ -33,6 +30,7 @@ jobs:
build:
needs: ["init"]
strategy:
fail-fast: false
matrix:
include:
- name: Windows x86_64
@ -71,6 +69,9 @@ jobs:
with:
targets: ${{ matrix.cargo-target }}
- name: Install Just
uses: extractions/setup-just@v1
- name: Install build tooling (aarch64-unknown-linux-gnu)
if: matrix.cargo-target == 'aarch64-unknown-linux-gnu'
run: |
@ -79,26 +80,12 @@ jobs:
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Build binary
run: |
cargo build \
--locked --release --all-features \
--target ${{ matrix.cargo-target }}
run: just build --locked --release --target ${{ matrix.cargo-target }}
- name: Create binary archive
run: |
mkdir -p staging
if [ "${{ matrix.runner-os }}" = "windows-latest" ]; then
cp "output/${{ matrix.cargo-target }}/release/lune.exe" staging/
cd staging
7z a ../release.zip *
else
cp "output/${{ matrix.cargo-target }}/release/lune" staging/
cd staging
chmod +x lune
zip ../release.zip *
fi
- name: Create release archive
run: just zip-release ${{ matrix.cargo-target }}
- name: Upload binary artifact
- name: Upload release artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
@ -109,38 +96,19 @@ jobs:
runs-on: ubuntu-latest
needs: ["init", "build"]
steps:
- name: Download binaries
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Just
uses: extractions/setup-just@v1
- name: Download releases
uses: actions/download-artifact@v3
with:
path: ./binaries
path: ./releases
- name: Discover binaries
run: |
cd ./binaries
echo ""
echo "Binaries dir:"
ls -lhrt
echo ""
echo "Searching for zipped releases..."
for DIR in * ; do
if [ -d "$DIR" ]; then
cd "$DIR"
for FILE in * ; do
if [ ! -d "$FILE" ]; then
if [ "$FILE" = "release.zip" ]; then
echo "Found zipped release '$DIR'"
mv "$FILE" "../$DIR.zip"
rm -rf "../$DIR/"
fi
fi
done
cd ..
fi
done
echo ""
echo "Binaries dir:"
ls -lhrt
cd ..
- name: Unpack releases
run: just unpack-releases "./releases"
- name: Create release
uses: softprops/action-gh-release@v1
@ -150,5 +118,5 @@ jobs:
name: ${{ needs.init.outputs.version }}
tag_name: v${{ needs.init.outputs.version }}
fail_on_unmatched_files: true
files: ./binaries/*.zip
files: ./releases/*.zip
draft: true

7
.gitignore vendored
View file

@ -6,7 +6,14 @@
# Autogenerated dirs
/bin
/out
/target
/staging
/**/bin
/**/out
/**/target
/**/staging
# Autogenerated files

131
.justfile
View file

@ -1,11 +1,128 @@
# Run an individual test using the Lune CLI
run-test TEST_NAME:
cargo run -- "tests/{{TEST_NAME}}"
EXT := if os() == "windows" { ".exe" } else { "" }
CWD := invocation_directory()
BIN_NAME := "lune"
# Default hidden recipe for listing other recipes + cwd
[no-cd]
[no-exit-message]
[private]
default:
#!/usr/bin/env bash
set -euo pipefail
printf "Current directory:\n {{CWD}}\n"
just --list
# Builds the Lune CLI binary
[no-exit-message]
build *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cargo build --bin {{BIN_NAME}} {{ARGS}}
# Run an individual file using the Lune CLI
run-file FILE_NAME:
cargo run -- "{{FILE_NAME}}"
[no-exit-message]
run FILE_PATH:
#!/usr/bin/env bash
set -euo pipefail
cargo run --bin {{BIN_NAME}} -- "{{FILE_PATH}}"
# Run tests for the Lune library
test:
cargo test --lib
[no-exit-message]
test *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cargo test --lib -- {{ARGS}}
# Run tests for the Lune binary
[no-exit-message]
test-bin *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cargo test --bin {{BIN_NAME}} -- {{ARGS}}
# Apply formatting for all Rust & Luau files
[no-exit-message]
fmt:
#!/usr/bin/env bash
set -euo pipefail
stylua .lune scripts tests types \
--glob "tests/**/*.luau" \
--glob "!tests/roblox/rbx-test-files/**"
cargo fmt
# Check formatting for all Rust & Luau files
[no-exit-message]
fmt-check:
#!/usr/bin/env bash
set -euo pipefail
stylua .lune scripts tests types \
--glob "tests/**/*.luau" \
--glob "!tests/roblox/rbx-test-files/**"
cargo fmt --check
# Analyze and lint Luau files using luau-lsp
[no-exit-message]
analyze:
#!/usr/bin/env bash
set -euo pipefail
luau-lsp analyze .lune scripts tests types \
--settings=".vscode/settings.json" \
--ignore="tests/roblox/rbx-test-files/**"
# Zips up the built binary into a single zip file
[no-exit-message]
zip-release TARGET_TRIPLE:
#!/usr/bin/env bash
set -euo pipefail
rm -rf staging
rm -rf release.zip
mkdir -p staging
cp "target/{{TARGET_TRIPLE}}/release/{{BIN_NAME}}{{EXT}}" staging/
cd staging
if [ "{{os_family()}}" = "windows" ]; then
7z a ../release.zip *
else
chmod +x {{BIN_NAME}}
zip ../release.zip *
fi
cd "{{CWD}}"
rm -rf staging
# Used in GitHub workflow to move per-matrix release zips
[no-exit-message]
[private]
unpack-releases RELEASES_DIR:
#!/usr/bin/env bash
set -euo pipefail
#
if [ ! -d "{{RELEASES_DIR}}" ]; then
echo "Releases directory is missing"
exit 1
fi
#
cd "{{RELEASES_DIR}}"
echo ""
echo "Releases dir:"
ls -lhrt
echo ""
echo "Searching for zipped releases..."
#
for DIR in * ; do
if [ -d "$DIR" ]; then
cd "$DIR"
for FILE in * ; do
if [ ! -d "$FILE" ]; then
if [ "$FILE" = "release.zip" ]; then
echo "Found zipped release '$DIR'"
mv "$FILE" "../$DIR.zip"
rm -rf "../$DIR/"
fi
fi
done
cd ..
fi
done
#
echo ""
echo "Releases dir:"
ls -lhrt

View file

@ -1,21 +1,15 @@
{
// Luau - disable Roblox features, enable Lune typedefs & requires
"luau-lsp.sourcemap.enabled": false,
"luau-lsp.types.roblox": false,
"luau-lsp.require.mode": "relativeToFile",
"luau-lsp.require.directoryAliases": {
"@lune/": "./types/"
},
// Luau - ignore type defs file in docs dir and dev scripts we use
"luau-lsp.ignoreGlobs": [
"docs/*.d.luau",
"packages/lib-roblox/scripts/*.luau",
"tests/roblox/rbx-test-files/**/*.lua",
"tests/roblox/rbx-test-files/**/*.luau"
],
// Rust
"rust-analyzer.check.command": "clippy",
// Formatting
"editor.formatOnSave": true,
"stylua.searchParentDirectories": true,
"prettier.tabWidth": 2,

View file

@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added a new `datetime` built-in library for handling date & time values, parsing, formatting, and more ([#94])
- Added a new `datetime` built-in library for handling date & time values, parsing, formatting, and more. ([#94])
Example usage:
@ -57,11 +57,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Update to Luau version `0.594`
- Update to Luau version `0.596`.
- `process.spawn` now uses `powershell` instead of `/bin/bash` as the shell on Windows, with `shell = true`.
- CFrame and Vector3 values are now rounded to the nearest 2 ^ 16 decimal place to reduce floating point errors and diff noise. Note that this does not affect intermediate calculations done in lua, and only happens when a property value is set on an Instance.
### Fixed
- Fixed missing trailing newline when using the `warn` global
- Fixed list subcommand not listing global scripts without a local `.lune` / `lune` directory present.
- Fixed `net.serve` stopping when the returned `ServeHandle` is garbage collected.
- Fixed missing trailing newline when using the `warn` global.
- Fixed constructor for `CFrame` in the `roblox` built-in library not parsing the 12-arg overload correctly. ([#102])
- Fixed various functions for `CFrame` in the `roblox` built-in library being incorrect, specifically row-column ordering and some flipped signs. ([#103])
@ -128,7 +132,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Update to Luau version `0.591`
- Update to Luau version `0.591`.
- Lune's internal task scheduler and `require` functionality has been completely rewritten. <br/>
The new scheduler is much more stable, conforms to a larger test suite, and has a few additional benefits:

165
Cargo.lock generated
View file

@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aho-corasick"
version = "1.0.5"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783"
checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab"
dependencies = [
"memchr",
]
@ -150,7 +150,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -217,16 +217,15 @@ dependencies = [
[[package]]
name = "blake3"
version = "1.4.1"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5"
checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87"
dependencies = [
"arrayref",
"arrayvec 0.7.4",
"cc",
"cfg-if",
"constant_time_eq 0.3.0",
"digest",
]
[[package]]
@ -324,9 +323,9 @@ dependencies = [
[[package]]
name = "chrono_lc"
version = "0.1.3"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4556d06f1286632cf49ef465898936b17c1b903e232965f2b52ebbc6bd5390a"
checksum = "ec58ebe2c3ff4a2262806e7bcda70a74f8cebd173d8cef16e1e30705dc016d08"
dependencies = [
"chrono",
"lazy_static",
@ -339,9 +338,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.4.3"
version = "4.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6"
checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136"
dependencies = [
"clap_builder",
"clap_derive",
@ -349,9 +348,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.4.2"
version = "4.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08"
checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56"
dependencies = [
"anstream",
"anstyle",
@ -368,7 +367,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -510,7 +509,6 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
"subtle",
]
[[package]]
@ -645,9 +643,9 @@ dependencies = [
[[package]]
name = "fastrand"
version = "2.0.0"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "fd-lock"
@ -708,7 +706,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -778,9 +776,9 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]]
name = "glam"
version = "0.24.1"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42218cb640844e3872cc3c153dc975229e080a6c4733b34709ef445610550226"
checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945"
[[package]]
name = "glob"
@ -827,9 +825,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
[[package]]
name = "home"
@ -1090,9 +1088,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "luau0-src"
version = "0.7.4+luau594"
version = "0.7.5+luau596"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3a63bc31a97efdd1f4d0246c33bed3086f63a67cdf7d0451f68cb215aad20c"
checksum = "cda221ef787513a320f1de3ca8987d110fa7096c460a8f6feaeeba46d1551507"
dependencies = [
"cc",
]
@ -1407,7 +1405,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -1439,7 +1437,7 @@ dependencies = [
"line-wrap",
"quick-xml",
"serde",
"time 0.3.28",
"time 0.3.29",
]
[[package]]
@ -1465,21 +1463,21 @@ dependencies = [
[[package]]
name = "profiling"
version = "1.0.10"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45f10e75d83c7aec79a6aa46f897075890e156b105eebe51cfa0abce51af025f"
checksum = "f89dff0959d98c9758c88826cc002e2c3d0b9dfac4139711d1f30de442f1139b"
dependencies = [
"profiling-procmacros",
]
[[package]]
name = "profiling-procmacros"
version = "1.0.10"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74c55e9e629af5298a40e0fa106435b2da30484c4ec76b41d19bc4d00dd8b903"
checksum = "eb156a45b6b9fe8027497422179fb65afc84d36707a7ca98297bf06bccb8d43f"
dependencies = [
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -1757,7 +1755,7 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots 0.25.2",
"webpki-roots",
"winreg 0.50.0",
]
@ -1833,9 +1831,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.13"
version = "0.38.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662"
checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f"
dependencies = [
"bitflags 2.4.0",
"errno",
@ -1852,7 +1850,7 @@ checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8"
dependencies = [
"log",
"ring",
"rustls-webpki 0.101.5",
"rustls-webpki",
"sct",
]
@ -1867,19 +1865,9 @@ dependencies = [
[[package]]
name = "rustls-webpki"
version = "0.100.3"
version = "0.101.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "rustls-webpki"
version = "0.101.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed"
checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe"
dependencies = [
"ring",
"untrusted",
@ -1987,7 +1975,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -2047,9 +2035,9 @@ dependencies = [
[[package]]
name = "sha1"
version = "0.10.5"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
"cpufeatures",
@ -2097,9 +2085,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.11.0"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
[[package]]
name = "socket2"
@ -2203,12 +2191,6 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "subtle"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "syn"
version = "1.0.109"
@ -2222,9 +2204,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.33"
version = "2.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668"
checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
dependencies = [
"proc-macro2",
"quote",
@ -2246,9 +2228,9 @@ dependencies = [
[[package]]
name = "termcolor"
version = "1.2.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64"
dependencies = [
"winapi-util",
]
@ -2270,7 +2252,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -2300,22 +2282,22 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.28"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48"
checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe"
dependencies = [
"deranged",
"itoa",
"serde",
"time-core",
"time-macros 0.2.14",
"time-macros 0.2.15",
]
[[package]]
name = "time-core"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
[[package]]
name = "time-macros"
@ -2329,9 +2311,9 @@ dependencies = [
[[package]]
name = "time-macros"
version = "0.2.14"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572"
checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20"
dependencies = [
"time-core",
]
@ -2392,7 +2374,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -2407,9 +2389,9 @@ dependencies = [
[[package]]
name = "tokio-tungstenite"
version = "0.20.0"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2"
checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c"
dependencies = [
"futures-util",
"log",
@ -2417,14 +2399,14 @@ dependencies = [
"tokio",
"tokio-rustls",
"tungstenite",
"webpki-roots 0.23.1",
"webpki-roots",
]
[[package]]
name = "tokio-util"
version = "0.7.8"
version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d"
checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d"
dependencies = [
"bytes",
"futures-core",
@ -2495,7 +2477,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
]
[[package]]
@ -2545,9 +2527,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "tungstenite"
version = "0.20.0"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649"
checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9"
dependencies = [
"byteorder 1.4.3",
"bytes",
@ -2557,7 +2539,7 @@ dependencies = [
"log",
"rand",
"rustls",
"sha1 0.10.5",
"sha1 0.10.6",
"thiserror",
"url",
"utf-8",
@ -2608,9 +2590,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-width"
version = "0.1.10"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "unsafe-libyaml"
@ -2717,7 +2699,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
"wasm-bindgen-shared",
]
@ -2751,7 +2733,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.33",
"syn 2.0.37",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -2772,15 +2754,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "webpki-roots"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338"
dependencies = [
"rustls-webpki 0.100.3",
]
[[package]]
name = "webpki-roots"
version = "0.25.2"
@ -2805,9 +2778,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
@ -2989,9 +2962,9 @@ dependencies = [
[[package]]
name = "xml-rs"
version = "0.8.18"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab77e97b50aee93da431f2cee7cd0f43b4d1da3c408042f2d7d164187774f0a"
checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
[[package]]
name = "zeroize"

View file

@ -1,9 +1,9 @@
<!-- markdownlint-disable MD033 -->
<!-- markdownlint-disable MD041 -->
<img align="right" width="250" src="assets/logo/tilt_svg.svg" />
<img align="right" width="250" src="assets/logo/tilt_svg.svg" alt="Lune logo" />
---
<h1 align="center">Lune</h1>
<div align="center">
<div>
@ -22,26 +22,26 @@
</div>
</div>
---
<br/>
A standalone [Luau](https://luau-lang.org) script runtime.
A standalone [Luau](https://luau-lang.org) runtime.
Write and run scripts, similar to runtimes for other languages such as [Node](https://nodejs.org) / [Deno](https://deno.land), or [Luvit](https://luvit.io) for vanilla Lua.
Write and run programs, similar to runtimes for other languages such as [Node](https://nodejs.org), [Deno](https://deno.land), [Bun](https://bun.sh), or [Luvit](https://luvit.io) for vanilla Lua.
Lune provides fully asynchronous APIs wherever possible, and is built in Rust 🦀 for optimal safety and correctness.
Lune provides fully asynchronous APIs wherever possible, and is built in Rust 🦀 for speed, safety and correctness.
## Features
- 🌙 A strictly minimal but powerful interface that is easy to read and remember, just like Luau itself
- 🧰 Fully featured APIs for the filesystem, networking, stdio, all included in the small (~4mb) executable
- 🌙 Strictly minimal but powerful interface that is easy to read and remember, just like Luau itself
- 🧰 Fully featured APIs for the filesystem, networking, stdio, all included in the small (~5mb) executable
- 📚 World-class documentation, on the web _or_ directly in your editor, no network connection necessary
- 🏡 A familiar scripting environment for Roblox developers, with an included 1-to-1 task scheduler port
- 🏡 Familiar runtime environment for Roblox developers, with an included 1-to-1 task scheduler port
- ✏️ Optional built-in library for manipulating Roblox place & model files, and their instances
## Non-goals
- Making scripts short and terse - proper autocomplete / intellisense make scripting using Lune just as quick, and readability is important
- Running full Roblox game scripts outside of Roblox - there is some compatibility, but Lune is meant for different purposes
- Making programs short and terse - proper autocomplete / intellisense make using Lune just as quick, and readability is important
- Running full Roblox games outside of Roblox - there is some compatibility, but Lune is meant for different purposes
## Where do I start?

View file

@ -1,4 +1,4 @@
[tools]
luau-lsp = "JohnnyMorganz/luau-lsp@1.23.0"
luau-lsp = "JohnnyMorganz/luau-lsp@1.24.1"
selene = "Kampfkarren/selene@0.25.0"
stylua = "JohnnyMorganz/StyLua@0.18.1"
stylua = "JohnnyMorganz/StyLua@0.18.2"

View file

@ -1,4 +1,5 @@
--!nocheck
--!nolint UnknownGlobal
-- NOTE: This must be ran in Roblox Studio to get up-to-date font values

View file

@ -1,4 +1,5 @@
--!nocheck
--!nolint UnknownGlobal
-- NOTE: This must be ran in Roblox Studio to get up-to-date enum values

View file

@ -83,20 +83,15 @@ impl Cli {
// List files in `lune` and `.lune` directories, if wanted
// This will also exit early and not run anything else
if self.list {
let sorted_relative = match find_lune_scripts(false).await {
Ok(scripts) => sort_lune_scripts(scripts),
Err(e) => {
eprintln!("{e}");
return Ok(ExitCode::FAILURE);
}
};
let sorted_home_dir = match find_lune_scripts(true).await {
Ok(scripts) => sort_lune_scripts(scripts),
Err(e) => {
eprintln!("{e}");
return Ok(ExitCode::FAILURE);
}
};
let sorted_relative = find_lune_scripts(false).await.map(sort_lune_scripts);
let sorted_home_dir = find_lune_scripts(true).await.map(sort_lune_scripts);
if sorted_relative.is_err() && sorted_home_dir.is_err() {
eprintln!("{}", sorted_relative.unwrap_err());
return Ok(ExitCode::FAILURE);
}
let sorted_relative = sorted_relative.unwrap_or(Vec::new());
let sorted_home_dir = sorted_home_dir.unwrap_or(Vec::new());
let mut buffer = String::new();
if !sorted_relative.is_empty() {

View file

@ -12,7 +12,7 @@ use tokio::sync::{mpsc, oneshot, Mutex};
use crate::lune::{
scheduler::Scheduler,
util::{traits::LuaEmitErrorExt, TableBuilder},
util::{futures::yield_forever, traits::LuaEmitErrorExt, TableBuilder},
};
use super::{
@ -115,7 +115,11 @@ where
.http1_keepalive(true) // Web sockets must be kept alive
.serve(hyper_make_service)
.with_graceful_shutdown(async move {
shutdown_rx.recv().await;
if shutdown_rx.recv().await.is_none() {
// The channel was closed, meaning the serve handle
// was garbage collected by lua without being used
yield_forever().await;
}
});
if let Err(e) = result.await {
eprintln!("Net serve error: {e}")

View file

@ -99,7 +99,7 @@ impl<'lua> FromLua<'lua> for ProcessSpawnOptions {
LuaValue::Boolean(true) => {
this.shell = match env::consts::FAMILY {
"unix" => Some("/bin/sh".to_string()),
"windows" => Some("/bin/sh".to_string()),
"windows" => Some("powershell".to_string()),
_ => None,
};
}

18
src/lune/util/futures.rs Normal file
View file

@ -0,0 +1,18 @@
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
#[derive(Debug, Clone, Copy)]
pub struct YieldForever;
impl Future for YieldForever {
type Output = ();
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Pending
}
}
pub fn yield_forever() -> YieldForever {
YieldForever
}

View file

@ -1,6 +1,7 @@
mod table_builder;
pub mod formatting;
pub mod futures;
pub mod traits;
pub use table_builder::TableBuilder;

View file

@ -6,6 +6,8 @@ pub mod extension;
pub mod result;
pub mod types;
mod util;
use result::*;
pub use crate::roblox::shared::userdata::*;

View file

@ -5,7 +5,10 @@ use glam::Vec3;
use mlua::prelude::*;
use rbx_dom_weak::types::Vector3 as DomVector3;
use crate::{lune::util::TableBuilder, roblox::exports::LuaExportsTable};
use crate::{
lune::util::TableBuilder,
roblox::{datatypes::util::round_float_decimal, exports::LuaExportsTable},
};
use super::{super::*, EnumItem};
@ -212,9 +215,9 @@ impl From<DomVector3> for Vector3 {
impl From<Vector3> for DomVector3 {
fn from(v: Vector3) -> Self {
DomVector3 {
x: v.0.x,
y: v.0.y,
z: v.0.z,
x: round_float_decimal(v.0.x),
y: round_float_decimal(v.0.y),
z: round_float_decimal(v.0.z),
}
}
}

View file

@ -0,0 +1,16 @@
// HACK: We round to the nearest Very Small Decimal
// to reduce writing out floating point accumulation
// errors to files (mostly relevant for xml formats)
const ROUNDING: usize = 65_536; // 2 ^ 16
pub fn round_float_decimal(value: f32) -> f32 {
let place = ROUNDING as f32;
// Round only the fractional part, we do not want to
// lose any float precision in case a user for some
// reason has very very large float numbers in files
let whole = value.trunc();
let fract = (value.fract() * place).round() / place;
whole + fract
}

View file

@ -1,4 +1,4 @@
local DateTime = require("@lune/DateTime")
local DateTime = require("@lune/datetime")
local values = DateTime.fromIsoDate("2023-08-27T05:54:19Z"):toLocalTime()

View file

@ -52,7 +52,8 @@ if not success then
assert(
string.find(message, "Connection reset")
or string.find(message, "Connection closed")
or string.find(message, "Connection refused"),
or string.find(message, "Connection refused")
or string.find(message, "No connection could be made"), -- Windows Request Error
"Server did not stop responding to requests"
)
else

View file

@ -10,9 +10,12 @@ local thread = task.delay(1, function()
process.exit(1)
end)
local result = process.spawn("ls", {
"-a",
})
local IS_WINDOWS = process.os == "windows"
local result = process.spawn(
if IS_WINDOWS then "cmd" else "ls",
if IS_WINDOWS then { "/c", "dir" } else { "-a" }
)
task.cancel(thread)
@ -25,9 +28,10 @@ assert(string.find(result.stdout, "Cargo.toml") ~= nil, "Missing Cargo.toml in o
assert(string.find(result.stdout, ".gitignore") ~= nil, "Missing .gitignore in output")
-- It should also work the same when spawned using a shell
-- Note that the default on Windows is Powershell which has different flags / behavior
local shellResult = process.spawn("ls", {
"-a",
if IS_WINDOWS then "-Force" else "-a",
}, {
shell = true,
})
@ -40,17 +44,24 @@ assert(shellResult.stdout ~= "", "Stdout was empty (shell)")
assert(string.find(shellResult.stdout, "Cargo.toml") ~= nil, "Missing Cargo.toml in output (shell)")
assert(string.find(shellResult.stdout, ".gitignore") ~= nil, "Missing .gitignore in output (shell)")
local pwdCommand = if IS_WINDOWS then "cmd" else "pwd"
local pwdArgs = if IS_WINDOWS then { "/c", "cd" } else {}
-- Make sure the cwd option actually uses the directory we want
local rootPwd = process.spawn("pwd", {}, {
local rootPwd = process.spawn(pwdCommand, pwdArgs, {
cwd = "/",
}).stdout
rootPwd = string.gsub(rootPwd, "^%s+", "")
rootPwd = string.gsub(rootPwd, "%s+$", "")
if rootPwd ~= "/" then
-- Windows: <Drive Letter>:\, Unix: /
local expectedRootPwd = if IS_WINDOWS then string.sub(rootPwd, 1, 1) .. ":\\" else "/"
if rootPwd ~= expectedRootPwd then
error(
string.format(
"Current working directory for child process was not set correctly!"
.. "\nExpected '/', got '%s'",
.. "\nExpected '%s', got '%s'",
expectedRootPwd,
rootPwd
)
)
@ -58,12 +69,12 @@ end
-- Setting cwd should not change the cwd of this process
local pwdBefore = process.spawn("pwd").stdout
local pwdBefore = process.spawn(pwdCommand, pwdArgs).stdout
process.spawn("ls", {}, {
cwd = "/",
shell = true,
})
local pwdAfter = process.spawn("pwd").stdout
local pwdAfter = process.spawn(pwdCommand, pwdArgs).stdout
assert(pwdBefore == pwdAfter, "Current working directory changed after running child process")
--[[
@ -74,7 +85,10 @@ assert(pwdBefore == pwdAfter, "Current working directory changed after running c
local homeDir1 = process.spawn("echo $HOME", nil, {
shell = true,
}).stdout
local homeDir2 = process.spawn("pwd", nil, {
-- Powershell for windows uses `$pwd.Path` instead of `pwd` as pwd would return a PathInfo object,
-- using $pwd.Path gets the Path property of the PathInfo object.
local homeDir2 = process.spawn(if IS_WINDOWS then "$pwd.Path" else "pwd", nil, {
shell = true,
cwd = "~",
}).stdout
@ -94,7 +108,8 @@ assert(homeDir1 == homeDir2, "Home dirs did not match when performing tilde subs
local SLEEP_DURATION = 1 / 4
local SLEEP_SAMPLES = 2
local thread2 = task.delay(SLEEP_DURATION * 1.5, function()
-- Unfortunately we
local thread2 = task.delay(30, function()
stdio.ewrite("Spawning a sleep process should take a reasonable amount of time\n")
task.wait(1)
process.exit(1)
@ -104,7 +119,16 @@ local sleepStart = os.clock()
local sleepCounter = 0
for i = 1, SLEEP_SAMPLES, 1 do
task.spawn(function()
process.spawn("sleep", { tostring(SLEEP_DURATION) })
local args = {
-- Sleep command on Windows in Seconds has some weird behavior with decimals ...
tostring(SLEEP_DURATION * (IS_WINDOWS and 1000 or 1)),
}
if IS_WINDOWS then
-- ... so we use milliseconds instead.
table.insert(args, 1, "-Milliseconds")
end
-- Windows does not have `sleep` as a process, so we use powershell instead.
process.spawn("sleep", args, if IS_WINDOWS then { shell = true } else nil)
sleepCounter += 1
end)
end
@ -114,28 +138,26 @@ end
task.cancel(thread2)
local sleepElapsed = os.clock() - sleepStart
assert(
sleepElapsed >= SLEEP_DURATION,
(os.clock() - sleepStart) >= SLEEP_DURATION,
"Spawning a process that does blocking sleep did not sleep enough"
)
assert(
sleepElapsed < SLEEP_DURATION * 1.5,
"Coroutine yielded the main lua thread during process yield"
)
-- Inheriting stdio & environment variables should work
local echoMessage = "Hello from child process!"
local echoResult = process.spawn("echo", {
'"$TEST_VAR"',
if IS_WINDOWS then '"$Env:TEST_VAR"' else '"$TEST_VAR"',
}, {
env = { TEST_VAR = echoMessage },
shell = "bash",
shell = if IS_WINDOWS then "powershell" else "bash",
stdio = "inherit",
})
-- Windows echo adds \r\n (CRLF) and unix adds \n (LF)
local trailingAddition = if IS_WINDOWS then "\r\n" else "\n"
assert(
echoResult.stdout == (echoMessage .. "\n"), -- Note that echo adds a newline
echoResult.stdout == (echoMessage .. trailingAddition),
"Inheriting stdio did not return proper output"
)

View file

@ -127,15 +127,17 @@ assertEq(
-- Angles
-- stylua: ignore start
assertEq(
CFrame.Angles(math.pi/2, math.pi/4, math.pi/4),
CFrame.Angles(math.pi / 2, math.pi / 4, math.pi / 4),
CFrame.new(
0, 0, 0,
0.49999997, -0.49999997, 0.707106769,
0.49999994, -0.5, -0.707106769,
0, 0, 0,
0.49999997, -0.49999997, 0.707106769,
0.49999994, -0.5, -0.707106769,
0.707106769, 0.707106769, 0
)
)
-- stylua: ignore end
-- TODO: More methods