ScriptCollection 4.2.144__py3-none-any.whl → 4.2.145__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -437,17 +437,16 @@ def PrintFileContent() -> int:
437
437
  parser.add_argument('-e', '--encoding', required=False, default="utf-8")
438
438
  parser.add_argument('-b', '--basefolder', required=False, default=".", help="Base-folder the excludedfolder-entries are relative to. Defaults to the current working-directory.")
439
439
  parser.add_argument('-x', '--excludedfolder', action='append', default=[], help="A folder (relative to basefolder) whose files must not be read. Can be specified multiple times. Example: --excludedfolder .git --excludedfolder .claude --excludedfolder Other/Secrets")
440
+ parser.add_argument('-f', '--fromline', required=False, default=None, type=int, help="1-based line-number to start printing from (inclusive). Defaults to the first line.")
441
+ parser.add_argument('-t', '--toline', required=False, default=None, type=int, help="1-based line-number to stop printing at (inclusive). Defaults to the last line.")
440
442
  args = parser.parse_args()
441
443
  file = args.path
442
444
  encoding = args.encoding
443
- if not os.path.isfile(file):
444
- GeneralUtilities.write_exception_to_stderr(f"File '{file}' does not exist.")
445
- return 1
446
445
  sc = ScriptCollectionCore()
447
- if sc.path_is_inside_one_of_the_folders(file, args.basefolder, args.excludedfolder):
448
- GeneralUtilities.write_message_to_stderr(f"Reading '{file}' is not allowed because it is located inside an excluded folder.")
446
+ if not sc.path_is_allowed_within_base_folder(file, args.basefolder, args.excludedfolder):
447
+ GeneralUtilities.write_message_to_stderr(f"Reading '{file}' is not allowed because it is not located inside the base-folder or it is located inside an excluded folder.")
449
448
  return 1
450
- GeneralUtilities.write_message_to_stdout(GeneralUtilities.read_text_from_file(file, encoding))
449
+ GeneralUtilities.write_message_to_stdout(sc.get_file_content(file, encoding, args.fromline, args.toline))
451
450
  return 0
452
451
 
453
452
 
@@ -473,6 +472,22 @@ def CreateFolder() -> int:
473
472
  return 0
474
473
 
475
474
 
475
+ def CreateSkill() -> int:
476
+ parser = argparse.ArgumentParser(description="Creates a skill ('skills/<name>/' with a lightweight 'skill.json' and a lazy-loaded 'detail.md'). The skill is created in the given repository-folder, or - if none is given - in the current working-directory when that is a git-repository, otherwise in the user's ScriptCollection-configuration-folder.")
477
+ parser.add_argument('-n', '--name', required=True, help='Name of the skill.')
478
+ parser.add_argument('-d', '--description', required=True, help='Description of the skill.')
479
+ parser.add_argument('-r', '--repositoryfolder', required=False, default=None, help='Repository-folder to create the skill in. Defaults to the current git-repository or the user-folder.')
480
+ parser.add_argument('-t', '--tags', required=False, default=None, help='Comma-separated list of tags.')
481
+ parser.add_argument('-p', '--priority', required=False, default=None, help='Priority of the skill (e.g. "high", "medium", "low").')
482
+ parser.add_argument('-g', '--triggers', required=False, default=None, help='Comma-separated list of triggers.')
483
+ args = parser.parse_args()
484
+ tags = [tag.strip() for tag in args.tags.split(",") if tag.strip() != GeneralUtilities.empty_string] if args.tags is not None else []
485
+ triggers = [trigger.strip() for trigger in args.triggers.split(",") if trigger.strip() != GeneralUtilities.empty_string] if args.triggers is not None else []
486
+ skill_folder = ScriptCollectionCore().create_skill(args.name, args.description, args.repositoryfolder, tags, args.priority, triggers)
487
+ GeneralUtilities.write_message_to_stdout(skill_folder)
488
+ return 0
489
+
490
+
476
491
  def AppendLineToFile() -> int:
477
492
  parser = argparse.ArgumentParser(description="Appends a line to a file. By default a leading newline is inserted before the line and a trailing newline after it (POSIX-line-ended files).")
478
493
  parser.add_argument('-p', '--path', required=True)
@@ -0,0 +1 @@
1
+ 21.0.6+7
@@ -38,7 +38,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
38
38
  from .ProgramRunnerPopen import ProgramRunnerPopen
39
39
  from .SCLog import SCLog, LogLevel
40
40
 
41
- version = "4.2.144"
41
+ version = "4.2.145"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -1102,14 +1102,7 @@ class ScriptCollectionCore:
1102
1102
  return False
1103
1103
  raise ValueError(f"Fatal error occurrs while checking whether folder '{path}' exists. StdErr: '{stderr}'")
1104
1104
 
1105
- @GeneralUtilities.check_arguments
1106
- def get_file_content(self, path: str, encoding: str = "utf-8") -> str:
1107
- """This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
1108
- if self.program_runner.will_be_executed_locally():
1109
- return GeneralUtilities.read_text_from_file(path, encoding)
1110
- else:
1111
- result = self.run_program_argsasarray("scprintfilecontent", ["--path", path, "--encofing", encoding]) # works platform-indepent
1112
- return result[1].replace("\\n", "\n")
1105
+
1113
1106
 
1114
1107
  @GeneralUtilities.check_arguments
1115
1108
  def set_file_content(self, path: str, content: str, encoding: str = "utf-8") -> None:
@@ -1181,6 +1174,50 @@ class ScriptCollectionCore:
1181
1174
  if exit_code != 0:
1182
1175
  raise ValueError(f"Fatal error occurrs while copying '{source}' to '{target}'; Exitcode: '{exit_code}'; StdOut: '{stdout}'. StdErr: '{stderr}'")
1183
1176
 
1177
+ @GeneralUtilities.check_arguments
1178
+ def get_file_content(self, file: str, encoding: str = "utf-8", from_line: int = None, to_line: int = None) -> str:
1179
+ """Returns the content of the file. With from_line and/or to_line (both 1-based and inclusive) the returned
1180
+ content can be restricted to a range of lines."""
1181
+ content = GeneralUtilities.read_text_from_file(file, encoding)
1182
+ if from_line is None and to_line is None:
1183
+ return content
1184
+ lines = content.splitlines()
1185
+ start_index = 0 if from_line is None else max(from_line - 1, 0)
1186
+ end_index = len(lines) if to_line is None else min(to_line, len(lines))
1187
+ return "\n".join(lines[start_index:end_index])
1188
+
1189
+ @GeneralUtilities.check_arguments
1190
+ def create_skill(self, skill_name: str, description: str, repository_folder: str = None, tags: list[str] = None, priority: str = None, triggers: list[str] = None) -> str:
1191
+ """Generates a skill-folder ('skills/<skill_name>/' with a lightweight 'skill.json' and a lazy-loaded 'detail.md').
1192
+ The skill is created in the given repository-folder, or - if none is given - in the current working-directory when
1193
+ that is a git-repository, otherwise in the user's ScriptCollection-configuration-folder. Returns the skill-folder."""
1194
+ if tags is None:
1195
+ tags = []
1196
+ if triggers is None:
1197
+ triggers = []
1198
+ if priority is None:
1199
+ priority = "medium"
1200
+ if repository_folder is not None:
1201
+ base_folder = repository_folder
1202
+ elif self.is_git_repository(os.getcwd()):
1203
+ base_folder = os.getcwd()
1204
+ else:
1205
+ base_folder = GeneralUtilities.get_scriptcollection_configuration_folder()
1206
+ skill_folder = os.path.join(base_folder, "skills", skill_name)
1207
+ GeneralUtilities.ensure_directory_exists(skill_folder)
1208
+ skill_definition = {
1209
+ "name": skill_name,
1210
+ "description": description,
1211
+ "triggers": triggers,
1212
+ "tags": tags,
1213
+ "priority": priority,
1214
+ }
1215
+ GeneralUtilities.write_text_to_file(os.path.join(skill_folder, "skill.json"), json.dumps(skill_definition, indent=2))
1216
+ detail_file = os.path.join(skill_folder, "detail.md")
1217
+ detail_content = f"# {skill_name}\n\n{description}\n\n## Details\n\n<!-- Add the detailed (lazy-loaded) instructions for this skill here. -->\n"
1218
+ GeneralUtilities.write_text_to_file(detail_file, detail_content)
1219
+ return skill_folder
1220
+
1184
1221
  @GeneralUtilities.check_arguments
1185
1222
  def create_file(self, path: str, error_if_already_exists: bool, create_necessary_folder: bool) -> None:
1186
1223
  """This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
@@ -2064,36 +2101,44 @@ class ScriptCollectionCore:
2064
2101
  return self.run_program_argsasarray(program, GeneralUtilities.arguments_to_array(arguments), working_directory, print_errors_as_information, log_file, timeoutInSeconds, addLogOverhead, title, log_namespace, GeneralUtilities.arguments_to_array(arguments_for_log), throw_exception_if_exitcode_is_not_zero, custom_argument, interactive, print_live_output, env_vars)
2065
2102
 
2066
2103
  @GeneralUtilities.check_arguments
2067
- def path_is_inside_one_of_the_folders(self, path: str, base_folder: str, folders: list[str]) -> bool:
2068
- """Returns whether path (a file or folder) is equal to or located inside one of the given folders. path and base_folder are resolved against the current working-directory; the entries of folders must be relative to base_folder."""
2069
- resolved_path = GeneralUtilities.resolve_relative_path(path, os.getcwd())
2104
+ def path_is_allowed_within_base_folder(self, path: str, base_folder: str, excluded_folders: list[str]) -> bool:
2105
+ """Returns True if and only if 'path' is located within 'base_folder' (equal to 'base_folder' or a subpath of it)
2106
+ AND 'path' is NOT located within any of the 'excluded_folders' (neither equal to nor a subpath of any of them).
2107
+ Returns False if 'path' is outside 'base_folder', or if 'path' is equal to or located inside one of the
2108
+ 'excluded_folders'.
2109
+ Path-resolution: a relative 'base_folder' is resolved against the current working-directory; a relative 'path' and
2110
+ relative entries of 'excluded_folders' are resolved against 'base_folder'."""
2070
2111
  resolved_base_folder = GeneralUtilities.resolve_relative_path(base_folder, os.getcwd())
2071
- normalized_path = os.path.normcase(os.path.normpath(resolved_path))
2112
+ resolved_path = GeneralUtilities.resolve_relative_path(path, resolved_base_folder)
2072
2113
  normalized_base_folder = os.path.normcase(os.path.normpath(resolved_base_folder))
2073
- for folder in folders:
2074
- if os.path.isabs(folder):
2075
- raise ValueError(f"The folder '{folder}' must be relative to the base-folder, but it is an absolute path.")
2076
- normalized_folder = os.path.normcase(os.path.normpath(os.path.join(normalized_base_folder, folder)))
2077
- if normalized_path == normalized_folder or normalized_path.startswith(normalized_folder + os.sep):
2078
- return True
2079
- return False
2114
+ normalized_path = os.path.normcase(os.path.normpath(resolved_path))
2115
+ # 1. path must be equal to or located inside base_folder
2116
+ if not (normalized_path == normalized_base_folder or normalized_path.startswith(normalized_base_folder + os.sep)):
2117
+ return False
2118
+ # 2. path must not be equal to or located inside any excluded folder
2119
+ for excluded_folder in excluded_folders:
2120
+ resolved_excluded_folder = GeneralUtilities.resolve_relative_path(excluded_folder, resolved_base_folder)
2121
+ normalized_excluded_folder = os.path.normcase(os.path.normpath(resolved_excluded_folder))
2122
+ if normalized_path == normalized_excluded_folder or normalized_path.startswith(normalized_excluded_folder + os.sep):
2123
+ return False
2124
+ # 3. path is inside base_folder and not inside any excluded folder
2125
+ return True
2080
2126
 
2081
2127
  @GeneralUtilities.check_arguments
2082
2128
  def run_command_in_folder(self, base_folder: str, command: str, arguments: str, actual_folder: str, excluded_folders: list[str] = None) -> int:
2083
- """Runs the given command with the given arguments in base_folder, but only if actual_folder is equal to base_folder or a subfolder of it and not located inside one of the excluded_folders. The entries of excluded_folders must be relative to base_folder. actual_folder can be used in arguments by using the placeholder "{actual_folder}"."""
2129
+ """Runs the given command with the given arguments in base_folder, but only if actual_folder is allowed according to
2130
+ path_is_allowed_within_base_folder, i.e. actual_folder is equal to base_folder or a subfolder of it and is not located
2131
+ inside one of the excluded_folders. A relative base_folder is resolved against the current working-directory; a
2132
+ relative actual_folder and relative entries of excluded_folders are resolved against base_folder. actual_folder can be
2133
+ used in arguments by using the placeholder "{actual_folder}"."""
2084
2134
  if excluded_folders is None:
2085
2135
  excluded_folders = []
2086
- resolved_actual_folder = GeneralUtilities.resolve_relative_path(actual_folder, os.getcwd())
2087
- base_folder = GeneralUtilities.resolve_relative_path(base_folder, os.getcwd())
2088
- normalized_actual_folder = os.path.normcase(os.path.normpath(resolved_actual_folder))
2089
- normalized_base_folder = os.path.normcase(os.path.normpath(base_folder))
2090
- actual_folder_is_allowed = normalized_actual_folder == normalized_base_folder or normalized_actual_folder.startswith(normalized_base_folder + os.sep)
2091
- if not actual_folder_is_allowed:
2092
- raise ValueError(f"The folder '{resolved_actual_folder}' is not allowed because it is neither equal to nor a subfolder of the allowed folder '{base_folder}'.")
2093
- if self.path_is_inside_one_of_the_folders(actual_folder, base_folder, excluded_folders):
2094
- raise ValueError(f"The folder '{resolved_actual_folder}' is not allowed because it is located inside one of the excluded folders (relative to the base-folder '{base_folder}').")
2136
+ resolved_base_folder = GeneralUtilities.resolve_relative_path(base_folder, os.getcwd())
2137
+ resolved_actual_folder = GeneralUtilities.resolve_relative_path(actual_folder, resolved_base_folder)
2138
+ if not self.path_is_allowed_within_base_folder(actual_folder, base_folder, excluded_folders):
2139
+ raise ValueError(f"The folder '{resolved_actual_folder}' is not allowed: it must be equal to or a subfolder of the base-folder '{resolved_base_folder}' and must not be located inside one of the excluded folders.")
2095
2140
  effective_arguments = arguments.replace(ScriptCollectionCore.run_command_in_folder_actual_folder_placeholder, resolved_actual_folder)
2096
- result = self.run_program(command, effective_arguments, base_folder)
2141
+ result = self.run_program(command, effective_arguments, resolved_base_folder)
2097
2142
  return result[0]
2098
2143
 
2099
2144
  # Return-values program_runner: Exitcode, StdOut, StdErr, Pid
@@ -35,6 +35,12 @@ class TFCPS_CodeUnitSpecific_NodeJS_Functions(TFCPS_CodeUnitSpecific_Base):
35
35
  self._protected_sc.normalize_line_endings(scss_file)
36
36
  for sass_file in self._protected_sc.get_not_git_ignored_files_of_folder(codeunit_folder, ".sass"):
37
37
  self._protected_sc.normalize_line_endings(sass_file)
38
+ # The OpenAPI-generator writes its '.openapi-generator/FILES' metadata-file with the host's native
39
+ # line-endings (CRLF on Windows, LF on Linux). Normalize it to LF like the other generated text-files
40
+ # so the committed file does not drift between build-hosts.
41
+ for openapi_generator_files_file in self._protected_sc.get_not_git_ignored_files_of_folder(codeunit_folder):
42
+ if os.path.basename(openapi_generator_files_file) == "FILES" and os.path.basename(os.path.dirname(openapi_generator_files_file)) == ".openapi-generator":
43
+ self._protected_sc.normalize_line_endings(openapi_generator_files_file)
38
44
  for html_file in self._protected_sc.get_not_git_ignored_files_of_folder(codeunit_folder, ".html"):
39
45
  self._protected_sc.format_html_file(html_file, os.path.basename(html_file) == "index.html")
40
46
  self._protected_sc.run_with_epew("npm", "run lint", codeunit_folder,print_live_output=self.get_verbosity()==LogLevel.Debug,encode_argument_in_base64=True)
@@ -224,8 +224,18 @@ class TFCPS_CodeUnitSpecific_Base(ABC):
224
224
  # Copy license-file
225
225
  self.tfcps_Tools_General.copy_licence_file(self.get_codeunit_folder())
226
226
 
227
- # Generate diff-report
228
- self.tfcps_Tools_General.generate_diff_report(repository_folder, codeunit_name, self.tfcps_Tools_General.get_version_of_codeunit(self.get_codeunit_file()))
227
+ # Propagate the repository-level dependency-version-pins (e.g. PlantUML, OpenAPIGenerator, JRE) into the codeunit
228
+ # so each codeunit carries its own copy of the versions that are defined once at repository-level.
229
+ repository_dependencies_folder = os.path.join(repository_folder, "Other", "Resources", "Dependencies")
230
+ if os.path.isdir(repository_dependencies_folder):
231
+ for dependency_folder in GeneralUtilities.get_direct_folders_of_folder(repository_dependencies_folder):
232
+ dependency_name = os.path.basename(dependency_folder)
233
+ source_version_file = os.path.join(dependency_folder, "Version.txt")
234
+ if os.path.isfile(source_version_file):
235
+ target_version_file = os.path.join(codeunit_folder, "Other", "Resources", "Dependencies", dependency_name, "Version.txt")
236
+ GeneralUtilities.ensure_directory_exists(os.path.dirname(target_version_file))
237
+ shutil.copyfile(source_version_file, target_version_file)
238
+
229
239
 
230
240
  @GeneralUtilities.check_arguments
231
241
  def generate_reference_using_docfx(self):
@@ -85,9 +85,13 @@ class TFCPS_CodeUnit_BuildCodeUnit:
85
85
  self.sc.log.log('Finalize building codeunits...')
86
86
  self.sc.run_program(GeneralUtilities.get_python_executable(), f"OnBuildingFinished.py {arguments}", os.path.join(self.codeunit_folder, "Other"), print_live_output=self.sc.log.loglevel==LogLevel.Debug)
87
87
 
88
+ codeunit_version = self.tFCPS_Tools.get_version_of_codeunit(codeunit_file)
89
+
90
+ # Generate diff-report
91
+ self.tFCPS_Tools.generate_diff_report(self.repository_folder, self.codeunit_name, codeunit_version)
92
+
88
93
  artifacts_folder = os.path.join(self.codeunit_folder, "Other", "Artifacts")
89
94
  artifactsinformation_file = os.path.join(artifacts_folder, f"{self.codeunit_name}.artifactsinformation.xml")
90
- codeunit_version = self.tFCPS_Tools.get_version_of_codeunit(codeunit_file)
91
95
  GeneralUtilities.ensure_file_exists(artifactsinformation_file)
92
96
  artifacts_list = []
93
97
  for artifact_folder in GeneralUtilities.get_direct_folders_of_folder(artifacts_folder):
@@ -36,6 +36,17 @@ class TFCPS_Tools_General:
36
36
  __default_diagram_font_name:str="DejaVu Sans"
37
37
  # Font-files (all faces of the diagram-font) bundled with the package and forced via the JVM-font-path when rendering.
38
38
  __bundled_diagram_font_filenames:list[str]=["DejaVuSans.ttf","DejaVuSans-Bold.ttf","DejaVuSans-Oblique.ttf","DejaVuSans-BoldOblique.ttf"]
39
+ # Relative path (in the source-repository and in the ScriptCollection.Resources-package) of the file that pins the
40
+ # default Eclipse-Temurin-JRE-version used to render the PlantUML-diagrams when a repository does not pin its own
41
+ # version in '<repo>/Other/Resources/Dependencies/JRE/Version.txt'. The file contains a build like "21.0.6+7" (the
42
+ # feature-version is derived from it). Pinning the exact JDK-build (not just the major-version) makes the AWT-font-
43
+ # metrics - and thus the computed SVG-geometry - byte-identical across machines: PlantUML computes the SVG purely as
44
+ # vector-math from the font-metrics, and different JDK-builds (e.g. a Windows-client vs. the Debian-build-container)
45
+ # round these metrics slightly differently. Together with the bundled DejaVu-font (see __default_diagram_font_name)
46
+ # this makes the rendered SVG fully deterministic. The PlantUML-rendering uses this pinned JRE instead of the host's
47
+ # 'java' on the PATH. When the pinned version is bumped, the committed diagram-SVGs must be regenerated and re-committed
48
+ # once so they match the new build's metrics.
49
+ __jre_version_resource_relative_path:str="Dependencies/JRE/Version.txt"
39
50
 
40
51
  def __init__(self,sc:ScriptCollectionCore):
41
52
  self.__sc=sc
@@ -88,6 +99,7 @@ class TFCPS_Tools_General:
88
99
  self.__sc.log.loglevel = LogLevel.Debug
89
100
  self.download_cyclonedx(enforce_update)
90
101
  self.download_plantuml(enforce_update)
102
+ self.download_jre(enforce_update)
91
103
  self.download_mediamtx(enforce_update)
92
104
  self.download_trufflehog(enforce_update)
93
105
  self.download_openapigenerator(enforce_update)
@@ -103,6 +115,13 @@ class TFCPS_Tools_General:
103
115
  self.__sc.log.log("Download cachable tool \"PlantUML\" into global cache...", LogLevel.Debug)
104
116
  self.ensure_plantuml_is_available(enforce_update)
105
117
 
118
+ @GeneralUtilities.check_arguments
119
+ def download_jre(self, enforce_update: bool = False) -> None:
120
+ self.__sc.log.log("Download cachable tool \"JRE\" into global cache...", LogLevel.Debug)
121
+ # Only the executing platform is warmed (unlike e.g. MediaMTX): a JDK-archive is large (~200MB), and the
122
+ # build-image is built per-platform, so warming foreign platforms would only bloat the image without benefit.
123
+ self.ensure_jre_is_available(enforce_update)
124
+
106
125
  @GeneralUtilities.check_arguments
107
126
  def download_mediamtx(self, enforce_update: bool = False) -> None:
108
127
  self.__sc.log.log("Download cachable tool \"MediaMTX\" into global cache...", LogLevel.Debug)
@@ -626,15 +645,17 @@ class TFCPS_Tools_General:
626
645
  self.__sc.log.log("Generate svg-files from plantuml-files...")
627
646
  self.__sc.assert_is_git_repository(repository_folder)
628
647
  plantuml_jar_file=self.ensure_plantuml_is_available(not use_cache, repository_folder)
648
+ java_executable=self.ensure_jre_is_available(not use_cache, repository_folder)
629
649
  target_folder = os.path.join(repository_folder, "Other", "Reference")
630
- self.__generate_svg_files_from_plantuml(target_folder, plantuml_jar_file)
650
+ self.__generate_svg_files_from_plantuml(target_folder, plantuml_jar_file, java_executable)
631
651
 
632
652
  @GeneralUtilities.check_arguments
633
653
  def generate_svg_files_from_plantuml_files_for_codeunit(self, codeunit_folder: str,use_cache:bool) -> None:
634
654
  self.assert_is_codeunit_folder(codeunit_folder)
635
655
  plantuml_jar_file=self.ensure_plantuml_is_available(not use_cache, os.path.dirname(codeunit_folder))
656
+ java_executable=self.ensure_jre_is_available(not use_cache, os.path.dirname(codeunit_folder))
636
657
  target_folder = os.path.join(codeunit_folder, "Other", "Reference")
637
- self.__generate_svg_files_from_plantuml(target_folder, plantuml_jar_file)
658
+ self.__generate_svg_files_from_plantuml(target_folder, plantuml_jar_file, java_executable)
638
659
 
639
660
  @GeneralUtilities.check_arguments
640
661
  def ensure_plantuml_is_available(self, enforce_update: bool, repository_folder: str = None) -> str:
@@ -646,7 +667,91 @@ class TFCPS_Tools_General:
646
667
  return self.ensure_file_from_github_assets_is_available_with_retry("plantuml", "plantuml", "PlantUML", "plantuml.jar", lambda latest_version: "plantuml.jar", enforce_update=enforce_update, pinned_version=pinned_version)
647
668
 
648
669
  @GeneralUtilities.check_arguments
649
- def __generate_svg_files_from_plantuml(self, diagrams_files_folder: str, plantuml_jar_file: str) -> None:
670
+ def get_default_jre_version(self) -> str:
671
+ """Returns the JRE-version used when a repository does not pin its own version (see
672
+ __jre_version_resource_relative_path). The value is read from the version-file bundled with the
673
+ ScriptCollection-package, with a fallback to the source-file for an unbuilt source-checkout."""
674
+ try:
675
+ content = GeneralUtilities._internal_load_resource(TFCPS_Tools_General.__jre_version_resource_relative_path)
676
+ return content.decode("utf-8").strip()
677
+ except (FileNotFoundError, ModuleNotFoundError):
678
+ source_version_file = GeneralUtilities.resolve_relative_path(f"../../../Other/Resources/{TFCPS_Tools_General.__jre_version_resource_relative_path}", os.path.dirname(__file__))
679
+ GeneralUtilities.assert_file_exists(source_version_file)
680
+ return GeneralUtilities.read_text_from_file(source_version_file).strip()
681
+
682
+ @GeneralUtilities.check_arguments
683
+ def get_jre_version(self, repository_folder: str = None) -> str:
684
+ """Resolves the JRE-version to use: the repository-specific pin in '<repo>/Other/Resources/Dependencies/JRE/Version.txt'
685
+ if present, otherwise the default bundled with ScriptCollection (see get_default_jre_version)."""
686
+ if repository_folder is not None:
687
+ version_file = os.path.join(repository_folder, "Other", "Resources", "Dependencies", "JRE", "Version.txt")
688
+ if os.path.isfile(version_file):
689
+ return GeneralUtilities.read_text_from_file(version_file).strip()
690
+ return self.get_default_jre_version()
691
+
692
+ @GeneralUtilities.check_arguments
693
+ def ensure_jre_is_available(self, enforce_update: bool, repository_folder: str = None) -> str:
694
+ """Ensures the pinned JDK is available in the global cache for the executing platform and returns the absolute path
695
+ to its 'java'-executable. The version is the repository-specific pin if present, otherwise the bundled default (see
696
+ get_jre_version). Pinning the exact build makes the PlantUML-rendering deterministic across machines."""
697
+ local_resource_name = "JRE"
698
+ jre_version = self.get_jre_version(repository_folder)
699
+ feature_version = jre_version.split(".")[0] # e.g. "21" from "21.0.6+7"
700
+ pinned_tag = "jdk-" + jre_version
701
+ if GeneralUtilities.current_system_is_x64():
702
+ architecture_token = "x64"
703
+ elif GeneralUtilities.current_system_is_arm64():
704
+ architecture_token = "aarch64"
705
+ else:
706
+ raise ValueError("Unsupported architecture for the pinned JRE.")
707
+ if GeneralUtilities.current_system_is_windows():
708
+ operatingsystem_token = "windows"
709
+ archive_extension = "zip"
710
+ java_executable_name = "java.exe"
711
+ elif GeneralUtilities.current_system_is_linux():
712
+ operatingsystem_token = "linux"
713
+ archive_extension = "tar.gz"
714
+ java_executable_name = "java"
715
+ else: # treat everything else as macOS (Darwin); Temurin uses the "mac"-token there.
716
+ operatingsystem_token = "mac"
717
+ archive_extension = "tar.gz"
718
+ java_executable_name = "java"
719
+
720
+ def get_asset_filename(release_tag: str) -> str:
721
+ # release_tag looks like "jdk-21.0.6+7"; the Adoptium-asset-name uses the version with the build-separator '+' replaced by '_'.
722
+ version_in_asset = release_tag[len("jdk-"):].replace("+", "_")
723
+ return f"OpenJDK{feature_version}U-jdk_{architecture_token}_{operatingsystem_token}_hotspot_{version_in_asset}.{archive_extension}"
724
+
725
+ extracted_folder = os.path.join(self.__sc.get_global_cache_folder(), "Tools", local_resource_name)
726
+ unextracted_resource_name = local_resource_name + "_Unextracted"
727
+ marker_file = os.path.join(extracted_folder, "PinnedVersion.txt")
728
+ cached_pinned_tag: str = None
729
+ if os.path.isfile(marker_file):
730
+ cached_pinned_tag = GeneralUtilities.read_text_from_file(marker_file).strip()
731
+ update: bool = enforce_update or not os.path.isdir(extracted_folder) or GeneralUtilities.folder_is_empty(extracted_folder) or cached_pinned_tag != pinned_tag
732
+ if update:
733
+ downloaded_archive = self.ensure_file_from_github_assets_is_available_with_retry("adoptium", f"temurin{feature_version}-binaries", unextracted_resource_name, get_asset_filename(pinned_tag), get_asset_filename, enforce_update=enforce_update, pinned_version=pinned_tag)
734
+ GeneralUtilities.ensure_folder_exists_and_is_empty(extracted_folder)
735
+ if archive_extension == "zip":
736
+ with zipfile.ZipFile(downloaded_archive, "r") as zip_ref:
737
+ zip_ref.extractall(extracted_folder)
738
+ else:
739
+ with tarfile.open(downloaded_archive, "r:gz") as tar:
740
+ tar.extractall(path=extracted_folder)
741
+ GeneralUtilities.ensure_directory_does_not_exist(os.path.join(self.__sc.get_global_cache_folder(), "Tools", unextracted_resource_name))
742
+ GeneralUtilities.write_text_to_file(marker_file, pinned_tag)
743
+ GeneralUtilities.assert_folder_exists(extracted_folder)
744
+ # The archive extracts into a top-level folder (e.g. "jdk-21.0.6+7"); locate the 'java'-executable inside its 'bin'-folder.
745
+ java_executable_candidates = [f for f in GeneralUtilities.get_all_files_of_folder(extracted_folder) if os.path.basename(f) == java_executable_name and os.path.basename(os.path.dirname(f)) == "bin"]
746
+ if len(java_executable_candidates) == 0:
747
+ raise ValueError(f"Could not locate the '{java_executable_name}'-executable inside the extracted JRE at '{extracted_folder}'.")
748
+ java_executable = java_executable_candidates[0]
749
+ if not GeneralUtilities.current_system_is_windows():
750
+ os.chmod(java_executable, 0o755)
751
+ return java_executable
752
+
753
+ @GeneralUtilities.check_arguments
754
+ def __generate_svg_files_from_plantuml(self, diagrams_files_folder: str, plantuml_jar_file: str, java_executable: str) -> None:
650
755
  # Pin the font for all rendered diagrams via a PlantUML-config-file so the resulting SVG is identical across
651
756
  # machines, without having to add a skinparam to every (also hand-written) .plantuml-file. See the comment at
652
757
  # __default_diagram_font_name for the reason.
@@ -666,7 +771,7 @@ class TFCPS_Tools_General:
666
771
  output_filename = self.get_output_filename_for_plantuml_filename(file)
667
772
  argument = java_font_arguments + ['-jar',plantuml_jar_file, '-tsvg', '-config', font_config_file, os.path.basename(file)]
668
773
  folder = os.path.dirname(file)
669
- self.__sc.run_program_argsasarray("java", argument, folder)
774
+ self.__sc.run_program_argsasarray(java_executable, argument, folder)
670
775
  result_file = folder+"/" + output_filename
671
776
  GeneralUtilities.assert_file_exists(result_file)
672
777
  self.__sc.format_xml_file(result_file)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.144
3
+ Version: 4.2.145
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Author-email: Marius Göcke <marius.goecke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
@@ -1,6 +1,6 @@
1
1
  ScriptCollection/AnionBuildPlatform.py,sha256=vg1lZ6D1nqq_mO7iYTDSktSImXd34scfPaXiIrbvrg0,11848
2
2
  ScriptCollection/CertificateUpdater.py,sha256=dR5JpJDlZdjD4_pgMz7zCrt1IM7VfatmK6pULSczxQw,9693
3
- ScriptCollection/Executables.py,sha256=TkAzd2_nfRdqiUR_QG2uGFcdbxOqpmslJBpOiBZcz0M,61938
3
+ ScriptCollection/Executables.py,sha256=O6REf3ricZVtAg-Z0isUxEpItqqH-pfIxK3BMfWMzaA,63861
4
4
  ScriptCollection/GeneralUtilities.py,sha256=cJK18rWzmVT3KyvjIAbPK4o4-jVPwYeuVpizbTHjBDc,68136
5
5
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
6
6
  ScriptCollection/ProcessesRunner.py,sha256=yYaC95h40uszuZPggn2kK3qXIN2ZjGMCavo-NQ53ElQ,1537
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=8tP0xWKeRYoGlaNB3iUh4o61O-tKtcxrS7IUqtU85C4,4091
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
11
11
  ScriptCollection/SCLog.py,sha256=Z-HhC_CRtU3HdQflNsabFh9IJOucHcXmxMDcf58fli0,4671
12
- ScriptCollection/ScriptCollectionCore.py,sha256=htJ5Wtqc0mffscRMF9ah77UX1RwuZ73XyIpeyyX3ab0,217549
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=4PXLjavMAOg2MZdug1yeYfBrz8ProHNLn8FgYUE5ENE,219953
13
13
  ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
14
14
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=o129UYDtLymCRjMZBP9Puaj19ueMHoNt6UTLspfnaRc,1758
@@ -24,6 +24,7 @@ ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerGitlabEE.py,sha256=
24
24
  ScriptCollection/OCIImages/ConcreteImageHandlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  ScriptCollection/Resources/CultureChooser/CultureChooser.js,sha256=5-4pwGDq5j1UnpTZy850ZMoxlM9tYPeu781QpZBtCWM,951
26
26
  ScriptCollection/Resources/CultureChooser/index.html,sha256=gxQzbrSp4WU52TqN-gcBEtz2gJXmmM14OwTSFtFVRvw,276
27
+ ScriptCollection/Resources/Dependencies/JRE/Version.txt,sha256=WlFzNJMH4lfVzW5QGHnuE52jLujSGpQ48zVB-Cln-7g,9
27
28
  ScriptCollection/Resources/Dependencies/OpenAPIGenerator/Version.txt,sha256=hdAgOhOHx4s13fJ-j0A06oYoM9rdEfDe0RzHoeAKXxo,7
28
29
  ScriptCollection/Resources/Fonts/DejaVuSans-Bold.ttf,sha256=5kdsG4BQKSQpTu1AiUxbGOBsGBREypU-UzQmLfnCdyQ,705684
29
30
  ScriptCollection/Resources/Fonts/DejaVuSans-BoldOblique.ttf,sha256=60NtygwllLc9i2A7iS43T9_Y2IXSX_tPGN9MTAtJ5Q8,643292
@@ -31,15 +32,15 @@ ScriptCollection/Resources/Fonts/DejaVuSans-Oblique.ttf,sha256=SvdfoW7m061D4ezsQ
31
32
  ScriptCollection/Resources/Fonts/DejaVuSans.ttf,sha256=faGVp0xVvvmI0NSPlQi9XYSUJcF3Dbpde_xs6e2EiVQ,757076
32
33
  ScriptCollection/Resources/Fonts/LICENSE.txt,sha256=egg7E25k0GR5TDQZdR5cfdENL2TBCP5boWHq5eWVipM,8816
33
34
  ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz6xU2aGfr03tJRGczQrlpn-IeODc15d5kc0,232
34
- ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=sWnTspNrdwWFuPNX0dCZYFv7U0ggtUL_-iYqToaYSV4,28896
35
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=WT4IzlzBaY46ogBeT2rvm_TnOE7HMw-cchJyTlmH5Og,9412
35
+ ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=ph66XVh1rsiIyTabkHVGQWoz38j5hUp9v7u7-naTyeo,29756
36
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=4PH3PGdc9Jf3B71Ws0z6E3cobifhgaXwhe750ag2RJs,9565
36
37
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=cScWO7n89Gbs3au8U_EczJO53jZx6NFzpm7c46IqO_Q,23733
37
38
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=X2NgZgbOkJsdZ6wMHB_RuS_rQCuz5oQCqzYrxyXBN9Q,6680
38
39
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=5vCFfDiU8bvfcnoKNs2ATS8nsl6mYXcIuX7XfYE0tvg,2116
39
40
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=BsSV4a-NZY86MZ20d-_rYxNVAI4UzAfmEwXlRZ8qWQc,7685
40
41
  ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=QRm8n1qH8H_XbJhGCbzwdNr9KSEy0WkbG7ulpc4Md3U,22696
41
42
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=JYiDqDsfVJQWS9xWMi_UzfXnXsJRnPRxAzFr82bUEvI,2370
42
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=OG8ormUnJ65jDyin7HSLISyKEK9nKXhUI1LNdC1rTUs,118314
43
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=_L84d4krR2dlZBj1E1j3wsHu7fc01BDw_LfwKDmRjS4,126256
43
44
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
45
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=wS2yzYUmJ4m0cf6cBYVTHsiXSXfYhHoLFFy8x6yEQvY,19573
45
46
  ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -54,14 +55,14 @@ ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py,sha256=kyx26AnT1-LySFA46w
54
55
  ScriptCollection/TFCPS/Go/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
56
  ScriptCollection/TFCPS/Maven/TFCPS_CodeUnitSpecific_Maven.py,sha256=WcWWtCV3GkAk53RIN_6rjXNvkKZ5i5hBEMCmPQo6j30,1685
56
57
  ScriptCollection/TFCPS/Maven/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
- ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py,sha256=SadtR8lhLshdPHNqTBwtkk_xla51P1z_5oPbephSmVo,13648
58
+ ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py,sha256=i2msd3tmXaB8EWF3tIR5jwveIFlZcmeYXMde4UP32P4,14310
58
59
  ScriptCollection/TFCPS/NodeJS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
60
  ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=fqGhXNx8tK8sWPcn4D3eIE6gV9Oh7J37NBKjU089e-A,15852
60
61
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
62
  ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
62
63
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
- scriptcollection-4.2.144.dist-info/METADATA,sha256=8q-gEcZI3llnBenLhrH5gFB3lmb92fCmox3xPmkrgLk,7817
64
- scriptcollection-4.2.144.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
65
- scriptcollection-4.2.144.dist-info/entry_points.txt,sha256=IUIlg0se3DubH9yuMrFE0sl92BXPdCqCPt0N7uGASs4,5373
66
- scriptcollection-4.2.144.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
67
- scriptcollection-4.2.144.dist-info/RECORD,,
64
+ scriptcollection-4.2.145.dist-info/METADATA,sha256=xwb2L1trz3kTrIoSrI4vDvTihrZULAsXNWWLRjYrUIQ,7817
65
+ scriptcollection-4.2.145.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
66
+ scriptcollection-4.2.145.dist-info/entry_points.txt,sha256=tXpgu2GUhY3yUmoK3gVPypYMnxorz3183wl82aFt7KI,5430
67
+ scriptcollection-4.2.145.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
68
+ scriptcollection-4.2.145.dist-info/RECORD,,
@@ -17,6 +17,7 @@ sccreatehashofallfiles = ScriptCollection.Executables:CreateHashOfAllFiles
17
17
  sccreateisofilewithobfuscatedfiles = ScriptCollection.Executables:CreateISOFileWithObfuscatedFiles
18
18
  sccreaterelease = ScriptCollection.Executables:CreateRelease
19
19
  sccreatesimplemergewithoutrelease = ScriptCollection.Executables:CreateSimpleMergeWithoutRelease
20
+ sccreateskill = ScriptCollection.Executables:CreateSkill
20
21
  sccurrentuserhaselevatedprivileges = ScriptCollection.Executables:CurrentUserHasElevatedPrivileges
21
22
  scdownloadcachabletools = ScriptCollection.Executables:DownloadCachableTools
22
23
  scensuredockernetworkisavailable = ScriptCollection.Executables:EnsureDockerNetworkIsAvailable