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 Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<!-- Framework-Agnostic Packages -->
<ItemGroup>
<PackageVersion Include="Inxton.Operon" Version="0.2.0-alpha.94" />
<PackageVersion Include="Inxton.Operon" Version="0.3.0-alpha.99" />
<PackageVersion Include="Cake.DocFx" Version="1.0.0" />
<PackageVersion Include="Octokit" Version="13.0.1" />
<PackageVersion Include="Octokit.Extensions" Version="1.0.7" />
Expand Down
107 changes: 100 additions & 7 deletions cake/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
// https://github.com/inxton/axsharp/blob/dev/LICENSE
// Third party licenses: https://github.com/inxton/axsharp/blob/master/notices.md

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using Build.FilteredSolution;
using Cake.Common.IO;
using Cake.Common.Tools.DotNet;
Expand All @@ -22,9 +17,15 @@
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Frosting;
using Polly;
using System;
using System.Collections.Generic;
using System.Formats.Tar;
using System.IO;
using System.IO.Compression;
using Polly;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;
using static NuGet.Packaging.PackagingConstants;
using Path = System.IO.Path;

Expand Down Expand Up @@ -189,7 +190,99 @@ public void PushNugetPackages(string artifactDirectory)
public string ApaxSignKey { get; set; } = System.Environment.GetEnvironmentVariable("APAX_KEY");
public string GitHubUser { get; set; } = System.Environment.GetEnvironmentVariable("GH_USER");
public string GitHubToken { get; set; } = System.Environment.GetEnvironmentVariable("GH_TOKEN");


internal void ProvisionNodeJs()
{
// Check if node is available
var nodeCommand = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "node" : "node.exe";
var npmCommand = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "npm" : "npm.cmd";

try
{
var nodeProcess = ProcessRunner.Start(nodeCommand, new ProcessSettings()
{
Arguments = "--version",
RedirectStandardOutput = true,
RedirectStandardError = true,
Silent = true
});

nodeProcess.WaitForExit();

if (nodeProcess.GetExitCode() == 0)
{
var version = string.Join("", nodeProcess.GetStandardOutput());
Log.Information($"Node.js is already installed: {version.Trim()}");
return;
}
}
catch (Exception ex)
{
Log.Warning($"Node.js not found or failed to execute: {ex.Message}");
}

// Node.js is not available, provision it
Log.Information("Node.js not found. Provisioning Node.js...");

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Use winget to install Node.js on Windows
Log.Information("Attempting to install Node.js using winget...");
var wingetProcess = ProcessRunner.Start("winget", new ProcessSettings()
{
Arguments = "install OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements",
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
});

wingetProcess.WaitForExit();

if (wingetProcess.GetExitCode() != 0)
{
Log.Warning("winget installation failed. Trying Chocolatey...");

// Fallback to Chocolatey
var chocoProcess = ProcessRunner.Start("choco", new ProcessSettings()
{
Arguments = "install nodejs-lts -y",
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
});

chocoProcess.WaitForExit();

if (chocoProcess.GetExitCode() != 0)
{
throw new Exception("Failed to provision Node.js. Please install Node.js manually from https://nodejs.org/");
}
}
}
else
{
// Linux - use package manager or nvm
Log.Information("Attempting to install Node.js on Linux...");

// Try using apt (Debian/Ubuntu)
var aptProcess = ProcessRunner.Start("bash", new ProcessSettings()
{
Arguments = "-c \"curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt-get install -y nodejs\"",
RedirectStandardOutput = false,
RedirectStandardError = false,
Silent = false
});

aptProcess.WaitForExit();

if (aptProcess.GetExitCode() != 0)
{
throw new Exception("Failed to provision Node.js on Linux. Please install Node.js manually.");
}
}

Log.Information("Node.js provisioning completed.");
}


public IEnumerable<(string ax, string approject, string solution)> GetTemplateProjects()
Expand Down
100 changes: 86 additions & 14 deletions cake/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@
// https://github.com/inxton/axsharp/blob/dev/LICENSE
// Third party licenses: https://github.com/inxton/axsharp/blob/master/notices.md

using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO;
using System.IO.Compression;
using System.IO.Packaging;
using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using AXSharp.nuget.update;
using Build.FilteredSolution;
using Cake.Common;
using Cake.Common.IO;
Expand All @@ -31,15 +21,26 @@
using Cake.Powershell;
using CliWrap;
using CommandLine;
using AXSharp.nuget.update;
using Microsoft.Extensions.DependencyInjection;
using NuGet.Packaging;
using Octokit;
using Polly;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.IO;
using System.IO.Compression;
using System.IO.Packaging;
using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using static NuGet.Packaging.PackagingConstants;
using Credentials = Octokit.Credentials;
using Path = System.IO.Path;
using ProductHeaderValue = Octokit.ProductHeaderValue;
using static NuGet.Packaging.PackagingConstants;


public static class Program
Expand Down Expand Up @@ -85,6 +86,7 @@ public override void Run(BuildContext context)
});

ProvisionProjectWideTools(context);
context.ProvisionNodeJs();
}

private static void ProvisionProjectWideTools(BuildContext context)
Expand Down Expand Up @@ -119,7 +121,7 @@ private static void ProvisionProjectWideTools(BuildContext context)
public sealed class BuildTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
{
context.DotNetBuild(Path.Combine(context.ScrDir, "AXSharp.compiler\\src\\ixc\\AXSharp.ixc.csproj"), context.DotNetBuildSettings);

var axprojects = new List<string>()
Expand All @@ -142,9 +144,79 @@ public override void Run(BuildContext context)
context.DotNetRun(Path.Combine(context.ScrDir, "AXSharp.compiler\\src\\ixc\\AXSharp.ixc.csproj"), context.DotNetRunSettings);
}

context.DotNetRestore(Path.Combine(context.ScrDir, "AXSharp.sln"));
BuildTailwindCss(context);
context.DotNetBuild(Path.Combine(context.ScrDir, "AXSharp.sln"), context.DotNetBuildSettings);

}

private void BuildTailwindCss(BuildContext context)
{
var stylingFolder = System.IO.Path.Combine(context.RootDir, "AXSharp.blazor", "src", "AXSharp.Presentation.Blazor.Controls");
var nodeModulesFolder = System.IO.Path.Combine(stylingFolder, "node_modules");

context.Log.Information($"Building Tailwind CSS in folder: {stylingFolder}");

// Check if node_modules exists, if not install packages
if (!Directory.Exists(nodeModulesFolder))
{
context.Log.Information("node_modules not found. Installing npm packages...");
var npmInstall = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "/c npm install",
WorkingDirectory = stylingFolder,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
};
npmInstall.OutputDataReceived += (sender, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
npmInstall.ErrorDataReceived += (sender, e) => { if (e.Data != null) Console.Error.WriteLine(e.Data); };
npmInstall.Start();
npmInstall.BeginOutputReadLine();
npmInstall.BeginErrorReadLine();
npmInstall.WaitForExit();

if (npmInstall.ExitCode != 0)
{
throw new Exception($"npm install failed with exit code {npmInstall.ExitCode}");
}
}

// Run the tailwind build using npx
context.Log.Information("Running Tailwind build...");
var npxBuild = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "/c npx @tailwindcss/cli -i ./wwwroot/css/tailwind.css -o ./wwwroot/css/momentum.css --minify",
WorkingDirectory = stylingFolder,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
};
npxBuild.OutputDataReceived += (sender, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
npxBuild.ErrorDataReceived += (sender, e) => { if (e.Data != null) Console.Error.WriteLine(e.Data); };
npxBuild.Start();
npxBuild.BeginOutputReadLine();
npxBuild.BeginErrorReadLine();
npxBuild.WaitForExit();

if (npxBuild.ExitCode != 0)
{
throw new Exception($"Tailwind CSS build failed with exit code {npxBuild.ExitCode}");
}

context.Log.Information("Tailwind CSS build completed.");
}

}

[TaskName("Test")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

<ItemGroup>
<Compile Remove="RenderableContentControl\**" />
<Compile Remove="wwwroot\**" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -68,16 +67,5 @@
<ItemGroup>
<!-- <ProjectReference Include="..\..\..\..\..\operon\src\Operon\Operon.csproj" /> -->
<ProjectReference Include="..\AXSharp.Presentation.Blazor\AXSharp.Presentation.Blazor.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="Layouts\**\*.*" Pack="true" PackagePath="contentFiles\Layouts\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
<None Include="Templates\**\*.*" Pack="true" PackagePath="contentFiles\Templates\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
<None Include="build\AXSharp.Presentation.Blazor.Controls.targets" Pack="true" PackagePath="build\AXSharp.Presentation.Blazor.Controls.targets" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);temp\**\*</DefaultItemExcludes>
</PropertyGroup>

</ItemGroup>
</Project>
Loading