diff --git a/README.md b/README.md index 065e489c..a1f343f4 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ USAGE * [`mw app install drupal`](#mw-app-install-drupal) * [`mw app install grav`](#mw-app-install-grav) * [`mw app install joomla`](#mw-app-install-joomla) +* [`mw app install magento2`](#mw-app-install-magento2) * [`mw app install matomo`](#mw-app-install-matomo) * [`mw app install moodle`](#mw-app-install-moodle) * [`mw app install neos`](#mw-app-install-neos) @@ -1004,6 +1005,132 @@ FLAG DESCRIPTIONS If unspecified, the Joomla! will be installed in the latest available version. ``` +## `mw app install magento2` + +Creates new Magento 2 installation. + +``` +USAGE + $ mw app install magento2 --version --opensearch-host --opensearch-port [-p ] [-q] + [--host ] [--admin-user ] [--admin-email ] [--admin-pass ] [--admin-firstname ] + [--admin-lastname ] [--site-title ] [--shop-email ] [--shop-lang ] [--shop-currency + ] [-w] [--wait-timeout ] + +FLAGS + -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. + -w, --wait wait for the resource to be ready. + --admin-email= email address of your administrator user. + --admin-firstname= first name of your administrator user. + --admin-lastname= Lastname of your administrator user. + --admin-pass= password of your administrator user. + --admin-user= Username for your administrator user. + --host= host to initially configure your Magento 2 installation with; needs to be created + separately. + --opensearch-host= (required) the OpenSearch instance host which your Magento 2 will try to connect to + --opensearch-port= (required) the OpenSearch instance port which your Magento 2 will try to connect to + --shop-currency= Currency your Magento 2 will be working with. + --shop-email= email address your Magento 2 will be working with. + --shop-lang= language your Magento 2 will be working with. + --site-title= site title for your Magento 2 installation. + --version= (required) [default: latest] version of Magento 2 to be installed. + --wait-timeout= [default: 600s] the duration to wait for the resource to be ready (common units like + 'ms', 's', 'm' are accepted). + +DESCRIPTION + Creates new Magento 2 installation. + +FLAG DESCRIPTIONS + -p, --project-id= + + ID or short ID of a project; this flag is optional if a default project is set in the context + + May contain a short ID or a full ID of a project; you can also use the "mw context set --project-id=" command + to persistently set a default project for all commands that accept this flag. + + -q, --quiet suppress process output and only display a machine-readable summary. + + This flag controls if you want to see the process output or only a summary. When using mw non-interactively (e.g. in + scripts), you can use this flag to easily get the IDs of created resources for further processing. + + --admin-email= email address of your administrator user. + + email address that will be used for the first administrator user that is created during the Magento 2 installation. + If unspecified, email address of your mStudio account will be used. This email address can be changed after the + installation is finished. + + --admin-firstname= first name of your administrator user. + + The first name that will be used for the first administrator user that is created during the Magento 2 installation. + If unspecified, the first name of your mStudio user will be used. This value can be changed after the installation + is finished. + + --admin-lastname= Lastname of your administrator user. + + The last name that will be used for the first administrator user that is created during the Magento 2 installation. + If unspecified, the last name of your mStudio user will be used. This value can be changed after the installation is + finished. + + --admin-pass= password of your administrator user. + + The password that will be used for the first administrator user that is created during the Magento 2 installation. + If unspecified, a random secure password will be generated and printed to stdout. This password can be changed after + the installation is finished + + --admin-user= Username for your administrator user. + + Username of the first administrator user which will be created during the Magento 2 installation. + If unspecified, an adequate username will be generated. + After the installation is finished, the username can be changed and additional administrator users can be created. + + --host= host to initially configure your Magento 2 installation with; needs to be created separately. + + Specify a host which will be used during the installation and as an initial host for the Magento 2 configuration. + If unspecified, the default host for the given project will be used. + This does not change the target of the used host and can be changed later by configuring the host and your Magento 2 + installation. + + --opensearch-host= the OpenSearch instance host which your Magento 2 will try to connect to + + This is the host of an existing OpenSearch instance which your application will have to connect to during + installation.This has to be a valid connection otherwise the installation will fail. + + --opensearch-port= the OpenSearch instance port which your Magento 2 will try to connect to + + This is the port of an existing OpenSearch instance which your application will have to connect to during + installation.This has to be a valid connection otherwise the installation will fail. + + --shop-currency= Currency your Magento 2 will be working with. + + The default currency your Magento 2 shop communicates prices and calculates transactions with. + If unspecified, this will default to EUR(€). The currency can be changed after the installation is finished. + + --shop-email= email address your Magento 2 will be working with. + + The email address your Magento 2 installation will be using for correspondence with end users. + If unspecified, your mStudio account email will be used. This email address can be changed after the installation is + finished. + + --shop-lang= language your Magento 2 will be working with. + + The default language your Magento 2 installation will be using. The front- and back end will be displayed using the + given language. + If unspecified, this will default to German (de_DE). The language can be changed after the installation is finished. + + --site-title= site title for your Magento 2 installation. + + The site title for this Magento 2 installation. It is also the title shown in the app overview in the mStudio and + the CLI. + If unspecified, the application name and the given project ID will be used. The title can be changed after the + installation is finished + + --version= version of Magento 2 to be installed. + + Specify the version in which your Magento 2 will be installed. + If unspecified, the Magento 2 will be installed in the latest available version. +``` + ## `mw app install matomo` Creates new Matomo installation. diff --git a/src/commands/app/install/magento2.tsx b/src/commands/app/install/magento2.tsx new file mode 100644 index 00000000..b75f8f74 --- /dev/null +++ b/src/commands/app/install/magento2.tsx @@ -0,0 +1,48 @@ +import { ExecRenderBaseCommand } from "../../../lib/basecommands/ExecRenderBaseCommand.js"; +import React from "react"; +import { + AppInstallationResult, + AppInstaller, +} from "../../../lib/resources/app/Installer.js"; + +export const magento2Installer = new AppInstaller( + "03c7cd76-7e0d-4504-932c-06947b370020", + "Magento 2", + [ + "version", + "host", + "admin-user", + "admin-email", + "admin-pass", + "admin-firstname", + "admin-lastname", + "site-title", + "shop-email", + "shop-lang", + "shop-currency", + "opensearch-host", + "opensearch-port", + ] as const, + { "shop-lang": "de_DE" }, +); + +export default class InstallMagento2 extends ExecRenderBaseCommand< + typeof InstallMagento2, + AppInstallationResult +> { + static description = magento2Installer.description; + static flags = magento2Installer.flags; + + protected async exec(): Promise<{ appInstallationId: string }> { + return magento2Installer.exec( + this.apiClient, + this.args, + this.flags, + this.config, + ); + } + + protected render(result: AppInstallationResult): React.ReactNode { + return magento2Installer.render(result, this.flags); + } +} diff --git a/src/lib/resources/app/Installer.tsx b/src/lib/resources/app/Installer.tsx index ea140f47..52244588 100644 --- a/src/lib/resources/app/Installer.tsx +++ b/src/lib/resources/app/Installer.tsx @@ -27,6 +27,7 @@ export class AppInstaller { public readonly appId: string; public readonly appName: string; public readonly appSupportedFlags: readonly TFlagName[]; + public readonly defaultFlagValues: Partial>; public readonly description: string; public mutateFlags?: ( @@ -41,10 +42,12 @@ export class AppInstaller { appId: string, appName: string, appSupportedFlags: readonly TFlagName[], + defaultFlagValues: Partial> = {}, ) { this.appId = appId; this.appName = appName; this.appSupportedFlags = appSupportedFlags; + this.defaultFlagValues = defaultFlagValues; this.description = AppInstaller.makeDescription(appName); } @@ -85,6 +88,7 @@ export class AppInstaller { flags, projectId, this.appName, + this.defaultFlagValues, ); const appVersion: AppAppVersion = await normalizeToAppVersionUuid( diff --git a/src/lib/resources/app/flags.tsx b/src/lib/resources/app/flags.tsx index e9fdcef6..4826adc1 100644 --- a/src/lib/resources/app/flags.tsx +++ b/src/lib/resources/app/flags.tsx @@ -65,6 +65,8 @@ type AvailableFlags = typeof waitFlags & { "shop-currency": OptionFlag; "install-mode": OptionFlag; "document-root": OptionFlag; + "opensearch-host": OptionFlag; + "opensearch-port": OptionFlag; entrypoint: OptionFlag; }; @@ -164,6 +166,20 @@ function buildFlagsWithDescription(appName: string): AvailableFlags { "This is the document root from which the files of your application will be served by the web server. This directory is specified relative to the installation path.", default: "/", }), + "opensearch-host": Flags.string({ + required: true, + summary: `the OpenSearch instance host which your ${appName} will try to connect to`, + description: + "This is the host of an existing OpenSearch instance which your application will have to connect to during installation." + + "This has to be a valid connection otherwise the installation will fail.", + }), + "opensearch-port": Flags.string({ + required: true, + summary: `the OpenSearch instance port which your ${appName} will try to connect to`, + description: + "This is the port of an existing OpenSearch instance which your application will have to connect to during installation." + + "This has to be a valid connection otherwise the installation will fail.", + }), entrypoint: Flags.string({ summary: `the command that should be used to start your ${appName} application.`, description: @@ -213,6 +229,7 @@ export async function autofillFlags( flags: Partial>>, projectId: string, appName: string, + defaults: Partial>, ): Promise { const ownUser = await apiClient.user.getOwnAccount(); assertStatus(ownUser, 200); @@ -322,8 +339,10 @@ export async function autofillFlags( // Shop Language Code if (necessaryFlags.includes("shop-lang") && !flags["shop-lang"]) { - flags["shop-lang"] = "de-DE"; - process.addInfo(Using default shop language 'de_DE'.); + flags["shop-lang"] = defaults["shop-lang"] ?? "de-DE"; + process.addInfo( + Using default shop language '{flags["shop-lang"]}'., + ); } // Shop Currency