update hash string script

This commit is contained in:
Alexander Popov 2023-08-04 00:45:01 +03:00
parent 97af1107ac
commit 16421f0023
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6
6 changed files with 40 additions and 6 deletions

6
.gitignore vendored
View File

@ -1,2 +1,8 @@
.parcel-cache/ .parcel-cache/
ec*.exe ec*.exe
# public (build)
public/content/
public/index.*
public/manifest.webmanifest
public/*.png

View File

@ -1,11 +1,11 @@
<footer class="text-center text-shadow mt-3 text-white-50"> <footer class="text-center text-shadow mt-3 text-white-50">
<p class="font-monospace"> <p class="font-monospace">
build: commit:
<a <a
class="text-reset text-decoration-none border-bottom py-1" class="text-reset text-decoration-none border-bottom py-1"
href="#" href="https://git.a2s.su/iiiypuk/a2s.su"
target="_blank" target="_blank"
>ab6324f</a >{GIT_COMMIT_HASH}</a
> >
</p> </p>
</footer> </footer>

17
clean_public.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
files=(
"manifest.webmanifest"
"index.html"
"*.css*"
"*.png"
)
echo -n "Remove all build files in 'public'... "
for file in "${files[@]}"
do
rm ./public/$file &> /dev/null
done
echo "Complete!"

View File

@ -7,6 +7,8 @@
"serve": "npx parcel serve --dist-dir public app/index.html", "serve": "npx parcel serve --dist-dir public app/index.html",
"build": "npx parcel build --dist-dir public app/index.html --no-optimize", "build": "npx parcel build --dist-dir public app/index.html --no-optimize",
"prettier": "npx prettier --write .", "prettier": "npx prettier --write .",
"git-hash": "./update_commit.sh",
"clean": "./clean_public.sh",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "Alexander Popov <iiiypuk@fastmail.fm>", "author": "Alexander Popov <iiiypuk@fastmail.fm>",

3
public/.gitignore vendored
View File

@ -1,3 +0,0 @@
index.*
manifest.webmanifest
*.png

12
update_commit.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
if [ -f "./public/index.html" ]; then
GIT_COMMIT_HASH=$(git rev-parse --short HEAD)
echo -n "Update git commit hash in 'index.html' "
sed -i -- "s/{GIT_COMMIT_HASH}/$GIT_COMMIT_HASH/g" ./public/index.html
echo " Complete!"
else
echo "Run 'npm run build'"
fi