mirror of
https://github.com/ajnart/homarr.git
synced 2026-03-06 04:11:04 +01:00
Merge branch 'dev' into useQuery-stale-time-cache
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
import Dockerode from 'dockerode';
|
||||
import { Config, MatchingImages, ServiceType, tryMatchPort } from './types';
|
||||
|
||||
async function MatchIcon(name: string) {
|
||||
const res = await fetch(
|
||||
`https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${name
|
||||
.replace(/\s+/g, '-')
|
||||
.toLowerCase()}.png`
|
||||
);
|
||||
return res.ok ? res.url : '/imgs/favicon/favicon.png';
|
||||
}
|
||||
import { MatchingImages, ServiceType, tryMatchPort } from './types';
|
||||
|
||||
function tryMatchType(imageName: string): ServiceType {
|
||||
// Try to find imageName inside MatchingImages
|
||||
|
||||
15
src/tools/client/zustands/usePackageAttributesStore.ts
Normal file
15
src/tools/client/zustands/usePackageAttributesStore.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import create from 'zustand';
|
||||
|
||||
import { ServerSidePackageAttributesType } from '../../server/getPackageVersion';
|
||||
|
||||
interface PackageAttributesState {
|
||||
attributes: ServerSidePackageAttributesType;
|
||||
setInitialPackageAttributes: (attributes: ServerSidePackageAttributesType) => void;
|
||||
}
|
||||
|
||||
export const usePackageAttributesStore = create<PackageAttributesState>((set) => ({
|
||||
attributes: { packageVersion: undefined, environment: 'test' },
|
||||
setInitialPackageAttributes(attributes) {
|
||||
set((state) => ({ ...state, attributes }));
|
||||
},
|
||||
}));
|
||||
14
src/tools/server/getPackageVersion.ts
Normal file
14
src/tools/server/getPackageVersion.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
const getServerPackageVersion = (): string | undefined => process.env.npm_package_version;
|
||||
|
||||
const getServerNodeEnvironment = (): 'development' | 'production' | 'test' =>
|
||||
process.env.NODE_ENV;
|
||||
|
||||
export const getServiceSidePackageAttributes = (): ServerSidePackageAttributesType => ({
|
||||
packageVersion: getServerPackageVersion(),
|
||||
environment: getServerNodeEnvironment(),
|
||||
});
|
||||
|
||||
export type ServerSidePackageAttributesType = {
|
||||
packageVersion: string | undefined;
|
||||
environment: 'development' | 'production' | 'test';
|
||||
};
|
||||
Reference in New Issue
Block a user