Created
June 9, 2020 14:07
-
-
Save JonathanWbn/eb81eb06c01d2d2e9f85fbd357e2f589 to your computer and use it in GitHub Desktop.
Compare html bodys for different pages for Now and Beyond. Requires `yarn start` to be running with shops for `fatty` and `skinny`.
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 | |
if [[ $# -eq 0 ]] ; then | |
echo 'No branchname provided.' | |
exit 0 | |
fi | |
# te | |
themes=( editorial limelight neutral spotlight structure uptown vision ) | |
fattyPages=( search l/contact i/about-us c/category cart unknown ) | |
skinnyPages=( search l/contact i/about-us cart unknown ) | |
baseUrl=http://localhost:7000 | |
initialBranch=`git rev-parse --abbrev-ref HEAD` | |
initialBranchPath="${initialBranch/\//-}" | |
currentBranch=$initialBranch | |
currentBranchPath="${currentBranch/\//-}" | |
for theme in "${themes[@]}"; do | |
mkdir -p ./compare/$currentBranchPath/$theme | |
themeParams=ViewAction=UnityMBO-ViewSFThemePreview\&previewTheme=epages.$theme@dev | |
for page in "${fattyPages[@]}"; do | |
# remove slashes from page to use as path | |
pagePath="${page/\//-}" | |
curl -s $baseUrl/$page\?shop=fatty\&$themeParams > ./compare/$currentBranchPath/$theme/$pagePath.html | |
done | |
for page in "${skinnyPages[@]}"; do | |
# remove slashes from page to use as path | |
pagePath="${page/\//-}" | |
curl -s $baseUrl/$page\?shop=skinny\&$themeParams > ./compare/$currentBranchPath/$theme/$pagePath.html | |
done | |
done | |
git checkout $1 | |
currentBranch=`git rev-parse --abbrev-ref HEAD` | |
currentBranchPath="${currentBranch/\//-}" | |
sleep 5 | |
for theme in "${themes[@]}"; do | |
mkdir -p ./compare/$currentBranchPath/$theme | |
themeParams=ViewAction=UnityMBO-ViewSFThemePreview\&previewTheme=epages.$theme@dev | |
for page in "${fattyPages[@]}"; do | |
# remove slashes from page to use as path | |
pagePath="${page/\//-}" | |
curl -s $baseUrl/$page\?shop=fatty\&$themeParams > ./compare/$currentBranchPath/$theme/$pagePath.html | |
done | |
for page in "${skinnyPages[@]}"; do | |
# remove slashes from page to use as path | |
pagePath="${page/\//-}" | |
curl -s $baseUrl/$page\?shop=skinny\&$themeParams > ./compare/$currentBranchPath/$theme/$pagePath.html | |
done | |
done | |
cd ./compare/$currentBranchPath | |
for theme in "${themes[@]}"; do | |
for file in $theme/*; do | |
# compare files after clearing out the script tag line, whiespaces and empty comments | |
diff --brief \ | |
<(sed -n "/<div id=\"app\">/,/<script nonce/p" $file | sed '$d' | tr -d '[:space:]' | sed 's/<!---->//g') \ | |
<(sed -n "/<div id=\"app\">/,/<script nonce/p" ../$initialBranchPath/$file | sed '$d' | tr -d '[:space:]' | sed 's/<!---->//g') | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment