Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compare html bodys for different pages for Now and Beyond. Requires `yarn start` to be running with shops for `fatty` and `skinny`.
#!/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