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