From 3f79756f70b511f94ef7a0111d60cfdc5f3c05e1 Mon Sep 17 00:00:00 2001 From: Someon1e <142684596+Someon1e@users.noreply.github.com> Date: Mon, 15 Apr 2024 22:21:25 +0100 Subject: [PATCH 01/10] Fix require not throwing syntax error (#168) --- src/lune/globals/require/path.rs | 78 ++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/src/lune/globals/require/path.rs b/src/lune/globals/require/path.rs index 3777b7e..7e8084f 100644 --- a/src/lune/globals/require/path.rs +++ b/src/lune/globals/require/path.rs @@ -1,6 +1,7 @@ use std::path::{Path, PathBuf}; use mlua::prelude::*; +use mlua::Error::ExternalError; use super::context::*; @@ -27,26 +28,33 @@ where 'lua: 'ctx, { // 1. Try to require the exact path - if let Ok(res) = require_inner(lua, ctx, &abs_path, &rel_path).await { - return Ok(res); + match require_inner(lua, ctx, &abs_path, &rel_path).await { + Ok(res) => return Ok(res), + Err(err) => { + if !is_file_not_found_error(&err) { + return Err(err); + } + } } // 2. Try to require the path with an added "luau" extension - let (luau_abs_path, luau_rel_path) = ( - append_extension(&abs_path, "luau"), - append_extension(&rel_path, "luau"), - ); - if let Ok(res) = require_inner(lua, ctx, &luau_abs_path, &luau_rel_path).await { - return Ok(res); - } - // 3. Try to require the path with an added "lua" extension - let (lua_abs_path, lua_rel_path) = ( - append_extension(&abs_path, "lua"), - append_extension(&rel_path, "lua"), - ); - if let Ok(res) = require_inner(lua, ctx, &lua_abs_path, &lua_rel_path).await { - return Ok(res); + for extension in ["luau", "lua"] { + match require_inner( + lua, + ctx, + &append_extension(&abs_path, extension), + &append_extension(&rel_path, extension), + ) + .await + { + Ok(res) => return Ok(res), + Err(err) => { + if !is_file_not_found_error(&err) { + return Err(err); + } + } + } } // We didn't find any direct file paths, look @@ -55,21 +63,23 @@ where let rel_init = rel_path.join("init"); // 4. Try to require the init path with an added "luau" extension - let (luau_abs_init, luau_rel_init) = ( - append_extension(&abs_init, "luau"), - append_extension(&rel_init, "luau"), - ); - if let Ok(res) = require_inner(lua, ctx, &luau_abs_init, &luau_rel_init).await { - return Ok(res); - } - // 5. Try to require the init path with an added "lua" extension - let (lua_abs_init, lua_rel_init) = ( - append_extension(&abs_init, "lua"), - append_extension(&rel_init, "lua"), - ); - if let Ok(res) = require_inner(lua, ctx, &lua_abs_init, &lua_rel_init).await { - return Ok(res); + for extension in ["luau", "lua"] { + match require_inner( + lua, + ctx, + &append_extension(&abs_init, extension), + &append_extension(&rel_init, extension), + ) + .await + { + Ok(res) => return Ok(res), + Err(err) => { + if !is_file_not_found_error(&err) { + return Err(err); + } + } + } } // Nothing left to try, throw an error @@ -109,3 +119,11 @@ fn append_extension(path: impl Into, ext: &'static str) -> PathBuf { }; new } + +fn is_file_not_found_error(err: &LuaError) -> bool { + if let ExternalError(err) = err { + err.as_ref().downcast_ref::().is_some() + } else { + false + } +} From aa04fb345c9ed5728b954f2b317603cc1226a599 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 15 Apr 2024 23:28:51 +0200 Subject: [PATCH 02/10] Update dependencies --- Cargo.lock | 154 ++++++++++++++++++++++++++++------------------------- Cargo.toml | 2 +- 2 files changed, 81 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8159d41..927396f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "arrayref" @@ -130,9 +130,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-channel" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" +checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", "event-listener 5.3.0", @@ -157,11 +157,10 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f98c37cf288e302c16ef6c8472aad1e034c6c84ce5ea7b8101c98eb4a802fee" +checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" dependencies = [ - "async-lock", "async-task", "concurrent-queue", "fastrand", @@ -188,13 +187,13 @@ checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.79" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -360,9 +359,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" [[package]] name = "cfg-if" @@ -387,7 +386,7 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -436,7 +435,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -663,9 +662,9 @@ checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "encode_unicode" @@ -675,9 +674,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -868,7 +867,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -938,9 +937,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "glam" -version = "0.25.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3" +checksum = "9e05e7e6723e3455f4818c7b26e855439f7546cf617ef669d1adedb8669e5cb9" [[package]] name = "glob" @@ -1113,9 +1112,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +checksum = "9f24ce812868d86d19daa79bf3bf9175bc44ea323391147a5e3abde2a283871b" dependencies = [ "bytes", "futures-channel", @@ -1153,7 +1152,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a343d17fe7885302ed7252767dc7bb83609a874b6ff581142241ec4b73957ad" dependencies = [ "http-body-util", - "hyper 1.2.0", + "hyper 1.3.0", "hyper-util", "pin-project-lite", "tokio", @@ -1172,7 +1171,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.2.0", + "hyper 1.3.0", "pin-project-lite", "socket2", "tokio", @@ -1293,7 +1292,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -1363,7 +1362,7 @@ dependencies = [ "glam", "http 1.1.0", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.0", "hyper-tungstenite", "hyper-util", "include_dir", @@ -1695,7 +1694,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1738,7 +1737,7 @@ dependencies = [ "line-wrap", "quick-xml", "serde", - "time 0.3.34", + "time 0.3.36", ] [[package]] @@ -1761,9 +1760,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ "unicode-ident", ] @@ -1784,7 +1783,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1798,9 +1797,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -2314,7 +2313,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -2533,9 +2532,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ "proc-macro2", "quote", @@ -2598,7 +2597,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -2628,9 +2627,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -2638,7 +2637,7 @@ dependencies = [ "powerfmt", "serde", "time-core", - "time-macros 0.2.17", + "time-macros 0.2.18", ] [[package]] @@ -2659,9 +2658,9 @@ dependencies = [ [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -2723,7 +2722,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -2860,7 +2859,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -3083,7 +3082,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", "wasm-bindgen-shared", ] @@ -3117,7 +3116,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3190,7 +3189,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -3208,7 +3207,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -3228,17 +3227,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -3249,9 +3249,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -3261,9 +3261,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -3273,9 +3273,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -3285,9 +3291,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -3297,9 +3303,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -3309,9 +3315,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -3321,15 +3327,15 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 2c79be6..0d79485 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -139,7 +139,7 @@ rustyline = { optional = true, version = "14.0" } ### ROBLOX -glam = { optional = true, version = "0.25" } +glam = { optional = true, version = "0.27" } rand = { optional = true, version = "0.8" } rbx_cookie = { optional = true, version = "0.1.4", default-features = false } From f36ec1483a79ab42e24f947acc62ee838e68ccad Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 15 Apr 2024 23:31:16 +0200 Subject: [PATCH 03/10] Update changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf23c65..5a47f74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed `require` not throwing syntax errors (#168) +- Fixed `require` caching not working correctly (#171) +- Fixed case-sensitivity issue in `require` with aliases (#173) +- Fixed itertools dependency being marked optional even though it is mandatory (#176) +- Fixed test cases for the `net` built-in on Windows (#177) + ## `0.8.2` - March 12th, 2024 ### Fixed From fcfb5ed3a81aae05a0de96dd7d49508951c7822b Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 15 Apr 2024 23:34:51 +0200 Subject: [PATCH 04/10] Version 0.8.3 --- CHANGELOG.md | 18 ++++++++++++------ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a47f74..091b0c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,15 +8,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## `0.8.3` - April 15th, 2024 ### Fixed -- Fixed `require` not throwing syntax errors (#168) -- Fixed `require` caching not working correctly (#171) -- Fixed case-sensitivity issue in `require` with aliases (#173) -- Fixed itertools dependency being marked optional even though it is mandatory (#176) -- Fixed test cases for the `net` built-in on Windows (#177) +- Fixed `require` not throwing syntax errors ([#168]) +- Fixed `require` caching not working correctly ([#171]) +- Fixed case-sensitivity issue in `require` with aliases ([#173]) +- Fixed `itertools` dependency being marked optional even though it is mandatory ([#176]) +- Fixed test cases for the `net` built-in library on Windows ([#177]) + +[#168]: https://github.com/lune-org/lune/pull/168 +[#171]: https://github.com/lune-org/lune/pull/171 +[#173]: https://github.com/lune-org/lune/pull/173 +[#176]: https://github.com/lune-org/lune/pull/176 +[#177]: https://github.com/lune-org/lune/pull/177 ## `0.8.2` - March 12th, 2024 diff --git a/Cargo.lock b/Cargo.lock index 927396f..5669047 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1344,7 +1344,7 @@ dependencies = [ [[package]] name = "lune" -version = "0.8.2" +version = "0.8.3" dependencies = [ "anyhow", "async-compression", diff --git a/Cargo.toml b/Cargo.toml index 0d79485..90e22c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lune" -version = "0.8.2" +version = "0.8.3" edition = "2021" license = "MPL-2.0" repository = "https://github.com/lune-org/lune" From 34fc23d02402bcee01787a69a921aa6d28b13cce Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 15 Apr 2024 23:40:58 +0200 Subject: [PATCH 05/10] Add native CI target for M1 macs --- .github/workflows/ci.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2444c37..b60e128 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -64,9 +64,13 @@ jobs: cargo-target: x86_64-unknown-linux-gnu - name: macOS x86_64 - runner-os: macos-latest + runner-os: macos-13 cargo-target: x86_64-apple-darwin - timeout-minutes: 10 + + - name: macOS aarch64 + runner-os: macos-14 + cargo-target: aarch64-apple-darwin + name: CI - ${{ matrix.name }} runs-on: ${{ matrix.runner-os }} steps: From fe55442daca9fae1c5928d36a0a8a9ff641319a5 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Thu, 18 Apr 2024 15:59:23 +0530 Subject: [PATCH 06/10] Fix Stack Overflow while Formatting Tables with Circular Keys (#183) --- src/lune/util/formatting.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lune/util/formatting.rs b/src/lune/util/formatting.rs index 19f9a88..54376b7 100644 --- a/src/lune/util/formatting.rs +++ b/src/lune/util/formatting.rs @@ -130,7 +130,7 @@ pub fn pretty_format_value( } else if let Some(s) = call_table_tostring_metamethod(tab) { write!(buffer, "{s}")?; } else if depth >= 1 && parent_table_addr.eq(&table_addr) { - write!(buffer, "{}", STYLE_DIM.apply_to(""))? + write!(buffer, "{}", STYLE_DIM.apply_to(""))?; } else { let mut is_empty = false; let depth_indent = INDENT.repeat(depth); @@ -148,7 +148,12 @@ pub fn pretty_format_value( )?, _ => { write!(buffer, "\n{depth_indent}{INDENT}[")?; - pretty_format_value(buffer, &key, parent_table_addr.clone(), depth)?; + pretty_format_value( + buffer, + &key, + parent_table_addr.clone(), + depth + 1, + )?; write!(buffer, "] {} ", STYLE_DIM.apply_to("="))?; } } From 03c773fd7928a8afa39c0515e97a5cdc0436d95b Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Thu, 18 Apr 2024 20:54:21 +0200 Subject: [PATCH 07/10] Fix headers in net.serve being raw bytes instead of strings --- src/lune/builtins/net/server/request.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lune/builtins/net/server/request.rs b/src/lune/builtins/net/server/request.rs index dde529f..bab7a5d 100644 --- a/src/lune/builtins/net/server/request.rs +++ b/src/lune/builtins/net/server/request.rs @@ -18,21 +18,30 @@ impl LuaRequest { let path = self.head.uri.path().to_string(); let body = lua.create_string(&self.body)?; - let query: HashMap = self + let query: HashMap = self .head .uri .query() .unwrap_or_default() .split('&') .filter_map(|q| q.split_once('=')) - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect(); - let headers: HashMap> = self + .map(|(k, v)| { + let k = lua.create_string(k)?; + let v = lua.create_string(v)?; + Ok((k, v)) + }) + .collect::>()?; + + let headers: HashMap = self .head .headers .iter() - .map(|(k, v)| (k.as_str().to_string(), v.as_bytes().to_vec())) - .collect(); + .map(|(k, v)| { + let k = lua.create_string(k.as_str())?; + let v = lua.create_string(v.as_bytes())?; + Ok((k, v)) + }) + .collect::>()?; TableBuilder::new(lua)? .with_value("method", method)? From 4a28499aaa1d9669636ffc6b0da2cd7c7549533d Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Thu, 18 Apr 2024 20:56:40 +0200 Subject: [PATCH 08/10] Fix net.serve no longer accepting ipv6 --- src/lune/builtins/net/config.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lune/builtins/net/config.rs b/src/lune/builtins/net/config.rs index 5d02d2b..d801c47 100644 --- a/src/lune/builtins/net/config.rs +++ b/src/lune/builtins/net/config.rs @@ -1,4 +1,7 @@ -use std::{collections::HashMap, net::Ipv4Addr}; +use std::{ + collections::HashMap, + net::{IpAddr, Ipv4Addr}, +}; use mlua::prelude::*; @@ -6,7 +9,7 @@ use reqwest::Method; use super::util::table_to_hash_map; -const DEFAULT_IP_ADDRESS: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1); +const DEFAULT_IP_ADDRESS: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); const WEB_SOCKET_UPDGRADE_REQUEST_HANDLER: &str = r#" return { @@ -155,7 +158,7 @@ impl FromLua<'_> for RequestConfig { #[derive(Debug)] pub struct ServeConfig<'a> { - pub address: Ipv4Addr, + pub address: IpAddr, pub handle_request: LuaFunction<'a>, pub handle_web_socket: Option>, } @@ -175,7 +178,7 @@ impl<'lua> FromLua<'lua> for ServeConfig<'lua> { let handle_request: Option = t.get("handleRequest")?; let handle_web_socket: Option = t.get("handleWebSocket")?; if handle_request.is_some() || handle_web_socket.is_some() { - let address: Ipv4Addr = match &address { + let address: IpAddr = match &address { Some(addr) => { let addr_str = addr.to_str()?; From 753897222ab8b02101d483d3d88384b6a992771d Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Thu, 18 Apr 2024 22:10:08 +0200 Subject: [PATCH 09/10] Implement stdio.readToEnd API --- src/lune/builtins/stdio/mod.rs | 18 +++++++++++++++++- types/stdio.luau | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/lune/builtins/stdio/mod.rs b/src/lune/builtins/stdio/mod.rs index 14927f2..f851bc7 100644 --- a/src/lune/builtins/stdio/mod.rs +++ b/src/lune/builtins/stdio/mod.rs @@ -2,7 +2,7 @@ use mlua::prelude::*; use dialoguer::{theme::ColorfulTheme, Confirm, Input, MultiSelect, Select}; use mlua_luau_scheduler::LuaSpawnExt; -use tokio::io::{self, AsyncWriteExt}; +use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; use crate::lune::util::{ formatting::{ @@ -21,6 +21,7 @@ pub fn create(lua: &Lua) -> LuaResult> { .with_function("format", stdio_format)? .with_async_function("write", stdio_write)? .with_async_function("ewrite", stdio_ewrite)? + .with_async_function("readToEnd", stdio_read_to_end)? .with_async_function("prompt", stdio_prompt)? .build_readonly() } @@ -53,6 +54,21 @@ async fn stdio_ewrite(_: &Lua, s: LuaString<'_>) -> LuaResult<()> { Ok(()) } +/* + FUTURE: Figure out how to expose some kind of "readLine" function using a buffered reader. + + This is a bit tricky since we would want to be able to use **both** readLine and readToEnd + in the same script, doing something like readLine, readLine, readToEnd from lua, and + having that capture the first two lines and then read the rest of the input. +*/ + +async fn stdio_read_to_end(lua: &Lua, _: ()) -> LuaResult { + let mut input = Vec::new(); + let mut stdin = io::stdin(); + stdin.read_to_end(&mut input).await?; + lua.create_string(&input) +} + async fn stdio_prompt(lua: &Lua, options: PromptOptions) -> LuaResult { lua.spawn_blocking(move || prompt(options)) .await diff --git a/types/stdio.luau b/types/stdio.luau index 3c5198e..70a73e0 100644 --- a/types/stdio.luau +++ b/types/stdio.luau @@ -58,6 +58,11 @@ end stdio.write("World! ") stdio.write("All on the same line") stdio.ewrite("\nAnd some error text, too") + + -- Reading from stdin, either line-by-line or the entire input + local firstLine = stdio.readLine() + local secondLine = stdio.readLine() + local remaining = stdio.readToEnd() ``` ]=] local stdio = {} @@ -143,4 +148,16 @@ function stdio.write(s: string) end ]=] function stdio.ewrite(s: string) end +--[=[ + @within Stdio + @tag must_use + + Reads the entire input from stdin. + + @return The input from stdin +]=] +function stdio.readToEnd(): string + return nil :: any +end + return stdio From fa7f6c6f5101f6a28beedf29104709fa4054e613 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Thu, 18 Apr 2024 22:14:54 +0200 Subject: [PATCH 10/10] Fix doc example for new stdio API --- types/stdio.luau | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/types/stdio.luau b/types/stdio.luau index 70a73e0..e6e88a4 100644 --- a/types/stdio.luau +++ b/types/stdio.luau @@ -59,10 +59,8 @@ end stdio.write("All on the same line") stdio.ewrite("\nAnd some error text, too") - -- Reading from stdin, either line-by-line or the entire input - local firstLine = stdio.readLine() - local secondLine = stdio.readLine() - local remaining = stdio.readToEnd() + -- Reading the entire input from stdin + local input = stdio.readToEnd() ``` ]=] local stdio = {}