-
Notifications
You must be signed in to change notification settings - Fork 63
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
Support workspaces at library level #197
Conversation
Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.45 to 0.10.48. - [Release notes](https://github.com/sfackler/rust-openssl/releases) - [Commits](sfackler/rust-openssl@openssl-v0.10.45...openssl-v0.10.48) --- updated-dependencies: - dependency-name: openssl dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ml of user projects
Compilation is hanging for |
I think I figured out my compilation issue, but a fix will require adding a new feature so that create-rust-app::dev::run_server (and it's sub-processes) opperate slightly differently |
hey Anthony, this seems like a big change, please give me some time to review it and think about whether this added complexity is appropriate |
currently yeah, but there are more things that need to be changed to get everything to work properly (currently hangs on compiling the backend if you run the other changes are miscellaneous bug-fixes (caught by running cargo clippy w/ and w/o debug-assertions enabled), formatting improvements (auto-generated by once everything is ready I'll be sure to do an in-depth code review that explains all the changes (like I have in the past for other big changes) but feedback is greatly appreciated in the meantime If, when everything is ready, you'd still like me to split it into separate PR's I can do so then |
for sure, let me set it as a draft while I figure things out on my end |
figured out it's not an issue with cargo-watch (or if it was, I fixed it already), it's likely being caused by bad file paths in various parts of the codebase, the working directory of the server binary is ./backend not ./ when using workspaces gotta go, here's a list of bugs i've found so far and need to fix
|
Ah, yeah — there’s definitely lots of tech debt in the code base when it comes to file paths. You’ve probably seen some of the TODO statements. The logging situation also needs reconsidering — I’ve always wanted to implement a universal logger which is why some of the logging setup is in the helper crate (create-rust-app) instead of the generated app. Alongside this, do you have any thoughts on moving package.json and other front end stuff to the root level of the project? It really sucks to have to cd into frontend in order to execute some commands; however, it also allows the end user to , for example, introduce a third folder for a mobile app or something similar (and thereby potentially sharing some common code amongst the three projects). |
I personally like the flexibility granted by having the package.json in the frontend folder, it also gives us the opportunity to support rust frontends in the future |
And regarding the tech debt, I have an idea we could implement remedy it (at least for the file paths and urls):
I'd like your thoughts on this though, because I might be missing something. |
I think I figured out the issue with logging, this line was recently commented out, when I add the code to my project's main fn the logging works again.
|
@Wulf the fix I suggest is to add that line of code into the template for actix, as I assume it was removed for a reason |
I'll probably redo this soon |
but it actually works this time, in addition to compiling
Tested working on JARA dev |
With this addition, it might be approaching time to have an example's folder showing the 4 basic project types, as well as some more advanced setups (i.e., workspaces, different frontend frameworks / languages, mixing SQL (for auth) and NoSQL (for everything else) databases, etc.) what do you think @Wulf |
Look what we have here 😅
Let's get this PR merged in soon :) |
pub static ref WORKSPACE_DIR: PathBuf = { | ||
let output = std::process::Command::new(env!("CARGO")) | ||
.arg("locate-project") | ||
.arg("--workspace") | ||
.arg("--message-format=plain") | ||
.output() | ||
.unwrap() | ||
.stdout; | ||
let cargo_path = Path::new(std::str::from_utf8(&output).unwrap().trim()); | ||
cargo_path.parent().unwrap().to_path_buf() | ||
// .to_str() | ||
// .unwrap() | ||
// .to_owned() | ||
}; |
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.
the rest looks good to me but here we're assuming we'll have the project's source code. That's not necessarily the case (see #332 -- we split the build and binary container into two). We also don't want to go in this direction as it stops us from attempting a "single binary" build in the future as well.
It does point out that there's some existing tech debt here that needs to be addressed
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.
Should we have it stored in an environment variable instead? Similar to frontenddir
It's just that we need a way to know where the base of the project is and that's not always the current working directory
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.
Yeah. Some more thoughts:
I think we need to remove the feature flag. In create-rust-app/src/dev/mod.rs
, we should check if it's a workspace using the Cargo.toml
instead of relying on a feature flag.
Also, all the variables in this file should be &'static str
and be initialized to some default unless the backing environment variable is present (and they should all be configurable by env vars).
Let me know what you think!
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.
I've implemented most of your suggestions as of the most recent commits (also got rid of some unnecessary unwraps), but there's a few things I still need to figure out:
- a function that can tell us if we're using workspaces (without needing source code) (rather than using the feature flag)
- a way of finding the workspace root when the (not yet added) CRA_WORKSPACE_ROOT environment variable isn't set
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.
btw, sorry I've been awol for so long, I was busy at work over the summer and then school's been keeping me busy too, so I haven't had much time.
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.
sounds awesome -- it's cool to hear about your journey so far :)
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.
I'll have to take some time out to look into this further
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.
I think I figured something out, high level is that I made "finding the workspace dir" infallible (no panics, even in a container or something), then rethought the logic used in initializing these variables (getting rid of the need for the feature flag)
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.
@Wulf is this resolved?
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.
beautifully done.
🙌
44511d0
to
e23de14
Compare
… can make a function that can tell us if we're using workspaces
…iable initialization logic in worspace_utils
Partially addresses #194
What this does:
fullstack
).What this doesn't do