Skip to content

Commit

Permalink
implement Magento2 install command
Browse files Browse the repository at this point in the history
  • Loading branch information
niristius committed Aug 13, 2024
1 parent 08c43b9 commit 90346ad
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
47 changes: 47 additions & 0 deletions src/commands/app/install/magento2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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,
);

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);
}
}
22 changes: 21 additions & 1 deletion src/lib/resources/app/flags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type AvailableFlags = typeof waitFlags & {
"shop-currency": OptionFlag<string | undefined>;
"install-mode": OptionFlag<string>;
"document-root": OptionFlag<string>;
"opensearch-host": OptionFlag<string>;
"opensearch-port": OptionFlag<string>;
entrypoint: OptionFlag<string | undefined>;
};

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -322,7 +338,11 @@ export async function autofillFlags(

// Shop Language Code
if (necessaryFlags.includes("shop-lang") && !flags["shop-lang"]) {
flags["shop-lang"] = "de-DE";
if (appName.toLowerCase().includes("magento")) {
flags["shop-lang"] = "de_DE";
} else {
flags["shop-lang"] = "de-DE";
}
process.addInfo(<Text>Using default shop language 'de_DE'.</Text>);
}

Expand Down

0 comments on commit 90346ad

Please sign in to comment.