Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SquirrelHelper #910

Merged
merged 5 commits into from
Aug 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/app/FakeLib/SquirrelHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ type SquirrelParams =
/// The full path to an optional animated gif to be displayed during installation
LoadingGif : string option

/// The full path to an optional icon, which will be used for the generated installer.
SetupIcon : string option

/// The path to Squirrel: `squirrel.exe`
ToolPath : string

Expand All @@ -36,7 +39,7 @@ type SquirrelParams =
SigningKeyFile : string option

/// The secret key for the code signing certificate
SigningSecret : string option}
SigningSecret : string option }

/// The Squirrel default parameters.
///
Expand All @@ -46,6 +49,7 @@ type SquirrelParams =
/// - `WorkingDir` - `None`
/// - `BootstrapperExe` - `None`
/// - `LoadingGif` - `None`
/// - `SetupIcon` - `None`
/// - `ToolPath` - The `squirrel.exe` path if it exists in a subdirectory of the current directory.
/// - `TimeOut` - 10 minutes
/// - `SignExecutable` - `None`
Expand All @@ -58,6 +62,7 @@ let SquirrelDefaults =
WorkingDir = None
BootstrapperExe = None
LoadingGif = None
SetupIcon = None
ToolPath = findToolInSubPath toolname (currentDirectory @@ "tools" @@ "Squirrel")
TimeOut = TimeSpan.FromMinutes 10.
SignExecutable = None
Expand All @@ -66,19 +71,20 @@ let SquirrelDefaults =

let private createSigningArgs (parameters : SquirrelParams) =
new StringBuilder()
|> appendWithoutQuotes "--signWithParams=\"/a"
|> appendWithoutQuotes "--signWithParams=\""
|> appendWithoutQuotes "/a"
|> appendIfSome parameters.SigningKeyFile (sprintf "/f %s")
|> appendIfSome parameters.SigningSecret (sprintf "/p %s")
|> appendWithoutQuotes "\""
|> toText

let internal buildSquirrelArgs parameters nugetPackage=
let internal buildSquirrelArgs parameters nugetPackage =
new StringBuilder()
|> appendIfNotNullOrEmpty nugetPackage "--releasify="
|> appendIfNotNullOrEmpty parameters.ReleaseDir "--releaseDir="
|> appendIfSome parameters.LoadingGif (sprintf "--loadingGif= %s")
|> appendIfSome parameters.BootstrapperExe (sprintf "--bootstrapperExe= %s")
|> appendIfSome parameters.LoadingGif (sprintf "\"--loadingGif=%s\"")
|> appendIfSome parameters.SetupIcon (sprintf "\"--setupIcon=%s\"")
|> appendIfSome parameters.BootstrapperExe (sprintf "\"--bootstrapperExe=%s\"")
|> appendIfSome parameters.SignExecutable (fun s -> createSigningArgs parameters)
|> toText

Expand Down
20 changes: 13 additions & 7 deletions src/test/Test.FAKECore/SquirrelHelperSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ namespace Test.FAKECore.SquirrelHelperSpec
internal abstract class BuildArgumentsSpecsBase
{
protected static Squirrel.SquirrelParams Parameters;
protected static string[] Assemblies;
protected static string Arguments;
protected static string NuGetPackage = "my.nuget";

Establish context = () =>
{
Parameters = Squirrel.SquirrelDefaults;
Assemblies = new[] { "test.dll", "other.dll" };
};

Because of = () =>
Expand All @@ -33,9 +31,10 @@ internal abstract class BuildArgumentsSpecsBase
internal class When_using_the_default_parameters
: BuildArgumentsSpecsBase
{
It should_not_include_releasify = () => Arguments.ShouldContain("--releasify=" + NuGetPackage);
It should_include_releasify = () => Arguments.ShouldContain("--releasify=" + NuGetPackage);
It should_not_include_releasedir = () => Arguments.ShouldNotContain("--releaseDir=");
It should_not_include_loading_gif = () => Arguments.ShouldNotContain("--loadingGif=");
It should_not_include_setup_icon = () => Arguments.ShouldNotContain("--setupIcon=");
It should_not_include_bootstrapper_exe = () => Arguments.ShouldNotContain("--bootstrapperExe=");
}

Expand All @@ -60,8 +59,16 @@ internal class When_specifying_loading_gif
const string LoadingGif = "spinner.gif";
Establish context = () => Parameters = Parameters.With(p => p.LoadingGif, FSharpOption<string>.Some(LoadingGif));

It should_include_loading_gif_param = () => Arguments.ShouldContain("--loadingGif=");
It should_include_loading_gif_file = () => Arguments.ShouldContain(LoadingGif);
It should_include_loading_gif_param = () => Arguments.ShouldContain("--loadingGif=" + LoadingGif);
}

internal class When_specifying_setup_icon
: BuildArgumentsSpecsBase
{
const string SetupIcon = "setup.ico";
Establish context = () => Parameters = Parameters.With(p => p.SetupIcon, FSharpOption<string>.Some(SetupIcon));

It should_include_setup_icon = () => Arguments.ShouldContain("--setupIcon=" + SetupIcon);
}

internal class When_specifying_bootstrapper_exe
Expand All @@ -70,8 +77,7 @@ internal class When_specifying_bootstrapper_exe
const string BootstrapperExe = "bootstrap.exe";
Establish context = () => Parameters = Parameters.With(p => p.BootstrapperExe, FSharpOption<string>.Some(BootstrapperExe));

It should_include_bootstrapper_param = () => Arguments.ShouldContain("--bootstrapperExe=");
It should_include_bootstrapper_file = () => Arguments.ShouldContain(BootstrapperExe);
It should_include_bootstrapper_param = () => Arguments.ShouldContain("--bootstrapperExe=" + BootstrapperExe);
}

internal class When_requesting_package_signing_with_default_parameters
Expand Down