mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-27 13:52:47 -07:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b9abfb64c0 | |||
| 3ca8861d85 | |||
| 0c93aab13f | |||
| 208b49cfc8 | |||
| db0a2d9d1d | |||
| c123e93433 | |||
| 35557d296d | |||
| d0d6550d7e | |||
| 38d9be2bb0 | |||
| fcb33d208c | |||
| f831ad6c7a | |||
| 3bfed5fabc | |||
| e1ce3ba2fd |
@@ -14,6 +14,15 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
lint_and_fmt:
|
||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: cargo fmt --all -- --check
|
||||
- run: cargo clippy -- -D warnings
|
||||
|
||||
build_and_test:
|
||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
|
||||
name: Build and test rust crates
|
||||
|
||||
@@ -74,7 +74,9 @@ Now to execute it just run `cargo run --release`.
|
||||
- rust
|
||||
- cargo
|
||||
- node
|
||||
- pnpm (other package managers support will be added soon)
|
||||
- npm/pnpm/yarn*
|
||||
|
||||
> yarn [pnp](https://yarnpkg.com/features/pnp) is not supported yet
|
||||
|
||||
## Folder structure
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[package]
|
||||
name = "tuono"
|
||||
version = "0.2.0"
|
||||
version = "0.2.3"
|
||||
edition = "2021"
|
||||
authors = ["V. Ageno <valerioageno@yahoo.it>"]
|
||||
description = "The react/rust fullstack framework"
|
||||
homepage = "https://github.com/Valerioageno/tuono"
|
||||
repository = "https://github.com/Valerioageno/tuono"
|
||||
readme = "../../README.md"
|
||||
license-file = "../../LICENSE.md"
|
||||
categories = ["web-programming", "reactjs", "typescript", "framework", "fullstack"]
|
||||
|
||||
@@ -165,7 +165,7 @@ fn outro(folder_name: String) {
|
||||
}
|
||||
|
||||
println!("\nInstall the dependencies:");
|
||||
println!("pnpm install");
|
||||
println!("npm install");
|
||||
|
||||
println!("\nRun the local environment:");
|
||||
println!("tuono dev");
|
||||
|
||||
@@ -73,15 +73,16 @@ async fn main() {
|
||||
|
||||
let app = Router::new()
|
||||
// ROUTE_BUILDER
|
||||
.fallback_service(
|
||||
ServeDir::new("public"))
|
||||
.fallback_service(ServeDir::new("out/client")
|
||||
.fallback(get(catch_all)))
|
||||
.fallback_service(ServeDir::new("/*public_dir*/").fallback(get(catch_all)))
|
||||
.with_state(fetch);
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||
|
||||
println!("\nDevelopment app ready at http://localhost:3000/");
|
||||
if MODE == Mode::Dev {
|
||||
println!("\nDevelopment app ready at http://localhost:3000/");
|
||||
} else {
|
||||
println!("\nProduction app ready at http://localhost:3000/");
|
||||
}
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
||||
@@ -108,6 +109,8 @@ async fn catch_all(Path(params): Path<HashMap<String, String>>, request: Request
|
||||
|
||||
const ROOT_FOLDER: &str = "src/routes";
|
||||
const DEV_FOLDER: &str = ".tuono";
|
||||
const DEV_PUBLIC_DIR: &str = "public";
|
||||
const PROD_PUBLIC_DIR: &str = "out/client";
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct Route {
|
||||
@@ -251,6 +254,12 @@ pub fn bundle_axum_source(mode: Mode) -> io::Result<()> {
|
||||
}
|
||||
|
||||
fn generate_axum_source(source_builder: &SourceBuilder, mode: Mode) -> String {
|
||||
let public_dir = if mode == Mode::Prod {
|
||||
PROD_PUBLIC_DIR
|
||||
} else {
|
||||
DEV_PUBLIC_DIR
|
||||
};
|
||||
|
||||
AXUM_ENTRY_POINT
|
||||
.replace(
|
||||
"// ROUTE_BUILDER\n",
|
||||
@@ -260,6 +269,7 @@ fn generate_axum_source(source_builder: &SourceBuilder, mode: Mode) -> String {
|
||||
"// MODULE_IMPORTS\n",
|
||||
&create_modules_declaration(&source_builder.route_map),
|
||||
)
|
||||
.replace("/*public_dir*/", public_dir)
|
||||
.replace("/*MODE*/", mode.as_str())
|
||||
}
|
||||
|
||||
@@ -400,4 +410,20 @@ mod tests {
|
||||
assert_eq!(dev, "Mode::Dev");
|
||||
assert_eq!(prod, "Mode::Prod");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_replace_the_correct_public_folder_dev() {
|
||||
let source_builder = SourceBuilder::new();
|
||||
let source = generate_axum_source(&source_builder, Mode::Dev);
|
||||
|
||||
assert!(source.contains(r#"ServeDir::new("public")"#))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_replace_the_correct_public_folder_prod() {
|
||||
let source_builder = SourceBuilder::new();
|
||||
let source = generate_axum_source(&source_builder, Mode::Prod);
|
||||
|
||||
assert!(source.contains(r#"ServeDir::new("out/client")"#))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[package]
|
||||
name = "tuono_lib"
|
||||
version = "0.2.0"
|
||||
version = "0.2.3"
|
||||
edition = "2021"
|
||||
authors = ["V. Ageno <valerioageno@yahoo.it>"]
|
||||
description = "The react/rust fullstack framework"
|
||||
homepage = "https://github.com/Valerioageno/tuono"
|
||||
repository = "https://github.com/Valerioageno/tuono"
|
||||
readme = "../../README.md"
|
||||
license-file = "../../LICENSE.md"
|
||||
categories = ["web-programming", "reactjs", "typescript", "framework", "fullstack"]
|
||||
@@ -24,7 +24,7 @@ serde = { version = "1.0.202", features = ["derive"] }
|
||||
erased-serde = "0.4.5"
|
||||
serde_json = "1.0"
|
||||
|
||||
tuono_lib_macros = {path = "../tuono_lib_macros", version = "0.2.0"}
|
||||
tuono_lib_macros = {path = "../tuono_lib_macros", version = "0.2.3"}
|
||||
once_cell = "1.19.0"
|
||||
lazy_static = "1.5.0"
|
||||
regex = "1.10.5"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[package]
|
||||
name = "tuono_lib_macros"
|
||||
version = "0.2.0"
|
||||
version = "0.2.3"
|
||||
edition = "2021"
|
||||
description = "The react/rust fullstack framework"
|
||||
homepage = "https://github.com/Valerioageno/tuono"
|
||||
repository = "https://github.com/Valerioageno/tuono"
|
||||
readme = "../../README.md"
|
||||
license-file = "../../LICENSE.md"
|
||||
categories = ["web-programming", "reactjs", "typescript", "framework", "fullstack"]
|
||||
|
||||
@@ -7,5 +7,3 @@ mod handler;
|
||||
pub fn handler(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||
handler::handler_core(args, item)
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -5,8 +5,8 @@ This tutorial is meant for giving you a sneak peek of the framework and is inten
|
||||
The first part is about the project setup and the base knowledge needed to work with tuono. The actual tutorial starts at [Tutorial introduction](#tutorial-introduction).
|
||||
|
||||
> I'd love to hear your thoughts about the framework and the tutorial - feel free to reach me
|
||||
at [valerioageno@yahoo.it](mailto:valerioageno@yahoo.it) or in Twitter (X) DMs
|
||||
[@valerioageno](https://twitter.com/valerioageno
|
||||
at [valerioageno@yahoo.it](mailto:valerioageno@yahoo.it) or on Twitter (X) DMs
|
||||
[@valerioageno](https://twitter.com/valerioageno)
|
||||
|
||||
This tutorial is **not meant** for people that don't know React - in that case I suggest you to first read the [React doc](https://react.dev/);
|
||||
|
||||
@@ -53,7 +53,7 @@ $ tuono new tuono-tutorial
|
||||
Get into the project folder and install the dependencies with:
|
||||
|
||||
```bash
|
||||
$ pnpm install
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Open it with your favourite code editor.
|
||||
@@ -283,7 +283,7 @@ Create alongside the `PokemonLink.tsx` component the CSS module `PokemonLink.mod
|
||||
}
|
||||
```
|
||||
|
||||
> 💡 SASS is supported out of the box. Just install the processor in the devDependencies `pnpm i -D sass` and run again `tuono dev`
|
||||
> 💡 SASS is supported out of the box. Just install the processor in the devDependencies `npm i -D sass` and run again `tuono dev`
|
||||
|
||||
Then import the styles into the `PokemonLink` component as following:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tuono-lazy-fn-vite-plugin",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.3",
|
||||
"description": "Plugin for the tuono's lazy fn. Tuono is the react/rust fullstack framework",
|
||||
"scripts": {
|
||||
"dev": "vite build --watch",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tuono",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.3",
|
||||
"description": "The react/rust fullstack framework",
|
||||
"scripts": {
|
||||
"dev": "vite build --watch",
|
||||
|
||||
Reference in New Issue
Block a user