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

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