Skip to content

Commit 43b1f1c

Browse files
Initial changes for overhaul
1 parent 5ea6dea commit 43b1f1c

File tree

141 files changed

+11449
-576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+11449
-576
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
## Ignore Visual Studio temporary files, build results, and
22
## files generated by popular Visual Studio add-ons.
33

4+
src/EditorServicesCommandSuite/gen/
5+
lib/
6+
tools/dotnet
7+
tools/ResGen
8+
49
# User-specific files
510
*.suo
611
*.user
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
#requires -Module InvokeBuild, PSScriptAnalyzer, Pester, PlatyPS -Version 5.1
2+
[CmdletBinding()]
3+
param(
4+
[ValidateSet('Debug', 'Release')]
5+
[string] $Configuration = 'Debug'
6+
)
7+
8+
$moduleName = 'EditorServicesCommandSuite'
9+
$manifest = Test-ModuleManifest -Path $PSScriptRoot\module\$moduleName.psd1 -ErrorAction Ignore -WarningAction Ignore
10+
11+
$script:Settings = @{
12+
Name = $moduleName
13+
Manifest = $manifest
14+
Version = $manifest.Version
15+
ShouldAnalyze = $true
16+
ShouldTest = $true
17+
}
18+
19+
$script:Folders = @{
20+
PowerShell = "$PSScriptRoot\module"
21+
Release = '{0}\Release\{1}\{2}' -f $PSScriptRoot, $moduleName, $manifest.Version
22+
Docs = "$PSScriptRoot\docs"
23+
Test = "$PSScriptRoot\test"
24+
PesterCC = "$PSScriptRoot\*.psm1", "$PSScriptRoot\Public\*.ps1", "$PSScriptRoot\Private\*.ps1"
25+
}
26+
27+
$script:Discovery = @{
28+
HasDocs = Test-Path ('{0}\{1}\*.md' -f $Folders.Docs, $PSCulture)
29+
HasTests = Test-Path ('{0}\*.Test.ps1' -f $Folders.Test)
30+
}
31+
32+
task Clean {
33+
$releaseFolder = $Folders.Release
34+
if (Test-Path $releaseFolder) {
35+
Remove-Item $releaseFolder -Recurse
36+
}
37+
New-Item -ItemType Directory $releaseFolder | Out-Null
38+
New-Item -ItemType Directory $releaseFolder/bin/Desktop | Out-Null
39+
New-Item -ItemType Directory $releaseFolder/bin/Core | Out-Null
40+
New-Item -ItemType Directory $releaseFolder/RefactorCmdlets | Out-Null
41+
42+
}
43+
44+
task BuildDocs -If { $Discovery.HasDocs } {
45+
$output = '{0}\{1}' -f $Folders.Release, $PSCulture
46+
$null = New-ExternalHelp -Path $PSScriptRoot\docs\$PSCulture -OutputPath $output
47+
}
48+
49+
task AssertDependencies AssertPSES, AssertPSRL
50+
51+
task AssertPSES {
52+
& "$PSScriptRoot\tools\AssertPSES.ps1"
53+
}
54+
55+
task AssertPSRL {
56+
& "$PSScriptRoot\tools\AssertPSRL.ps1"
57+
}
58+
59+
task AssertPSResGen {
60+
# Download the ResGen tool used by PowerShell core internally. This will need to be replaced
61+
# when the dotnet cli gains support for it.
62+
# The SHA in the uri's are for the 6.0.2 release commit.
63+
if (-not (Test-Path $PSScriptRoot/tools/ResGen)) {
64+
New-Item -ItemType Directory $PSScriptRoot/tools/ResGen | Out-Null
65+
}
66+
67+
if (-not (Test-Path $PSScriptRoot/tools/ResGen/Program.cs)) {
68+
$programUri = 'https://raw.githubusercontent.com/PowerShell/PowerShell/36b71ba39e36be3b86854b3551ef9f8e2a1de5cc/src/ResGen/Program.cs'
69+
Invoke-WebRequest $programUri -OutFile $PSScriptRoot/tools/ResGen/Program.cs -ErrorAction Stop
70+
}
71+
72+
if (-not (Test-Path $PSScriptRoot/tools/ResGen/ResGen.csproj)) {
73+
$projUri = 'https://raw.githubusercontent.com/PowerShell/PowerShell/36b71ba39e36be3b86854b3551ef9f8e2a1de5cc/src/ResGen/ResGen.csproj'
74+
Invoke-WebRequest $projUri -OutFile $PSScriptRoot/tools/ResGen/ResGen.csproj -ErrorAction Stop
75+
}
76+
}
77+
78+
task ResGenImpl {
79+
Push-Location $PSScriptRoot/src/EditorServicesCommandSuite
80+
try {
81+
dotnet run --project $PSScriptRoot/tools/ResGen/ResGen.csproj
82+
} finally {
83+
Pop-Location
84+
}
85+
}
86+
87+
task BuildManaged {
88+
$script:dotnet = $dotnet = & $PSScriptRoot\tools\GetDotNet.ps1 -Unix:$Discover.IsUnix
89+
if (!$Discovery.IsUnix) {
90+
& $dotnet build --framework net462 --configuration $Configuration --verbosity q -nologo
91+
}
92+
93+
& $dotnet build --framework netcoreapp2.0 --configuration $Configuration --verbosity q -nologo
94+
}
95+
96+
task BuildRefactorModule {
97+
$releaseFolder = $Folders.Release
98+
$dllToImport = if ('Core' -eq $PSEdition) {
99+
"$PSScriptRoot/src/EditorServicesCommandSuite/bin/$Configuration/netcoreapp2.0/EditorServicesCommandSuite.dll"
100+
} else {
101+
"$PSScriptRoot/src/EditorServicesCommandSuite/bin/$Configuration/net462/EditorServicesCommandSuite.dll"
102+
}
103+
104+
$script = {
105+
Add-Type -Path '{0}'
106+
[EditorServicesCommandSuite.Internal.CommandSuite]::WriteRefactorModule('{1}')
107+
}.ToString() -f $dllToImport, "$releaseFolder\RefactorCmdlets\RefactorCmdlets.cdxml"
108+
109+
$encodedScript = [convert]::ToBase64String(
110+
[System.Text.Encoding]::Unicode.GetBytes($script))
111+
112+
if ('Core' -eq $PSEdition) {
113+
pwsh -NoProfile -EncodedCommand $encodedScript
114+
} else {
115+
powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand $encodedScript
116+
}
117+
}
118+
119+
task CopyToRelease {
120+
$moduleName = $Settings.Name
121+
& "$PSScriptRoot\tools\BuildMonolith.ps1" -OutputPath $Folders.Release -ModuleName $Settings.Name
122+
123+
"$moduleName.psd1",
124+
'en-US' | ForEach-Object {
125+
Join-Path $Folders.PowerShell -ChildPath $PSItem |
126+
Copy-Item -Destination $Folders.Release -Recurse
127+
}
128+
129+
$releaseFolder = $Folders.Release
130+
Copy-Item $PSScriptRoot/src/EditorServicesCommandSuite/bin/$Configuration/net462/EditorServicesCommandSuite.* -Destination $releaseFolder/bin/Desktop
131+
Copy-Item $PSScriptRoot/src/EditorServicesCommandSuite.EditorServices/bin/$Configuration/net462/EditorServicesCommandSuite.* -Destination $releaseFolder/bin/Desktop
132+
Copy-Item $PSScriptRoot/src/EditorServicesCommandSuite.PSReadLine/bin/$Configuration/net462/EditorServicesCommandSuite.* -Destination $releaseFolder/bin/Desktop
133+
Copy-Item $PSScriptRoot/src/EditorServicesCommandSuite/bin/$Configuration/netcoreapp2.0/EditorServicesCommandSuite.* -Destination $releaseFolder/bin/Core
134+
Copy-Item $PSScriptRoot/src/EditorServicesCommandSuite.EditorServices/bin/$Configuration/netcoreapp2.0/EditorServicesCommandSuite.* -Destination $releaseFolder/bin/Core
135+
Copy-Item $PSScriptRoot/src/EditorServicesCommandSuite.PSReadLine/bin/$Configuration/netcoreapp2.0/EditorServicesCommandSuite.* -Destination $releaseFolder/bin/Core
136+
}
137+
138+
task Analyze -If { $Settings.ShouldAnalyze } {
139+
Invoke-ScriptAnalyzer -Path $Folders.Release -Settings $PSScriptRoot\ScriptAnalyzerSettings.psd1 -Recurse
140+
}
141+
142+
task Test -If { $Discovery.HasTests -and $Settings.ShouldTest } {
143+
Invoke-Pester -PesterOption @{ IncludeVSCodeMarker = $true }
144+
}
145+
146+
task DoInstall {
147+
$installBase = $Home
148+
if ($profile) { $installBase = $profile | Split-Path }
149+
$installPath = '{0}\Modules\{1}\{2}' -f $installBase, $Settings.Name, $Settings.Version
150+
151+
if (-not (Test-Path $installPath)) {
152+
$null = New-Item $installPath -ItemType Directory
153+
}
154+
155+
Copy-Item -Path ('{0}\*' -f $Folders.Release) -Destination $installPath -Force -Recurse
156+
}
157+
158+
task DoPublish {
159+
if (-not (Test-Path $env:USERPROFILE\.PSGallery\apikey.xml)) {
160+
throw 'Could not find PSGallery API key!'
161+
}
162+
163+
$apiKey = (Import-Clixml $env:USERPROFILE\.PSGallery\apikey.xml).GetNetworkCredential().Password
164+
Publish-Module -Name $Folders.Release -NuGetApiKey $apiKey -Confirm
165+
}
166+
167+
task ResGen -Jobs AssertPSResGen, ResGenImpl
168+
169+
task Build -Jobs Clean, AssertDependencies, ResGen, BuildManaged, BuildRefactorModule, CopyToRelease, BuildDocs
170+
171+
task PreRelease -Jobs Build, Analyze, Test
172+
173+
task Install -Jobs PreRelease, DoInstall
174+
175+
task Publish -Jobs PreRelease, DoPublish
176+
177+
task . Build
178+

.vscode/extensions.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// See http://go.microsoft.com/fwlink/?LinkId=827846
33
// for the documentation about the extensions.json format
44
"recommendations": [
5-
"ms-vscode.PowerShell"
6-
]
5+
"ms-vscode.csharp",
6+
"ms-vscode.powershell",
7+
"DavidAnson.vscode-markdownlint",
8+
],
79
}

.vscode/launch.json

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,71 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"type": "PowerShell",
6-
"request": "launch",
7-
"name": "PowerShell debugHarness (Temporary Console)",
8-
"script": "${workspaceRoot}/debugHarness.ps1",
9-
"args": [],
10-
"cwd":"${workspaceRoot}",
11-
"createTemporaryIntegratedConsole": true
12-
},
13-
{
14-
"type": "PowerShell",
15-
"request": "launch",
16-
"name": "PowerShell debugHarness",
17-
"script": "${workspaceRoot}/debugHarness.ps1",
18-
"args": [],
19-
"cwd":"${workspaceRoot}"
20-
},
21-
{
22-
"type": "PowerShell",
23-
"request": "launch",
24-
"name": "PowerShell Launch Current File",
25-
"script": "${file}",
26-
"args": [],
27-
"cwd": "${file}"
28-
},
29-
{
30-
"type": "PowerShell",
31-
"request": "launch",
32-
"name": "PowerShell Launch Current File in Temporary Console",
33-
"script": "${file}",
34-
"args": [],
35-
"cwd": "${file}",
36-
"createTemporaryIntegratedConsole": true
5+
"name": ".NET FullCLR Attach",
6+
"type": "clr",
7+
"request": "attach",
8+
"processId": "${command:pickProcess}",
9+
"justMyCode": true,
3710
},
3811
{
39-
"type": "PowerShell",
12+
"name": ".NET FullCLR Launch (console)",
13+
"type": "clr",
4014
"request": "launch",
41-
"name": "PowerShell Launch Current File w/Args Prompt",
42-
"script": "${file}",
15+
"preLaunchTask": "Build",
16+
"cwd": "${workspaceFolder}",
17+
"stopAtEntry": false,
18+
"justMyCode": true,
19+
"console": "externalTerminal",
20+
"program": "powershell.exe",
4321
"args": [
44-
"${command:SpecifyScriptArgs}"
22+
"-ExecutionPolicy",
23+
"Bypass",
24+
"-NoExit",
25+
"-Command",
26+
". \"${workspaceRoot}/debugHarness.ps1\"",
4527
],
46-
"cwd": "${file}"
4728
},
4829
{
49-
"type": "PowerShell",
30+
"name": ".NET CoreCLR Attach",
31+
"type": "coreclr",
5032
"request": "attach",
51-
"name": "PowerShell Attach to Host Process",
52-
"processId": "${command:PickPSHostProcess}",
53-
"runspaceId": 1
33+
"processId": "${command:pickProcess}",
34+
"justMyCode": true,
5435
},
5536
{
56-
"type": "PowerShell",
37+
"name": ".NET CoreCLR Launch (console)",
38+
"type": "coreclr",
5739
"request": "launch",
58-
"name": "PowerShell Interactive Session",
59-
"cwd": "${workspaceRoot}"
60-
}
61-
]
40+
"preLaunchTask": "Build",
41+
"cwd": "${workspaceFolder}",
42+
"stopAtEntry": false,
43+
"justMyCode": true,
44+
"console": "externalTerminal",
45+
"linux": {
46+
"program": "/usr/bin/pwsh",
47+
"args": [
48+
"-NoExit",
49+
"-Command",
50+
". \"${workspaceRoot}/debugHarness.ps1\"",
51+
],
52+
},
53+
"osx": {
54+
"program": "/usr/local/bin/pwsh",
55+
"args": [
56+
"-NoExit",
57+
"-Command",
58+
". \"${workspaceRoot}/debugHarness.ps1\"",
59+
],
60+
},
61+
"program": "pwsh.exe",
62+
"args": [
63+
"-ExecutionPolicy",
64+
"Bypass",
65+
"-NoExit",
66+
"-Command",
67+
". \"${workspaceRoot}/debugHarness.ps1\"",
68+
],
69+
},
70+
],
6271
}
6372

0 commit comments

Comments
 (0)