81 lines
No EOL
1.9 KiB
Bash
Executable file
81 lines
No EOL
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Component/Page/Service generator script for justfile
|
|
|
|
set -euo pipefail
|
|
|
|
NAME="$1"
|
|
TYPE="$2"
|
|
|
|
echo "🛠️ Creating new ${TYPE}: ${NAME}"
|
|
|
|
case "${TYPE}" in
|
|
"component"|"comp")
|
|
mkdir -p "crates/client/src/components"
|
|
NAME_KEBAB=$(echo "${NAME}" | tr '[:upper:]' '[:lower:]' | tr '_' '-')
|
|
cat > "crates/client/src/components/${NAME}.rs" << EOF
|
|
use leptos::*;
|
|
|
|
#[component]
|
|
pub fn ${NAME}() -> impl IntoView {
|
|
view! {
|
|
<div class="${NAME_KEBAB}">
|
|
<h2>"${NAME}"</h2>
|
|
<p>"New component created by Claude Code"</p>
|
|
</div>
|
|
}
|
|
}
|
|
EOF
|
|
echo "✅ Component created: crates/client/src/components/${NAME}.rs"
|
|
;;
|
|
|
|
"page")
|
|
mkdir -p "crates/client/src/pages"
|
|
NAME_KEBAB=$(echo "${NAME}" | tr '[:upper:]' '[:lower:]' | tr '_' '-')
|
|
cat > "crates/client/src/pages/${NAME}.rs" << EOF
|
|
use leptos::*;
|
|
use leptos_meta::*;
|
|
|
|
#[component]
|
|
pub fn ${NAME}() -> impl IntoView {
|
|
view! {
|
|
<Title text="${NAME}"/>
|
|
<div class="page-${NAME_KEBAB}">
|
|
<h1>"${NAME}"</h1>
|
|
<p>"New page created by Claude Code"</p>
|
|
</div>
|
|
}
|
|
}
|
|
EOF
|
|
echo "✅ Page created: crates/client/src/pages/${NAME}.rs"
|
|
;;
|
|
|
|
"service"|"srv")
|
|
mkdir -p "crates/server/src/services"
|
|
cat > "crates/server/src/services/${NAME}.rs" << EOF
|
|
use anyhow::Result;
|
|
|
|
pub struct ${NAME}Service {
|
|
// Add service fields here
|
|
}
|
|
|
|
impl ${NAME}Service {
|
|
pub fn new() -> Self {
|
|
Self {
|
|
// Initialize service
|
|
}
|
|
}
|
|
|
|
pub async fn example_method(&self) -> Result<String> {
|
|
Ok("${NAME} service response".to_string())
|
|
}
|
|
}
|
|
EOF
|
|
echo "✅ Service created: crates/server/src/services/${NAME}.rs"
|
|
;;
|
|
|
|
*)
|
|
echo "❌ Unknown component type: ${TYPE}"
|
|
echo "Available types: component, page, service"
|
|
exit 1
|
|
;;
|
|
esac |