-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add local preview make target
- Loading branch information
Showing
5 changed files
with
55 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode | ||
*.out | ||
cover.txt | ||
cover-test | ||
cover.html | ||
cover.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
LOCAL_COVER_DIR := cover-test | ||
|
||
.PHONY: release | ||
release: | ||
git tag -d v1 | ||
git tag v1 HEAD | ||
git push -f origin v1 | ||
|
||
$(LOCAL_COVER_DIR)/revisions: | ||
@mkdir -p "$(LOCAL_COVER_DIR)/revisions" | ||
|
||
$(LOCAL_COVER_DIR)/revisions/local.html: $(LOCAL_COVER_DIR)/revisions | ||
@cd go-test-app-01; make test | ||
@cd go-test-app-01; go tool cover -html=cover.out -o "../$(LOCAL_COVER_DIR)/revisions/local.html" | ||
@cp $(LOCAL_COVER_DIR)/revisions/local.html $(LOCAL_COVER_DIR)/revisions/local-inc.html | ||
@for file in assets/*; do ln -s "$$PWD/$$file" "$(LOCAL_COVER_DIR)/$(shell basename "$$file")"; done | ||
@cd $(LOCAL_COVER_DIR); REVISION=local ../scripts/beautify-html.sh "$$html_file" | ||
|
||
preview: clean $(LOCAL_COVER_DIR)/revisions/local.html | ||
@echo "" | ||
@echo preview live at: http://localhost:8000?hash=local | ||
@echo " ctrl+c to stop" | ||
@echo "" | ||
@cd $(LOCAL_COVER_DIR); python3 -m http.server 8000 > /dev/null | ||
|
||
clean: | ||
@rm -rf "$(LOCAL_COVER_DIR)" | ||
@cd go-test-app-01; make clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
if [ "${REVISION}" = "local" ]; then | ||
set -eo pipefail | ||
else | ||
set -xeo pipefail | ||
fi | ||
|
||
if [ -z "${REVISION}" ]; then | ||
echo "REVISION is not set" | ||
exit 1 | ||
fi | ||
|
||
# this is useful for browser caching | ||
hash=$(cat index.css index.js | md5sum | awk '{print $1}') | ||
|
||
for file in "revisions/${REVISION}.html" "revisions/${REVISION}-inc.html"; do | ||
ex -sc '%s/\n\t\t<style>\_.\{-}<\/style>//' -c 'x' "${file}" | ||
ex -sc '%s/\n\t<script>\_.\{-}<\/script>//' -c 'x' "${file}" | ||
ex -sc '%s/<title>/<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" \/>\r\t\t<title>/' -c 'x' "${file}" | ||
ex -sc '%s/<title>/<meta http-equiv="Pragma" content="no-cache" \/>\r\t\t<title>/' -c 'x' "${file}" | ||
ex -sc '%s/<title>/<meta http-equiv="Expires" content="0" \/>\r\t\t<title>/' -c 'x' "${file}" | ||
ex -sc '%s/<\/title>/<\/title>\r\t\t<script src="..\/index.js?'"${hash}"'"><\/script>/' -c 'x' "${file}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters