Permalink
Browse files

drop legacy commands

  • Loading branch information...
1 parent 9752a93 commit 4867b967af78cfd4dd0c3cdd24b642711f398f65 @jonnyzzz jonnyzzz committed May 11, 2012
View
4 nuget-extensions/nuget-commands/nuget-commands.csproj
@@ -55,13 +55,11 @@
<Compile Include="src\AssemblyResolver.cs" />
<Compile Include="src\CommandBase.cs" />
<Compile Include="src\ListCommandBase.cs" />
- <Compile Include="src\NuGetTeamCityListCommand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\NuGetTeamCityListPackagesCommand.cs" />
<Compile Include="src\NuGetTeamCityPingCommand.cs" />
- <Compile Include="src\Util\ServiceMessageFormatter.cs" />
- <Compile Include="src\Util\ServiceMessageProperty.cs" />
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
View
20 nuget-extensions/nuget-commands/src/ListCommandBase.cs
@@ -4,7 +4,6 @@
using System.Linq;
using System.Linq.Expressions;
using JetBrains.Annotations;
-using JetBrains.TeamCity.NuGet.ExtendedCommands.Util;
using NuGet;
namespace JetBrains.TeamCity.NuGet.ExtendedCommands
@@ -90,21 +89,6 @@ private static Expression GeneratePackageIdFilter(IEnumerable<string> ids, Param
return expressions.Single();
}
-
- /// <summary>
- /// There was a change in signature in NuGet poset 1.5. IPackage.get_Version now returns Semantic version instead of Version
- /// Here is no difference here, so we can stick to dynamic object as there are tests for this method.
- /// </summary>
- protected static void PrintPackageInfo(string id, string version)
- {
- var msg = ServiceMessageFormatter.FormatMessage(
- "nuget-package",
- new ServiceMessageProperty("Id", id),
- new ServiceMessageProperty("Version", version)
- );
-
- System.Console.Out.WriteLine(msg);
- }
}
public enum PackageFetchOption
@@ -118,7 +102,9 @@ public static class PackageExtensions2
{
public static string VersionString(this IPackage package)
{
- return ((dynamic) package).Version.ToString();
+ // There was a change in signature in NuGet poset 1.5. IPackage.get_Version now returns Semantic version instead of Version
+ // Here is no difference here, so we can stick to dynamic object as there are tests for this method.
+ return ((dynamic)package).Version.ToString();
}
}
}
View
47 nuget-extensions/nuget-commands/src/NuGetTeamCityListCommand.cs
@@ -1,47 +0,0 @@
-using System.Collections.Generic;
-using NuGet;
-using System.Linq;
-
-namespace JetBrains.TeamCity.NuGet.ExtendedCommands
-{
- [Command("TeamCity.List", "Lists packages for given Id with parsable output")]
- public class NuGetTeamCityListCommand : ListCommandBase
- {
- [Option("NuGet package Source to search for package")]
- public string Source { get; set; }
-
- [Option("Package Id to check for version update")]
- public string Id { get; set; }
-
- [Option("NuGet Version Spec to constraint versions to be checked. Optional")]
- public string Version { get; set; }
-
- protected override void ExecuteCommandImpl()
- {
- if (string.IsNullOrWhiteSpace(Source))
- Source = NuGetConstants.DefaultFeedUrl;
-
- System.Console.Out.WriteLine("TeamCity NuGet List command.");
- System.Console.Out.WriteLine("Source: {0}", Source ?? "<null>");
- System.Console.Out.WriteLine("Package Id: {0}", Id ?? "<null>");
- System.Console.Out.WriteLine("Version: {0}", Version ?? "<null>");
- System.Console.Out.WriteLine("Checking for latest version...");
-
- foreach (var p in GetPackages())
- PrintPackageInfo(p.Id, p.VersionString());
- }
-
- private IEnumerable<IPackage> GetPackages()
- {
- if (string.IsNullOrWhiteSpace(Source))
- throw new CommandLineException("-Source must be specified.");
-
-
- if (string.IsNullOrWhiteSpace(Version))
- return GetAllPackages(Source, PackageFetchOption.IncludeLatest, new[] {Id}).ToList();
-
- var versionSpec = VersionUtility.ParseVersionSpec(Version);
- return GetAllPackages(Source, PackageFetchOption.IncludeAll, new[] {Id}).ToList().FindByVersion(versionSpec);
- }
- }
-}
View
82 nuget-extensions/nuget-commands/src/Util/ServiceMessageFormatter.cs
@@ -1,82 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace JetBrains.TeamCity.NuGet.ExtendedCommands.Util
-{
- public static class ServiceMessageFormatter
- {
- private static readonly Pair[] ESCAPINGS = {
- new Pair('|', "||"),
- new Pair('\'', "|'"),
- new Pair('\n', "|n"),
- new Pair('\r', "|r"),
- new Pair(']', "|]")
- };
-
- private const string SERVICE_MESSAGE_HEADER = "##teamcity[";
-
- /// <summary>
- /// Performs TeamCity-format escaping of a string.
- /// </summary>
- /// <returns></returns>
- private static string Escape(string value)
- {
- return ESCAPINGS.Aggregate(value, (current, pair) => current.Replace(pair.What, pair.Replacement));
- }
-
- private struct Pair
- {
- public readonly string What;
- public readonly string Replacement;
-
- private Pair(string what, string replacement)
- {
- What = what;
- Replacement = replacement;
- }
-
- public Pair(char what, string replacement)
- : this(what.ToString(), replacement)
- {
- }
- }
-
- public static string FormatMessage(string sMessageName, string sValue)
- {
- if (string.IsNullOrEmpty(sMessageName))
- throw new ArgumentNullException("sMessageName");
- if (sValue == null)
- throw new ArgumentNullException("sValue");
-
- if (Escape(sMessageName) != sMessageName)
- throw new ArgumentException("The message name contains illegal characters.", "sMessageName");
-
- return string.Format("{2}{0} '{1}']", sMessageName, Escape(sValue), SERVICE_MESSAGE_HEADER);
- }
-
- public static string FormatMessage(string sMessageName, params ServiceMessageProperty[] properties)
- {
- if (string.IsNullOrEmpty(sMessageName))
- throw new ArgumentNullException("sMessageName");
- if (properties == null)
- throw new ArgumentNullException("properties");
-
- if (Escape(sMessageName) != sMessageName)
- throw new ArgumentException("The message name contains illegal characters.", "sMessageName");
-
- var sb = new StringBuilder();
- sb.AppendFormat("{1}{0}", sMessageName, SERVICE_MESSAGE_HEADER);
- foreach (var property in properties)
- {
- if (Escape(property.Key) != property.Key)
- throw new InvalidOperationException(string.Format("The property name “{0}” contains illegal characters.", property.Key));
- sb.AppendFormat(" {0}='{1}'", property.Key, Escape(property.Value));
- }
- sb.Append(']');
-
- return sb.ToString();
- }
- }
-}
View
14 nuget-extensions/nuget-commands/src/Util/ServiceMessageProperty.cs
@@ -1,14 +0,0 @@
-namespace JetBrains.TeamCity.NuGet.ExtendedCommands.Util
-{
- public struct ServiceMessageProperty
- {
- public readonly string Key;
- public readonly string Value;
-
- public ServiceMessageProperty(string key, string value)
- {
- Key = key;
- Value = value;
- }
- }
-}
View
1 nuget-extensions/nuget-tests/nuget-tests.csproj
@@ -62,7 +62,6 @@
<Compile Include="src\NuGetConstants.cs" />
<Compile Include="src\NuGetRunnerTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="src\NuGetRunner_ListCommandTest.cs" />
<Compile Include="src\NuGetRunner_ListPackagesCommandTest.cs" />
<Compile Include="src\NuGetRunner_ListPackagesCommandTestBase.cs" />
<Compile Include="src\TempFilesHolder.cs" />
View
103 nuget-extensions/nuget-tests/src/NuGetRunner_ListCommandTest.cs
@@ -1,103 +0,0 @@
-using NUnit.Framework;
-
-namespace JetBrains.TeamCity.NuGet.Tests
-{
- [TestFixture]
- public class NuGetRunner_ListCommandTest
- {
- [TestCase(NuGetVersion.NuGet_1_4)]
- [TestCase(NuGetVersion.NuGet_1_5)]
- [TestCase(NuGetVersion.NuGet_1_6)]
- [TestCase(NuGetVersion.NuGet_1_7)]
- [TestCase(NuGetVersion.NuGet_CommandLine_Package_Latest)]
- [TestCase(NuGetVersion.NuGet_Latest_CI)]
- public void TestCommand_TeamListPublic_v1_Remote(NuGetVersion version)
- {
- ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, Files.GetNuGetExe(version), "TeamCity.List", "-Id", "NUnit", "-Source", NuGetConstants.DefaultFeedUrl_v1)
- .Dump()
- .AssertExitedSuccessfully()
- .AssertNoErrorOutput()
- .AssertOutputContains("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");
- }
-
- [TestCase(NuGetVersion.NuGet_1_6)]
- [TestCase(NuGetVersion.NuGet_1_7)]
- [TestCase(NuGetVersion.NuGet_CommandLine_Package_Latest)]
- [TestCase(NuGetVersion.NuGet_Latest_CI)]
- public void TestCommand_TeamListPublic_v2_Remote(NuGetVersion version)
- {
- ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, Files.GetNuGetExe(version), "TeamCity.List", "-Id", "NUnit", "-Source", NuGetConstants.DefaultFeedUrl_v2)
- .Dump()
- .AssertExitedSuccessfully()
- .AssertNoErrorOutput()
- .AssertOutputContains("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");
- }
-
- [TestCase(NuGetVersion.NuGet_1_4)]
- [TestCase(NuGetVersion.NuGet_1_5)]
- [TestCase(NuGetVersion.NuGet_1_6)]
- [TestCase(NuGetVersion.NuGet_1_7)]
- [TestCase(NuGetVersion.NuGet_CommandLine_Package_Latest)]
- [TestCase(NuGetVersion.NuGet_Latest_CI)]
- public void TestCommand_TeamListPublicVersion_v1_Remote(NuGetVersion version)
- {
- var r = ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, Files.GetNuGetExe(version), "TeamCity.List", "-Id", "NUnit", "-Version", "(1.1.1, 2.5.8)", "-Source", NuGetConstants.DefaultFeedUrl_v1)
- .Dump()
- .AssertExitedSuccessfully()
- .AssertNoErrorOutput()
- .AssertOutputContains("##teamcity[nuget-package Id='NUnit' Version='2.5.7.10213']");
-
- Assert.IsFalse(r.Output.Contains("Version='2.5.10"));
- }
-
- [TestCase(NuGetVersion.NuGet_1_6)]
- [TestCase(NuGetVersion.NuGet_1_7)]
- [TestCase(NuGetVersion.NuGet_CommandLine_Package_Latest)]
- [TestCase(NuGetVersion.NuGet_Latest_CI)]
- public void TestCommand_TeamListPublicVersion_v2_Remote(NuGetVersion version)
- {
- var r = ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, Files.GetNuGetExe(version), "TeamCity.List", "-Id", "NUnit", "-Version", "(1.1.1, 2.5.8)", "-Source", NuGetConstants.DefaultFeedUrl_v2)
- .Dump()
- .AssertExitedSuccessfully()
- .AssertNoErrorOutput()
- .AssertOutputContains("##teamcity[nuget-package Id='NUnit' Version='2.5.7.10213']");
-
- Assert.IsFalse(r.Output.Contains("Version='2.5.10"));
- }
-
- [TestCase(NuGetVersion.NuGet_1_6)]
- [TestCase(NuGetVersion.NuGet_1_7)]
- [TestCase(NuGetVersion.NuGet_CommandLine_Package_Latest)]
- [TestCase(NuGetVersion.NuGet_Latest_CI)]
- public void TestCommand_TeamListPublic_Local(NuGetVersion version)
- {
- ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, Files.GetNuGetExe(version), "TeamCity.List", "-Id", "Web", "-Source", Files.GetLocalFeed(version))
- .Dump()
- .AssertExitedSuccessfully()
- .AssertNoErrorOutput()
- .AssertOutputContains("##teamcity[nuget-package Id='Web' Version='1.1.1']",
- "##teamcity[nuget-package Id='Web' Version='1.2.1']",
- "##teamcity[nuget-package Id='Web' Version='2.2.2']");
- }
-
- [TestCase(NuGetVersion.NuGet_1_4)]
- [TestCase(NuGetVersion.NuGet_1_5)]
- [TestCase(NuGetVersion.NuGet_1_6)]
- [TestCase(NuGetVersion.NuGet_1_7)]
- [TestCase(NuGetVersion.NuGet_CommandLine_Package_Latest)]
- [TestCase(NuGetVersion.NuGet_Latest_CI)]
- public void TestCommand_TeamListPublicVersion_Local(NuGetVersion version)
- {
- var r = ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, Files.GetNuGetExe(version), "TeamCity.List", "-Id", "Web", "-Version", "(1.2.0, 2.1.8)", "-Source", Files.GetLocalFeed(version))
- .Dump()
- .AssertExitedSuccessfully()
- .AssertNoErrorOutput()
- .AssertOutputContains("##teamcity[nuget-package Id='Web' Version='1.2.1']");
-
- Assert.IsFalse(r.Output.Contains("Version='1.1.1"));
- Assert.IsFalse(r.Output.Contains("Version='2.2.2"));
- }
-
- }
-
-}

0 comments on commit 4867b96

Please sign in to comment.