-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRAFT: Start adding support for workspace #804
Draft
Its-Just-Nans
wants to merge
1
commit into
trunk-rs:main
Choose a base branch
from
Its-Just-Nans:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ description = "Build, bundle & ship your Rust WASM application to the web." | |
license = "MIT/Apache-2.0" | ||
authors = [ | ||
"Anthony Dodd <[email protected]>", | ||
"Jens Reimann <[email protected]>" | ||
"Jens Reimann <[email protected]>", | ||
] | ||
repository = "https://github.com/trunk-rs/trunk" | ||
readme = "README.md" | ||
|
@@ -34,7 +34,9 @@ console = "0.15" | |
directories = "5" | ||
dunce = "1" | ||
flate2 = "1" | ||
futures-util = { version = "0.3", default-features = false, features = ["sink"] } | ||
futures-util = { version = "0.3", default-features = false, features = [ | ||
"sink", | ||
] } | ||
htmlescape = "0.3.1" | ||
humantime = "2" | ||
humantime-serde = "1" | ||
|
@@ -51,7 +53,10 @@ open = "5" | |
oxipng = "9" | ||
parking_lot = "0.12" | ||
remove_dir_all = "0.8" | ||
reqwest = { version = "0.12", default-features = false, features = ["stream", "trust-dns"] } | ||
reqwest = { version = "0.12", default-features = false, features = [ | ||
"stream", | ||
"trust-dns", | ||
] } | ||
sha2 = "0.10" | ||
schemars = { version = "0.8", features = ["derive"] } | ||
seahash = { version = "4", features = ["use_std"] } | ||
|
@@ -64,7 +69,10 @@ tar = "0.4" | |
time = { version = "0.3", features = ["serde-well-known"] } | ||
thiserror = "1" | ||
tokio = { version = "1", default-features = false, features = ["full"] } | ||
tokio-stream = { version = "0.1", default-features = false, features = ["fs", "sync"] } | ||
tokio-stream = { version = "0.1", default-features = false, features = [ | ||
"fs", | ||
"sync", | ||
] } | ||
tokio-tungstenite = "0.21" | ||
toml = "0.8" | ||
tower-http = { version = "0.5.1", features = ["fs", "trace", "set-header"] } | ||
|
@@ -104,6 +112,4 @@ native-tls = [ | |
] | ||
|
||
# enable the update check on startup | ||
update_check = [ | ||
"crates_io_api" | ||
] | ||
update_check = ["crates_io_api"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["simple-example"] | ||
default-members = ["simple-example"] | ||
|
||
[workspace.package] | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
rust-version = "1.76" | ||
version = "0.27.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "simple-example" | ||
version = "0.1.0" | ||
authors = ["Jens Reimann <[email protected]>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
web-sys = { version = "0.3", features = [ | ||
"console", | ||
"Document", | ||
"HtmlElement", | ||
"Node", | ||
"Text", | ||
"Window", | ||
] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Trunk | No-Rust</title> | ||
|
||
<base data-trunk-public-url /> | ||
</head> | ||
<body> | ||
<h1>Trunk without WASM</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use web_sys::window; | ||
|
||
fn start_app() { | ||
let document = window() | ||
.and_then(|win| win.document()) | ||
.expect("Could not access document"); | ||
let body = document.body().expect("Could not access document.body"); | ||
let text_node = document.create_text_node("Hello, world from Vanilla Rust!"); | ||
body.append_child(text_node.as_ref()) | ||
.expect("Failed to append text"); | ||
} | ||
|
||
fn main() { | ||
start_app(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod cargo; | ||
pub mod workspace; | ||
|
||
use crate::config::{models::ConfigModel, Configuration}; | ||
use anyhow::bail; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use anyhow::{Context, Result}; | ||
use cargo_metadata::{Metadata, MetadataCommand}; | ||
use std::path::Path; | ||
use std::path::PathBuf; | ||
use tokio::task::spawn_blocking; | ||
|
||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
pub struct WorkspaceConfig { | ||
pub metadata: Metadata, | ||
} | ||
|
||
impl WorkspaceConfig { | ||
pub async fn new(manifest: &Path) -> Result<Self> { | ||
let mut cmd = MetadataCommand::new(); | ||
cmd.manifest_path(dunce::simplified(manifest)); | ||
let metadata = spawn_blocking(move || cmd.exec()) | ||
.await | ||
.context("error awaiting spawned cargo metadata task")? | ||
.context("error getting cargo metadata")?; | ||
return Ok(Self { metadata }); | ||
} | ||
|
||
pub fn get_default_workspace(self) -> Option<PathBuf> { | ||
if let Some(default_members) = self.metadata.workspace_default_members.get(0) { | ||
if let Some(found) = self | ||
.metadata | ||
.packages | ||
.into_iter() | ||
.find(|p| p.id == *default_members) | ||
{ | ||
return Some(found.manifest_path.clone().into()); | ||
} | ||
} | ||
None | ||
} | ||
} | ||
|
||
/// Load the trunk configuration from the cargo manifest | ||
pub async fn workspace_from_manifest(file: impl AsRef<Path>) -> anyhow::Result<WorkspaceConfig> { | ||
let workspace_config = WorkspaceConfig::new(file.as_ref()).await?; | ||
Ok(workspace_config) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the one line format, as this allows to easily sort the dependencies alphabetically.