Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 94 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ authors = ["the Andromeda team"]
edition = "2024"
license = "Mozilla Public License 2.0"
repository = "https://github.com/tryandromeda/andromeda"
version = "0.1.0-draft3"
version = "0.1.0-draft4"

[workspace.dependencies]
andromeda-core = { path = "core" }
andromeda-runtime = { path = "runtime", features = ["canvas", "crypto", "storage"] }
anyhow = "1.0.98"
anymap = "0.12.1"
base64-simd = "0.8.0"
clap = { version = "4.5.40", features = ["derive"] }
clap_complete = "4.5.54"
clap = { version = "4.5.41", features = ["derive"] }
clap_complete = "4.5.55"
console = "0.16.0"
dprint-core = "0.67.4"
dprint-plugin-typescript = "0.95.8"
Expand All @@ -25,30 +25,30 @@ indexmap = "2.10.0"
image = "0.25.6"
lazy_static = "1.5.0"
libsui = "0.10.0"
nova_vm = { git = "https://github.com/trynova/nova", rev = "58451921b0d350572a90cf63e8c6d476fd5c6855", features = [
nova_vm = { git = "https://github.com/trynova/nova", rev = "508168f9db71082294c3d536c455dae166f5bfbe", features = [
"typescript"
] }
nu-ansi-term = "0.50.1"
owo-colors = "4.2.2"
oxc_ast = "0.75.0"
oxc_allocator = "0.75.0"
oxc_diagnostics = "0.75.0"
oxc_ast = "0.77.0"
oxc_allocator = "0.77.0"
oxc_diagnostics = "0.77.0"
oxc-miette = { version = "2.3.1", features = ["fancy"] }
oxc_parser = "0.75.0"
oxc_semantic = "0.75.0"
oxc_span = "0.75.0"
oxc_parser = "0.77.0"
oxc_semantic = "0.77.0"
oxc_span = "0.77.0"
rand = "0.9.1"
reedline = "0.40.0"
regex = "1.11.1"
ring = "0.17.14"
rusqlite = { version = "0.36.0", features = ["bundled"] }
rusqlite = { version = "0.37.0", features = ["bundled"] }
serde = { version = "1.0.219", features = ["derive"] }
signal-hook = "0.3.18"
thiserror = "2.0.12"
tokio = { version = "1.46.0", features = ["rt", "sync", "time"] }
tokio = { version = "1.46.1", features = ["rt", "sync", "time"] }
ureq = { version = "3.0.12", features = ["json"] }
url = { version = "2.5.4", features = ["serde", "expose_internals"] }
wgpu = { version = "25.0.2", features = ["wgsl", "webgpu"] }
wgpu = { version = "26.0.1", features = ["wgsl", "webgpu"] }

[profile.release]
lto = true
10 changes: 5 additions & 5 deletions cli/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn get_file_info(path: &std::path::Path) -> Result<FileType> {
"js" | "jsx" | "mjs" | "cjs" => Ok(FileType::JavaScript),
"json" | "jsonc" => Ok(FileType::Json),
_ => Err(AndromedaError::format_error(
format!("Unsupported file type: .{}", extension),
format!("Unsupported file type: .{extension}"),
None::<std::io::Error>,
)),
}
Expand Down Expand Up @@ -150,11 +150,11 @@ fn format_ts_js_file(
let error_msg = resolved_config
.diagnostics
.iter()
.map(|d| format!("{}", d))
.map(|d| format!("{d}"))
.collect::<Vec<_>>()
.join(", ");
return Err(AndromedaError::format_error(
format!("Failed to resolve dprint TS configuration: {}", error_msg),
format!("Failed to resolve dprint TS configuration: {error_msg}"),
None::<std::io::Error>,
));
}
Expand Down Expand Up @@ -190,11 +190,11 @@ fn format_json_file(
let error_msg = resolved_config
.diagnostics
.iter()
.map(|d| format!("{}", d))
.map(|d| format!("{d}"))
.collect::<Vec<_>>()
.join(", ");
return Err(AndromedaError::format_error(
format!("Failed to resolve dprint JSON configuration: {}", error_msg),
format!("Failed to resolve dprint JSON configuration: {error_msg}"),
None::<std::io::Error>,
));
}
Expand Down
8 changes: 4 additions & 4 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,22 @@ fn run_main() -> Result<()> {
Command::Compile { path, out } => {
compile(out.as_path(), path.as_path()).map_err(|e| {
AndromedaError::compile_error(
format!("Compilation failed: {}", e),
format!("Compilation failed: {e}"),
path.clone(),
out.clone(),
Some(e),
)
})?;

println!("✅ Successfully created the output binary at {:?}", out);
println!("✅ Successfully created the output binary at {out:?}");
Ok(())
}
Command::Repl {
expose_internals,
print_internals,
disable_gc,
} => run_repl(expose_internals, print_internals, disable_gc)
.map_err(|e| AndromedaError::repl_error(format!("REPL failed: {}", e), Some(e))),
.map_err(|e| AndromedaError::repl_error(format!("REPL failed: {e}"), Some(e))),
Command::Fmt { paths } => {
let files_to_format = find_formattable_files(&paths)?;

Expand All @@ -202,7 +202,7 @@ fn run_main() -> Result<()> {
dry_run,
} => upgrade::run_upgrade(force, version, dry_run).map_err(|e| {
AndromedaError::runtime_error(
format!("Upgrade failed: {}", e),
format!("Upgrade failed: {e}"),
None,
None,
None,
Expand Down
7 changes: 4 additions & 3 deletions cli/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ pub fn run_repl(expose_internals: bool, print_internals: bool, disable_gc: bool)
std::process::exit(0);
}
Err(err) => {
println!("Error reading input: {}", err);
println!("Error reading input: {err}");
continue;
}
};
Expand Down Expand Up @@ -735,15 +735,15 @@ pub fn run_repl(expose_internals: bool, print_internals: bool, disable_gc: bool)
let result_style = Style::new().green();
let time_style = Style::new().dim();
let type_style = Style::new().dim().italic();
let output = val.as_str(agent);
let output = val.as_str(agent).expect("String is not valid UTF-8");

if !output.is_empty() && output != "undefined" {
let (formatted_value, value_type) = format_js_value(output);
println!(
"{} {} {}",
result_style.apply_to("←"),
formatted_value,
type_style.apply_to(format!("({})", value_type))
type_style.apply_to(format!("({value_type})"))
);
} else if output == "undefined" {
let (formatted_value, _) = format_js_value(output);
Expand All @@ -768,6 +768,7 @@ pub fn run_repl(expose_internals: bool, print_internals: bool, disable_gc: bool)
let error_message = error_value
.string_repr(agent, gc.reborrow())
.as_str(agent)
.expect("String is not valid UTF-8")
.to_string();
handle_runtime_error_with_message(error_message);
}
Expand Down
3 changes: 2 additions & 1 deletion cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn run(verbose: bool, no_strict: bool, files: Vec<RuntimeFile>) -> Result<()
match runtime_output.result {
Ok(result) => {
if verbose {
println!("✅ Execution completed successfully: {:?}", result);
println!("✅ Execution completed successfully: {result:?}");
}
Ok(())
}
Expand All @@ -70,6 +70,7 @@ pub fn run(verbose: bool, no_strict: bool, files: Vec<RuntimeFile>) -> Result<()
.value()
.string_repr(agent, gc)
.as_str(agent)
.expect("String is not valid UTF-8")
.to_string()
});

Expand Down
34 changes: 11 additions & 23 deletions cli/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct PlatformInfo {
/// Run the upgrade process
pub fn run_upgrade(force: bool, target_version: Option<String>, dry_run: bool) -> Result<()> {
println!("🚀 Andromeda Upgrade Tool");
println!("Current version: {}", CURRENT_VERSION);
println!("Current version: {CURRENT_VERSION}");
println!();

let platform = detect_platform()?;
Expand All @@ -64,10 +64,7 @@ pub fn run_upgrade(force: bool, target_version: Option<String>, dry_run: bool) -
}

if release.tag_name == CURRENT_VERSION && !force {
println!(
"ℹ️ You are already on version {}. Use --force to reinstall.",
CURRENT_VERSION
);
println!("ℹ️ You are already on version {CURRENT_VERSION}. Use --force to reinstall.");
return Ok(());
}

Expand Down Expand Up @@ -143,9 +140,9 @@ fn detect_platform() -> Result<PlatformInfo> {
};

let asset_name = if os == "windows" {
format!("andromeda-{}-{}.exe", os, arch)
format!("andromeda-{os}-{arch}.exe")
} else {
format!("andromeda-{}-{}", os, arch)
format!("andromeda-{os}-{arch}")
};

Ok(PlatformInfo {
Expand All @@ -157,13 +154,10 @@ fn detect_platform() -> Result<PlatformInfo> {

/// Get the latest release from GitHub
fn get_latest_release() -> Result<GitHubRelease> {
let url = format!(
"https://api.github.com/repos/{}/{}/releases/latest",
REPO_OWNER, REPO_NAME
);
let url = format!("https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/releases/latest");

let response = ureq::get(&url)
.header("User-Agent", &format!("andromeda-cli/{}", CURRENT_VERSION))
.header("User-Agent", &format!("andromeda-cli/{CURRENT_VERSION}"))
.call();

match response {
Expand All @@ -183,13 +177,10 @@ fn get_latest_release() -> Result<GitHubRelease> {

/// Get the most recent release (including drafts and prereleases)
fn get_most_recent_release() -> Result<GitHubRelease> {
let url = format!(
"https://api.github.com/repos/{}/{}/releases",
REPO_OWNER, REPO_NAME
);
let url = format!("https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/releases");

let mut response = ureq::get(&url)
.header("User-Agent", &format!("andromeda-cli/{}", CURRENT_VERSION))
.header("User-Agent", &format!("andromeda-cli/{CURRENT_VERSION}"))
.call()
.context("Failed to fetch releases")?;

Expand All @@ -206,13 +197,10 @@ fn get_most_recent_release() -> Result<GitHubRelease> {

/// Get a specific release by tag
fn get_release_by_tag(tag: &str) -> Result<GitHubRelease> {
let url = format!(
"https://api.github.com/repos/{}/{}/releases/tags/{}",
REPO_OWNER, REPO_NAME, tag
);
let url = format!("https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/releases/tags/{tag}");

let mut response = ureq::get(&url)
.header("User-Agent", &format!("andromeda-cli/{}", CURRENT_VERSION))
.header("User-Agent", &format!("andromeda-cli/{CURRENT_VERSION}"))
.call()
.context("Failed to fetch release information")?;

Expand All @@ -227,7 +215,7 @@ fn get_release_by_tag(tag: &str) -> Result<GitHubRelease> {
/// Download an asset from the given URL
fn download_asset(url: &str) -> Result<Vec<u8>> {
let mut response = ureq::get(url)
.header("User-Agent", &format!("andromeda-cli/{}", CURRENT_VERSION))
.header("User-Agent", &format!("andromeda-cli/{CURRENT_VERSION}"))
.call()
.context("Failed to download asset")?;

Expand Down
26 changes: 11 additions & 15 deletions core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,42 +216,38 @@ impl fmt::Display for AndromedaError {
AndromedaError::FsError {
operation, path, ..
} => {
write!(f, "File system error during {}: {}", operation, path)
write!(f, "File system error during {operation}: {path}")
}
AndromedaError::ParseError { source_path, .. } => {
write!(f, "Parse error in {}", source_path)
write!(f, "Parse error in {source_path}")
}
AndromedaError::RuntimeError { message, .. } => {
write!(f, "Runtime error: {}", message)
write!(f, "Runtime error: {message}")
}
AndromedaError::ExtensionError {
extension_name,
message,
} => {
write!(f, "Extension '{}' error: {}", extension_name, message)
write!(f, "Extension '{extension_name}' error: {message}")
}
AndromedaError::ResourceError {
rid,
operation,
message,
} => {
write!(
f,
"Resource {} error during {}: {}",
rid, operation, message
)
write!(f, "Resource {rid} error during {operation}: {message}")
}
AndromedaError::TaskError { task_id, message } => {
write!(f, "Task {} error: {}", task_id, message)
write!(f, "Task {task_id} error: {message}")
}
AndromedaError::NetworkError { url, operation, .. } => {
write!(f, "Network error during {} for {}", operation, url)
write!(f, "Network error during {operation} for {url}")
}
AndromedaError::EncodingError { format, message } => {
write!(f, "Encoding error ({}): {}", format, message)
write!(f, "Encoding error ({format}): {message}")
}
AndromedaError::ConfigError { field, message } => {
write!(f, "Configuration error in field '{}': {}", field, message)
write!(f, "Configuration error in field '{field}': {message}")
}
}
}
Expand All @@ -277,7 +273,7 @@ impl ErrorReporter {
eprintln!("{}", "─".repeat(50).red());

// Use Display instead of miette for now to avoid trait issues
eprintln!("{}", error);
eprintln!("{error}");
}

/// Print multiple errors
Expand All @@ -302,7 +298,7 @@ impl ErrorReporter {
errors.len().to_string().bright_cyan()
);
}
eprintln!("{}", error);
eprintln!("{error}");
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn create_parse_error_report(
source: &str,
) -> String {
let mut output = String::new();
output.push_str(&format!(" Parse Error in {}:\n", source_path));
output.push_str(&format!(" Parse Error in {source_path}:\n"));
output.push_str("────────────────────────────────────────────────\n");
let source_owned = source.to_string();
let source_path_owned = source_path.to_string();
Expand All @@ -47,7 +47,7 @@ pub fn create_parse_error_report(
output.push_str(&format!("\n Error {} of {}:\n", index + 1, errors.len()));
}
let report = error.clone().with_source_code(named_source.clone());
output.push_str(&format!("{}\n", report));
output.push_str(&format!("{report}\n"));
}

output
Expand Down
14 changes: 9 additions & 5 deletions core/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl RuntimeFile {
return Err(AndromedaError::fs_error(
std::io::Error::new(
std::io::ErrorKind::NotFound,
format!("File not found: {}", path),
format!("File not found: {path}"),
),
"validate",
path,
Expand All @@ -121,7 +121,7 @@ impl RuntimeFile {
return Err(AndromedaError::fs_error(
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("Path is not a file: {}", path),
format!("Path is not a file: {path}"),
),
"validate",
path,
Expand Down Expand Up @@ -265,9 +265,13 @@ impl<UserMacroTask> Runtime<UserMacroTask> {
gc.nogc(),
) {
Ok(script) => script,
Err(errors) => {
exit_with_parse_errors(errors, file.get_path(), source_text.as_str(agent))
}
Err(errors) => exit_with_parse_errors(
errors,
file.get_path(),
source_text
.as_str(agent)
.expect("String is not valid UTF-8"),
),
};

script_evaluation(agent, script.unbind(), gc.reborrow()).unbind()
Expand Down
Loading
Loading