-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/Mechanic.NetcoreCliTool/Mechanic.NetcoreCliTool.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<AssemblyName>dotnet-mechanic</AssemblyName> | ||
<PackageId>DotNetMechanic</PackageId> | ||
<PackageVersion>0.0.1</PackageVersion> | ||
<PackageType>DotnetCliTool</PackageType> | ||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Mechanic\Mechanic.fsproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
open System | ||
open System.IO | ||
open Mechanic | ||
open Mechanic.Files | ||
open Mechanic.GraphAlg | ||
open Mechanic.Files | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
let projectDirectory = | ||
if argv.Length = 0 then | ||
Environment.CurrentDirectory | ||
else | ||
Path.Combine (Environment.CurrentDirectory, argv.[0]) | ||
|
||
let solve (n, m) projectFile = | ||
printfn "Project %s" projectFile.FileName | ||
|
||
projectFile | ||
|> ProjectFile.getSourceFiles | ||
|> SymbolGraph.solveOrder (fun f -> f.FullName) | ||
|> function | ||
| TopologicalOrderResult.TopologicalOrder xs -> | ||
ProjectFile.updateProjectFile xs projectFile | ||
TopologicalOrderResult.TopologicalOrder (xs |> List.map (fun f -> f.FullName)) | ||
|> printfn "%A" | ||
(n + 1, m) | ||
| TopologicalOrderResult.Cycle xs -> | ||
TopologicalOrderResult.Cycle (xs |> List.map (fun f -> f.FullName)) | ||
|> printfn "%A" | ||
(n, m + 1) | ||
|
||
let projectFiles = | ||
Directory.EnumerateFiles projectDirectory | ||
|> Seq.map ProjectFile.tryLoad | ||
|> Seq.filter Option.isSome | ||
|> Seq.map (fun projectFile -> projectFile.Value) | ||
|
||
if Seq.isEmpty projectFiles then | ||
printfn "No *.fsproj files found in %s" Environment.CurrentDirectory | ||
else | ||
projectFiles | ||
|> Seq.fold solve (0, 0) | ||
|> fun (n, m) -> | ||
printfn "\nupdate %i projects, %i projects untouched because of cycle dependency" n m | ||
|
||
0 // return an integer exit code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FSharp.Core | ||
FSharp.Compiler.Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters