Compare commits

..

12 Commits

Author SHA1 Message Date
Valerio Ageno 7401a59346 update version to v0.2.5 2024-06-27 17:53:12 +02:00
Valerio Ageno 622ae93d68 fix: crates categories 2024-06-27 17:52:32 +02:00
Valerio Ageno b4207feb7e Update version to v0.2.4 2024-06-27 17:47:09 +02:00
Valerio Ageno 332fdb70ca Update ssr_rs to v0.5.5 2024-06-27 17:46:19 +02:00
Valerio Ageno b9abfb64c0 feat: update version to v0.2.3 2024-06-25 18:53:17 +02:00
Valerio Ageno 3ca8861d85 feat: use the correct public folder according to the mode 2024-06-25 18:48:55 +02:00
Valerio Ageno 0c93aab13f Update tutorial.md 2024-06-25 14:26:27 +02:00
Valerio Ageno 208b49cfc8 Update tutorial.md 2024-06-25 14:26:01 +02:00
Valerio Ageno db0a2d9d1d Update README.md 2024-06-25 14:24:59 +02:00
Valerio Ageno c123e93433 Update scaffold_project.rs 2024-06-25 14:23:22 +02:00
Valerio Ageno 35557d296d feat: update version to v0.2.2 2024-06-25 08:35:09 +02:00
Gábor Szabó d0d6550d7e It is better to use the repository field in Cargo.toml (#7) 2024-06-25 07:42:04 +02:00
9 changed files with 45 additions and 21 deletions
+3 -1
View File
@@ -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
+3 -3
View File
@@ -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"
+1 -1
View File
@@ -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");
+26 -4
View File
@@ -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")"#))
}
} }
+5 -5
View File
@@ -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"
+3 -3
View File
@@ -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
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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",