-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(#310, #3318) Add Uninstall-ChocolateyPath cmdlet & rewrite associated functions as cmdlets #3440
(#310, #3318) Add Uninstall-ChocolateyPath cmdlet & rewrite associated functions as cmdlets #3440
Conversation
4dc4c82
to
1b4485c
Compare
nuspec/nuget/Chocolatey.PowerShell/Chocolatey.PowerShell.nuspec
Outdated
Show resolved
Hide resolved
nuspec/nuget/Chocolatey.PowerShell/Chocolatey.PowerShell.nuspec
Outdated
Show resolved
Hide resolved
nuspec/nuget/Chocolatey.PowerShell/Chocolatey.PowerShell.nuspec
Outdated
Show resolved
Hide resolved
src/Chocolatey.PowerShell/Commands/GetEnvironmentVariableNamesCommand.cs
Outdated
Show resolved
Hide resolved
src/Chocolatey.PowerShell/Commands/SetEnvironmentVariableCommand.cs
Outdated
Show resolved
Hide resolved
tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1
Outdated
Show resolved
Hide resolved
40934f0
to
50e5994
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Chocolatey.PowerShell/Commands/InstallChocolateyPathCommand.cs
Outdated
Show resolved
Hide resolved
@vexx32 one other thing that I thought about yesterday, but didn't mention... Can you update your commit messages to provide more information? If/when reviewing the commits directly, we won't have the same context that exists in this PR. I am thinking that all the information in the PR description should make its way into the commit messages. Thoughts? |
That sounds like rather a lot, but I don't disagree, I'll look to do that too. EDIT: Done. |
7aea2c1
to
c985b57
Compare
c985b57
to
c7149f5
Compare
@vexx32 can you let me know when the last remaining unresolved comments have been worked on? I would like to get this merged, so that we can continue with testing. Thanks NOTE: I will mention here again, I forced pushed this PR on the head of develop, as I thought that it was ready for merging. You will need to reset you clone before continuing. |
c7149f5
to
669e116
Compare
@gep13 I think I have everything sorted out, apologies for the wait on the last little bits here. :3 |
Finally added Uninstall-ChocolateyPath. However, given overall contribution rates to the powershell functions are quite low, the decision has been made to rewrite our helper functions into C# cmdlets. This serves as the initial set of cmdlets, a handful of useful example cases to prove out the viability of this approach, as well as ensuring that we have a better path forward for both OSS commands and any licensed commands we want to use in the future. It also opens up the possibility of more easily overriding the OSS cmdlets with a licensed command, and there are provisions in the `chocolateyInstaller.psm1` module script to ensure that can work seamlessly. Summary of changes: - Added Uninstall-ChocolateyPath helper cmdlet - Rewrote the following associated functions into C# cmdlets: - Get-EnvironmentVariable - Get-EnvironmentVariableNames - Install-ChocolateyPath - Set-EnvironmentVariable - Test-ProcessAdminRights - Update-SessionEnvironment - Tweaked the PowerShell command lookup behaviour when loading the `chocolateyInstaller.psm1` module to ensure that licensed cmdlets can be preferentially used instead of open-source cmdlets or functions, regardless of any name collisions that may occur. - Tweaked the assembly resolver to ensure that if we have the licensed extension depend on the new Chocolatey.PowerShell assembly, it will not cause any issues when trying to load the licensed extension outside the PowerShell module context.
- Added an `update-cmdlet-documentation.ps1` script which will use PlatyPS to read the cmdlet metadata and keep documentation up to date. - Provides a `-NewCommand` switch to allow easier additions of documentation pages for any new cmdlets (PlatyPS does not add newly added commands by default). - This script directly adds or updates documentation in a local copy of the chocolatey/docs repository, and compiles an XML help file from the resulting content.
669e116
to
a91901f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The requested changes have been completed.
@vexx32 thank you very much for your work on this! It is great to see this getting added! |
Description Of Changes
chocolateyInstaller.psm1
module to ensure that licensed cmdlets can be preferentially used instead of open-source cmdlets or functions, regardless of any name collisions that may occur.update-cmdlet-documentation.ps1
script which will use PlatyPS to read the cmdlet metadata and keep documentation up to date.-NewCommand
switch to allow easier additions of documentation pages for any new cmdlets (PlatyPS does not add newly added commands by default).Motivation and Context
Partially, we just want to finally add Uninstall-ChocolateyPath. However, given overall contribution rates to the powershell functions are quite low, the decision has been made to rewrite our helper functions into C# cmdlets.
This PR serves as the initial set of cmdlets, a handful of useful example cases to prove out the viability of this approach, as well as ensuring that we have a better path forward for both OSS commands and any licensed commands we want to use in the future. It also opens up the possibility of more easily overriding the OSS cmdlets with a licensed command, and there are provisions in the
chocolateyInstaller.psm1
module script to ensure that can work seamlessly.Testing
.nupkg
), attempt to install and uninstall the package running the chocolatey.console project in Visual Studio, specifying package parameters as/Path=C:\test /Scope=Machine
(or other paths, or with/Scope=User
).$env:ChocolateyInstall
to this folder, and attempt to run the same tests as before with thechoco.exe
in this folder. You should notice that any attempts to write to theMachine
scope path fail with an error.Import-Module $env:ChocolateyInstall/helpers/chocolateyInstaller.psm1
and check theGet-Help
results forInstall-ChocolateyPath
,Uninstall-ChocolateyPath
, and the other provided cmdlets. None of the cmdlets added/rewritten here should be missing help.There will be a related PR to the licensed extension repository with some additional instructions to confirm the command overriding behaviour works and inheritance from this new assembly can function correctly.
For documentation generation:
update-cmdlet-documentation.ps1
script, optionally providing the path to the docs repo folder with-DocsRepositoryPath
if it is cloned in a folder that is not../docs
relative to thechoco
repository.For the present I have included the XML rendition of the help in the repository, and I think it makes sufficient sense to just update this file whenever we need to; the markdown help can remain in the docs repository, and updating the XML help for this PowerShell module can be done as-needed and just committed to this repository.
The
Invoke-Tests.ps1
file should also run the included Pester tests for these commands.Operating Systems Testing
Win10
Change Types Made
Change Checklist
Related Issue
Fixes #310
Fixes #3318