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

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