-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add local dotnet tools management. Fixes #248
- Loading branch information
Showing
21 changed files
with
342 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { TerminalCommand } from "@extensions/defaultTerminalCommands"; | ||
import { CustomTerminalAction } from "./base/CustomTerminalAction"; | ||
|
||
export class AddLocalToolReference extends CustomTerminalAction { | ||
constructor(private readonly workspaceRoot: string, private readonly packageId: string, packageVersion?: string) { | ||
super({ | ||
name: AddLocalToolReference.getTerminalCommand(workspaceRoot, packageId, packageVersion), | ||
parameters: { packageId, packageVersion: packageVersion || "" }, | ||
workingFolder: workspaceRoot | ||
}); | ||
} | ||
|
||
public toString(): string { | ||
return `Add local tool reference ${this.packageId} to workspace ${this.workspaceRoot}`; | ||
} | ||
|
||
private static getTerminalCommand(workspaceRoot: string, packageId: string, packageVersion: string | undefined): TerminalCommand { | ||
if (packageVersion) { | ||
return "addLocalToolReferenceWithVersion"; | ||
} else { | ||
return "addLocalToolReference"; | ||
} | ||
} | ||
} |
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,15 @@ | ||
import { CustomTerminalAction } from "./base/CustomTerminalAction"; | ||
|
||
export class RemoveLocalToolReference extends CustomTerminalAction { | ||
constructor(private readonly workspaceRoot: string, private readonly packageId: string) { | ||
super({ | ||
name: "removeLocalToolReference", | ||
parameters: { packageId }, | ||
workingFolder: workspaceRoot | ||
}); | ||
} | ||
|
||
public toString(): string { | ||
return `Remove local tool reference ${this.packageId} from workspace ${this.workspaceRoot}`; | ||
} | ||
} |
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,15 @@ | ||
import { CustomTerminalAction } from "./base/CustomTerminalAction"; | ||
|
||
export class UpdateLocalToolReference extends CustomTerminalAction { | ||
constructor(private readonly workspaceRoot: string, private readonly packageId: string) { | ||
super({ | ||
name: 'updateLocalToolReference', | ||
parameters: { packageId }, | ||
workingFolder: workspaceRoot | ||
}); | ||
} | ||
|
||
public toString(): string { | ||
return `Update local tool reference ${this.packageId} in workspace ${this.workspaceRoot}`; | ||
} | ||
} |
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,30 @@ | ||
import * as dialogs from '@extensions/dialogs'; | ||
import { TreeItem } from "@tree"; | ||
import { Action, AddLocalToolReference } from "@actions"; | ||
import { AddPackageCommand } from "@commands"; | ||
|
||
export class AddLocalToolCommand extends AddPackageCommand { | ||
constructor() { | ||
super('Add local tool'); | ||
} | ||
|
||
public shouldRun(item: TreeItem): boolean { | ||
return item && !!item.workspaceRoot; | ||
} | ||
|
||
public async getActions(item: TreeItem): Promise<Action[]> { | ||
if (!item || !item.workspaceRoot) { return []; } | ||
|
||
this.wizard = new dialogs.Wizard('Add local dotnet tool') | ||
.selectOption('Select a feed', () => this.getNugetFeeds(item.workspaceRoot) ) | ||
.searchOption('Search a tool', search => this.searchAndMapNugetPackages(search, 'dotnettool'), '') | ||
.selectOption('Select a tool', () => this.getCurrentPackageVersions(), () => this.getCurrentPackageDefaultVersion()); | ||
|
||
const parameters = await this.wizard.run(); | ||
if (!parameters) { | ||
return []; | ||
} | ||
|
||
return [ new AddLocalToolReference(item.workspaceRoot, parameters[1], parameters[2]) ]; | ||
} | ||
} |
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,19 @@ | ||
import { TreeItem } from "@tree"; | ||
import { Action, RemoveLocalToolReference } from "@actions"; | ||
import { ActionsCommand } from "@commands"; | ||
|
||
export class RemoveLocalToolCommand extends ActionsCommand { | ||
constructor() { | ||
super('Remove local tool'); | ||
} | ||
|
||
public shouldRun(item: TreeItem): boolean { | ||
return !!item && !!item.workspaceRoot && !!item.path; | ||
} | ||
|
||
public async getActions(item: TreeItem): Promise<Action[]> { | ||
if (!item || !item.workspaceRoot || !item.path) { return []; } | ||
|
||
return [ new RemoveLocalToolReference(item.workspaceRoot, item.path) ]; | ||
} | ||
} |
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,20 @@ | ||
import { Action, UpdateLocalToolReference } from "@actions"; | ||
import { ActionsCommand } from "@commands"; | ||
import { LocalToolsTreeItem } from "@tree/items/LocalToolsTreeItem"; | ||
|
||
export class UpdateLocalToolsVersionCommand extends ActionsCommand { | ||
constructor() { | ||
super('UpdateLocalToolsVersion'); | ||
} | ||
|
||
public shouldRun(item: LocalToolsTreeItem): boolean { | ||
return !!item && !!item.workspaceRoot; | ||
} | ||
|
||
public async getActions(item: LocalToolsTreeItem): Promise<Action[]> { | ||
if (!item || !item.workspaceRoot) { return []; } | ||
|
||
const references = item.getLocalTools(); | ||
return references.map(reference => new UpdateLocalToolReference(item.workspaceRoot, reference.name)); | ||
} | ||
} |
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
Oops, something went wrong.