From 065d82415484d931eaafbdec29d4918894734bae Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Mon, 15 Dec 2025 11:39:12 +0100 Subject: [PATCH 1/3] feat: add "--update-context" flag to app installation commands --- src/commands/project/create.tsx | 22 +++++++++++++++++++--- src/lib/resources/app/Installer.tsx | 11 ++++++++++- src/lib/resources/app/flags.tsx | 15 ++++++++++++++- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/commands/project/create.tsx b/src/commands/project/create.tsx index 80ddba10e..1a5da773a 100644 --- a/src/commands/project/create.tsx +++ b/src/commands/project/create.tsx @@ -10,6 +10,7 @@ import { } from "../../rendering/process/process_flags.js"; import { waitFlags, waitUntil } from "../../lib/wait.js"; import Context from "../../lib/context/Context.js"; +import { Value } from "../../rendering/react/components/Value.js"; export default class Create extends ExecRenderBaseCommand< typeof Create, @@ -27,7 +28,8 @@ export default class Create extends ExecRenderBaseCommand< description: "A description for the project.", }), "update-context": Flags.boolean({ - description: "Update the CLI context to use the newly created project", + description: "update the CLI context to use the newly created project", + char: "c", }), }; @@ -68,6 +70,11 @@ export default class Create extends ExecRenderBaseCommand< stepWaiting.complete(); } + const projectResult = await this.apiClient.project.getProject({ + projectId: result.data.id, + }); + assertStatus(projectResult, 200); + if (flags["update-context"]) { await process.runStep("updating CLI context", async () => { await new Context(this.apiClient, this.config).setProjectId( @@ -76,9 +83,10 @@ export default class Create extends ExecRenderBaseCommand< }); } - process.complete( - Your new project was successfully created! 🚀, + await process.complete( + , ); + return { projectId: result.data.id }; } @@ -88,3 +96,11 @@ export default class Create extends ExecRenderBaseCommand< } } } + +function ProjectCreationSuccess({ shortId }: { shortId: string }) { + return ( + + Your new project {shortId} was successfully created! 🚀 + + ); +} diff --git a/src/lib/resources/app/Installer.tsx b/src/lib/resources/app/Installer.tsx index d56593948..c9f9d2fb3 100644 --- a/src/lib/resources/app/Installer.tsx +++ b/src/lib/resources/app/Installer.tsx @@ -15,6 +15,7 @@ import AppUsageHints from "../../../rendering/react/components/AppInstallation/A import React from "react"; import { MittwaldAPIV2, MittwaldAPIV2Client } from "@mittwald/api-client"; import { Config } from "@oclif/core"; +import Context from "../../context/Context.js"; type AppVersion = MittwaldAPIV2.Components.Schemas.AppAppVersion; type AppInstallation = MittwaldAPIV2.Components.Schemas.AppAppInstallation; @@ -23,7 +24,8 @@ type ImplicitDefaultFlag = | "wait" | "wait-timeout" | "site-title" - | "install-path"; + | "install-path" + | "update-context"; export interface AppInstallationResult { appInstallation: AppInstallation; @@ -69,6 +71,7 @@ export class AppInstaller { "wait-timeout", "site-title", "install-path", + "update-context", ], this.appName, ); @@ -134,6 +137,12 @@ export class AppInstaller { successText = `Your ${this.appName} installation has started. Have fun when it's ready! 🎉`; } + if (flags["update-context"]) { + const context = new Context(apiClient, config); + await context.setProjectId(appInstallation.projectId); + await context.setAppInstallationId(appInstallation.id); + } + await process.complete({successText}); return { diff --git a/src/lib/resources/app/flags.tsx b/src/lib/resources/app/flags.tsx index d4434e13d..fc554c4da 100644 --- a/src/lib/resources/app/flags.tsx +++ b/src/lib/resources/app/flags.tsx @@ -9,7 +9,12 @@ import { processFlags, } from "../../../rendering/process/process_flags.js"; import { Flags } from "@oclif/core"; -import { FlagInput, OptionFlag, OutputFlags } from "@oclif/core/interfaces"; +import { + BooleanFlag, + FlagInput, + OptionFlag, + OutputFlags, +} from "@oclif/core/interfaces"; import FlagSetBuilder from "../../context/FlagSetBuilder.js"; import { contextIDNormalizers } from "../../context/Context.js"; import { generatePasswordWithSpecialChars } from "../../util/password/generatePasswordWithSpecialChars.js"; @@ -62,6 +67,7 @@ type AvailableFlags = typeof waitFlags & { "opensearch-host": OptionFlag; "opensearch-port": OptionFlag; entrypoint: OptionFlag; + "update-context": BooleanFlag; }; function buildFlagsWithDescription(appName: string): AvailableFlags { @@ -188,6 +194,13 @@ function buildFlagsWithDescription(appName: string): AvailableFlags { required: false, default: undefined, }), + "update-context": Flags.boolean({ + description: + "update the CLI context to use the newly created app installation", + char: "c", + required: false, + default: undefined, + }), ...waitFlags, }; } From dd0e5f881e13343b9d2b021e3f989c573c985317 Mon Sep 17 00:00:00 2001 From: martin-helmich <2538958+martin-helmich@users.noreply.github.com> Date: Mon, 15 Dec 2025 10:41:21 +0000 Subject: [PATCH 2/3] chore: re-generate README --- docs/app.md | 39 ++++++++++++++++++++++++++------------- docs/project.md | 4 ++-- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/docs/app.md b/docs/app.md index 432e33312..3ba37ef75 100644 --- a/docs/app.md +++ b/docs/app.md @@ -73,9 +73,10 @@ Creates new custom Node.js installation. ``` USAGE $ mw app create node [--token ] [-p ] [-q] [--site-title ] [--entrypoint ] [-w] - [--wait-timeout ] [--install-path ] + [--wait-timeout ] [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -130,9 +131,10 @@ Creates new custom PHP installation. ``` USAGE $ mw app create php --document-root [--token ] [-p ] [-q] [--site-title ] [-w] - [--wait-timeout ] [--install-path ] + [--wait-timeout ] [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -189,9 +191,10 @@ Creates new PHP worker installation. ``` USAGE $ mw app create php-worker [--token ] [-p ] [-q] [--entrypoint ] [--site-title ] [-w] - [--wait-timeout ] [--install-path ] + [--wait-timeout ] [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -245,9 +248,10 @@ Creates new custom python site installation. ``` USAGE $ mw app create python [--token ] [-p ] [-q] [--site-title ] [--entrypoint ] [-w] - [--wait-timeout ] [--install-path ] + [--wait-timeout ] [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -301,9 +305,10 @@ Creates new custom static site installation. ``` USAGE $ mw app create static --document-root [--token ] [-p ] [-q] [--site-title ] [-w] - [--wait-timeout ] [--install-path ] + [--wait-timeout ] [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -636,9 +641,10 @@ Creates new Contao installation. USAGE $ mw app install contao --version [--token ] [-p ] [-q] [--host ] [--admin-firstname ] [--admin-user ] [--admin-email ] [--admin-pass ] [--admin-lastname ] - [--site-title ] [-w] [--wait-timeout ] [--install-path ] + [--site-title ] [-w] [--wait-timeout ] [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -737,9 +743,10 @@ Creates new Joomla! installation. USAGE $ mw app install joomla --version [--token ] [-p ] [-q] [--host ] [--admin-user ] [--admin-email ] [--admin-pass ] [--admin-firstname ] [--admin-lastname ] [--site-title - ] [-w] [--wait-timeout ] [--install-path ] + ] [-w] [--wait-timeout ] [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -838,9 +845,10 @@ Creates new Matomo installation. USAGE $ mw app install matomo --version [--token ] [-p ] [-q] [--host ] [--admin-user ] [--admin-email ] [--admin-pass ] [--site-title ] [-w] [--wait-timeout ] [--install-path - ] + ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -924,9 +932,10 @@ Creates new Nextcloud installation. USAGE $ mw app install nextcloud --version [--token ] [-p ] [-q] [--host ] [--admin-user ] [--admin-email ] [--admin-pass ] [--site-title ] [-w] [--wait-timeout ] [--install-path - ] + ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -1012,9 +1021,10 @@ USAGE $ mw app install shopware5 --version [--token ] [-p ] [-q] [--host ] [--admin-user ] [--admin-email ] [--admin-pass ] [--admin-firstname ] [--admin-lastname ] [--site-title ] [--shop-email ] [--shop-lang ] [--shop-currency ] [-w] [--wait-timeout ] - [--install-path ] + [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -1135,9 +1145,10 @@ USAGE $ mw app install shopware6 --version [--token ] [-p ] [-q] [--host ] [--admin-user ] [--admin-email ] [--admin-pass ] [--admin-firstname ] [--admin-lastname ] [--site-title ] [--shop-email ] [--shop-lang ] [--shop-currency ] [-w] [--wait-timeout ] - [--install-path ] + [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -1257,9 +1268,10 @@ Creates new TYPO3 installation. USAGE $ mw app install typo3 --version --install-mode composer|symlink [--token ] [-p ] [-q] [--host ] [--admin-user ] [--admin-email ] [--admin-pass ] [--site-title ] [-w] - [--wait-timeout ] [--install-path ] + [--wait-timeout ] [--install-path ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary @@ -1351,9 +1363,10 @@ Creates new WordPress installation. USAGE $ mw app install wordpress --version [--token ] [-p ] [-q] [--host ] [--admin-user ] [--admin-email ] [--admin-pass ] [--site-title ] [-w] [--wait-timeout ] [--install-path - ] + ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created app installation -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context -q, --quiet suppress process output and only display a machine-readable summary diff --git a/docs/project.md b/docs/project.md index d2505a6c4..dd562dd69 100644 --- a/docs/project.md +++ b/docs/project.md @@ -261,15 +261,15 @@ Create a new project ``` USAGE - $ mw project create -d [--token ] [-s ] [-q] [-w] [--wait-timeout ] [--update-context] + $ mw project create -d [--token ] [-s ] [-q] [-w] [--wait-timeout ] [-c] FLAGS + -c, --update-context update the CLI context to use the newly created project -d, --description= (required) A description for the project. -q, --quiet suppress process output and only display a machine-readable summary -s, --server-id= ID or short ID of a server; this flag is optional if a default server is set in the context -w, --wait wait for the resource to be ready. - --update-context Update the CLI context to use the newly created project --wait-timeout= [default: 600s] the duration to wait for the resource to be ready (common units like 'ms', 's', 'm' are accepted). From caf95e4c82b84c6509c609f4611f168033931f76 Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Thu, 15 Jan 2026 13:51:30 +0100 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/lib/resources/app/flags.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/resources/app/flags.tsx b/src/lib/resources/app/flags.tsx index fc554c4da..b784108de 100644 --- a/src/lib/resources/app/flags.tsx +++ b/src/lib/resources/app/flags.tsx @@ -67,7 +67,7 @@ type AvailableFlags = typeof waitFlags & { "opensearch-host": OptionFlag; "opensearch-port": OptionFlag; entrypoint: OptionFlag; - "update-context": BooleanFlag; + "update-context": BooleanFlag; }; function buildFlagsWithDescription(appName: string): AvailableFlags { @@ -199,7 +199,7 @@ function buildFlagsWithDescription(appName: string): AvailableFlags { "update the CLI context to use the newly created app installation", char: "c", required: false, - default: undefined, + default: false, }), ...waitFlags, };