-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 217: Allow Package Name specification (#230)
* added default setting for packageName * function for validating package names * added packageName property to handler interfaces * added step for specifying package name using groupId + artifactId as default value * call package name step after artifactId * handling new step * removed default config since it's always dynamic * fix: replace hyphen with underscore when recommending a packageName --------- Co-authored-by: Jinbo Wang <jinbwan@microsoft.com>
- Loading branch information
1 parent
d1e9eed
commit 8bf8732
Showing
6 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
import { instrumentOperationStep } from "vscode-extension-telemetry-wrapper"; | ||
import { IInputMetaData, IProjectMetadata, IStep } from "./HandlerInterfaces"; | ||
import { SpecifyPackagingStep } from "./SpecifyPackagingStep"; | ||
import { createInputBox } from "./utils"; | ||
|
||
export class SpecifyPackageNameStep implements IStep { | ||
|
||
public static getInstance(): SpecifyPackageNameStep { | ||
return SpecifyPackageNameStep.specifyPackageNameStep; | ||
} | ||
|
||
private static specifyPackageNameStep: SpecifyPackageNameStep = new SpecifyPackageNameStep(); | ||
|
||
private defaultInput: string; | ||
|
||
constructor() { | ||
this.resetDefaultInput(); | ||
} | ||
|
||
public getDefaultInput(): string { | ||
return this.defaultInput; | ||
} | ||
|
||
public setDefaultInput(defaultInput: string): void { | ||
this.defaultInput = defaultInput; | ||
} | ||
|
||
public resetDefaultInput(): void { | ||
this.defaultInput = null; | ||
} | ||
|
||
public getNextStep(): IStep | undefined { | ||
return SpecifyPackagingStep.getInstance(); | ||
} | ||
|
||
public async execute(operationId: string, projectMetadata: IProjectMetadata): Promise<IStep | undefined> { | ||
if (!await instrumentOperationStep(operationId, "PackageName", this.specifyPackageName)(projectMetadata)) { | ||
return projectMetadata.pickSteps.pop(); | ||
} | ||
return this.getNextStep(); | ||
} | ||
|
||
private async specifyPackageName(projectMetadata: IProjectMetadata): Promise<boolean> { | ||
const recommendedPackageName = `${projectMetadata.groupId}.${projectMetadata.artifactId}`.replace("-", "_"); | ||
|
||
const inputMetaData: IInputMetaData = { | ||
metadata: projectMetadata, | ||
title: "Spring Initializr: Input Package Name", | ||
pickStep: SpecifyPackageNameStep.getInstance(), | ||
placeholder: "e.g. com.example", | ||
prompt: "Input Package Name for your project.", | ||
defaultValue: recommendedPackageName || SpecifyPackageNameStep.getInstance().defaultInput | ||
}; | ||
return await createInputBox(inputMetaData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters