Skip to content

Commit

Permalink
(GH-17) Added ability to use bundle execution
Browse files Browse the repository at this point in the history
- refactored tool name
- Cleanup Warnings
  • Loading branch information
RLittlesII committed Oct 25, 2018
1 parent c54a9a5 commit aafd2cd
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 57 deletions.
16 changes: 16 additions & 0 deletions src/Cake.Fastlane.Tests/Deliver/FastlaneDeliverProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,22 @@ public void Should_Throw_If_Process_Was_Not_Started()
Assert.Equal("fastlane: Process was not started.", result?.Message);
}

[Fact]
public void Should_Throw_Bundle_Exec_Process_Was_Not_Started_()
{
// Given
var fixture = new FastlaneDeliverProviderFixture();
fixture.Settings.UseBundleExecution = true;
fixture.GivenProcessCannotStart();

// When
var result = Record.Exception(() => fixture.Run());

// Then
Assert.IsType<CakeException>(result);
Assert.Equal("bundle exec fastlane: Process was not started.", result?.Message);
}

[Fact]
public void Should_Throw_If_Settings_Is_Null()
{
Expand Down
20 changes: 14 additions & 6 deletions src/Cake.Fastlane.Tests/Supply/FastlaneSupplyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Cake.Fastlane.Tests.Supply
{
#pragma warning disable CS0618 // Type or member is obsolete
public sealed class FastlaneSupplyTests
{
public sealed class TheSupplyMethod
Expand All @@ -14,8 +15,10 @@ public sealed class TheSupplyMethod
public void Should_Throw_If_Settings_Is_Null()
{
// Given
var fixture = new FastlaneSupplyFixture();
fixture.Settings = null;
var fixture = new FastlaneSupplyFixture
{
Settings = null
};

// When
var result = Record.Exception(() => fixture.Run());
Expand Down Expand Up @@ -116,8 +119,10 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
public void Should_Throw_If_Configuration_Null()
{
// Given
var fixture = new FastlaneSupplyFixture();
fixture.Settings = null;
var fixture = new FastlaneSupplyFixture
{
Settings = null
};

// When
var result = Record.Exception(() => fixture.Run());
Expand All @@ -131,8 +136,10 @@ public void Should_Throw_If_Configuration_Null()
public void Should_Throw_If_Configuration_Null_OSX()
{
// Given
var fixture = new FastlaneSupplyFixture();
fixture.Settings = null;
var fixture = new FastlaneSupplyFixture
{
Settings = null
};

// When
var result = Record.Exception(() => fixture.Run());
Expand Down Expand Up @@ -464,4 +471,5 @@ public void Should_Add_Check_Superseded_Tracks_If_Provided()
}
}
}
#pragma warning restore CS0618 // Type or member is obsolete
}
18 changes: 10 additions & 8 deletions src/Cake.Fastlane/Deliver/FastlaneDeliverProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ internal class FastlaneDeliverProvider : FastlaneTool<FastlaneDeliverConfigurati
{
private readonly ICakeEnvironment _environment;

private readonly Func<Dictionary<string, string>, string> Aggregate = (dictionary) =>
{
return dictionary.Aggregate(string.Empty, (current, hash) => current + $"{hash.Key}:{hash.Value}")
.TrimEnd(',');
};

/// <summary>
/// Initializes a new instance of the <see cref="FastlaneDeliverProvider"/> class.
/// </summary>
Expand All @@ -31,7 +25,8 @@ internal class FastlaneDeliverProvider : FastlaneTool<FastlaneDeliverConfigurati
public FastlaneDeliverProvider(IFileSystem fileSystem,
ICakeEnvironment environment,
IProcessRunner processRunner,
IToolLocator tools) : base(fileSystem, environment, processRunner, tools)
IToolLocator tools)
: base(fileSystem, environment, processRunner, tools)
{
_environment = environment;
}
Expand All @@ -51,6 +46,8 @@ public void Deliver(FastlaneDeliverConfiguration configuration)
Run(configuration, ArgumentBuilder(configuration));
}

protected override string GetToolName() => ToolName;

/// <summary>
/// https://github.com/fastlane/fastlane/blob/master/deliver/lib/deliver/options.rb
/// </summary>
Expand All @@ -62,6 +59,11 @@ private ProcessArgumentBuilder ArgumentBuilder(FastlaneDeliverConfiguration conf

builder.Append("deliver");

if (configuration.UseBundleExecution)
{
ToolName = BundleExecution;
}

if (!string.IsNullOrWhiteSpace(configuration.AppIdentifier))
{
builder.AppendSwitch("-a", configuration.AppIdentifier);
Expand Down Expand Up @@ -288,7 +290,7 @@ private ProcessArgumentBuilder ArgumentBuilder(FastlaneDeliverConfiguration conf
builder.AppendSwitch("--marketing_url", configuration.MarketingUrl);
}

return builder;
return builder.RenderSafe();
}
}
}
4 changes: 3 additions & 1 deletion src/Cake.Fastlane/Deliver/IFastlaneDeliverProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Cake.Fastlane
using Cake.Core.IO;

namespace Cake.Fastlane
{
/// <summary>
/// Interface that represents fastlane deliver.
Expand Down
12 changes: 2 additions & 10 deletions src/Cake.Fastlane/FastlaneProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,11 @@ public sealed class FastlaneProvider : IFastlaneProvider
/// Initializes a new instance of the <see cref="FastlaneProvider"/> class.
/// </summary>
/// <param name="context">The context.</param>
public FastlaneProvider(ICakeContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

_context = context;
}
public FastlaneProvider(ICakeContext context) => _context = context ?? throw new ArgumentNullException(nameof(context));

/// <inheritdoc />
/// <summary>
/// Delivers the specified deliver configuration.
/// </summary>
/// <example>
/// <code>
/// var configuration = new FastlaneDeliverConfiguration
Expand All @@ -49,6 +40,7 @@ public FastlaneProvider(ICakeContext context)
/// Fastlane.Deliver(configuration);
/// </code>
/// </example>
/// </summary>
/// <param name="deliverConfiguration">The fastlane deliver configuration.</param>
[CakeAliasCategory("Deliver")]
public void Deliver(FastlaneDeliverConfiguration deliverConfiguration = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Fastlane/Match/FastlaneMatchProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Cake.Fastlane
/// Provides functionality for fastlane match tool.
/// </summary>
/// <seealso cref="IFastlaneMatchProvider" />
internal class FastlaneMatchProvider : FastlaneTool<FastlaneMatchConfiguration>, IFastlaneMatchProvider
public class FastlaneMatchProvider : FastlaneTool<FastlaneMatchConfiguration>, IFastlaneMatchProvider
{
/// <summary>
/// The environment
Expand Down
3 changes: 3 additions & 0 deletions src/Cake.Fastlane/Pilot/FastlanePilotConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public FastlanePilotConfiguration()
/// <summary>
/// Gets or sets the command to run with pilot.
/// </summary>
/// <value>
/// The command.
/// </value>
public PilotCommand Command { get; set; }

/// <summary>
Expand Down
26 changes: 10 additions & 16 deletions src/Cake.Fastlane/Pilot/FastlanePilotProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ internal class FastlanePilotProvider : FastlaneTool<FastlanePilotConfiguration>,
{
private readonly ICakeEnvironment _environment;

public void Pilot(FastlanePilotConfiguration configuration)
{
if (configuration == null)
{
throw new ArgumentNullException(nameof(configuration));
}

Run(configuration, ArgumentBuilder(configuration));
}

/// <summary>
/// Initializes a new instance of the <see cref="FastlanePilotProvider"/> class.
/// </summary>
Expand All @@ -30,22 +40,6 @@ internal class FastlanePilotProvider : FastlaneTool<FastlanePilotConfiguration>,
_environment = environment;
}

/// <inheritdoc />
/// <summary>
/// Executes fastlane pilot with the specified configuration.
/// </summary>
/// <param name="configuration"></param>
/// <exception cref="T:System.ArgumentNullException">configuration</exception>
public void Pilot(FastlanePilotConfiguration configuration)
{
if (configuration == null)
{
throw new ArgumentNullException(nameof(configuration));
}

Run(configuration, ArgumentBuilder(configuration));
}

/// <summary>
/// https://github.com/fastlane/fastlane/blob/master/pilot/lib/pilot/options.rb
/// </summary>
Expand Down
12 changes: 2 additions & 10 deletions src/Cake.Fastlane/Supply/FastlaneSupplyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

namespace Cake.Fastlane
{
/// <summary>
/// Provides functionality for fastlane supply tool.
/// </summary>
/// <seealso cref="Cake.Fastlane.FastlaneTool{Cake.Fastlane.FastlaneSupplyConfiguration}" />
/// <seealso cref="Cake.Fastlane.IFastlaneSupplyProvider" />
#pragma warning disable CS0618 // Type or member is obsolete
internal class FastlaneSupplyProvider : FastlaneTool<FastlaneSupplyConfiguration>, IFastlaneSupplyProvider
{
private readonly ICakeEnvironment _environment;
Expand All @@ -23,11 +19,6 @@ internal class FastlaneSupplyProvider : FastlaneTool<FastlaneSupplyConfiguration
_environment = environment;
}

/// <summary>
/// Supplies the specified configuration.
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <exception cref="ArgumentNullException">configuration</exception>
public void Supply(FastlaneSupplyConfiguration configuration)
{
if (configuration == null)
Expand Down Expand Up @@ -165,4 +156,5 @@ private ProcessArgumentBuilder ArgumentBuilder(FastlaneSupplyConfiguration confi
return builder;
}
}
#pragma warning restore CS0618 // Type or member is obsolete
}
4 changes: 0 additions & 4 deletions src/Cake.Fastlane/Supply/IFastlaneSupplyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ namespace Cake.Fastlane
{
internal interface IFastlaneSupplyProvider
{
/// <summary>
/// Executes fastlane supply with the specified configuration.
/// </summary>
/// <param name="configuration"></param>
void Supply(FastlaneSupplyConfiguration configuration);
}
}
5 changes: 5 additions & 0 deletions src/Cake.Fastlane/Tool/FastlaneConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,10 @@ public class FastlaneConfiguration : ToolSettings
/// Gets or sets the team identifier.
/// </summary>
public string TeamId { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [use bundle execution].
/// </summary>
public bool UseBundleExecution { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/Cake.Fastlane/Tool/FastlaneTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ namespace Cake.Fastlane
public abstract class FastlaneTool<T> : Tool<T>
where T : FastlaneConfiguration
{
/// <summary>
/// The tool name
/// </summary>
protected string ToolName = "fastlane";

/// <summary>
/// The bundle execution
/// </summary>
protected string BundleExecution = "bundle exec fastlane";

/// <summary>
/// Initializes a new instance of the <see cref="FastlaneTool{T}"/> class.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Fastlane/Tool/FastlaneToolProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Cake.Fastlane
/// <summary>
/// Provides functionality for fastlane tool.
/// </summary>
/// <seealso cref="Fastlane.FastlaneTool{Fastlane.FastlaneConfiguration}" />
/// <seealso cref="FastlaneConfiguration" />
/// <seealso cref="IFastlaneToolProvider" />
public class FastlaneToolProvider : FastlaneTool<FastlaneConfiguration>, IFastlaneToolProvider
{
Expand Down

0 comments on commit aafd2cd

Please sign in to comment.