Skip to content

Commit

Permalink
read new setting and use default for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
brunovieira97 committed Feb 9, 2024
1 parent 087abac commit bbc31a5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/handler/SpecifyPackagingStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { workspace } from "vscode";
import { instrumentOperationStep } from "vscode-extension-telemetry-wrapper";
import { serviceManager } from "../model";
import { MatadataType, Packaging } from "../model/Metadata";
import { MetadataType, Packaging } from "../model/Metadata";
import { IPickMetadata, IProjectMetadata, IStep } from "./HandlerInterfaces";
import { SpecifyJavaVersionStep } from "./SpecifyJavaVersionStep";
import { createPickBox } from "./utils";
Expand All @@ -30,17 +30,27 @@ export class SpecifyPackagingStep implements IStep {

private async specifyPackaging(projectMetadata: IProjectMetadata): Promise<boolean> {
const packaging: string = projectMetadata.defaults.packaging || workspace.getConfiguration("spring.initializr").get<string>("defaultPackaging");

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

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 pickMetaData: IPickMetadata<Packaging> = {
metadata: projectMetadata,
title: "Spring Initializr: Specify packaging type",
pickStep: SpecifyPackagingStep.getInstance(),
placeholder: "Specify packaging type.",
items: serviceManager.getItems(projectMetadata.serviceUrl, MatadataType.PACKAGING),
items: items
};

return await createPickBox(pickMetaData);
}
}

0 comments on commit bbc31a5

Please sign in to comment.