2020-04-02 03:11:19 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
2020-05-10 12:11:11 -04:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
|
#
|
|
|
|
|
# This source code is licensed under the MIT license found in the
|
|
|
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
|
|
2020-04-02 03:11:19 -04:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
CUSTOM_REGISTRY_URL="http://localhost:4873"
|
|
|
|
|
NEW_VERSION="$(node -p "require('./packages/docusaurus/package.json').version").NEW"
|
|
|
|
|
CONTAINER_NAME="verdaccio"
|
2020-11-16 10:11:16 -05:00
|
|
|
EXTRA_OPTS=""
|
|
|
|
|
|
2022-02-26 20:20:59 -05:00
|
|
|
usage() { echo "Usage: $0 [-s] [-t]" 1>&2; exit 1; }
|
2021-08-12 07:18:07 -04:00
|
|
|
|
2022-02-26 20:20:59 -05:00
|
|
|
while getopts ":st" o; do
|
2021-08-12 07:18:07 -04:00
|
|
|
case "${o}" in
|
|
|
|
|
s)
|
2021-12-10 09:04:05 -05:00
|
|
|
EXTRA_OPTS="${EXTRA_OPTS} --skip-install"
|
2021-08-12 07:18:07 -04:00
|
|
|
;;
|
2022-02-26 20:20:59 -05:00
|
|
|
t)
|
|
|
|
|
EXTRA_OPTS="${EXTRA_OPTS} --typescript"
|
|
|
|
|
;;
|
2021-08-12 07:18:07 -04:00
|
|
|
*)
|
|
|
|
|
usage
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -z $EXTRA_OPTS ]
|
|
|
|
|
then
|
2021-10-07 10:06:42 -04:00
|
|
|
echo create-docusaurus extra options = ${EXTRA_OPTS}
|
2020-11-16 10:11:16 -05:00
|
|
|
fi
|
2020-04-02 03:11:19 -04:00
|
|
|
|
|
|
|
|
# Run Docker container with private npm registry Verdaccio
|
2020-11-16 10:11:16 -05:00
|
|
|
docker run -d --rm --name "$CONTAINER_NAME" -p 4873:4873 -v "$PWD/admin/verdaccio.yaml":/verdaccio/conf/config.yaml verdaccio/verdaccio:latest
|
2020-04-02 03:11:19 -04:00
|
|
|
|
|
|
|
|
# Build packages
|
2020-07-27 06:17:59 -04:00
|
|
|
yarn build:packages
|
2020-04-02 03:11:19 -04:00
|
|
|
|
|
|
|
|
# Publish the monorepo
|
2021-04-14 11:25:50 -04:00
|
|
|
npx --no-install lerna publish --exact --yes --no-verify-access --no-git-reset --no-git-tag-version --no-push --registry "$CUSTOM_REGISTRY_URL" "$NEW_VERSION"
|
2020-04-02 03:11:19 -04:00
|
|
|
|
|
|
|
|
# Revert version changes
|
|
|
|
|
git diff --name-only -- '*.json' | sed 's, ,\\&,g' | xargs git checkout --
|
|
|
|
|
|
2021-11-29 02:12:18 -05:00
|
|
|
|
|
|
|
|
# The website is generated outside the repo to minimize chances of yarn resolving the wrong version
|
|
|
|
|
cd ..
|
|
|
|
|
|
2020-04-02 03:11:19 -04:00
|
|
|
# Build skeleton website with new version
|
2021-12-10 09:04:05 -05:00
|
|
|
npm_config_registry="$CUSTOM_REGISTRY_URL" npx create-docusaurus@"$NEW_VERSION" test-website classic $EXTRA_OPTS
|
2020-04-02 03:11:19 -04:00
|
|
|
|
|
|
|
|
# Stop Docker container
|
2022-02-26 20:20:59 -05:00
|
|
|
if [[ -z "${KEEP_CONTAINER:-true}" ]] && ( $(docker container inspect "$CONTAINER_NAME" > /dev/null 2>&1) ); then
|
2020-04-02 03:11:19 -04:00
|
|
|
# Remove Docker container
|
2020-04-22 08:31:44 -04:00
|
|
|
docker container stop $CONTAINER_NAME > /dev/null
|
2020-04-02 03:11:19 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "The website with to-be published packages was successfully build to the $(tput setaf 2)test-website$(tput sgr 0) directory."
|