Skip to content

Commit

Permalink
fix(build): issues/34 correct deployment path prefix (#49)
Browse files Browse the repository at this point in the history
* build, deployment path prefix
* routerTypes, update route, use acronym
  • Loading branch information
cdcabrera authored and priley86 committed Jul 22, 2019
1 parent 1255279 commit 34cb100
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ GENERATE_SOURCEMAP=true
REACT_APP_ENV=production
REACT_APP_UI_VERSION=${UI_VERSION}

REACT_APP_INCLUDE_CONTENT_HEADER='<esi:include src="/@@env/chrome/snippets/head.html" />'
REACT_APP_INCLUDE_CONTENT_BODY='<esi:include src="/@@env/chrome/snippets/body.html" />'
REACT_APP_INCLUDE_CONTENT_HEADER=<esi:include src="${UI_DEPLOY_PATH_PREFIX}/apps/chrome/snippets/head.html" />
REACT_APP_INCLUDE_CONTENT_BODY=<esi:include src="${UI_DEPLOY_PATH_PREFIX}/apps/chrome/snippets/body.html" />
26 changes: 15 additions & 11 deletions scripts/pre.sh
Original file line number Diff line number Diff line change
@@ -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"
}
#
#
Expand All @@ -25,17 +26,20 @@ 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
}
#
#
# Clean directories
#
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
}
#
#
Expand All @@ -46,5 +50,5 @@ clean()
version

# see .travis.yml globals
path $BRANCH
deployPaths ${BRANCH:-local}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
]
}
Expand Down Expand Up @@ -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",
},
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ exports[`Router Component should render a basic component: basic 1`] = `
<Switch>
<Route
component={[Function]}
key="/redhatenterpriselinux"
path="/redhatenterpriselinux"
key="/rhel"
path="/rhel"
/>
<Redirect
from="/"
to="/redhatenterpriselinux"
to="/rhel"
/>
</Switch>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Array [
"id": "rhel",
"redirect": true,
"title": "Red Hat Enterprise Linux",
"to": "/redhatenterpriselinux",
"to": "/rhel",
},
]
`;
2 changes: 1 addition & 1 deletion src/components/router/routerTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const routes = [
{
title: 'Red Hat Enterprise Linux',
id: 'rhel',
to: '/redhatenterpriselinux',
to: '/rhel',
redirect: true,
component: RhelView
}
Expand Down
4 changes: 2 additions & 2 deletions tests/__snapshots__/html.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ exports[`Index.HTML should have a specific html output: html output 1`] = `
<meta charset=\\"utf-8\\"/>
<title>Subscription Reporting
</title>
<esi:include src=\\"/@@env/chrome/snippets/head.html\\" />
<esi:include src=\\"*/apps/chrome/snippets/head.html\\" />
<link href=\\"*/apps/subscription-reporting/static/css/*.chunk.css\\" rel=\\"stylesheet\\">
<link href=\\"*/apps/subscription-reporting/static/css/*.chunk.css\\" rel=\\"stylesheet\\">
</head>
<body>
<esi:include src=\\"/@@env/chrome/snippets/body.html\\" />
<esi:include src=\\"*/apps/chrome/snippets/body.html\\" />
<script>/* filtered */</script>
<script src=\\"*/apps/subscription-reporting/static/js/*.chunk.js\\">
</script>
Expand Down

0 comments on commit 34cb100

Please sign in to comment.