Skip to content

Commit

Permalink
fix #59: add base starter if no explict dependency (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eskibear authored Apr 28, 2018
1 parent 0626554 commit 23a3912
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/DependencyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class DependencyManager {
}

public getSelectedDependencies(): IDependency[] {
return this.selectedIds.map((id: string) => this.dict[id]);
return this.selectedIds.map((id: string) => this.dict[id]).filter(Boolean);
}

public getUnselectedDependencies(): IDependency[] {
Expand Down
3 changes: 2 additions & 1 deletion src/Metadata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import * as _ from "lodash";
import { IDependency, IStarters, ITopLevelAttribute } from "./Interfaces";
import { Utils } from "./Utils";
import { Versions } from "./Versions";
Expand All @@ -26,7 +27,7 @@ export namespace dependencies {
const rawJSONString: string = await Utils.downloadFile(`${Utils.settings.getServiceUrl()}dependencies?bootVersion=${bootVersion}`, true, { Accept: "application/vnd.initializr.v2.1+json" });
starters[bootVersion] = JSON.parse(rawJSONString);
}
return starters[bootVersion];
return _.cloneDeep(starters[bootVersion]);
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/Routines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ export module Routines {
vscode.window.showInformationMessage("No changes.");
return;
}
const msgRemove: string = (toRemove && toRemove.length) ? `Removing: [${toRemove.map(d => manager.dict[d].name).join(", ")}].` : "";
const msgAdd: string = (toAdd && toAdd.length) ? `Adding: [${toAdd.map(d => manager.dict[d].name).join(", ")}].` : "";
const msgRemove: string = (toRemove && toRemove.length) ? `Removing: [${toRemove.map(d => manager.dict[d] && manager.dict[d].name).filter(Boolean).join(", ")}].` : "";
const msgAdd: string = (toAdd && toAdd.length) ? `Adding: [${toAdd.map(d => manager.dict[d] && manager.dict[d].name).filter(Boolean).join(", ")}].` : "";
const choice: string = await vscode.window.showWarningMessage(`${msgRemove} ${msgAdd} Proceed?`, "Proceed", "Cancel");
if (choice !== "Proceed") {
TelemetryHelper.finishStep(stepCancel);
Expand All @@ -196,6 +196,14 @@ export module Routines {
TelemetryHelper.finishStep(stepProceed);
}

// add spring-boot-starter if no selected starters
if (manager.selectedIds.length === 0) {
toAdd.push("spring-boot-starter");
starters.dependencies["spring-boot-starter"] = {
groupId: "org.springframework.boot",
artifactId: "spring-boot-starter"
};
}
// modify xml object
const newXml: { project: XmlNode } = getUpdatedPomXml(xml, starters, toRemove, toAdd);

Expand Down

0 comments on commit 23a3912

Please sign in to comment.