Skip to content

Commit

Permalink
ECOPROJECT-2281: expose migration-planner-ui version in the devtool (#39
Browse files Browse the repository at this point in the history
)

Signed-off-by: Nir Argaman <[email protected]>
  • Loading branch information
nirarg authored Nov 13, 2024
1 parent d344804 commit 95b5737
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@patternfly/react-icons": "^5.4.0",
"@patternfly/react-table": "^5.4.0",
"@redhat-cloud-services/frontend-components": "^4.2.13",
"dotenv": "^16.4.5",
"humanize-plus": "^1.8.2",
"lodash": "^4.17.21",
"prop-types": "^15.8.1",
Expand Down
10 changes: 10 additions & 0 deletions apps/demo/src/common/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import buildManifest from 'demo/package.json';

/**
* The function returns the build-time generated version.
* It can be overriden via the MIGRATION_PLANNER_UI_VERSION environment variable.
*/
export const getMigrationPlannerUiVersion = () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return
return process.env.MIGRATION_PLANNER_UI_VERSION || buildManifest.version;
};
4 changes: 4 additions & 0 deletions apps/demo/src/components/AppPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
PageHeader,
PageHeaderTitle,
} from "@redhat-cloud-services/frontend-components/PageHeader";
import { getMigrationPlannerUiVersion } from "#/common/version";

// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace AppPage {
Expand All @@ -40,6 +41,9 @@ export const AppPage: React.FC<React.PropsWithChildren<AppPage.Props>> = (
</BreadcrumbItem>
))}
</Breadcrumb>
<div data-testid="migration-planner-ui-version" hidden>
{getMigrationPlannerUiVersion()}
</div>
</PageBreadcrumb>
<PageHeader>
<PageHeaderTitle title={title} />
Expand Down
4 changes: 4 additions & 0 deletions apps/demo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import tsconfigPaths from "vite-tsconfig-paths";
import dotenv from 'dotenv';

// https://vitejs.dev/config/
export default defineConfig((_env) => {
return {
define: {
'process.env': dotenv.config().parsed
},
plugins: [tsconfigPaths(), react()],
server: {
proxy: {
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,7 @@ __metadata:
"@patternfly/react-table": "npm:^5.4.0"
"@redhat-cloud-services/frontend-components": "npm:^4.2.13"
"@types/humanize-plus": "npm:^1"
dotenv: "npm:^16.4.5"
humanize-plus: "npm:^1.8.2"
lodash: "npm:^4.17.21"
prop-types: "npm:^15.8.1"
Expand Down Expand Up @@ -2579,6 +2580,13 @@ __metadata:
languageName: node
linkType: hard

"dotenv@npm:^16.4.5":
version: 16.4.5
resolution: "dotenv@npm:16.4.5"
checksum: 10c0/48d92870076832af0418b13acd6e5a5a3e83bb00df690d9812e94b24aff62b88ade955ac99a05501305b8dc8f1b0ee7638b18493deb6fe93d680e5220936292f
languageName: node
linkType: hard

"eastasianwidth@npm:^0.2.0":
version: 0.2.0
resolution: "eastasianwidth@npm:0.2.0"
Expand Down

0 comments on commit 95b5737

Please sign in to comment.