Last active
May 2, 2025 23:00
-
-
Save melaniekung/40cff723748a3e470591c5b8e160536b to your computer and use it in GitHub Desktop.
arB5Plugin.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script should be run on a new dev branch for B5 Plugin | |
# NOTE: Make sure to uncomment the right version of sed commands | |
# This script does the following: | |
# - Clones empty B5 plugin template | |
# - Updates the plugin config's summary | |
# - Creates empty _custom.scss and _variables.scss files | |
# - Copies header, footer, and homepage templates (unless excluded by flags) | |
# Ensure client name is provided | |
if [ -z "$1" ]; then | |
echo "Client name is required." | |
exit 1 | |
fi | |
# Client name | |
CLIENT=$1 | |
# Check client name | |
if [[ "$1" == ar*B5Plugin ]]; then | |
# Remove prefix 'ar' | |
CLIENT="${1#ar}" | |
# Remove suffix 'B5Plugin' | |
CLIENT="${CLIENT%B5Plugin}" | |
echo "Stripped value: $CLIENT" | |
fi | |
plugin="ar${CLIENT}B5Plugin" | |
# Clone empty B5 plugin branch and remove git files | |
git clone --depth=1 [email protected]:software-development/arB5ThemePlugin.git plugins/ar${CLIENT}B5Plugin | |
rm -rf plugins/ar${CLIENT}B5Plugin/.git plugins/ar${CLIENT}B5Plugin/README.md | |
# Rename config file and reset $summary | |
mv plugins/ar${CLIENT}B5Plugin/config/arB5PluginConfiguration.class.php plugins/ar${CLIENT}B5Plugin/config/ar${CLIENT}B5PluginConfiguration.class.php | |
CONF_FILE="plugins/ar${CLIENT}B5Plugin/config/ar${CLIENT}B5PluginConfiguration.class.php" | |
# For MacOS | |
sed -i '' "s|class arB5PluginConfiguration extends arDominionB5PluginConfiguration|class ar${CLIENT}B5PluginConfiguration extends arDominionB5PluginConfiguration|" "$CONF_FILE" | |
## For Linux | |
## sed -i "s|class arB5PluginConfiguration extends arDominionB5PluginConfiguration|class ar${CLIENT}B5PluginConfiguration extends arDominionB5PluginConfiguration|" "$CONF_FILE" | |
# For MacOS | |
sed -i '' "s|public static \$summary = 'B5 theme plugin skeleton, extension of arDominionB5Plugin without modifications.';|public static \$summary = 'B5 theme plugin, extension of arDominionB5Plugin.';|" "$CONF_FILE" | |
## For Linux | |
## sed -i "s|public static \$summary = 'B5 theme plugin skeleton, extension of arDominionB5Plugin without modifications.';|public static \$summary = 'B5 theme plugin, extension of arDominionB5Plugin.';|" "$CONF_FILE" | |
# Create _custom.scss and _variables.scss files and add to main.scss | |
touch plugins/ar${CLIENT}B5Plugin/scss/_variables.scss | |
ls plugins/ar${CLIENT}B5Plugin/scss/_variables.scss | |
touch plugins/ar${CLIENT}B5Plugin/scss/_custom.scss | |
ls plugins/ar${CLIENT}B5Plugin/scss/_custom.scss | |
# For MacOS | |
sed -i '' '12i\ | |
@import "variables";\ | |
@import "custom";' plugins/ar${CLIENT}B5Plugin/scss/main.scss | |
## For Linux | |
## sed -i '12i\ | |
## @import "variables";\ | |
## @import "custom";' plugins/ar${CLIENT}B5Plugin/scss/main.scss | |
# Copy header, footer, homepage templates from arDominionB5Plugin | |
# NOTE: flags are used to EXCLUDE files | |
header=true | |
footer=true | |
homepage=true | |
if [[ $# -gt 1 ]]; then | |
case "$2" in | |
-hd|--header) | |
header=false | |
shift | |
;; | |
-f|--footer) | |
footer=false | |
shift | |
;; | |
-hp|--homepage) | |
homepage=false | |
shift | |
;; | |
*) | |
echo "Unknown option: $1" | |
exit 1 | |
;; | |
esac | |
fi | |
if [ "$header" = true ]; then | |
cp plugins/arDominionB5Plugin/templates/_header.php plugins/ar${CLIENT}B5Plugin/templates/ | |
ls plugins/ar${CLIENT}B5Plugin/templates/_header.php | |
fi | |
if [ "$footer" = true ]; then | |
cp apps/qubit/templates/_footer.php plugins/ar${CLIENT}B5Plugin/templates/_footer.php | |
ls plugins/ar${CLIENT}B5Plugin/templates/_footer.php | |
fi | |
if [ "$homepage" = true ]; then | |
mkdir -p plugins/ar${CLIENT}B5Plugin/modules/staticpage/templates | |
cp plugins/arDominionB5Plugin/modules/staticpage/templates/homeSuccess.php plugins/ar${CLIENT}B5Plugin/modules/staticpage/templates/ | |
ls plugins/ar${CLIENT}B5Plugin/modules/staticpage/templates/homeSuccess.php | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment