From d6612f4087f7b0a3bf24d956d2bb9c1be5c437cb Mon Sep 17 00:00:00 2001 From: Iveta Date: Mon, 10 Jun 2024 10:20:42 -0400 Subject: [PATCH 1/9] Display commit hash --- .gitignore | 2 ++ package.json | 8 ++++---- src/app/page.tsx | 34 ++++++++++++++++++++++------------ src/styles/globals.scss | 1 + 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 8e8f1e02..9956211e 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,8 @@ next-env.d.ts # generated Git info /src/generated/gitInfo.ts + +# test files /test-results/ /playwright-report/ /blob-report/ diff --git a/package.json b/package.json index 3bcb7df3..c70dc0fd 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "next dev", - "build": "next build", - "start": "next start", + "dev": "yarn git-info && next dev", + "build": "yarn git-info && next build", + "start": "yarn git-info && next start", "lint": "next lint", "lint:ts": "tsc --noEmit", "test": "playwright test", @@ -17,7 +17,7 @@ "prepare": "husky", "pre-commit": "yarn lint-staged", "pre-push": "yarn lint:ts && yarn test", - "git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo export default \"{\\\"commitHash\\\": \\\"$(git rev-parse --short HEAD)\\\", \\\"version\\\": \\\"$(git describe --tags --always)\\\"};\" > src/generated/gitInfo.ts" + "git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo \"export const gitInfo = { commitHash: \\\"$(git rev-parse --short HEAD)\\\", version: \\\"$(git describe --tags --always)\\\" };\" > src/generated/gitInfo.ts" }, "dependencies": { "@creit.tech/stellar-wallets-kit": "^0.8.2", diff --git a/src/app/page.tsx b/src/app/page.tsx index 64854cfa..ab759e48 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -6,9 +6,13 @@ import { NextLink } from "@/components/NextLink"; import { LayoutContentContainer } from "@/components/layout/LayoutContentContainer"; import { InfoCards } from "@/components/InfoCards"; import { SdsLink } from "@/components/SdsLink"; +import { Box } from "@/components/layout/Box"; + import { Routes } from "@/constants/routes"; import { openUrl } from "@/helpers/openUrl"; +import { gitInfo } from "@/generated/gitInfo"; + export default function Introduction() { const infoCards = [ { @@ -90,18 +94,24 @@ export default function Introduction() {
- - Privacy Policy - - - Terms of Service - + + + Privacy Policy + + + Terms of Service + + + + {gitInfo?.commitHash ? ( +
{`Commit hash: ${gitInfo.commitHash}`}
+ ) : null}
); diff --git a/src/styles/globals.scss b/src/styles/globals.scss index 1b585f49..b76a4dc4 100644 --- a/src/styles/globals.scss +++ b/src/styles/globals.scss @@ -405,6 +405,7 @@ flex: 1; display: flex; align-items: flex-end; + justify-content: space-between; gap: pxToRem(12px); font-size: pxToRem(14px); line-height: pxToRem(20px); From 19f83aa45ff8ec9eb66994842589e6333833fc3b Mon Sep 17 00:00:00 2001 From: Iveta Date: Mon, 10 Jun 2024 11:58:31 -0400 Subject: [PATCH 2/9] 404 page design --- src/app/not-found.tsx | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 356ffb86..463af830 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,18 +1,45 @@ "use client"; -import Link from "next/link"; +import { useRouter } from "next/navigation"; +import { Button, Card, Heading, Icon, Text } from "@stellar/design-system"; import { Routes } from "@/constants/routes"; import { LayoutContentContainer } from "@/components/layout/LayoutContentContainer"; +import { Box } from "@/components/layout/Box"; -// TODO: update 404 -// TODO: keep searchParams export default function NotFound() { + const router = useRouter(); + + const handleBackClick = () => { + router.push(Routes.ROOT); + }; + return ( -

Not Found

-

Could not find requested resource

- Return Home + + + + + Error 404 - Page not found + + + + Oops! The page you’re looking for doesn’t exist. It might have + been removed, had its name changed, or is temporarily unavailable. + + + + + +
); } From 5bffba04a6bbe89c0292e5318c22819917e113d8 Mon Sep 17 00:00:00 2001 From: Iveta Date: Mon, 10 Jun 2024 13:39:24 -0400 Subject: [PATCH 3/9] Save commit hash in env var instead of file --- package.json | 9 ++++----- src/app/page.tsx | 6 ++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index c70dc0fd..7e1d3093 100644 --- a/package.json +++ b/package.json @@ -7,17 +7,16 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "yarn git-info && next dev", - "build": "yarn git-info && next build", - "start": "yarn git-info && next start", + "dev": "export NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) && next dev", + "build": "export NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) && next build", + "start": "export NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) && next start", "lint": "next lint", "lint:ts": "tsc --noEmit", "test": "playwright test", "install-if-package-changed": "git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet yarn.lock && yarn install || exit 0", "prepare": "husky", "pre-commit": "yarn lint-staged", - "pre-push": "yarn lint:ts && yarn test", - "git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo \"export const gitInfo = { commitHash: \\\"$(git rev-parse --short HEAD)\\\", version: \\\"$(git describe --tags --always)\\\" };\" > src/generated/gitInfo.ts" + "pre-push": "yarn lint:ts && yarn test" }, "dependencies": { "@creit.tech/stellar-wallets-kit": "^0.8.2", diff --git a/src/app/page.tsx b/src/app/page.tsx index ab759e48..2d46bf64 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -11,8 +11,6 @@ import { Box } from "@/components/layout/Box"; import { Routes } from "@/constants/routes"; import { openUrl } from "@/helpers/openUrl"; -import { gitInfo } from "@/generated/gitInfo"; - export default function Introduction() { const infoCards = [ { @@ -109,8 +107,8 @@ export default function Introduction() { - {gitInfo?.commitHash ? ( -
{`Commit hash: ${gitInfo.commitHash}`}
+ {process.env.NEXT_PUBLIC_COMMIT_HASH ? ( +
{`Commit hash: ${process.env.NEXT_PUBLIC_COMMIT_HASH}`}
) : null} From a96d5c534ed275e5de8d725f69128dd9db08cba4 Mon Sep 17 00:00:00 2001 From: Iveta Date: Mon, 10 Jun 2024 14:13:41 -0400 Subject: [PATCH 4/9] Use .env.local --- package.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7e1d3093..15d4d518 100644 --- a/package.json +++ b/package.json @@ -7,16 +7,18 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "export NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) && next dev", - "build": "export NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) && next build", - "start": "export NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) && next start", + "dev": "next dev", + "build": "next build", + "start": "next start", "lint": "next lint", "lint:ts": "tsc --noEmit", "test": "playwright test", "install-if-package-changed": "git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet yarn.lock && yarn install || exit 0", "prepare": "husky", "pre-commit": "yarn lint-staged", - "pre-push": "yarn lint:ts && yarn test" + "pre-push": "yarn lint:ts && yarn test", + "git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo \"export const gitInfo = { commitHash: \\\"$(git rev-parse --short HEAD)\\\", version: \\\"$(git describe --tags --always)\\\" };\" > src/generated/gitInfo.ts", + "git-commit-hash": "rm -f .env.local && echo NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) >> .env.local" }, "dependencies": { "@creit.tech/stellar-wallets-kit": "^0.8.2", From 8a9f357e3cdda36ded79eed9bc61d62dbde94ec9 Mon Sep 17 00:00:00 2001 From: Iveta Date: Mon, 10 Jun 2024 14:14:43 -0400 Subject: [PATCH 5/9] Update scripts --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 15d4d518..39082e38 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "next dev", - "build": "next build", - "start": "next start", + "dev": "yarn git-commit-hash && next dev", + "build": "yarn git-commit-hash && next build", + "start": "yarn git-commit-hash && next start", "lint": "next lint", "lint:ts": "tsc --noEmit", "test": "playwright test", From 0207a748e062c97f86265a2cb9c55c9b6e3e5f3e Mon Sep 17 00:00:00 2001 From: Iveta Date: Mon, 10 Jun 2024 14:59:29 -0400 Subject: [PATCH 6/9] Another test --- package.json | 9 ++++----- src/app/page.tsx | 8 ++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 39082e38..b107e3f0 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "yarn git-commit-hash && next dev", - "build": "yarn git-commit-hash && next build", - "start": "yarn git-commit-hash && next start", + "dev": "yarn git-info && next dev", + "build": "yarn git-info && next build", + "start": "next start", "lint": "next lint", "lint:ts": "tsc --noEmit", "test": "playwright test", @@ -17,8 +17,7 @@ "prepare": "husky", "pre-commit": "yarn lint-staged", "pre-push": "yarn lint:ts && yarn test", - "git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo \"export const gitInfo = { commitHash: \\\"$(git rev-parse --short HEAD)\\\", version: \\\"$(git describe --tags --always)\\\" };\" > src/generated/gitInfo.ts", - "git-commit-hash": "rm -f .env.local && echo NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) >> .env.local" + "git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo \"export const gitInfo = { commitHash: \\\"$(git rev-parse --short HEAD)\\\", version: \\\"$(git describe --tags --always)\\\" };\" >> src/generated/gitInfo.ts" }, "dependencies": { "@creit.tech/stellar-wallets-kit": "^0.8.2", diff --git a/src/app/page.tsx b/src/app/page.tsx index 2d46bf64..efa785d6 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -11,6 +11,8 @@ import { Box } from "@/components/layout/Box"; import { Routes } from "@/constants/routes"; import { openUrl } from "@/helpers/openUrl"; +import { gitInfo } from "@/generated/gitInfo"; + export default function Introduction() { const infoCards = [ { @@ -53,6 +55,8 @@ export default function Introduction() { }, ]; + console.log(">>> gitInfo: ", gitInfo); + return ( @@ -107,8 +111,8 @@ export default function Introduction() { - {process.env.NEXT_PUBLIC_COMMIT_HASH ? ( -
{`Commit hash: ${process.env.NEXT_PUBLIC_COMMIT_HASH}`}
+ {gitInfo?.commitHash ? ( +
{`Commit hash: ${gitInfo.commitHash}`}
) : null}
From aa831cceee5dc297cde58e4c4b7ab517d0cd86a1 Mon Sep 17 00:00:00 2001 From: Iveta Date: Mon, 10 Jun 2024 15:37:28 -0400 Subject: [PATCH 7/9] Another experiment --- Dockerfile | 2 ++ Makefile | 2 +- package.json | 4 ++-- src/app/page.tsx | 11 ++++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 91a7f7b1..4163101d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ ENV NEXT_TELEMETRY_DISABLED 1 ENV PORT 80 WORKDIR /app COPY . . +ARG NEXT_PUBLIC_COMMIT_HASH +ENV NEXT_PUBLIC_COMMIT_HASH=$NEXT_PUBLIC_COMMIT_HASH RUN yarn install RUN yarn build # Run on port 80 for compatibility with laboratory v1 diff --git a/Makefile b/Makefile index deeec1b0..e669262d 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ TAG ?= stellar/laboratory:$(LABEL) BUILD_DATE := $(shell date -u +%FT%TZ) docker-build: - $(SUDO) docker build --pull --label org.opencontainers.image.created="$(BUILD_DATE)" -t $(TAG) . + $(SUDO) docker build --pull --label org.opencontainers.image.created="$(BUILD_DATE)" -t $(TAG) --build-arg NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) . docker-push: $(SUDO) docker push $(TAG) diff --git a/package.json b/package.json index b107e3f0..896cecaf 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "yarn git-info && next dev", - "build": "yarn git-info && next build", + "dev": "export NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) && next dev", + "build": "next build", "start": "next start", "lint": "next lint", "lint:ts": "tsc --noEmit", diff --git a/src/app/page.tsx b/src/app/page.tsx index efa785d6..9e063dfb 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -11,8 +11,6 @@ import { Box } from "@/components/layout/Box"; import { Routes } from "@/constants/routes"; import { openUrl } from "@/helpers/openUrl"; -import { gitInfo } from "@/generated/gitInfo"; - export default function Introduction() { const infoCards = [ { @@ -55,7 +53,10 @@ export default function Introduction() { }, ]; - console.log(">>> gitInfo: ", gitInfo); + console.log( + ">>> process.env.NEXT_PUBLIC_COMMIT_HASH: ", + process.env.NEXT_PUBLIC_COMMIT_HASH, + ); return ( @@ -111,8 +112,8 @@ export default function Introduction() { - {gitInfo?.commitHash ? ( -
{`Commit hash: ${gitInfo.commitHash}`}
+ {process.env.NEXT_PUBLIC_COMMIT_HASH ? ( +
{`Commit hash: ${process.env.NEXT_PUBLIC_COMMIT_HASH}`}
) : null}
From 627c69c3a633a2411665cbbc6a2eb1424a3ee331 Mon Sep 17 00:00:00 2001 From: Iveta Date: Tue, 11 Jun 2024 09:00:40 -0400 Subject: [PATCH 8/9] Tweak Docker config --- Dockerfile | 1 - Makefile | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4163101d..2995a210 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ ENV PORT 80 WORKDIR /app COPY . . ARG NEXT_PUBLIC_COMMIT_HASH -ENV NEXT_PUBLIC_COMMIT_HASH=$NEXT_PUBLIC_COMMIT_HASH RUN yarn install RUN yarn build # Run on port 80 for compatibility with laboratory v1 diff --git a/Makefile b/Makefile index e669262d..26d3bc9f 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ TAG ?= stellar/laboratory:$(LABEL) BUILD_DATE := $(shell date -u +%FT%TZ) docker-build: - $(SUDO) docker build --pull --label org.opencontainers.image.created="$(BUILD_DATE)" -t $(TAG) --build-arg NEXT_PUBLIC_COMMIT_HASH=$(git rev-parse --short HEAD) . + $(SUDO) docker build --pull --label org.opencontainers.image.created="$(BUILD_DATE)" -t $(TAG) --build-arg=NEXT_PUBLIC_COMMIT_HASH="$(shell git rev-parse --short HEAD)" . docker-push: $(SUDO) docker push $(TAG) From ea0e3e35d7d53fbc0562c9913fcb829603deac45 Mon Sep 17 00:00:00 2001 From: Iveta Date: Tue, 11 Jun 2024 09:13:55 -0400 Subject: [PATCH 9/9] Cleanup --- .gitignore | 6 ------ Dockerfile | 1 + package.json | 3 +-- src/app/page.tsx | 5 ----- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 9956211e..50d2e64e 100644 --- a/.gitignore +++ b/.gitignore @@ -36,12 +36,6 @@ yarn-error.log* *.tsbuildinfo next-env.d.ts -# env variables -/public/settings/env-config.js - -# generated Git info -/src/generated/gitInfo.ts - # test files /test-results/ /playwright-report/ diff --git a/Dockerfile b/Dockerfile index 2995a210..0e8166b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ ENV NEXT_TELEMETRY_DISABLED 1 ENV PORT 80 WORKDIR /app COPY . . +# Passing env var to be used on client side ARG NEXT_PUBLIC_COMMIT_HASH RUN yarn install RUN yarn build diff --git a/package.json b/package.json index 896cecaf..57373818 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,7 @@ "install-if-package-changed": "git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet yarn.lock && yarn install || exit 0", "prepare": "husky", "pre-commit": "yarn lint-staged", - "pre-push": "yarn lint:ts && yarn test", - "git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo \"export const gitInfo = { commitHash: \\\"$(git rev-parse --short HEAD)\\\", version: \\\"$(git describe --tags --always)\\\" };\" >> src/generated/gitInfo.ts" + "pre-push": "yarn lint:ts && yarn test" }, "dependencies": { "@creit.tech/stellar-wallets-kit": "^0.8.2", diff --git a/src/app/page.tsx b/src/app/page.tsx index 9e063dfb..2d46bf64 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -53,11 +53,6 @@ export default function Introduction() { }, ]; - console.log( - ">>> process.env.NEXT_PUBLIC_COMMIT_HASH: ", - process.env.NEXT_PUBLIC_COMMIT_HASH, - ); - return (