Skip to content

Commit

Permalink
(GH-737) Use built-in template
Browse files Browse the repository at this point in the history
When creating packages from templates, provide the ability to use the
built-in template even when an overriding template exists.
  • Loading branch information
ferventcoder committed May 28, 2016
1 parent 8a71af7 commit 7896950
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $commandOptions = @{
outdated = "-? --source='' --user= --password=" + $allcommands
upgrade = "-y -whatif -? --pre --version= --except='' --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --source='webpi' --user= --password= --prerelease --forcex86 --not-silent --package-parameters='' --allow-downgrade --allow-multiple-versions --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --fail-on-unfound --fail-on-not-installed --ignore-checksums" + $allcommands + $proInstallUpgradeOptions
uninstall = "-y -whatif -? --force-dependencies --remove-dependencies --all-versions --source='windowsfeatures' --source='webpi' --version= --uninstall-arguments='' --override-arguments --not-silent --params='' --package-parameters='' --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts" + $allcommands
new = "--template-name= --file='Biz editions only' --automaticpackage --version= --maintainer='' packageversion= maintainername='' maintainerrepo='' installertype= url='' url64='' silentargs='' -?" + $allcommands
new = "--template-name= --file='Biz editions only' --automaticpackage --version= --maintainer='' packageversion= maintainername='' maintainerrepo='' installertype= url='' url64='' silentargs='' --use-built-in-template -?" + $allcommands
pack = "--version= -?" + $allcommands
push = "--source='' --api-key= --timeout= -?" + $allcommands
source = "--name= --source='' --user= --password= --priority= -?" + $allcommands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
option => configuration.NewCommand.TemplateProperties.Add(TemplateValues.MaintainerPropertyName, option.remove_surrounding_quotes()))
.Add("outputdirectory=",
"OutputDirectory - Specifies the directory for the created Chocolatey package file. If not specified, uses the current directory.",
option => configuration.OutputDirectory = option)
option => configuration.OutputDirectory = option)
.Add("built-in|built-in-template|originaltemplate|original-template|use-original-template|use-built-in-template",
"BuiltInTemplate - Use the original built-in template instead of any override. Available in 0.9.10+.",
option => configuration.NewCommand.UseOriginalTemplate = option != null)
;
//todo: more built-in templates
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ public NewCommandConfiguration()
public string Name { get; set; }
public bool AutomaticPackage { get; set; }
public IDictionary<string, string> TemplateProperties { get; private set; }
public bool UseOriginalTemplate { get; set; }
}

[Serializable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void generate(ChocolateyConfiguration configuration)
}

var defaultTemplateOverride = _fileSystem.combine_paths(ApplicationParameters.TemplatesLocation, "default");
if (string.IsNullOrWhiteSpace(configuration.NewCommand.TemplateName) && !_fileSystem.directory_exists(defaultTemplateOverride))
if (string.IsNullOrWhiteSpace(configuration.NewCommand.TemplateName) && (!_fileSystem.directory_exists(defaultTemplateOverride) || configuration.NewCommand.UseOriginalTemplate))
{
generate_file_from_template(configuration, tokens, NuspecTemplate.Template, _fileSystem.combine_paths(packageLocation, "{0}.nuspec".format_with(tokens.PackageNameLower)), Encoding.UTF8);
generate_file_from_template(configuration, tokens, ChocolateyInstallTemplate.Template, _fileSystem.combine_paths(packageToolsLocation, "chocolateyinstall.ps1"), Encoding.UTF8);
Expand Down

0 comments on commit 7896950

Please sign in to comment.