Hugo Dark Theme Site Generator https://after-dark.habd.as
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

upgrade 1.5KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh
  2. set -e
  3. CONFIG_FILE=config.toml
  4. CONTENT_DIR=`sed -n 's/contentDir[=:]"\([^"]*\)".*/\1/p' <<< "$(cat $CONFIG_FILE | tr -d ' ')"`
  5. [ -z $CONTENT_DIR ] && CONTENT_DIR=content
  6. generate_help_docs () {
  7. echo "Generating help documentation ..."
  8. meta_path=themes/after-dark/data/npm
  9. mkdir -p "$meta_path" && echo "$LATEST_META" | tr '\r\n' ' ' > "$meta_path"/latest.json
  10. [ -f "$CONTENT_DIR"/help/index.md ] && rm "$CONTENT_DIR"/help/index.md
  11. hugo new help/index.md --kind help 1>/dev/null
  12. }
  13. upgrade () {
  14. meta_file=themes/"$1"/data/npm/latest.json
  15. current_vers=`sed -n 's/.*"version":"\([^"]*\).*/\1/p' < "$meta_file"`
  16. if ! [ -f "$meta_file" ] ; then
  17. echo "Error: Unable to locate metadata for $1. Cannot proceed with upgrade." >&2; exit 1
  18. else
  19. LATEST_META=$(wget -qO - https://registry.npmjs.org/"$1"/latest)
  20. latest_vers=`sed -n 's/.*"version":"\([^"]*\).*/\1/p' <<< "$LATEST_META"`
  21. if [ "$current_vers" = "$latest_vers" ] ; then
  22. echo "Did not upgrade $1. Already using latest version." >&1; exit 0
  23. else
  24. echo "Starting upgrade from $current_vers to $latest_vers ..."
  25. rm -rf themes/"$1"/*
  26. wget -qO - https://registry.npmjs.org/"$1"/-/"$1"-"$latest_vers".tgz | tar --strip-components=1 -xz -C themes/"$1"
  27. echo "Version $latest_vers downloaded to themes/$1"
  28. [ "$1" = "after-dark" ] && generate_help_docs
  29. echo "Upgrade complete! Please see CHANGELOG.md for changes."
  30. fi
  31. fi
  32. }
  33. upgrade "after-dark"