-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·119 lines (99 loc) · 2.96 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# extension.json template
EXT_CONFIG_TPL='{
"module": "%s",
"name": "%s",
"description": "%s",
"author": {
"name": "%s",
"email": "%s"
},
"repository": "%s",
"acceptableVersions": [
">=7.0.0"
],
"php": [
">=7.3"
]
}
'
EXT_COMPOSER_TPL='{
"name": "%s",
"description": "%s",
"authors": [
{
"name": "%s",
"email": "%s"
}
],
"require": {},
"autoload": {
"psr-4": {
"Espo\\\\Modules\\\\%s": "app/"
}
}
}
'
EXT_PACKAGE_TPL='{
"name": "%s",
"description": "%s",
"author": {
"name": "%s",
"email": "%s"
}
}
'
EXT_AUTOLOAD_TPL='{
"autoloadFileList": [
"application/Espo/Modules/%s/vendor/autoload.php"
]
}
'
echo "=> EspoCRM extension template initialization <="
echo ""
# read extension config
echo "=> Please provide the following information: "
read -p "=> Extension Name (eg: Awesome Extension): " extName
if [[ "$extName" == "" ]]; then
echo "ERROR: please provide extension name!"
exit
fi
read -p "=> Extension Module Name (eg: AwesomeExtension): " extModuleName
if [[ "$extModuleName" == "" ]]; then
echo "ERROR: please provide module name!"
exit
fi
extModuleNameHyphen=$(sed --expression 's/\([A-Z]\)/-\L\1/g' --expression 's/^-//' <<< "$extModuleName")
read -p "=> Extension Description: " extDescription
read -p "=> Extension Author Name (eg: SuperEwald) [git.user.name]: " extAuthorName
if [[ "$extAuthorName" == "" ]]; then
extAuthorName=$(git config --global user.name)
fi
read -p "=> Extension Author Email [git.user.email]: " extAuthorEmail
if [[ "$extAuthorEmail" == "" ]]; then
extAuthorEmail=$(git config --global user.email)
fi
read -p "=> Extension Git Repository: " extRepository
printf -v EXT_CONFIG_CONF "$EXT_CONFIG_TPL" "$extModuleName" "$extName" "$extDescription" "$extAuthorName" "$extAuthorEmail" "$extRepository"
printf -v EXT_COMPOSER_CONF "$EXT_COMPOSER_TPL" "$extAuthorName/$extModuleNameHyphen" "$extDescription" "$extAuthorName" "$extAuthorEmail" "$extModuleName"
printf -v EXT_PACKAGE_CONF "$EXT_PACKAGE_TPL" "$extAuthorName/$extModuleNameHyphen" "$extDescription" "$extAuthorName" "$extAuthorEmail"
printf -v EXT_AUTOLOAD_CONF "$EXT_AUTOLOAD_TPL" "$extModuleName"
echo ""
echo "Writing infos to extension.json, package.json and composer.json"
echo "$EXT_PACKAGE_CONF" > package.json
echo "$EXT_CONFIG_CONF" > extension.json
echo "$EXT_COMPOSER_CONF" > composer.json
mkdir -p app/Resources
echo "$EXT_AUTOLOAD_CONF" > app/Resources/autoload.json
echo ""
echo "Update git remotes"
currentOrigin=$(git config --get remote.origin.url)
if [[ "$currentOrigin" == *"superewald/espo-ext-template"* ]]; then
git remote rename origin upstream
git remote add origin "$extRepository"
rm ./init.sh ./Readme.md
git add .
git commit -m "initial commit"
fi
echo ""
echo "Extension template was initialized and is ready to be built!"