-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We are accumulating quite a lot of build scripts that are all written in bash, and need to be implemented in a just-so order, and you need to know exactly when you need to run them. It might be time to start looking into moving to an actual tool to manage the build for us. These come in a lot of flavors with various capabilities. I've looked around a bunch, and I think [DoIt](https://pydoit.org) looks quite nice. Here are the features that I think make this tool quite nice: - It's written in Python, so comes in automatically as Python dependency during `pip install`. - The configuration file is written in Python as well, so we don't have to learn a new configuration language just for this tool. - Tasks have dependencies between them, so if there are multiple that need to run, they automatically run in the right order. - Tasks can (optionally) declare files that are inputs to the task itself, and if the input files have not changed the task is skipped. This makes it safe to just run the build toold and trust that you're not waiting too long for nothing. I've started converting some build scripts over to this new tool to show how it works. You can see it in action by going into the virtual env and running (must be in the root directory, unfortunately): ``` $ doit $ doit run typescript $ doit help ``` The `.doit.db.db` that I've ignored is a file it uses internally to track changes to dependencies. I've paused here because I'd like to solicit feedback. Does the tool look okay? Is this understandable? Do we prefer this to bash, or to other build tools?
- Loading branch information
Showing
22 changed files
with
77,086 additions
and
874 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,3 +177,6 @@ grammars-Total/*.lark | |
|
||
# hedy test cache | ||
.test-cache | ||
|
||
.doit.db | ||
.doit.db.* |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,6 @@ | ||
#!/bin/bash | ||
set -eu | ||
# Recompile the TypeScript and generate a minified JavaScript bundle using esbuild. | ||
# | ||
# We commit the generated JavaScript bundle to minimize the burden on contributors-- | ||
# they don't need to install any of the NPM/esbuild tools and remember to run build | ||
# scripts if they don't need to work on the browser code. | ||
# | ||
# We minimize the generated bundle so that contributors aren't tempted to accidentally | ||
# edit straight in the JavaScript. | ||
# | ||
#---------------------------------------------------------------------- | ||
# | ||
# This script does two similar, but different jobs: | ||
# | ||
# In normal build mode, we first compile TypeScript -> JavaScript using the | ||
# TypeScript compiler (TSC), and then bundle it all into one file using esbuild. | ||
# The reason we do this is because TSC can translate certain desirable idioms | ||
# that are are not supposed in old browsers, like `async`, `?.` and `??` to | ||
# plain old JavaScript. `esbuild` does not do that, which is why have TSC do | ||
# this job first. | ||
# | ||
# We can also run in `--watch` mode, in which case we bypass the TypeScript | ||
# compiler and only run esbuild. This is because the TypeScript compiler is | ||
# rather slow (think 5-10 seconds to do a compilation), and we want to | ||
# optimize for iteration speed in that case. That does mean that the generated | ||
# JavaScript is slightly different between those cases--however, the final | ||
# JavaScript will always be generated on deploy using the official generation | ||
# method. | ||
root=$(cd $(dirname $0)/../.. && pwd) | ||
|
||
cd $root | ||
|
||
python3 highlighting/generate-rules-highlighting.py | ||
python3 build-tools/heroku/generate-client-messages.py | ||
|
||
if [[ ! -f node_modules/.bin/tsc ]]; then | ||
echo "👉 You need to run the following command ONCE before running 'generate-typescript':" >&2 | ||
echo "" >&2 | ||
echo " npm ci" >&2 | ||
echo "" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [[ "${1:-}" == "--watch" ]]; then | ||
echo "👀 Running TypeScript compilation in watch mode. 👀" | ||
echo "Leave this window open and edit (and save) .ts files to your heart's content." | ||
echo "" | ||
# Watch mode, just use esbuild and nothing else | ||
npx esbuild static/js/index.ts \ | ||
--watch \ | ||
--bundle \ | ||
--sourcemap \ | ||
--minify \ | ||
--target=es2017 \ | ||
--global-name=hedyApp \ | ||
--platform=browser \ | ||
--outfile=static/js/appbundle.js | ||
elif [[ "${1:-}" == "--tests" ]]; then | ||
echo "Generating .js bundle files" | ||
npx esbuild static/js/index.ts \ | ||
--bundle \ | ||
--sourcemap \ | ||
--minify \ | ||
--target=es2017 \ | ||
--global-name=hedyApp \ | ||
--platform=browser \ | ||
--outfile=static/js/appbundle.js | ||
else | ||
# Use tsc to generate .js | ||
npx tsc --outDir __tmp__ | ||
|
||
npx esbuild static/js/index.ts \ | ||
--bundle \ | ||
--sourcemap \ | ||
--minify \ | ||
--target=es2017 \ | ||
--global-name=hedyApp \ | ||
--platform=browser \ | ||
--outfile=static/js/appbundle.js "$@" | ||
|
||
rm -rf __tmp__ | ||
fi | ||
echo "🦄 This command has been replaced! To compile TypeScript, type the following": | ||
echo "" | ||
echo " doit run typescript" | ||
exit 1 |
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.