Skip to content

Commit

Permalink
feat: implement app version during deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
SergBily committed Feb 3, 2025
1 parent 12589ad commit 2dd922f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions mobile/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ if [ -z "$VITE_API_BASE_URL" ]; then
exit 1
fi

if [ -z "$APP_VERSION" ]; then
echo "Error: APP_VERSION is not set."
exit 1
fi

echo "Replacing VITE_API_BASE_URL with: $VITE_API_BASE_URL"
echo "Replacing APP_VERSION with: $APP_VERSION"

find /usr/share/nginx/html -type f -exec sed -i "s|__VITE_API_BASE_URL__|$VITE_API_BASE_URL|g" {} \;
find /usr/share/nginx/html -type f -exec sed -i "s|__APP_VERSION__|$APP_VERSION|g" {} \;

nginx -g "daemon off;"
5 changes: 5 additions & 0 deletions mobile/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ export const API_BASE_URL =
? import.meta.env.VITE_API_BASE_URL
: '__VITE_API_BASE_URL__';

export const APP_VERSION =
import.meta.env.MODE === 'development'
? import.meta.env.VITE_APP_VERSION
: '__APP_VERSION__';

export const API_BASE_PATH = import.meta.env.BASE_URL;
3 changes: 2 additions & 1 deletion mobile/src/pages/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import "./Menu.scss";
import { Preloader } from "../../components/preloader/preloader";
import { ITimespan } from "../../models/interfaces/orders.interface";
import { TIMESPAN_REQUEST } from "../../dispatcher";
import { API_BASE_URL, APP_VERSION } from "../../config";

export const Menu: React.FC = () => {
const [cookies, , removeCookie] = useCookies(["token"]);
Expand Down Expand Up @@ -113,7 +114,7 @@ export const Menu: React.FC = () => {
<MenuListButton title={t("menu.language")} handleItemClick={() => handleItemClick(ROUTES.LANGUAGE)} />
</IonList>
<IonFooter className="footer">
<IonText>Version 0.8</IonText>
<IonText>{`Version ${APP_VERSION}`}</IonText>
</IonFooter>
</>
) : (
Expand Down

0 comments on commit 2dd922f

Please sign in to comment.