-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
93 lines (78 loc) · 3.04 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# List all available commands
default:
@just --list
# Create a new FastAPI basic project
new-fastapi-basic project_name="":
#!/usr/bin/env bash
if [ -z "{{project_name}}" ]; then
read -p "Enter project name: " name
else
name="{{project_name}}"
fi
# Convert project name to lowercase and replace hyphens with underscores
poetry_name=$(echo "$name" | tr '[:upper:]' '[:lower:]' | tr '-' '_')
display_name="$name"
# Create project directory
mkdir -p "$name"
# Copy template files
cp -r templates/fastapi-basic/* "$name/"
# Replace template variables using perl (more reliable than sed for this case)
find "$name" -type f -exec perl -pi -e "s/\{\{project_name\}\}/$poetry_name/g" {} +
find "$name" -type f -exec perl -pi -e "s/\{\{display_name\}\}/$display_name/g" {} +
# Setup Python environment
cd "$name"
poetry install || {
echo "Error: Poetry installation failed. Please check your project name and try again."
echo "Project names must:"
echo " - Start with a letter or number"
echo " - Contain only letters, numbers, underscores, and hyphens"
echo " - End with a letter or number"
cd ..
rm -rf "$name"
exit 1
}
echo "Project '$name' created successfully!"
echo "To get started:"
echo " cd $name"
echo " just setup"
echo " just dev"
# Create a new Rust Axum basic project
new-rust-axum-basic project_name="":
#!/usr/bin/env bash
if [ -z "{{project_name}}" ]; then
read -p "Enter project name: " name
else
name="{{project_name}}"
fi
# Validate project name
if [[ ! "$name" =~ ^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$ ]]; then
echo "Error: Project name must start with a letter, end with a letter or number, and contain only letters, numbers, underscores, and hyphens"
exit 1
fi
# Convert project name to Cargo-compatible format (lowercase with underscores)
cargo_name=$(echo "$name" | tr '[:upper:]' '[:lower:]' | tr '-' '_')
display_name="$name"
# Copy template
cp -r templates/rust-axum-basic "$name"
# Replace template variables
find "$name" -type f -exec perl -pi -e "s/\\{\\{project_name\\}\\}/$cargo_name/g" {} +
find "$name" -type f -exec perl -pi -e "s/\\{\\{display_name\\}\\}/$display_name/g" {} +
echo "Created new Rust Axum project: $name"
echo "To get started:"
echo " cd $name"
echo " just setup"
echo " just dev"
# List available templates
list-templates:
@echo "Available templates:"
@ls -1 templates/
# Create template directory structure
create-template template_name:
#!/usr/bin/env bash
mkdir -p "templates/{{template_name}}"
echo "# {{template_name}} Template" > "templates/{{template_name}}/README.md"
echo "Template directory created at templates/{{template_name}}"
echo "Don't forget to:"
echo "1. Add template files"
echo "2. Update the justfile with a new recipe"
echo "3. Update the main README.md"