4
4
import { workspace } from "vscode" ;
5
5
import { instrumentOperationStep } from "vscode-extension-telemetry-wrapper" ;
6
6
import { serviceManager } from "../model" ;
7
- import { MatadataType , Packaging } from "../model/Metadata" ;
7
+ import { MetadataType , Packaging } from "../model/Metadata" ;
8
8
import { IPickMetadata , IProjectMetadata , IStep } from "./HandlerInterfaces" ;
9
9
import { SpecifyJavaVersionStep } from "./SpecifyJavaVersionStep" ;
10
10
import { createPickBox } from "./utils" ;
@@ -30,17 +30,27 @@ export class SpecifyPackagingStep implements IStep {
30
30
31
31
private async specifyPackaging ( projectMetadata : IProjectMetadata ) : Promise < boolean > {
32
32
const packaging : string = projectMetadata . defaults . packaging || workspace . getConfiguration ( "spring.initializr" ) . get < string > ( "defaultPackaging" ) ;
33
+
33
34
if ( packaging ) {
34
35
projectMetadata . packaging = packaging && packaging . toLowerCase ( ) ;
35
36
return true ;
36
37
}
38
+
39
+ const items = await serviceManager . getItems ( projectMetadata . serviceUrl , MetadataType . PACKAGING ) ;
40
+
41
+ if ( projectMetadata . enableSmartDefaults === true ) {
42
+ projectMetadata . packaging = items . find ( x => x . default === true ) ?. label ?. toLowerCase ( ) ;
43
+ return true ;
44
+ }
45
+
37
46
const pickMetaData : IPickMetadata < Packaging > = {
38
47
metadata : projectMetadata ,
39
48
title : "Spring Initializr: Specify packaging type" ,
40
49
pickStep : SpecifyPackagingStep . getInstance ( ) ,
41
50
placeholder : "Specify packaging type." ,
42
- items : serviceManager . getItems ( projectMetadata . serviceUrl , MatadataType . PACKAGING ) ,
51
+ items : items
43
52
} ;
53
+
44
54
return await createPickBox ( pickMetaData ) ;
45
55
}
46
56
}
0 commit comments