1#!/usr/bin/env bash 2 3set -euo pipefail 4 5scriptdir=$(dirname "${BASH_SOURCE[0]}") 6bucket="docs.expo.io" 7target="${1-$scriptdir/out}" 8 9if [ ! -d "$target" ]; then 10 echo "target $target not found" 11 exit 1 12fi 13 14aws s3 sync "$target" "s3://${bucket}" --delete 15 16aws s3 cp \ 17 --recursive \ 18 --metadata-directive REPLACE \ 19 --cache-control "public,max-age=31536000,immutable" \ 20 "s3://${bucket}/_next/static/" \ 21 "s3://${bucket}/_next/static/" 22 23declare -A redirects # associative array variable 24 25# usage: 26# redicts[requests/for/this/path]=are/redirected/to/this/one 27 28# Temporarily create a redirect for a page that Home links to 29redirects[versions/latest/introduction/installation.html]=versions/latest/introduction/installation/ 30# useful link on twitter 31redirects[versions/latest/guides/app-stores.html]=versions/latest/distribution/app-stores/ 32# Xdl caches 33redirects[versions/latest/guides/offline-support.html]=versions/latest/guides/offline-support/ 34# xdl convert comment 35redirects[versions/latest/sdk/index.html]=versions/latest/sdk/overview/ 36# upgrading expo -> upgrading sdk walkthrough 37redirects[versions/latest/workflow/upgrading-expo]=versions/latest/workflow/upgrading-expo-sdk-walkthrough/ 38# rename 39redirects[versions/latest/sdk/haptic/index.html]=versions/latest/sdk/haptics/ 40# duplicate docs file, consolidate into one page 41redirects[versions/latest/sdk/introduction/index.html]=versions/latest/sdk/overview/ 42# project-lifecycle is now covered by managed-vs-bare 43redirects[versions/latest/introduction/project-lifecycle/]=versions/latest/introduction/managed-vs-bare/ 44# exp-cli is now expo-cli 45redirects[versions/latest/guides/exp-cli.html]=versions/latest/workflow/expo-cli/ 46redirects[versions/latest/guides/exp-cli]=versions/latest/workflow/expo-cli/ 47 48for i in "${!redirects[@]}" # iterate over keys 49do 50 aws s3 cp \ 51 --metadata-directive REPLACE \ 52 --website-redirect "/${redirects[$i]}" \ 53 "$target/404.html" \ 54 "s3://${bucket}/${i}" 55done 56