Skip to content

Commit

Permalink
Cleanup -> remove fromBootstrapper as it was never actually used anyw…
Browse files Browse the repository at this point in the history
…here.
  • Loading branch information
matthid committed Aug 26, 2017
1 parent 47af54a commit 9ced1f6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 72 deletions.
4 changes: 2 additions & 2 deletions src/Paket.Core/PackageManagement/NugetConvert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ let convertR rootDirectory force credsMigrationMode = trial {
return! createResult(rootDirectory, nugetEnv, credsMigrationMode)
}

let replaceNuGetWithPaket initAutoRestore installAfter fromBootstrapper result =
let replaceNuGetWithPaket initAutoRestore installAfter result =
let remove (fi : FileInfo) =
tracefn "Removing %s" fi.FullName
fi.Delete()
Expand Down Expand Up @@ -497,7 +497,7 @@ let replaceNuGetWithPaket initAutoRestore installAfter fromBootstrapper result =

if initAutoRestore && (autoVSPackageRestore || result.NuGetEnv.NuGetTargets.IsSome) then
try
VSIntegration.TurnOnAutoRestore fromBootstrapper result.PaketEnv |> returnOrFail
VSIntegration.TurnOnAutoRestore result.PaketEnv |> returnOrFail
with
| exn ->
traceWarnfn "Could not enable auto restore%sMessage: %s" Environment.NewLine exn.Message
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/PackageManagement/VSIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let TurnOffAutoRestore environment =
}

/// Activates the Visual Studio NuGet autorestore feature in all projects
let TurnOnAutoRestore fromBootstrapper environment =
let TurnOnAutoRestore environment =
let exeDir = Path.Combine(environment.RootDirectory.FullName, Constants.PaketFolderName)

trial {
Expand Down
29 changes: 6 additions & 23 deletions src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ type Dependencies(dependenciesFileName: string) =
static member Init() = Dependencies.Init(Directory.GetCurrentDirectory())

/// Initialize paket.dependencies file in the given directory
static member Init(directory) = Dependencies.Init(directory,false)

/// Initialize paket.dependencies file in the given directory
static member Init(directory,fromBootstrapper) =
static member Init(directory) =
let directory = DirectoryInfo(directory)

RunInLockedAccessMode(
Expand All @@ -84,16 +81,10 @@ type Dependencies(dependenciesFileName: string) =
)

let deps = Dependencies.Locate()
deps.DownloadLatestBootstrapper(fromBootstrapper)
deps.DownloadLatestBootstrapper()

/// Converts the solution from NuGet to Paket.
static member ConvertFromNuget(force: bool,installAfter: bool, initAutoRestore: bool,credsMigrationMode: string option, ?directory: DirectoryInfo) : unit =
match directory with
| Some d -> Dependencies.ConvertFromNuget(force, installAfter, initAutoRestore, credsMigrationMode, false, d)
| None -> Dependencies.ConvertFromNuget(force, installAfter, initAutoRestore, credsMigrationMode, false)

/// Converts the solution from NuGet to Paket.
static member ConvertFromNuget(force: bool,installAfter: bool, initAutoRestore: bool,credsMigrationMode: string option, fromBootstrapper, ?directory: DirectoryInfo) : unit =
let dir = defaultArg directory (DirectoryInfo(Directory.GetCurrentDirectory()))
let rootDirectory = dir

Expand All @@ -102,7 +93,7 @@ type Dependencies(dependenciesFileName: string) =
fun () ->
NuGetConvert.convertR rootDirectory force credsMigrationMode
|> returnOrFail
|> NuGetConvert.replaceNuGetWithPaket initAutoRestore installAfter fromBootstrapper
|> NuGetConvert.replaceNuGetWithPaket initAutoRestore installAfter
)

/// Converts the current package dependency graph to the simplest dependency graph.
Expand Down Expand Up @@ -350,12 +341,8 @@ type Dependencies(dependenciesFileName: string) =
|> this.Process
|> List.map (fun (g, p,_,newVersion) -> g.ToString(),p.ToString(),newVersion)

/// Downloads the latest paket.bootstrapper into the .paket folder.
member this.DownloadLatestBootstrapper() : unit =
this.DownloadLatestBootstrapper(false)

/// Downloads the latest paket.bootstrapper into the .paket folder and try to rename it to paket.exe in order to activate magic mode.
member this.DownloadLatestBootstrapper(fromBootstrapper) : unit =
member this.DownloadLatestBootstrapper() : unit =
RunInLockedAccessMode(
this.RootPath,
fun () ->
Expand All @@ -370,14 +357,10 @@ type Dependencies(dependenciesFileName: string) =
| _ ->())

/// Pulls new paket.targets and bootstrapper and puts them into .paket folder.
member this.TurnOnAutoRestore(fromBootstrapper: bool): unit =
member this.TurnOnAutoRestore(): unit =
RunInLockedAccessMode(
this.RootPath,
fun () -> VSIntegration.TurnOnAutoRestore fromBootstrapper |> this.Process)

/// Pulls new paket.targets and bootstrapper and puts them into .paket folder.
member this.TurnOnAutoRestore(): unit =
this.TurnOnAutoRestore(false)
fun () -> VSIntegration.TurnOnAutoRestore |> this.Process)

/// Removes paket.targets file and Import section from project files.
member this.TurnOffAutoRestore(): unit =
Expand Down
93 changes: 47 additions & 46 deletions src/Paket/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ let config (results : ParseResults<_>) =
let validateAutoRestore (results : ParseResults<_>) =
results.GetAllResults().Length = 1

let autoRestore (fromBootstrapper:bool) (results : ParseResults<_>) =
let autoRestore (results : ParseResults<_>) =
match results.GetResult <@ Flags @> with
| On -> Dependencies.Locate().TurnOnAutoRestore(fromBootstrapper)
| On -> Dependencies.Locate().TurnOnAutoRestore()
| Off -> Dependencies.Locate().TurnOffAutoRestore()

let convert (fromBootstrapper:bool) (results : ParseResults<_>) =
let convert (results : ParseResults<_>) =
let force = results.Contains <@ ConvertFromNugetArgs.Force @>
let noInstall = results.Contains <@ ConvertFromNugetArgs.No_Install @>
let noAutoRestore = results.Contains <@ ConvertFromNugetArgs.No_Auto_Restore @>
Expand All @@ -249,7 +249,7 @@ let convert (fromBootstrapper:bool) (results : ParseResults<_>) =
results.TryGetResult <@ ConvertFromNugetArgs.Migrate_Credentials @>)
|> legacyOption results (ReplaceArgument("--migrate-credentials", "--creds-migration"))

Dependencies.ConvertFromNuget(force, noInstall |> not, noAutoRestore |> not, credsMigrationMode, fromBootstrapper=fromBootstrapper)
Dependencies.ConvertFromNuget(force, noInstall |> not, noAutoRestore |> not, credsMigrationMode)

let findRefs (results : ParseResults<_>) =
let packages =
Expand All @@ -266,8 +266,8 @@ let findRefs (results : ParseResults<_>) =
packages |> List.map (fun p -> group,p)
|> Dependencies.Locate().ShowReferencesFor

let init (fromBootstrapper:bool) (results : ParseResults<InitArgs>) =
Dependencies.Init(Directory.GetCurrentDirectory(),fromBootstrapper)
let init (results : ParseResults<InitArgs>) =
Dependencies.Init(Directory.GetCurrentDirectory())

let clearCache (results : ParseResults<ClearCacheArgs>) =
Dependencies.ClearCache()
Expand Down Expand Up @@ -700,13 +700,53 @@ let why (results: ParseResults<WhyArgs>) =

Why.ohWhy(packageName, directDeps, lockFile, groupName, results.Parser.PrintUsage(), options)

let handleCommand silent command =
match command with
| Add r -> processCommand silent add r
| ClearCache r -> processCommand silent clearCache r
| Config r -> processWithValidation silent validateConfig config r
| ConvertFromNuget r -> processCommand silent convert r
| FindRefs r -> processCommand silent findRefs r
| Init r -> processCommand silent (init) r
| AutoRestore r -> processWithValidation silent validateAutoRestore autoRestore r
| Install r -> processCommand silent install r
| Outdated r -> processCommand silent outdated r
| Remove r -> processCommand silent remove r
| Restore r -> processCommand silent restore r
| Simplify r -> processCommand silent simplify r
| Update r -> processCommand silent update r
| FindPackages r -> processCommand silent (findPackages silent) r
| FindPackageVersions r -> processCommand silent findPackageVersions r
| FixNuspec r ->
warnObsolete (ReplaceArgument("fix-nuspec", "fix-nuspecs"))
processCommand silent (fixNuspec silent) r
| FixNuspecs r -> processCommand silent (fixNuspecs silent) r
| ShowInstalledPackages r -> processCommand silent showInstalledPackages r
| ShowGroups r -> processCommand silent showGroups r
| Pack r -> processCommand silent pack r
| Push r -> processCommand silent (push AssemblyVersionInformation.AssemblyInformationalVersion) r
| GenerateIncludeScripts r ->
warnObsolete (ReplaceArgument("generate-include-scripts", "generate-load-scripts"))
processCommand silent generateLoadScripts r
| GenerateLoadScripts r -> processCommand silent generateLoadScripts r
| GenerateNuspec r -> processCommand silent generateNuspec r
| Why r -> processCommand silent why r
// global options; list here in order to maintain compiler warnings
// in case of new subcommands added
| Verbose
| Silent
| From_Bootstrapper
| Version
| Log_File _ -> failwithf "internal error: this code should never be reached."
let main() =
let resolution = Environment.GetEnvironmentVariable ("PAKET_DISABLE_RUNTIME_RESOLUTION")
if System.String.IsNullOrEmpty resolution then
Environment.SetEnvironmentVariable ("PAKET_DISABLE_RUNTIME_RESOLUTION", "true")
use consoleTrace = Logging.event.Publish |> Observable.subscribe Logging.traceToConsole
let paketVersion = AssemblyVersionInformation.AssemblyInformationalVersion



try
let parser = ArgumentParser.Create<Command>(programName = "paket",
helpTextMessage = sprintf "Paket version %s%sHelp was requested:" paketVersion Environment.NewLine,
Expand All @@ -720,8 +760,6 @@ let main() =
if results.Contains <@ Verbose @> then
Logging.verbose <- true

let fromBootstrapper = results.Contains <@ From_Bootstrapper @>

let version = results.Contains <@ Version @>
if not version then

Expand All @@ -730,44 +768,7 @@ let main() =
| Some lf -> setLogFile lf
| None -> null

match results.GetSubCommand() with
| Add r -> processCommand silent add r
| ClearCache r -> processCommand silent clearCache r
| Config r -> processWithValidation silent validateConfig config r
| ConvertFromNuget r -> processCommand silent (convert fromBootstrapper) r
| FindRefs r -> processCommand silent findRefs r
| Init r -> processCommand silent (init fromBootstrapper) r
| AutoRestore r -> processWithValidation silent validateAutoRestore (autoRestore fromBootstrapper) r
| Install r -> processCommand silent install r
| Outdated r -> processCommand silent outdated r
| Remove r -> processCommand silent remove r
| Restore r -> processCommand silent restore r
| Simplify r -> processCommand silent simplify r
| Update r -> processCommand silent update r
| FindPackages r -> processCommand silent (findPackages silent) r
| FindPackageVersions r -> processCommand silent findPackageVersions r
| FixNuspec r ->
warnObsolete (ReplaceArgument("fix-nuspec", "fix-nuspecs"))
processCommand silent (fixNuspec silent) r
| FixNuspecs r -> processCommand silent (fixNuspecs silent) r
| ShowInstalledPackages r -> processCommand silent showInstalledPackages r
| ShowGroups r -> processCommand silent showGroups r
| Pack r -> processCommand silent pack r
| Push r -> processCommand silent (push paketVersion) r
| GenerateIncludeScripts r ->
warnObsolete (ReplaceArgument("generate-include-scripts", "generate-load-scripts"))
processCommand silent generateLoadScripts r
| GenerateLoadScripts r -> processCommand silent generateLoadScripts r
| GenerateNuspec r -> processCommand silent generateNuspec r
| Why r -> processCommand silent why r
// global options; list here in order to maintain compiler warnings
// in case of new subcommands added
| Verbose
| Silent
| From_Bootstrapper
| Version
| Log_File _ -> failwithf "internal error: this code should never be reached."

handleCommand silent (results.GetSubCommand())
with
| exn when not (exn :? System.NullReferenceException) ->
#if NETCOREAPP1_0
Expand Down

0 comments on commit 9ced1f6

Please sign in to comment.