-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
278 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// DISABLE WYAM | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
BuildParameters.Tasks.PreviewDocumentationTask.WithCriteria(() => false, "Favor Statiq over Wyam"); | ||
BuildParameters.Tasks.PublishDocumentationTask.WithCriteria(() => false, "Favor Statiq over Wyam"); | ||
BuildParameters.Tasks.ForcePublishDocumentationTask.WithCriteria(() => false, "Favor Statiq over Wyam"); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// TASK DEFINITIONS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
// No Clean task, we re-use the one provided in Wyam.cake | ||
|
||
BuildParameters.Tasks.PublishDocumentationTask = Task("Publish-StatiqDocs") | ||
.IsDependentOn("Clean-Documentation") | ||
.WithCriteria(() => BuildParameters.ShouldGenerateDocumentation, "Statiq documentation has been disabled") | ||
.WithCriteria(() => DirectoryExists(BuildParameters.WyamRootDirectoryPath), "Statiq documentation directory is missing") | ||
.Does(() => { | ||
// ensure submodules are in place | ||
var gitTool = Context.Tools.Resolve("git"); | ||
if (gitTool == null) | ||
{ | ||
gitTool = Context.Tools.Resolve("git.exe"); | ||
} | ||
if (gitTool == null) | ||
{ | ||
throw new FileNotFoundException("git/git.exe could not be found!"); | ||
} | ||
var exitCode = Context.StartProcess( | ||
gitTool, | ||
new ProcessSettings { | ||
Arguments = "submodule init --recursive", | ||
} | ||
); | ||
// Check to see if any documentation has changed | ||
var sourceCommit = GitLogTip("./"); | ||
Information("Source Commit Sha: {0}", sourceCommit.Sha); | ||
var filesChanged = GitDiff("./", sourceCommit.Sha); | ||
Information("Number of changed files: {0}", filesChanged.Count); | ||
var docFileChanged = false; | ||
var wyamDocsFolderDirectoryName = BuildParameters.WyamRootDirectoryPath.GetDirectoryName(); | ||
var pathsToTestAgainst = new List<string>() { | ||
string.Format("{0}{1}", wyamDocsFolderDirectoryName, "/input/") | ||
}; | ||
if (BuildParameters.ShouldDocumentSourceFiles) | ||
{ | ||
// BuildParameters.WyamSourceFiles can not be used - the wyam globs are different from globs in GetFiles(). | ||
pathsToTestAgainst.Add(string.Format("{0}{1}", BuildParameters.SourceDirectoryPath.FullPath, '/')); | ||
} | ||
Verbose("Comparing all file-changes to the following paths:"); | ||
foreach(var p in pathsToTestAgainst) | ||
{ | ||
Verbose(" - "+p); | ||
} | ||
foreach (var file in filesChanged) | ||
{ | ||
Verbose("Changed File OldPath: {0}, Path: {1}", file.OldPath, file.Path); | ||
if (pathsToTestAgainst.Any(x => file.OldPath.Contains(x) || file.Path.Contains(x))) | ||
{ | ||
docFileChanged = true; | ||
break; | ||
} | ||
} | ||
if (docFileChanged) | ||
{ | ||
Information("Detected that documentation files have changed, so running Statiq..."); | ||
Statiq(); | ||
PublishStatiqDocs(); | ||
} | ||
else | ||
{ | ||
Information("No documentation has changed, so no need to generate documentation"); | ||
} | ||
} | ||
) | ||
.OnError(exception => | ||
{ | ||
Error(exception.Message); | ||
Information("Publish-StatiqDocs Task failed, but continuing with next Task..."); | ||
publishingError = true; | ||
}); | ||
|
||
BuildParameters.Tasks.PreviewDocumentationTask = Task("Preview-StatiqDocs") | ||
.WithCriteria(() => DirectoryExists(BuildParameters.WyamRootDirectoryPath), "Statiq documentation directory is missing") | ||
.Does(() => { | ||
Statiq("preview"); | ||
}); | ||
|
||
|
||
BuildParameters.Tasks.ForcePublishDocumentationTask = Task("Force-Publish-StatiqDocs") | ||
.IsDependentOn("Clean-Documentation") | ||
.WithCriteria(() => DirectoryExists(BuildParameters.WyamRootDirectoryPath), "Statiq documentation directory is missing") | ||
.Does(() => { | ||
Statiq(); | ||
PublishStatiqDocs(); | ||
} | ||
); | ||
|
||
public void PublishStatiqDocs() | ||
{ | ||
|
||
if (!BuildParameters.CanUseWyam) | ||
{ | ||
Warning("Unable to publish documentation, as not all Wyam Configuration is present"); | ||
return; | ||
} | ||
|
||
Statiq("deploy"); | ||
} | ||
|
||
// TODO: Do we need Cake.Statiq ? | ||
public void Statiq(string command = "", IDictionary<string, string> additionalSetting = null) | ||
{ | ||
var statiqProj = BuildParameters.WyamRootDirectoryPath.CombineWithFilePath("Docs.csproj").FullPath; // TODO: Configurable! | ||
var logLevel = (Context.Log.Verbosity > Verbosity.Normal) ? "--log-level Trace" : string.Empty; | ||
var settings = new Dictionary<string, string> | ||
{ | ||
{ "Host", BuildParameters.WebHost }, | ||
{ "LinkRoot", BuildParameters.WebLinkRoot }, | ||
{ "BaseEditUrl", BuildParameters.WebBaseEditUrl }, | ||
{ "Title", BuildParameters.Title }, | ||
{ "IncludeGlobalNamespace", "false" }, | ||
{ "STATIQ_DEPLOY_OWNER", BuildParameters.RepositoryOwner }, | ||
{ "STATIQ_DEPLOY_REPO_NAME", BuildParameters.RepositoryName } | ||
}; | ||
|
||
if (BuildParameters.ShouldDocumentSourceFiles) | ||
{ | ||
settings.Add("SourceFiles", BuildParameters.WyamSourceFiles); | ||
} | ||
|
||
if(additionalSetting != null) | ||
{ | ||
settings = new[]{settings, additionalSetting}.SelectMany(x => x).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); | ||
} | ||
|
||
if((command.EqualsIgnoreCase("preview") || command.EqualsIgnoreCase("serve")) && !string.IsNullOrEmpty(BuildParameters.WebLinkRoot)) | ||
{ | ||
command += $" --virtual-dir={BuildParameters.WebLinkRoot}"; | ||
} | ||
|
||
DotNetCoreRun(statiqProj, new DotNetCoreRunSettings | ||
{ | ||
EnvironmentVariables = settings, | ||
ArgumentCustomization = args=>args.Append($" -- {command} --root=\"{BuildParameters.WyamRootDirectoryPath}\" {logLevel}"), | ||
}); | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// BAKE STATIQ IN Cake.Recipe | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
BuildParameters.Tasks.PreviewTask.IsDependentOn("Preview-StatiqDocs"); | ||
BuildParameters.Tasks.PublishDocsTask.IsDependentOn("Force-Publish-StatiqDocs"); | ||
BuildParameters.Tasks.ContinuousIntegrationTask.IsDependentOn("Publish-StatiqDocs"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,5 @@ docs/input/tasks/* | |
# Wyam related | ||
config.wyam.* | ||
.idea/ | ||
docs/cache/ | ||
docs/output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "docs/theme"] | ||
path = docs/theme | ||
url = https://github.com/statiqdev/Docable.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LanguageVersion>latest</LanguageVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Statiq.Docs" Version="1.0.0-beta.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
await Bootstrapper | ||
.Factory | ||
.CreateDocs(args) | ||
.DeployToGitHubPagesBranch( | ||
Config.FromSetting<string>("STATIQ_DEPLOY_OWNER"), | ||
Config.FromSetting<string>("STATIQ_DEPLOY_REPO_NAME"), | ||
Config.FromSetting<string>("WYAM_ACCESS_TOKEN"), | ||
Config.FromSetting<string>("WYAM_DEPLOY_BRANCH") | ||
) | ||
.RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# FAVICON package | ||
|
||
This was all generated by using https://realfavicongenerator.net/ with | ||
https://github.com/cake-contrib/graphics/blob/3344c5e09d33dedb984edf8a362d8a3d32f7acd4/png/addin/cake-contrib-addin-large.png as the source. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<browserconfig> | ||
<msapplication> | ||
<tile> | ||
<square150x150logo src="/mstile-150x150.png"/> | ||
<TileColor>#da532c</TileColor> | ||
</tile> | ||
</msapplication> | ||
</browserconfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "CakeContrib/Cake.7zip", | ||
"short_name": "Cake.7zip", | ||
"icons": [ | ||
{ | ||
"src": "/android-chrome-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "/android-chrome-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
], | ||
"theme_color": "#ffffff", | ||
"background_color": "#ffffff", | ||
"display": "standalone" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#load nuget:?package=Cake.Recipe&version=3.0.1 | ||
#l ./.build/statiq-docs.cake | ||
|
||
Environment.SetVariableNames(); | ||
|
||
|