mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-29 13:52:46 -07:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7401a59346 | |||
| 622ae93d68 | |||
| b4207feb7e | |||
| 332fdb70ca | |||
| b9abfb64c0 | |||
| 3ca8861d85 | |||
| 0c93aab13f | |||
| 208b49cfc8 | |||
| db0a2d9d1d | |||
| c123e93433 | |||
| 35557d296d | |||
| d0d6550d7e |
@@ -74,7 +74,9 @@ Now to execute it just run `cargo run --release`.
|
|||||||
- rust
|
- rust
|
||||||
- cargo
|
- cargo
|
||||||
- node
|
- 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
|
## Folder structure
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tuono"
|
name = "tuono"
|
||||||
version = "0.2.1"
|
version = "0.2.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["V. Ageno <valerioageno@yahoo.it>"]
|
authors = ["V. Ageno <valerioageno@yahoo.it>"]
|
||||||
description = "The react/rust fullstack framework"
|
description = "The react/rust fullstack framework"
|
||||||
homepage = "https://github.com/Valerioageno/tuono"
|
repository = "https://github.com/Valerioageno/tuono"
|
||||||
readme = "../../README.md"
|
readme = "../../README.md"
|
||||||
license-file = "../../LICENSE.md"
|
license-file = "../../LICENSE.md"
|
||||||
categories = ["web-programming", "reactjs", "typescript", "framework", "fullstack"]
|
categories = ["web-programming"]
|
||||||
include = [
|
include = [
|
||||||
"src/*.rs",
|
"src/*.rs",
|
||||||
"Cargo.toml"
|
"Cargo.toml"
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ fn outro(folder_name: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
println!("\nInstall the dependencies:");
|
println!("\nInstall the dependencies:");
|
||||||
println!("pnpm install");
|
println!("npm install");
|
||||||
|
|
||||||
println!("\nRun the local environment:");
|
println!("\nRun the local environment:");
|
||||||
println!("tuono dev");
|
println!("tuono dev");
|
||||||
|
|||||||
@@ -73,10 +73,7 @@ async fn main() {
|
|||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
// ROUTE_BUILDER
|
// ROUTE_BUILDER
|
||||||
.fallback_service(
|
.fallback_service(ServeDir::new("/*public_dir*/").fallback(get(catch_all)))
|
||||||
ServeDir::new("public"))
|
|
||||||
.fallback_service(ServeDir::new("out/client")
|
|
||||||
.fallback(get(catch_all)))
|
|
||||||
.with_state(fetch);
|
.with_state(fetch);
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||||
@@ -112,6 +109,8 @@ async fn catch_all(Path(params): Path<HashMap<String, String>>, request: Request
|
|||||||
|
|
||||||
const ROOT_FOLDER: &str = "src/routes";
|
const ROOT_FOLDER: &str = "src/routes";
|
||||||
const DEV_FOLDER: &str = ".tuono";
|
const DEV_FOLDER: &str = ".tuono";
|
||||||
|
const DEV_PUBLIC_DIR: &str = "public";
|
||||||
|
const PROD_PUBLIC_DIR: &str = "out/client";
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
struct Route {
|
struct Route {
|
||||||
@@ -255,6 +254,12 @@ pub fn bundle_axum_source(mode: Mode) -> io::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn generate_axum_source(source_builder: &SourceBuilder, mode: Mode) -> String {
|
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
|
AXUM_ENTRY_POINT
|
||||||
.replace(
|
.replace(
|
||||||
"// ROUTE_BUILDER\n",
|
"// ROUTE_BUILDER\n",
|
||||||
@@ -264,6 +269,7 @@ fn generate_axum_source(source_builder: &SourceBuilder, mode: Mode) -> String {
|
|||||||
"// MODULE_IMPORTS\n",
|
"// MODULE_IMPORTS\n",
|
||||||
&create_modules_declaration(&source_builder.route_map),
|
&create_modules_declaration(&source_builder.route_map),
|
||||||
)
|
)
|
||||||
|
.replace("/*public_dir*/", public_dir)
|
||||||
.replace("/*MODE*/", mode.as_str())
|
.replace("/*MODE*/", mode.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,4 +410,20 @@ mod tests {
|
|||||||
assert_eq!(dev, "Mode::Dev");
|
assert_eq!(dev, "Mode::Dev");
|
||||||
assert_eq!(prod, "Mode::Prod");
|
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,13 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tuono_lib"
|
name = "tuono_lib"
|
||||||
version = "0.2.1"
|
version = "0.2.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["V. Ageno <valerioageno@yahoo.it>"]
|
authors = ["V. Ageno <valerioageno@yahoo.it>"]
|
||||||
description = "The react/rust fullstack framework"
|
description = "The react/rust fullstack framework"
|
||||||
homepage = "https://github.com/Valerioageno/tuono"
|
repository = "https://github.com/Valerioageno/tuono"
|
||||||
readme = "../../README.md"
|
readme = "../../README.md"
|
||||||
license-file = "../../LICENSE.md"
|
license-file = "../../LICENSE.md"
|
||||||
categories = ["web-programming", "reactjs", "typescript", "framework", "fullstack"]
|
categories = ["web-programming"]
|
||||||
include = [
|
include = [
|
||||||
"src/*.rs",
|
"src/*.rs",
|
||||||
"Cargo.toml"
|
"Cargo.toml"
|
||||||
@@ -18,13 +18,13 @@ name = "tuono_lib"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ssr_rs = "0.5.4"
|
ssr_rs = "0.5.5"
|
||||||
axum = "0.7.5"
|
axum = "0.7.5"
|
||||||
serde = { version = "1.0.202", features = ["derive"] }
|
serde = { version = "1.0.202", features = ["derive"] }
|
||||||
erased-serde = "0.4.5"
|
erased-serde = "0.4.5"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
tuono_lib_macros = {path = "../tuono_lib_macros", version = "0.2.1"}
|
tuono_lib_macros = {path = "../tuono_lib_macros", version = "0.2.5"}
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
regex = "1.10.5"
|
regex = "1.10.5"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tuono_lib_macros"
|
name = "tuono_lib_macros"
|
||||||
version = "0.2.1"
|
version = "0.2.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "The react/rust fullstack framework"
|
description = "The react/rust fullstack framework"
|
||||||
homepage = "https://github.com/Valerioageno/tuono"
|
repository = "https://github.com/Valerioageno/tuono"
|
||||||
readme = "../../README.md"
|
readme = "../../README.md"
|
||||||
license-file = "../../LICENSE.md"
|
license-file = "../../LICENSE.md"
|
||||||
categories = ["web-programming", "reactjs", "typescript", "framework", "fullstack"]
|
categories = ["web-programming"]
|
||||||
include = [
|
include = [
|
||||||
"src/*.rs",
|
"src/*.rs",
|
||||||
"Cargo.toml"
|
"Cargo.toml"
|
||||||
|
|||||||
+2
-2
@@ -53,7 +53,7 @@ $ tuono new tuono-tutorial
|
|||||||
Get into the project folder and install the dependencies with:
|
Get into the project folder and install the dependencies with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ pnpm install
|
$ npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
Open it with your favourite code editor.
|
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:
|
Then import the styles into the `PokemonLink` component as following:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tuono-lazy-fn-vite-plugin",
|
"name": "tuono-lazy-fn-vite-plugin",
|
||||||
"version": "0.2.1",
|
"version": "0.2.5",
|
||||||
"description": "Plugin for the tuono's lazy fn. Tuono is the react/rust fullstack framework",
|
"description": "Plugin for the tuono's lazy fn. Tuono is the react/rust fullstack framework",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite build --watch",
|
"dev": "vite build --watch",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tuono",
|
"name": "tuono",
|
||||||
"version": "0.2.1",
|
"version": "0.2.5",
|
||||||
"description": "The react/rust fullstack framework",
|
"description": "The react/rust fullstack framework",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite build --watch",
|
"dev": "vite build --watch",
|
||||||
|
|||||||
Reference in New Issue
Block a user