Skip to content

Commit

Permalink
fix: only use api defaults if they are present
Browse files Browse the repository at this point in the history
  • Loading branch information
brunovieira97 committed Sep 14, 2024
1 parent bbc31a5 commit 4e8fd28
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/handler/SpecifyBootVersionStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export class SpecifyBootVersionStep implements IStep {
const items = await serviceManager.getItems(projectMetadata.serviceUrl, MetadataType.BOOTVERSION);

if (projectMetadata.enableSmartDefaults === true) {
projectMetadata.bootVersion = items.find(x => x.default === true)?.value?.id;
return true;
const recommendedBootVersion: string = items.find(x => x.default === true)?.value?.id;

if (recommendedBootVersion) {
projectMetadata.bootVersion = recommendedBootVersion;
return true;
}
}

const pickMetaData: IPickMetadata<BootVersion> = {
Expand Down
8 changes: 6 additions & 2 deletions src/handler/SpecifyJavaVersionStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ export class SpecifyJavaVersionStep implements IStep {
const items = await serviceManager.getItems(projectMetadata.serviceUrl, MetadataType.JAVAVERSION);

if (projectMetadata.enableSmartDefaults === true) {
projectMetadata.javaVersion = items.find(x => x.default === true)?.value?.id;
return true;
const recommendedJavaVersion: string = items.find(x => x.default === true)?.value?.id;

if (recommendedJavaVersion) {
projectMetadata.javaVersion = recommendedJavaVersion;
return true;
}
}

const pickMetaData: IPickMetadata<JavaVersion> = {
Expand Down
8 changes: 6 additions & 2 deletions src/handler/SpecifyLanguageStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ export class SpecifyLanguageStep implements IStep {
const items = await serviceManager.getItems(projectMetadata.serviceUrl, MetadataType.LANGUAGE);

if (projectMetadata.enableSmartDefaults === true) {
projectMetadata.language = items.find(x => x.default === true)?.label.toLowerCase();
return true;
const recommendedLanguage: string = items.find(x => x.default === true)?.label.toLowerCase();

if (recommendedLanguage) {
projectMetadata.language = recommendedLanguage;
return true;
}
}

const pickMetaData: IPickMetadata<Language> = {
Expand Down
8 changes: 6 additions & 2 deletions src/handler/SpecifyPackagingStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ export class SpecifyPackagingStep implements IStep {
const items = await serviceManager.getItems(projectMetadata.serviceUrl, MetadataType.PACKAGING);

if (projectMetadata.enableSmartDefaults === true) {
projectMetadata.packaging = items.find(x => x.default === true)?.label?.toLowerCase();
return true;
const recommendedPackaging: string = items.find(x => x.default === true)?.label?.toLowerCase();

if (recommendedPackaging) {
projectMetadata.packaging = recommendedPackaging;
return true;
}
}

const pickMetaData: IPickMetadata<Packaging> = {
Expand Down

0 comments on commit 4e8fd28

Please sign in to comment.