Skip to content

Commit

Permalink
Merge branch 'main' of github.com:riganti/dotvvm into feature/azure-p…
Browse files Browse the repository at this point in the history
…ipelines
  • Loading branch information
cafour committed May 25, 2021
2 parents 0b448d5 + 60df745 commit bcb754f
Show file tree
Hide file tree
Showing 303 changed files with 7,135 additions and 13,221 deletions.
18 changes: 13 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ UpgradeLog*.htm
FakesAssemblies/
*.bak
/src/DotVVM.sln.GhostDoc.xml
/src/.vs
/src/DotVVM.Framework/Resources/Scripts/DotVVM.js.map
/src/DotVVM.Framework.Tests.Javascript/tests/*.js
/src/DotVVM.Framework.Tests.Javascript/tests/*.js.map
Expand All @@ -195,12 +194,21 @@ FakesAssemblies/
/src/Tools/DotVVM.Framework.Hosting.Owin.nuspec
/src/DotVVM.Samples.Common/Temp/returnedFiles

/.vs
/.vscode
/.idea
/src/.idea
.vs/
.vscode/
.idea/

/src/DotVVM.Samples.BasicSamples.Api.AspNetCore/temp/returnedFiles
/src/DotVVM.Framework.Tools.SeleniumGenerator/Properties/launchSettings.json
/src/DotVVM.Compiler/Properties/launchSettings.json
/src/DotVVM.Framework.Tests.Javascript/package-lock.json
/src/DotVVM.Framework/package-lock.json

.dotvvm/
.dotvvm.json


*.binlog
/src/DotVVM.Framework/.vs/VSWorkspaceState.json
/src/Tools/npm/dotvvm-types/*.d.ts
/src/DotVVM.Framework/junit.xml
Expand Down
4 changes: 2 additions & 2 deletions src/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// "request": "launch",
// "preLaunchTask": "build-tests",
// "program": "dotnet",
// "args": [ "test", "${workspaceRoot}/DotVVM.Framework.Tests.Common" ],
// "args": [ "test", "${workspaceRoot}/DotVVM.Framework.Tests" ],
// "cwd": "${workspaceRoot}",
// "stopAtEntry": false,
// "console": "internalConsole"
Expand Down Expand Up @@ -73,4 +73,4 @@
"envFile": "${workspaceRoot}/.env"
}
]
}
}
4 changes: 2 additions & 2 deletions src/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
{
"label": "build-tests",
"command": "build",
"args": [ "DotVVM.Framework.Tests.Common" ],
"args": [ "DotVVM.Framework.Tests" ],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
}
43 changes: 43 additions & 0 deletions src/DotVVM.CommandLine/ApiClientDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Text.Json.Serialization;

namespace DotVVM.CommandLine
{
public class ApiClientDefinition
{
public const string DefaultSwaggerFile = "openapi.json";
public const string DefaultCSharpClient = "ApiClient.cs";
public const string DefaultTypeScriptClient = "ApiClient.ts";
public const string DefaultInvalidNamespace = "Invalid.Namespace";

[JsonPropertyName("swaggerFile")]
public Uri SwaggerFile { get; set; }
= new Uri(Path.Combine(Directory.GetCurrentDirectory(), DefaultSwaggerFile));

[JsonPropertyName("csharpClient")]
public string CSharpClient { get; set; } = DefaultCSharpClient;

[JsonPropertyName("typescriptClient")]
public string TypescriptClient { get; set; } = DefaultTypeScriptClient;

[JsonPropertyName("namespace")]
public string Namespace { get; set; } = DefaultInvalidNamespace;

[JsonPropertyName("compileTypescript")]
[DefaultValue(true)]
public bool CompileTypescript { get; set; } = true;

[JsonPropertyName("generateWrapperClass")]
[DefaultValue(true)]
public bool GenerateWrapperClass { get; set; } = true;

[DefaultValue(false)]
[JsonPropertyName("isSingleClient")]
public bool IsSingleClient { get; set; }

[JsonPropertyName("fetchOptions")]
public ApiClientFetchOptions FetchOptions { get; set; } = new ApiClientFetchOptions();
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace DotVVM.CommandLine.Metadata
namespace DotVVM.CommandLine
{
public class ApiClientFetchOptions
{

[DefaultValue("same-origin")]
[JsonProperty("credentials")]
[JsonPropertyName("credentials")]
public string Credentials { get; set; } = "same-origin";

}
}
}
152 changes: 152 additions & 0 deletions src/DotVVM.CommandLine/CommandLineExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
using System.Collections.Generic;
using System.CommandLine.Builder;
using System.CommandLine.Invocation;
using System.CommandLine.Parsing;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using DotVVM.CommandLine;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Logging.Console;

namespace System.CommandLine
{
public static class CommandLineExtensions
{
public const string VerboseAlias = "--verbose";
public const string DebuggerBreakAlias = "--debugger-break";
public const string TargetArg = "target";

public static ILoggerFactory Factory = new NullLoggerFactory();

private static readonly Option<bool> verboseOption = new Option<bool>(
aliases: new[] { "-v", VerboseAlias },
description: "Print more verbose output");

private static readonly Option<bool> debuggerBreakOption = new Option<bool>(
alias: DebuggerBreakAlias,
description: "Breaks to let a debugger attach to the process");

private static readonly Argument<FileSystemInfo> targetArgument = new Argument<FileSystemInfo>(
name: TargetArg,
description: "Path to a DotVVM project")
{
Arity = ArgumentArity.ZeroOrOne
};

public static void AddRange(this Command command, params Symbol[] symbols)
{
foreach (var symbol in symbols)
{
command.Add(symbol);
}
}

public static void AddVerboseOption(this Command command)
{
command.AddGlobalOption(verboseOption);
}

public static void AddDebuggerBreakOption(this Command command)
{
command.AddGlobalOption(debuggerBreakOption);
}

public static void AddTargetArgument(this Command command)
{
command.AddArgument(targetArgument);
}

public static CommandLineBuilder UseLogging(this CommandLineBuilder builder)
{
return builder.UseMiddleware(async (c, next) =>
{
var logLevel = c.ParseResult.ValueForOption(verboseOption)
? LogLevel.Debug
: LogLevel.Information;
Factory = LoggerFactory.Create(b => b.AddConsole().SetMinimumLevel(logLevel));
var loggerName = GetCommandPath(c.ParseResult.CommandResult);
c.BindingContext.AddService(_ => Factory.CreateLogger(loggerName));
await next(c);
Factory.Dispose();
});
}

public static CommandLineBuilder UseDotvvmMetadata(this CommandLineBuilder builder)
{
return builder.UseMiddleware(async (c, next) =>
{
var target = FindTarget(c.ParseResult);
if (target is object)
{
var logger = Factory.CreateLogger("Project Metadata");
var csproj = DotvvmProject.FindProjectFile(target.FullName);
if (csproj is null)
{
logger.LogError($"No project could be found in '{target}'.");
c.ResultCode = 1;
return;
}
var project = DotvvmProject.FromCsproj(csproj.FullName, logger);
if (project is null)
{
c.ResultCode = 1;
return;
}
c.BindingContext.AddService(_ => project);
}
await next(c);
});
}

public static CommandLineBuilder UseDebuggerBreak(this CommandLineBuilder builder)
{
return builder.UseMiddleware(async (c, next) =>
{
var shouldBreak = c.ParseResult.ValueForOption<bool>(DebuggerBreakAlias);
if (shouldBreak)
{
var logger = Factory.CreateLogger("debugging");
var pid = Diagnostics.Process.GetCurrentProcess().Id;
logger.LogInformation($"Started with PID '{pid}'. Waiting for debugger to attach.");
Debugger.Break();
}
await next(c);
});
}

private static FileSystemInfo? FindTarget(ParseResult result)
{
CommandResult? current = result.CommandResult;
while (current is object)
{
var target = current.Command.Arguments.FirstOrDefault(c => c.Name == TargetArg);
if (target is object)
{
var fsInfo = result.ValueForArgument((Argument<FileSystemInfo>)target);
fsInfo ??= new DirectoryInfo(Environment.CurrentDirectory);
return fsInfo;
}
current = current.Parent as CommandResult;
}
return null;
}

private static string GetCommandPath(CommandResult result)
{
var names = new List<string>();
CommandResult? current = result;
while (current is object)
{
names.Add(current.Symbol.Name);
current = current.Parent as CommandResult;
}
names.Reverse();
return string.Join(" ", names);
}
}
}
54 changes: 0 additions & 54 deletions src/DotVVM.CommandLine/Commands/Arguments.cs

This file was deleted.

29 changes: 0 additions & 29 deletions src/DotVVM.CommandLine/Commands/CommandBase.cs

This file was deleted.

Loading

0 comments on commit bcb754f

Please sign in to comment.