Skip to content

Commit

Permalink
Add Command data files of PowerShell 6.1.0 (#1075)
Browse files Browse the repository at this point in the history
* add command data file for pwsh 6.1.0 on windows 10 1803. Also make it the default reference

* add command date file using Ubuntu 18.04

* update documentation

* add os details about command data files

* Add macOS file from SteveL-MSFT and add to documentation

* Add command data file for raspbian and add to docs. Thanks @tylerl0706

* Remove 6.0.2 files since we have 6.1 files and 6.0 is out of support already

* fix failing test by adapting settings file and add more info to documentation
  • Loading branch information
bergmeister authored Mar 2, 2019
1 parent d1a12b6 commit dff9522
Show file tree
Hide file tree
Showing 9 changed files with 1,994 additions and 143 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,696 changes: 1,696 additions & 0 deletions Engine/Settings/core-6.1.0-macos.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions RuleDocumentation/UseCompatibleCmdlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ This rule flags cmdlets that are not available in a given Edition/Version of Pow
@{
'Rules' = @{
'PSUseCompatibleCmdlets' = @{
'compatibility' = @("core-6.0.2-windows")
'compatibility' = @("core-6.1.0-windows")
}
}
}
```

The parameter `compatibility` is a list that contain any of the following `{desktop-3.0-windows, desktop-4.0-windows, desktop-5.1.14393.206-windows, core-6.0.2-windows, core-6.0.2-linux, core-6.0.2-macos}`.
The parameter `compatibility` is a list that contain any of the following

- desktop-3.0-windows
- desktop-4.0-windows (taken from Windows Server 2012R2)
- desktop-5.1.14393.206-windows
- core-6.1.0-windows (taken from Windows 10 - 1803)
- core-6.1.0-linux (taken from Ubuntu 18.04)
- core-6.1.0-linux-arm (taken from Raspbian)
- core-6.1.0-macos

Usually, patched versions of PowerShell have the same cmdlet data, therefore only settings of major and minor versions of PowerShell are supplied. One can also create a custom settings file as well with the [New-CommandDataFile.ps1](https://github.com/PowerShell/PSScriptAnalyzer/blob/development/Utils/New-CommandDataFile.ps1) script and use it by placing the created `JSON` into the `Settings` folder of the `PSScriptAnalyzer` module installation folder, then the `compatibility` parameter is just its file name (that can also be changed if desired).
Note that the `core-6.0.2-*` files were removed in PSScriptAnalyzer 1.18 since PowerShell 6.0 reached it's end of life.
2 changes: 1 addition & 1 deletion Rules/UseCompatibleCmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private struct RuleParameters
private bool hasInitializationError;
private string reference;
private readonly string defaultReference = "desktop-5.1.14393.206-windows";
private readonly string alternativeDefaultReference = "core-6.0.2-windows";
private readonly string alternativeDefaultReference = "core-6.1.0-windows";
private RuleParameters ruleParameters;

public UseCompatibleCmdlets()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Rules/UseCompatibleCmdlets.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Describe "UseCompatibleCmdlets" {
}
}

$settings = @{rules=@{PSUseCompatibleCmdlets=@{compatibility=@("core-6.0.2-windows")}}}
$settings = @{rules=@{PSUseCompatibleCmdlets=@{compatibility=@("core-6.1.0-windows")}}}

Context "Microsoft.PowerShell.Core" {
@('Enter-PSSession', 'Foreach-Object', 'Get-Command') | `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@{
'Rules' = @{
'PSUseCompatibleCmdlets' = @{
'compatibility' = @("core-6.0.2-windows")
'compatibility' = @("core-6.1.0-windows")
}
}
}
2 changes: 1 addition & 1 deletion Utils/New-CommandDataFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.EXAMPLE
C:\PS> ./New-CommandDataFile.ps1
Suppose this file is run on the following version of PowerShell: PSVersion = 6.0.2, PSEdition = Core, and Windows 10 operating system. Then this script will create a file named core-6.0.2-windows.json that contains a JSON object of the following form:
Suppose this file is run on the following version of PowerShell: PSVersion = 6.1.0, PSEdition = Core, and Windows 10 operating system. Then this script will create a file named core-6.1.0-windows.json that contains a JSON object of the following form:
{
"Modules" : [
"Module1" : {
Expand Down

0 comments on commit dff9522

Please sign in to comment.