Files
blockly/tests/scripts/update_metadata.sh
Christopher Allen 307ff71c21 refactor(build): Preparation for building TypeScript (#6205)
* chore(deps): Update closure/goog/base.js, add goog.js

  - Update base.js from the latest version (20220502.0.0).
  - Also copy over goog.js, which provides access to a suitable subset
    of goog.* via an importable module).

* chore(build): Split gulpfiles/config.js exports object

  This makes it possible for entries to depend on each other.

* chore(build): build config consistency

  - Reorder entries in gulpfiles.config.js to better match order they
    are used.
  - Have update_metadata.sh reference config.js and vice versa.

* refactor(build): Move deps.js (+ deps.mocha.js) from test/ to build/

  Once we start using tsc, deps.js will be created based on the ouptut
  of tsc rather than the raw source in core/.  Since tsc will need to
  be run before running closure-make-deps and also before trying to
  load blockly_uncompressed.js, it doesn't really make sense to check
  in deps.js; it's better to re-create as needed.

  To reduce inconvenience, a new "prepare" script is added to
  package.json which will run the buildDeps gulp target automaticaly
  when one runs npm install.

* refactor(build): Always build from TypeScript sources

  - Add buildJavaScript gulp task to use tsc to compile any .ts files
    in core/ into build/src/core/ (and also copy any .js files that
    are not yet migrated to TypeScript, which for now is all of them.
  - Remove closure/goog from explicit inputs to tsc; it will find
    the files it needs (e.g., goog.js) automatically.
  - Have buildDeps, the playground, and all the tests that run in
    uncompiled mode use build/src/core/ instead of core/ as their
    input directory.

* feat(build): Add buildJavaScriptAndDeps gulp task

  Have npm run build:deps (and npm run prepare) use a new gulp task,
  buildJavaScriptAndDeps, to run tsc followed by closure-make-deps,
  ensuring that deps.js is calculated based on the most recent code
  in core/.

* fix(build): Fix implementation of flattenCorePaths

  Even though this function is going away I want to remove it in
  a separate PR so that we can revert easily if desired.  But the
  previous checked-in code was totally wrong.  This version works.

* fix(build): Don't let checkinBuilt copy build/src/**

  Now that we are putting a lot more stuff in build/ (specifically,
  all the tsc output in build/src/), modify checkinBuilt so that it
  only copies the specific things we want to check in (for now):

  - _compressed.js build artifacts and their accompanying .js.maps
  - the generated build/msg/js/*.js language files.

  Unrelatedly, also fix safety-quoting of arguments for one execSync
  call.
2022-06-14 22:20:42 +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 BUILD_DIR='build'
gzip -k "${BUILD_DIR}/blockly_compressed.js"
gzip -k "${BUILD_DIR}/blocks_compressed.js"
blockly_size=$(wc -c < "${BUILD_DIR}/blockly_compressed.js")
blocks_size=$(wc -c < "${BUILD_DIR}/blocks_compressed.js")
blockly_gz_size=$(wc -c < "${BUILD_DIR}/blockly_compressed.js.gz")
blocks_gz_size=$(wc -c < "${BUILD_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