ScriptCollection 4.4.9__py3-none-any.whl → 4.4.10__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.
@@ -39,7 +39,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
39
39
  from .ProgramRunnerPopen import ProgramRunnerPopen
40
40
  from .SCLog import SCLog, LogLevel
41
41
 
42
- version = "4.4.9"
42
+ version = "4.4.10"
43
43
  __version__ = version
44
44
 
45
45
  class VSCodeWorkspaceShellTask:
@@ -192,17 +192,19 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
192
192
 
193
193
  @GeneralUtilities.check_arguments
194
194
  def __get_arguments_which_prevent_writing_a_lock_file(self) -> list[str]:
195
- """Returns the arguments which keep a dotnet-operation from writing a lock-file.
195
+ """Returns the arguments which keep a dotnet-operation from writing a lock-file into the codeunit.
196
196
 
197
197
  The lock-files belong to the restore of the build alone, because only there the runtime - and with it the name of the
198
198
  lock-file which belongs to that runtime - is known. Every other dotnet-operation of a codeunit (linting, test, ...)
199
199
  works on the solution instead of on one runtime and restores implicitly, and the csproj-property
200
- "RestorePackagesWithLockFile" would make each of those restores write a lock-file under the default-name. Such a file
201
- is never validated against anything, because locked mode is only requested for the runtime-specific one, so it would
202
- only be an additional file which looks like the relevant pinning without being it. The value has to be passed on the
203
- command-line because a property which the project-file sets explicitly wins over one which comes from the
204
- environment."""
205
- return ["-p:RestorePackagesWithLockFile=false"]
200
+ "RestorePackagesWithLockFile" would make each of those restores write a lock-file under the default-name next to the
201
+ runtime-specific ones.
202
+ The lock-file of those operations is therefore pointed at a throwaway-path outside of the repository. Switching the
203
+ property off instead does not work: nuget rejects a restore with NU1005 as soon as a lock-file under the default-name
204
+ exists, which is exactly the case this has to survive (a developer who ran "dotnet build" once has such a file). The
205
+ value has to be passed on the command-line, because a property which the project-file sets explicitly wins over one
206
+ which comes from the environment."""
207
+ return [f"-p:NuGetLockFilePath={self.tfcps_Tools_General.get_throwaway_lock_file(self.get_codeunit_name())}"]
206
208
 
207
209
  @GeneralUtilities.check_arguments
208
210
  def __standardized_tasks_build_for_dotnet_build(self, csproj_file: str, originaloutputfolder: str, files_to_sign: dict[str, str], commitid: str, runtimes: list[str], target_environmenttype_mapping: dict[str, str], copy_license_file_to_target_folder: bool, repository_folder: str, codeunit_name: str) -> None:
@@ -247,6 +249,26 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
247
249
  sarif_target_file = os.path.join(sarif_folder_target, sarif_filename)
248
250
  GeneralUtilities.ensure_file_does_not_exist(sarif_target_file)
249
251
  shutil.copyfile(sarif_source_file, sarif_target_file)
252
+ # The lock-file of this runtime becomes a part of the build-result: it states which version of which package
253
+ # the build actually used, which is what makes it possible to reproduce a build later or to check an
254
+ # artifact against a vulnerability afterwards. The working-copy keeps its own lock-file, so this is a copy
255
+ # and not a move.
256
+ # It is copied into a folder per project, because the name of the file only contains the runtime while a
257
+ # codeunit builds more than one project (itself and its test-project) for the same runtime, so a flat folder
258
+ # would let the second project overwrite the file of the first one. The name of the file itself stays
259
+ # unchanged, because it is the name nuget expects and a consumer of the artifact reads the runtime from it.
260
+ lock_file = os.path.join(csproj_file_folder, self.__get_lock_file_name(runtime))
261
+ if os.path.isfile(lock_file):
262
+ lock_file_folder_target = os.path.join(codeunit_folder, "Other", "Artifacts", "PackagesLock", csproj_file_name_without_extension)
263
+ GeneralUtilities.ensure_directory_exists(lock_file_folder_target)
264
+ lock_file_target = os.path.join(lock_file_folder_target, os.path.basename(lock_file))
265
+ GeneralUtilities.ensure_file_does_not_exist(lock_file_target)
266
+ shutil.copyfile(lock_file, lock_file_target)
267
+ else:
268
+ # The restore which ran above creates the file whenever the project demands one (see
269
+ # __get_lock_file_arguments), so a missing file means the project does not set
270
+ # RestorePackagesWithLockFile - and then the build-result does not state which versions it used.
271
+ self._protected_sc.log.log(f"The lock-file \"{lock_file}\" does not exist, so the build-result of \"{csproj_file_name_without_extension}\" does not contain the versions which were used for the runtime \"{runtime}\".", LogLevel.Warning)
250
272
 
251
273
  @GeneralUtilities.check_arguments
252
274
  def standardized_tasks_build_for_dotnet_project(self,runtimes:list[str]) -> None:
@@ -274,7 +296,6 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
274
296
 
275
297
  @GeneralUtilities.check_arguments
276
298
  def __standardized_tasks_build_for_dotnet_project(self,runtimes:list[str]) -> None:
277
-
278
299
  target_environment_type: str=self.get_target_environment_type()
279
300
  copy_license_file_to_target_folder: bool=True
280
301
  codeunitname: str = self.get_codeunit_name()
@@ -282,7 +303,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
282
303
  workspace_folder=os.path.join(self.get_codeunit_folder(),"Other","Workspace")
283
304
  GeneralUtilities.ensure_directory_does_not_exist(workspace_folder)
284
305
 
285
- files_to_sign: dict[str, str] = self.get_filestosign_from_commandline_arguments( dict())
306
+ files_to_sign: dict[str, str] = self.get_filestosign_from_commandline_arguments(dict())
286
307
  repository_folder: str = self.get_repository_folder()
287
308
  commitid = self._protected_sc.git_get_commit_id(repository_folder)
288
309
  outputfolder = GeneralUtilities.resolve_relative_path("./Other/Artifacts", self.get_codeunit_folder())
@@ -660,6 +681,16 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
660
681
  result.append(f"Line {i+1} does not match: Regex='{r}' String='{s}'")
661
682
  return result
662
683
 
684
+ @GeneralUtilities.check_arguments
685
+ def _protected_restore_projects_for_the_metadata_of_docfx(self) -> None:
686
+ """Restores the projects of this codeunit, so that docfx can read them without restoring them itself.
687
+
688
+ The reference is generated from the sourcecode and not for one runtime, so this restore knows no runtime either and
689
+ its lock-file is pointed at the throwaway-path like the one of every other operation of that kind (see
690
+ __get_arguments_which_prevent_writing_a_lock_file). The restore is done here and not left to docfx, because the
691
+ reference of a codeunit can also be generated on its own, without a build before it."""
692
+ self._protected_sc.run_program_argsasarray("dotnet", ["restore"]+self.__get_arguments_which_prevent_writing_a_lock_file(), self.get_codeunit_folder(), print_live_output=self.get_verbosity() == LogLevel.Debug)
693
+
663
694
  @GeneralUtilities.check_arguments
664
695
  def generate_reference(self, generate_class_reference:bool=False) -> None:
665
696
  self.generate_reference_using_docfx(generate_class_reference)
@@ -283,6 +283,15 @@ class TFCPS_CodeUnitSpecific_Base(ABC):
283
283
  content_without_trailing_commas: str = re.sub(r",(\s*[}\]])", r"\1", content)
284
284
  return 0 < len(json.loads(content_without_trailing_commas).get("metadata", []))
285
285
 
286
+ @GeneralUtilities.check_arguments
287
+ def _protected_restore_projects_for_the_metadata_of_docfx(self) -> None:
288
+ """Restores what the metadata-step of docfx reads.
289
+
290
+ docfx is called with "--noRestore" (see generate_reference_using_docfx), so a codeunit whose reference is generated
291
+ from project-files has to restore them itself; this is where a codeunit-kind states how that is done. Doing nothing
292
+ is the default, because the reference of a codeunit of most kinds is generated from files which are read as they
293
+ are."""
294
+
286
295
  @GeneralUtilities.check_arguments
287
296
  def generate_reference_using_docfx(self, generate_class_reference:bool=False):
288
297
  reference_folder =os.path.join( self.get_codeunit_folder(),"Other","Reference")
@@ -297,15 +306,16 @@ class TFCPS_CodeUnitSpecific_Base(ABC):
297
306
  obj_folder = os.path.join(reference_folder, "obj")
298
307
  GeneralUtilities.ensure_folder_exists_and_is_empty(obj_folder)
299
308
  # The metadata-step and the build-step are executed separately instead of using the default-command which runs both
300
- # of them at once, because only the metadata-command accepts "--property". That property is required because docfx
301
- # restores the project before it reads it (which is what its option "--noRestore" switches off): that restore does
302
- # not know the name of the lock-file which belongs to the runtime the build restored for, so it would write one
303
- # under the default-name besides them (see
304
- # TFCPS_CodeUnitSpecific_DotNet.__get_arguments_which_prevent_writing_a_lock_file). The restore itself is kept
305
- # (instead of passing "--noRestore"), because the reference of a codeunit can also be generated on its own, without
306
- # a build before it.
309
+ # of them at once, because only the metadata-command accepts "--noRestore". That option is required because the
310
+ # restore which docfx runs before it reads a project is a process of its own which none of the properties of this
311
+ # call reach: neither "RestorePackagesWithLockFile" nor "NuGetLockFilePath" arrives there, so that restore writes a
312
+ # lock-file under the default-name into the codeunit. Such a file must never exist - it pins nothing, because only
313
+ # the runtime-specific lock-files are validated, and every following dotnet-operation fails with NU1005 as long as
314
+ # it lies there. What the metadata-step reads is therefore restored before docfx is called (see
315
+ # _protected_restore_projects_for_the_metadata_of_docfx), where the name of the lock-file is under our control.
307
316
  if self.__docfx_configuration_declares_metadata(os.path.join(reference_folder, "docfx.json")):
308
- self._protected_sc.run_program("docfx", "metadata docfx.json --property RestorePackagesWithLockFile=false", reference_folder)
317
+ self._protected_restore_projects_for_the_metadata_of_docfx()
318
+ self._protected_sc.run_program("docfx", "metadata docfx.json --noRestore", reference_folder)
309
319
  self._protected_sc.run_program("docfx", "build -t default,templates/darkfx docfx.json", reference_folder)
310
320
  GeneralUtilities.ensure_directory_does_not_exist(obj_folder)
311
321
 
@@ -1876,6 +1876,21 @@ class TFCPS_Tools_General:
1876
1876
  changelog_file = os.path.join(repository_folder, "Other", "Resources", "Changelog", f"v{projectversion}.md")
1877
1877
  self.__sc.run_program_argsasarray("gh", ["release", "create", f"v{projectversion}", "--repo", github_repo, "--notes-file", changelog_file, "--title", f"Release v{projectversion}"]+artifact_files)
1878
1878
 
1879
+ @GeneralUtilities.check_arguments
1880
+ def get_throwaway_lock_file(self, codeunit_name: str) -> str:
1881
+ """Returns the path of a lock-file whose content is not used by anybody.
1882
+
1883
+ Every dotnet-operation of a codeunit restores, and a project which demands a lock-file (see the property
1884
+ RestorePackagesWithLockFile) makes each of those restores write one. Only the restore of the build knows which
1885
+ runtime it restores for and therefore which lock-file belongs to the result; every other operation would write
1886
+ one under the default-name next to it, which is not validated against anything and only looks like the relevant
1887
+ pinning. Those operations are therefore pointed at this path instead.
1888
+ The path is not inside the repository, so the operations leave nothing behind there, and it contains the name of
1889
+ the codeunit, so two codeunits which are built at the same time do not write to the same file."""
1890
+ folder = os.path.join(GeneralUtilities.get_temp_folder(), "ScriptCollection", "ThrowawayLockFiles", codeunit_name)
1891
+ GeneralUtilities.ensure_directory_exists(folder)
1892
+ return os.path.join(folder, "packages.lock.json")
1893
+
1879
1894
  @GeneralUtilities.check_arguments
1880
1895
  def get_dependency_version_in_resources_folder(self, resources_folder:str, dependency_name: str) ->str:
1881
1896
  dependency_folder = os.path.join(resources_folder, "Dependencies", dependency_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.4.9
3
+ Version: 4.4.10
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
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=ot9Ib-plQ8wejR9M2XXfnx6GR-va9k8SH1gAC5kjaJ0,5123
11
11
  ScriptCollection/SCLog.py,sha256=Fjf8Pdi63cXHGMxL_aI6A0dwGm7QIfrv3czjvpSUlaM,4705
12
- ScriptCollection/ScriptCollectionCore.py,sha256=rldvIi9zD5BgzRFqgmou-1P0alxEEouWky3w-PV46Pw,261810
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=kfI9PrinFNNJ5e0vy7RywhwXm9_9mU0g4j9AyFsVTyE,261811
13
13
  ScriptCollection/TestKind.py,sha256=EBTLR8yBz5VmWA2NZIpDTbQNg6tkfv_kAsIzEJ--mCI,1756
14
14
  ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
15
15
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -37,7 +37,7 @@ ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz
37
37
  ScriptCollection/TFCPS/PackageSource.py,sha256=tQoMbxrIbV3mYHKH2wgOoGzIHY1TvBH8EAFpWGhryrQ,1311
38
38
  ScriptCollection/TFCPS/SCTaskRunnerServer.py,sha256=rpuwSsQ6YQfZS2LGnvOH5ql8zs_-cHU4LQttS7XNT60,11272
39
39
  ScriptCollection/TFCPS/TFCPS_BuildCodeUnitsHook.py,sha256=67_DQwoH5bhxxSmwtuAeoW1NOCMiLMzOy48OqlJX-KY,1744
40
- ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=N6hOkfts6g61dhrQyrWx64Nxe0nInMtzyVNKyqHvUfk,38992
40
+ ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=Rm1wY0CKHqFGyTlLAbFE1CY7SBzfhms68Mz-UFX7b5s,39740
41
41
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=Mj9t1SyRpkYZE74cLsGWYv4xB89gXL2ld-RX3xvvGdw,9835
42
42
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=PHu13UCn3xj3UBneGk5DDkYZ9iGdJ80IKIte3ewwKfI,49143
43
43
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=kpEmSnfzfgB4OjcCuS_X6jgW_ftcphxEnjjoLoAHTLY,6582
@@ -47,7 +47,7 @@ ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=oYEhz5ZWMnbu97_CcYEqdDxakUF
47
47
  ScriptCollection/TFCPS/TFCPS_OCIImageSecretScan.py,sha256=rhw0glr4gZ5enG9faOD51xE4MMK1cIdNjUdaswiMsrY,14622
48
48
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=XLVsFTA1jvfDbZ7wYJgIdEByZhF_bYVbA5jkisuvK4k,2322
49
49
  ScriptCollection/TFCPS/TFCPS_RemoteBuild.py,sha256=Z8Gw-j5I7VPafHEsVeQJ2gTTKVLAnnhwZhY8IVTi2Qk,11867
50
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=6oi5vdng6wMx2inbj8KTwIFOPvZAO4ekIVLQcq4pZ9Y,162988
50
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=ujl2kltznTMQCibnltTuG51kmFChzOtd2M2QLXY5wEE,164189
51
51
  ScriptCollection/TFCPS/TFCPS_VisualRegressionTests.py,sha256=6_63udxHnPlu_TMk_ftLZTnzriJO8MCxVCVAsweZqHs,37073
52
52
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=919mNfzVRurTJhWi8WV0oEAFoH-yd4a6m2Rbxcf2oZ4,19927
@@ -55,7 +55,7 @@ ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
55
55
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py,sha256=bT6Gd5pQpZCw4OQz6HWkPCSn5z__eUUEisABLDSxd0o,200
56
56
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=QyjOfMY22JWCvKjMelHiDWbJiWqotOfebpJpgDUaoO4,237
57
57
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
58
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=9KUJLrYqEXV-h-AR4gde2u-KX-JXwtb0BNJ9OyuUEnM,56266
58
+ ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=A4eIIJGDrbXZSYH80Ooudma_YQHQvf7coYBMvOA4r70,59462
59
59
  ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=cAE_OFJBU0M3L2Ov5PUUMH7aOVVzKtnKlFoXSw43fng,8759
61
61
  ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -71,8 +71,8 @@ ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=yyjWPMHQjPLkML
71
71
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  ScriptCollection/TFCPS/TypeScript/TFCPS_CodeUnitSpecific_TypeScript.py,sha256=5z990qyO5durX07xRWRwju1hl6wpjQAy2f-yRwJ-7s0,11856
73
73
  ScriptCollection/TFCPS/TypeScript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- scriptcollection-4.4.9.dist-info/METADATA,sha256=h2-_3VwdzABZM0Qyi5VJvL_Ret6DA_KiVFyDzpd6MXo,7647
75
- scriptcollection-4.4.9.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
- scriptcollection-4.4.9.dist-info/entry_points.txt,sha256=Aj6CHuJxASMe52fK_O6-bNJ_uhxcDb-AgRxFOeTojyE,6069
77
- scriptcollection-4.4.9.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
- scriptcollection-4.4.9.dist-info/RECORD,,
74
+ scriptcollection-4.4.10.dist-info/METADATA,sha256=cYHDkvcc2oaJG1PWoDUbRS6gggPDoUNW9jv65NRm5eM,7648
75
+ scriptcollection-4.4.10.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
+ scriptcollection-4.4.10.dist-info/entry_points.txt,sha256=Aj6CHuJxASMe52fK_O6-bNJ_uhxcDb-AgRxFOeTojyE,6069
77
+ scriptcollection-4.4.10.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
+ scriptcollection-4.4.10.dist-info/RECORD,,