docs.sheetjs.com/tests/contributing/darwin.sh

75 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# https://docs.sheetjs.com/docs/miscellany/contributing
SHEETJS_VERSION="0.20.3"
OS="$(uname -s)"
case "$OS" in
Darwin) ;;
*) echo "unsupported OS: $OS"; exit 1 ;;
esac
cd /tmp
git --version || { echo "Git not found. Please install Xcode command-line tools."; exit 1; }
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
if ! command -v nvm &> /dev/null; then curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash; fi
if ! command -v node &> /dev/null; then nvm install --lts; fi
nvm use --lts
node --version
if [ ! -e sheetjs ]; then
if ! git clone https://git.sheetjs.com/sheetjs/sheetjs 2>&1; then
git config --global http.sslVerify false
git clone https://git.sheetjs.com/sheetjs/sheetjs 2>&1
git config --global http.sslVerify true
fi
fi
cd sheetjs
npm i
npm i -g mocha@2.5.3 voc @sheetjs/uglify-js || sudo npm i -g mocha@2.5.3 voc @sheetjs/uglify-js
rmdir test_files 2>/dev/null || rm -rf test_files
curl -LO https://test-files.sheetjs.com/test_files.zip
unzip -q test_files.zip
mkdir -p tmp
npx -y esbuild@0.14.14 --version
cd modules; make clean; make; cd ..
make
make dist
make test_misc
for file in dist/xlsx.full.min.js xlsx.js xlsx.mjs; do
if ! stat "$file" > /dev/null 2>&1; then echo "ERROR: $file not found"; exit 1; fi
done
git checkout -- .
COMMIT_HASH=$(git log | grep -B4 "version bump $SHEETJS_VERSION" | head -1 | awk '{print $2}')
if [ -z "$COMMIT_HASH" ]; then echo "ERROR: Could not find commit for version $SHEETJS_VERSION"; exit 1; fi
echo "Version $SHEETJS_VERSION : Commit $COMMIT_HASH"
git checkout "$COMMIT_HASH"
make clean; make
cd modules; make clean; make; cd ..
make
make dist
LOCAL_MD5=$(md5 dist/xlsx.full.min.js | awk '{print $4}')
CDN_MD5=$(curl -k -L "https://cdn.sheetjs.com/xlsx-$SHEETJS_VERSION/package/dist/xlsx.full.min.js" | md5)
echo "Local MD5: $LOCAL_MD5"
echo "CDN MD5: $CDN_MD5"
if [ "$LOCAL_MD5" != "$CDN_MD5" ]; then echo "ERROR: MD5 checksums do not match!"; exit 1; fi
git checkout master