Browse Source

feat(scripts): add theme upgrade script

run `./themes/after-dark/bin/upgrade` to upgrade the theme to the
latest version anytime from the

if you are using theme version 6.6.x please do this before using...
mkdir -p themes/after-dark/data/npm && mv data/theme/latest.json $_

if you are running a version prior to 6.6.0 please do:
mkdir -p themes/after-dark/data/npm && cd $_ && \
wget -qO latest.json https://registry.npmjs.org/after-dark/latest

...then manually hack the version number to some other version
before running upgrade >;D

resolves #59
master
Josh Habdas 3 years ago
parent
commit
6415250769
Signed by untrusted user: jhabdas GPG Key ID: B148B31154C75A74
4 changed files with 37 additions and 2 deletions
  1. +1
    -0
      .gitignore
  2. +3
    -0
      CHANGELOG.md
  3. +2
    -2
      bin/install
  4. +31
    -0
      bin/upgrade

+ 1
- 0
.gitignore View File

@ -1,2 +1,3 @@
.DS_Store
node_modules
data

+ 3
- 0
CHANGELOG.md View File

@ -5,7 +5,10 @@ All notable changes to this project will be documented in this file. See [standa
<a name="6.6.4"></a>
## [6.6.4](https://git.habd.as/comfusion/after-dark/compare/v6.6.3...v6.6.4) (2018-08-27)
### Security
* **build:** enclose release tag sha512 in delimeters
([543d32d](https://git.habd.as/comfusion/after-dark/commit/543d32d))
<a name="6.6.3"></a>
## [6.6.3](https://git.habd.as/comfusion/after-dark/compare/v6.6.1...v6.6.3) (2018-08-27)

+ 2
- 2
bin/install View File

@ -96,8 +96,8 @@ update_archetypes () {
generate_help_docs () {
echo "Generating help documentation ..."
path=themes/after-dark/data/npm
mkdir -p "$path" && echo "$THEME_META" | tr '\r\n' ' ' > "$path"/latest.json
meta_path=themes/after-dark/data/npm
mkdir -p "$meta_path" && echo "$THEME_META" | tr '\r\n' ' ' > "$meta_path"/latest.json
hugo new help/index.md --kind help 1>/dev/null
}

+ 31
- 0
bin/upgrade View File

@ -0,0 +1,31 @@
#!/bin/sh
set -e
generate_help_docs () {
echo "Generating help documentation ..."
meta_path=themes/after-dark/data/npm
mkdir -p "$path" && echo "$LATEST_META" | tr '\r\n' ' ' > "$meta_path"/latest.json
hugo new help/index.md --kind help 1>/dev/null
}
upgrade () {
current_meta=themes/"$1"/data/npm/latest.json
current_vers=`sed -n 's/.*"version":"\([^"]*\).*/\1/p' <<< "$current_meta"`
if ! [ -f "$current_meta" ] ; then
echo "Error: Unable to locate metadata for $1. Cannot proceed with upgrade." >&2; exit 1
else
LATEST_META=$(wget -qO - https://registry.npmjs.org/"$1"/latest)
latest_vers=`sed -n 's/.*"version":"\([^"]*\).*/\1/p' <<< "$meta"`
if [ "$current_vers" = "$latest_vers" ] ; then
echo "Did not upgrade $1. Already using latest version." >&1; exit 0
else
rm -rf themes/"$1"
wget -qO - https://registry.npmjs.org/"$1"/-/"$1"-"$latest_vers".tgz | tar --strip-components=1 -xz -C themes/"$1"
echo "Version $latest_vers downloaded to ./themes/$1"
[ "$1" = "after-dark" ] && generate_help_docs
echo "Upgrade complete! Please see CHANGELOG.md for breaking changes."
fi
fi
}
upgrade "after-dark"

Loading…
Cancel
Save