Skip to content

Commit

Permalink
Merge pull request #17 from platzhersh/feature/expressJS_remove_async…
Browse files Browse the repository at this point in the history
…_false_refactor

Feature/express js remove async false refactor
  • Loading branch information
platzhersh authored Oct 5, 2020
2 parents cd14c44 + 277ff43 commit 97826b8
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**.db**
**.bak
*.db
.idea/
node_modules
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Feel free to use / copy / modify my code, as long as you reshare your version an
Version history
===============

*Version 1.0.1 - 6.10.2020*
* add `bump-version.sh` to make versioning easier

*Version 1.0.0 - 5.9.2020*
* use "default" version number format, go up to 1.0.0
* add `package.json`
Expand Down
156 changes: 156 additions & 0 deletions bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#!/bin/bash

#region globalvars
option=$1
abort=false
currentVersion=''
newVersion=''
currentDateTime=$(date +"%Y-%m-%d %T")
currentDate=$(date +"%Y-%m-%d")

#region functions

function showHelp {
echo 'Parameter invalid / missing.'
echo ''
echo 'usage:'
echo ''
echo ' bump_version [patch|minor|major]'
echo ''
}

function checkParameters {
# check if parameter provided
if [ -z $option ];
then
showHelp
abort=true
else
case $option in
patch)
# echo "patch"
;;
minor)
# echo "minor"
;;
major)
# echo "major"
;;
*)
showHelp
abort=true
return
;;
esac
echo "bump ${option} version"
fi
}

# use package.json as the source of truth
function read_current_version {
currentVersion=$(echo "$var1" | (grep version package.json | sed 's/.*"version": "\(.*\)".*/\1/'))
echo "currentVersion=${currentVersion}"
}

function get_new_version {
local currentMajor=$(echo "$var1" | (echo "${currentVersion}" | awk -F'.' '{print $1}'))
local currentMinor=$(echo "$var1" | (echo "${currentVersion}" | awk -F'.' '{print $2}'))
local currentPatch=$(echo "$var1" | (echo "${currentVersion}" | awk -F'.' '{print $3}'))

echo "${currentMajor} ${currentMinor} ${currentPatch}"
case $option in
patch)
let "newPatch = $currentPatch + 1"
newVersion="${currentMajor}.${currentMinor}.${newPatch}"
echo "newVersion=${newVersion}"
;;
minor)
let "newMinor = $currentMinor + 1"
newVersion="${currentMajor}.${newMinor}.0"
echo "newVersion=${newVersion}"
;;
major)
let "newMajor = $currentMajor + 1"
newVersion="${newMajor}.0.0"
echo "newVersion=${newVersion}"
;;
esac
}

function search_replace_in_file {
local file=$1
local search=$2
local replace=$3

sed -i "" "s/${search}/${replace}/g" $file
}

function write_new_version {

echo ""
echo "Update files to ${newVersion} (${currentDateTime}):"

echo " package.json"
local line="\"version\": \".*\""
local rep="\"version\": \"${newVersion}\""
sed -i "" "s/${line}/${rep}/g" package.json

echo " package-lock.json"
sed -i "" "s/${line}/${rep}/g" package-lock.json

# TODO: update last_update
echo " web-app-manifest.json"
sed -i "" "s/${line}/${rep}/g" web-app-manifest.json

# TODO: update last_update
echo " manifest.json"
sed -i "" "s/${line}/${rep}/g" manifest.json

# TODO: update last_update
echo " pacman-canvas.webapp"
sed -i "" "s/${line}/${rep}/g" pacman-canvas.webapp

echo " cache.manifest"
local line="# Pacman .*"
local rep="# Pacman ${newVersion} ${currentDateTime}"
sed -i "" "s/${line}/${rep}/g" cache.manifest

echo " index.htm"
local line="<span class=\"app-version\">.*<\/span>"
local rep="<span class=\"app-version\">${newVersion} (${currentDate})<\/span>"
sed -i "" "s/${line}/${rep}/g" index.htm

echo ""
echo "All files up to date. New Version ${newVersion} (${currentDateTime})."
echo "Don't forget to update README.md."
}

function run {
# local option="${1}"

echo "run ${option}"

checkParameters

if [[ ${abort} == true ]];
then
return
fi

echo "bump version $option"

read_current_version
get_new_version

# TODO: user confirmation

write_new_version
}

#endregion

#region main

run

#endregion
2 changes: 1 addition & 1 deletion cache.manifest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
# Pacman 1.0.0 05.09.2020
# Pacman 1.0.1 2020-10-06 00:57:08

CACHE:

Expand Down
11 changes: 11 additions & 0 deletions data/db-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@
} else {
echo getHighscore();
}
} else if ($_GET['action'] == 'version') {
echo getVersionInfo();
}
} else echo "define action to call";


function getVersionInfo() {
$strJsonFileContents = file_get_contents("../package.json");
// Convert to array
$array = json_decode($strJsonFileContents, true);
$version = $array['version'];

return $version;
}

function getHighscore($page = 1) {

$db = new SQLite3('pacman.db');
Expand Down
2 changes: 1 addition & 1 deletion index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ <h3>Powerpills</h3>
<div class="button" id="back">&lt; back</div>
<div>
<h1>Info</h1>
<p>Current Version: 0.91 (15.01.2016) (<a href="#" id="updateCode">get latest</a>)</p>
<p>Current Version: <span class="app-version">1.0.1 (2020-10-06)</span> (<a href="#" id="updateCode">get latest</a>)</p>
<img src="img/platzh1rsch-logo.png">
<p>Pacman Canvas is Open Source, written by <a href="http://platzh1rsch.ch">platzh1rsch</a>. You can get the code on <a target="_blank" href="https://github.com/platzhersh/pacman-canvas" target="_blank">github</a>.</p>
<p>If you have any suggestions how to make this app better, please post your suggestion / request on <a target="_blank" href="https://platzh1rsch.uservoice.com/">uservoice</a>.</p>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Pacman Canvas",
"short_name": "Pacman Canvas",
"description": "An old classic, rewritten in HTML5",
"version": "0.93",
"version": "1.0.1",
"lang": "en-US",

"display": "standalone",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pacman-canvas",
"version": "1.0.0",
"version": "1.0.1",
"description": "pacman-canvas =============",
"main": "pacman-canvas.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion pacman-canvas.webapp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "Pacman Canvas",
"description": "An old classic, rewritten in HTML5",
"launch_path": "/",
"version": "1.0.1",
"developer": {
"name": "platzh1rsch",
"url": "http://platzh1rsch.ch"
Expand All @@ -10,4 +11,4 @@
"128": "/img/icon-128.png"
},
"default_locale": "en"
}
}
10 changes: 5 additions & 5 deletions web-app-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"verification_key" : "eca78f4d-14f3-4fe7-8b44-3e0006a9a9c7",
"version" : "1.0.0",
"type" : "web",
"last_update" : "2018-03-06 16:45:11+0000"
}
"verification_key": "eca78f4d-14f3-4fe7-8b44-3e0006a9a9c7",
"version": "1.0.1",
"type": "web",
"last_update": "2018-03-06 16:45:11+0000"
}

0 comments on commit 97826b8

Please sign in to comment.