68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using Faithlife.Build;
|
|
using NuGet.Configuration;
|
|
using NuGet.Versioning;
|
|
using static Faithlife.Build.DotNetRunner;
|
|
|
|
internal static class Build
|
|
{
|
|
public static int Main(string[] args) => BuildRunner.Execute(args, build =>
|
|
{
|
|
var artifactDirOption = build.AddOption("--artifact-dir <directory>", "Artifact directory", defaultValue: "artifacts");
|
|
|
|
var dotNetSettings = new DotNetBuildSettings();
|
|
|
|
build.AddDotNetTargets(dotNetSettings);
|
|
|
|
build.Target("deployment-package")
|
|
.DependsOn("test")
|
|
.Describe("Creates the deployment package")
|
|
.Does(() =>
|
|
{
|
|
var projectPath = Path.Combine("src", "Twain.Web", "Twain.Web.csproj");
|
|
|
|
if (artifactDirOption.Value != null)
|
|
DeleteDirectory(artifactDirOption.Value);
|
|
|
|
RunDotNet(new[]
|
|
{
|
|
"publish", projectPath,
|
|
"-c", dotNetSettings.GetConfiguration(),
|
|
"-o", artifactDirOption.Value,
|
|
dotNetSettings.GetPlatformArg(),
|
|
"--no-build",
|
|
dotNetSettings.GetVerbosityArg(),
|
|
dotNetSettings.GetMaxCpuCountArg()
|
|
});
|
|
});
|
|
|
|
build.Target("codegen")
|
|
.DependsOn("restore")
|
|
.Describe("Generates code from the FSD")
|
|
.Does(() => CodeGen(verify: false));
|
|
|
|
build.Target("verify-codegen")
|
|
.DependsOn("restore")
|
|
.Describe("Ensures that the generated code is up-to-date")
|
|
.Does(() => CodeGen(verify: true));
|
|
|
|
build.Target("build")
|
|
.DependsOn("verify-codegen");
|
|
|
|
void CodeGen(bool verify)
|
|
{
|
|
const string slash = "/";
|
|
const string fsdFilePath = "fsd/Oap.Api.v1.fsd";
|
|
//const string clientProject = "Oap.Api.v1.Client";
|
|
const string webApiProject = "Oap.Api.v1";
|
|
|
|
var csharpCodeGenerator = DotNetLocalTool.Create("fsdgencsharp");
|
|
var jsCodeGenerator = DotNetLocalTool.Create("fsdgenjs");
|
|
|
|
var verifyOption = verify ? "--verify" : null;
|
|
|
|
csharpCodeGenerator.Run(fsdFilePath, Path.Combine("src", "OAP", webApiProject) + slash, "--namespace", webApiProject, "--clean", "--newline", "lf", verifyOption);
|
|
jsCodeGenerator.Run(fsdFilePath, Path.Combine("src", "OAP", "Oap.Theme.Svelte", "src", "lib", "oap") + slash, "--module", "OapApiV1Client", "--typescript", "--newline", "lf", verifyOption);
|
|
}
|
|
});
|
|
}
|