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

(#2500) List parameters in templates #2507

Merged
merged 1 commit into from
Aug 13, 2022

Conversation

TheCakeIsNaOH
Copy link
Member

@TheCakeIsNaOH TheCakeIsNaOH commented Jan 5, 2022

Description Of Changes

This adds the ability for the template command to list the parameters
in templates. If the template is installed via a package, the
parameters get cached in a file called .parameters in the template's
directory. This file is ignored by calls to choco new, as it is
excluded from being copied.

There another method added to TokenReplacer to get the parameters via
regex. This keeps the regex in the TokenReplacer class.

Motivation and Context

It it useful to be able to list the available parameters in a template.

The parameters are cached to reduce the number of files that need to be read to get the parameters. Only templates installed via a .template package have the parameters cached. This is because those cache files would get deleted as a part of the package upgrade process, so any cache files from those templates would be up to date. However, for packages that are installed manually, there is not an efficient way to check that the cache is still valid, so that it why parameters from those templates are always read manually.

Testing

Just like in #2385, unit tests cannot be added yet, due to #2501

Manual testing instructions:

  1. Install msi.template and zip.template
  2. Make a copy of the msi template folder and rename to "default"
  3. Make a copy of the msi template folder and rename to "non-pkg"
  4. Run choco template --verbose
  5. Check that the parameters are listed correctly
  6. Check that only the msi and zip template folders have the .parameters file

Change Types Made

  • Bug fix (non-breaking change)
  • Feature / Enhancement (non-breaking change)
  • Breaking change (fix or feature that could cause existing functionality to change)

Related Issue

Fixes #2500
Depends on #2385 (now merged)

Change Checklist

  • Requires a change to the documentation
  • Documentation has been updated
  • Tests to cover my changes, have been added
  • All new and existing tests passed.
  • N/A PowerShell v2 compatibility checked.

@TheCakeIsNaOH TheCakeIsNaOH marked this pull request as ready for review January 11, 2022 00:12
@TheCakeIsNaOH TheCakeIsNaOH force-pushed the template-params branch 2 times, most recently from a194aa4 to 0d817a3 Compare June 27, 2022 15:56
@coveralls
Copy link

coveralls commented Jun 27, 2022

Coverage Status

Coverage remained the same at 28.668% when pulling 565c083 on TheCakeIsNaOH:template-params into 974a3bc on chocolatey:develop.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
This adds the ability for the template command to list the parameters
in templates. If the template is installed via a package, the
parameters get cached in a file called .parameters in the template's
directory. This file is ignored by calls to choco new, as it is
excluded from being copied.

There another method added to TokenReplacer to get the parameters via
regex. This keeps the regex in the TokenReplacer class.
Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gep13
Copy link
Member

gep13 commented Aug 13, 2022

@TheCakeIsNaOH thanks for pulling this together! I am going to go ahead and get this merged in once the CI builds finish.

@gep13 gep13 merged commit 1f34adf into chocolatey:develop Aug 13, 2022
@TheCakeIsNaOH TheCakeIsNaOH deleted the template-params branch September 23, 2022 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List parameters in templates
3 participants