diff --git a/src/commands/context/get.tsx b/src/commands/context/get.tsx
index e8000ffee..d3542cd17 100644
--- a/src/commands/context/get.tsx
+++ b/src/commands/context/get.tsx
@@ -1,166 +1,16 @@
import { RenderBaseCommand } from "../../lib/basecommands/RenderBaseCommand.js";
-import { FC, ReactNode } from "react";
-import { SingleResult } from "../../rendering/react/components/SingleResult.js";
-import { Value } from "../../rendering/react/components/Value.js";
-import { usePromise } from "@mittwald/react-use-promise";
-import { Note } from "../../rendering/react/components/Note.js";
-import { Box, Text } from "ink";
-import { Set } from "./set.js";
-import { RenderJson } from "../../rendering/react/json/RenderJson.js";
-import { useRenderContext } from "../../rendering/react/context.js";
-import { LocalFilename } from "../../rendering/react/components/LocalFilename.js";
-import Context, {
- ContextKey,
- ContextValue,
- ContextValueSource,
-} from "../../lib/context/Context.js";
-
-const ContextSourceValue: FC<{ source: ContextValueSource }> = ({ source }) => {
- switch (source.type) {
- case "user":
- return (
-
- );
- case "terraform":
- return (
-
- );
- case "ddev":
- return (
-
- );
- case "dotfile":
- return (
-
- );
- default:
- return ;
- }
-};
-
-const ContextSourceKnownValue: FC<{
- name: string;
- source: ContextValueSource;
- relative?: boolean;
-}> = ({ name, source, relative }) => {
- return (
-
- {name}, in{" "}
-
-
- );
-};
-
-const ContextSourceUnknown: FC = () => {
- return unknown;
-};
-
-const ContextSource: FC<{ source: ContextValueSource }> = ({ source }) => {
- return (
-
- (source: )
-
- );
-};
-
-const GetContext: FC<{ ctx: Context }> = ({ ctx }) => {
- const rows: Record = {};
- const { renderAsJson } = useRenderContext();
- const values: Record = {};
-
- let hasTerraformSource = false;
- let hasDDEVSource = false;
- let hasDotfileSource = false;
-
- for (const key of [
- "project-id",
- "server-id",
- "org-id",
- "installation-id",
- "stack-id",
- ] as ContextKey[]) {
- const value = usePromise(ctx.getContextValue.bind(ctx), [key]);
- if (value) {
- rows[`--${key}`] = (
-
- {value.value}
-
- );
- values[key] = value;
-
- hasTerraformSource =
- hasTerraformSource || value.source.type === "terraform";
- hasDDEVSource = hasDDEVSource || value.source.type === "ddev";
- hasDotfileSource = hasDotfileSource || value.source.type === "dotfile";
- } else {
- rows[`--${key}`] = ;
- }
- }
-
- if (renderAsJson) {
- return ;
- }
-
- return (
-
-
-
-
- {hasTerraformSource && }
- {hasDDEVSource && }
- {hasDotfileSource && }
-
-
- );
-};
-
-const TerraformHint: FC = () => (
-
- You are in a directory that contains a terraform state file; some of the
- context values were read from there.
-
-);
-
-const DDEVHint: FC = () => (
-
- You are in a directory that contains a DDEV project; some of the context
- values were read from there.
-
-);
-
-const DotfileHint: FC = () => (
-
- You are in a directory that contains a .mw-context.json file; some of the
- context values were read from there.
-
-);
-
-const ContextSetHint: FC = () => (
-
- Use the mw context set command to set one of the values
- listed above.
-
-);
+import { ReactNode } from "react";
+import { Set as SetCommand } from "./set.js";
+import Context from "../../lib/context/Context.js";
+import { ContextOverview } from "../../rendering/react/components/Context/ContextOverview.js";
export class Get extends RenderBaseCommand {
static summary = "Print an overview of currently set context parameters";
- static description = Set.description;
+ static description = SetCommand.description;
static flags = { ...RenderBaseCommand.buildFlags() };
protected render(): ReactNode {
const ctx = new Context(this.apiClient, this.config);
- return ;
+ return ;
}
}
diff --git a/src/lib/context/projectOverview.ts b/src/lib/context/projectOverview.ts
new file mode 100644
index 000000000..7d39ca794
--- /dev/null
+++ b/src/lib/context/projectOverview.ts
@@ -0,0 +1,302 @@
+import { MittwaldAPIV2, MittwaldAPIV2Client } from "@mittwald/api-client";
+import { assertStatus } from "@mittwald/api-client-commons";
+import {
+ getAppFromUuid,
+ getAppInstallationFromUuid,
+} from "../resources/app/uuid.js";
+
+type AppLinkedDatabase = MittwaldAPIV2.Components.Schemas.AppLinkedDatabase;
+
+export type LinkedDatabaseSummary = {
+ databaseId: string;
+ purpose: string;
+ kind: "mysql" | "redis" | "unknown";
+ name?: string;
+};
+
+export type AppSummary = {
+ installationId: string;
+ installationShortId?: string;
+ appId: string;
+ appName: string;
+ installationPath: string;
+ linkedDatabases: LinkedDatabaseSummary[];
+};
+
+export type StackSummary = {
+ id: string;
+ shortId?: string;
+ description?: string;
+ services: number;
+ volumes: number;
+};
+
+export type ContainerSummary = {
+ id: string;
+ shortId?: string;
+ name: string;
+ status: string;
+ stackId?: string;
+};
+
+export type ResolvedProjectContext = {
+ projectId?: string;
+ resolvedFrom?: "project-id" | "installation-id";
+ unavailableReason?: string;
+};
+
+export type ProjectOverview = {
+ projectId?: string;
+ projectShortId?: string;
+ projectName?: string;
+ resolvedFrom?: "project-id" | "installation-id";
+ apps: AppSummary[];
+ stacks: StackSummary[];
+ containers: ContainerSummary[];
+ unavailableReason?: string;
+ warnings?: string[];
+};
+
+async function fetchDatabaseLookup(
+ apiClient: MittwaldAPIV2Client,
+ projectId: string,
+ warnings: string[],
+): Promise