From 34cb100e041112c1abd8e3930b6de5e1ac6b06cc Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Mon, 22 Jul 2019 14:34:36 -0400 Subject: [PATCH] fix(build): issues/34 correct deployment path prefix (#49) * build, deployment path prefix * routerTypes, update route, use acronym --- .env | 2 +- .env.production | 4 +-- scripts/pre.sh | 26 +++++++++++-------- .../__snapshots__/authentication.test.js.snap | 4 +-- .../__snapshots__/router.test.js.snap | 6 ++--- .../__snapshots__/routerTypes.test.js.snap | 2 +- src/components/router/routerTypes.js | 2 +- tests/__snapshots__/html.test.js.snap | 4 +-- 8 files changed, 27 insertions(+), 23 deletions(-) diff --git a/.env b/.env index 0f28d7d33..a31579a1f 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ REACT_APP_UI_VERSION=$npm_package_version REACT_APP_UI_NAME=subscription-reporting REACT_APP_UI_DISPLAY_NAME=Subscription Reporting -PUBLIC_URL=${PUBLIC_URL_PREFIX}/apps/subscription-reporting/ +PUBLIC_URL=${UI_DEPLOY_PATH_PREFIX}/apps/subscription-reporting/ REACT_APP_AJAX_TIMEOUT=60000 diff --git a/.env.production b/.env.production index cdba6190e..25b9c2194 100644 --- a/.env.production +++ b/.env.production @@ -3,5 +3,5 @@ GENERATE_SOURCEMAP=true REACT_APP_ENV=production REACT_APP_UI_VERSION=${UI_VERSION} -REACT_APP_INCLUDE_CONTENT_HEADER='' -REACT_APP_INCLUDE_CONTENT_BODY='' +REACT_APP_INCLUDE_CONTENT_HEADER= +REACT_APP_INCLUDE_CONTENT_BODY= diff --git a/scripts/pre.sh b/scripts/pre.sh index 17b9e2edd..9545fab87 100644 --- a/scripts/pre.sh +++ b/scripts/pre.sh @@ -1,21 +1,22 @@ #!/usr/bin/env bash # # -# Update public path +# Update deployment paths, prefixes # -path() +deployPaths() { - local CI_BRANCH=$1 - PUBLIC_URL_PREFIX="" + DEPLOY_PATH_PREFIX="" if [[ $CI_BRANCH == *"beta"* ]] || [[ $CI_BRANCH == *"master"* ]]; then - PUBLIC_URL_PREFIX=/beta + DEPLOY_PATH_PREFIX=/beta fi - echo "Path prefix for branch ${CI_BRANCH}... PUBLIC_URL_PREFIX=$PUBLIC_URL_PREFIX" - echo PUBLIC_URL_PREFIX="$PUBLIC_URL_PREFIX" >> ./.env.production.local + echo UI_DEPLOY_PATH_PREFIX="$DEPLOY_PATH_PREFIX" >> ./.env.production.local + + echo "Deploy config for branch \"${CI_BRANCH}\"..." + echo "Deploy path prefix ... UI_DEPLOY_PATH_PREFIX=$DEPLOY_PATH_PREFIX" } # # @@ -25,7 +26,7 @@ version() { UI_VERSION="$(node -p 'require(`./package.json`).version').$(git rev-parse --short HEAD)" echo "Version... UI_VERSION=$UI_VERSION" - echo UI_VERSION="$UI_VERSION" > ./.env.production.local + echo UI_VERSION="$UI_VERSION" >> ./.env.production.local } # # @@ -33,9 +34,12 @@ version() # clean() { - echo "Cleaning build directories..." + FILE="$(pwd)/.env.production.local" + + echo "Cleaning build directories, files..." rm -rf -- "$(pwd)"/build - rm -rf -- "$(pwd)"/public/apps; + rm -rf -- "$(pwd)"/public/apps + rm $FILE } # # @@ -46,5 +50,5 @@ clean() version # see .travis.yml globals - path $BRANCH + deployPaths ${BRANCH:-local} } diff --git a/src/components/authentication/__tests__/__snapshots__/authentication.test.js.snap b/src/components/authentication/__tests__/__snapshots__/authentication.test.js.snap index b59f2a70a..ce4e7227d 100644 --- a/src/components/authentication/__tests__/__snapshots__/authentication.test.js.snap +++ b/src/components/authentication/__tests__/__snapshots__/authentication.test.js.snap @@ -23,7 +23,7 @@ exports[`Authorization Component should render a non-connected component authori "id": "rhel", "redirect": true, "title": "Red Hat Enterprise Linux", - "to": "/redhatenterpriselinux", + "to": "/rhel", }, ] } @@ -61,7 +61,7 @@ exports[`Authorization Component should render a non-connected component error: "id": "rhel", "redirect": true, "title": "Red Hat Enterprise Linux", - "to": "/redhatenterpriselinux", + "to": "/rhel", }, ] } diff --git a/src/components/router/__tests__/__snapshots__/router.test.js.snap b/src/components/router/__tests__/__snapshots__/router.test.js.snap index d6af3d005..a0cedcf80 100644 --- a/src/components/router/__tests__/__snapshots__/router.test.js.snap +++ b/src/components/router/__tests__/__snapshots__/router.test.js.snap @@ -7,12 +7,12 @@ exports[`Router Component should render a basic component: basic 1`] = ` diff --git a/src/components/router/__tests__/__snapshots__/routerTypes.test.js.snap b/src/components/router/__tests__/__snapshots__/routerTypes.test.js.snap index c82f7e32f..ff414290b 100644 --- a/src/components/router/__tests__/__snapshots__/routerTypes.test.js.snap +++ b/src/components/router/__tests__/__snapshots__/routerTypes.test.js.snap @@ -9,7 +9,7 @@ Array [ "id": "rhel", "redirect": true, "title": "Red Hat Enterprise Linux", - "to": "/redhatenterpriselinux", + "to": "/rhel", }, ] `; diff --git a/src/components/router/routerTypes.js b/src/components/router/routerTypes.js index 2205fd672..bfbd7a7dd 100644 --- a/src/components/router/routerTypes.js +++ b/src/components/router/routerTypes.js @@ -15,7 +15,7 @@ const routes = [ { title: 'Red Hat Enterprise Linux', id: 'rhel', - to: '/redhatenterpriselinux', + to: '/rhel', redirect: true, component: RhelView } diff --git a/tests/__snapshots__/html.test.js.snap b/tests/__snapshots__/html.test.js.snap index 8c59b7b51..fd40a8da3 100644 --- a/tests/__snapshots__/html.test.js.snap +++ b/tests/__snapshots__/html.test.js.snap @@ -8,12 +8,12 @@ exports[`Index.HTML should have a specific html output: html output 1`] = ` Subscription Reporting - + - +