mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
add version information
This commit is contained in:
parent
08615fe9f6
commit
ea6a668a84
@ -22,6 +22,10 @@ RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm i
|
|||||||
FROM node:current-alpine AS builder
|
FROM node:current-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
ARG BUILDTIME
|
||||||
|
ARG VERSION
|
||||||
|
ARG REVISION
|
||||||
|
|
||||||
COPY --link --from=deps /app/node_modules ./node_modules/
|
COPY --link --from=deps /app/node_modules ./node_modules/
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
@ -29,7 +33,7 @@ RUN <<EOF
|
|||||||
set -xe
|
set -xe
|
||||||
yarn next telemetry disable
|
yarn next telemetry disable
|
||||||
mkdir config && echo '-' > config/settings.yaml
|
mkdir config && echo '-' > config/settings.yaml
|
||||||
npm run build
|
NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
# Production image, copy all the files and run next
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"@headlessui/react": "^1.7.0",
|
"@headlessui/react": "^1.7.0",
|
||||||
"@tailwindcss/forms": "^0.5.3",
|
"@tailwindcss/forms": "^0.5.3",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
|
"compare-versions": "^5.0.1",
|
||||||
"dockerode": "^3.3.4",
|
"dockerode": "^3.3.4",
|
||||||
"follow-redirects": "^1.15.2",
|
"follow-redirects": "^1.15.2",
|
||||||
"i18next": "^21.9.1",
|
"i18next": "^21.9.1",
|
||||||
|
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@ -5,6 +5,7 @@ specifiers:
|
|||||||
'@tailwindcss/forms': ^0.5.3
|
'@tailwindcss/forms': ^0.5.3
|
||||||
autoprefixer: ^10.4.9
|
autoprefixer: ^10.4.9
|
||||||
classnames: ^2.3.1
|
classnames: ^2.3.1
|
||||||
|
compare-versions: ^5.0.1
|
||||||
dockerode: ^3.3.4
|
dockerode: ^3.3.4
|
||||||
eslint: ^8.23.1
|
eslint: ^8.23.1
|
||||||
eslint-config-airbnb: ^19.0.4
|
eslint-config-airbnb: ^19.0.4
|
||||||
@ -45,6 +46,7 @@ dependencies:
|
|||||||
'@headlessui/react': 1.7.0_biqbaboplfbrettd7655fr4n2y
|
'@headlessui/react': 1.7.0_biqbaboplfbrettd7655fr4n2y
|
||||||
'@tailwindcss/forms': 0.5.3_tailwindcss@3.1.8
|
'@tailwindcss/forms': 0.5.3_tailwindcss@3.1.8
|
||||||
classnames: 2.3.1
|
classnames: 2.3.1
|
||||||
|
compare-versions: 5.0.1
|
||||||
dockerode: 3.3.4
|
dockerode: 3.3.4
|
||||||
follow-redirects: 1.15.2
|
follow-redirects: 1.15.2
|
||||||
i18next: 21.9.1
|
i18next: 21.9.1
|
||||||
@ -715,6 +717,10 @@ packages:
|
|||||||
delayed-stream: 1.0.0
|
delayed-stream: 1.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/compare-versions/5.0.1:
|
||||||
|
resolution: {integrity: sha512-v8Au3l0b+Nwkp4G142JcgJFh1/TUhdxut7wzD1Nq1dyp5oa3tXaqb03EXOAB6jS4gMlalkjAUPZBMiAfKUixHQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/concat-map/0.0.1:
|
/concat-map/0.0.1:
|
||||||
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
47
src/components/version.jsx
Normal file
47
src/components/version.jsx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import useSWR from "swr";
|
||||||
|
import { compareVersions } from "compare-versions";
|
||||||
|
import { MdNewReleases } from "react-icons/md";
|
||||||
|
|
||||||
|
export default function Version() {
|
||||||
|
const { t, i18n } = useTranslation();
|
||||||
|
|
||||||
|
const buildTime = process.env.NEXT_PUBLIC_BUILDTIME ?? new Date().toISOString();
|
||||||
|
const revision = process.env.NEXT_PUBLIC_REVISION ?? "dev";
|
||||||
|
const version = process.env.NEXT_PUBLIC_VERSION ?? "dev";
|
||||||
|
|
||||||
|
const { data: releaseData } = useSWR("https://api.github.com/repos/benphelps/homepage/releases");
|
||||||
|
|
||||||
|
// use Intl.DateTimeFormat to format the date
|
||||||
|
const formatDate = (date) => {
|
||||||
|
const options = {
|
||||||
|
year: "numeric",
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
};
|
||||||
|
return new Intl.DateTimeFormat(i18n.language, options).format(new Date(date));
|
||||||
|
};
|
||||||
|
|
||||||
|
const latestRelease = releaseData?.[0];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-row items-center">
|
||||||
|
<span className="text-xs text-theme-500 opacity-50">
|
||||||
|
{version} ({revision.substring(0, 7)}, {formatDate(buildTime)})
|
||||||
|
</span>
|
||||||
|
{version === "main" || version === "dev"
|
||||||
|
? null
|
||||||
|
: releaseData &&
|
||||||
|
compareVersions(latestRelease.tag_name, version) > 0 && (
|
||||||
|
<a
|
||||||
|
href={latestRelease.html_url}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="ml-2 text-xs text-theme-500 opacity-50 flex flex-row items-center"
|
||||||
|
>
|
||||||
|
<MdNewReleases className="mr-1" /> {t("Update Available")}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
@ -24,12 +24,16 @@ const ColorToggle = dynamic(() => import("components/color-toggle"), {
|
|||||||
ssr: false,
|
ssr: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const Version = dynamic(() => import("components/version"), {
|
||||||
|
ssr: false,
|
||||||
|
});
|
||||||
|
|
||||||
const rightAlignedWidgets = ["weatherapi", "openweathermap", "weather", "search", "datetime"];
|
const rightAlignedWidgets = ["weatherapi", "openweathermap", "weather", "search", "datetime"];
|
||||||
|
|
||||||
export function getStaticProps() {
|
export function getStaticProps() {
|
||||||
let logger;
|
let logger;
|
||||||
try {
|
try {
|
||||||
logger = createLogger('index');
|
logger = createLogger("index");
|
||||||
const { providers, ...settings } = getSettings();
|
const { providers, ...settings } = getSettings();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -38,7 +42,9 @@ export function getStaticProps() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (logger) { logger.error(e); }
|
if (logger) {
|
||||||
|
logger.error(e);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
initialSettings: {},
|
initialSettings: {},
|
||||||
@ -157,11 +163,15 @@ function Home({ initialSettings }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="rounded-full flex p-8 w-full justify-end">
|
<div className="flex p-8 pb-0 w-full justify-end">
|
||||||
{!settings?.color && <ColorToggle />}
|
{!settings?.color && <ColorToggle />}
|
||||||
<Revalidate />
|
<Revalidate />
|
||||||
{!settings?.theme && <ThemeToggle />}
|
{!settings?.theme && <ThemeToggle />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex p-8 pt-4 w-full justify-end">
|
||||||
|
<Version />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user