build(format): move rust formatting to prettier

main
Carsten Kragelund 2023-07-29 16:09:12 +02:00
parent 748346fa6e
commit ca429aaccc
Signed by: nyx
GPG Key ID: CADDADEEC9F753C0
6 changed files with 38 additions and 15 deletions

@ -3,6 +3,13 @@
{ {
"files": ".prettierrc", "files": ".prettierrc",
"options": { "parser": "json" } "options": { "parser": "json" }
},
{
"files": "**/*.rs",
"options": {
"tabWidth": 4,
"printWidth": 80
}
} }
] ]
} }

17
package-lock.json generated

@ -27,6 +27,7 @@
"concurrently": "^8.2.0", "concurrently": "^8.2.0",
"eslint-config-prettier": "^8.9.0", "eslint-config-prettier": "^8.9.0",
"prettier": "^2.8.8", "prettier": "^2.8.8",
"prettier-plugin-rust": "^0.1.9",
"prettier-plugin-toml": "^0.3.1", "prettier-plugin-toml": "^0.3.1",
"rimraf": "^5.0.1" "rimraf": "^5.0.1"
} }
@ -3036,6 +3037,12 @@
"@pkgjs/parseargs": "^0.11.0" "@pkgjs/parseargs": "^0.11.0"
} }
}, },
"node_modules/jinx-rust": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/jinx-rust/-/jinx-rust-0.1.6.tgz",
"integrity": "sha512-qP+wtQL1PrDDFwtPKhNGtjWOmijCrKdfUHWTV2G/ikxfjrh+cjdvkQTmny9RAsVF0jiui9m+F0INWu4cuRcZeQ==",
"dev": true
},
"node_modules/jiti": { "node_modules/jiti": {
"version": "1.19.1", "version": "1.19.1",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-1.19.1.tgz", "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.19.1.tgz",
@ -3873,6 +3880,16 @@
"url": "https://github.com/prettier/prettier?sponsor=1" "url": "https://github.com/prettier/prettier?sponsor=1"
} }
}, },
"node_modules/prettier-plugin-rust": {
"version": "0.1.9",
"resolved": "https://registry.npmjs.org/prettier-plugin-rust/-/prettier-plugin-rust-0.1.9.tgz",
"integrity": "sha512-n1DTTJQaHMdnoG/+nKUvBm3EKsMVWsYES2UPCiOPiZdBrmuAO/pX++m7L3+Hz3uuhtddpH0HRKHB2F3jbtJBOQ==",
"dev": true,
"dependencies": {
"jinx-rust": "0.1.6",
"prettier": "^2.7.1"
}
},
"node_modules/prettier-plugin-toml": { "node_modules/prettier-plugin-toml": {
"version": "0.3.1", "version": "0.3.1",
"resolved": "https://registry.npmjs.org/prettier-plugin-toml/-/prettier-plugin-toml-0.3.1.tgz", "resolved": "https://registry.npmjs.org/prettier-plugin-toml/-/prettier-plugin-toml-0.3.1.tgz",

@ -9,12 +9,8 @@
"lint": "npm run lint@js && npm run lint@rust", "lint": "npm run lint@js && npm run lint@rust",
"lint@js": "eslint . --ext .js,.ts,.jsx,.tsx", "lint@js": "eslint . --ext .js,.ts,.jsx,.tsx",
"lint@rust": "cargo clippy --all-targets --all-features -- -D warnings", "lint@rust": "cargo clippy --all-targets --all-features -- -D warnings",
"format": "npm run format@js && npm run format@rust", "format": "prettier --write --ignore-unknown --no-error-on-unmatched-pattern .",
"format@js": "prettier --write --ignore-unknown --no-error-on-unmatched-pattern .", "format-check": "prettier --check --ignore-unknown --no-error-on-unmatched-pattern .",
"format@rust": "cargo fmt --all",
"format-check": "npm run format-check@js && npm run format-check@rust",
"format-check@js": "prettier --check --ignore-unknown --no-error-on-unmatched-pattern .",
"format-check@rust": "cargo fmt --all --check",
"clean": "npm run clean@js && npm run clean@rust", "clean": "npm run clean@js && npm run clean@rust",
"clean@js": "rimraf node_modules && rimraf .next", "clean@js": "rimraf node_modules && rimraf .next",
"clean@rust": "cargo clean" "clean@rust": "cargo clean"
@ -39,6 +35,7 @@
"concurrently": "^8.2.0", "concurrently": "^8.2.0",
"eslint-config-prettier": "^8.9.0", "eslint-config-prettier": "^8.9.0",
"prettier": "^2.8.8", "prettier": "^2.8.8",
"prettier-plugin-rust": "^0.1.9",
"prettier-plugin-toml": "^0.3.1", "prettier-plugin-toml": "^0.3.1",
"rimraf": "^5.0.1" "rimraf": "^5.0.1"
} }

@ -1,5 +1,5 @@
use rapid_web::actix::HttpServer; use rapid_web::actix::HttpServer;
use rapid_web::rapid_web_codegen::{main, rapid_configure_nextjs, routes}; use rapid_web::rapid_web_codegen::{ main, rapid_configure_nextjs, routes };
use rapid_web::server::RapidServer; use rapid_web::server::RapidServer;
rapid_configure_nextjs!(); rapid_configure_nextjs!();
@ -8,8 +8,9 @@ rapid_configure_nextjs!();
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
let app = RapidServer::create(None, None); let app = RapidServer::create(None, None);
app.listen(HttpServer::new(move || { app.listen(
RapidServer::fs_router(None, None, routes!("pages/api/routes")) HttpServer::new(move || {
})) RapidServer::fs_router(None, None, routes!("pages/api/routes"))
.await })
).await
} }

@ -1,11 +1,11 @@
use rapid_web::actix::HttpResponse; use rapid_web::actix::HttpResponse;
use rapid_web::{rapid_web_codegen::rapid_handler, welcome_view}; use rapid_web::{ rapid_web_codegen::rapid_handler, welcome_view };
pub const ROUTE_KEY: &str = "index"; pub const ROUTE_KEY: &str = "index";
#[rapid_handler] #[rapid_handler]
pub async fn query() -> HttpResponse { pub async fn query() -> HttpResponse {
HttpResponse::Ok() HttpResponse::Ok()
.content_type("text/html; charset=utf-8") .content_type("text/html; charset=utf-8")
.body(welcome_view) .body(welcome_view)
} }

@ -1,2 +1,3 @@
pub mod index; pub mod echo;
pub mod hello; pub mod hello;
pub mod index;