2using System.Collections.Generic;
4using System.Text.RegularExpressions;
5using System.Threading.Tasks;
9using Nuke.Common.Utilities;
10using Nuke.Common.Utilities.Collections;
12using YamlDotNet.Serialization;
35 [YamlMember(Alias =
"dir")]
41 [YamlMember(Alias =
"not")]
42 public List<string>
Not = [];
58 [YamlMember(Alias =
"procContent")]
66 [YamlMember(Alias =
"manifestFilePattern")]
69 internal AbsolutePath? GetDestination(AbsolutePath srcRoot, AbsolutePath dstRoot, AbsolutePath currentPath,
int itemId, IEnumerable<string> exclude)
72 var relativePath = srcRoot.GetRelativePathTo(currentPath);
74 bool Ignore(
string glob)
76 var regex = glob.GlobToRegex();
77 return Regex.IsMatch(relativePath!.ToString(), regex, RegexOptions.IgnoreCase);
80 if (exclude.Any(Ignore))
84 return dstRoot / relativePath;
86 var asExpr =
As.Replace(
"$#", itemId.ToString());
88 if (glob.Contains(
'*') && asExpr.Contains(
'$'))
90 var asResult = asExpr;
91 var relPath = relativePath.ToString().Replace(
"\\",
"/");
92 var regex = glob.GlobToRegex();
93 var match = Regex.Match(relPath, regex);
94 for (
int i = 1; i < match.Groups.Count; i++)
96 asResult = asResult.Replace($
"${i}", match.Groups[i]?.Value);
99 return dstRoot / asResult.Replace(
"//",
"/");
101 else return dstRoot / asExpr;
117 object ICloneable.Clone()
133 public List<FileOrDirectory>
Link = [];
140 public List<FileOrDirectory>
Copy = [];
151 public List<FileOrDirectory>
Use = [];
157 public List<string>
Not = [];
164 if (other ==
null)
return;
175 Link = [..
Link.Select(s => s.Clone())],
176 Copy = [..
Copy.Select(s => s.Clone())],
177 Use = [..
Use.Select(s => s.Clone())],
182 object ICloneable.Clone()
200 if (others ==
null || others.IsEmpty())
return self;
203 self = others.First().Clone();
204 others = others.Skip(1);
206 foreach (var other
in others)
static ? ExportManifest Combine(this ExportManifest? self, IEnumerable< ExportManifest >? others)
Combine input export manifests together into given one. If given is null, the first one will be clone...
Controls how a folder should be exported for composition. It is meant to be used with export....
List< FileOrDirectory > Copy
A list of items which will be copied. Content processing can happen in this case if item is flagged t...
void Add(ExportManifest? other)
Merge one manifest with another. This will simply append items to each lists.
List< string > Not
Ignore files or directories matching any of these patterns from this entire export.
List< FileOrDirectory > Use
A list of folders which should contain an export manifest, or files which points to export manifests....
List< FileOrDirectory > Link
A list of items which will be symlinked. Content processing will obviously not happen in this case.
A union provided for denoting wether we want to link/copy a file or a directory. It is undefined beha...
string? File
Export a single or a glob of files handled individually. Either File or Directory (dir) must be speci...
string? As
Override the destination relative path of exported item.
string? ManifestFilePattern
Only used by "use", if a subfolder uses a different file for export manifest, specify that via this g...
List< string > Not
Exclude iterms from this particular set of files or directories if they match any of these patterns.
string? Directory
Export one or a glob of directories handled recursively. Files inside target directories are not cons...
bool ProcessContent
When working with a file, process its contents for replacing specified suffixes.