Add a load of fallbacks and rework the docker bits
All checks were successful
Build and deploy / deploy (push) Successful in 1m58s
All checks were successful
Build and deploy / deploy (push) Successful in 1m58s
This commit is contained in:
14
biome.jsonc
14
biome.jsonc
@@ -5,9 +5,17 @@
|
|||||||
"clientKind": "git",
|
"clientKind": "git",
|
||||||
"useIgnoreFile": true
|
"useIgnoreFile": true
|
||||||
},
|
},
|
||||||
"files": { "ignoreUnknown": false, "ignore": [] },
|
"files": {
|
||||||
"formatter": { "enabled": true },
|
"ignoreUnknown": false,
|
||||||
"organizeImports": { "enabled": true },
|
"ignore": []
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"lineWidth": 200
|
||||||
|
},
|
||||||
|
"organizeImports": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|||||||
92
package.json
92
package.json
@@ -1,47 +1,47 @@
|
|||||||
{
|
{
|
||||||
"name": "dvdash",
|
"name": "dvdash",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"check": "biome check .",
|
"check": "biome check .",
|
||||||
"check:unsafe": "biome check --write --unsafe .",
|
"check:unsafe": "biome check --write --unsafe .",
|
||||||
"check:write": "biome check --write .",
|
"check:write": "biome check --write .",
|
||||||
"dev": "next dev --turbo",
|
"dev": "next dev --turbo",
|
||||||
"preview": "next build && next start",
|
"preview": "next build && next start",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"update-regctl": "mkdir bin && curl -L https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 >bin/regctl && chmod 755 bin/regctl"
|
"update-regctl": "mkdir bin && curl -L https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 >bin/regctl && chmod 755 bin/regctl"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@t3-oss/env-nextjs": "^0.13.0",
|
"@t3-oss/env-nextjs": "^0.13.0",
|
||||||
"@tailwindcss/postcss": "^4.1.4",
|
"@tailwindcss/postcss": "^4.1.4",
|
||||||
"@tanstack/react-query": "^5.74.4",
|
"@tanstack/react-query": "^5.74.4",
|
||||||
"@trpc/client": "^11.1.1",
|
"@trpc/client": "^11.1.1",
|
||||||
"@trpc/react-query": "^11.1.1",
|
"@trpc/react-query": "^11.1.1",
|
||||||
"@trpc/server": "^11.1.1",
|
"@trpc/server": "^11.1.1",
|
||||||
"daisyui": "^5.0.28",
|
"daisyui": "^5.0.28",
|
||||||
"dockerode": "^4.0.6",
|
"dockerode": "^4.0.6",
|
||||||
"next": "^15.3.1",
|
"next": "^15.3.1",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"semver": "^7.7.1",
|
"semver": "^7.7.1",
|
||||||
"server-only": "^0.0.1",
|
"server-only": "^0.0.1",
|
||||||
"superjson": "^2.2.2",
|
"superjson": "^2.2.2",
|
||||||
"zod": "^3.24.3",
|
"zod": "^3.24.3",
|
||||||
"zx": "^8.5.3",
|
"zx": "^8.5.3",
|
||||||
"@biomejs/biome": "1.9.4",
|
"@biomejs/biome": "1.9.4",
|
||||||
"@types/bun": "^1.2.10",
|
"@types/bun": "^1.2.10",
|
||||||
"@types/dockerode": "^3.3.38",
|
"@types/dockerode": "^3.3.38",
|
||||||
"@types/react": "19.1.2",
|
"@types/react": "19.1.2",
|
||||||
"@types/react-dom": "^19.1.2",
|
"@types/react-dom": "^19.1.2",
|
||||||
"@types/semver": "^7.7.0",
|
"@types/semver": "^7.7.0",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.5.3",
|
||||||
"tailwindcss": "^4.1.4",
|
"tailwindcss": "^4.1.4",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
},
|
},
|
||||||
"ct3aMetadata": {
|
"ct3aMetadata": {
|
||||||
"initVersion": "7.39.3"
|
"initVersion": "7.39.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ const handler = (req: NextRequest) =>
|
|||||||
onError:
|
onError:
|
||||||
env.NODE_ENV === "development"
|
env.NODE_ENV === "development"
|
||||||
? ({ path, error }) => {
|
? ({ path, error }) => {
|
||||||
console.error(
|
console.error(`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`);
|
||||||
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,9 +16,7 @@ const geist = Geist({
|
|||||||
variable: "--font-geist-sans",
|
variable: "--font-geist-sans",
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||||
children,
|
|
||||||
}: Readonly<{ children: React.ReactNode }>) {
|
|
||||||
return (
|
return (
|
||||||
<html lang="en" className={`${geist.variable}`}>
|
<html lang="en" className={`${geist.variable}`}>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -16,45 +16,34 @@ export default async function Home() {
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Image</th>
|
<th>Image</th>
|
||||||
<th>Version</th>
|
<th>Tag</th>
|
||||||
<th>Short Hash</th>
|
<th>Short Hash</th>
|
||||||
<th>Version</th>
|
<th>Tag</th>
|
||||||
<th>Short Hash</th>
|
<th>Short Hash</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{list
|
{list
|
||||||
.sort((ca, cb) => {
|
.sort((ca, cb) => {
|
||||||
if (ca.Names[0] && cb.Names[0]) {
|
if (ca.containerName && cb.containerName) {
|
||||||
if (ca.Names[0] < cb.Names[0]) {
|
if (ca.containerName < cb.containerName) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ca.Names[0] > cb.Names[0]) {
|
if (ca.containerName > cb.containerName) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
})
|
})
|
||||||
.map((containerInfo) => {
|
.map((containerInfo) => {
|
||||||
const outdated =
|
const outdated = containerInfo.current.hash !== containerInfo.latest.hash;
|
||||||
containerInfo.current.version !==
|
|
||||||
containerInfo.latest.version ||
|
|
||||||
containerInfo.current.hash !==
|
|
||||||
containerInfo.latest.hash;
|
|
||||||
return (
|
return (
|
||||||
<tr
|
<tr key={containerInfo.containerName} className={`${outdated ? "bg-base-200" : null}`}>
|
||||||
key={containerInfo.Image.split(":")[0]}
|
<td className={`border-l-8 ${outdated ? "border-l-error/80" : "border-l-info/80"}`}>{containerInfo.containerName}</td>
|
||||||
className={`${outdated ? "bg-base-200" : null}`}
|
<td>{containerInfo.imageName}</td>
|
||||||
>
|
<td>{containerInfo.current.tag}</td>
|
||||||
<td
|
|
||||||
className={`border-l-8 ${outdated ? "border-l-error/80" : "border-l-info/80"}`}
|
|
||||||
>
|
|
||||||
{containerInfo.Names[0]?.substring(1)}
|
|
||||||
</td>
|
|
||||||
<td>{containerInfo.Image.split(":")[0]}</td>
|
|
||||||
<td>{containerInfo.current.version}</td>
|
|
||||||
<td>{containerInfo.current.hash}</td>
|
<td>{containerInfo.current.hash}</td>
|
||||||
<td>{containerInfo.latest.version}</td>
|
<td>{containerInfo.latest.tag}</td>
|
||||||
<td>{containerInfo.latest.hash}</td>
|
<td>{containerInfo.latest.hash}</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,38 +18,46 @@ export const dockerRouter = createTRPCRouter({
|
|||||||
|
|
||||||
// curl -fsSL -v -H "Accept: application/json" "hub.docker.com/v2/repositories/linuxserver/code-server/tags?n=25&ordering=last_updated"
|
// curl -fsSL -v -H "Accept: application/json" "hub.docker.com/v2/repositories/linuxserver/code-server/tags?n=25&ordering=last_updated"
|
||||||
|
|
||||||
return Promise.all(
|
const dockerInfo = await Promise.all(
|
||||||
containers.map(async (container) => {
|
containers.map(async (container) => {
|
||||||
const version = (
|
const imageInspect = await docker.getImage(container.Image).inspect();
|
||||||
await docker.getImage(container.Image).inspect()
|
const imageDigest = imageInspect.RepoDigests[0];
|
||||||
).RepoTags[0]?.split(":")[1];
|
const containerInspect = docker.getContainer(container.Id);
|
||||||
const latest = {
|
|
||||||
version: version,
|
let imageTag = imageInspect.RepoTags[0]?.split(":")[1];
|
||||||
hash: "N/A",
|
|
||||||
|
let imageName = imageDigest?.split("@")?.[0];
|
||||||
|
imageName ??= container.Image.split(":")[0] ?? undefined;
|
||||||
|
|
||||||
|
const imageHash = imageDigest?.split("@")?.[1]?.split(":")?.[1];
|
||||||
|
imageTag ??= (await containerInspect.inspect()).Config.Image.split(":")[1] ?? undefined;
|
||||||
|
|
||||||
|
const current = {
|
||||||
|
hash: imageHash?.substring(0, 12),
|
||||||
|
tag: imageTag,
|
||||||
};
|
};
|
||||||
if (version && isSemver(version)) {
|
|
||||||
latest.version = await getLatestSemverTag(container.Image);
|
let latest: {
|
||||||
latest.hash = await getLatestHash(
|
hash?: string;
|
||||||
`${container.Image.split(":")[0]}:${latest.version}`,
|
tag?: string;
|
||||||
);
|
} = {
|
||||||
} else {
|
hash: "",
|
||||||
latest.hash = await getLatestHash(container.Image);
|
tag: "",
|
||||||
|
};
|
||||||
|
if (imageName) {
|
||||||
|
latest = await getLatest(imageName, current.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...container,
|
containerName: container.Names[0]?.replace("/", ""),
|
||||||
current: {
|
imageName,
|
||||||
version,
|
current,
|
||||||
hash: (
|
|
||||||
await docker.getImage(container.Image).inspect()
|
|
||||||
).RepoDigests[0]
|
|
||||||
?.split(":")[1]
|
|
||||||
?.substring(0, 12),
|
|
||||||
},
|
|
||||||
latest,
|
latest,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return dockerInfo;
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -58,27 +66,58 @@ function isSemver(tag: string): boolean {
|
|||||||
return !!semver.valid(removeV);
|
return !!semver.valid(removeV);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLatestSemverTag(image: string): Promise<string> {
|
async function getLatestSemverTag(image: string, tag?: string): Promise<{ hash: string; tag?: string }> {
|
||||||
try {
|
try {
|
||||||
const allTags =
|
const latest = {
|
||||||
await $`bin/regctl tag ls --exclude 'version.*' --exclude 'unstable.*' --exclude '.*rc.*' --exclude 'lib.*' --exclude 'release.*' --exclude 'arm.*
|
hash: "",
|
||||||
|
tag: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
const allTags = await $`bin/regctl tag ls --exclude 'version.*' --exclude 'unstable.*' --exclude '.*rc.*' --exclude 'lib.*' --exclude 'release.*' --exclude 'arm.*
|
||||||
' --exclude 'amd.*' ${image}`.text();
|
' --exclude 'amd.*' ${image}`.text();
|
||||||
const semverTags = allTags
|
const semverTags = allTags.split("\n").filter((tag) => isSemver(tag));
|
||||||
.split("\n")
|
const newestTag = semver.rsort(semverTags)[0];
|
||||||
.slice(-20)
|
|
||||||
.filter((tag) => isSemver(tag));
|
let imageSh = image;
|
||||||
return semver.rsort(semverTags)[0] ?? "Error";
|
if (newestTag) {
|
||||||
|
imageSh += `:${newestTag}`;
|
||||||
|
latest.tag = newestTag;
|
||||||
|
}
|
||||||
|
const latestImage = await $`bin/regctl image digest ${imageSh}`.text();
|
||||||
|
latest.hash = latestImage.split(":")?.[1]?.substring(0, 12) ?? "Error";
|
||||||
|
|
||||||
|
return latest;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
return "Error";
|
console.error((ex as unknown as Error).message);
|
||||||
|
return {
|
||||||
|
hash: "Error",
|
||||||
|
tag: "Error",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLatestHash(image: string): Promise<string> {
|
async function getLatest(image: string, tag?: string): Promise<{ hash: string; tag?: string }> {
|
||||||
try {
|
try {
|
||||||
const latestImage = await $`bin/regctl image digest ${image}`.text();
|
let latest: { hash: string; tag?: string } = {
|
||||||
const latestHash = latestImage.split(":")?.[1];
|
hash: "",
|
||||||
return latestHash?.substring(0, 12) ?? "Error";
|
tag: tag,
|
||||||
|
};
|
||||||
|
if (tag && isSemver(tag)) {
|
||||||
|
latest = await getLatestSemverTag(image, tag);
|
||||||
|
} else {
|
||||||
|
let imageSh = image;
|
||||||
|
if (tag) {
|
||||||
|
imageSh += `:${tag}`;
|
||||||
|
}
|
||||||
|
const latestImage = await $`bin/regctl image digest ${imageSh}`.text();
|
||||||
|
latest.hash = latestImage.split(":")?.[1]?.substring(0, 12) ?? "Error";
|
||||||
|
}
|
||||||
|
return latest;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
return "Error";
|
console.error((ex as unknown as Error).message);
|
||||||
|
return {
|
||||||
|
hash: "Error",
|
||||||
|
tag: "Error",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ const t = initTRPC.context<typeof createTRPCContext>().create({
|
|||||||
...shape,
|
...shape,
|
||||||
data: {
|
data: {
|
||||||
...shape.data,
|
...shape.data,
|
||||||
zodError:
|
zodError: error.cause instanceof ZodError ? error.cause.flatten() : null,
|
||||||
error.cause instanceof ZodError ? error.cause.flatten() : null,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,6 +5,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@theme {
|
@theme {
|
||||||
--font-sans: var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif,
|
--font-sans: var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||||
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import {
|
import { QueryClient, defaultShouldDehydrateQuery } from "@tanstack/react-query";
|
||||||
QueryClient,
|
|
||||||
defaultShouldDehydrateQuery,
|
|
||||||
} from "@tanstack/react-query";
|
|
||||||
import SuperJSON from "superjson";
|
import SuperJSON from "superjson";
|
||||||
|
|
||||||
export const createQueryClient = () =>
|
export const createQueryClient = () =>
|
||||||
@@ -14,9 +11,7 @@ export const createQueryClient = () =>
|
|||||||
},
|
},
|
||||||
dehydrate: {
|
dehydrate: {
|
||||||
serializeData: SuperJSON.serialize,
|
serializeData: SuperJSON.serialize,
|
||||||
shouldDehydrateQuery: (query) =>
|
shouldDehydrateQuery: (query) => defaultShouldDehydrateQuery(query) || query.state.status === "pending",
|
||||||
defaultShouldDehydrateQuery(query) ||
|
|
||||||
query.state.status === "pending",
|
|
||||||
},
|
},
|
||||||
hydrate: {
|
hydrate: {
|
||||||
deserializeData: SuperJSON.deserialize,
|
deserializeData: SuperJSON.deserialize,
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ export function TRPCReactProvider(props: { children: React.ReactNode }) {
|
|||||||
api.createClient({
|
api.createClient({
|
||||||
links: [
|
links: [
|
||||||
loggerLink({
|
loggerLink({
|
||||||
enabled: (op) =>
|
enabled: (op) => process.env.NODE_ENV === "development" || (op.direction === "down" && op.result instanceof Error),
|
||||||
process.env.NODE_ENV === "development" ||
|
|
||||||
(op.direction === "down" && op.result instanceof Error),
|
|
||||||
}),
|
}),
|
||||||
httpBatchStreamLink({
|
httpBatchStreamLink({
|
||||||
transformer: SuperJSON,
|
transformer: SuperJSON,
|
||||||
|
|||||||
@@ -24,7 +24,4 @@ const createContext = cache(async () => {
|
|||||||
const getQueryClient = cache(createQueryClient);
|
const getQueryClient = cache(createQueryClient);
|
||||||
const caller = createCaller(createContext);
|
const caller = createCaller(createContext);
|
||||||
|
|
||||||
export const { trpc: api, HydrateClient } = createHydrationHelpers<AppRouter>(
|
export const { trpc: api, HydrateClient } = createHydrationHelpers<AppRouter>(caller, getQueryClient);
|
||||||
caller,
|
|
||||||
getQueryClient,
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -30,13 +30,6 @@
|
|||||||
"@/*": ["./src/*"]
|
"@/*": ["./src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.js", ".next/types/**/*.ts"],
|
||||||
"next-env.d.ts",
|
|
||||||
"**/*.ts",
|
|
||||||
"**/*.tsx",
|
|
||||||
"**/*.cjs",
|
|
||||||
"**/*.js",
|
|
||||||
".next/types/**/*.ts"
|
|
||||||
],
|
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user