private static void ConfigBower(UrlTemplate urlTemplate) { // Configure bower if (Msdos.IsInstalled("bower.cmd")) { // bowerrc user file var bowerrc = Path.Combine(Windows.GetCurrentUserFolder(), ".bowerrc"); if (urlTemplate.ClearData) { logger.Info("Clearing proxy for bower"); Msdos.Run("npm.cmd", $@"config delete proxy"); Msdos.Run("npm.cmd", $@"config delete https-proxy"); if (File.Exists(bowerrc)) { System.IO.File.Delete(bowerrc); } } else { logger.Info("Setting proxy for bower"); Msdos.Run("npm.cmd", $@"npm config set proxy {urlTemplate.GetProxy()}"); Msdos.Run("npm.cmd", $@"npm config set https-proxy {urlTemplate.GetProxySsl()}"); if (!File.Exists(bowerrc)) { // create settings var obj = new JObject(); obj.Add("proxy", urlTemplate.GetProxy()); obj.Add("https-proxy", urlTemplate.GetProxySsl()); obj.Add("no-proxy", urlTemplate.GetProxyExceptions()); System.IO.File.WriteAllText(bowerrc, obj.ToString()); } else { // update settings var content = System.IO.File.ReadAllText(bowerrc); var obj = JObject.Parse(content); obj["proxy"] = urlTemplate.GetProxy(); obj["https-proxy"] = urlTemplate.GetProxySsl(); obj["no-proxy"] = urlTemplate.GetProxyExceptions(); System.IO.File.WriteAllText(bowerrc, obj.ToString()); } } } }
private static void ConfigYarn(UrlTemplate urlTemplate) { // Configure yarn if (Msdos.IsInstalled("yarn.cmd")) { if (urlTemplate.ClearData) { logger.Info("Clearing proxy for yarn"); Msdos.Run("yarn.cmd", $@"config delete proxy"); Msdos.Run("yarn.cmd", $@"config delete https-proxy"); } else { logger.Info("Setting proxy for yarn"); Msdos.Run("yarn.cmd", $@"npm config set proxy {urlTemplate.GetProxy()}"); Msdos.Run("yarn.cmd", $@"npm config set https-proxy {urlTemplate.GetProxySsl()}"); } } }
private static void ConfigGit(UrlTemplate urlTemplate) { // Configure GIT if (Msdos.IsInstalled("git.exe", "version")) { if (urlTemplate.ClearData) { logger.Info("Clearing proxy for GIT"); Msdos.Run("git.exe", $"config --global --unset http.proxy"); Msdos.Run("git.exe", $"config --global --unset https.proxy"); } else { logger.Info("Setting proxy for GIT"); Msdos.Run("git.exe", $"config --global http.proxy {urlTemplate.GetProxy()}"); Msdos.Run("git.exe", $"config --global https.proxy {urlTemplate.GetProxySsl()}"); } } }
private static void ConfigNuget(UrlTemplate urlTemplate) { // Configure nuget if (Msdos.IsInstalled("nuget.exe", "help")) { if (urlTemplate.ClearData) { logger.Info("Clearing proxy for nuget"); Msdos.Run("nuget.exe", $@"config -set http_proxy="); Msdos.Run("nuget.exe", $@"config -set http_proxy.user="******"nuget.exe", $@"config -set http_proxy.password="******"Setting proxy for nuget"); Msdos.Run("nuget.exe", $@"config -set http_proxy={urlTemplate.GetProxy(true)}"); Msdos.Run("nuget.exe", $@"config -set http_proxy.user={urlTemplate.GetProxyUsername()}"); Msdos.Run("nuget.exe", $@"config -set http_proxy.password={urlTemplate.GetProxyPassword(true)}"); } } }
private static void ConfigNpm(UrlTemplate urlTemplate) { // Configure npm if (Msdos.IsInstalled("npm.cmd", "version")) { if (urlTemplate.ClearData) { logger.Info("Clearing proxy for npm"); Msdos.Run("npm.cmd", $@"config delete proxy"); Msdos.Run("npm.cmd", $@"config delete https-proxy"); } else { logger.Info("Setting proxy for npm"); Msdos.Run("npm.cmd", $@"config set proxy {urlTemplate.GetProxy()}"); Msdos.Run("npm.cmd", $@"config set https-proxy {urlTemplate.GetProxySsl()}"); var npmrc = Path.Combine(Windows.GetCurrentUserFolder(), ".npmrc"); // npmrc file is managed automatically } } }
private static void ConfigChocolatey(UrlTemplate urlTemplate) { // Configure CHOCOLATEY if (Msdos.IsInstalled("choco.exe", "--version")) { if (urlTemplate.ClearData) { logger.Info("Clearing proxy for chocolatey"); Msdos.Run("choco.exe", $@"config unset proxy"); Msdos.Run("choco.exe", $@"config unset proxyUser"); Msdos.Run("choco.exe", $@"config unset proxyPassword"); Msdos.Run("choco.exe", $@"config unset proxyBypassList"); Msdos.Run("choco.exe", $@"config unset proxyBypassOnLocal"); } else { logger.Info("Setting proxy for chocolatey"); Msdos.Run("choco.exe", $@"config set proxy {urlTemplate.GetProxy()}"); if (!string.IsNullOrEmpty(urlTemplate.GetProxyUsername())) { Msdos.Run("choco.exe", $@"config set proxyUser {urlTemplate.GetProxyUsername()}"); } if (!string.IsNullOrEmpty(urlTemplate.GetProxyPassword())) { Msdos.Run("choco.exe", $@"config set proxyPassword {urlTemplate.GetProxyPassword()}"); } if (!string.IsNullOrEmpty(urlTemplate.GetProxyExceptions())) { Msdos.Run("choco.exe", $@"config set proxyBypassList ""{urlTemplate.GetProxyExceptions()}"); } Msdos.Run("choco.exe", $@"config set proxyBypassOnLocal true"); } } }