From 309e12033b76c2221b6b5c761c620816dc0d945d Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sun, 29 Dec 2019 01:00:49 -0500 Subject: Move template files to subfolder More static files will likely be used that do not require using a template (e.g. favicon.ico), so storing them in the public folder will keep them with other served files without getting them confused with the templates. --- public/bash.template | 72 ------------------------------------ public/index.html.template | 17 --------- public/templates/bash.template | 72 ++++++++++++++++++++++++++++++++++++ public/templates/index.html.template | 17 +++++++++ src/index.ts | 4 +- 5 files changed, 91 insertions(+), 91 deletions(-) delete mode 100644 public/bash.template delete mode 100644 public/index.html.template create mode 100644 public/templates/bash.template create mode 100644 public/templates/index.html.template diff --git a/public/bash.template b/public/bash.template deleted file mode 100644 index 08a5913..0000000 --- a/public/bash.template +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env bash - -# Licensed under Parity Public License 7.0.0 -# The full version of this license can be found here: -# https://git.submelon.dev/kjhoerr/ao-coverage/raw/branch/trunk/LICENSE.md - -url="{{TARGET_URL}}" -commit="" -branch="" -repo="" -format="tarpaulin" -report="" -token="$COV_TOKEN" - -function verbose_say() { - if [ -z "$QUIET" ] || [ "$VERBOSE" == "true" ]; then - echo "$1" - fi -} - -verbose_say "===========================" -verbose_say " ao-coverage " -verbose_say "===========================" -verbose_say - -verbose_say "Gathering report information . . ." - -if [ "$CI" == "drone" ]; then - verbose_say "Drone CI discovered - using Drone report info" - commit="$DRONE_COMMIT" - branch="$DRONE_BRANCH" - repo="$DRONE_REPO" -else - verbose_say "Using environment variables for report info" - commit="$VCS_COMMIT" - branch="$VCS_BRANCH" - repo="$VCS_REPO" -fi - -verbose_say "Using commit #: $commit" -verbose_say "Using branch: $branch" -verbose_say "Using repo: $repo" -verbose_say - -if [ "$format" == "tarpaulin" ]; then - report="${REPORT_FILE:-tarpaulin-report.html}" -fi - -if [[ ! -f "$report" ]]; then - echo "Report file could not be found." - exit 1 -fi - -verbose_say "Uploading $report . . ." - -response=$(curl -X POST --data-binary "@$report" \ - -H 'Content-Type: text/html' \ - "$url/v1/$repo/$branch/$commit.html?token=$token&format=$format") - -if [ ! -z "$response" ]; then - echo "Error uploading report: $response" - exit 1 -else - echo "Successfully uploaded report!" - verbose_say - verbose_say "View uploaded report at: $url/v1/$repo/$branch/$commit.html" - verbose_say "View coverage badge at: $url/v1/$repo/$branch/$commit.svg" - verbose_say - verbose_say "Shorthand links are also available, as the latest commit of this branch." - verbose_say "View latest report for branch $branch: $url/v1/$repo/$branch.html" - verbose_say "View latest badge for branch $branch: $url/v1/$repo/$branch.svg" -fi \ No newline at end of file diff --git a/public/index.html.template b/public/index.html.template deleted file mode 100644 index 0dfbee7..0000000 --- a/public/index.html.template +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - AO Coverage: Simple code coverage tracking - - - -
- bash <(curl -s {{TARGET_URL}}/bash) -
- - - \ No newline at end of file diff --git a/public/templates/bash.template b/public/templates/bash.template new file mode 100644 index 0000000..08a5913 --- /dev/null +++ b/public/templates/bash.template @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# Licensed under Parity Public License 7.0.0 +# The full version of this license can be found here: +# https://git.submelon.dev/kjhoerr/ao-coverage/raw/branch/trunk/LICENSE.md + +url="{{TARGET_URL}}" +commit="" +branch="" +repo="" +format="tarpaulin" +report="" +token="$COV_TOKEN" + +function verbose_say() { + if [ -z "$QUIET" ] || [ "$VERBOSE" == "true" ]; then + echo "$1" + fi +} + +verbose_say "===========================" +verbose_say " ao-coverage " +verbose_say "===========================" +verbose_say + +verbose_say "Gathering report information . . ." + +if [ "$CI" == "drone" ]; then + verbose_say "Drone CI discovered - using Drone report info" + commit="$DRONE_COMMIT" + branch="$DRONE_BRANCH" + repo="$DRONE_REPO" +else + verbose_say "Using environment variables for report info" + commit="$VCS_COMMIT" + branch="$VCS_BRANCH" + repo="$VCS_REPO" +fi + +verbose_say "Using commit #: $commit" +verbose_say "Using branch: $branch" +verbose_say "Using repo: $repo" +verbose_say + +if [ "$format" == "tarpaulin" ]; then + report="${REPORT_FILE:-tarpaulin-report.html}" +fi + +if [[ ! -f "$report" ]]; then + echo "Report file could not be found." + exit 1 +fi + +verbose_say "Uploading $report . . ." + +response=$(curl -X POST --data-binary "@$report" \ + -H 'Content-Type: text/html' \ + "$url/v1/$repo/$branch/$commit.html?token=$token&format=$format") + +if [ ! -z "$response" ]; then + echo "Error uploading report: $response" + exit 1 +else + echo "Successfully uploaded report!" + verbose_say + verbose_say "View uploaded report at: $url/v1/$repo/$branch/$commit.html" + verbose_say "View coverage badge at: $url/v1/$repo/$branch/$commit.svg" + verbose_say + verbose_say "Shorthand links are also available, as the latest commit of this branch." + verbose_say "View latest report for branch $branch: $url/v1/$repo/$branch.html" + verbose_say "View latest badge for branch $branch: $url/v1/$repo/$branch.svg" +fi \ No newline at end of file diff --git a/public/templates/index.html.template b/public/templates/index.html.template new file mode 100644 index 0000000..0dfbee7 --- /dev/null +++ b/public/templates/index.html.template @@ -0,0 +1,17 @@ + + + + + + + + AO Coverage: Simple code coverage tracking + + + +
+ bash <(curl -s {{TARGET_URL}}/bash) +
+ + + \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 6749ae1..71da73c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,12 +34,12 @@ if (!path.isAbsolute(HOST_DIR)) { // prepare template files const bashTemplate = { - inputFile: path.join(__dirname, "..", "public", "bash.template"), + inputFile: path.join(__dirname, "..", "public", "templates", "bash.template"), outputFile: path.join(HOST_DIR, "bash"), context: { TARGET_URL } } as Template; const indexTemplate = { - inputFile: path.join(__dirname, "..", "public", "index.html.template"), + inputFile: path.join(__dirname, "..", "public", "templates", "index.html.template"), outputFile: path.join(HOST_DIR, "index.html"), context: { TARGET_URL } } as Template; -- cgit