Skip to content

Commit

Permalink
desmell lang flag, implement defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
niristius committed Aug 27, 2024
1 parent aced1b9 commit 918d25b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/commands/app/install/magento2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const magento2Installer = new AppInstaller(
"opensearch-host",
"opensearch-port",
] as const,
{ "shop-lang": "de_DE" },
);

export default class InstallMagento2 extends ExecRenderBaseCommand<
Expand Down
4 changes: 4 additions & 0 deletions src/lib/resources/app/Installer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class AppInstaller<TFlagName extends AvailableFlagName> {
public readonly appId: string;
public readonly appName: string;
public readonly appSupportedFlags: readonly TFlagName[];
public readonly defaultFlagValues: Partial<Record<AvailableFlagName, string>>;
public readonly description: string;

public mutateFlags?: (
Expand All @@ -41,10 +42,12 @@ export class AppInstaller<TFlagName extends AvailableFlagName> {
appId: string,
appName: string,
appSupportedFlags: readonly TFlagName[],
defaultFlagValues: Partial<Record<AvailableFlagName, string>> = {},
) {
this.appId = appId;
this.appName = appName;
this.appSupportedFlags = appSupportedFlags;
this.defaultFlagValues = defaultFlagValues;
this.description = AppInstaller.makeDescription(appName);
}

Expand Down Expand Up @@ -85,6 +88,7 @@ export class AppInstaller<TFlagName extends AvailableFlagName> {
flags,
projectId,
this.appName,
this.defaultFlagValues,
);

const appVersion: AppAppVersion = await normalizeToAppVersionUuid(
Expand Down
11 changes: 5 additions & 6 deletions src/lib/resources/app/flags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export async function autofillFlags(
flags: Partial<OutputFlags<RelevantFlagInput<AvailableFlagName[]>>>,
projectId: string,
appName: string,
defaults: Partial<Record<AvailableFlagName, string>>,
): Promise<void> {
const ownUser = await apiClient.user.getOwnAccount();
assertStatus(ownUser, 200);
Expand Down Expand Up @@ -338,12 +339,10 @@ export async function autofillFlags(

// Shop Language Code
if (necessaryFlags.includes("shop-lang") && !flags["shop-lang"]) {
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>);
flags["shop-lang"] = defaults["shop-lang"] ?? "de-DE";
process.addInfo(
<Text>Using default shop language '{flags["shop-lang"]}'.</Text>,
);
}

// Shop Currency
Expand Down

0 comments on commit 918d25b

Please sign in to comment.