Goodbye monorepo, hello monolith

This commit is contained in:
Filip Tibell 2023-07-20 09:47:00 +02:00
parent 151cfe9b2f
commit 689994552f
No known key found for this signature in database
123 changed files with 189 additions and 275 deletions

11
.gitignore vendored
View file

@ -3,7 +3,6 @@
/.DS_Store
/**/.DS_Store
# Autogenerated dirs
/bin
@ -16,11 +15,7 @@ lune.yml
luneDocs.json
luneTypes.d.luau
# NOTE: Don't remove the typedefs file in the docs dir!
# We depend on it to autogenerate all of the above files.
!/docs/luneTypes.d.luau
# Files generated by runtime or build scripts
packages/lib-roblox/scripts/brick_color.rs
packages/lib-roblox/scripts/font_enum_map.rs
packages/lib-roblox/scripts/physical_properties_enum_map.rs
scripts/brick_color.rs
scripts/font_enum_map.rs
scripts/physical_properties_enum_map.rs

View file

@ -8,7 +8,7 @@ run-file FILE_NAME:
# Run tests for the Lune library
test:
cargo test --package lune -- --test-threads 1
cargo test --lib -- --test-threads 1
# Generate gitbook directory
generate-gitbook:

58
Cargo.lock generated
View file

@ -1145,45 +1145,31 @@ dependencies = [
"anyhow",
"async-compression",
"async-trait",
"clap 4.3.11",
"console",
"dialoguer",
"directories",
"dunce",
"env_logger 0.10.0",
"full_moon",
"futures-util",
"glam",
"hyper",
"hyper-tungstenite",
"lune-roblox",
"include_dir",
"itertools",
"lz4_flex",
"mlua",
"once_cell",
"os_str_bytes",
"pin-project",
"rand",
"rbx_binary",
"rbx_cookie",
"reqwest",
"serde",
"serde_json",
"serde_yaml",
"tokio",
"tokio-tungstenite",
"toml",
"urlencoding",
]
[[package]]
name = "lune-cli"
version = "0.7.4"
dependencies = [
"anyhow",
"clap 4.3.11",
"console",
"directories",
"env_logger 0.10.0",
"full_moon",
"futures-util",
"include_dir",
"itertools",
"lune",
"once_cell",
"rbx_dom_weak",
"rbx_reflection",
"rbx_reflection_database",
"rbx_xml",
"regex",
"reqwest",
"serde",
@ -1191,23 +1177,9 @@ dependencies = [
"serde_yaml",
"thiserror",
"tokio",
]
[[package]]
name = "lune-roblox"
version = "0.7.4"
dependencies = [
"anyhow",
"glam",
"mlua",
"once_cell",
"rand",
"rbx_binary",
"rbx_dom_weak",
"rbx_reflection",
"rbx_reflection_database",
"rbx_xml",
"thiserror",
"tokio-tungstenite",
"toml",
"urlencoding",
]
[[package]]

View file

@ -1,10 +1,5 @@
[workspace]
members = ["packages/cli", "packages/lib", "packages/lib-roblox"]
default-members = ["packages/cli"]
# Package config values shared across all packages,
# such as version, license, and other metadata
[workspace.package]
[package]
name = "lune"
version = "0.7.4"
edition = "2021"
license = "MPL-2.0"
@ -14,26 +9,35 @@ readme = "README.md"
keywords = ["cli", "lua", "luau", "scripts"]
categories = ["command-line-interface"]
# Shared dependencies that are used across 2 or more packages
# These are declared here to ensure consistent versioning
[workspace.dependencies]
console = "0.15"
directories = "5.0"
futures-util = "0.3"
once_cell = "1.17"
thiserror = "1.0"
[[bin]]
name = "lune"
path = "src/main.rs"
mlua = { version = "0.9.0-beta.3", features = ["luau", "serialize"] }
tokio = { version = "1.24", features = ["full"] }
reqwest = { version = "0.11", default-features = false, features = [
"rustls-tls",
] }
[lib]
name = "lune"
path = "src/lib.rs"
# Serde dependencies, supporting user-facing formats: json, yaml, toml
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
serde_yaml = "0.9"
toml = { version = "0.7", features = ["preserve_order"] }
[features]
default = ["cli", "roblox"]
cli = [
"dep:anyhow",
"dep:env_logger",
"dep:itertools",
"dep:clap",
"dep:full_moon",
"dep:include_dir",
"dep:regex",
]
roblox = [
"dep:glam",
"dep:rand",
"dep:rbx_cookie",
"dep:rbx_binary",
"dep:rbx_dom_weak",
"dep:rbx_reflection",
"dep:rbx_reflection_database",
"dep:rbx_xml",
]
# Profile for building the release binary, with the following options set:
#
@ -49,3 +53,80 @@ toml = { version = "0.7", features = ["preserve_order"] }
opt-level = "z"
strip = true
lto = true
# All of the dependencies for Lune.
#
# Dependencies are categorized as following:
#
# 1. General dependencies with no specific features set
# 2. Large / core dependencies that have many different crates and / or features set
# 3. Dependencies for specific features of Lune, eg. the CLI or massive Roblox builtin library
#
[dependencies]
console = "0.15"
directories = "5.0"
futures-util = "0.3"
once_cell = "1.17"
thiserror = "1.0"
async-trait = "0.1"
dialoguer = "0.10"
dunce = "1.0"
lz4_flex = "0.10"
pin-project = "1.0"
os_str_bytes = "6.4"
urlencoding = "2.1.2"
### RUNTIME
mlua = { version = "0.9.0-beta.3", features = ["luau", "serialize"] }
tokio = { version = "1.24", features = ["full"] }
### SERDE
async-compression = { version = "0.4", features = [
"tokio",
"brotli",
"deflate",
"gzip",
"zlib",
] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
serde_yaml = "0.9"
toml = { version = "0.7", features = ["preserve_order"] }
### NET
hyper = { version = "0.14", features = ["full"] }
hyper-tungstenite = { version = "0.10" }
reqwest = { version = "0.11", default-features = false, features = [
"rustls-tls",
] }
tokio-tungstenite = { version = "0.19", features = ["rustls-tls-webpki-roots"] }
### CLI
anyhow = { optional = true, version = "1.0" }
env_logger = { optional = true, version = "0.10" }
itertools = { optional = true, version = "0.10" }
clap = { optional = true, version = "4.1", features = ["derive"] }
full_moon = { optional = true, version = "0.18", features = ["roblox"] }
include_dir = { optional = true, version = "0.7.3", features = ["glob"] }
regex = { optional = true, version = "1.7", default-features = false, features = [
"std",
"unicode-perl",
] }
### ROBLOX
glam = { optional = true, version = "0.24" }
rand = { optional = true, version = "0.8" }
rbx_cookie = { optional = true, version = "0.1.2" }
rbx_binary = { optional = true, git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
rbx_dom_weak = { optional = true, git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
rbx_reflection = { optional = true, git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
rbx_reflection_database = { optional = true, git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
rbx_xml = { optional = true, git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }

View file

@ -1,46 +0,0 @@
[package]
name = "lune-cli"
publish = false
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description.workspace = true
readme.workspace = true
keywords.workspace = true
categories.workspace = true
[[bin]]
name = "lune"
path = "src/main.rs"
[features]
default = []
roblox = ["lune/roblox"]
[dependencies]
lune = { path = "../lib" }
console.workspace = true
directories.workspace = true
futures-util.workspace = true
once_cell.workspace = true
reqwest.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
tokio.workspace = true
thiserror.workspace = true
anyhow = "1.0"
env_logger = "0.10"
itertools = "0.10"
clap = { version = "4.1", features = ["derive"] }
full_moon = { version = "0.18", features = ["roblox"] }
include_dir = { version = "0.7.3", features = ["glob"] }
regex = { version = "1.7", default-features = false, features = [
"std",
"unicode-perl",
] }

View file

@ -1,32 +0,0 @@
[package]
name = "lune-roblox"
publish = false
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description.workspace = true
readme.workspace = true
keywords.workspace = true
categories.workspace = true
[lib]
name = "lune_roblox"
path = "src/lib.rs"
[dependencies]
mlua.workspace = true
once_cell.workspace = true
thiserror.workspace = true
glam = "0.24"
rand = "0.8"
rbx_binary = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
rbx_dom_weak = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
rbx_reflection = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
rbx_reflection_database = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
rbx_xml = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "e7a813d569c3f8a54be8a8873c33f8976c37b8b1" }
[dev-dependencies]
anyhow = "1.0"

View file

@ -1,57 +0,0 @@
[package]
name = "lune"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description.workspace = true
readme.workspace = true
keywords.workspace = true
categories.workspace = true
[lib]
name = "lune"
path = "src/lib.rs"
[features]
default = ["roblox"]
roblox = ["dep:lune-roblox", "dep:rbx_cookie"]
[dependencies]
lune-roblox = { path = "../lib-roblox", optional = true }
rbx_cookie = { version = "0.1.2", optional = true }
console.workspace = true
directories.workspace = true
futures-util.workspace = true
mlua.workspace = true
once_cell.workspace = true
reqwest.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
toml.workspace = true
tokio.workspace = true
async-trait = "0.1"
dialoguer = "0.10"
dunce = "1.0"
lz4_flex = "0.10"
pin-project = "1.0"
os_str_bytes = "6.4"
urlencoding = "2.1.2"
async-compression = { version = "0.4", features = [
"tokio",
"brotli",
"deflate",
"gzip",
"zlib",
] }
hyper = { version = "0.14", features = ["full"] }
hyper-tungstenite = { version = "0.10" }
tokio-tungstenite = { version = "0.19", features = ["rustls-tls-webpki-roots"] }
[dev-dependencies]
anyhow = "1.0"

View file

@ -1,10 +0,0 @@
pub(crate) mod fs;
pub(crate) mod net;
pub(crate) mod process;
pub(crate) mod serde;
pub(crate) mod stdio;
pub(crate) mod task;
pub(crate) mod top_level;
#[cfg(feature = "roblox")]
pub(crate) mod roblox;

View file

@ -9,12 +9,14 @@ use tokio::{
io::{stdin, AsyncReadExt},
};
use crate::{
setup::run_setup,
utils::{
pub(crate) mod gen;
pub(crate) mod setup;
pub(crate) mod utils;
use setup::run_setup;
use utils::{
files::{discover_script_path_including_lune_dirs, strip_shebang},
listing::{find_lune_scripts, sort_lune_scripts, write_lune_scripts_list},
},
};
/// A Luau script runner

View file

@ -8,7 +8,7 @@ use tokio::fs;
// TODO: Use a library that supports json with comments since VSCode settings may contain comments
use serde_json::Value as JsonValue;
use crate::gen::generate_typedef_files_from_definitions;
use super::gen::generate_typedef_files_from_definitions;
pub(crate) static TYPEDEFS_DIR: Dir<'_> = include_dir!("docs/typedefs");

7
src/lib.rs Normal file
View file

@ -0,0 +1,7 @@
mod lune;
mod roblox;
#[cfg(test)]
mod tests;
pub use crate::lune::{Lune, LuneError};

View file

@ -3,7 +3,7 @@ use std::path::{PathBuf, MAIN_SEPARATOR};
use mlua::prelude::*;
use tokio::fs;
use crate::lua::{fs::FsWriteOptions, table::TableBuilder};
use crate::lune::lua::{fs::FsWriteOptions, table::TableBuilder};
pub fn create(lua: &'static Lua) -> LuaResult<LuaTable> {
TableBuilder::new(lua)?

10
src/lune/builtins/mod.rs Normal file
View file

@ -0,0 +1,10 @@
pub mod fs;
pub mod net;
pub mod process;
pub mod serde;
pub mod stdio;
pub mod task;
pub mod top_level;
#[cfg(feature = "roblox")]
pub mod roblox;

View file

@ -9,7 +9,7 @@ use hyper::{
};
use tokio::{sync::mpsc, task};
use crate::lua::{
use crate::lune::lua::{
net::{
NetClient, NetClientBuilder, NetLocalExec, NetService, NetWebSocket, RequestConfig,
ServeConfig,

View file

@ -11,7 +11,7 @@ use mlua::prelude::*;
use os_str_bytes::RawOsString;
use tokio::process::Command;
use crate::lua::{
use crate::lune::lua::{
process::pipe_and_inherit_child_process_stdio, table::TableBuilder, task::TaskScheduler,
};

View file

@ -1,16 +1,17 @@
use mlua::prelude::*;
use lune_roblox::{
use crate::roblox::{
self,
document::{Document, DocumentError, DocumentFormat, DocumentKind},
instance::Instance,
};
use tokio::task;
use crate::lua::table::TableBuilder;
use crate::lune::lua::table::TableBuilder;
pub fn create(lua: &'static Lua) -> LuaResult<LuaTable> {
let mut roblox_constants = Vec::new();
let roblox_module = lune_roblox::module(lua)?;
let roblox_module = roblox::module(lua)?;
for pair in roblox_module.pairs::<LuaValue, LuaValue>() {
roblox_constants.push(pair?);
}

View file

@ -1,6 +1,6 @@
use mlua::prelude::*;
use crate::lua::{
use crate::lune::lua::{
serde::{
compress, decompress, CompressDecompressFormat, EncodeDecodeConfig, EncodeDecodeFormat,
},

View file

@ -5,7 +5,7 @@ use tokio::{
task,
};
use crate::lua::{
use crate::lune::lua::{
stdio::{
formatting::{
format_style, pretty_format_multi_value, style_from_color_str, style_from_style_str,

View file

@ -1,6 +1,6 @@
use mlua::prelude::*;
use crate::lua::{
use crate::lune::lua::{
async_ext::LuaAsyncExt,
table::TableBuilder,
task::{

View file

@ -2,9 +2,9 @@ use mlua::prelude::*;
use std::io::{self, Write as _};
#[cfg(feature = "roblox")]
use lune_roblox::datatypes::extension::RobloxUserdataTypenameExt;
use crate::roblox::datatypes::extension::RobloxUserdataTypenameExt;
use crate::lua::{
use crate::lune::lua::{
stdio::formatting::{format_label, pretty_format_multi_value},
task::TaskReference,
};

View file

@ -5,7 +5,7 @@ use std::{
use mlua::prelude::*;
use crate::lua::stdio::formatting::pretty_format_luau_error;
use crate::lune::lua::stdio::formatting::pretty_format_luau_error;
/**
An opaque error type for formatted lua errors.

View file

@ -3,7 +3,7 @@ use mlua::prelude::*;
mod require;
mod require_waker;
use crate::builtins::{self, top_level};
use crate::lune::builtins::{self, top_level};
pub fn create(lua: &'static Lua, args: Vec<String>) -> LuaResult<()> {
// Create all builtins

View file

@ -11,7 +11,7 @@ use mlua::{prelude::*, Compiler as LuaCompiler};
use tokio::fs;
use tokio::sync::Mutex as AsyncMutex;
use crate::lua::{
use crate::lune::lua::{
table::TableBuilder,
task::{TaskScheduler, TaskSchedulerScheduleExt},
};

View file

@ -2,7 +2,7 @@ use async_trait::async_trait;
use futures_util::Future;
use mlua::prelude::*;
use crate::{lua::table::TableBuilder, lua::task::TaskScheduler};
use crate::lune::{lua::table::TableBuilder, lua::task::TaskScheduler};
use super::task::TaskSchedulerAsyncExt;

View file

@ -12,7 +12,7 @@ use hyper::{Body, Request, Response};
use hyper_tungstenite::{is_upgrade_request as is_ws_upgrade_request, upgrade as ws_upgrade};
use tokio::task;
use crate::{
use crate::lune::{
lua::table::TableBuilder,
lua::task::{TaskScheduler, TaskSchedulerAsyncExt, TaskSchedulerScheduleExt},
};

View file

@ -22,7 +22,7 @@ use hyper_tungstenite::{
};
use tokio_tungstenite::MaybeTlsStream;
use crate::lua::table::TableBuilder;
use crate::lune::lua::table::TableBuilder;
const WEB_SOCKET_IMPL_LUA: &str = r#"
return freeze(setmetatable({

View file

@ -4,7 +4,7 @@ use console::{colors_enabled, set_colors_enabled, style, Style};
use mlua::prelude::*;
use once_cell::sync::Lazy;
use crate::lua::task::TaskReference;
use crate::lune::lua::task::TaskReference;
const MAX_FORMAT_DEPTH: usize = 4;

View file

@ -2,7 +2,7 @@ use std::future::Future;
use mlua::prelude::*;
use crate::lua::async_ext::LuaAsyncExt;
use crate::lune::lua::async_ext::LuaAsyncExt;
pub struct TableBuilder {
lua: &'static Lua,

View file

@ -6,7 +6,7 @@ use futures_util::Future;
use mlua::prelude::*;
use tokio::time::{sleep, Instant};
use crate::lua::task::TaskKind;
use crate::lune::lua::task::TaskKind;
use super::super::{
scheduler::TaskReference, scheduler::TaskScheduler, scheduler_handle::TaskSchedulerAsyncHandle,

View file

@ -5,13 +5,11 @@ use mlua::prelude::*;
use mlua::Compiler as LuaCompiler;
use tokio::task::LocalSet;
pub(crate) mod builtins;
pub(crate) mod importer;
pub(crate) mod lua;
pub mod builtins;
pub mod importer;
pub mod lua;
mod error;
#[cfg(test)]
mod tests;
pub use error::LuneError;

View file

@ -13,9 +13,6 @@ use std::process::ExitCode;
use clap::Parser;
pub(crate) mod cli;
pub(crate) mod gen;
pub(crate) mod setup;
pub(crate) mod utils;
use cli::Cli;
use console::style;

View file

@ -2,7 +2,7 @@ use mlua::prelude::*;
use rbx_dom_weak::types::{Variant as DomValue, VariantType as DomType};
use crate::{datatypes::extension::DomValueExt, instance::Instance};
use crate::roblox::{datatypes::extension::DomValueExt, instance::Instance};
use super::*;

View file

@ -1,6 +1,6 @@
use mlua::prelude::*;
use crate::instance::Instance;
use crate::roblox::instance::Instance;
use super::*;

View file

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

Some files were not shown because too many files have changed in this diff Show more