-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmkplugin
executable file
·100 lines (84 loc) · 2.04 KB
/
mkplugin
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
94
95
96
97
98
99
100
#!/bin/sh
text=""
read_option() {
exp=""
if [ "$2" != "" ]
then
exp=" ($2)"
fi
echo -n "$1$exp: "
read text
if [ "$text" = "" ]
then
text="$2"
fi
}
echo "Welcome to Nelio Plugin Boilerplate."
echo "Let's create your new plugin!"
name=""
dir=""
prefix=""
ok="n"
verbose="y"
while [ "$ok" = "n" ]
do
echo ""
echo "Plugin Information"
# ===================================================
read_option " Plugin Name" "$name"
name=$text
read_option " Current Version" "$version"
version=$text
read_option " Plugin Dir" "$dir"
dir=$text
read_option " Class Prefix" "$prefix"
prefix=$text
echo "Author Information"
# ===================================================
read_option " Author Name" "$author"
author=$text
read_option " Author E-Mail" "$email"
email=$text
echo ""
echo "Please, check the information your provided:"
echo ""
echo " Plugin Name: $name"
echo " Version: $version"
echo " Plugin Dir: $dir"
echo " Class Prefix: $prefix"
echo ""
echo " Author: $author <$email>"
echo ""
echo -n "Is everything OK? (Y/n) "
read ok
done
echo ""
# Prepare some variables
domain=`echo "$prefix" | tr "[:upper:]" "[:lower:]"`
constant=`echo "$prefix" | tr "[:lower:]" "[:upper:]"`
slug=`echo "$domain" | sed -e "s/_/-/"`
# Create the new plugin
cp -r "plugin-name" "$dir"
# Rename all files
mv "$dir/plugin-name.php" "$dir/${slug}.php" 2>/dev/null
find $dir -type "f" | while read file
do
dest=`echo "$file" | sed -e "s/plugin-name/$slug/"`
mv "$file" "$dest" 2>/dev/null
done
# Make the appropriate changes in the contents
find $dir -type "f" | while read file
do
cat "$file" | \
sed -e "s/0.0.0/$version/g" | \
sed -e "s/Plugin Name/$name/g" | \
sed -e "s/* $name:/* Plugin Name:/g" | \
sed -e "s/Plugin_Name/$prefix/g" | \
sed -e "s/PLUGIN_NAME/$constant/g" | \
sed -e "s/plugin_name/$domain/g" | \
sed -e "s/pn_var/plugin_name/g" | \
sed -e "s/plugin-name/$slug/g" | \
sed -e "s/Your Name/$author/g" | \
sed -e "s/[email protected]/$email/g" > "$dir/aux"
mv "$dir/aux" "$file"
done