From 4ce5f09eda4a0cbc8863ff7889b5ce58e73d2453 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Fri, 16 May 2025 19:44:19 +0200 Subject: [PATCH 01/11] Add Apax build and packaging support with YAML configuration files - Introduced ApaxCmd and ApaxFile classes for managing Apax project versions and packaging. - Updated BuildContext to include new properties for Apax artifacts and GitHub credentials. - Enhanced Program.cs to automate Apax version updates and artifact packing. - Added YAML configuration files for axsharp-ixc, axsharp-ixd, and axsharp-ixr projects. - Updated .gitignore to exclude Apax package files. - Included YamlDotNet package in Build.csproj for YAML processing. --- .gitignore | 3 + cake/ApaxCmd.cs | 93 +++++++++++++++++++++ cake/ApaxFile.cs | 112 ++++++++++++++++++++++++++ cake/Build.csproj | 3 +- cake/BuildContext.cs | 10 +++ cake/Program.cs | 14 ++++ src/AXSharp.compiler/src/ixc/apax.yml | 12 +++ src/AXSharp.compiler/src/ixd/apax.yml | 12 +++ src/AXSharp.compiler/src/ixr/apax.yml | 12 +++ 9 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 cake/ApaxCmd.cs create mode 100644 cake/ApaxFile.cs create mode 100644 src/AXSharp.compiler/src/ixc/apax.yml create mode 100644 src/AXSharp.compiler/src/ixd/apax.yml create mode 100644 src/AXSharp.compiler/src/ixr/apax.yml diff --git a/.gitignore b/.gitignore index 8eee6dc6c..a27fcbd1a 100644 --- a/.gitignore +++ b/.gitignore @@ -405,3 +405,6 @@ ix/.g/** .apax/ /src/apax/stc-generic-x64 TestResults/ + +# Apax packages +*.apax.tgz diff --git a/cake/ApaxCmd.cs b/cake/ApaxCmd.cs new file mode 100644 index 000000000..fc7bdfded --- /dev/null +++ b/cake/ApaxCmd.cs @@ -0,0 +1,93 @@ +// Build +// Copyright (c) 2023 MTS spol. s r.o, and Contributors. All Rights Reserved. +// Contributors: https://github.com/inxton/AXOpen/graphs/contributors +// See the LICENSE file in the repository root for more information. +// https://github.com/inxton/AXOpen/blob/master/LICENSE +// Third party licenses: https://github.com/inxton/AXOpen/blob/master/notices.md + +using System; +using System.IO; +using System.Text; +using Cake.Core.IO; +using Path = System.IO.Path; + +public static class ApaxCmd +{ + public static void UpdateApaxVersion(this BuildContext context, string file, string version) + { + var sb = new StringBuilder(); + foreach (var line in System.IO.File.ReadLines(file)) + { + var newLine = line; + + if (line.Trim().StartsWith("version")) + { + var semicPosition = line.IndexOf(":"); + var lenght = line.Length - semicPosition; + + newLine = $"{line.Substring(0, semicPosition)} : '{version}'"; + } + + sb.AppendLine(newLine); + } + + System.IO.File.WriteAllText(file, sb.ToString()); + } + + public static void ApaxPack(this BuildContext context, string apaxFolder) + { + { + context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings() + { + Arguments = $"pack --key={context.ApaxSignKey}", + WorkingDirectory = apaxFolder, + RedirectStandardOutput = false, + RedirectStandardError = false, + Silent = false + }).WaitForExit(); + } + } + + public static void ApaxCopyArtifacts(this BuildContext context, string folder, string name) + { + var packageFile = $"{context.ApaxRegistry}-{name}-{GitVersionInformation.SemVer}.apax.tgz"; + var sourceFile = Path.Combine(folder, packageFile); + File.Copy(sourceFile, Path.Combine(context.ArtifactsApax, packageFile)); + } + + public static void ApaxPublishAllArtefacts(this BuildContext context) + { + context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings() + { + Arguments = + $"login --registry https://npm.pkg.github.com --username {context.GitHubUser} --password {context.GitHubToken}", + WorkingDirectory = context.ArtifactsApax, + RedirectStandardOutput = false, + RedirectStandardError = false, + Silent = false + }).WaitForExit(); + + foreach (var apaxPackageFile in Directory.EnumerateFiles(context.ArtifactsApax)) + { + var process = context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings() + { + Arguments = $"publish -p {apaxPackageFile} -r https://npm.pkg.github.com", + WorkingDirectory = context.ArtifactsApax, + RedirectStandardOutput = false, + RedirectStandardError = false, + Silent = false + }); + + process.WaitForExit(); + + if (process.GetExitCode() != 0) + { + throw new PublishFailedException(); + } + } + } +} + +public class PublishFailedException : Exception +{ +} \ No newline at end of file diff --git a/cake/ApaxFile.cs b/cake/ApaxFile.cs new file mode 100644 index 000000000..acc899088 --- /dev/null +++ b/cake/ApaxFile.cs @@ -0,0 +1,112 @@ +// Copyright (c) 2023 MTS spol. s r.o, and Contributors. All Rights Reserved. +// Contributors: https://github.com/inxton/AXOpen/graphs/contributors +// See the LICENSE file in the repository root for more information. +// https://github.com/inxton/AXOpen/blob/master/LICENSE +// Third party licenses: https://github.com/inxton/AXOpen/blob/master/notices.md + +using System.Collections.Generic; +using System.IO; +using YamlDotNet.Serialization.NamingConventions; +using YamlDotNet.Serialization; + + + public class ApaxFile + { + // + // Summary: + // Gets or sets ax project name. + public string? Name { get; set; } + + // + // Summary: + // Ax project type. + public string? Type { get; set; } + + // + // Summary: + // Gets or sets the version of the AX project. + public string? Version { get; set; } + + // + // Summary: + // Gets or sets ax targets. + public IEnumerable? Targets { get; set; } + + // + // Summary: + // Gets or sets ax project files to include in package. + public IEnumerable? Files { get; set; } + + // + // Summary: + // Gets or sets ax projects development dependencies. + public IDictionary? DevDependencies { get; set; } + + // + // Summary: + // Gets or sets ax projects dependencies. + public IDictionary? Dependencies { get; set; } + + + public IDictionary? Catalogs { get; set; } + + public string? Registries { get; set; } + + public string InstallStrategy { get; set; } + + public string ApaxVersion { get; set; } + + public Dictionary Scripts { get; set; } + + // + // Summary: + // Creates new instance of AXSharp.Compiler.Apax. + // + // Parameters: + // projectFile: + // Project file from which the ApaxFile object will be created. + // + // Exceptions: + // T:System.IO.FileNotFoundException: + public static ApaxFile CreateApaxDto(string projectFile) + { + try + { + return new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).IgnoreUnmatchedProperties().Build() + .Deserialize(File.ReadAllText(projectFile)); + } + catch (FileNotFoundException) + { + throw new FileNotFoundException("'apax.yml' file was not found in the working directory. Make sure your current directory is simatic-ax project directory or provide source directory argument (for details see ixc --help)"); + } + } + + public static void UpdateDependencyVersions(string apaxFile, string version) + { + try + { + var apax = CreateApaxDto(apaxFile); + + + foreach (var dependency in apax.Dependencies) + { + // dependency = new KeyValuePair(dependency.Key, version); + } + + + using (var tw = new StreamWriter(apaxFile)) + { + var serializer = new SerializerBuilder() + .WithNamingConvention(CamelCaseNamingConvention.Instance) + .Build(); + + serializer.Serialize(tw, apax); + } + } + catch (FileNotFoundException) + { + throw new FileNotFoundException( + "'apax.yml' file was not found in the working directory. Make sure your current directory is simatic-ax project directory or provide source directory argument (for details see ixc --help)"); + } + } + } diff --git a/cake/Build.csproj b/cake/Build.csproj index fbb9bfd2b..299450d4f 100644 --- a/cake/Build.csproj +++ b/cake/Build.csproj @@ -15,7 +15,8 @@ - + + diff --git a/cake/BuildContext.cs b/cake/BuildContext.cs index 03f5bda91..d3709ef1a 100644 --- a/cake/BuildContext.cs +++ b/cake/BuildContext.cs @@ -30,8 +30,13 @@ public class BuildContext : FrostingContext { public string Artifacts => Path.Combine(Environment.WorkingDirectory.FullPath, "..//artifacts//"); + public string ArtifactsApax => Path.Combine(Environment.WorkingDirectory.FullPath, "..//artifacts//apax//"); + public string TestResults => Path.Combine(Environment.WorkingDirectory.FullPath, "..//TestResults//"); + public string RootDir => Path.GetFullPath(Path.Combine(Environment.WorkingDirectory.FullPath, "..//src//")); + public string ApaxRegistry => "inxton"; + public string WorkDirName => Environment.WorkingDirectory.GetDirectoryName(); public string DocumentationOutputDir => Path.GetFullPath(Path.Combine(Environment.WorkingDirectory.FullPath, "..//docs//")); @@ -179,6 +184,11 @@ public void PushNugetPackages(string artifactDirectory) } public IEnumerable TargetFrameworks { get; } = new List() { "net9.0", "net8.0" }; + public string ApaxSignKey { get; set; } = System.Environment.GetEnvironmentVariable("APAX_SIGN_KEY"); + public string GitHubUser { get; set; } = System.Environment.GetEnvironmentVariable("InxtonDev"); + public string GitHubToken { get; set; } = System.Environment.GetEnvironmentVariable("GH_TOKEN"); + + public IEnumerable<(string ax, string approject, string solution)> GetTemplateProjects() { diff --git a/cake/Program.cs b/cake/Program.cs index afc4073ae..f28a6b8ea 100644 --- a/cake/Program.cs +++ b/cake/Program.cs @@ -236,6 +236,19 @@ private static void PackPackages(BuildContext context, string solutionToPack) NoRestore = true, NoBuild = false, }); + + var apaxConstributedToPack = new (string folder, string name)[] + { + (Path.Combine(context.ScrDir, "AXSharp.compiler\\src\\ixc\\"), "axsharp-ixc"), + (Path.Combine(context.ScrDir, "AXSharp.compiler\\src\\ixr\\"), "axsharp-ixr"), + (Path.Combine(context.ScrDir, "AXSharp.compiler\\src\\ixd\\"), "axsharp-ixd"), + }; + + apaxConstributedToPack.ToList().ForEach(p => + context.UpdateApaxVersion(Path.Combine(p.folder, "apax.yml"), p.name)); + apaxConstributedToPack.ToList().ForEach(p => context.ApaxPack(p.folder)); + apaxConstributedToPack.ToList().ForEach(p => context.ApaxCopyArtifacts(p.folder, p.name)); + } } @@ -284,6 +297,7 @@ public override void Run(BuildContext context) } context.PushNugetPackages("nugets"); + context.ApaxPublishAllArtefacts(); } } diff --git a/src/AXSharp.compiler/src/ixc/apax.yml b/src/AXSharp.compiler/src/ixc/apax.yml new file mode 100644 index 000000000..7dcdde9e2 --- /dev/null +++ b/src/AXSharp.compiler/src/ixc/apax.yml @@ -0,0 +1,12 @@ +name: "@inxton/axsharp-ixc" +description: "AX#Sharp twin compiler" +version: 0.0.0-dev.0 +type: generic +files: + - "bin/Release/net9.0/**" + - "!bin/Release/net9.0/.apax/.apax/**" +contributedCommands: + ixc: + bin: "bin/Release/net9.0/AXSharp.ixc.exe" + description: "AX#Sharp twin compiler" + hidden: false \ No newline at end of file diff --git a/src/AXSharp.compiler/src/ixd/apax.yml b/src/AXSharp.compiler/src/ixd/apax.yml new file mode 100644 index 000000000..19f762130 --- /dev/null +++ b/src/AXSharp.compiler/src/ixd/apax.yml @@ -0,0 +1,12 @@ +name: "@inxton/axsharp-ixd" +description: "AX#Sharp documentation compiler" +version: 0.0.0-dev.0 +type: generic +files: + - "bin/Release/net9.0/**" + - "!bin/Release/net9.0/.apax/.apax/**" +contributedCommands: + ixc: + bin: "bin/Release/net9.0/AXSharp.ixd.exe" + description: "AX#Sharp documentation compiler" + hidden: false \ No newline at end of file diff --git a/src/AXSharp.compiler/src/ixr/apax.yml b/src/AXSharp.compiler/src/ixr/apax.yml new file mode 100644 index 000000000..5a86149bf --- /dev/null +++ b/src/AXSharp.compiler/src/ixr/apax.yml @@ -0,0 +1,12 @@ +name: "@inxton/axsharp-ixr" +description: "AX#Sharp resources compiler" +version: 0.0.0-dev.0 +type: generic +files: + - "bin/Release/net9.0/**" + - "!bin/Release/net9.0/.apax/.apax/**" +contributedCommands: + ixc: + bin: "bin/Release/net9.0/AXSharp.ixr.exe" + description: "AX#Sharp resources compiler" + hidden: false \ No newline at end of file From a52da90310d9819ce7a57e7f433903db493052d6 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Fri, 16 May 2025 20:05:19 +0200 Subject: [PATCH 02/11] aps --- cake/BuildContext.cs | 4 ++-- src/AXSharp.compiler/src/ixc/Program.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/BuildContext.cs b/cake/BuildContext.cs index d3709ef1a..0dc1e6e53 100644 --- a/cake/BuildContext.cs +++ b/cake/BuildContext.cs @@ -184,8 +184,8 @@ public void PushNugetPackages(string artifactDirectory) } public IEnumerable TargetFrameworks { get; } = new List() { "net9.0", "net8.0" }; - public string ApaxSignKey { get; set; } = System.Environment.GetEnvironmentVariable("APAX_SIGN_KEY"); - public string GitHubUser { get; set; } = System.Environment.GetEnvironmentVariable("InxtonDev"); + public string ApaxSignKey { get; set; } = System.Environment.GetEnvironmentVariable("APAX_KEY"); + public string GitHubUser { get; set; } = System.Environment.GetEnvironmentVariable("GH_USER"); public string GitHubToken { get; set; } = System.Environment.GetEnvironmentVariable("GH_TOKEN"); diff --git a/src/AXSharp.compiler/src/ixc/Program.cs b/src/AXSharp.compiler/src/ixc/Program.cs index c02340cde..1243206e6 100644 --- a/src/AXSharp.compiler/src/ixc/Program.cs +++ b/src/AXSharp.compiler/src/ixc/Program.cs @@ -111,7 +111,7 @@ private static void DisplayInfo() Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine($"Using version '{LegalAcrobatics.StcVersion}' of stc."); + Console.WriteLine($"Using version '> {LegalAcrobatics.StcVersion}' of stc."); Console.ForegroundColor = originalColor; if (int.Parse(GitVersionInformation.Major) < 1 || string.IsNullOrEmpty(GitVersionInformation.PreReleaseLabel)) From 98bac3793e2f7b078415053fa73dd58b3023d1f5 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Fri, 16 May 2025 20:16:23 +0200 Subject: [PATCH 03/11] Update CreateArtifactsTask to use GitVersion for Apax versioning --- cake/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/Program.cs b/cake/Program.cs index f28a6b8ea..9b71bf260 100644 --- a/cake/Program.cs +++ b/cake/Program.cs @@ -245,7 +245,7 @@ private static void PackPackages(BuildContext context, string solutionToPack) }; apaxConstributedToPack.ToList().ForEach(p => - context.UpdateApaxVersion(Path.Combine(p.folder, "apax.yml"), p.name)); + context.UpdateApaxVersion(Path.Combine(p.folder, "apax.yml"), GitVersionInformation.SemVer)); apaxConstributedToPack.ToList().ForEach(p => context.ApaxPack(p.folder)); apaxConstributedToPack.ToList().ForEach(p => context.ApaxCopyArtifacts(p.folder, p.name)); From 4a3e5fbe47291f186438b3af11a055c6c92efbd2 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Fri, 16 May 2025 20:31:15 +0200 Subject: [PATCH 04/11] Ensure artifacts directory exists before copying files --- cake/ApaxCmd.cs | 2 +- cake/Program.cs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cake/ApaxCmd.cs b/cake/ApaxCmd.cs index fc7bdfded..ede48ca5b 100644 --- a/cake/ApaxCmd.cs +++ b/cake/ApaxCmd.cs @@ -49,7 +49,7 @@ public static void ApaxPack(this BuildContext context, string apaxFolder) } public static void ApaxCopyArtifacts(this BuildContext context, string folder, string name) - { + { var packageFile = $"{context.ApaxRegistry}-{name}-{GitVersionInformation.SemVer}.apax.tgz"; var sourceFile = Path.Combine(folder, packageFile); File.Copy(sourceFile, Path.Combine(context.ArtifactsApax, packageFile)); diff --git a/cake/Program.cs b/cake/Program.cs index 9b71bf260..0b58f0dfc 100644 --- a/cake/Program.cs +++ b/cake/Program.cs @@ -244,6 +244,13 @@ private static void PackPackages(BuildContext context, string solutionToPack) (Path.Combine(context.ScrDir, "AXSharp.compiler\\src\\ixd\\"), "axsharp-ixd"), }; + // Ensure articfats directory exists + if (!Directory.Exists(context.ArtifactsApax)) + { + context.CreateDirectory(context.ArtifactsApax); + } + + apaxConstributedToPack.ToList().ForEach(p => context.UpdateApaxVersion(Path.Combine(p.folder, "apax.yml"), GitVersionInformation.SemVer)); apaxConstributedToPack.ToList().ForEach(p => context.ApaxPack(p.folder)); From fac6b682a0a1271537263c7f795d66500644ce13 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Sat, 17 May 2025 09:55:06 +0200 Subject: [PATCH 05/11] Add metadata fields to apax.yml files for ixr, ixh, and ixd compilers --- src/AXSharp.compiler/src/ixc/apax.yml | 23 ++++++++++++++++++++++- src/AXSharp.compiler/src/ixd/apax.yml | 22 +++++++++++++++++++++- src/AXSharp.compiler/src/ixr/apax.yml | 15 ++++++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/AXSharp.compiler/src/ixc/apax.yml b/src/AXSharp.compiler/src/ixc/apax.yml index 7dcdde9e2..2f68e78be 100644 --- a/src/AXSharp.compiler/src/ixc/apax.yml +++ b/src/AXSharp.compiler/src/ixc/apax.yml @@ -9,4 +9,25 @@ contributedCommands: ixc: bin: "bin/Release/net9.0/AXSharp.ixc.exe" description: "AX#Sharp twin compiler" - hidden: false \ No newline at end of file + hidden: false +keywords: + - "compiler" + - "twin" + - "AX#" + - "SIMATIC-AX" + - "PLC" + - "IT-OT" +homepage: "https://inxton.github.io/axsharp/articles/compiler/README.html" +repository: + type: "git" + url: "https://github.com/Inxton/axsharp" +license: + type: "MIT" + url: "https://github.com/Inxton/axsharp/blob/dev/LICENSE" +bugs: + url: "https://github.com/Inxton/axsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug" +authors: + - name: "MTS spol. s r.o." + url: "https://www.mts.sk/en" + email: "team@inxton.com" + diff --git a/src/AXSharp.compiler/src/ixd/apax.yml b/src/AXSharp.compiler/src/ixd/apax.yml index 19f762130..213e8a676 100644 --- a/src/AXSharp.compiler/src/ixd/apax.yml +++ b/src/AXSharp.compiler/src/ixd/apax.yml @@ -9,4 +9,24 @@ contributedCommands: ixc: bin: "bin/Release/net9.0/AXSharp.ixd.exe" description: "AX#Sharp documentation compiler" - hidden: false \ No newline at end of file + hidden: false +keywords: + - "compiler" + - "twin" + - "AX#" + - "SIMATIC-AX" + - "PLC" + - "IT-OT" +homepage: "https://inxton.github.io/axsharp/articles/ixd/IXD.html" +repository: + type: "git" + url: "https://github.com/Inxton/axsharp" +license: + type: "MIT" + url: "https://github.com/Inxton/axsharp/blob/dev/LICENSE" +bugs: + url: "https://github.com/Inxton/axsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug" +authors: + - name: "MTS spol. s r.o." + url: "https://www.mts.sk/en" + email: "team@inxton.com" \ No newline at end of file diff --git a/src/AXSharp.compiler/src/ixr/apax.yml b/src/AXSharp.compiler/src/ixr/apax.yml index 5a86149bf..ae58636d2 100644 --- a/src/AXSharp.compiler/src/ixr/apax.yml +++ b/src/AXSharp.compiler/src/ixr/apax.yml @@ -9,4 +9,17 @@ contributedCommands: ixc: bin: "bin/Release/net9.0/AXSharp.ixr.exe" description: "AX#Sharp resources compiler" - hidden: false \ No newline at end of file + hidden: false +homepage: "https://inxton.github.io/axsharp/articles/ixr/IXR.html" +repository: + type: "git" + url: "https://github.com/Inxton/axsharp" +license: + type: "MIT" + url: "https://github.com/Inxton/axsharp/blob/dev/LICENSE" +bugs: + url: "https://github.com/Inxton/axsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug" +authors: + - name: "MTS spol. s r.o." + url: "https://www.mts.sk/en" + email: "team@inxton.com" \ No newline at end of file From 50f477de97bac36a5b8416ed194deffaea9d0a8f Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Sat, 17 May 2025 10:41:45 +0200 Subject: [PATCH 06/11] Refactor apax.yml files for ixr, ixh, and ixd compilers: streamline structure and ensure consistency in metadata fields --- src/AXSharp.compiler/src/ixc/apax.yml | 27 ++++++++++-------------- src/AXSharp.compiler/src/ixd/apax.yml | 27 ++++++++++-------------- src/AXSharp.compiler/src/ixr/apax.yml | 30 ++++++++++++++------------- 3 files changed, 38 insertions(+), 46 deletions(-) diff --git a/src/AXSharp.compiler/src/ixc/apax.yml b/src/AXSharp.compiler/src/ixc/apax.yml index 2f68e78be..0f57f592c 100644 --- a/src/AXSharp.compiler/src/ixc/apax.yml +++ b/src/AXSharp.compiler/src/ixc/apax.yml @@ -2,14 +2,6 @@ name: "@inxton/axsharp-ixc" description: "AX#Sharp twin compiler" version: 0.0.0-dev.0 type: generic -files: - - "bin/Release/net9.0/**" - - "!bin/Release/net9.0/.apax/.apax/**" -contributedCommands: - ixc: - bin: "bin/Release/net9.0/AXSharp.ixc.exe" - description: "AX#Sharp twin compiler" - hidden: false keywords: - "compiler" - "twin" @@ -21,13 +13,16 @@ homepage: "https://inxton.github.io/axsharp/articles/compiler/README.html" repository: type: "git" url: "https://github.com/Inxton/axsharp" -license: - type: "MIT" - url: "https://github.com/Inxton/axsharp/blob/dev/LICENSE" bugs: url: "https://github.com/Inxton/axsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug" -authors: - - name: "MTS spol. s r.o." - url: "https://www.mts.sk/en" - email: "team@inxton.com" - +license: "MIT" +author: "https://github.com/Inxton/axsharp/graphs/contributors" +files: + - "bin/Release/net9.0/**" + - "!bin/Release/net9.0/.apax/.apax/**" +contributedCommands: + ixc: + bin: "bin/Release/net9.0/AXSharp.ixc.exe" + description: "AX#Sharp twin compiler" + hidden: false + diff --git a/src/AXSharp.compiler/src/ixd/apax.yml b/src/AXSharp.compiler/src/ixd/apax.yml index 213e8a676..bda96d0e0 100644 --- a/src/AXSharp.compiler/src/ixd/apax.yml +++ b/src/AXSharp.compiler/src/ixd/apax.yml @@ -2,14 +2,6 @@ name: "@inxton/axsharp-ixd" description: "AX#Sharp documentation compiler" version: 0.0.0-dev.0 type: generic -files: - - "bin/Release/net9.0/**" - - "!bin/Release/net9.0/.apax/.apax/**" -contributedCommands: - ixc: - bin: "bin/Release/net9.0/AXSharp.ixd.exe" - description: "AX#Sharp documentation compiler" - hidden: false keywords: - "compiler" - "twin" @@ -17,16 +9,19 @@ keywords: - "SIMATIC-AX" - "PLC" - "IT-OT" -homepage: "https://inxton.github.io/axsharp/articles/ixd/IXD.html" +homepage: "https://inxton.github.io/axsharp/articles/compiler/README.html" repository: type: "git" url: "https://github.com/Inxton/axsharp" -license: - type: "MIT" - url: "https://github.com/Inxton/axsharp/blob/dev/LICENSE" bugs: url: "https://github.com/Inxton/axsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug" -authors: - - name: "MTS spol. s r.o." - url: "https://www.mts.sk/en" - email: "team@inxton.com" \ No newline at end of file +license: "MIT" +author: "https://github.com/Inxton/axsharp/graphs/contributors" +files: + - "bin/Release/net9.0/**" + - "!bin/Release/net9.0/.apax/.apax/**" +contributedCommands: + ixc: + bin: "bin/Release/net9.0/AXSharp.ixd.exe" + description: "AX#Sharp documentation compiler" + hidden: false diff --git a/src/AXSharp.compiler/src/ixr/apax.yml b/src/AXSharp.compiler/src/ixr/apax.yml index ae58636d2..9289a467d 100644 --- a/src/AXSharp.compiler/src/ixr/apax.yml +++ b/src/AXSharp.compiler/src/ixr/apax.yml @@ -2,6 +2,21 @@ name: "@inxton/axsharp-ixr" description: "AX#Sharp resources compiler" version: 0.0.0-dev.0 type: generic +keywords: + - "compiler" + - "twin" + - "AX#" + - "SIMATIC-AX" + - "PLC" + - "IT-OT" +homepage: "https://inxton.github.io/axsharp/articles/compiler/README.html" +repository: + type: "git" + url: "https://github.com/Inxton/axsharp" +bugs: + url: "https://github.com/Inxton/axsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug" +license: "MIT" +author: "https://github.com/Inxton/axsharp/graphs/contributors" files: - "bin/Release/net9.0/**" - "!bin/Release/net9.0/.apax/.apax/**" @@ -9,17 +24,4 @@ contributedCommands: ixc: bin: "bin/Release/net9.0/AXSharp.ixr.exe" description: "AX#Sharp resources compiler" - hidden: false -homepage: "https://inxton.github.io/axsharp/articles/ixr/IXR.html" -repository: - type: "git" - url: "https://github.com/Inxton/axsharp" -license: - type: "MIT" - url: "https://github.com/Inxton/axsharp/blob/dev/LICENSE" -bugs: - url: "https://github.com/Inxton/axsharp/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug" -authors: - - name: "MTS spol. s r.o." - url: "https://www.mts.sk/en" - email: "team@inxton.com" \ No newline at end of file + hidden: false \ No newline at end of file From 4d9d5291467faac54d0af3546b4856dc144e1ba7 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Sat, 17 May 2025 10:56:13 +0200 Subject: [PATCH 07/11] Add extraction and verification of .apax.tgz files in BuildContext --- cake/BuildContext.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cake/BuildContext.cs b/cake/BuildContext.cs index 0dc1e6e53..95b6552b4 100644 --- a/cake/BuildContext.cs +++ b/cake/BuildContext.cs @@ -268,5 +268,23 @@ public void CheckLicenseComplianceInArtifacts() Directory.Delete(ouptutDir, true); } } + + foreach (var nugetFile in Directory.EnumerateFiles(this.Artifacts, "*.apax.tgz", SearchOption.AllDirectories)) + { + using (var zip = ZipFile.OpenRead(nugetFile)) + { + var ouptutDir = Path.Combine(this.Artifacts, "verif"); + zip.ExtractToDirectory(Path.Combine(this.Artifacts, "verif")); + + if (Directory.EnumerateFiles(ouptutDir, "*.*", SearchOption.AllDirectories) + .Select(p => new FileInfo(p)) + .Any(p => licensedFiles.Any(l => l.Name == p.Name))) + { + throw new Exception(""); + } + + Directory.Delete(ouptutDir, true); + } + } } } \ No newline at end of file From 5f64e80315ff0cacd33d3ddf07090bad2e50a729 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Sat, 17 May 2025 11:24:06 +0200 Subject: [PATCH 08/11] Add error handling and improve extraction process for .apax.tgz files in BuildContext --- cake/BuildContext.cs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/cake/BuildContext.cs b/cake/BuildContext.cs index 95b6552b4..c2348bb7c 100644 --- a/cake/BuildContext.cs +++ b/cake/BuildContext.cs @@ -268,23 +268,32 @@ public void CheckLicenseComplianceInArtifacts() Directory.Delete(ouptutDir, true); } } - - foreach (var nugetFile in Directory.EnumerateFiles(this.Artifacts, "*.apax.tgz", SearchOption.AllDirectories)) + + try { - using (var zip = ZipFile.OpenRead(nugetFile)) + foreach (var apaxPackageFile in Directory.EnumerateFiles(this.Artifacts, "*.apax.tgz", SearchOption.AllDirectories)) { - var ouptutDir = Path.Combine(this.Artifacts, "verif"); - zip.ExtractToDirectory(Path.Combine(this.Artifacts, "verif")); - - if (Directory.EnumerateFiles(ouptutDir, "*.*", SearchOption.AllDirectories) - .Select(p => new FileInfo(p)) - .Any(p => licensedFiles.Any(l => l.Name == p.Name))) + using (var zip = ZipFile.OpenRead(apaxPackageFile)) { - throw new Exception(""); - } + var ouptutDir = Path.Combine(this.Artifacts, "apax-verif"); + zip.ExtractToDirectory(Path.Combine(this.Artifacts, "apax-verif")); - Directory.Delete(ouptutDir, true); + if (Directory.EnumerateFiles(ouptutDir, "*.*", SearchOption.AllDirectories) + .Select(p => new FileInfo(p)) + .Any(p => licensedFiles.Any(l => l.Name == p.Name))) + { + throw new Exception(""); + } + + Directory.Delete(ouptutDir, true); + } } } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } } \ No newline at end of file From 123aa84f5537f6a4117f9140008785fe8b7d083c Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Sat, 17 May 2025 11:34:07 +0200 Subject: [PATCH 09/11] Refactor .apax.tgz extraction process in BuildContext and update version in apax.yml files for ixr, ixh, and ixd compilers --- cake/BuildContext.cs | 32 +++++++++++++++++---------- src/AXSharp.compiler/src/ixc/apax.yml | 2 +- src/AXSharp.compiler/src/ixd/apax.yml | 2 +- src/AXSharp.compiler/src/ixr/apax.yml | 4 ++-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/cake/BuildContext.cs b/cake/BuildContext.cs index c2348bb7c..4dc88c69c 100644 --- a/cake/BuildContext.cs +++ b/cake/BuildContext.cs @@ -22,6 +22,8 @@ using Cake.Core.Diagnostics; using Cake.Core.IO; using Cake.Frosting; +using System.Formats.Tar; +using System.IO.Compression; using Polly; using static NuGet.Packaging.PackagingConstants; using Path = System.IO.Path; @@ -273,20 +275,26 @@ public void CheckLicenseComplianceInArtifacts() { foreach (var apaxPackageFile in Directory.EnumerateFiles(this.Artifacts, "*.apax.tgz", SearchOption.AllDirectories)) { - using (var zip = ZipFile.OpenRead(apaxPackageFile)) + var outputDir = Path.Combine(this.Artifacts, "apax-verif"); + // ensure clean folder + if (Directory.Exists(outputDir)) + Directory.Delete(outputDir, true); + Directory.CreateDirectory(outputDir); + + // open .tgz, gunzip it, then untar into outputDir + using var fs = File.OpenRead(apaxPackageFile); + using var gz = new GZipStream(fs, CompressionMode.Decompress); + TarFile.ExtractToDirectory(gz, outputDir, true); + + // now scan extracted files + if (Directory.EnumerateFiles(outputDir, "*.*", SearchOption.AllDirectories) + .Select(p => new FileInfo(p)) + .Any(p => licensedFiles.Any(l => l.Name == p.Name))) { - var ouptutDir = Path.Combine(this.Artifacts, "apax-verif"); - zip.ExtractToDirectory(Path.Combine(this.Artifacts, "apax-verif")); - - if (Directory.EnumerateFiles(ouptutDir, "*.*", SearchOption.AllDirectories) - .Select(p => new FileInfo(p)) - .Any(p => licensedFiles.Any(l => l.Name == p.Name))) - { - throw new Exception(""); - } - - Directory.Delete(ouptutDir, true); + throw new Exception("License violation detected in .apax.tgz"); } + + Directory.Delete(outputDir, true); } } catch (Exception e) diff --git a/src/AXSharp.compiler/src/ixc/apax.yml b/src/AXSharp.compiler/src/ixc/apax.yml index 0f57f592c..600b2a09e 100644 --- a/src/AXSharp.compiler/src/ixc/apax.yml +++ b/src/AXSharp.compiler/src/ixc/apax.yml @@ -1,6 +1,6 @@ name: "@inxton/axsharp-ixc" description: "AX#Sharp twin compiler" -version: 0.0.0-dev.0 +version : '0.30.0-add-contributed-commands.166' type: generic keywords: - "compiler" diff --git a/src/AXSharp.compiler/src/ixd/apax.yml b/src/AXSharp.compiler/src/ixd/apax.yml index bda96d0e0..c38a42c43 100644 --- a/src/AXSharp.compiler/src/ixd/apax.yml +++ b/src/AXSharp.compiler/src/ixd/apax.yml @@ -1,6 +1,6 @@ name: "@inxton/axsharp-ixd" description: "AX#Sharp documentation compiler" -version: 0.0.0-dev.0 +version : '0.30.0-add-contributed-commands.166' type: generic keywords: - "compiler" diff --git a/src/AXSharp.compiler/src/ixr/apax.yml b/src/AXSharp.compiler/src/ixr/apax.yml index 9289a467d..b11764d75 100644 --- a/src/AXSharp.compiler/src/ixr/apax.yml +++ b/src/AXSharp.compiler/src/ixr/apax.yml @@ -1,6 +1,6 @@ name: "@inxton/axsharp-ixr" description: "AX#Sharp resources compiler" -version: 0.0.0-dev.0 +version : '0.30.0-add-contributed-commands.166' type: generic keywords: - "compiler" @@ -24,4 +24,4 @@ contributedCommands: ixc: bin: "bin/Release/net9.0/AXSharp.ixr.exe" description: "AX#Sharp resources compiler" - hidden: false \ No newline at end of file + hidden: false From 6c44c6b5c547cd7adf3e056b320afd2491b065e1 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Sat, 17 May 2025 11:36:16 +0200 Subject: [PATCH 10/11] asp --- src/AXSharp.compiler/src/ixc/apax.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AXSharp.compiler/src/ixc/apax.yml b/src/AXSharp.compiler/src/ixc/apax.yml index 600b2a09e..5f056211a 100644 --- a/src/AXSharp.compiler/src/ixc/apax.yml +++ b/src/AXSharp.compiler/src/ixc/apax.yml @@ -1,6 +1,6 @@ name: "@inxton/axsharp-ixc" description: "AX#Sharp twin compiler" -version : '0.30.0-add-contributed-commands.166' +version : '0.0.0-dev.0' type: generic keywords: - "compiler" From f76975745851c443e8d571bf6b1c4319edf65d77 Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Sat, 17 May 2025 11:36:38 +0200 Subject: [PATCH 11/11] asp --- src/AXSharp.compiler/src/ixd/apax.yml | 2 +- src/AXSharp.compiler/src/ixr/apax.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AXSharp.compiler/src/ixd/apax.yml b/src/AXSharp.compiler/src/ixd/apax.yml index c38a42c43..0244cdb50 100644 --- a/src/AXSharp.compiler/src/ixd/apax.yml +++ b/src/AXSharp.compiler/src/ixd/apax.yml @@ -1,6 +1,6 @@ name: "@inxton/axsharp-ixd" description: "AX#Sharp documentation compiler" -version : '0.30.0-add-contributed-commands.166' +version : '0.0.0-dev.0' type: generic keywords: - "compiler" diff --git a/src/AXSharp.compiler/src/ixr/apax.yml b/src/AXSharp.compiler/src/ixr/apax.yml index b11764d75..691311f63 100644 --- a/src/AXSharp.compiler/src/ixr/apax.yml +++ b/src/AXSharp.compiler/src/ixr/apax.yml @@ -1,6 +1,6 @@ name: "@inxton/axsharp-ixr" description: "AX#Sharp resources compiler" -version : '0.30.0-add-contributed-commands.166' +version : '0.0.0-dev.0' type: generic keywords: - "compiler"