# download assets
download:
    #!/usr/bin/env bash
    set -euxo pipefail

    # Bootstrap Datepicker Styles
    curl -fsSLo datepicker.zip https://github.com/uxsolutions/bootstrap-datepicker/releases/download/v1.6.4/bootstrap-datepicker-1.6.4-dist.zip
    unzip -p datepicker.zip css/bootstrap-datepicker.standalone.min.css \
        > bootstrap-datepicker.standalone.min.css

    # Shiny Server Client
    SSCLIENT_VERSION=1.2.0
    curl -fsSLo shiny-server-client.zip "https://github.com/rstudio/shiny-server-client/archive/v${SSCLIENT_VERSION}.zip"
    unzip -p shiny-server-client.zip "shiny-server-client-${SSCLIENT_VERSION}/dist/shiny-server-client.min.js" \
        > shiny-server-client.min.js

    # SockJS
    # Commented out until https://github.com/sockjs/sockjs-client/issues/563 is resolved.

    # NOTE: The ui/dashboard sockjs-client dependency needs to be kept in sync
    # with the assets/sockjs.min.js because that is the JS served by the
    # SockJsApiFilter for iframe requests.
    # https://github.com/rstudio/connect/issues/20365
    
    # SOCKJS_VERSION=1.5.2
    # curl -fsSLo sockjs.tar.gz "https://github.com/sockjs/sockjs-client/archive/v${SOCKJS_VERSION}.tar.gz"
    # tar --to-stdout --extract --gzip -f sockjs.tar.gz "sockjs-client-${SOCKJS_VERSION}/dist/sockjs.min.js" > sockjs.min.js
    # tar --to-stdout --extract --gzip -f sockjs.tar.gz "sockjs-client-${SOCKJS_VERSION}/dist/sockjs.min.js.map" > sockjs.min.js.map

    cat <<-EOF

    ****************************************
    SockJS needs to be manually installed from the branch:
      https://github.com/jcheng5/sockjs-client/tree/patch-1
    
    Resolves:
      https://github.com/sockjs/sockjs-client/issues/563

    Failing this task as a reminder to perform the manual SockJS install.
    ****************************************
    EOF

    rm -fv *.zip *.tar.gz

    # Remove after the SockJS update is released.
    exit 1
