Bump subprocess and toml. Also remove the demo project I accidentally

pushed.
This commit is contained in:
Cutieguwu
2026-02-15 19:38:20 -05:00
parent 79629391c5
commit b338f76e06
23 changed files with 73 additions and 164 deletions

29
Cargo.lock generated
View File

@@ -171,12 +171,12 @@ dependencies = [
"anyhow", "anyhow",
"derive_more", "derive_more",
"fs", "fs",
"io",
"java", "java",
"pathsub", "pathsub",
"semver", "semver",
"serde", "serde",
"sha256", "sha256",
"subprocess",
"toml", "toml",
] ]
@@ -308,14 +308,6 @@ dependencies = [
"hashbrown", "hashbrown",
] ]
[[package]]
name = "io"
version = "0.2.0"
dependencies = [
"derive_more",
"subprocess",
]
[[package]] [[package]]
name = "is_terminal_polyfill" name = "is_terminal_polyfill"
version = "1.70.2" version = "1.70.2"
@@ -329,8 +321,8 @@ dependencies = [
"bytesize", "bytesize",
"derive_more", "derive_more",
"fs", "fs",
"io",
"semver", "semver",
"subprocess",
] ]
[[package]] [[package]]
@@ -413,7 +405,6 @@ dependencies = [
"cli", "cli",
"core", "core",
"fs", "fs",
"io",
"java", "java",
"toml", "toml",
] ]
@@ -529,9 +520,9 @@ dependencies = [
[[package]] [[package]]
name = "subprocess" name = "subprocess"
version = "0.2.14" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b09969f0abcf65111c0cbdd8bfaa292ca3c38b46bc8ecc7270467af2f4acb172" checksum = "98e067360c7f5a302e35c9f9cd24cb583c378fbedc73d0237284dbdd0650fcc5"
dependencies = [ dependencies = [
"libc", "libc",
"winapi", "winapi",
@@ -571,9 +562,9 @@ dependencies = [
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.9.11+spec-1.1.0" version = "1.0.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" checksum = "bbe30f93627849fa362d4a602212d41bb237dc2bd0f8ba0b2ce785012e124220"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde_core", "serde_core",
@@ -586,18 +577,18 @@ dependencies = [
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.7.5+spec-1.1.0" version = "1.0.0+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" checksum = "32c2555c699578a4f59f0cc68e5116c8d7cabbd45e1409b989d4be085b53f13e"
dependencies = [ dependencies = [
"serde_core", "serde_core",
] ]
[[package]] [[package]]
name = "toml_parser" name = "toml_parser"
version = "1.0.6+spec-1.1.0" version = "1.0.8+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" checksum = "0742ff5ff03ea7e67c8ae6c93cac239e0d9784833362da3f9a9c1da8dfefcbdc"
dependencies = [ dependencies = [
"winnow", "winnow",
] ]

View File

@@ -17,7 +17,6 @@ publish = false
# #
cli = { path = "crates/cli" } cli = { path = "crates/cli" }
fs = { path = "crates/fs" } fs = { path = "crates/fs" }
io = { path = "crates/io" }
java = { path = "crates/java" } java = { path = "crates/java" }
core = { path = "crates/core" } core = { path = "crates/core" }
pom = { path = "crates/pom" } pom = { path = "crates/pom" }
@@ -34,8 +33,8 @@ lenient_semver = "0.4.2"
pathsub = "0.1.1" pathsub = "0.1.1"
ron = "0.12.0" ron = "0.12.0"
sha256 = "1.6" sha256 = "1.6"
subprocess = "0.2.13" subprocess = "1.0"
toml = "0.9.11" toml = "1.0"
derive_more = { version = "2.1", features = ["display", "from"] } derive_more = { version = "2.1", features = ["display", "from"] }
semver = { version = "1.0",features = ["serde"] } semver = { version = "1.0",features = ["serde"] }

View File

@@ -12,12 +12,12 @@ publish.workspace = true
[dependencies] [dependencies]
derive_more.workspace = true derive_more.workspace = true
fs.workspace = true fs.workspace = true
io.workspace = true
java.workspace = true java.workspace = true
pathsub.workspace = true pathsub.workspace = true
semver.workspace = true semver.workspace = true
serde.workspace = true serde.workspace = true
sha256.workspace = true sha256.workspace = true
subprocess.workspace = true
toml.workspace = true toml.workspace = true
[dependencies.anyhow] [dependencies.anyhow]

View File

@@ -5,16 +5,13 @@ pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, From, Display)] #[derive(Debug, From, Display)]
pub enum Error { pub enum Error {
#[from] #[from]
Io(io::Error), Io(std::io::Error),
#[from] #[from]
Java(java::Error), Java(java::Error),
MissingFileName, MissingFileName,
#[from]
StdIo(std::io::Error),
#[from] #[from]
TomlDeserialize(toml::de::Error), TomlDeserialize(toml::de::Error),

View File

@@ -2,11 +2,12 @@ use std::collections::HashMap;
use std::fs::{OpenOptions, read_dir}; use std::fs::{OpenOptions, read_dir};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::time::Duration;
use fs::expand_files; use fs::expand_files;
use io::run_process;
use java::{JAVA_EXT_CLASS, JAVA_EXT_SOURCE}; use java::{JAVA_EXT_CLASS, JAVA_EXT_SOURCE};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use subprocess::Exec;
use crate::Error; use crate::Error;
use crate::nest::{F_NEST_LOCK, F_NEST_TOML, Nest, NestLock}; use crate::nest::{F_NEST_LOCK, F_NEST_TOML, Nest, NestLock};
@@ -102,7 +103,11 @@ impl WorkspaceHandler {
self.write_example_project()?; self.write_example_project()?;
self.discover_packages()?; self.discover_packages()?;
run_process(&["git", "init", "."])?; Exec::cmd("git")
.arg("init")
.arg(".")
.start()?
.wait_timeout(Duration::from_secs(10))?;
} }
// Append to .gitignore // Append to .gitignore

View File

@@ -1,14 +0,0 @@
[package]
name = "io"
version = "0.2.0"
edition.workspace = true
license.workspace = true
description = "Raven's IO utilities"
repository.workspace = true
publish.workspace = true
[dependencies]
derive_more.workspace = true
subprocess.workspace = true

View File

@@ -1,11 +0,0 @@
use derive_more::{Display, From};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, From, Display)]
pub enum Error {
#[from]
Io(std::io::Error),
#[from]
Popen(subprocess::PopenError),
}

View File

@@ -1,30 +0,0 @@
mod error;
use std::ffi;
pub use error::{Error, Result};
pub fn run_process<S>(argv: &[S]) -> Result<(Option<String>, Option<String>)>
where
S: AsRef<ffi::OsStr>,
{
let mut process = subprocess::Popen::create(
argv,
subprocess::PopenConfig {
stdout: subprocess::Redirection::Pipe,
..Default::default()
},
)?;
let result = process.communicate(None)?;
if process
.wait_timeout(std::time::Duration::from_secs(5))
.is_err()
|| process.exit_status().is_none()
{
process.terminate()?;
}
Ok(result)
}

View File

@@ -16,5 +16,5 @@ publish.workspace = true
bytesize.workspace = true bytesize.workspace = true
derive_more.workspace = true derive_more.workspace = true
fs.workspace = true fs.workspace = true
io.workspace = true
semver.workspace = true semver.workspace = true
subprocess.workspace = true

View File

@@ -1,5 +1,8 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use subprocess::Exec;
use subprocess::Redirection;
use crate::JAVA_BIN_COMPILER; use crate::JAVA_BIN_COMPILER;
use crate::Result; use crate::Result;
@@ -45,6 +48,7 @@ pub struct Compiler {
} }
impl Compiler { impl Compiler {
/*
pub fn compile<P: AsRef<Path>>(self, path: P) -> Result<(Option<String>, Option<String>)> { pub fn compile<P: AsRef<Path>>(self, path: P) -> Result<(Option<String>, Option<String>)> {
let mut cmd: Vec<String> = vec![JAVA_BIN_COMPILER.to_string()]; let mut cmd: Vec<String> = vec![JAVA_BIN_COMPILER.to_string()];
@@ -62,6 +66,23 @@ impl Compiler {
Ok(io::run_process(cmd.as_slice())?) Ok(io::run_process(cmd.as_slice())?)
} }
*/
pub fn compile<P: AsRef<Path>>(self, path: P) -> Result<bool> {
Ok(Exec::cmd(JAVA_BIN_COMPILER)
.args(
self.flags
.clone()
.into_iter()
.flat_map(|f| Into::<Vec<String>>::into(f)),
)
.arg(path.as_ref())
.stdout(Redirection::Pipe)
.detached()
.start()?
.wait()?
.success())
}
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@@ -7,13 +7,10 @@ pub enum Error {
EmptyStdout, EmptyStdout,
#[from] #[from]
Io(io::Error), Io(std::io::Error),
NthOutOfBounds, NthOutOfBounds,
#[from] #[from]
Semver(semver::Error), Semver(semver::Error),
#[from]
StdIo(std::io::Error),
} }

View File

@@ -6,6 +6,7 @@ use std::str::FromStr;
pub use error::{Error, Result}; pub use error::{Error, Result};
use runtime::VMFlag; use runtime::VMFlag;
use subprocess::Exec;
pub const JAVA_BIN_VM: &str = "java"; pub const JAVA_BIN_VM: &str = "java";
pub const JAVA_BIN_COMPILER: &str = "javac"; pub const JAVA_BIN_COMPILER: &str = "javac";
@@ -41,9 +42,8 @@ pub fn get_javac_ver() -> Result<semver::Version> {
/// Calls the java binary, returning the complete stdout version information. /// Calls the java binary, returning the complete stdout version information.
fn get_java_version_info() -> Result<String> { fn get_java_version_info() -> Result<String> {
Ok( Ok(Exec::cmd(JAVA_BIN_VM)
io::run_process(&[JAVA_BIN_VM, VMFlag::Version.to_string().as_str()])? .arg(VMFlag::Version.to_string().as_str())
.0 .capture()?
.ok_or(Error::EmptyStdout)?, .stdout_str())
)
} }

View File

@@ -5,6 +5,7 @@ use crate::JAVA_BIN_VM;
use crate::Result; use crate::Result;
use bytesize::ByteSize; use bytesize::ByteSize;
use subprocess::Exec;
#[derive(Debug, Default, Clone)] #[derive(Debug, Default, Clone)]
pub struct JVMBuilder { pub struct JVMBuilder {
@@ -74,36 +75,32 @@ pub struct JVM {
} }
impl JVM { impl JVM {
pub fn run<P: AsRef<Path>>(self, entry_point: P) -> Result<(Option<String>, Option<String>)> { pub fn run<P: AsRef<Path>>(self, entry_point: P) -> Result<()> {
let mut cmd = vec![JAVA_BIN_VM.to_string()]; let capture = Exec::cmd(JAVA_BIN_VM)
.args(
self.flags
.clone()
.into_iter()
.flat_map(|f| Into::<Vec<String>>::into(f)),
)
.arg(entry_point.as_ref())
.capture()?;
cmd.extend( if !self.monitor {
self.flags return Ok(());
.clone()
.into_iter()
.flat_map(|f| Into::<Vec<String>>::into(f)),
);
cmd.push(entry_point.as_ref().to_path_buf().display().to_string());
let result = io::run_process(cmd.as_slice())?;
if self.monitor {
let (stdout, stderr) = &result;
if let Option::Some(stdout) = stdout
&& stdout.len() > 0
{
print!("{stdout}");
}
if let Option::Some(stderr) = stderr
&& stderr.len() > 0
{
eprintln!("{stderr}");
}
} }
Ok(result) let stdout = capture.stdout_str();
if stdout.len() > 0 {
println!("{stdout}");
}
let stderr = capture.stderr_str();
if stderr.len() > 0 {
eprintln!("{stderr}");
}
Ok(())
} }
} }

View File

@@ -17,6 +17,5 @@ bytesize.workspace = true
cli.workspace = true cli.workspace = true
core.workspace = true core.workspace = true
fs.workspace = true fs.workspace = true
io.workspace = true
java.workspace = true java.workspace = true
toml.workspace = true toml.workspace = true

View File

@@ -17,7 +17,6 @@ fn main() -> anyhow::Result<()> {
} }
.map_err(|err| anyhow!(err))?; .map_err(|err| anyhow!(err))?;
dbg!();
match &CLI_ARGS.command { match &CLI_ARGS.command {
Command::New { .. } | Command::Init => wh.init(), Command::New { .. } | Command::Init => wh.init(),
Command::Build => wh.build(), Command::Build => wh.build(),

View File

@@ -1 +0,0 @@
21

View File

@@ -1,8 +0,0 @@
dependencies = []
[workspace]
default_package = "main"
[meta]
name = "demo"
version = "0.1.0"

View File

@@ -1,6 +0,0 @@
[package]
entry_point = ""
[meta]
name = "main"
version = "0.1.0"

View File

@@ -1,10 +0,0 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
public static int add(int a, int b) {
return a + b;
}
}

View File

@@ -1,6 +0,0 @@
[package]
entry_point = ""
[meta]
name = "test"
version = "0.1.0"

View File

@@ -1,10 +0,0 @@
public class MainTest {
public static void main(String[] args) {
testAdd();
}
public static void testAdd() {
assert Main.add(2, 2) == 4;
}
}

Binary file not shown.

Binary file not shown.