Skip to content
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

Feature Request: Add script to choco new templates to remove comments from ps1 and nuspec files #2037

Open
corbob opened this issue Apr 19, 2020 · 3 comments

Comments

@corbob
Copy link
Member

corbob commented Apr 19, 2020

Currently there is a comment at the top of the chocolateyinstall.ps1 and chocolateyuninstall.ps1 files:

# IMPORTANT: Before releasing this package, copy/paste the next 2 lines into PowerShell to remove all comments from this file:
#   $f='c:\path\to\thisFile.ps1'
#   gc $f | ? {$_ -notmatch "^\s*#"} | % {$_ -replace '(^.*?)\s*?[^``]#.*','$1'} | Out-File $f+".~" -en utf8; mv -fo $f+".~" $f

Would it be possible to move this code to a PowerShell script beside the nuspec file that runs on all of the ps1 files? This script could also remove all comments from the nuspec file as well.

Or, as another option: could this action be done as part of the choco pack process? Akin to minifying javascript before deploying to a website.

If this is something that would be desired, I have been working on a script in my own repo that I could contribute.

@ferventcoder
Copy link
Member

Removing by pack could be a definite option! However curious how to only remove the template comments versus something folks have added themselves?

@asears
Copy link

asears commented Aug 13, 2020

Perhaps you could add a chocolatey-specific token to the help lines, or move the lines to a document / example markdown with powershell? It would likely make sense to reduce noise in the scaffolding files. Perhaps the option to generate more detailed scaffolding could be non-default new option?

This should be part of the nuget / choco new as it doesn't seem like happy path to a clean package with best practices from the default choco new command.

After the package is ready for build, a choco linter/scanner and set of Pester tests could be used to verify the template was changed properly and meets good practice for publishing?

@ferventcoder
Copy link
Member

Perhaps the option to generate more detailed scaffolding could be non-default new option?

The problem with this is the folks that would need this wouldn't know to do this. However if there is a feature switch, folks could simply switch it off and then they would get choco new templates without all the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants