From 80300f3b68a88ef69e22869c90f568a0e3e75967 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Sat, 20 Sep 2025 11:00:03 +0300 Subject: [PATCH] chore: update rename script + info.xml --- appinfo/info.xml | 17 ++--------------- rename-template.sh | 29 +++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 13caa34..afdbbb4 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -6,22 +6,9 @@ --> nextcloudapptemplate Nextcloud App Template - Automatically fills the currency rates for your Cospend projects daily. + Enter your app summary here. **Note**: This is a companion app to [Cospend](https://apps.nextcloud.com/apps/cospend). -> -> Without Cospend, this app will not work. +Enter your app description here. ]]> 1.0.0 agpl diff --git a/rename-template.sh b/rename-template.sh index 5b92ae8..5552db2 100755 --- a/rename-template.sh +++ b/rename-template.sh @@ -2,9 +2,9 @@ # Replace template names in all text files under the current directory. # Prompts for target names and replaces these sources: # $SOURCE_PACKAGE -> -# $SOURCE_PASCAL -> -# $SOURCE_USER -> (default: your-user) -# $SOURCE_FULL -> (default: Your Name) +# $SOURCE_PASCAL -> +# $SOURCE_USER -> (default: your-user) +# $SOURCE_FULL -> (default: Your Name) # # Defaults (override via env before running): # SOURCE_PACKAGE=nextcloudapptemplate @@ -14,7 +14,12 @@ set -euo pipefail +# --- Resolve absolute path to this script (portable) --- +abs_path() { perl -MCwd=abs_path -e 'print abs_path(shift)' "$1"; } +SCRIPT_ABS="$(abs_path "$0")" + SOURCE_PACKAGE="${SOURCE_PACKAGE:-nextcloudapptemplate}" +SOURCE_APPNAME="${SOURCE_APPNAME:-Nextcloud App Template}" SOURCE_PASCAL="${SOURCE_PASCAL:-NextcloudAppTemplate}" SOURCE_USER="${SOURCE_USER:-your-user}" SOURCE_FULL="${SOURCE_FULL:-Your Name}" @@ -23,9 +28,11 @@ SOURCE_WEBSITE="${SOURCE_WEBSITE:-https://your.website}" printf "Enter package name (e.g., mynextcloudapp): " IFS= read PACKAGE +printf "Enter app name (e.g., My Nextcloud App): " +IFS= read APPNAME printf "Enter PascalCase name (e.g., MyNextcloudApp): " IFS= read PASCAL -printf "Enter username (e.g., myUsername): " +printf "Enter GitHub username (e.g., myUsername): " IFS= read DEST_USER printf "Enter full name (e.g., My Full Name): " IFS= read DEST_FULL @@ -34,13 +41,14 @@ IFS= read DEST_EMAIL printf "Enter website (e.g., https://mywebsite.com): " IFS= read DEST_WEBSITE -if [[ -z "${PACKAGE}" || -z "${PASCAL}" || -z "${DEST_USER}" || -z "${DEST_FULL}" || -z "${DEST_EMAIL}" || -z "${DEST_WEBSITE}" ]]; then +if [[ -z "${PACKAGE}" || -z "${APPNAME}" || -z "${PASCAL}" || -z "${DEST_USER}" || -z "${DEST_FULL}" || -z "${DEST_EMAIL}" || -z "${DEST_WEBSITE}" ]]; then echo "All values are required." >&2 exit 1 fi echo "Replacing:" echo " ${SOURCE_PACKAGE} -> ${PACKAGE}" +echo " ${SOURCE_APPNAME} -> ${APPNAME}" echo " ${SOURCE_PASCAL} -> ${PASCAL}" echo " ${SOURCE_USER} -> ${DEST_USER}" echo " ${SOURCE_FULL} -> ${DEST_FULL}" @@ -71,12 +79,18 @@ done unset 'PRUNE_EXPR[${#PRUNE_EXPR[@]}-1]' # Export for Perl -export PACKAGE PASCAL DEST_USER DEST_FULL SOURCE_PACKAGE SOURCE_PASCAL SOURCE_USER SOURCE_FULL SOURCE_EMAIL DEST_EMAIL SOURCE_WEBSITE DEST_WEBSITE +export PACKAGE PASCAL DEST_USER DEST_FULL SOURCE_PACKAGE SOURCE_PASCAL SOURCE_USER SOURCE_FULL SOURCE_EMAIL DEST_EMAIL SOURCE_WEBSITE DEST_WEBSITE SOURCE_APPNAME APPNAME # Iterate files safely (null-delimited), skip binaries, replace in place with perl while IFS= read -r -d '' file; do [[ -f "$file" ]] || continue + # Skip this script itself + FILE_ABS="$(abs_path "$file")" + if [[ "$FILE_ABS" == "$SCRIPT_ABS" ]]; then + continue + fi + # Skip binary files if ! LC_ALL=C grep -Iq . "$file"; then continue @@ -87,6 +101,7 @@ while IFS= read -r -d '' file; do perl -0777 -i.bak -pe ' BEGIN { $src_k = $ENV{SOURCE_PACKAGE}; + $src_a = $ENV{SOURCE_APPNAME}; $src_p = $ENV{SOURCE_PASCAL}; $src_u = $ENV{SOURCE_USER}; $src_f = $ENV{SOURCE_FULL}; @@ -94,6 +109,7 @@ while IFS= read -r -d '' file; do $src_w = $ENV{SOURCE_WEBSITE}; $dst_k = $ENV{PACKAGE}; + $dst_a = $ENV{APPNAME}; $dst_p = $ENV{PASCAL}; $dst_u = $ENV{DEST_USER}; $dst_f = $ENV{DEST_FULL}; @@ -101,6 +117,7 @@ while IFS= read -r -d '' file; do $dst_w = $ENV{DEST_WEBSITE}; } s/\Q$src_k\E/$dst_k/g; + s/\Q$src_a\E/$dst_a/g; s/\Q$src_p\E/$dst_p/g; s/\Q$src_u\E/$dst_u/g; s/\Q$src_f\E/$dst_f/g;