From 7d681c703fdbc2f910d0cc6f4b3ae11ab658e9ee Mon Sep 17 00:00:00 2001 From: Evan Stohlmann Date: Wed, 25 Sep 2024 23:47:04 -0600 Subject: [PATCH 1/2] adding LISA version to dropdown in UI --- lib/user-interface/react/index.html | 1 + lib/user-interface/react/package-lock.json | 38 ++++++++++++------- lib/user-interface/react/package.json | 7 ++-- .../react/scripts/set-revision-info.mjs | 32 ++++++++++++++++ .../react/src/components/Topbar.tsx | 3 +- lib/user-interface/react/src/main.tsx | 4 ++ 6 files changed, 68 insertions(+), 17 deletions(-) create mode 100755 lib/user-interface/react/scripts/set-revision-info.mjs diff --git a/lib/user-interface/react/index.html b/lib/user-interface/react/index.html index c5d1f63..5c14dc5 100644 --- a/lib/user-interface/react/index.html +++ b/lib/user-interface/react/index.html @@ -6,6 +6,7 @@ AWS LISA Chatbot +
diff --git a/lib/user-interface/react/package-lock.json b/lib/user-interface/react/package-lock.json index d9701eb..02d47db 100644 --- a/lib/user-interface/react/package-lock.json +++ b/lib/user-interface/react/package-lock.json @@ -1,12 +1,12 @@ { - "name": "react", - "version": "0.0.0", + "name": "lisa-web", + "version": "3.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "react", - "version": "0.0.0", + "name": "lisa-web", + "version": "3.0.1", "dependencies": { "@cloudscape-design/collection-hooks": "^1.0.23", "@cloudscape-design/component-toolkit": "^1.0.0-beta.65", @@ -16,6 +16,7 @@ "@microsoft/fetch-event-source": "^2.0.1", "@reduxjs/toolkit": "^1.9.5", "axios": "^1.7.4", + "git-repo-info": "^2.1.1", "langchain": "^0.1.12", "lodash": "^4.17.21", "luxon": "^3.4.0", @@ -3536,6 +3537,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/git-repo-info": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/git-repo-info/-/git-repo-info-2.1.1.tgz", + "integrity": "sha512-8aCohiDo4jwjOwma4FmYFd3i97urZulL8XL24nIPxuE+GZnfsAyy/g2Shqx6OjUiFKUXZM+Yy+KHnOmmA3FVcg==", + "license": "MIT", + "engines": { + "node": ">= 4.0" + } + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -5145,9 +5155,9 @@ ] }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "license": "MIT", "dependencies": { "braces": "^3.0.3", @@ -6315,10 +6325,11 @@ } }, "node_modules/rollup": { - "version": "3.29.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", - "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", + "version": "3.29.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.5.tgz", + "integrity": "sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w==", "dev": true, + "license": "MIT", "bin": { "rollup": "dist/bin/rollup" }, @@ -7351,10 +7362,11 @@ } }, "node_modules/vite": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.3.tgz", - "integrity": "sha512-kQL23kMeX92v3ph7IauVkXkikdDRsYMGTVl5KY2E9OY4ONLvkHf04MDTbnfo6NKxZiDLWzVpP5oTa8hQD8U3dg==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.5.tgz", + "integrity": "sha512-ifW3Lb2sMdX+WU91s3R0FyQlAyLxOzCSCP37ujw0+r5POeHPwe6udWVIElKQq8gk3t7b8rkmvqC6IHBpCff4GQ==", "dev": true, + "license": "MIT", "dependencies": { "esbuild": "^0.18.10", "postcss": "^8.4.27", diff --git a/lib/user-interface/react/package.json b/lib/user-interface/react/package.json index ca80ed9..30f4097 100644 --- a/lib/user-interface/react/package.json +++ b/lib/user-interface/react/package.json @@ -1,11 +1,11 @@ { - "name": "react", + "name": "lisa-web", "private": true, - "version": "0.0.0", + "version": "3.0.1", "type": "module", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build": "node ./scripts/set-revision-info.mjs && tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", "format": "prettier --ignore-path .gitignore --write \"**/*.+(tsx|js|ts|json)\"" @@ -19,6 +19,7 @@ "@microsoft/fetch-event-source": "^2.0.1", "@reduxjs/toolkit": "^1.9.5", "axios": "^1.7.4", + "git-repo-info": "^2.1.1", "langchain": "^0.1.12", "lodash": "^4.17.21", "luxon": "^3.4.0", diff --git a/lib/user-interface/react/scripts/set-revision-info.mjs b/lib/user-interface/react/scripts/set-revision-info.mjs new file mode 100755 index 0000000..fb1d27f --- /dev/null +++ b/lib/user-interface/react/scripts/set-revision-info.mjs @@ -0,0 +1,32 @@ +/** + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import getRepoInfo from 'git-repo-info'; +import fs from 'fs'; +import packageFile from '../package.json' with { type: 'json' }; + + +const info = getRepoInfo(); +console.log('Git Revision Info:'); +console.log('Version:', packageFile.version); +console.log('Latest hash:', info.abbreviatedSha); + +const revInfo = `window.gitInfo = { + revisionTag: '${packageFile.version}', + gitHash: '${info.abbreviatedSha}', +}; +`; + +fs.writeFileSync('./public/git-info.js', revInfo); diff --git a/lib/user-interface/react/src/components/Topbar.tsx b/lib/user-interface/react/src/components/Topbar.tsx index 1e650e6..2759ca1 100644 --- a/lib/user-interface/react/src/components/Topbar.tsx +++ b/lib/user-interface/react/src/components/Topbar.tsx @@ -107,7 +107,8 @@ function Topbar () { } }, iconName: 'user-profile', - items: [auth.isAuthenticated ? { id: 'signout', text: 'Sign out' } : { id: 'signin', text: 'Sign in' }], + items: [{id: 'version-info', text: `LISA v${window.gitInfo?.revisionTag}`, disabled: true}, + auth.isAuthenticated ? { id: 'signout', text: 'Sign out' } : { id: 'signin', text: 'Sign in' }], }, { type: 'button', diff --git a/lib/user-interface/react/src/main.tsx b/lib/user-interface/react/src/main.tsx index c5aa98e..039ff81 100644 --- a/lib/user-interface/react/src/main.tsx +++ b/lib/user-interface/react/src/main.tsx @@ -50,6 +50,10 @@ declare global { }, ]; }; + gitInfo?: { + revisionTag?: string; + gitHash?: string; + }; } } From 8404beb713eaefda7b5cb3ab8674a230a51cb11e Mon Sep 17 00:00:00 2001 From: Evan Stohlmann Date: Wed, 25 Sep 2024 23:54:48 -0600 Subject: [PATCH 2/2] adding LISA version to dropdown in UI --- .github/workflows/code.hotfix.branch.yml | 1 + .github/workflows/code.release.branch.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/code.hotfix.branch.yml b/.github/workflows/code.hotfix.branch.yml index 3155c72..34df320 100644 --- a/.github/workflows/code.hotfix.branch.yml +++ b/.github/workflows/code.hotfix.branch.yml @@ -30,6 +30,7 @@ jobs: DST_TAG=${{ github.event.inputs.dest_tag }} git checkout -b hotfix/${{ github.event.inputs.dest_tag }} sed -i -e "s/\"version\": \"${SRC_TAG:1}\"/\"version\": \"${DST_TAG:1}\"/g" package.json + sed -i -e "s/\"version\": \"${SRC_TAG:1}\"/\"version\": \"${DST_TAG:1}\"/g" lib/user-interface/react/package.json sed -i -e "s/version = \"${SRC_TAG:1}\"/version = \"${DST_TAG:1}\"/g" lisa-sdk/pyproject.toml sed -i -e "s/${SRC_TAG:1}/${DST_TAG:1}/g" VERSION git commit -a -m "Updating version for hotfix ${{ github.event.inputs.dest_tag }}" diff --git a/.github/workflows/code.release.branch.yml b/.github/workflows/code.release.branch.yml index 9d59f6d..4b8e07b 100644 --- a/.github/workflows/code.release.branch.yml +++ b/.github/workflows/code.release.branch.yml @@ -25,6 +25,7 @@ jobs: git config --global user.name "github_actions_lisa" RELEASE_TAG=${{ github.event.inputs.release_tag }} git checkout -b release/${{ github.event.inputs.release_tag }} + echo "$( jq --arg version ${RELEASE_TAG:1} '.version = $version' lib/user-interface/react/package.json )" > lib/user-interface/react/package.json echo "$( jq --arg version ${RELEASE_TAG:1} '.version = $version' package.json )" > package.json sed -E -i -e "s/version = \"[0-9\.].+\"/version = \"${RELEASE_TAG:1}\"/g" lisa-sdk/pyproject.toml echo ${RELEASE_TAG:1} > VERSION