Skip to content

Commit

Permalink
(chocolateyGH-14) WebPi source
Browse files Browse the repository at this point in the history
WebPI can download and install its required package to run.
  • Loading branch information
ferventcoder committed Jan 22, 2015
1 parent 55b53dd commit 8e67207
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/chocolatey/infrastructure.app/registration/ContainerBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ public void RegisterComponents(Container container)
new ChocolateyUnpackSelfCommand(container.GetInstance<IFileSystem>())
};
return list.AsReadOnly();
}, Lifestyle.Singleton);

container.Register<IEnumerable<ISourceRunner>>(() =>
{
var list = new List<ISourceRunner>
{
container.GetInstance<INugetService>(),
new WebPiService(container.GetInstance<ICommandExecutor>(),container.GetInstance<INugetService>())
};
return list.AsReadOnly();
}, Lifestyle.Singleton);

container.Register<IEventSubscriptionManagerService, EventSubscriptionManagerService>(Lifestyle.Singleton);
Expand Down
50 changes: 43 additions & 7 deletions src/chocolatey/infrastructure.app/services/WebPiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,25 @@ namespace chocolatey.infrastructure.app.services
using System.Collections.Generic;
using System.Text.RegularExpressions;
using configuration;
using domain;
using infrastructure.commands;
using logging;
using results;

public interface IWebPiService
{
}


//todo this is the old nuget.exe installer code that needs cleaned up for webpi
public class WebPiService : IWebPiService
public class WebPiService : ISourceRunner
{
private readonly ICommandExecutor _commandExecutor;
private readonly INugetService _nugetService;
private const string PACKAGE_NAME_TOKEN = "{{packagename}}";
private readonly string _webPiExePath = "webpicmd"; //ApplicationParameters.Tools.NugetExe;
private readonly IDictionary<string, ExternalCommandArgument> _webPiListArguments = new Dictionary<string, ExternalCommandArgument>(StringComparer.InvariantCultureIgnoreCase);
private readonly IDictionary<string, ExternalCommandArgument> _webPiInstallArguments = new Dictionary<string, ExternalCommandArgument>(StringComparer.InvariantCultureIgnoreCase);

public WebPiService(ICommandExecutor commandExecutor)
public WebPiService(ICommandExecutor commandExecutor, INugetService nugetService)
{
_commandExecutor = commandExecutor;
_nugetService = nugetService;
set_cmd_args_dictionaries();
}

Expand Down Expand Up @@ -73,6 +72,43 @@ private void set_webpi_install_dictionary()
_webPiInstallArguments.Add("_no_cache_", new ExternalCommandArgument {ArgumentOption = "-nocache", Required = true});
}

public SourceType SourceType
{
get { return SourceType.webpi; }
}

public void ensure_source_app_installed(ChocolateyConfiguration config, Action<PackageResult> ensureAction)
{
var runnerConfig = new ChocolateyConfiguration()
{
CommandName = "install",
PackageNames = ApplicationParameters.SourceRunner.WebPiPackage,
Sources = ApplicationParameters.ChocolateyCommunityFeedSource,
Debug = config.Debug,
Force = config.Force,
Verbose = config.Verbose,
CommandExecutionTimeoutSeconds = config.CommandExecutionTimeoutSeconds,
CacheLocation = config.CacheLocation,
RegularOuptut = config.RegularOuptut,
};

_nugetService.install_run(runnerConfig, ensureAction.Invoke);
}

public void list_noop(ChocolateyConfiguration config)
{

}

public ConcurrentDictionary<string, PackageResult> list_run(ChocolateyConfiguration config, bool logResults)
{
return new ConcurrentDictionary<string, PackageResult>();
}

public void install_noop(ChocolateyConfiguration config, Action<PackageResult> continueAction)
{
}

public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfiguration configuration, Action<PackageResult> continueAction)
{
var packageInstalls = new ConcurrentDictionary<string, PackageResult>();
Expand Down

0 comments on commit 8e67207

Please sign in to comment.