#!/usr/bin/env bash # Renames the template to your own project name. # # ./rename.sh my-project ["My Project"] # # Replaces app-template / app_template / "App template" everywhere they are used # (crate name, database name, package name, page title, ...). Run it once, right # after copying the template, then delete this script. set -euo pipefail if [ $# -lt 1 ]; then echo "usage: $0 [\"Display Name\"]" >&2 exit 1 fi NAME="$1" SNAKE="${NAME//-/_}" DISPLAY="${2:-$NAME}" if ! [[ "$NAME" =~ ^[a-z][a-z0-9-]*$ ]]; then echo "The project name must be lowercase, and may contain digits and dashes." >&2 exit 1 fi cd "$(dirname "$0")" FILES=( Cargo.toml Cargo.lock .env config.example.yml config.yml README.md src/utils/config.rs frontend/package.json frontend/index.html frontend/src/locales/fr.yml frontend/src/locales/en.yml ) for file in "${FILES[@]}"; do [ -f "$file" ] || continue sed -i \ -e "s/app-template/$NAME/g" \ -e "s/app_template/$SNAKE/g" \ -e "s/App template/$DISPLAY/g" \ "$file" echo "updated $file" done echo echo "Done. Next steps:" echo " - create the database: psql -h localhost -U postgres -c 'CREATE DATABASE $SNAKE'" echo " - dbmate up" echo " - cp config.example.yml config.yml" echo " - rm rename.sh"