66// https://github.com/inxton/axsharp/blob/dev/LICENSE
77// Third party licenses: https://github.com/inxton/axsharp/blob/master/notices.md
88
9- using System ;
10- using System . Collections . Generic ;
11- using System . Diagnostics . Contracts ;
12- using System . IO ;
13- using System . IO . Compression ;
14- using System . IO . Packaging ;
15- using System . Linq ;
16- using System . Management . Automation ;
17- using System . Net ;
18- using System . Text ;
19- using System . Threading . Tasks ;
9+ using AXSharp . nuget . update ;
2010using Build . FilteredSolution ;
2111using Cake . Common ;
2212using Cake . Common . IO ;
3121using Cake . Powershell ;
3222using CliWrap ;
3323using CommandLine ;
34- using AXSharp . nuget . update ;
3524using Microsoft . Extensions . DependencyInjection ;
3625using NuGet . Packaging ;
3726using Octokit ;
3827using Polly ;
28+ using System ;
29+ using System . Collections . Generic ;
30+ using System . Diagnostics ;
31+ using System . Diagnostics . Contracts ;
32+ using System . IO ;
33+ using System . IO . Compression ;
34+ using System . IO . Packaging ;
35+ using System . Linq ;
36+ using System . Management . Automation ;
37+ using System . Net ;
38+ using System . Text ;
39+ using System . Threading . Tasks ;
40+ using static NuGet . Packaging . PackagingConstants ;
3941using Credentials = Octokit . Credentials ;
4042using Path = System . IO . Path ;
4143using ProductHeaderValue = Octokit . ProductHeaderValue ;
42- using static NuGet . Packaging . PackagingConstants ;
4344
4445
4546public static class Program
@@ -85,6 +86,7 @@ public override void Run(BuildContext context)
8586 } ) ;
8687
8788 ProvisionProjectWideTools ( context ) ;
89+ context . ProvisionNodeJs ( ) ;
8890 }
8991
9092 private static void ProvisionProjectWideTools ( BuildContext context )
@@ -119,7 +121,7 @@ private static void ProvisionProjectWideTools(BuildContext context)
119121public sealed class BuildTask : FrostingTask < BuildContext >
120122{
121123 public override void Run ( BuildContext context )
122- {
124+ {
123125 context . DotNetBuild ( Path . Combine ( context . ScrDir , "AXSharp.compiler\\ src\\ ixc\\ AXSharp.ixc.csproj" ) , context . DotNetBuildSettings ) ;
124126
125127 var axprojects = new List < string > ( )
@@ -142,9 +144,79 @@ public override void Run(BuildContext context)
142144 context . DotNetRun ( Path . Combine ( context . ScrDir , "AXSharp.compiler\\ src\\ ixc\\ AXSharp.ixc.csproj" ) , context . DotNetRunSettings ) ;
143145 }
144146
147+ context . DotNetRestore ( Path . Combine ( context . ScrDir , "AXSharp.sln" ) ) ;
148+ BuildTailwindCss ( context ) ;
145149 context . DotNetBuild ( Path . Combine ( context . ScrDir , "AXSharp.sln" ) , context . DotNetBuildSettings ) ;
146150
147151 }
152+
153+ private void BuildTailwindCss ( BuildContext context )
154+ {
155+ var stylingFolder = System . IO . Path . Combine ( context . RootDir , "AXSharp.blazor" , "src" , "AXSharp.Presentation.Blazor.Controls" ) ;
156+ var nodeModulesFolder = System . IO . Path . Combine ( stylingFolder , "node_modules" ) ;
157+
158+ context . Log . Information ( $ "Building Tailwind CSS in folder: { stylingFolder } ") ;
159+
160+ // Check if node_modules exists, if not install packages
161+ if ( ! Directory . Exists ( nodeModulesFolder ) )
162+ {
163+ context . Log . Information ( "node_modules not found. Installing npm packages..." ) ;
164+ var npmInstall = new Process
165+ {
166+ StartInfo = new ProcessStartInfo
167+ {
168+ FileName = "cmd.exe" ,
169+ Arguments = "/c npm install" ,
170+ WorkingDirectory = stylingFolder ,
171+ UseShellExecute = false ,
172+ RedirectStandardOutput = true ,
173+ RedirectStandardError = true ,
174+ CreateNoWindow = true
175+ }
176+ } ;
177+ npmInstall . OutputDataReceived += ( sender , e ) => { if ( e . Data != null ) Console . WriteLine ( e . Data ) ; } ;
178+ npmInstall . ErrorDataReceived += ( sender , e ) => { if ( e . Data != null ) Console . Error . WriteLine ( e . Data ) ; } ;
179+ npmInstall . Start ( ) ;
180+ npmInstall . BeginOutputReadLine ( ) ;
181+ npmInstall . BeginErrorReadLine ( ) ;
182+ npmInstall . WaitForExit ( ) ;
183+
184+ if ( npmInstall . ExitCode != 0 )
185+ {
186+ throw new Exception ( $ "npm install failed with exit code { npmInstall . ExitCode } ") ;
187+ }
188+ }
189+
190+ // Run the tailwind build using npx
191+ context . Log . Information ( "Running Tailwind build..." ) ;
192+ var npxBuild = new Process
193+ {
194+ StartInfo = new ProcessStartInfo
195+ {
196+ FileName = "cmd.exe" ,
197+ Arguments = "/c npx @tailwindcss/cli -i ./wwwroot/css/tailwind.css -o ./wwwroot/css/momentum.css --minify" ,
198+ WorkingDirectory = stylingFolder ,
199+ UseShellExecute = false ,
200+ RedirectStandardOutput = true ,
201+ RedirectStandardError = true ,
202+ CreateNoWindow = true
203+ }
204+ } ;
205+ npxBuild . OutputDataReceived += ( sender , e ) => { if ( e . Data != null ) Console . WriteLine ( e . Data ) ; } ;
206+ npxBuild . ErrorDataReceived += ( sender , e ) => { if ( e . Data != null ) Console . Error . WriteLine ( e . Data ) ; } ;
207+ npxBuild . Start ( ) ;
208+ npxBuild . BeginOutputReadLine ( ) ;
209+ npxBuild . BeginErrorReadLine ( ) ;
210+ npxBuild . WaitForExit ( ) ;
211+
212+ if ( npxBuild . ExitCode != 0 )
213+ {
214+ throw new Exception ( $ "Tailwind CSS build failed with exit code { npxBuild . ExitCode } ") ;
215+ }
216+
217+ context . Log . Information ( "Tailwind CSS build completed." ) ;
218+ }
219+
148220}
149221
150222[ TaskName ( "Test" ) ]
0 commit comments