ScriptCollection 4.4.12__py3-none-any.whl → 4.4.14__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.
@@ -1400,11 +1400,22 @@ class GeneralUtilities:
1400
1400
  path=str(path)
1401
1401
  path=os.path.expandvars(path)
1402
1402
  if GeneralUtilities.current_system_is_windows():
1403
- path=path.replace("/","\\")
1403
+ path=GeneralUtilities.__sanitize(path.replace("/","\\"),"\\")
1404
1404
  else:
1405
- path=path.replace("\\","/")
1405
+ path=GeneralUtilities.__sanitize(path.replace("\\","/"),"/")
1406
1406
  return path
1407
1407
 
1408
+ @staticmethod
1409
+ @check_arguments
1410
+ def __sanitize(string:str,separator:str) -> str:
1411
+ first_non_separator_index = 0
1412
+ while first_non_separator_index < len(string) and string[first_non_separator_index] == separator:
1413
+ first_non_separator_index = first_non_separator_index + 1
1414
+ prefix = string[:first_non_separator_index]
1415
+ suffix = string[first_non_separator_index:]
1416
+ suffix = re.sub(re.escape(separator) + r"{2,}", lambda _: separator, suffix)
1417
+ return prefix + suffix
1418
+
1408
1419
  @staticmethod
1409
1420
  @check_arguments
1410
1421
  def int_to_string(number: int, leading_zeroplaces: int, trailing_zeroplaces: int) -> str:
@@ -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.12"
42
+ version = "4.4.14"
43
43
  __version__ = version
44
44
 
45
45
  class VSCodeWorkspaceShellTask:
@@ -1,11 +1,12 @@
1
1
  import os
2
+ import platform
2
3
  import shutil
3
4
  import re
4
5
  import zipfile
5
6
  from ...GeneralUtilities import GeneralUtilities
6
7
  from ...SCLog import LogLevel
7
8
  from ..TFCPS_CodeUnitSpecific_Base import TFCPS_CodeUnitSpecific_Base,TFCPS_CodeUnitSpecific_Base_CLI
8
- from ..TFCPS_RemoteBuild import RunnerOperatingSystem
9
+ from ..TFCPS_RemoteBuild import TFCPS_RemoteBuild, RunnerOperatingSystem
9
10
 
10
11
  class TFCPS_CodeUnitSpecific_Flutter_Functions(TFCPS_CodeUnitSpecific_Base):
11
12
 
@@ -40,9 +41,17 @@ class TFCPS_CodeUnitSpecific_Flutter_Functions(TFCPS_CodeUnitSpecific_Base):
40
41
  GeneralUtilities.ensure_directory_exists(web_folder)
41
42
  GeneralUtilities.copy_content_of_folder(web_relase_folder, web_folder)
42
43
  elif target == "windows":
43
- # Windows-builds always run on a Windows-task-runner - even when building on a Windows-client - so that all
44
- # builds are produced uniformly in the same defined environment. See the remote-build-article in the reference.
45
- self.run_program_on_remote_runner(RunnerOperatingSystem.Windows, "flutter", ["build", "windows"], src_folder)
44
+ # Windows-builds prefer a Windows-task-runner - even when building on a Windows-client - so that all builds
45
+ # are produced uniformly in the same defined environment. See the remote-build-article in the reference. If
46
+ # no runner is configured, fall back to building locally (only possible when already running on Windows)
47
+ # instead of failing, so a development machine without a configured runner is not blocked.
48
+ if platform.system() == "Windows" and not TFCPS_RemoteBuild(self._protected_sc).has_any_runner_configured():
49
+ self._protected_sc.log.log("No remote-build-runner is configured; building the windows-target locally "
50
+ "instead. This build is not guaranteed to be produced in the same uniform "
51
+ "environment as a runner-built one.", LogLevel.Warning)
52
+ self._protected_sc.run_with_epew("flutter", "build windows", src_folder)
53
+ else:
54
+ self.run_program_on_remote_runner(RunnerOperatingSystem.Windows, "flutter", ["build", "windows"], src_folder)
46
55
  windows_release_folder = os.path.join(src_folder, "build/windows/x64/runner/Release")
47
56
  windows_folder = os.path.join(artifacts_folder, "BuildResult_Windows")
48
57
  GeneralUtilities.ensure_directory_does_not_exist(windows_folder)
@@ -82,6 +91,17 @@ class TFCPS_CodeUnitSpecific_Flutter_Functions(TFCPS_CodeUnitSpecific_Base):
82
91
  else:
83
92
  raise ValueError(f"Not supported target: {target}")
84
93
  self.copy_source_files_to_output_directory()
94
+ if len(targets) == 0:
95
+ # A pure Dart/Flutter library codeunit (no platform target) has no compiled artifact of its own, but
96
+ # TFCPS_CodeUnit_BuildCodeUnit.build_codeunit() requires a 'BuildResult_.+'-matching artifact for every
97
+ # codeunit. Publish a copy of the SourceCode-artifact under a BuildResult_-name to satisfy that generic
98
+ # check instead of weakening it for every codeunit type. The SourceCode-artifact folder itself keeps its
99
+ # name unchanged because the DependentCodeUnits-convention (see the reference) already relies on it.
100
+ source_code_folder = os.path.join(artifacts_folder, "SourceCode")
101
+ build_result_source_code_folder = os.path.join(artifacts_folder, "BuildResult_SourceCode")
102
+ GeneralUtilities.ensure_directory_does_not_exist(build_result_source_code_folder)
103
+ GeneralUtilities.ensure_directory_exists(build_result_source_code_folder)
104
+ GeneralUtilities.copy_content_of_folder(source_code_folder, build_result_source_code_folder)
85
105
 
86
106
  @GeneralUtilities.check_arguments
87
107
  def linting(self) -> None:
@@ -90,8 +110,16 @@ class TFCPS_CodeUnitSpecific_Flutter_Functions(TFCPS_CodeUnitSpecific_Base):
90
110
  #TODO call the flutter-linting here when available
91
111
 
92
112
  @GeneralUtilities.check_arguments
93
- def do_common_tasks(self,current_codeunit_version:str )-> None:
113
+ def do_common_tasks(self,current_codeunit_version:str,package_name:str )-> None:
94
114
  self.do_common_tasks_base(current_codeunit_version)
115
+ # The codeunit-version is the single source of truth for the version of a flutter/dart-codeunit, so the
116
+ # version of its package (which pub itself never derives from anything else) has to be kept in sync with it.
117
+ repository_folder = self.get_repository_folder()
118
+ version = current_codeunit_version if current_codeunit_version is not None else self.tfcps_Tools_General.get_version_of_project(repository_folder)
119
+ pubspec_file = os.path.join(self.get_codeunit_folder(), package_name, "pubspec.yaml")
120
+ content = GeneralUtilities.read_text_from_file(pubspec_file)
121
+ content = re.sub(r"(?m)^version:.*$", f"version: {version}", content, count=1)
122
+ GeneralUtilities.write_text_to_file(pubspec_file, content)
95
123
 
96
124
  @GeneralUtilities.check_arguments
97
125
  def generate_reference(self) -> None:
@@ -425,7 +425,10 @@ class TFCPS_CodeUnitSpecific_Base(ABC):
425
425
  def copy_source_files_to_output_directory(self) -> None:
426
426
  self._protected_sc.log.log("Copy sourcecode...")
427
427
  codeunit_folder =self.get_codeunit_folder()
428
- result = self._protected_sc.run_program_argsasarray("git", ["ls-tree", "-r", "HEAD", "--name-only"], codeunit_folder)
428
+ # "git ls-files" (unlike "git ls-tree -r HEAD --name-only") reads the index, so a file which is staged but not
429
+ # yet committed is recognized here too - a freshly scaffolded codeunit which was only "git add"ed still gets a
430
+ # SourceCode-artifact instead of an empty one.
431
+ result = self._protected_sc.run_program_argsasarray("git", ["ls-files"], codeunit_folder)
429
432
  files = [f for f in result[1].split('\n') if len(f) > 0]
430
433
  for file in files:
431
434
  full_source_file = os.path.join(codeunit_folder, file)
@@ -44,6 +44,11 @@ class TFCPS_RemoteBuild:
44
44
  def __init__(self, sc: ScriptCollectionCore):
45
45
  self.__sc = sc
46
46
 
47
+ @GeneralUtilities.check_arguments
48
+ def has_any_runner_configured(self) -> bool:
49
+ """Whether at least one remote-build-runner is configured (see run_program_on_runner)."""
50
+ return len(self.__load_runner_endpoints()) > 0
51
+
47
52
  @GeneralUtilities.check_arguments
48
53
  def run_program_on_runner(self, required_os: RunnerOperatingSystem, repository_folder: str, codeunit_name: str, program: str, arguments: list[str], working_directory: str, poll_interval_in_seconds: int = 3, timeout_in_seconds: int = 60*60) -> None:
49
54
  endpoints = self.__load_runner_endpoints()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.4.12
3
+ Version: 4.4.14
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,7 +1,7 @@
1
1
  ScriptCollection/AnionBuildPlatform.py,sha256=LF9b4f4iqgsjgXZjS0RHiEBw73tQANfu0O1dYGWNjy8,11948
2
2
  ScriptCollection/CertificateUpdater.py,sha256=bD0VhKQsD2cNRTG1kzMkhgpd0BZw7igbG30goKw5p1A,9749
3
3
  ScriptCollection/Executables.py,sha256=jU4TPpi3psAd1gsMVAGCrw6Wyv7MdX1spBh9Grk0gbA,74303
4
- ScriptCollection/GeneralUtilities.py,sha256=JeUZM4uHO85RAbx-MIYRXAVmklTw7UycVnrSxbXFROI,71417
4
+ ScriptCollection/GeneralUtilities.py,sha256=jdAjCqSeGzH2rH_gcJFXbDea4o8MpctpChtZh3Q2IyI,72015
5
5
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
6
6
  ScriptCollection/ProcessesRunner.py,sha256=Va9O-ohWoRfe4pO2gPBzc940gkM5BpP4Txcu1CmLOvg,1494
7
7
  ScriptCollection/ProgramRunnerBase.py,sha256=eZenpiIFW1dhvSVCG7cfBs5hO4_KLlOxR7oXoSxUDmk,2286
@@ -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=QyUfpkajP2hQf2SlmpP06aQAB4i2Wu3j0FbRW8DdGYU,261811
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=e8seZtE804I4NhyL--7xcX3IO7i7Tgf0BPZgfb8-nrA,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=Rm1wY0CKHqFGyTlLAbFE1CY7SBzfhms68Mz-UFX7b5s,39740
40
+ ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=ngbtRfZiu6RDeV9RuxmGz7SiACQ-t1O9S6HZte-FxK8,40005
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
@@ -46,7 +46,7 @@ ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=Krt5oyGNcRAN3szsgU7LoTh8yVTOd
46
46
  ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=oYEhz5ZWMnbu97_CcYEqdDxakUFVppyOVQiJzADq59c,22434
47
47
  ScriptCollection/TFCPS/TFCPS_OCIImageSecretScan.py,sha256=rhw0glr4gZ5enG9faOD51xE4MMK1cIdNjUdaswiMsrY,14622
48
48
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=XLVsFTA1jvfDbZ7wYJgIdEByZhF_bYVbA5jkisuvK4k,2322
49
- ScriptCollection/TFCPS/TFCPS_RemoteBuild.py,sha256=Z8Gw-j5I7VPafHEsVeQJ2gTTKVLAnnhwZhY8IVTi2Qk,11867
49
+ ScriptCollection/TFCPS/TFCPS_RemoteBuild.py,sha256=JY2mafxObDXVxbALgex5hIFMN0Pd7AZae1OP_6rS5M8,12108
50
50
  ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=XC2KXHiF5gNptyinqyWaK2DeP0li-hD4f-yEB2sktVQ,164339
51
51
  ScriptCollection/TFCPS/TFCPS_VisualRegressionTests.py,sha256=6_63udxHnPlu_TMk_ftLZTnzriJO8MCxVCVAsweZqHs,37073
52
52
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -57,7 +57,7 @@ ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=
57
57
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
58
58
  ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=GCFzDNAnmm40EeqOYgD_EeuEwDY58ujwJ1-Zn_naamc,61797
59
59
  ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
- ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=cAE_OFJBU0M3L2Ov5PUUMH7aOVVzKtnKlFoXSw43fng,8759
60
+ ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=6AOKEMR1s6d1BIAxUC-E2lolzwKXqKBSYMQnCVqPAcs,11460
61
61
  ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py,sha256=m4Pax-U6o5XuspLnLfnWjyQMtoC7zBDDNJW9EhLWjeE,9012
63
63
  ScriptCollection/TFCPS/Go/__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.12.dist-info/METADATA,sha256=JVKXuIC0_F4BSy16DNacDFqmMlY-mywadrAeDb-yqU8,7648
75
- scriptcollection-4.4.12.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
- scriptcollection-4.4.12.dist-info/entry_points.txt,sha256=GNma7tN0J59EvK71su-G1w22RnZ05bXcPrELyLx3AL0,6151
77
- scriptcollection-4.4.12.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
- scriptcollection-4.4.12.dist-info/RECORD,,
74
+ scriptcollection-4.4.14.dist-info/METADATA,sha256=Qidw2T7BBBAUqWpOs0fryVuo7MrvMTgdTjwa4ND4yNY,7648
75
+ scriptcollection-4.4.14.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
+ scriptcollection-4.4.14.dist-info/entry_points.txt,sha256=GNma7tN0J59EvK71su-G1w22RnZ05bXcPrELyLx3AL0,6151
77
+ scriptcollection-4.4.14.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
+ scriptcollection-4.4.14.dist-info/RECORD,,