Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions docs/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ Creates new custom Node.js installation.
```
USAGE
$ mw app create node [--token <value>] [-p <value>] [-q] [--site-title <value>] [--entrypoint <value>] [-w]
[--wait-timeout <value>] [--install-path <value>]
[--wait-timeout <value>] [--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -130,9 +131,10 @@ Creates new custom PHP installation.
```
USAGE
$ mw app create php --document-root <value> [--token <value>] [-p <value>] [-q] [--site-title <value>] [-w]
[--wait-timeout <value>] [--install-path <value>]
[--wait-timeout <value>] [--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -189,9 +191,10 @@ Creates new PHP worker installation.
```
USAGE
$ mw app create php-worker [--token <value>] [-p <value>] [-q] [--entrypoint <value>] [--site-title <value>] [-w]
[--wait-timeout <value>] [--install-path <value>]
[--wait-timeout <value>] [--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -245,9 +248,10 @@ Creates new custom python site installation.
```
USAGE
$ mw app create python [--token <value>] [-p <value>] [-q] [--site-title <value>] [--entrypoint <value>] [-w]
[--wait-timeout <value>] [--install-path <value>]
[--wait-timeout <value>] [--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -301,9 +305,10 @@ Creates new custom static site installation.
```
USAGE
$ mw app create static --document-root <value> [--token <value>] [-p <value>] [-q] [--site-title <value>] [-w]
[--wait-timeout <value>] [--install-path <value>]
[--wait-timeout <value>] [--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -636,9 +641,10 @@ Creates new Contao installation.
USAGE
$ mw app install contao --version <value> [--token <value>] [-p <value>] [-q] [--host <value>] [--admin-firstname
<value>] [--admin-user <value>] [--admin-email <value>] [--admin-pass <value>] [--admin-lastname <value>]
[--site-title <value>] [-w] [--wait-timeout <value>] [--install-path <value>]
[--site-title <value>] [-w] [--wait-timeout <value>] [--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -737,9 +743,10 @@ Creates new Joomla! installation.
USAGE
$ mw app install joomla --version <value> [--token <value>] [-p <value>] [-q] [--host <value>] [--admin-user <value>]
[--admin-email <value>] [--admin-pass <value>] [--admin-firstname <value>] [--admin-lastname <value>] [--site-title
<value>] [-w] [--wait-timeout <value>] [--install-path <value>]
<value>] [-w] [--wait-timeout <value>] [--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -838,9 +845,10 @@ Creates new Matomo installation.
USAGE
$ mw app install matomo --version <value> [--token <value>] [-p <value>] [-q] [--host <value>] [--admin-user <value>]
[--admin-email <value>] [--admin-pass <value>] [--site-title <value>] [-w] [--wait-timeout <value>] [--install-path
<value>]
<value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -924,9 +932,10 @@ Creates new Nextcloud installation.
USAGE
$ mw app install nextcloud --version <value> [--token <value>] [-p <value>] [-q] [--host <value>] [--admin-user <value>]
[--admin-email <value>] [--admin-pass <value>] [--site-title <value>] [-w] [--wait-timeout <value>] [--install-path
<value>]
<value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -1012,9 +1021,10 @@ USAGE
$ mw app install shopware5 --version <value> [--token <value>] [-p <value>] [-q] [--host <value>] [--admin-user <value>]
[--admin-email <value>] [--admin-pass <value>] [--admin-firstname <value>] [--admin-lastname <value>] [--site-title
<value>] [--shop-email <value>] [--shop-lang <value>] [--shop-currency <value>] [-w] [--wait-timeout <value>]
[--install-path <value>]
[--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -1135,9 +1145,10 @@ USAGE
$ mw app install shopware6 --version <value> [--token <value>] [-p <value>] [-q] [--host <value>] [--admin-user <value>]
[--admin-email <value>] [--admin-pass <value>] [--admin-firstname <value>] [--admin-lastname <value>] [--site-title
<value>] [--shop-email <value>] [--shop-lang <value>] [--shop-currency <value>] [-w] [--wait-timeout <value>]
[--install-path <value>]
[--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -1257,9 +1268,10 @@ Creates new TYPO3 installation.
USAGE
$ mw app install typo3 --version <value> --install-mode composer|symlink [--token <value>] [-p <value>] [-q] [--host
<value>] [--admin-user <value>] [--admin-email <value>] [--admin-pass <value>] [--site-title <value>] [-w]
[--wait-timeout <value>] [--install-path <value>]
[--wait-timeout <value>] [--install-path <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down Expand Up @@ -1351,9 +1363,10 @@ Creates new WordPress installation.
USAGE
$ mw app install wordpress --version <value> [--token <value>] [-p <value>] [-q] [--host <value>] [--admin-user <value>]
[--admin-email <value>] [--admin-pass <value>] [--site-title <value>] [-w] [--wait-timeout <value>] [--install-path
<value>]
<value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created app installation
-p, --project-id=<value> 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
Expand Down
4 changes: 2 additions & 2 deletions docs/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ Create a new project

```
USAGE
$ mw project create -d <value> [--token <value>] [-s <value>] [-q] [-w] [--wait-timeout <value>] [--update-context]
$ mw project create -d <value> [--token <value>] [-s <value>] [-q] [-w] [--wait-timeout <value>] [-c]

FLAGS
-c, --update-context update the CLI context to use the newly created project
-d, --description=<value> (required) A description for the project.
-q, --quiet suppress process output and only display a machine-readable summary
-s, --server-id=<value> 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=<value> [default: 600s] the duration to wait for the resource to be ready (common units like 'ms',
's', 'm' are accepted).

Expand Down
22 changes: 19 additions & 3 deletions src/commands/project/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
}),
};

Expand Down Expand Up @@ -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(
Expand All @@ -76,9 +83,10 @@ export default class Create extends ExecRenderBaseCommand<
});
}

process.complete(
<Success>Your new project was successfully created! 🚀</Success>,
await process.complete(
<ProjectCreationSuccess shortId={projectResult.data.shortId} />,
);

return { projectId: result.data.id };
}

Expand All @@ -88,3 +96,11 @@ export default class Create extends ExecRenderBaseCommand<
}
}
}

function ProjectCreationSuccess({ shortId }: { shortId: string }) {
return (
<Success>
Your new project <Value>{shortId}</Value> was successfully created! 🚀
</Success>
);
}
11 changes: 10 additions & 1 deletion src/lib/resources/app/Installer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +24,8 @@ type ImplicitDefaultFlag =
| "wait"
| "wait-timeout"
| "site-title"
| "install-path";
| "install-path"
| "update-context";

export interface AppInstallationResult {
appInstallation: AppInstallation;
Expand Down Expand Up @@ -69,6 +71,7 @@ export class AppInstaller<TFlagName extends AvailableFlagName> {
"wait-timeout",
"site-title",
"install-path",
"update-context",
],
this.appName,
);
Expand Down Expand Up @@ -134,6 +137,12 @@ export class AppInstaller<TFlagName extends AvailableFlagName> {
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(<Success>{successText}</Success>);

return {
Expand Down
15 changes: 14 additions & 1 deletion src/lib/resources/app/flags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -62,6 +67,7 @@ type AvailableFlags = typeof waitFlags & {
"opensearch-host": OptionFlag<string>;
"opensearch-port": OptionFlag<string>;
entrypoint: OptionFlag<string | undefined>;
"update-context": BooleanFlag<boolean>;
};

function buildFlagsWithDescription(appName: string): AvailableFlags {
Expand Down Expand Up @@ -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: false,
}),
...waitFlags,
};
}
Expand Down