diff options
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/IArtifact.cs | 23 | ||||
-rw-r--r-- | src/Model/IBuildable.cs | 19 | ||||
-rw-r--r-- | src/Model/IDirectoryIndex.cs | 37 | ||||
-rw-r--r-- | src/Model/IFeedManager.cs | 16 | ||||
-rw-r--r-- | src/Model/IModuleData.cs | 19 | ||||
-rw-r--r-- | src/Model/IModuleFileManager.cs | 62 | ||||
-rw-r--r-- | src/Model/IProject.cs | 37 | ||||
-rw-r--r-- | src/Model/IProjectData.cs | 19 | ||||
-rw-r--r-- | src/Model/IProjectExplorer.cs | 16 | ||||
-rw-r--r-- | src/Model/ITaskfileScope.cs | 22 | ||||
-rw-r--r-- | src/Model/IUploadManager.cs | 15 | ||||
-rw-r--r-- | src/Model/TaskfileVars.cs | 48 |
12 files changed, 333 insertions, 0 deletions
diff --git a/src/Model/IArtifact.cs b/src/Model/IArtifact.cs new file mode 100644 index 0000000..c3c215a --- /dev/null +++ b/src/Model/IArtifact.cs @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; + +namespace VNLib.Tools.Build.Executor.Model +{ + internal interface IArtifact : IDisposable + { + /// <summary> + /// Invoked when the executor requests all created artifacts load async assets + /// and update state accordingly + /// </summary> + /// <param name="vars">The taskfile variable container</param> + /// <returns>A task that completes when all assets are loaded</returns> + Task LoadAsync(TaskfileVars vars); + + /// <summary> + /// Invoked when the executor requests all artifacts cleanup assets that + /// may have been generated during a build process + /// </summary> + /// <returns>A task that completes when all assest are cleaned</returns> + Task CleanAsync(); + } +}
\ No newline at end of file diff --git a/src/Model/IBuildable.cs b/src/Model/IBuildable.cs new file mode 100644 index 0000000..dd32e03 --- /dev/null +++ b/src/Model/IBuildable.cs @@ -0,0 +1,19 @@ +using System.Threading.Tasks; + +namespace VNLib.Tools.Build.Executor.Model +{ + internal interface IBuildable : IArtifact + { + Task DoStepSyncSource(); + + Task<bool> CheckForChangesAsync(); + + Task DoStepBuild(); + + Task DoStepPostBuild(bool success); + + Task DoStepPublish(); + + Task DoRunTests(bool failOnError); + } +}
\ No newline at end of file diff --git a/src/Model/IDirectoryIndex.cs b/src/Model/IDirectoryIndex.cs new file mode 100644 index 0000000..4a30344 --- /dev/null +++ b/src/Model/IDirectoryIndex.cs @@ -0,0 +1,37 @@ +using System.IO; + +namespace VNLib.Tools.Build.Executor.Model +{ + public interface IDirectoryIndex + { + /// <summary> + /// The current build base directory + /// </summary> + DirectoryInfo BaseDir { get; } + + /// <summary> + /// The top level internal build directory + /// </summary> + DirectoryInfo BuildDir { get; } + + /// <summary> + /// The directory where log files are stored + /// </summary> + DirectoryInfo LogDir { get; } + + /// <summary> + /// Gets the build scratch directory + /// </summary> + DirectoryInfo ScratchDir { get; } + + /// <summary> + /// Gets the build checksum directory, used to store source file sums + /// </summary> + DirectoryInfo SumDir { get; } + + /// <summary> + /// The build output directory + /// </summary> + DirectoryInfo OutputDir { get; } + } +}
\ No newline at end of file diff --git a/src/Model/IFeedManager.cs b/src/Model/IFeedManager.cs new file mode 100644 index 0000000..7f56449 --- /dev/null +++ b/src/Model/IFeedManager.cs @@ -0,0 +1,16 @@ +namespace VNLib.Tools.Build.Executor.Model +{ + public interface IFeedManager + { + /// <summary> + /// Adds taskfile variables for the feed manager + /// </summary> + /// <param name="vars">The taskfile variable container</param> + void AddVariables(TaskfileVars vars); + + /// <summary> + /// The output directory of the feed + /// </summary> + string FeedOutputDir { get; } + } +}
\ No newline at end of file diff --git a/src/Model/IModuleData.cs b/src/Model/IModuleData.cs new file mode 100644 index 0000000..c41a76b --- /dev/null +++ b/src/Model/IModuleData.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +using LibGit2Sharp; + +namespace VNLib.Tools.Build.Executor.Model +{ + public interface IModuleData + { + ICollection<IProject> Projects { get; } + + string ModuleName { get; } + + Repository Repository { get; } + + TaskfileVars TaskVars { get; } + + IModuleFileManager FileManager { get; } + } +}
\ No newline at end of file diff --git a/src/Model/IModuleFileManager.cs b/src/Model/IModuleFileManager.cs new file mode 100644 index 0000000..cf1a325 --- /dev/null +++ b/src/Model/IModuleFileManager.cs @@ -0,0 +1,62 @@ +using System.IO; +using System.Threading.Tasks; + +namespace VNLib.Tools.Build.Executor.Model +{ + public enum ModuleFileType + { + None, + Catalog, + GitHistory, + Checksum, + LatestHash, + VersionHistory, + Archive + } + + public interface IModuleFileManager + { + /// <summary> + /// Writes the file to the module output directory + /// </summary> + /// <param name="type">The <see cref="ModuleFileType"/> to write</param> + /// <param name="fileData">The file data to write</param> + /// <returns>A task that resolves when the file has been written</returns> + Task<FileInfo> WriteFileAsync(ModuleFileType type, byte[] fileData); + + /// <summary> + /// Writes the checksum file to the sum's output directory for the given project + /// </summary> + /// <param name="project">The project to write the sum file data for</param> + /// <param name="fileData"></param> + /// <returns></returns> + Task WriteChecksumAsync(IProject project, byte[] fileData); + + /// <summary> + /// Attemts to read the checksum file data for the given project + /// </summary> + /// <param name="project">The project to get the sum data for</param> + /// <returns>The file contents of the sum file, or null if the file does not exist</returns> + Task<byte[]?> ReadCheckSumAsync(IProject project); + + /// <summary> + /// The module's output directory + /// </summary> + string OutputDir { get; } + + /// <summary> + /// Copies the given file to the project's output directory + /// </summary> + /// <param name="project"></param> + /// <param name="file"></param> + /// <returns></returns> + Task CopyArtifactToOutputAsync(IProject project, FileInfo file); + + /// <summary> + /// Gets the output directory for the given project + /// </summary> + /// <param name="project">The project to get the artifact output of</param> + /// <returns>A <see cref="DirectoryInfo"/> object describing the output dir</returns> + DirectoryInfo GetArtifactOutputDir(IProject project); + } +}
\ No newline at end of file diff --git a/src/Model/IProject.cs b/src/Model/IProject.cs new file mode 100644 index 0000000..e7f15bb --- /dev/null +++ b/src/Model/IProject.cs @@ -0,0 +1,37 @@ +using System.IO; +using System.Threading.Tasks; + +namespace VNLib.Tools.Build.Executor.Model +{ + public interface IProject : ITaskfileScope + { + /// <summary> + /// Gets the the project file + /// </summary> + FileInfo ProjectFile { get; } + + /// <summary> + /// Gets the actual project name + /// </summary> + string ProjectName { get; } + + /// <summary> + /// The msbuild project dom + /// </summary> + IProjectData ProjectData { get; } + + /// <summary> + /// A value that indicates (after a source sync) that the project + /// is considered up to date. + /// </summary> + bool UpToDate { get; set; } + + /// <summary> + /// Invoked when the executor requests all created artifacts load async assets + /// and update state accordingly + /// </summary> + /// <param name="vars">The taskfile variable container</param> + /// <returns>A task that completes when all assets are loaded</returns> + Task LoadAsync(TaskfileVars vars); + } +}
\ No newline at end of file diff --git a/src/Model/IProjectData.cs b/src/Model/IProjectData.cs new file mode 100644 index 0000000..1b4190d --- /dev/null +++ b/src/Model/IProjectData.cs @@ -0,0 +1,19 @@ +using System.IO; + + +namespace VNLib.Tools.Build.Executor.Model +{ + public interface IProjectData + { + string? Description { get; } + string? Authors { get; } + string? Copyright { get; } + string? VersionString { get; } + string? CompanyName { get; } + string? Product { get; } + string? RepoUrl { get; } + string? this[string index] { get; } + void Load(Stream stream); + string[] GetProjectRefs(); + } +}
\ No newline at end of file diff --git a/src/Model/IProjectExplorer.cs b/src/Model/IProjectExplorer.cs new file mode 100644 index 0000000..3c9c61b --- /dev/null +++ b/src/Model/IProjectExplorer.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace VNLib.Tools.Build.Executor.Model +{ + /// <summary> + /// Represents a project explorer, capable of discovering projects within a module + /// </summary> + internal interface IProjectExplorer + { + /// <summary> + /// Discovers all projects within the module + /// </summary> + /// <returns>An enumeration of projects discovered</returns> + IEnumerable<IProject> DiscoverProjects(); + } +}
\ No newline at end of file diff --git a/src/Model/ITaskfileScope.cs b/src/Model/ITaskfileScope.cs new file mode 100644 index 0000000..6a416fa --- /dev/null +++ b/src/Model/ITaskfileScope.cs @@ -0,0 +1,22 @@ +using System.IO; + +namespace VNLib.Tools.Build.Executor.Model +{ + public interface ITaskfileScope + { + /// <summary> + /// The taskfile working directory + /// </summary> + DirectoryInfo WorkingDir { get; } + + /// <summary> + /// The taskfile variable container + /// </summary> + TaskfileVars TaskVars { get; } + + /// <summary> + /// The optional taskfile name + /// </summary> + string? TaskfileName { get; } + } +}
\ No newline at end of file diff --git a/src/Model/IUploadManager.cs b/src/Model/IUploadManager.cs new file mode 100644 index 0000000..01d7081 --- /dev/null +++ b/src/Model/IUploadManager.cs @@ -0,0 +1,15 @@ +using System.Threading.Tasks; + +namespace VNLib.Tools.Build.Executor.Model +{ + public interface IUploadManager + { + Task CleanAllAsync(string path); + + Task DeleteFileAsync(string filePath); + + Task UploadDirectoryAsync(string path); + + Task UploadFileAsync(string filePath); + } +}
\ No newline at end of file diff --git a/src/Model/TaskfileVars.cs b/src/Model/TaskfileVars.cs new file mode 100644 index 0000000..c0e6cdc --- /dev/null +++ b/src/Model/TaskfileVars.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; + +namespace VNLib.Tools.Build.Executor.Model +{ + /// <summary> + /// Represents a collection of taskfile "environment" variables + /// </summary> + public sealed class TaskfileVars + { + private readonly Dictionary<string, string> vars; + + public TaskfileVars() + { + vars = new(StringComparer.OrdinalIgnoreCase); + } + + private TaskfileVars(IEnumerable<KeyValuePair<string, string>> values) + { + vars = new(values, StringComparer.OrdinalIgnoreCase); + } + + /// <summary> + /// Gets all variables as a readonly dictionary + /// </summary> + /// <returns>The collection of environment variables</returns> + public IReadOnlyDictionary<string, string> GetVariables() => vars; + + /// <summary> + /// Sets a taskfile environment variable + /// </summary> + /// <param name="key">The variable name</param> + /// <param name="value">The optional variable value</param> + public void Set(string key, string? value) => vars[key] = value ?? string.Empty; + + /// <summary> + /// Removes a taskfile environment variable + /// </summary> + /// <param name="key">The name of the variable to remove</param> + public void Remove(string key) => vars.Remove(key); + + /// <summary> + /// Clones the current taskfile variables into an independent instance + /// </summary> + /// <returns>The new <see cref="TaskfileVars"/> instance</returns> + public TaskfileVars Clone() => new (vars); + } +}
\ No newline at end of file |