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",
|
||||
"useIgnoreFile": true
|
||||
},
|
||||
"files": { "ignoreUnknown": false, "ignore": [] },
|
||||
"formatter": { "enabled": true },
|
||||
"organizeImports": { "enabled": true },
|
||||
"files": {
|
||||
"ignoreUnknown": false,
|
||||
"ignore": []
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"lineWidth": 200
|
||||
},
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
|
||||
92
package.json
92
package.json
@@ -1,47 +1,47 @@
|
||||
{
|
||||
"name": "dvdash",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "next build",
|
||||
"check": "biome check .",
|
||||
"check:unsafe": "biome check --write --unsafe .",
|
||||
"check:write": "biome check --write .",
|
||||
"dev": "next dev --turbo",
|
||||
"preview": "next build && next start",
|
||||
"start": "next start",
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@t3-oss/env-nextjs": "^0.13.0",
|
||||
"@tailwindcss/postcss": "^4.1.4",
|
||||
"@tanstack/react-query": "^5.74.4",
|
||||
"@trpc/client": "^11.1.1",
|
||||
"@trpc/react-query": "^11.1.1",
|
||||
"@trpc/server": "^11.1.1",
|
||||
"daisyui": "^5.0.28",
|
||||
"dockerode": "^4.0.6",
|
||||
"next": "^15.3.1",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"semver": "^7.7.1",
|
||||
"server-only": "^0.0.1",
|
||||
"superjson": "^2.2.2",
|
||||
"zod": "^3.24.3",
|
||||
"zx": "^8.5.3",
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/bun": "^1.2.10",
|
||||
"@types/dockerode": "^3.3.38",
|
||||
"@types/react": "19.1.2",
|
||||
"@types/react-dom": "^19.1.2",
|
||||
"@types/semver": "^7.7.0",
|
||||
"postcss": "^8.5.3",
|
||||
"tailwindcss": "^4.1.4",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"ct3aMetadata": {
|
||||
"initVersion": "7.39.3"
|
||||
}
|
||||
}
|
||||
"name": "dvdash",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "next build",
|
||||
"check": "biome check .",
|
||||
"check:unsafe": "biome check --write --unsafe .",
|
||||
"check:write": "biome check --write .",
|
||||
"dev": "next dev --turbo",
|
||||
"preview": "next build && next start",
|
||||
"start": "next start",
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@t3-oss/env-nextjs": "^0.13.0",
|
||||
"@tailwindcss/postcss": "^4.1.4",
|
||||
"@tanstack/react-query": "^5.74.4",
|
||||
"@trpc/client": "^11.1.1",
|
||||
"@trpc/react-query": "^11.1.1",
|
||||
"@trpc/server": "^11.1.1",
|
||||
"daisyui": "^5.0.28",
|
||||
"dockerode": "^4.0.6",
|
||||
"next": "^15.3.1",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"semver": "^7.7.1",
|
||||
"server-only": "^0.0.1",
|
||||
"superjson": "^2.2.2",
|
||||
"zod": "^3.24.3",
|
||||
"zx": "^8.5.3",
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/bun": "^1.2.10",
|
||||
"@types/dockerode": "^3.3.38",
|
||||
"@types/react": "19.1.2",
|
||||
"@types/react-dom": "^19.1.2",
|
||||
"@types/semver": "^7.7.0",
|
||||
"postcss": "^8.5.3",
|
||||
"tailwindcss": "^4.1.4",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"ct3aMetadata": {
|
||||
"initVersion": "7.39.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ const handler = (req: NextRequest) =>
|
||||
onError:
|
||||
env.NODE_ENV === "development"
|
||||
? ({ path, error }) => {
|
||||
console.error(
|
||||
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`,
|
||||
);
|
||||
console.error(`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`);
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
@@ -16,9 +16,7 @@ const geist = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
});
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{ children: React.ReactNode }>) {
|
||||
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
return (
|
||||
<html lang="en" className={`${geist.variable}`}>
|
||||
<body>
|
||||
|
||||
@@ -16,45 +16,34 @@ export default async function Home() {
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Image</th>
|
||||
<th>Version</th>
|
||||
<th>Tag</th>
|
||||
<th>Short Hash</th>
|
||||
<th>Version</th>
|
||||
<th>Tag</th>
|
||||
<th>Short Hash</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{list
|
||||
.sort((ca, cb) => {
|
||||
if (ca.Names[0] && cb.Names[0]) {
|
||||
if (ca.Names[0] < cb.Names[0]) {
|
||||
if (ca.containerName && cb.containerName) {
|
||||
if (ca.containerName < cb.containerName) {
|
||||
return -1;
|
||||
}
|
||||
if (ca.Names[0] > cb.Names[0]) {
|
||||
if (ca.containerName > cb.containerName) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
.map((containerInfo) => {
|
||||
const outdated =
|
||||
containerInfo.current.version !==
|
||||
containerInfo.latest.version ||
|
||||
containerInfo.current.hash !==
|
||||
containerInfo.latest.hash;
|
||||
const outdated = containerInfo.current.hash !== containerInfo.latest.hash;
|
||||
return (
|
||||
<tr
|
||||
key={containerInfo.Image.split(":")[0]}
|
||||
className={`${outdated ? "bg-base-200" : null}`}
|
||||
>
|
||||
<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>
|
||||
<tr key={containerInfo.containerName} className={`${outdated ? "bg-base-200" : null}`}>
|
||||
<td className={`border-l-8 ${outdated ? "border-l-error/80" : "border-l-info/80"}`}>{containerInfo.containerName}</td>
|
||||
<td>{containerInfo.imageName}</td>
|
||||
<td>{containerInfo.current.tag}</td>
|
||||
<td>{containerInfo.current.hash}</td>
|
||||
<td>{containerInfo.latest.version}</td>
|
||||
<td>{containerInfo.latest.tag}</td>
|
||||
<td>{containerInfo.latest.hash}</td>
|
||||
</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"
|
||||
|
||||
return Promise.all(
|
||||
const dockerInfo = await Promise.all(
|
||||
containers.map(async (container) => {
|
||||
const version = (
|
||||
await docker.getImage(container.Image).inspect()
|
||||
).RepoTags[0]?.split(":")[1];
|
||||
const latest = {
|
||||
version: version,
|
||||
hash: "N/A",
|
||||
const imageInspect = await docker.getImage(container.Image).inspect();
|
||||
const imageDigest = imageInspect.RepoDigests[0];
|
||||
const containerInspect = docker.getContainer(container.Id);
|
||||
|
||||
let imageTag = imageInspect.RepoTags[0]?.split(":")[1];
|
||||
|
||||
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);
|
||||
latest.hash = await getLatestHash(
|
||||
`${container.Image.split(":")[0]}:${latest.version}`,
|
||||
);
|
||||
} else {
|
||||
latest.hash = await getLatestHash(container.Image);
|
||||
|
||||
let latest: {
|
||||
hash?: string;
|
||||
tag?: string;
|
||||
} = {
|
||||
hash: "",
|
||||
tag: "",
|
||||
};
|
||||
if (imageName) {
|
||||
latest = await getLatest(imageName, current.tag);
|
||||
}
|
||||
|
||||
return {
|
||||
...container,
|
||||
current: {
|
||||
version,
|
||||
hash: (
|
||||
await docker.getImage(container.Image).inspect()
|
||||
).RepoDigests[0]
|
||||
?.split(":")[1]
|
||||
?.substring(0, 12),
|
||||
},
|
||||
containerName: container.Names[0]?.replace("/", ""),
|
||||
imageName,
|
||||
current,
|
||||
latest,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return dockerInfo;
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -58,27 +66,58 @@ function isSemver(tag: string): boolean {
|
||||
return !!semver.valid(removeV);
|
||||
}
|
||||
|
||||
async function getLatestSemverTag(image: string): Promise<string> {
|
||||
async function getLatestSemverTag(image: string, tag?: string): Promise<{ hash: string; tag?: string }> {
|
||||
try {
|
||||
const allTags =
|
||||
await $`bin/regctl tag ls --exclude 'version.*' --exclude 'unstable.*' --exclude '.*rc.*' --exclude 'lib.*' --exclude 'release.*' --exclude 'arm.*
|
||||
const latest = {
|
||||
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();
|
||||
const semverTags = allTags
|
||||
.split("\n")
|
||||
.slice(-20)
|
||||
.filter((tag) => isSemver(tag));
|
||||
return semver.rsort(semverTags)[0] ?? "Error";
|
||||
const semverTags = allTags.split("\n").filter((tag) => isSemver(tag));
|
||||
const newestTag = semver.rsort(semverTags)[0];
|
||||
|
||||
let imageSh = image;
|
||||
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) {
|
||||
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 {
|
||||
const latestImage = await $`bin/regctl image digest ${image}`.text();
|
||||
const latestHash = latestImage.split(":")?.[1];
|
||||
return latestHash?.substring(0, 12) ?? "Error";
|
||||
let latest: { hash: string; tag?: string } = {
|
||||
hash: "",
|
||||
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) {
|
||||
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,
|
||||
data: {
|
||||
...shape.data,
|
||||
zodError:
|
||||
error.cause instanceof ZodError ? error.cause.flatten() : null,
|
||||
zodError: error.cause instanceof ZodError ? error.cause.flatten() : null,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -5,6 +5,5 @@
|
||||
}
|
||||
|
||||
@theme {
|
||||
--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";
|
||||
--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";
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
QueryClient,
|
||||
defaultShouldDehydrateQuery,
|
||||
} from "@tanstack/react-query";
|
||||
import { QueryClient, defaultShouldDehydrateQuery } from "@tanstack/react-query";
|
||||
import SuperJSON from "superjson";
|
||||
|
||||
export const createQueryClient = () =>
|
||||
@@ -14,9 +11,7 @@ export const createQueryClient = () =>
|
||||
},
|
||||
dehydrate: {
|
||||
serializeData: SuperJSON.serialize,
|
||||
shouldDehydrateQuery: (query) =>
|
||||
defaultShouldDehydrateQuery(query) ||
|
||||
query.state.status === "pending",
|
||||
shouldDehydrateQuery: (query) => defaultShouldDehydrateQuery(query) || query.state.status === "pending",
|
||||
},
|
||||
hydrate: {
|
||||
deserializeData: SuperJSON.deserialize,
|
||||
|
||||
@@ -45,9 +45,7 @@ export function TRPCReactProvider(props: { children: React.ReactNode }) {
|
||||
api.createClient({
|
||||
links: [
|
||||
loggerLink({
|
||||
enabled: (op) =>
|
||||
process.env.NODE_ENV === "development" ||
|
||||
(op.direction === "down" && op.result instanceof Error),
|
||||
enabled: (op) => process.env.NODE_ENV === "development" || (op.direction === "down" && op.result instanceof Error),
|
||||
}),
|
||||
httpBatchStreamLink({
|
||||
transformer: SuperJSON,
|
||||
|
||||
@@ -24,7 +24,4 @@ const createContext = cache(async () => {
|
||||
const getQueryClient = cache(createQueryClient);
|
||||
const caller = createCaller(createContext);
|
||||
|
||||
export const { trpc: api, HydrateClient } = createHydrationHelpers<AppRouter>(
|
||||
caller,
|
||||
getQueryClient,
|
||||
);
|
||||
export const { trpc: api, HydrateClient } = createHydrationHelpers<AppRouter>(caller, getQueryClient);
|
||||
|
||||
@@ -30,13 +30,6 @@
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"**/*.cjs",
|
||||
"**/*.js",
|
||||
".next/types/**/*.ts"
|
||||
],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.js", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user