Skip to content

Commit

Permalink
VCST-1132: Add support of CustomApps in Compress (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro authored May 2, 2024
1 parent 7217e72 commit 7d5ac37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
13 changes: 10 additions & 3 deletions src/VirtoCommerce.Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static Solution Solution

protected static bool IsModule => ModuleManifestFile.FileExists();

private static readonly string[] cleanSearchPattern = new[] { "**/bin", "**/obj" };
private static readonly string[] cleanSearchPattern = ["**/bin", "**/obj"];

private static string AIConnectionString = "InstrumentationKey=935c72ed-d8a9-4ef6-a4d1-b3ebfdfddfef;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/";
private static TelemetryClient _telemetryClient;
Expand Down Expand Up @@ -301,7 +301,13 @@ protected override void OnTargetFailed(string target)
.Before(Restore)
.Executes(() =>
{
CleanSolution(cleanSearchPattern);
AbsolutePath[] ignorePaths = null;
if (ThereAreCustomApps)
{
ignorePaths = [WebProject.Directory / "App"];
}

CleanSolution(cleanSearchPattern, ignorePaths);
});

public Target Restore => _ => _
Expand Down Expand Up @@ -541,6 +547,7 @@ private static void PublishMethod(Project webProject, string output, Configurati
}

public Target WebPackBuild => _ => _
.After(Clean)
.Executes(() =>
{
WebPackBuildMethod(WebProject);
Expand Down Expand Up @@ -571,7 +578,7 @@ private static void WebPackBuildMethod(Project webProject)
});

public Target Compress => _ => _
.DependsOn(Clean, WebPackBuild, Test, Publish)
.DependsOn(Clean, WebPackBuild, BuildCustomApp, Test, Publish)
.Executes(CompressExecuteMethod);

public Target GetManifestGit => _ => _
Expand Down
20 changes: 9 additions & 11 deletions src/VirtoCommerce.Build/PlatformTools/Build.ModuleWithCustomApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ namespace VirtoCommerce.Build
{
internal partial class Build
{
public static bool ThereAreCustomApps => IsModule && ModuleManifest?.Apps?.Length > 0;

public Target CompressWithCustomApp => _ => _
.DependsOn(CleanWithCustomApp, WebPackBuild, BuildCustomApp, Test, Publish)
.Executes(CompressExecuteMethod);
.DependsOn(Clean, WebPackBuild, BuildCustomApp, Test, Publish)
.Executes(() => {
Log.Warning("{target} is deprecated. Use {actualTarget} instead.", nameof(CompressWithCustomApp), nameof(Compress));
CompressExecuteMethod();
});

public Target BuildCustomApp => _ => _
.After(WebPackBuild)
.OnlyWhenDynamic(() => ThereAreCustomApps)
.Executes(() =>
{
if (WebProject != null && ModuleManifest.Apps.Any())
Expand All @@ -25,6 +31,7 @@ internal partial class Build
continue;
}


var chmod = ToolResolver.GetPathTool("yarn");
chmod.Invoke("install", WebProject.Directory / "App");
chmod.Invoke("build", WebProject.Directory / "App");
Expand All @@ -39,14 +46,5 @@ internal partial class Build
Log.Information("Nothing to build.");
}
});

public Target CleanWithCustomApp => _ => _
.Before(Restore)
.Executes(() =>
{
var ignorePaths = new[] { WebProject.Directory / "App" };
var searchPattern = new[] { "**/bin", "**/obj" };
CleanSolution(searchPattern, ignorePaths);
});
}
}

0 comments on commit 7d5ac37

Please sign in to comment.