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.2KB

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