2022-08-12 12:45:02 +03:00
#!/usr/bin/env bash
2021-06-06 02:02:22 +03:00
2022-10-17 18:40:35 +03:00
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
2021-06-06 02:38:07 +03:00
set -euxo pipefail
2021-06-06 05:20:32 +03:00
# cd into the directory where this script lives.
# This allows us to run this script from the root project directory,
# which is what Netlify wants to do.
SCRIPT_RELATIVE_DIR = $( dirname " ${ BASH_SOURCE [0] } " )
cd $SCRIPT_RELATIVE_DIR
2021-06-06 02:02:22 +03:00
rm -rf build/
cp -r public/ build/
2021-06-06 02:38:07 +03:00
2022-03-02 11:40:13 +03:00
# grab the source code and copy it to Netlify's server; if it's not there, fail the build.
2022-05-09 22:55:21 +03:00
pushd build
2022-08-12 22:27:23 +03:00
wget https://github.com/roc-lang/roc/archive/www.tar.gz
2022-06-26 18:11:53 +03:00
# Download the latest pre-built Web REPL as a zip file. (Build takes longer than Netlify's timeout.)
2022-08-24 23:54:51 +03:00
REPL_TARFILE = "roc_repl_wasm.tar.gz"
wget https://github.com/roc-lang/roc/releases/download/nightly/$REPL_TARFILE
tar -xzf $REPL_TARFILE -C repl
rm $REPL_TARFILE
ls -lh repl
2022-06-26 18:11:53 +03:00
2022-03-03 02:34:47 +03:00
popd
2022-05-01 22:30:46 +03:00
pushd ..
2022-09-04 03:35:28 +03:00
echo 'Generating builtin docs...'
2022-05-01 22:30:46 +03:00
cargo --version
rustc --version
# We set ROC_DOCS_ROOT_DIR=builtins so that links will be generated relative to
# "/builtins/" rather than "/" - which is what we want based on how the server
# is set up to serve them.
2022-05-03 03:14:48 +03:00
export ROC_DOCS_URL_ROOT = /builtins
2022-05-01 22:30:46 +03:00
2022-07-02 15:46:57 +03:00
cargo run --bin roc-docs crates/compiler/builtins/roc/*.roc
2022-05-03 03:14:48 +03:00
mv generated-docs/*.* www/build # move all the .js, .css, etc. files to build/
mv generated-docs/ www/build/builtins # move all the folders to build/builtins/
2022-05-09 22:55:21 +03:00
2022-10-24 00:42:54 +03:00
# Manually add this tip to all the builtin docs.
2022-11-11 20:24:19 +03:00
find www/build/builtins -type f -name 'index.html' -exec sed -i 's!</nav>!<div class="builtins-tip"><b>Tip:</b> <a href="/different-names">Some names</a> differ from other languages.</div></nav>!' { } \;
2022-10-24 00:42:54 +03:00
2022-09-04 03:35:28 +03:00
echo 'Generating CLI example platform docs...'
# Change ROC_DOCS_ROOT_DIR=builtins so that links will be generated relative to
# "/examples/cli/" rather than "/builtins/"
export ROC_DOCS_URL_ROOT = /examples/cli
# Until https://github.com/roc-lang/roc/issues/3280 is done,
# manually exclude the Internal* modules and `main.roc`.
2022-09-12 06:52:48 +03:00
ls examples/cli/cli-platform/*.roc | grep -v Internal | grep -v main.roc | grep -v Effect.roc | xargs cargo run --bin roc-docs
2022-09-04 03:35:28 +03:00
mkdir www/build/examples
rm generated-docs/*.* # we already copied over the *.js and *.css files earlier, so just drop these.
mv generated-docs/ www/build/examples/cli # move all the folders to build/examples/cli
2022-05-01 22:30:46 +03:00
popd