1- import os , sys , shutil
1+ from typing import Literal
2+ import os , sys , pathlib
23import lib .config .codebase as config
34from lib .config .consumer import signing_key_name
4- from lib .utils import run_command
5+ from lib .utils import run_command , eprint
6+
7+
8+ def build_component (
9+ name : str ,
10+ command : list [str | pathlib .Path ],
11+ output : Literal ["shell" , "none" ] = "none" ,
12+ ):
13+ print (f"Generating { name } ..." , end = "" , flush = True )
14+ if run_command (command , output ):
15+ eprint ("\n Build Abroaded." )
16+ exit (1 )
17+ print ("done." )
518
619
720def build_codemg_setup ():
@@ -12,11 +25,12 @@ def build_codemg_setup():
1225 os .makedirs (config .BUILD_DIR )
1326
1427 # Writing seperate Secrets file for production
15- with open (config .secrets_path , "w" ) as file :
28+ with open (config .secrets_build_path , "w" ) as file :
1629 file .write (f'{ signing_key_name } ="{ os .environ .get (signing_key_name )} "' )
1730
1831 # Making: codemg-CLI
19- run_command (
32+ build_component (
33+ "codemg cli" ,
2034 [
2135 config .pyinstaller_path ,
2236 config .codemgCLI_source ,
@@ -28,36 +42,45 @@ def build_codemg_setup():
2842 #
2943 # Secrets
3044 "--add-data" ,
31- f"{ config .secrets_path } :./" ,
45+ f"{ config .secrets_build_path } :./" ,
3246 ],
33- output = "none" ,
3447 )
3548
36- # Making: CodeManager-App
37- run_command (["bun" , "tauri" , "build" ])
38- shutil .copy2 (
39- config .codemanagerApp_setup_init_path ,
40- config .codemanagerApp_setup_path ,
41- )
49+ # Making: CodeManager
50+ build_component ("CodeManager" , ["bun" , "tauri" , "build" ], "shell" )
4251
43- # Making: CodeManager-Setup
44- run_command (
52+ # Making: codemg-Setup
53+ upgradeCode = os .environ .get ("UPGRADE_CODE" )
54+ build_component (
55+ "codemg-setup executable" ,
4556 [
46- config .pyinstaller_path ,
57+ "wix" ,
58+ "build" ,
4759 config .codemanagerSetup_source ,
48- "-n" ,
49- config .codemanagerSetup_name ,
50- "--onefile" ,
51- "--specpath" ,
52- config .BUILD_DIR ,
60+ "-o" ,
61+ config .codemanagerSetup_msi_path ,
5362 #
54- # CLI
55- "--add-binary" ,
56- f"{ config .codemgCLI_exe_path } :./" ,
63+ # App Info
64+ "-d" ,
65+ f"appName={ config .app_name } " ,
66+ "-d" ,
67+ f"appVersion={ config .app_version } " ,
68+ "-d" ,
69+ f"appManufacturer={ config .app_manufacturer } " ,
70+ "-d" ,
71+ f"appIdentifier={ config .app_identifier } " ,
72+ "-d" ,
73+ f"upgradeCode={ upgradeCode } " ,
5774 #
58- # App
59- "--add-binary" ,
60- f"{ config .codemanagerApp_setup_path } :./" ,
75+ # Components Info
76+ "-d" ,
77+ f"iconPath={ config .codemanagerApp_exe_path } " ,
78+ "-d" ,
79+ f"codemgCLIPath={ config .codemgCLI_exe_path } " ,
80+ "-d" ,
81+ f"codemamagerPath={ config .codemanagerApp_exe_path } " ,
82+ "-d" ,
83+ f"sccSidecarPath={ config .codemanagerSCC_sidecar_path } " ,
6184 ],
6285 )
6386
0 commit comments