Skip to content
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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"ix.ixc": {
"version": "0.13.0-alpha.32",
"version": "0.13.3-alpha.53",
"commands": [
"ixc"
]
Expand Down
116 changes: 116 additions & 0 deletions cake/ApaxCmd.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Build
// Copyright (c) 2023 Peter Kurhajec (PTKu), MTS, and Contributors. All Rights Reserved.
// Contributors: https://github.com/ix-ax/ix/graphs/contributors
// See the LICENSE file in the repository root for more information.
// https://github.com/ix-ax/ix/blob/master/LICENSE
// Third party licenses: https://github.com/ix-ax/ix/blob/master/notices.md

using System.IO;
using Cake.Core.IO;
using Path = System.IO.Path;

public static class ApaxCmd
{
public static void ApaxInstall(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "install -L",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxClean(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "clean",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxBuild(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "build",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxPack(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "pack",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxTest(this BuildContext context, (string folder, string name) lib)
{
var process = context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "test",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
});

process.WaitForExit();

if(process.GetExitCode() != 0)
throw new TestFailedException();
}

public static void ApaxIxc(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "ixc",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxCopyArtifacts(this BuildContext context, (string folder, string name) lib)
{
var libraryFolder = Path.Combine(Path.Combine(context.RootDir, lib.folder), "ctrl");
var packageFile = $"{context.ApaxRegistry}-{lib.name}-{GitVersionInformation.SemVer}.apax.tgz";
var sourceFile = Path.Combine(libraryFolder, packageFile);

File.Copy(sourceFile, Path.Combine(context.ArtifactsApax, packageFile));
}


public static void ApaxPublish(this BuildContext context, (string folder, string name) lib)
{

foreach (var apaxPackageFile in Directory.EnumerateFiles(context.ArtifactsApax))
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = $"publish -p {apaxPackageFile} -r https://npm.pkg.github.com",
WorkingDirectory = context.ArtifactsApax,
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}
}
}
133 changes: 60 additions & 73 deletions cake/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,75 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.Build;
using Cake.Common.Tools.DotNet.MSBuild;
using Cake.Common.Tools.DotNet.Run;
using Cake.Common.Tools.DotNet.Test;
using Cake.Core;
using Cake.Core.IO;
using Cake.Frosting;
using Polly;
using Path = System.IO.Path;

public class BuildContext : FrostingContext
{

public string ApaxRegistry => "ix-ax";

public void UpdateApaxVersion(string file, string version)
{
var sb = new StringBuilder();
foreach (var line in System.IO.File.ReadLines(file))
{
var newLine = line;

if (line.Trim().StartsWith("version"))
{
var semicPosition = line.IndexOf(":");
var lenght = line.Length - semicPosition;

newLine = $"{line.Substring(0, semicPosition)} : '{version}'";
}
sb.AppendLine(newLine);
}

System.IO.File.WriteAllText(file, sb.ToString());
}

public void UpdateApaxDependencies(string file, IEnumerable<string> dependencies, string version)
{
var sb = new StringBuilder();
foreach (var line in System.IO.File.ReadLines(file))
{
var newLine = line;

foreach (var dependency in dependencies.Select(p => $"\"@{ApaxRegistry}/{p}\""))
{
if (line.Trim().StartsWith(dependency))
{
var semicPosition = line.IndexOf(":");
var lenght = line.Length - semicPosition;

newLine = $"{line.Substring(0, semicPosition)} : '{version}'";
}
}

sb.AppendLine(newLine);
}

System.IO.File.WriteAllText(file, sb.ToString());
}

public string Artifacts => Path.Combine(Environment.WorkingDirectory.FullPath, "..//artifacts//");

public string ArtifactsApax => EnsureFolder(Path.Combine(Artifacts, "apax"));

public string ArtifactsNugets => EnsureFolder(Path.Combine(Artifacts, "nugets"));

public string PackableNugetsSlnf => Path.Combine(RootDir, "ix.framework-packable-only.slnf");

public string WorkDirName => Environment.WorkingDirectory.GetDirectoryName();

public string ApiDocumentationDir => Path.GetFullPath(Path.Combine(Environment.WorkingDirectory.FullPath, "..//docs//api//"));
Expand Down Expand Up @@ -92,81 +146,14 @@ public string GetApaxFile((string folder, string name) library)
{
return Path.Combine(Path.Combine(RootDir, library.folder), "ctrl", "apax.yml");
}
}

public static class Apax
{
public static void ApaxInstall(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "install -L",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxClean(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "clean",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxBuild(this BuildContext context, (string folder, string name) lib)
public string EnsureFolder(string path)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
if (!Directory.Exists(path))
{
Arguments = "build",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxPack(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "pack",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}
Directory.CreateDirectory(path);
}

public static void ApaxTest(this BuildContext context, (string folder, string name) lib)
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "test",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
}

public static void ApaxPublish(this BuildContext context, (string folder, string name) lib)
{
var libraryFolder = Path.Combine(Path.Combine(context.RootDir, lib.folder), "ctrl");
var packageFile = $"ix-ax-{lib.name}-{GitVersionInformation.SemVer}.apax.tgz";
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = $"publish -p {packageFile} -r https://npm.pkg.github.com",
WorkingDirectory = libraryFolder,
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
}).WaitForExit();
return path;
}
}
2 changes: 1 addition & 1 deletion cake/BuildParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class BuildParameters
{
[Option('t', "do-test", Required = false, Default = false, HelpText = "Runs tests")]
[Option('t', "do-test", Required = false, Default = true, HelpText = "Runs tests")]
public bool DoTest { get; set; }

[Option('d', "do-docs", Required = false, Default = false, HelpText = "Generates documentation")]
Expand Down
Loading