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
Josh Habdas 7 months ago
parent
commit
6415250769
Signed by: Josh Habdas <jhabdas@protonmail.com> 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 @@
1 1
 .DS_Store
2 2
 node_modules
3
+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
5 5
 <a name="6.6.4"></a>
6 6
 ## [6.6.4](https://git.habd.as/comfusion/after-dark/compare/v6.6.3...v6.6.4) (2018-08-27)
7 7
 
8
+### Security
8 9
 
10
+* **build:** enclose release tag sha512 in delimeters
11
+([543d32d](https://git.habd.as/comfusion/after-dark/commit/543d32d))
9 12
 
10 13
 <a name="6.6.3"></a>
11 14
 ## [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 () {
96 96
 
97 97
 generate_help_docs () {
98 98
    echo "Generating help documentation ..."
99
-   path=themes/after-dark/data/npm
100
-   mkdir -p "$path" && echo "$THEME_META" | tr '\r\n' ' ' > "$path"/latest.json
99
+   meta_path=themes/after-dark/data/npm
100
+   mkdir -p "$meta_path" && echo "$THEME_META" | tr '\r\n' ' ' > "$meta_path"/latest.json
101 101
    hugo new help/index.md --kind help 1>/dev/null
102 102
 }
103 103
 

+ 31
- 0
bin/upgrade View File

@@ -0,0 +1,31 @@
1
+#!/bin/sh
2
+set -e
3
+
4
+generate_help_docs () {
5
+   echo "Generating help documentation ..."
6
+   meta_path=themes/after-dark/data/npm
7
+   mkdir -p "$path" && echo "$LATEST_META" | tr '\r\n' ' ' > "$meta_path"/latest.json
8
+   hugo new help/index.md --kind help 1>/dev/null
9
+}
10
+
11
+upgrade () {
12
+   current_meta=themes/"$1"/data/npm/latest.json
13
+   current_vers=`sed -n 's/.*"version":"\([^"]*\).*/\1/p' <<< "$current_meta"`
14
+   if ! [ -f "$current_meta" ] ; 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' <<< "$meta"`
19
+      if [ "$current_vers" = "$latest_vers" ] ; then
20
+         echo "Did not upgrade $1. Already using latest version." >&1; exit 0
21
+      else
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 breaking changes."
27
+      fi
28
+   fi
29
+}
30
+
31
+upgrade "after-dark"

Loading…
Cancel
Save