From 318af3a00fbf42300f24973b5b29e35e58672af6 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Sun, 18 Aug 2019 18:35:56 +0200 Subject: [PATCH 1/8] added Changelog.md, removed one warning, minor fixes --- Changelog.md | 24 +++++++++++++++++ LICENSE.txt | 2 +- ReadMe.md | 27 ++++++++++++++++--- src/Cake.AsciiDoctorJ.nuspec | 4 +-- .../AsciiDoctorJRunnerSettings.cs | 3 +++ 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 Changelog.md diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 00000000..5da4a3de --- /dev/null +++ b/Changelog.md @@ -0,0 +1,24 @@ +# Changelog +Changelog for Cake.AsciiDoctorJ + +_The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)._ + +## [Unreleased] +### Changed +- moved project into cake-contrb +- modified nuspec to reflect new project-path +- created a changelog + +## [1.0.0] - 2019-08-13 +### Added +- inline documentation + +## [0.0.1] - 2019-08-12 +### Added +- Initial idea - working version mostly without documentation + + +[Unreleased]: https://github.com/cake-contrib/cake.asciidoctorj/compare/v1.0.0...HEAD +[1.0.0]: https://github.com/cake-contrib/cake.asciidoctorj/compare/v0.0.1...v1.0.0 +[0.0.1]: https://github.com/cake-contrib/cake.asciidoctorj/tree/v0.0.1 \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt index 403462ac..a4bc525b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) .NET Foundation and Contributors +Copyright (c) Nils Andresen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/ReadMe.md b/ReadMe.md index 341ba8c4..8b9f6824 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,6 +1,8 @@ # cake.asciidoctorj -makes [asciidoctorj](https://github.com/asciidoctor/asciidoctorj) available as a tool in [cake](https://cakebuild.net/) +This addin makes [asciidoctorj](https://github.com/asciidoctor/asciidoctorj) available as a tool in [cake](https://cakebuild.net/) + +[![License](http://img.shields.io/:license-mit-blue.svg)](http://cake-contrib.mit-license.org) ## usage @@ -15,6 +17,25 @@ AsciiDoctorJ(s => s .WithDestinationDir(distDir)); ``` -## TODO +## Build Status + +|Develop|Master| +|:--:|:--:| +|[![Build status](https://ci.appveyor.com/api/projects/status/lfnuyv5q5dbc9aoj/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-asciidoctorj/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/lfnuyv5q5dbc9aoj/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-asciidoctorj/branch/master)| + +## Code Coverage + +[![Coverage Status](https://coveralls.io/repos/github/cake-contrib/cake.asciidoctorj/badge.svg?branch=develop)](https://coveralls.io/github/cake-contrib/cake.asciidoctorj?branch=develop) + +## Packages + +| Location | Link | +|:--:|:--:| +|NuGet|![Nuget](https://img.shields.io/nuget/v/cake.asciidoctorj)| + + +## Chat Room + +Join in the conversation about Cake.AsciiDoctorJ on gitter -* Documentation ! \ No newline at end of file +[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/src/Cake.AsciiDoctorJ.nuspec b/src/Cake.AsciiDoctorJ.nuspec index 9f3045d5..d4bc54c7 100644 --- a/src/Cake.AsciiDoctorJ.nuspec +++ b/src/Cake.AsciiDoctorJ.nuspec @@ -2,12 +2,12 @@ Cake.AsciiDoctorJ - 1.0.0 + 1.0.1 Cake.AsciiDoctorJ Nils Andresen Nils Andresen MIT - https://github.com/nils-a/cake.asciidoctorj + https://github.com/cake-contrib/cake.asciidoctorj https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png false Adds AsciiDoctorJ alias for Cake diff --git a/src/Cake.AsciiDoctorJ/AsciiDoctorJRunnerSettings.cs b/src/Cake.AsciiDoctorJ/AsciiDoctorJRunnerSettings.cs index c4690d87..4926ee56 100644 --- a/src/Cake.AsciiDoctorJ/AsciiDoctorJRunnerSettings.cs +++ b/src/Cake.AsciiDoctorJ/AsciiDoctorJRunnerSettings.cs @@ -111,6 +111,9 @@ public AsciiDoctorJRunnerSettings() /// public bool SuppressHeaderAndFooter { get; set; } + /// + /// The list of input files to be processed. + /// public IList InputFiles { get; private set; } /// From 5a68c984d1135a314124f11bafeb9d3e6c1abe5c Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Sun, 18 Aug 2019 21:44:22 +0200 Subject: [PATCH 2/8] added first unittests --- .gitignore | 2 + ReadMe.md | 4 +- build/build.cake | 6 +- res/GlobalAssemblyInfo.cs | 31 +++++ .../Cake.AsciiDoctorJ.Tests.csproj | 110 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 10 ++ .../SettingsExtensionsTests.cs | 83 +++++++++++++ src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs | 91 +++++++++++++++ src/Cake.AsciiDoctorJ.Tests/TestBase.cs | 17 +++ src/Cake.AsciiDoctorJ.Tests/app.config | 19 +++ src/Cake.AsciiDoctorJ.Tests/packages.config | 15 +++ src/Cake.AsciiDoctorJ.sln | 6 + .../Cake.AsciiDoctorJ.csproj | 3 + .../Properties/AssemblyInfo.cs | 26 +---- 14 files changed, 395 insertions(+), 28 deletions(-) create mode 100644 res/GlobalAssemblyInfo.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj create mode 100644 src/Cake.AsciiDoctorJ.Tests/Properties/AssemblyInfo.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/TestBase.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/app.config create mode 100644 src/Cake.AsciiDoctorJ.Tests/packages.config diff --git a/.gitignore b/.gitignore index 7f31cfc8..bac39498 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ lib/packages/ .vs/ build/tools dist +TestResult.xml +TestResults/ diff --git a/ReadMe.md b/ReadMe.md index 8b9f6824..bcb19dc0 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,10 +1,10 @@ -# cake.asciidoctorj +# Cake.AsciiDoctorJ This addin makes [asciidoctorj](https://github.com/asciidoctor/asciidoctorj) available as a tool in [cake](https://cakebuild.net/) [![License](http://img.shields.io/:license-mit-blue.svg)](http://cake-contrib.mit-license.org) -## usage +## Usage Install asciidoctorj - this addin has no dependency on asciidoctorj. diff --git a/build/build.cake b/build/build.cake index 6a718da9..5d4ea8db 100644 --- a/build/build.cake +++ b/build/build.cake @@ -1,4 +1,4 @@ - +#tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0" ////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -38,6 +38,10 @@ Task("Build") .SetConfiguration(configuration) .WithTarget("Build") ); + + var testAssemblies = GetFiles(srcDir + File($"**/bin/{configuration}/*.Tests.dll")); + var workDir = testAssemblies.First().GetDirectory(); + NUnit3(testAssemblies); }); Task("Dist") diff --git a/res/GlobalAssemblyInfo.cs b/res/GlobalAssemblyInfo.cs new file mode 100644 index 00000000..91ef2838 --- /dev/null +++ b/res/GlobalAssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyDescription("Cake.AsciiDoctorJ")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Cake.AsciiDoctorJ")] +[assembly: AssemblyCopyright("Copyright © Nils Andresen 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj b/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj new file mode 100644 index 00000000..b34e65f3 --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj @@ -0,0 +1,110 @@ + + + + + + + Debug + AnyCPU + {76882FBF-6DA4-4221-AC2E-8D5CB28F104D} + Library + Properties + Cake.AsciiDoctorJ.Tests + Cake.AsciiDoctorJ.Tests + v4.6 + 512 + true + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\lib\packages\AutoFixture.4.11.0\lib\net452\AutoFixture.dll + + + ..\..\lib\packages\AutoFixture.AutoNSubstitute.4.11.0\lib\net452\AutoFixture.AutoNSubstitute.dll + + + ..\..\lib\packages\Cake.Core.0.34.1\lib\net46\Cake.Core.dll + + + ..\..\lib\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll + + + ..\..\lib\packages\Fare.2.1.2\lib\net35\Fare.dll + + + ..\..\lib\packages\FluentAssertions.5.8.0\lib\net45\FluentAssertions.dll + + + ..\..\lib\packages\NSubstitute.4.2.1\lib\net46\NSubstitute.dll + + + ..\..\lib\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll + + + + + + + ..\..\lib\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\..\lib\packages\System.Threading.Tasks.Extensions.4.5.3\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll + + + ..\..\lib\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll + + + + + + + + + + + Properties\GlobalAssemblyInfo.cs + + + + + + + + + {5b65b4ed-0902-48a4-8ff6-c3e6d0954bc6} + Cake.AsciiDoctorJ + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/Properties/AssemblyInfo.cs b/src/Cake.AsciiDoctorJ.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..120c7667 --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Cake.AsciiDoctorJ.Tests")] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("76882fbf-6da4-4221-ac2e-8d5cb28f104d")] \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs b/src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs new file mode 100644 index 00000000..f3597d5a --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs @@ -0,0 +1,83 @@ +using Cake.Core; +using Cake.Core.IO; +using NUnit.Framework; +using AutoFixture; +using FluentAssertions; + +namespace Cake.AsciiDoctorJ.Tests +{ + [TestFixture] + public class SettingsExtensionsTests : TestBase + { + [SetUp] + public void Setup() + { + SetupFixture(); + } + + [TestCase("WithVersion", "--version")] + [TestCase("WithVerbose", "--verbose")] + [TestCase("WithTimingsMode", "--timings")] + [TestCase("WithSectionNumbers", "--section-numbers")] + [TestCase("WithRequire", "--require")] + [TestCase("WithQuiet", "--quiet")] + [TestCase("WithSuppressHeaderAndFooter", "--no-header-footer")] + [TestCase("WithCompact", "--compact")] + public void SimpleBoolProperties(string extensionName, string expectedParam) + { + var args = new ProcessArgumentBuilder(); + var sut = new AsciiDoctorJRunnerSettings(); + + var ext = typeof(AsciiDoctorJRunnerSettingsExtensions).GetMethod(extensionName, + System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); + ext.Invoke(null, new object[] { sut }); + + sut.Evaluate(args, Fixture.Create()); + + var actual = args.Render(); + actual.Should().Contain(expectedParam); + } + + [TestCase(SafeMode.Safe, "--safe-mode safe")] + [TestCase(SafeMode.Unsafe, "--safe-mode unsafe")] + [TestCase(SafeMode.Secure, "--safe-mode secure")] + [TestCase(SafeMode.Server, "--safe-mode server")] + public void SafeModeValues(SafeMode mode, string expected) + { + var args = new ProcessArgumentBuilder(); + var sut = new AsciiDoctorJRunnerSettings().WithSafeMode(mode); + + sut.Evaluate(args, Fixture.Create()); + + var actual = args.Render(); + actual.Should().Contain(expected); + } + + [TestCase(ERuby.Erb, "--eruby erb")] + [TestCase(ERuby.Erubis, "--eruby erubis")] + public void ERubyValues(ERuby eruby, string expected) + { + var args = new ProcessArgumentBuilder(); + var sut = new AsciiDoctorJRunnerSettings().WithERuby(eruby); + + sut.Evaluate(args, Fixture.Create()); + + var actual = args.Render(); + actual.Should().Contain(expected); + } + + [TestCase(DocType.Article, "--doctype article")] + [TestCase(DocType.Book, "--doctype book")] + [TestCase(DocType.Inline, "--doctype inline")] + public void DocTypeValues(DocType type, string expected) + { + var args = new ProcessArgumentBuilder(); + var sut = new AsciiDoctorJRunnerSettings().WithDocType(type); + + sut.Evaluate(args, Fixture.Create()); + + var actual = args.Render(); + actual.Should().Contain(expected); + } + } +} \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs b/src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs new file mode 100644 index 00000000..01805e49 --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs @@ -0,0 +1,91 @@ +using Cake.Core; +using Cake.Core.IO; +using NUnit.Framework; +using AutoFixture; +using FluentAssertions; + +namespace Cake.AsciiDoctorJ.Tests +{ + [TestFixture] + public class SettingsTests : TestBase + { + [SetUp] + public void Setup() + { + SetupFixture(); + } + + [TestCase("Version", "--version")] + [TestCase("Verbose", "--verbose")] + [TestCase("TimingsMode", "--timings")] + [TestCase("SectionNumbers", "--section-numbers")] + [TestCase("Require", "--require")] + [TestCase("Quiet", "--quiet")] + [TestCase("SuppressHeaderAndFooter", "--no-header-footer")] + [TestCase("Compact", "--compact")] + public void SimpleBoolProperties(string propertyName, string expectedParam) + { + var args = new ProcessArgumentBuilder(); + var sut = new AsciiDoctorJRunnerSettings(); + + var prop = typeof(AsciiDoctorJRunnerSettings).GetProperty(propertyName); + prop.SetValue(sut, true); + + sut.Evaluate(args, Fixture.Create()); + + var actual = args.Render(); + actual.Should().Contain(expectedParam); + } + + [TestCase(SafeMode.Safe, "--safe-mode safe")] + [TestCase(SafeMode.Unsafe, "--safe-mode unsafe")] + [TestCase(SafeMode.Secure, "--safe-mode secure")] + [TestCase(SafeMode.Server, "--safe-mode server")] + public void SafeModeValues(SafeMode mode, string expected) + { + var args = new ProcessArgumentBuilder(); + var sut = new AsciiDoctorJRunnerSettings + { + SafeMode = mode + }; + + sut.Evaluate(args, Fixture.Create()); + + var actual = args.Render(); + actual.Should().Contain(expected); + } + + [TestCase(ERuby.Erb, "--eruby erb")] + [TestCase(ERuby.Erubis, "--eruby erubis")] + public void ERubyValues(ERuby eruby, string expected) + { + var args = new ProcessArgumentBuilder(); + var sut = new AsciiDoctorJRunnerSettings + { + ERuby = eruby + }; + + sut.Evaluate(args, Fixture.Create()); + + var actual = args.Render(); + actual.Should().Contain(expected); + } + + [TestCase(DocType.Article, "--doctype article")] + [TestCase(DocType.Book, "--doctype book")] + [TestCase(DocType.Inline, "--doctype inline")] + public void DocTypeValues(DocType type, string expected) + { + var args = new ProcessArgumentBuilder(); + var sut = new AsciiDoctorJRunnerSettings + { + DocType = type + }; + + sut.Evaluate(args, Fixture.Create()); + + var actual = args.Render(); + actual.Should().Contain(expected); + } + } +} \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/TestBase.cs b/src/Cake.AsciiDoctorJ.Tests/TestBase.cs new file mode 100644 index 00000000..d206d2ab --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/TestBase.cs @@ -0,0 +1,17 @@ +using AutoFixture; +using AutoFixture.AutoNSubstitute; +using System; + +namespace Cake.AsciiDoctorJ.Tests +{ + public abstract class TestBase + { + protected IFixture Fixture; + + protected void SetupFixture(Action modifications = null) + { + Fixture = new Fixture().Customize(new AutoNSubstituteCustomization()); + modifications?.Invoke(Fixture); + } + } +} \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/app.config b/src/Cake.AsciiDoctorJ.Tests/app.config new file mode 100644 index 00000000..f434d45d --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/packages.config b/src/Cake.AsciiDoctorJ.Tests/packages.config new file mode 100644 index 00000000..f55176b8 --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.sln b/src/Cake.AsciiDoctorJ.sln index eb1d5104..e5a35b25 100644 --- a/src/Cake.AsciiDoctorJ.sln +++ b/src/Cake.AsciiDoctorJ.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29102.190 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.AsciiDoctorJ", "Cake.AsciiDoctorJ\Cake.AsciiDoctorJ.csproj", "{5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.AsciiDoctorJ.Tests", "Cake.AsciiDoctorJ.Tests\Cake.AsciiDoctorJ.Tests.csproj", "{76882FBF-6DA4-4221-AC2E-8D5CB28F104D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Debug|Any CPU.Build.0 = Debug|Any CPU {5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Release|Any CPU.ActiveCfg = Release|Any CPU {5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Release|Any CPU.Build.0 = Release|Any CPU + {76882FBF-6DA4-4221-AC2E-8D5CB28F104D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76882FBF-6DA4-4221-AC2E-8D5CB28F104D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76882FBF-6DA4-4221-AC2E-8D5CB28F104D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76882FBF-6DA4-4221-AC2E-8D5CB28F104D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Cake.AsciiDoctorJ/Cake.AsciiDoctorJ.csproj b/src/Cake.AsciiDoctorJ/Cake.AsciiDoctorJ.csproj index 24f1345d..cef41ca9 100644 --- a/src/Cake.AsciiDoctorJ/Cake.AsciiDoctorJ.csproj +++ b/src/Cake.AsciiDoctorJ/Cake.AsciiDoctorJ.csproj @@ -49,6 +49,9 @@ + + Properties\GlobalAssemblyInfo.cs + diff --git a/src/Cake.AsciiDoctorJ/Properties/AssemblyInfo.cs b/src/Cake.AsciiDoctorJ/Properties/AssemblyInfo.cs index c0dc4c2a..553a8d90 100644 --- a/src/Cake.AsciiDoctorJ/Properties/AssemblyInfo.cs +++ b/src/Cake.AsciiDoctorJ/Properties/AssemblyInfo.cs @@ -6,31 +6,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Cake.AsciiDoctorJ")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Cake.AsciiDoctorJ")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("5b65b4ed-0902-48a4-8ff6-c3e6d0954bc6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: InternalsVisibleTo("Cake.AsciiDoctorJ.Tests")] \ No newline at end of file From 554555183a5cb93a0193dca436c14c9a5433f6f0 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Sun, 18 Aug 2019 21:57:19 +0200 Subject: [PATCH 3/8] (build) enabled unittests in appveyor --- .appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 3ba38d8d..2f43c699 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -12,7 +12,9 @@ build_script: #---------------------------------# # Tests #---------------------------------# -test: off +test: + assemblies: + - '**\*.tests.dll' #---------------------------------# # Pull Requests # From dff984f5f9d3cd95e796e554da2912a412cb6d03 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Sun, 18 Aug 2019 23:11:30 +0200 Subject: [PATCH 4/8] (build) added opencover to build --- .appveyor.yml | 4 +--- build/build.cake | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2f43c699..3ba38d8d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -12,9 +12,7 @@ build_script: #---------------------------------# # Tests #---------------------------------# -test: - assemblies: - - '**\*.tests.dll' +test: off #---------------------------------# # Pull Requests # diff --git a/build/build.cake b/build/build.cake index 5d4ea8db..29fc1ea6 100644 --- a/build/build.cake +++ b/build/build.cake @@ -1,4 +1,5 @@ #tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0" +#tool "nuget:?package=OpenCover&version=4.7.922" ////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -38,10 +39,31 @@ Task("Build") .SetConfiguration(configuration) .WithTarget("Build") ); - + + // test & coverage var testAssemblies = GetFiles(srcDir + File($"**/bin/{configuration}/*.Tests.dll")); - var workDir = testAssemblies.First().GetDirectory(); - NUnit3(testAssemblies); + var testOutput = binDir + File("TestResult.xml"); + var coverOutput = binDir + File("CoverageResult.xml"); + OpenCover(c => + { + c.NUnit3(testAssemblies, new NUnit3Settings + { + Work = binDir, + OutputFile = testOutput + }); + }, + coverOutput, + new OpenCoverSettings() + .WithFilter("+[Cake.AsciiDoctorJ]*") + .WithFilter("-[Cake.AsciiDoctorJ.Tests]*") + ); + + // on AppVeyor, publish testsettings.. + if(EnvironmentVariable("APPVEYOR_JOB_ID") != null) + { + Information("Running on appveyor. Publishing Test-Result."); + BuildSystem.AppVeyor.UploadTestResults(testOutput, AppVeyorTestResultsType.NUnit3); + } }); Task("Dist") From f768151327bd19e79f03af6d1a8f93b0b9f5a2a0 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Sun, 18 Aug 2019 23:29:07 +0200 Subject: [PATCH 5/8] (build) push to coveralls --- build/build.cake | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/build/build.cake b/build/build.cake index 29fc1ea6..fb2094fc 100644 --- a/build/build.cake +++ b/build/build.cake @@ -1,5 +1,7 @@ #tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0" #tool "nuget:?package=OpenCover&version=4.7.922" +#tool "nuget:?package=coveralls.io&version=1.4.2" +#addin "nuget:?package=Cake.Coveralls&version=0.10.0" ////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -41,6 +43,7 @@ Task("Build") ); // test & coverage + Information("Test and coverage..."); var testAssemblies = GetFiles(srcDir + File($"**/bin/{configuration}/*.Tests.dll")); var testOutput = binDir + File("TestResult.xml"); var coverOutput = binDir + File("CoverageResult.xml"); @@ -61,8 +64,22 @@ Task("Build") // on AppVeyor, publish testsettings.. if(EnvironmentVariable("APPVEYOR_JOB_ID") != null) { - Information("Running on appveyor. Publishing Test-Result."); + Information("Running on AppVeyor. Publishing Test-Result."); BuildSystem.AppVeyor.UploadTestResults(testOutput, AppVeyorTestResultsType.NUnit3); + + var repoToken = EnvironmentVariable("COVERALLS_REPO_TOKEN"); + if(repoToken == null) + { + Warning("We're running on AppVeyor but there is no COVERALLS_REPO_TOKEN"); + } + else + { + Information("Publishing Coverage-Result to coveralls.io"); + CoverallsIo(coverOutput, new CoverallsIoSettings() + { + RepoToken = repoToken + }); + } } }); From b37de0a9a1046313c302f2ae80662f712099b852 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Tue, 20 Aug 2019 10:17:45 +0200 Subject: [PATCH 6/8] restructured the project using the wonderful https://github.com/WormieCorp/generator-cake-addin --- .all-contributorsrc | 13 ++ .appveyor.yml | 51 ++----- .editorconfig | 38 +++++ .gitattributes | 21 +++ .gitignore | 59 ++++++- .gitlab-ci.yml | 9 -- .vscode/tasks.json | 42 +++++ CODE_OF_CONDUCT.md | 76 +++++++++ CONTRIBUTING.md | 144 ++++++++++++++++++ Changelog.md | 2 +- GitReleaseManager.yaml | 34 +++++ LICENSE.txt | 27 ++-- ReadMe.md | 82 +++++++--- build/build.ps1 => build.ps1 | 117 +++++++------- build/build.sh => build.sh | 75 +++++---- build/build.cake | 108 ------------- build/nuget.config | 6 - recipe.cake | 23 +++ res/GlobalAssemblyInfo.cs | 31 ---- .../AsciiDoctorJAliasesFixture.cs | 44 ++++++ .../AsciiDoctorJAliasesTests.cs | 28 ++++ .../AsciiDoctorJRunnerFixture.cs | 18 +++ .../AsciiDoctorJRunnerTests.cs | 24 +++ .../Cake.AsciiDoctorJ.Tests.csproj | 128 +++------------- .../Properties/AssemblyInfo.cs | 10 -- .../SettingsExtensionsTests.cs | 31 ++-- src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs | 29 ++-- src/Cake.AsciiDoctorJ.Tests/TestBase.cs | 17 --- src/Cake.AsciiDoctorJ.Tests/app.config | 19 --- src/Cake.AsciiDoctorJ.Tests/packages.config | 15 -- src/Cake.AsciiDoctorJ.nuspec | 21 --- src/Cake.AsciiDoctorJ.sln | 36 ++--- src/Cake.AsciiDoctorJ/AsciiDoctorJAliases.cs | 48 +++++- src/Cake.AsciiDoctorJ/AsciiDoctorJRunner.cs | 13 +- .../Cake.AsciiDoctorJ.csproj | 104 +++++-------- .../Properties/AssemblyInfo.cs | 12 -- src/Cake.AsciiDoctorJ/packages.config | 4 - tools/packages.config | 4 + 38 files changed, 920 insertions(+), 643 deletions(-) create mode 100644 .all-contributorsrc create mode 100644 .editorconfig create mode 100644 .gitattributes delete mode 100644 .gitlab-ci.yml create mode 100644 .vscode/tasks.json create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 GitReleaseManager.yaml rename build/build.ps1 => build.ps1 (67%) rename build/build.sh => build.sh (57%) mode change 100755 => 100644 delete mode 100644 build/build.cake delete mode 100644 build/nuget.config create mode 100644 recipe.cake delete mode 100644 res/GlobalAssemblyInfo.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJAliasesFixture.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJAliasesTests.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJRunnerFixture.cs create mode 100644 src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJRunnerTests.cs delete mode 100644 src/Cake.AsciiDoctorJ.Tests/Properties/AssemblyInfo.cs delete mode 100644 src/Cake.AsciiDoctorJ.Tests/TestBase.cs delete mode 100644 src/Cake.AsciiDoctorJ.Tests/app.config delete mode 100644 src/Cake.AsciiDoctorJ.Tests/packages.config delete mode 100644 src/Cake.AsciiDoctorJ.nuspec delete mode 100644 src/Cake.AsciiDoctorJ/Properties/AssemblyInfo.cs delete mode 100644 src/Cake.AsciiDoctorJ/packages.config create mode 100644 tools/packages.config diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 00000000..3edf6c8a --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,13 @@ +{ + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "contributors": [], + "contributorsPerLine": 7, + "projectName": "Cake.AsciiDoctorJ", + "projectOwner": "cake-contrib", + "repoType": "github", + "repoHost": "https://github.com" +} diff --git a/.appveyor.yml b/.appveyor.yml index 3ba38d8d..2a8a174c 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,50 +1,23 @@ -#---------------------------------# -# Build Image # -#---------------------------------# -image: Visual Studio 2017 +image: + - Visual Studio 2017 -#---------------------------------# -# Build Script # -#---------------------------------# -build_script: - - ps: .\build\build.ps1 - -#---------------------------------# -# Tests -#---------------------------------# -test: off - -#---------------------------------# -# Pull Requests # -#---------------------------------# pull_requests: do_not_increment_build_number: true -#---------------------------------# -# General # -#---------------------------------# skip_branch_with_pr: true -#---------------------------------# -# Branches to build # -#---------------------------------# branches: - # Whitelist only: - - develop - master - - /release/.*/ - - /hotfix/.*/ + - develop + - /release\/.*/ + - /hotfix\/.*/ -#---------------------------------# -# Build Cache # -#---------------------------------# -cache: -- tools -> build/build.cake, tools/packages.config +test: off +build: off -#---------------------------------# -# Skip builds for doc changes # -#---------------------------------# -skip_commits: - # Regex for matching commit message - message: /(doc).*/ +build_script: + - ps: .\build.ps1 -Target AppVeyor + +cache: + - "tools -> recipe.cake,tools/packages.config" diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4e1e34d3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,38 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +# This may not be needed, but kept for compatibility with VS +[*.{sln,csproj}] +end_of_line = crlf + +# Markdown files allows the use of trailing spaces to denote +# a line break +[*.md] +trim_trailing_whitespace = false + +# Batch and powershell files requires crlf to be +# used as the line ending. +# Powershell also requires UTF-8 with BOM encoding +# to function if utf8 characters is used (maibe batch files as well) +[*.{bat,ps1}] +charset = utf-8-bom +end_of_line = crlf + +# Shell scripts requires the use of lf line endings +# to be able to run. +[*.sh] +end_of_line = lf + +[*.{yml,yaml}] +indent_size = 2 + +# The visual studio code file +# requires the use of crlf line endings +[tasks.json] +end_of_line = crlf diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..3dde06ea --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +*.cs text diff=csharp + +*.ps1 text eol=crlf +*.bat text eol=crlf +*.sln text eol=crlf +*.csproj text eol=crlf +tasks.json text eol=crlf + +*.sh text eol=lf + +*.md text whitespace=-trailing-space + +# Exclude files from exporting + +.gitattributes export-ignore +.gitignore export-ignore diff --git a/.gitignore b/.gitignore index bac39498..83d6d57c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,53 @@ -bin/ -obj/ -lib/packages/ +# Ignore everything in vscode folder +# except what we want users to +# contribute if there is any +# improvement +.vscode/* +!.vscode/extensions.json +!.vscode/settings.json +!.vscode/tasks.json + +# User-specific files in Visual Studio +*.suo +*.user +*.userosscache +*.sln.docstates .vs/ -build/tools -dist -TestResult.xml -TestResults/ + +# GhostDoc plugin settings file +*.GhostDoc.xml + +# Ignore cake tools directory, except packages.config +tools/* +!tools/packages.config + +# Ignore build artifacts +BuildArtifacts/ +[Oo]bj/ +[Bb]in/ + +# OS Specific files +*~ +.DS_Store +.AppleDouble +.LSOverride + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Windows shortcuts +*.lnk + +# Thumbnails +._* + +# Cake.Graph related +docs/input/tasks/* + +# Wyam related +config.wyam.* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index d0f9b509..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,9 +0,0 @@ -nupgk: - image: mono - script: - - "cd ./build/" - - "./build.sh" - artifacts: - paths: - - "./dist/*" - diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..684ad7d4 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..f87f367d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic + address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when +an individual is representing the project or its community in public spaces. +Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting +as an appointed representative at an online or offline event. Representation of +a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at nils@nils-andresen.de. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..88f80042 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,144 @@ +# Contributing to Cake.AsciiDoctorJ + +First and foremost, thank you! We appreciate that you want to contribute to Cake.AsciiDoctorJ, +your time is valuable, and your contributions mean a lot to us. + +## Table of Contents + +- [Important](#important) +- [Getting started](#getting-started) +- [Issues](#issues) + - [Before creating an issue](#before-creating-an-issue) + - [Creating an issue](#creating-an-issue) + - [Closing issues](#closing-issues) +- [Next steps](#next-steps) + +## Important + +By contributing to this project, you: + +- Agree that you have authored 100% of the content +- Agree that you have the necessary rights to the content +- Agree that you have received the necessary permissions from your employer to make the contributions (if applicable) +- Agree that the content you contribute may be provided under the Project license(s) +- Agree that, if you did not author 100% of the content, + the appropriate licenses and copyrights have been added along with any other necessary attribution. + +## Getting started + +**What does "contributing" mean?** +Creating an issue is the simplest form of contributing to a project. +But there are many ways to contribute, including the following: + +- Updating or correcting documentation +- Feature requests +- Bug reports + +If you'd like to learn more about contributing in general, the [Guide to Idiomatic Contributing][idiomatic-contributing] has a lot of useful information. + +**Showing support for Cake.AsciiDoctorJ** +Please keep in mind that open source software is built by people like you, +who spend their free time creating things the rest of the community can use. + +Don't have time to contribute? No worries, here are some other ways to show your support for Cake.AsciiDoctorJ: + +- star the [project][] +- tweet your support for Cake.AsciiDoctorJ +- answer questions on [StackOverflow][] + +## Issues + +Please only create issues for bug reports or feature requests. +Issues discussing any other topics may be closed by the project's maintainers without further explanation. + +Do not create issues about bumping dependencies unless a bug has been identified +and you can demonstrate that it effects this library. + +**Help us to help you** +Remember that we’re here to help, but not to make guesses about what you need help with: + +- Whatever bug or issue you're experiencing, assume that it will not be as obvious to the maintainers as it is to you. +- Spell it out completely. Keep in mind that maintainers need to think about _all potential use cases_ of a library. + It's important that you explain how you're using a library so that maintainers can make that connection + and solve the issue. + +_It can't be understated how frustrating and draining it can be to maintainers to have to ask +clarifying questions on the most basic things, +before it's even possible to start debugging. +Please try to make the best use of everyone's time involved, including yourself, +by providing this information up front._ + +### Before creating an issue + +Please try to determine if the issue is caused by an underlying library, and if so, create the issue there. +Sometimes this is difficult to know. We only ask that you attempt to give a reasonable attempt to find out. +Oftentimes the readme will have advice about where to go to create issues. + +Try to follow these guidelines: + +- **Avoid creating issues for implementation help** - It's much better for discoverability, SEO, and semantics - + to keep the issue tracker focused on bugs and feature requests - + to ask implementation-related questions on [stackoverflow.com][stackoverflow] +- **Investigate the issue** - Search for existing issues (open or closed) that address the issue, and might have even resolved it already. +- **Check the readme** - oftentimes you will find notes about creating issues, + and where to go depending on the type of issue. +- Create the issue in the appropriate repository. + +### Creating an issue + +Please be as descriptive as possible when creating an issue. +Give us the information we need to successfully answer your question or address your issue +by answering the following in your issue: + +- **description**: (required) What is the bug you're experiencing? How are you using this library? +- **OS**: (required) What operating system are you on? +- **version**: (required) please note the version of Cake.AsciiDoctorJ you are using +- **cake version**: (required) please note the version of Cake you are running your build script with +- **error messages**: (required) please paste any error messages into the issue, + or a [gist][] (you may also link to a failing build) +- **addins, etc**: (if applicable) please list any other addins you're using that may affect the Cake.AsciiDoctorJ addin + +### Closing issues + +The original poster or the maintainers of Cake.AsciiDoctorJ may close an issue at any time. +Typically, but not exclusively, issues are closed when: + +- The issue is resolved, and will be released in the next version of Cake.AsciiDoctorJ +- The project's maintainers have determined the issue is out of scope +- An issue is clearly a duplicate of another issue, in which case the duplicate issue will be linked. +- A discussion has clearly run its course + +## Next steps + +**Tips for creating idiomatic issues** +Spending just a little extra time to review best practices and brush up on your contributing skills will, at minimum, +make your issue easier to read, easier to resolve, +and more likely to be found by others who have the same or similar issue in the future. +At best, it will open up doors and potential career opportunities by helping you be at your best. + +The following resources were hand-picked to help you be the most effective contributor you can be: + +- The [Guide to Idiomatic Contributing][idiomatic-contributing] is a great place for newcomers to start, + but there is also information for experienced contributors there. +- Take some time to learn basic markdown. We can't stress this enough. + Don't start pasting code into GitHub issues before you've taken a moment to review this [markdown cheatsheet][md-cheatsheet] +- The GitHub guide to [basic markdown][basic-md] is another great markdown resource. +- Learn about [GitHub Flavored Markdown][gh-flavored-md]. + And if you want to really go above and beyond, + read [mastering markdown][mastering-md]. + +At the very least, please try to: + +- Use backticks to wrap code. + This ensures that it retains its formatting and isn't modified when it's rendered by GitHub, + and makes the code more readable to others +- When applicable, use syntax highlighting by adding the correct language name after the "code fence" + +[basic-md]: https://help.github.com/articles/markdown-basics/ +[gh-flavored-md]: https://help.github.com/articles/github-flavored-markdown/ +[gist]: https://gist.github.com/ +[idiomatic-contributing]: https://github.com/jonschlinkert/idiomatic-contributing +[mastering-md]: https://guides.github.com/features/mastering-markdown/ +[md-cheatsheet]: https://gist.github.com/jonschlinkert/5854601 +[project]: https://github.com/cake-contrib/Cake.AsciiDoctorJ +[stackoverflow]: https://stackoverflow.com/questions/tagged/cakebuild diff --git a/Changelog.md b/Changelog.md index 5da4a3de..b28ae9ea 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,8 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed - moved project into cake-contrb -- modified nuspec to reflect new project-path - created a changelog +- many changes to internal project-structure ## [1.0.0] - 2019-08-13 ### Added diff --git a/GitReleaseManager.yaml b/GitReleaseManager.yaml new file mode 100644 index 00000000..e13cf468 --- /dev/null +++ b/GitReleaseManager.yaml @@ -0,0 +1,34 @@ +create: + include-footer: true + footer-heading: Where to get it + footer-content: > + You can download this release from + [nuget](https://nuget.org/packages/Cake.AsciiDoctorJ/{milestone}), + or you can just reference it in a cake build script + with `#addin nuget:?package=Cake.AsciiDoctorJ&version={milestone}`. + footer-includes-milestone: true + milestone-replace-text: "{milestone}" +export: + include-created-date-in-title: true + created-date-string-format: yyyy-MM-dd + perform-regex-removal: true + regex-text: '[\r\n]*### Where to get it[\r\n]*You can .*`\.[\r\n]*' + multiline-regex: true +issue-labels-include: + - Breaking change + - Bug + - Feature + - Enhancement + - Improvement + - Documentation + - security +issue-labels-exclude: + - Build + - Internal / Refactoring +issue-labels-alias: + - name: Documentation + header: Documentation + plural: Documentation + - name: security + header: Security + plural: Security diff --git a/LICENSE.txt b/LICENSE.txt index a4bc525b..433ff481 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,20 +1,21 @@ -The MIT License (MIT) +MIT License -Copyright (c) Nils Andresen +Copyright (c) 2019 Nils Andresen -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ReadMe.md b/ReadMe.md index bcb19dc0..576a8e7b 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,41 +1,79 @@ # Cake.AsciiDoctorJ -This addin makes [asciidoctorj](https://github.com/asciidoctor/asciidoctorj) available as a tool in [cake](https://cakebuild.net/) +[![standard-readme compliant][]][standard-readme] +[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors) +[![Appveyor build][appveyorimage]][appveyor] +[![Codecov Report][codecovimage]][codecov] +[![NuGet package][nugetimage]][nuget] -[![License](http://img.shields.io/:license-mit-blue.svg)](http://cake-contrib.mit-license.org) +> makes [asciidoctorj](https://github.com/asciidoctor/asciidoctorj) available as a tool in [cake](https://cakebuild.net/) -## Usage +## Table of Contents + +- [Install](#install) +- [Usage](#usage) +- [Maintainer](#maintainer) +- [Contributing](#contributing) + - [Contributors](#contributors) +- [License](#license) -Install asciidoctorj - this addin has no dependency on asciidoctorj. +## Install ```cs -#addin "nuget:?package=Cake.AsciiDoctorJ" +#addin nuget:?package=Cake.AsciiDoctorJ +``` + +## Usage -AsciiDoctorJ(s => s - .WithVerbose() - .WithInputFile(file) - .WithDestinationDir(distDir)); +```cs +#addin nuget:?package=Cake.AsciiDoctorJ + +Task("MyTask").Does(() => { + AsciiDoctorJ(s => s + .WithVerbose() + .WithInputFile(file) + .WithDestinationDir(distDir)); +}); ``` -## Build Status +## Maintainer + +[Nils Andresen @nils-a][maintainer] + +## Contributing + +Cake.AsciiDoctorJ follows the [Contributor Covenant][contrib-covenant] Code of Conduct. -|Develop|Master| -|:--:|:--:| -|[![Build status](https://ci.appveyor.com/api/projects/status/lfnuyv5q5dbc9aoj/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-asciidoctorj/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/lfnuyv5q5dbc9aoj/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-asciidoctorj/branch/master)| +We accept Pull Requests. +Please see [the contributing file][contributing] for how to contribute to Cake.AsciiDoctorJ. -## Code Coverage +Small note: If editing the Readme, please conform to the [standard-readme][] specification. -[![Coverage Status](https://coveralls.io/repos/github/cake-contrib/cake.asciidoctorj/badge.svg?branch=develop)](https://coveralls.io/github/cake-contrib/cake.asciidoctorj?branch=develop) +This project follows the [all-contributors][] specification. Contributions of any kind welcome! -## Packages +### Contributors -| Location | Link | -|:--:|:--:| -|NuGet|![Nuget](https://img.shields.io/nuget/v/cake.asciidoctorj)| +Thanks goes to these wonderful people ([emoji key][emoji-key]): + + + -## Chat Room +## License -Join in the conversation about Cake.AsciiDoctorJ on gitter +[MIT License © Nils Andresen][license] -[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[all-contributors]: https://github.com/all-contributors/all-contributors +[appveyor]: https://ci.appveyor.com/project/cakecontrib/cake-asciidoctorj +[appveyorimage]: https://img.shields.io/appveyor/ci/cakecontrib/cake-asciidoctorj.svg?logo=appveyor&style=flat-square +[codecov]: https://codecov.io/gh/cake-contrib/Cake.AsciiDoctorJ +[codecovimage]: https://img.shields.io/codecov/c/github/cake-contrib/Cake.AsciiDoctorJ.svg?logo=codecov&style=flat-square +[contrib-covenant]: https://www.contributor-covenant.org/version/1/4/code-of-conduct +[contributing]: CONTRIBUTING.md +[emoji-key]: https://allcontributors.org/docs/en/emoji-key +[maintainer]: https://github.com/nils-a +[nuget]: https://nuget.org/packages/Cake.AsciiDoctorJ +[nugetimage]: https://img.shields.io/nuget/v/Cake.AsciiDoctorJ.svg?logo=nuget&style=flat-square +[license]: LICENSE.txt +[standard-readme]: https://github.com/RichardLitt/standard-readme +[standard-readme compliant]: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square diff --git a/build/build.ps1 b/build.ps1 similarity index 67% rename from build/build.ps1 rename to build.ps1 index 991f1b19..c56584b6 100644 --- a/build/build.ps1 +++ b/build.ps1 @@ -25,10 +25,6 @@ Specifies the amount of information to be displayed. Shows description about tasks. .PARAMETER DryRun Performs a dry run. -.PARAMETER Experimental -Uses the nightly builds of the Roslyn script engine. -.PARAMETER Mono -Uses the Mono Compiler rather than the Roslyn script engine. .PARAMETER SkipToolPackageRestore Skips restoring of packages. .PARAMETER ScriptArgs @@ -41,7 +37,7 @@ https://cakebuild.net [CmdletBinding()] Param( - [string]$Script = "build.cake", + [string]$Script = "recipe.cake", [string]$Target, [string]$Configuration, [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] @@ -49,50 +45,60 @@ Param( [switch]$ShowDescription, [Alias("WhatIf", "Noop")] [switch]$DryRun, - [switch]$Experimental, - [switch]$Mono, [switch]$SkipToolPackageRestore, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [Parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)] [string[]]$ScriptArgs ) +# Attempt to set highest encryption available for SecurityProtocol. +# PowerShell will not set this by default (until maybe .NET 4.6.x). This +# will typically produce a message for PowerShell v2 (just an info +# message though) +try { + # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48) + # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't + # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is + # installed (.NET 4.5 is an in-place upgrade). + # PowerShell Core already has support for TLS 1.2 so we can skip this if running in that. + if (-not $IsCoreCLR) { + [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48 + } +} +catch { + Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3' +} + [Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null -function MD5HashFile([string] $filePath) -{ - if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) - { +function MD5HashFile([string] $filePath) { + if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) { return $null } [System.IO.Stream] $file = $null; [System.Security.Cryptography.MD5] $md5 = $null; - try - { + try { $md5 = [System.Security.Cryptography.MD5]::Create() $file = [System.IO.File]::OpenRead($filePath) return [System.BitConverter]::ToString($md5.ComputeHash($file)) } - finally - { - if ($file -ne $null) - { + finally { + if ($null -ne $file) { $file.Dispose() } } } -function GetProxyEnabledWebClient -{ +function GetProxyEnabledWebClient { $wc = New-Object System.Net.WebClient $proxy = [System.Net.WebRequest]::GetSystemWebProxy() - $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials $wc.Proxy = $proxy return $wc } Write-Host "Preparing to run build script..." -if(!$PSScriptRoot){ +if (!$PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } @@ -110,15 +116,17 @@ $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" # Make sure tools folder exists if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { Write-Verbose -Message "Creating tools directory..." - New-Item -Path $TOOLS_DIR -Type directory | out-null + New-Item -Path $TOOLS_DIR -Type Directory | Out-Null } # Make sure that packages.config exist. if (!(Test-Path $PACKAGES_CONFIG)) { - Write-Verbose -Message "Downloading packages.config..." - try { + Write-Verbose -Message "Downloading packages.config..." + try { $wc = GetProxyEnabledWebClient - $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { + $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) + } + catch { Throw "Could not download packages.config." } } @@ -127,8 +135,8 @@ if (!(Test-Path $PACKAGES_CONFIG)) { if (!(Test-Path $NUGET_EXE)) { Write-Verbose -Message "Trying to find nuget.exe in PATH..." $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } - $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 - if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { + $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select-Object -First 1 + if ($null -ne $NUGET_EXE_IN_PATH -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName } @@ -140,38 +148,46 @@ if (!(Test-Path $NUGET_EXE)) { try { $wc = GetProxyEnabledWebClient $wc.DownloadFile($NUGET_URL, $NUGET_EXE) - } catch { + } + catch { Throw "Could not download NuGet.exe." } } # Save nuget.exe path to environment to be available to child processed -$ENV:NUGET_EXE = $NUGET_EXE +$env:NUGET_EXE = $NUGET_EXE +$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { + "mono `"$NUGET_EXE`"" +} +else { + "`"$NUGET_EXE`"" +} # Restore tools from NuGet? -if(-Not $SkipToolPackageRestore.IsPresent) { +if (-Not $SkipToolPackageRestore.IsPresent) { Push-Location Set-Location $TOOLS_DIR # Check for changes in packages.config and remove installed tools if true. - [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) - if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or - ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + [string] $md5Hash = MD5HashFile $PACKAGES_CONFIG + if ((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { Write-Verbose -Message "Missing or changed package.config hash..." - Remove-Item * -Recurse -Exclude packages.config,nuget.exe + Get-ChildItem -Exclude packages.config, nuget.exe, Cake.Bakery | + Remove-Item -Recurse } Write-Verbose -Message "Restoring tools from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" + + $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" if ($LASTEXITCODE -ne 0) { Throw "An error occurred while restoring NuGet tools." } - else - { + else { $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" } - Write-Verbose -Message ($NuGetOutput | out-string) + Write-Verbose -Message ($NuGetOutput | Out-String) Pop-Location } @@ -182,13 +198,13 @@ if (Test-Path $ADDINS_PACKAGES_CONFIG) { Set-Location $ADDINS_DIR Write-Verbose -Message "Restoring addins from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" + $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" if ($LASTEXITCODE -ne 0) { Throw "An error occurred while restoring NuGet addins." } - Write-Verbose -Message ($NuGetOutput | out-string) + Write-Verbose -Message ($NuGetOutput | Out-String) Pop-Location } @@ -199,13 +215,13 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) { Set-Location $MODULES_DIR Write-Verbose -Message "Restoring modules from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" + $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" if ($LASTEXITCODE -ne 0) { Throw "An error occurred while restoring NuGet modules." } - Write-Verbose -Message ($NuGetOutput | out-string) + Write-Verbose -Message ($NuGetOutput | Out-String) Pop-Location } @@ -215,6 +231,12 @@ if (!(Test-Path $CAKE_EXE)) { Throw "Could not find Cake.exe at $CAKE_EXE" } +$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { + "mono `"$CAKE_EXE`"" +} +else { + "`"$CAKE_EXE`"" +} # Build Cake arguments @@ -224,16 +246,9 @@ if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } if ($ShowDescription) { $cakeArguments += "-showdescription" } if ($DryRun) { $cakeArguments += "-dryrun" } -if ($Experimental) { $cakeArguments += "-experimental" } -if ($Mono) { $cakeArguments += "-mono" } $cakeArguments += $ScriptArgs # Start Cake -Push-Location -Set-Location $PSScriptRoot Write-Host "Running build script..." -&$CAKE_EXE $cakeArguments -Pop-Location - - +Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")" exit $LASTEXITCODE diff --git a/build/build.sh b/build.sh old mode 100755 new mode 100644 similarity index 57% rename from build/build.sh rename to build.sh index 27193217..1f3df0d9 --- a/build/build.sh +++ b/build.sh @@ -7,12 +7,16 @@ ########################################################################## # Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) TOOLS_DIR=$SCRIPT_DIR/tools +ADDINS_DIR=$TOOLS_DIR/Addins +MODULES_DIR=$TOOLS_DIR/Modules NUGET_EXE=$TOOLS_DIR/nuget.exe CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe PACKAGES_CONFIG=$TOOLS_DIR/packages.config PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum +ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config +MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config # Define md5sum or md5 depending on Linux/OSX MD5_EXE= @@ -23,32 +27,29 @@ else fi # Define default arguments. -SCRIPT=$SCRIPT_DIR/"build.cake" -TARGET="Default" -CONFIGURATION="Release" -VERBOSITY="verbose" -DRYRUN= -SHOW_VERSION=false -SCRIPT_ARGUMENTS=() +SCRIPT="recipe.cake" +CAKE_ARGUMENTS=() # Parse arguments. for i in "$@"; do case $1 in - -s|--script) SCRIPT="$2"; shift ;; - -t|--target) TARGET="$2"; shift ;; - -c|--configuration) CONFIGURATION="$2"; shift ;; - -v|--verbosity) VERBOSITY="$2"; shift ;; - -d|--dryrun) DRYRUN="-dryrun" ;; - --version) SHOW_VERSION=true ;; - --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; - *) SCRIPT_ARGUMENTS+=("$1") ;; + -s | --script) + SCRIPT="$2" + shift + ;; + --) + shift + CAKE_ARGUMENTS+=("$@") + break + ;; + *) CAKE_ARGUMENTS+=("$1") ;; esac shift done # Make sure the tools folder exist. if [ ! -d "$TOOLS_DIR" ]; then - mkdir "$TOOLS_DIR" + mkdir "$TOOLS_DIR" fi # Make sure that packages.config exist. @@ -73,20 +74,46 @@ fi # Restore tools from NuGet. pushd "$TOOLS_DIR" >/dev/null -if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then - find . -type d ! -name . | xargs rm -rf +if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$(cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//')" != "$($MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }')" ]; then + find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf fi mono "$NUGET_EXE" install -ExcludeVersion if [ $? -ne 0 ]; then - echo "Could not restore NuGet packages." + echo "Could not restore NuGet tools." exit 1 fi -$MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5 +$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >|"$PACKAGES_CONFIG_MD5" popd >/dev/null +# Restore addins from NuGet. +if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then + pushd "$ADDINS_DIR" >/dev/null + + mono "$NUGET_EXE" install -ExcludeVersion + if [ $? -ne 0 ]; then + echo "Could not restore NuGet addins." + exit 1 + fi + + popd >/dev/null +fi + +# Restore modules from NuGet. +if [ -f "$MODULES_PACKAGES_CONFIG" ]; then + pushd "$MODULES_DIR" >/dev/null + + mono "$NUGET_EXE" install -ExcludeVersion + if [ $? -ne 0 ]; then + echo "Could not restore NuGet modules." + exit 1 + fi + + popd >/dev/null +fi + # Make sure that Cake has been installed. if [ ! -f "$CAKE_EXE" ]; then echo "Could not find Cake.exe at '$CAKE_EXE'." @@ -94,8 +121,4 @@ if [ ! -f "$CAKE_EXE" ]; then fi # Start Cake -if $SHOW_VERSION; then - exec mono "$CAKE_EXE" -version -else - exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" -fi \ No newline at end of file +exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}" diff --git a/build/build.cake b/build/build.cake deleted file mode 100644 index fb2094fc..00000000 --- a/build/build.cake +++ /dev/null @@ -1,108 +0,0 @@ -#tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0" -#tool "nuget:?package=OpenCover&version=4.7.922" -#tool "nuget:?package=coveralls.io&version=1.4.2" -#addin "nuget:?package=Cake.Coveralls&version=0.10.0" - -////////////////////////////////////////////////////////////////////// -// ARGUMENTS -////////////////////////////////////////////////////////////////////// - -var target = Argument("target", "Default"); -var configuration = Argument("configuration", "Release"); - -////////////////////////////////////////////////////////////////////// -// PREPARATION -////////////////////////////////////////////////////////////////////// - -// Define directories. -var rootDir = Directory("./../"); -var srcDir = rootDir + Directory ("src"); -var binDir = rootDir + Directory("bin"); -var distDir = rootDir + Directory("dist"); - -////////////////////////////////////////////////////////////////////// -// TASKS -////////////////////////////////////////////////////////////////////// - -Task("Clean") - .Does(() => -{ - CleanDirectory(binDir); - CleanDirectory(distDir); -}); - -Task("Build") - .Does(() => -{ - var file = srcDir + File("Cake.AsciiDoctorJ.sln"); - NuGetRestore(file); - MSBuild(file, settings => settings - .SetVerbosity(Verbosity.Minimal) - .SetConfiguration(configuration) - .WithTarget("Build") - ); - - // test & coverage - Information("Test and coverage..."); - var testAssemblies = GetFiles(srcDir + File($"**/bin/{configuration}/*.Tests.dll")); - var testOutput = binDir + File("TestResult.xml"); - var coverOutput = binDir + File("CoverageResult.xml"); - OpenCover(c => - { - c.NUnit3(testAssemblies, new NUnit3Settings - { - Work = binDir, - OutputFile = testOutput - }); - }, - coverOutput, - new OpenCoverSettings() - .WithFilter("+[Cake.AsciiDoctorJ]*") - .WithFilter("-[Cake.AsciiDoctorJ.Tests]*") - ); - - // on AppVeyor, publish testsettings.. - if(EnvironmentVariable("APPVEYOR_JOB_ID") != null) - { - Information("Running on AppVeyor. Publishing Test-Result."); - BuildSystem.AppVeyor.UploadTestResults(testOutput, AppVeyorTestResultsType.NUnit3); - - var repoToken = EnvironmentVariable("COVERALLS_REPO_TOKEN"); - if(repoToken == null) - { - Warning("We're running on AppVeyor but there is no COVERALLS_REPO_TOKEN"); - } - else - { - Information("Publishing Coverage-Result to coveralls.io"); - CoverallsIo(coverOutput, new CoverallsIoSettings() - { - RepoToken = repoToken - }); - } - } -}); - -Task("Dist") - .IsDependentOn("Build") - .Does(() => -{ - NuGetPack(srcDir + File("Cake.AsciiDoctorJ.nuspec"), new NuGetPackSettings { - BasePath = binDir.ToString(), - OutputDirectory = distDir.ToString() - }); -}); - -////////////////////////////////////////////////////////////////////// -// TASK TARGETS -////////////////////////////////////////////////////////////////////// - -Task("Default") - .IsDependentOn("Clean") - .IsDependentOn("Dist"); - -////////////////////////////////////////////////////////////////////// -// EXECUTION -////////////////////////////////////////////////////////////////////// - -RunTarget(target); \ No newline at end of file diff --git a/build/nuget.config b/build/nuget.config deleted file mode 100644 index 0e1f0ac9..00000000 --- a/build/nuget.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/recipe.cake b/recipe.cake new file mode 100644 index 00000000..38a18460 --- /dev/null +++ b/recipe.cake @@ -0,0 +1,23 @@ +#load nuget:?package=Cake.Recipe&version=1.0.0 + +Environment.SetVariableNames(); + +BuildParameters.SetParameters( + context: Context, + buildSystem: BuildSystem, + sourceDirectoryPath: "./src", + title: "Cake.AsciiDoctorJ", + repositoryOwner: "cake-contrib", + repositoryName: "Cake.AsciiDoctorJ", + appVeyorAccountName: "cakecontrib", + shouldRunGitVersion: true, + shouldExecuteGitLink: false, + shouldRunCodecov: true, + shouldDeployGraphDocumentation: false, + shouldRunDotNetCorePack: true); + +BuildParameters.PrintParameters(Context); + +ToolSettings.SetToolSettings(context: Context); + +Build.RunDotNetCore(); diff --git a/res/GlobalAssemblyInfo.cs b/res/GlobalAssemblyInfo.cs deleted file mode 100644 index 91ef2838..00000000 --- a/res/GlobalAssemblyInfo.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyDescription("Cake.AsciiDoctorJ")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Cake.AsciiDoctorJ")] -[assembly: AssemblyCopyright("Copyright © Nils Andresen 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJAliasesFixture.cs b/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJAliasesFixture.cs new file mode 100644 index 00000000..4f3ec72e --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJAliasesFixture.cs @@ -0,0 +1,44 @@ +namespace Cake.AsciiDoctorJ.Tests +{ + using System.Collections.Generic; + using System.Linq; + using Cake.Core; + using Cake.Core.IO; + using Cake.Testing; + using Cake.Testing.Fixtures; + using Moq; + + public class AsciiDoctorJAliasesFixture : AsciiDoctorJRunnerFixture + { + internal ICakeContext _context; + + public AsciiDoctorJAliasesFixture() + { + var argumentsMoq = new Mock(); + var registryMoq = new Mock(); + var dataService = new Mock(); + _context = new CakeContext( + FileSystem, + Environment, + Globber, + new FakeLog(), + argumentsMoq.Object, + ProcessRunner, + registryMoq.Object, + Tools,dataService.Object, + Configuration); + } + + protected override void RunTool() + { + if (Settings == null) + { + AsciiDoctorJAliases.AsciiDoctorJ(_context); + } + else + { + AsciiDoctorJAliases.AsciiDoctorJ(_context, Settings); + } + } + } +} diff --git a/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJAliasesTests.cs b/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJAliasesTests.cs new file mode 100644 index 00000000..bb5cbb4a --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJAliasesTests.cs @@ -0,0 +1,28 @@ +using System; +using Cake.Core; +using FluentAssertions; +using Moq; +using NUnit.Framework; + +namespace Cake.AsciiDoctorJ.Tests +{ + [TestFixture] + [TestOf(typeof(AsciiDoctorJAliases))] + public class AsciiDoctorJAliasesTests + { + private ICakeContext context; + + [SetUp] + public void Setup() + { + context = new Mock().Object; // TODO: Is there nothin in Cake.Testing?! + } + + [Test] + public void Should_Throw_If_Settings_Are_Null() + { + Action action = () => AsciiDoctorJAliases.AsciiDoctorJ(context, (AsciiDoctorJRunnerSettings)null); + action.Should().Throw().WithMessage("*settings"); + } + } +} diff --git a/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJRunnerFixture.cs b/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJRunnerFixture.cs new file mode 100644 index 00000000..5eb9c156 --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJRunnerFixture.cs @@ -0,0 +1,18 @@ +namespace Cake.AsciiDoctorJ.Tests +{ + using Cake.Testing.Fixtures; + + public class AsciiDoctorJRunnerFixture : ToolFixture + { + public AsciiDoctorJRunnerFixture() + : base("AsciiDoctorJ.exe") + { + } + + protected override void RunTool() + { + var tool = new AsciiDoctorJRunner(FileSystem, Environment, ProcessRunner, Tools); + tool.Run(Settings); + } + } +} diff --git a/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJRunnerTests.cs b/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJRunnerTests.cs new file mode 100644 index 00000000..c68d9c49 --- /dev/null +++ b/src/Cake.AsciiDoctorJ.Tests/AsciiDoctorJRunnerTests.cs @@ -0,0 +1,24 @@ +namespace Cake.AsciiDoctorJ.Tests +{ + using System; + using Cake.Core; + using Cake.Testing; + using FluentAssertions; + using NUnit.Framework; + + [TestFixture] + [TestOf(typeof(AsciiDoctorJRunner))] + public class AsciiDoctorJRunnerTests + { + [Test] + public void Should_Throw_If_AsciiDoctorJ_Executable_Was_Not_Found() + { + var fixture = new AsciiDoctorJRunnerFixture(); + fixture.GivenDefaultToolDoNotExist(); + const string expectedMessage = "Could not locate executable"; + + Action result = () => fixture.Run(); + result.Should().Throw().Where(ex => ex.Message.Contains(expectedMessage)); + } + } +} diff --git a/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj b/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj index b34e65f3..e10b741e 100644 --- a/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj +++ b/src/Cake.AsciiDoctorJ.Tests/Cake.AsciiDoctorJ.Tests.csproj @@ -1,110 +1,22 @@ - - - - - - - Debug - AnyCPU - {76882FBF-6DA4-4221-AC2E-8D5CB28F104D} - Library - Properties - Cake.AsciiDoctorJ.Tests - Cake.AsciiDoctorJ.Tests - v4.6 - 512 - true - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\lib\packages\AutoFixture.4.11.0\lib\net452\AutoFixture.dll - - - ..\..\lib\packages\AutoFixture.AutoNSubstitute.4.11.0\lib\net452\AutoFixture.AutoNSubstitute.dll - - - ..\..\lib\packages\Cake.Core.0.34.1\lib\net46\Cake.Core.dll - - - ..\..\lib\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\..\lib\packages\Fare.2.1.2\lib\net35\Fare.dll - - - ..\..\lib\packages\FluentAssertions.5.8.0\lib\net45\FluentAssertions.dll - - - ..\..\lib\packages\NSubstitute.4.2.1\lib\net46\NSubstitute.dll - - - ..\..\lib\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll - - - - - - - ..\..\lib\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\..\lib\packages\System.Threading.Tasks.Extensions.4.5.3\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll - - - ..\..\lib\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll - - - - - - - - - - - Properties\GlobalAssemblyInfo.cs - - - - - - - - - {5b65b4ed-0902-48a4-8ff6-c3e6d0954bc6} - Cake.AsciiDoctorJ - - - - - - - - + + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + netcoreapp2.0 + $(TargetFrameworks);net461 + + false - - - - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/src/Cake.AsciiDoctorJ.Tests/Properties/AssemblyInfo.cs b/src/Cake.AsciiDoctorJ.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 120c7667..00000000 --- a/src/Cake.AsciiDoctorJ.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Cake.AsciiDoctorJ.Tests")] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("76882fbf-6da4-4221-ac2e-8d5cb28f104d")] \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs b/src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs index f3597d5a..d935913c 100644 --- a/src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs +++ b/src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs @@ -1,18 +1,23 @@ -using Cake.Core; +using Cake.Core; using Cake.Core.IO; using NUnit.Framework; -using AutoFixture; using FluentAssertions; +using Cake.Testing; namespace Cake.AsciiDoctorJ.Tests { [TestFixture] - public class SettingsExtensionsTests : TestBase + [TestOf(typeof(AsciiDoctorJRunnerSettingsExtensions))] + public class SettingsExtensionsTests { + // TODO: It would be better (i.e. more isolated) to test whether the extensions use the settings "correctly"... + + private ICakeEnvironment environment; + [SetUp] public void Setup() { - SetupFixture(); + environment = FakeEnvironment.CreateWindowsEnvironment(); } [TestCase("WithVersion", "--version")] @@ -23,7 +28,7 @@ public void Setup() [TestCase("WithQuiet", "--quiet")] [TestCase("WithSuppressHeaderAndFooter", "--no-header-footer")] [TestCase("WithCompact", "--compact")] - public void SimpleBoolProperties(string extensionName, string expectedParam) + public void Should_Convert_All_Flags_To_Arguments(string extensionName, string expectedParam) { var args = new ProcessArgumentBuilder(); var sut = new AsciiDoctorJRunnerSettings(); @@ -32,7 +37,7 @@ public void SimpleBoolProperties(string extensionName, string expectedParam) System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); ext.Invoke(null, new object[] { sut }); - sut.Evaluate(args, Fixture.Create()); + sut.Evaluate(args, environment); var actual = args.Render(); actual.Should().Contain(expectedParam); @@ -42,12 +47,12 @@ public void SimpleBoolProperties(string extensionName, string expectedParam) [TestCase(SafeMode.Unsafe, "--safe-mode unsafe")] [TestCase(SafeMode.Secure, "--safe-mode secure")] [TestCase(SafeMode.Server, "--safe-mode server")] - public void SafeModeValues(SafeMode mode, string expected) + public void Should_Convert_SafeMode_Settings_To_Arguments(SafeMode mode, string expected) { var args = new ProcessArgumentBuilder(); var sut = new AsciiDoctorJRunnerSettings().WithSafeMode(mode); - sut.Evaluate(args, Fixture.Create()); + sut.Evaluate(args, environment); var actual = args.Render(); actual.Should().Contain(expected); @@ -55,12 +60,12 @@ public void SafeModeValues(SafeMode mode, string expected) [TestCase(ERuby.Erb, "--eruby erb")] [TestCase(ERuby.Erubis, "--eruby erubis")] - public void ERubyValues(ERuby eruby, string expected) + public void Should_Convert_Eruby_Settings_To_Arguments(ERuby eruby, string expected) { var args = new ProcessArgumentBuilder(); var sut = new AsciiDoctorJRunnerSettings().WithERuby(eruby); - sut.Evaluate(args, Fixture.Create()); + sut.Evaluate(args, environment); var actual = args.Render(); actual.Should().Contain(expected); @@ -69,15 +74,15 @@ public void ERubyValues(ERuby eruby, string expected) [TestCase(DocType.Article, "--doctype article")] [TestCase(DocType.Book, "--doctype book")] [TestCase(DocType.Inline, "--doctype inline")] - public void DocTypeValues(DocType type, string expected) + public void Should_Convert_DocType_Settings_To_Arguments(DocType type, string expected) { var args = new ProcessArgumentBuilder(); var sut = new AsciiDoctorJRunnerSettings().WithDocType(type); - sut.Evaluate(args, Fixture.Create()); + sut.Evaluate(args, environment); var actual = args.Render(); actual.Should().Contain(expected); } } -} \ No newline at end of file +} diff --git a/src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs b/src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs index 01805e49..92933e7d 100644 --- a/src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs +++ b/src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs @@ -1,18 +1,21 @@ -using Cake.Core; +using Cake.Core; using Cake.Core.IO; using NUnit.Framework; -using AutoFixture; using FluentAssertions; +using Cake.Testing; namespace Cake.AsciiDoctorJ.Tests { [TestFixture] - public class SettingsTests : TestBase + [TestOf(typeof(AsciiDoctorJRunnerSettings))] + public class SettingsTests { + private ICakeEnvironment environment; + [SetUp] public void Setup() { - SetupFixture(); + environment = FakeEnvironment.CreateWindowsEnvironment(); } [TestCase("Version", "--version")] @@ -23,7 +26,7 @@ public void Setup() [TestCase("Quiet", "--quiet")] [TestCase("SuppressHeaderAndFooter", "--no-header-footer")] [TestCase("Compact", "--compact")] - public void SimpleBoolProperties(string propertyName, string expectedParam) + public void Should_Convert_All_Flags_To_Arguments(string propertyName, string expectedParam) { var args = new ProcessArgumentBuilder(); var sut = new AsciiDoctorJRunnerSettings(); @@ -31,7 +34,7 @@ public void SimpleBoolProperties(string propertyName, string expectedParam) var prop = typeof(AsciiDoctorJRunnerSettings).GetProperty(propertyName); prop.SetValue(sut, true); - sut.Evaluate(args, Fixture.Create()); + sut.Evaluate(args, environment); var actual = args.Render(); actual.Should().Contain(expectedParam); @@ -41,7 +44,7 @@ public void SimpleBoolProperties(string propertyName, string expectedParam) [TestCase(SafeMode.Unsafe, "--safe-mode unsafe")] [TestCase(SafeMode.Secure, "--safe-mode secure")] [TestCase(SafeMode.Server, "--safe-mode server")] - public void SafeModeValues(SafeMode mode, string expected) + public void Should_Convert_SafeMode_Settings_To_Arguments(SafeMode mode, string expected) { var args = new ProcessArgumentBuilder(); var sut = new AsciiDoctorJRunnerSettings @@ -49,7 +52,7 @@ public void SafeModeValues(SafeMode mode, string expected) SafeMode = mode }; - sut.Evaluate(args, Fixture.Create()); + sut.Evaluate(args, environment); var actual = args.Render(); actual.Should().Contain(expected); @@ -57,7 +60,7 @@ public void SafeModeValues(SafeMode mode, string expected) [TestCase(ERuby.Erb, "--eruby erb")] [TestCase(ERuby.Erubis, "--eruby erubis")] - public void ERubyValues(ERuby eruby, string expected) + public void Should_Convert_Eruby_Settings_To_Arguments(ERuby eruby, string expected) { var args = new ProcessArgumentBuilder(); var sut = new AsciiDoctorJRunnerSettings @@ -65,7 +68,7 @@ public void ERubyValues(ERuby eruby, string expected) ERuby = eruby }; - sut.Evaluate(args, Fixture.Create()); + sut.Evaluate(args, environment); var actual = args.Render(); actual.Should().Contain(expected); @@ -74,7 +77,7 @@ public void ERubyValues(ERuby eruby, string expected) [TestCase(DocType.Article, "--doctype article")] [TestCase(DocType.Book, "--doctype book")] [TestCase(DocType.Inline, "--doctype inline")] - public void DocTypeValues(DocType type, string expected) + public void Should_Convert_DocType_Settings_To_Arguments(DocType type, string expected) { var args = new ProcessArgumentBuilder(); var sut = new AsciiDoctorJRunnerSettings @@ -82,10 +85,10 @@ public void DocTypeValues(DocType type, string expected) DocType = type }; - sut.Evaluate(args, Fixture.Create()); + sut.Evaluate(args, environment); var actual = args.Render(); actual.Should().Contain(expected); } } -} \ No newline at end of file +} diff --git a/src/Cake.AsciiDoctorJ.Tests/TestBase.cs b/src/Cake.AsciiDoctorJ.Tests/TestBase.cs deleted file mode 100644 index d206d2ab..00000000 --- a/src/Cake.AsciiDoctorJ.Tests/TestBase.cs +++ /dev/null @@ -1,17 +0,0 @@ -using AutoFixture; -using AutoFixture.AutoNSubstitute; -using System; - -namespace Cake.AsciiDoctorJ.Tests -{ - public abstract class TestBase - { - protected IFixture Fixture; - - protected void SetupFixture(Action modifications = null) - { - Fixture = new Fixture().Customize(new AutoNSubstituteCustomization()); - modifications?.Invoke(Fixture); - } - } -} \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/app.config b/src/Cake.AsciiDoctorJ.Tests/app.config deleted file mode 100644 index f434d45d..00000000 --- a/src/Cake.AsciiDoctorJ.Tests/app.config +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.Tests/packages.config b/src/Cake.AsciiDoctorJ.Tests/packages.config deleted file mode 100644 index f55176b8..00000000 --- a/src/Cake.AsciiDoctorJ.Tests/packages.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.nuspec b/src/Cake.AsciiDoctorJ.nuspec deleted file mode 100644 index d4bc54c7..00000000 --- a/src/Cake.AsciiDoctorJ.nuspec +++ /dev/null @@ -1,21 +0,0 @@ - - - - Cake.AsciiDoctorJ - 1.0.1 - Cake.AsciiDoctorJ - Nils Andresen - Nils Andresen - MIT - https://github.com/cake-contrib/cake.asciidoctorj - https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png - false - Adds AsciiDoctorJ alias for Cake - An alias to run AcsiiDoctorJ as part of a build - Cake Script Build asciidoc - - - - - - \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ.sln b/src/Cake.AsciiDoctorJ.sln index e5a35b25..1391ee91 100644 --- a/src/Cake.AsciiDoctorJ.sln +++ b/src/Cake.AsciiDoctorJ.sln @@ -1,31 +1,27 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29102.190 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.AsciiDoctorJ", "Cake.AsciiDoctorJ\Cake.AsciiDoctorJ.csproj", "{5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}" +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.AsciiDoctorJ", "Cake.AsciiDoctorJ\Cake.AsciiDoctorJ.csproj", "{9C63DC31-720C-4593-A5B7-142B117A88A0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.AsciiDoctorJ.Tests", "Cake.AsciiDoctorJ.Tests\Cake.AsciiDoctorJ.Tests.csproj", "{76882FBF-6DA4-4221-AC2E-8D5CB28F104D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.AsciiDoctorJ.Tests", "Cake.AsciiDoctorJ.Tests\Cake.AsciiDoctorJ.Tests.csproj", "{21300EC0-81FE-4956-A067-5A085F1535B1}" EndProject Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6}.Release|Any CPU.Build.0 = Release|Any CPU - {76882FBF-6DA4-4221-AC2E-8D5CB28F104D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {76882FBF-6DA4-4221-AC2E-8D5CB28F104D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {76882FBF-6DA4-4221-AC2E-8D5CB28F104D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {76882FBF-6DA4-4221-AC2E-8D5CB28F104D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E5328D05-8D19-4D0D-B440-17BA1A2DD9DD} + {9C63DC31-720C-4593-A5B7-142B117A88A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C63DC31-720C-4593-A5B7-142B117A88A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C63DC31-720C-4593-A5B7-142B117A88A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C63DC31-720C-4593-A5B7-142B117A88A0}.Release|Any CPU.Build.0 = Release|Any CPU + {21300EC0-81FE-4956-A067-5A085F1535B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21300EC0-81FE-4956-A067-5A085F1535B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21300EC0-81FE-4956-A067-5A085F1535B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21300EC0-81FE-4956-A067-5A085F1535B1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/Cake.AsciiDoctorJ/AsciiDoctorJAliases.cs b/src/Cake.AsciiDoctorJ/AsciiDoctorJAliases.cs index 22c8ee90..bf757a80 100644 --- a/src/Cake.AsciiDoctorJ/AsciiDoctorJAliases.cs +++ b/src/Cake.AsciiDoctorJ/AsciiDoctorJAliases.cs @@ -1,4 +1,4 @@ -using Cake.Core; +using Cake.Core; using Cake.Core.Annotations; using System; @@ -34,7 +34,7 @@ public static class AsciiDoctorJAliases [CakeMethodAlias] public static IAsciiDoctorJRunner AsciiDoctorJ( this ICakeContext context, - Action configure) + Action configure = null) { if (context == null) { @@ -44,5 +44,47 @@ public static IAsciiDoctorJRunner AsciiDoctorJ( var runner = new AsciiDoctorJRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); return runner.Run(configure); } + + /// + /// Runs AsciiDoctorJ + /// + /// + /// + /// + /// /// + /// + /// + /// { + /// AsciiDoctorJ(new AsciiDoctorJRunnerSettings { + /// Verbose = true, + /// DocType = DocType.Article, + /// Backend = "pdf", + /// InputFiles = new[]{ file }, + /// DestinationDir = distDir + /// }); + /// }); + /// ]]> + /// + /// + [CakeMethodAlias] + public static IAsciiDoctorJRunner AsciiDoctorJ( + this ICakeContext context, + AsciiDoctorJRunnerSettings settings) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (settings == null) + { + throw new ArgumentNullException(nameof(settings)); + } + + var runner = new AsciiDoctorJRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); + return runner.Run(settings); + } } -} \ No newline at end of file +} diff --git a/src/Cake.AsciiDoctorJ/AsciiDoctorJRunner.cs b/src/Cake.AsciiDoctorJ/AsciiDoctorJRunner.cs index b0650d47..cbd26af3 100644 --- a/src/Cake.AsciiDoctorJ/AsciiDoctorJRunner.cs +++ b/src/Cake.AsciiDoctorJ/AsciiDoctorJRunner.cs @@ -1,8 +1,11 @@ -using Cake.Core; -using Cake.Core.IO; -using Cake.Core.Tooling; using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; +using Cake.Core; +using Cake.Core.IO; +using Cake.Core.Tooling; + +[assembly: InternalsVisibleTo("Cake.AsciiDoctorJ.Tests")] namespace Cake.AsciiDoctorJ { @@ -45,7 +48,7 @@ internal AsciiDoctorJRunner Run(Action configure = n return Run(settings); } - protected AsciiDoctorJRunner Run(AsciiDoctorJRunnerSettings settings) + internal AsciiDoctorJRunner Run(AsciiDoctorJRunnerSettings settings) { var args = new ProcessArgumentBuilder(); settings?.Evaluate(args, environment); @@ -53,4 +56,4 @@ protected AsciiDoctorJRunner Run(AsciiDoctorJRunnerSettings settings) return this; } } -} \ No newline at end of file +} diff --git a/src/Cake.AsciiDoctorJ/Cake.AsciiDoctorJ.csproj b/src/Cake.AsciiDoctorJ/Cake.AsciiDoctorJ.csproj index cef41ca9..d2bb5b99 100644 --- a/src/Cake.AsciiDoctorJ/Cake.AsciiDoctorJ.csproj +++ b/src/Cake.AsciiDoctorJ/Cake.AsciiDoctorJ.csproj @@ -1,70 +1,34 @@ - - - - - Debug - AnyCPU - {5B65B4ED-0902-48A4-8FF6-C3E6D0954BC6} - Library - Properties - Cake.AsciiDoctorJ - Cake.AsciiDoctorJ - v4.6 - 512 - true - - - - true - full - false - ..\..\bin\ - DEBUG;TRACE - prompt - 4 - false - ..\..\bin\Cake.AsciiDoctorJ.xml - - - pdbonly - true - ..\..\bin\ - TRACE - prompt - 4 - false - ..\..\bin\Cake.AsciiDoctorJ.xml - - - - ..\..\lib\packages\Cake.Core.0.34.1\lib\net46\Cake.Core.dll - - - - - - - - - - - - - Properties\GlobalAssemblyInfo.cs - - - - - - - - - - - - - - - - - \ No newline at end of file + + + netstandard2.0;net461 + true + true + snupkg + + + + 2019 + $([System.DateTime]::Today.Year) + $(StartYear) + $(StartYear)-$(EndYear) + + + Nils Andresen + Copyright © $(FullYear) — Nils Andresen + makes [asciidoctorj](https://github.com/asciidoctor/asciidoctorj) available as a tool in [cake](https://cakebuild.net/) + https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png + MIT + https://cake-contrib.github.io/Cake.AsciiDoctorJ + cake;addin;asciidoctorj + https://github.com/cake-contrib/Cake.AsciiDoctorJ.git + https://github.com/cake-contrib/Cake.AsciiDoctorJ/releases/tag/$(Version) + + + + + + runtime; build; native; contentfiles; analyzers + all + + + diff --git a/src/Cake.AsciiDoctorJ/Properties/AssemblyInfo.cs b/src/Cake.AsciiDoctorJ/Properties/AssemblyInfo.cs deleted file mode 100644 index 553a8d90..00000000 --- a/src/Cake.AsciiDoctorJ/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Cake.AsciiDoctorJ")] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5b65b4ed-0902-48a4-8ff6-c3e6d0954bc6")] -[assembly: InternalsVisibleTo("Cake.AsciiDoctorJ.Tests")] \ No newline at end of file diff --git a/src/Cake.AsciiDoctorJ/packages.config b/src/Cake.AsciiDoctorJ/packages.config deleted file mode 100644 index 8a50c747..00000000 --- a/src/Cake.AsciiDoctorJ/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 00000000..f27ab48f --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,4 @@ + + + + From c57ffa95eff9308f1c1f01a8704b1ecaddcc20d7 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Sun, 1 Sep 2019 20:25:17 +0200 Subject: [PATCH 7/8] (GH-2) modified Changelog in preparation for release --- Changelog.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index b28ae9ea..ec875a28 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,9 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed + +## [1.0.1 - 2019-09-01] +### Changed - moved project into cake-contrb - created a changelog -- many changes to internal project-structure +- (GH-2) many changes to internal project-structure ## [1.0.0] - 2019-08-13 ### Added @@ -19,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial idea - working version mostly without documentation -[Unreleased]: https://github.com/cake-contrib/cake.asciidoctorj/compare/v1.0.0...HEAD +[Unreleased]: https://github.com/cake-contrib/cake.asciidoctorj/compare/v1.0.1...HEAD +[1.0.1]: https://github.com/cake-contrib/cake.asciidoctorj/compare/v1.0.0...v1.0.1 [1.0.0]: https://github.com/cake-contrib/cake.asciidoctorj/compare/v0.0.1...v1.0.0 [0.0.1]: https://github.com/cake-contrib/cake.asciidoctorj/tree/v0.0.1 \ No newline at end of file From 45bd425747721f535dfa8c5fe0db84f86fec9e72 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Sun, 1 Sep 2019 21:14:00 +0200 Subject: [PATCH 8/8] (maint) update to latest cake bootstrappers --- build.ps1 | 56 ++++++++++++++++++++++++++++--------------------------- build.sh | 21 +++++++-------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/build.ps1 b/build.ps1 index c56584b6..0b70945d 100644 --- a/build.ps1 +++ b/build.ps1 @@ -46,7 +46,7 @@ Param( [Alias("WhatIf", "Noop")] [switch]$DryRun, [switch]$SkipToolPackageRestore, - [Parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)] + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] [string[]]$ScriptArgs ) @@ -63,32 +63,37 @@ try { if (-not $IsCoreCLR) { [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48 } -} -catch { + } catch { Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3' -} + } [Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null -function MD5HashFile([string] $filePath) { - if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) { +function MD5HashFile([string] $filePath) +{ + if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) + { return $null } [System.IO.Stream] $file = $null; [System.Security.Cryptography.MD5] $md5 = $null; - try { + try + { $md5 = [System.Security.Cryptography.MD5]::Create() $file = [System.IO.File]::OpenRead($filePath) return [System.BitConverter]::ToString($md5.ComputeHash($file)) } - finally { - if ($null -ne $file) { + finally + { + if ($file -ne $null) + { $file.Dispose() } } } -function GetProxyEnabledWebClient { +function GetProxyEnabledWebClient +{ $wc = New-Object System.Net.WebClient $proxy = [System.Net.WebRequest]::GetSystemWebProxy() $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials @@ -98,7 +103,7 @@ function GetProxyEnabledWebClient { Write-Host "Preparing to run build script..." -if (!$PSScriptRoot) { +if(!$PSScriptRoot){ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } @@ -125,8 +130,7 @@ if (!(Test-Path $PACKAGES_CONFIG)) { try { $wc = GetProxyEnabledWebClient $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) - } - catch { + } catch { Throw "Could not download packages.config." } } @@ -135,8 +139,8 @@ if (!(Test-Path $PACKAGES_CONFIG)) { if (!(Test-Path $NUGET_EXE)) { Write-Verbose -Message "Trying to find nuget.exe in PATH..." $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } - $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select-Object -First 1 - if ($null -ne $NUGET_EXE_IN_PATH -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { + $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 + if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName } @@ -148,8 +152,7 @@ if (!(Test-Path $NUGET_EXE)) { try { $wc = GetProxyEnabledWebClient $wc.DownloadFile($NUGET_URL, $NUGET_EXE) - } - catch { + } catch { Throw "Could not download NuGet.exe." } } @@ -158,33 +161,33 @@ if (!(Test-Path $NUGET_EXE)) { $env:NUGET_EXE = $NUGET_EXE $env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { "mono `"$NUGET_EXE`"" -} -else { +} else { "`"$NUGET_EXE`"" } # Restore tools from NuGet? -if (-Not $SkipToolPackageRestore.IsPresent) { +if(-Not $SkipToolPackageRestore.IsPresent) { Push-Location Set-Location $TOOLS_DIR # Check for changes in packages.config and remove installed tools if true. [string] $md5Hash = MD5HashFile $PACKAGES_CONFIG - if ((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or - ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { Write-Verbose -Message "Missing or changed package.config hash..." - Get-ChildItem -Exclude packages.config, nuget.exe, Cake.Bakery | + Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery | Remove-Item -Recurse } Write-Verbose -Message "Restoring tools from NuGet..." - + $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" if ($LASTEXITCODE -ne 0) { Throw "An error occurred while restoring NuGet tools." } - else { + else + { $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" } Write-Verbose -Message ($NuGetOutput | Out-String) @@ -233,8 +236,7 @@ if (!(Test-Path $CAKE_EXE)) { $CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { "mono `"$CAKE_EXE`"" -} -else { +} else { "`"$CAKE_EXE`"" } diff --git a/build.sh b/build.sh index 1f3df0d9..7fc4599a 100644 --- a/build.sh +++ b/build.sh @@ -7,7 +7,7 @@ ########################################################################## # Define directories. -SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TOOLS_DIR=$SCRIPT_DIR/tools ADDINS_DIR=$TOOLS_DIR/Addins MODULES_DIR=$TOOLS_DIR/Modules @@ -33,23 +33,16 @@ CAKE_ARGUMENTS=() # Parse arguments. for i in "$@"; do case $1 in - -s | --script) - SCRIPT="$2" - shift - ;; - --) - shift - CAKE_ARGUMENTS+=("$@") - break - ;; - *) CAKE_ARGUMENTS+=("$1") ;; + -s|--script) SCRIPT="$2"; shift ;; + --) shift; CAKE_ARGUMENTS+=("$@"); break ;; + *) CAKE_ARGUMENTS+=("$1") ;; esac shift done # Make sure the tools folder exist. if [ ! -d "$TOOLS_DIR" ]; then - mkdir "$TOOLS_DIR" + mkdir "$TOOLS_DIR" fi # Make sure that packages.config exist. @@ -74,7 +67,7 @@ fi # Restore tools from NuGet. pushd "$TOOLS_DIR" >/dev/null -if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$(cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//')" != "$($MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }')" ]; then +if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf fi @@ -84,7 +77,7 @@ if [ $? -ne 0 ]; then exit 1 fi -$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >|"$PACKAGES_CONFIG_MD5" +$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5" popd >/dev/null