-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VS Code task to re-run and update
fixes #1987
- Loading branch information
Showing
7 changed files
with
130 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace RevEng.Common.Cli.VsCode | ||
{ | ||
public class Input | ||
{ | ||
public string type { get; set; } | ||
public string id { get; set; } | ||
public string description { get; set; } | ||
public string @default { get; set; } | ||
} | ||
} |
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,7 @@ | ||
namespace RevEng.Common.Cli.VsCode | ||
{ | ||
public class Presentation | ||
{ | ||
public string reveal { get; set; } | ||
} | ||
} |
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 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace RevEng.Common.Cli.VsCode | ||
{ | ||
internal class TaskItem | ||
{ | ||
public string label { get; set; } | ||
public string command { get; set; } | ||
public string type { get; set; } | ||
public List<string> args { get; set; } | ||
public string group { get; set; } | ||
public Presentation presentation { get; set; } | ||
public string problemMatcher { get; set; } | ||
} | ||
} |
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,11 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace RevEng.Common.Cli.VsCode | ||
{ | ||
internal class VsCodeTask | ||
{ | ||
public string version { get; set; } | ||
public List<TaskItem> tasks { get; set; } | ||
public List<Input> inputs { get; set; } | ||
} | ||
} |
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,83 @@ | ||
using System.IO; | ||
using System.Text; | ||
using System.Text.Json; | ||
|
||
namespace RevEng.Common.Cli.VsCode | ||
{ | ||
public static class VsCodeTaskHelper | ||
{ | ||
public static void GenerateTaskPayload(string projectPath, int version, string redactedConnectionString) | ||
{ | ||
var path = Path.Combine(projectPath, ".vscode"); | ||
|
||
if (!Directory.Exists(path)) | ||
{ | ||
Directory.CreateDirectory(path); | ||
} | ||
|
||
path = Path.Combine(path, "tasks.json"); | ||
|
||
if (File.Exists(path)) | ||
{ | ||
return; | ||
} | ||
|
||
var vsCodeTask = new VsCodeTask | ||
{ | ||
version = "2.0.0", | ||
tasks = new System.Collections.Generic.List<TaskItem> | ||
{ | ||
new TaskItem | ||
{ | ||
label = "EF Core Power Tools: Reverse Engineer", | ||
command = "efcpt", | ||
type = "shell", | ||
args = new System.Collections.Generic.List<string> | ||
{ | ||
"${input:connection}", | ||
"mssql", | ||
}, | ||
group = "none", | ||
presentation = new Presentation | ||
{ | ||
reveal = "always", | ||
}, | ||
problemMatcher = "$msCompile", | ||
}, | ||
new TaskItem | ||
{ | ||
label = "EF Core Power Tools: Update", | ||
command = "dotnet", | ||
type = "shell", | ||
args = new System.Collections.Generic.List<string> | ||
{ | ||
"tool", | ||
"update", | ||
"-g", | ||
"--version", | ||
$"{version}.0.*-*", | ||
}, | ||
group = "none", | ||
presentation = new Presentation | ||
{ | ||
reveal = "always", | ||
}, | ||
problemMatcher = "$msCompile", | ||
}, | ||
}, | ||
inputs = new System.Collections.Generic.List<Input> | ||
{ | ||
new Input | ||
{ | ||
type = "promptString", | ||
id = "connection", | ||
description = "Enter the ADO.NET connection string to use", | ||
@default = redactedConnectionString, | ||
}, | ||
}, | ||
}; | ||
|
||
File.WriteAllText(path, JsonSerializer.Serialize(vsCodeTask, new JsonSerializerOptions { WriteIndented = true }), Encoding.UTF8); | ||
} | ||
} | ||
} |
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