Merge branch 'dev' into useQuery-stale-time-cache

This commit is contained in:
Thomas Camlong
2023-02-02 18:59:09 +09:00
committed by GitHub
23 changed files with 121 additions and 39 deletions

View File

@@ -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

View 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 }));
},
}));

View 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';
};