Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
Move Pretzel.Logic to multitarget net451/netstandard2.0 (#328)
Browse files Browse the repository at this point in the history
* feat: netstandard is compiling for logic
* feat: moved over to System.Composition (MEF2)
* build: pretzel.logic now packs with dotnet core
* build: use latest dotnet core version supported by appveyor
  • Loading branch information
biohazard999 authored and laedit committed Sep 17, 2019
1 parent e4d949c commit 83c8009
Show file tree
Hide file tree
Showing 54 changed files with 356 additions and 309 deletions.
2 changes: 1 addition & 1 deletion BuildScripts/AppVeyor-Build.ps1
Expand Up @@ -117,7 +117,7 @@ function CreatePackage($versionInfos)
nuget pack chocoTemp\Pretzel.ScriptCs\pretzel.scriptcs.nuspec -OutputDirectory $artifacts -Version $version -NoPackageAnalysis

# build Pretzel.Logic nupkg
nuget pack $src\Pretzel.Logic\Pretzel.Logic.csproj -OutputDirectory $artifacts -Version $version -symbols
dotnet pack $src\Pretzel.Logic\Pretzel.Logic.csproj -o $artifacts /p:Version=$version --include-symbols
}

# Test
Expand Down
5 changes: 5 additions & 0 deletions global.json
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "2.2.301"
}
}
29 changes: 15 additions & 14 deletions src/Pretzel.Logic/Commands/BaseParameters.cs
@@ -1,41 +1,40 @@
using NDesk.Options;
using NDesk.Options;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Composition;
using System.IO.Abstractions;
using System.Linq;

namespace Pretzel.Logic.Commands
{
public sealed class BaseParameters
{
public OptionSet Options { get; private set; }
public OptionSet Options { get; }

public string CommandName { get; private set; }
public string CommandName { get; }

public bool Help { get; private set; }

public bool Debug { get; private set; }

public bool Safe { get; private set; }

[Export("SourcePath")]
public string Path { get; private set; }

[Export]
public IFileSystem FileSystem { get; private set; }

public List<string> CommandArgs { get; private set; }

private BaseParameters(string[] arguments, IFileSystem fileSystem)
{
Options = new OptionSet
{
{"help", "Display help mode", p => Help = true},
{"debug", "Enable debugging", p => Debug = true},
{ "safe", "Disable custom plugins", v => Safe = true },
{ "d|directory=", "[Obsolete, use --source instead] The path to site directory", p => Path = p },
{ "s|source=", "The path to the source site (default current directory)", p => Path = p}
};
{
{ "help", "Display help mode", p => Help = true },
{ "debug", "Enable debugging", p => Debug = true },
{ "safe", "Disable custom plugins", v => Safe = true },
{ "d|directory=", "[Obsolete, use --source instead] The path to site directory", p => Path = p },
{ "s|source=", "The path to the source site (default current directory)", p => Path = p }
};

FileSystem = fileSystem;

Expand All @@ -60,7 +59,9 @@ private void SetPath(string firstArgument)
? firstArgument
: FileSystem.Path.Combine(FileSystem.Directory.GetCurrentDirectory(), firstArgument);
}
Path = string.IsNullOrWhiteSpace(Path) ? FileSystem.Directory.GetCurrentDirectory() : FileSystem.Path.GetFullPath(Path);
Path = string.IsNullOrWhiteSpace(Path)
? FileSystem.Directory.GetCurrentDirectory()
: FileSystem.Path.GetFullPath(Path);
}
}
}
8 changes: 4 additions & 4 deletions src/Pretzel.Logic/Commands/CommandParameters.cs
@@ -1,19 +1,19 @@
using NDesk.Options;
using NDesk.Options;
using Pretzel.Logic.Extensibility;
using Pretzel.Logic.Extensions;
using Pretzel.Logic.Templating;
using Pretzel.Logic.Templating.Context;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Composition;
using System.IO;
using System.IO.Abstractions;
using System.Linq;

namespace Pretzel.Logic.Commands
{
[Export]
[PartCreationPolicy(CreationPolicy.Shared)]
[Shared]
public class CommandParameters
{
[ImportingConstructor]
Expand Down Expand Up @@ -47,7 +47,7 @@ public CommandParameters([ImportMany] IEnumerable<IHaveCommandLineArgs> commandL
}

[Import("SourcePath")]
public string Path { get; internal set; }
public string Path { get; set; }

public string Template { get; private set; }

Expand Down
11 changes: 8 additions & 3 deletions src/Pretzel.Logic/Configuration.cs
@@ -1,5 +1,7 @@
using Pretzel.Logic.Extensions;
using Pretzel.Logic.Commands;
using Pretzel.Logic.Extensions;
using System.Collections.Generic;
using System.Composition;
using System.IO.Abstractions;

namespace Pretzel.Logic
Expand All @@ -17,7 +19,8 @@ public interface IConfiguration
IDefaultsConfiguration Defaults { get; }
}


[Shared]
[Export(typeof(IConfiguration))]
internal sealed class Configuration : IConfiguration
{
private const string ConfigFileName = "_config.yml";
Expand All @@ -38,7 +41,8 @@ internal Configuration()
EnsureDefaults();
}

internal Configuration(IFileSystem fileSystem, string sitePath)
[ImportingConstructor]
public Configuration(IFileSystem fileSystem, [Import("SourcePath")] string sitePath)
: this()
{
_fileSystem = fileSystem;
Expand All @@ -55,6 +59,7 @@ private void EnsureDefaults()
_defaultsConfiguration = new DefaultsConfiguration(_config);
}

[OnImportsSatisfied]
internal void ReadFromFile()
{
_config = new Dictionary<string, object>();
Expand Down
@@ -1,13 +1,15 @@
using NDesk.Options;
using NDesk.Options;
using Pretzel.Logic.Extensions;
using System.ComponentModel.Composition;
using System.Composition;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Reflection;

namespace Pretzel.Logic.Extensibility.Extensions
{
[Export(typeof(IAdditionalIngredient))]
[Export(typeof(IHaveCommandLineArgs))]
public class AzureHostSupport : IAdditionalIngredient, IHaveCommandLineArgs
{
private readonly IFileSystem fileSystem;
Expand Down Expand Up @@ -67,4 +69,4 @@ public void MixIn(string directory)
Tracing.Info("Shim project added to allow deployment to azure websites");
}
}
}
}
6 changes: 4 additions & 2 deletions src/Pretzel.Logic/Extensibility/Extensions/PostUrlTag.cs
@@ -1,9 +1,10 @@
using DotLiquid;
using DotLiquid;
using System.Collections.Generic;
using System.IO;
using Pretzel.Logic.Templating.Context;
using System.Linq;
using Pretzel.Logic.Exceptions;
using System.Composition;

namespace Pretzel.Logic.Extensibility.Extensions
{
Expand Down Expand Up @@ -54,7 +55,8 @@ public override void Render(Context context, TextWriter result)
result.Write(PostUrl(_postFileName));
}
}


[Export(typeof(PostUrlTagFactory))]
public class PostUrlTagFactory : TagFactoryBase
{
public PostUrlTagFactory()
Expand Down
@@ -1,7 +1,9 @@
using System;
using System;
using System.Composition;

namespace Pretzel.Logic.Extensibility.Extensions
{
[Export(typeof(IFilter))]
public class PrettifyUrlFilter : IFilter
{
public string Name
Expand Down
4 changes: 3 additions & 1 deletion src/Pretzel.Logic/Extensibility/Extensions/SlugifyFilter.cs
@@ -1,8 +1,10 @@
using System.Globalization;
using System.Composition;
using System.Globalization;
using System.Text.RegularExpressions;

namespace Pretzel.Logic.Extensibility.Extensions
{
[Export(typeof(IFilter))]
public class SlugifyFilter : IFilter
{
public string Name
Expand Down
@@ -1,4 +1,4 @@
using System.ComponentModel.Composition;
using System.Composition;
using System.IO.Abstractions;
using System.Linq;
using System.Text.RegularExpressions;
Expand All @@ -7,6 +7,8 @@

namespace Pretzel.Logic.Extensibility.Extensions
{
[Export(typeof(IHaveCommandLineArgs))]
[Export(typeof(ITransform))]
public class VirtualDirectorySupport : ITransform, IHaveCommandLineArgs
{
readonly IFileSystem fileSystem;
Expand Down Expand Up @@ -55,4 +57,4 @@ public string[] GetArguments(string command)

public string VirtualDirectory { get; set; }
}
}
}
@@ -1,7 +1,9 @@
using System.Text.RegularExpressions;
using System.Composition;
using System.Text.RegularExpressions;

namespace Pretzel.Logic.Extensibility.Extensions
{
[Export(typeof(IContentTransform))]
public class WebSequenceDiagrams : IContentTransform
{
static readonly Regex SequenceDiagramRegex = new Regex(@"(?s:<pre><code>@@sequence(?<style>.*?)\r?\n(?<sequenceContent>.*?)</code></pre>)");
Expand Down Expand Up @@ -34,4 +36,4 @@ public string Transform(string content)
return content;
}
}
}
}
4 changes: 1 addition & 3 deletions src/Pretzel.Logic/Extensibility/IAdditionalIngredient.cs
@@ -1,10 +1,8 @@
using System.ComponentModel.Composition;

namespace Pretzel.Logic.Extensibility
{
[InheritedExport]
public interface IAdditionalIngredient
{
void MixIn(string directory);
}
}
}
8 changes: 4 additions & 4 deletions src/Pretzel.Logic/Extensibility/IBeforeProcessingTransform.cs
@@ -1,9 +1,9 @@
using System.ComponentModel.Composition;
using Pretzel.Logic.Templating.Context;

namespace Pretzel.Logic.Extensibility {
[InheritedExport]
public interface IBeforeProcessingTransform {
namespace Pretzel.Logic.Extensibility
{
public interface IBeforeProcessingTransform
{
void Transform(SiteContext context);
}
}
4 changes: 1 addition & 3 deletions src/Pretzel.Logic/Extensibility/IContentTransform.cs
@@ -1,10 +1,8 @@
using System.ComponentModel.Composition;

namespace Pretzel.Logic.Extensibility
{
[InheritedExport]
public interface IContentTransform
{
string Transform(string content);
}
}
}
2 changes: 0 additions & 2 deletions src/Pretzel.Logic/Extensibility/IFilter.cs
@@ -1,8 +1,6 @@
using System.ComponentModel.Composition;

namespace Pretzel.Logic.Extensibility
{
[InheritedExport]
public interface IFilter : IName
{
}
Expand Down
4 changes: 1 addition & 3 deletions src/Pretzel.Logic/Extensibility/IHaveCommandLineArgs.cs
@@ -1,12 +1,10 @@
using System.ComponentModel.Composition;
using NDesk.Options;

namespace Pretzel.Logic.Extensibility
{
[InheritedExport]
public interface IHaveCommandLineArgs
{
void UpdateOptions(OptionSet options);
string[] GetArguments(string command);
}
}
}
@@ -1,4 +1,3 @@
using System.ComponentModel.Composition;

namespace Pretzel.Logic.Extensibility
{
Expand Down
4 changes: 1 addition & 3 deletions src/Pretzel.Logic/Extensibility/ITransform.cs
@@ -1,11 +1,9 @@
using System.ComponentModel.Composition;
using Pretzel.Logic.Templating.Context;

namespace Pretzel.Logic.Extensibility
{
[InheritedExport]
public interface ITransform
{
void Transform(SiteContext siteContext);
}
}
}
4 changes: 1 addition & 3 deletions src/Pretzel.Logic/Extensibility/TagFactoryBase.cs
@@ -1,10 +1,8 @@
using Pretzel.Logic.Extensions;
using Pretzel.Logic.Extensions;
using Pretzel.Logic.Templating.Context;
using System.ComponentModel.Composition;

namespace Pretzel.Logic.Extensibility
{
[InheritedExport]
public abstract class TagFactoryBase : DotLiquid.ITagFactory
{
private readonly string _tageName;
Expand Down
2 changes: 1 addition & 1 deletion src/Pretzel.Logic/Extensions/IAssembly.cs
@@ -1,4 +1,4 @@
using System.ComponentModel.Composition;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;

Expand Down
5 changes: 3 additions & 2 deletions src/Pretzel.Logic/Minification/LessTransform.cs
@@ -1,4 +1,4 @@
using dotless.Core;
using dotless.Core;
using dotless.Core.Importers;
using dotless.Core.Input;
using dotless.Core.Parser;
Expand All @@ -7,13 +7,14 @@
using Pretzel.Logic.Extensibility;
using Pretzel.Logic.Templating.Context;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Composition;
using System.IO;
using System.IO.Abstractions;
using System.Linq;

namespace Pretzel.Logic.Minification
{
[Export(typeof(ITransform))]
public class LessTransform : ITransform
{
private static string[] ExternalProtocols = new[] { "http", "https", "//" };
Expand Down

0 comments on commit 83c8009

Please sign in to comment.