This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·71 lines (56 loc) · 1.88 KB
/
init.sh
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
#!/bin/bash
shopt -s globstar
# Check script options
if [[ "$#" -lt 1 ]]; then
echo "Usage: ./init.sh MyAddonName [folder]"
exit 1
fi
if [[ $(echo "$1" | head -c 1) == "-" ]]; then
echo "Usage: ./init.sh MyAddonName [folder]"
exit 1
fi
# Check script necessary tools : sed, perl, perl-rename
PERL=$(command -v perl)
if [[ ! -x "$PERL" ]] ; then
echo "Install perl"
exit 1
fi
RENAME=$(command -v perl-rename)
if [[ ! -x "$RENAME" ]] ; then
RENAME=$(command -v rename)
fi
RENAME_KIND=$($RENAME --help | grep -i PERLEXPR)
if [[ "$RENAME_KIND" == "" ]]; then
echo "Install perl-rename (sometimes called just 'rename')"
exit 1
fi
SED=/usr/bin/sed
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! [[ -x "$(command -v gsed)" ]]; then
echo "Install gnu-sed"
exit 1
fi
SED=/usr/bin/gsed
fi
ADDON="$1"
ADDON_LC=$(echo $ADDON | $PERL -ne 'print lc')
ADDON_LC_DASHES=$(echo $ADDON_LC | sed 's/_/-/g')
ADDON_DIR="$PWD"
if [[ "x$2" != "x" ]]; then
TARGET_FOLDER="$2"
mkdir -p "$TARGET_FOLDER"
cp -rf * "$TARGET_FOLDER/"
cd "$TARGET_FOLDER"
else
TARGET_FOLDER="$PWD"
fi
mv "MyAudioEffect" "$ADDON"
$RENAME "s/my_audio_effect/$ADDON_LC/" **/*.{hpp,cpp,txt}
$RENAME "s/MyAudioEffect/$ADDON/" **/*.{hpp,cpp,txt}
$SED -i "s/my_audio_effect/$ADDON_LC/g" **/*.{hpp,cpp,txt}
$SED -i "s/MyAudioEffect/$ADDON/g" **/*.{hpp,cpp,txt} release.sh
$SED -i "s/my-audio-effect/$ADDON_LC_DASHES/g" **/*.{hpp,cpp,txt} release.sh
echo -e "# $ADDON\nA new and wonderful [ossia score](https://ossia.io) add-on" > README.md
find . -name '*.hpp' -exec $PERL -pi -e 'chomp(my $uidgen = `uuidgen`);s|00000000-0000-0000-0000-000000000000|$uidgen|gi' {} \;
find . -name '*.cpp' -exec $PERL -pi -e 'chomp(my $uidgen = `uuidgen`);s|00000000-0000-0000-0000-000000000000|$uidgen|gi' {} \;
find . -name '*.json' -exec $PERL -pi -e 'chomp(my $uidgen = `uuidgen`);s|00000000-0000-0000-0000-000000000000|$uidgen|gi' {} \;