| 1 | #!/bin/bash |
| 2 | # This script generates the bundled JS files and pushes all content to a web site using rsync. |
| 3 | |
| 4 | if [ "$1" == "" ] ; then |
| 5 | echo "usage: $0 destination" |
| 6 | exit 1 |
| 7 | fi |
| 8 | |
| 9 | set -x |
| 10 | set -o errexit |
| 11 | site=$1 |
| 12 | |
| 13 | # Produce dist/*.js |
| 14 | npm run build |
| 15 | |
| 16 | # Generate documentation. |
| 17 | ./scripts/generate-documentation.py > docs/options.html |
| 18 | chmod a+r docs/options.html |
| 19 | if [ -s docs/options.html ] ; then |
| 20 | ./scripts/generate-jsdoc.sh |
| 21 | ./scripts/generate-download.py > docs/download.html |
| 22 | |
| 23 | temp_dir=$(mktemp -d /tmp/dygraphs-docs.XXXX) |
| 24 | cd docs |
| 25 | ./ssi_expander.py $temp_dir |
| 26 | cd .. |
| 27 | |
| 28 | # Make sure everything will be readable on the web. |
| 29 | # This is like "chmod -R a+rX", but excludes the .git and node_modules directories. |
| 30 | find . -print | egrep -v '\.git|node_modules' | xargs chmod a+rX |
| 31 | |
| 32 | # Copy everything to the site. |
| 33 | rsync -avzr src src/extras gallery common tests jsdoc dist $site \ |
| 34 | && \ |
| 35 | rsync -avzr --copy-links dist/* thumbnail.png screenshot.png $temp_dir/* $site/ |
| 36 | else |
| 37 | echo "generate-documentation.py failed" |
| 38 | fi |
| 39 | |
| 40 | # Revert changes to docs. |
| 41 | git checkout docs/download.html |
| 42 | rm docs/options.html |
| 43 | rm -rf $temp_dir |