Files
blockly/tests/scripts/update_metadata.sh
Christopher Allen 4d150ff8d7 feat(tests): Write Closure Compiler output directly to dist/
Since they are already UMD-wrapped, have Closure Compiler write
output chunks directly to RELEASE_DIR, i.e. dist/.
2022-10-03 17:29:30 +01:00

45 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Determines the size of generated files and updates check_metadata.sh to
# reflect the new values.
# Location of the pre-built compressed files.
#
# (TODO(#5007): Should fetch this from scripts/gulpfiles/config.js
# instead of hardcoding it here.
readonly RELEASE_DIR='dist'
gzip -k "${RELEASE_DIR}/blockly_compressed.js"
gzip -k "${RELEASE_DIR}/blocks_compressed.js"
blockly_size=$(wc -c < "${RELEASE_DIR}/blockly_compressed.js")
blocks_size=$(wc -c < "${RELEASE_DIR}/blocks_compressed.js")
blockly_gz_size=$(wc -c < "${RELEASE_DIR}/blockly_compressed.js.gz")
blocks_gz_size=$(wc -c < "${RELEASE_DIR}/blocks_compressed.js.gz")
quarters=(1 1 1 2 2 2 3 3 3 4 4 4)
month=$(date +%-m)
quarter=$(echo Q${quarters[$month - 1]} $(date +%Y))
version=$(npx -c 'echo "$npm_package_version"')
replacement="# ${quarter}\t${version}\t${blockly_size}\n"
replacement+="readonly BLOCKLY_SIZE_EXPECTED=${blockly_size}"
sed -ri.bak "s/readonly BLOCKLY_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh
replacement="# ${quarter}\t${version}\t${blocks_size}\n"
replacement+="readonly BLOCKS_SIZE_EXPECTED=${blocks_size}"
sed -ri.bak "s/readonly BLOCKS_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh
replacement="# ${quarter}\t${version}\t${blockly_gz_size}\n"
replacement+="readonly BLOCKLY_GZ_SIZE_EXPECTED=${blockly_gz_size}"
sed -ri.bak "s/readonly BLOCKLY_GZ_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh
replacement="# ${quarter}\t${version}\t${blocks_gz_size}\n"
replacement+="readonly BLOCKS_GZ_SIZE_EXPECTED=${blocks_gz_size}"
sed -ri.bak "s/readonly BLOCKS_GZ_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh
rm tests/scripts/check_metadata.sh.bak