Skip to content

Commit 778cbfd

Browse files
committed
feat(setup): enhance developer setup script for Python and PowerShell profile configuration
1 parent 1f6c6e4 commit 778cbfd

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

SetupDeveloperPC.bat

+38-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ set "ORIGINAL_DIR=%CD%"
77
:: Change to the directory where the script resides
88
cd /d %~dp0
99

10-
set "targetPath=%USERPROFILE%\AppData\Roaming\Python\Python312\Scripts"
10+
if exist "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2544.0_x64__qbz5n2kfra8p0" (
11+
set "targetPath=C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2544.0_x64__qbz5n2kfra8p0"
12+
) else if exist "%USERPROFILE%\AppData\Roaming\Python\Python312\Scripts" (
13+
set "targetPath=%USERPROFILE%\\AppData\Roaming\Python\Python312\Scripts"
14+
)
15+
1116
set "found=0"
1217

1318
:: Normalize the target path by removing any trailing backslash
@@ -43,6 +48,8 @@ if "!found!"=="0" (
4348

4449
:checkDone
4550

51+
52+
call :ConfigureArgComplete
4653
call :ConfigureGit
4754
call :ConfigureVSCode
4855
call :ConfigurePreCommit
@@ -170,3 +177,33 @@ IF %ERRORLEVEL% NEQ 0 (
170177

171178
)
172179
goto :eof
180+
181+
:ConfigureArgComplete
182+
183+
:: Define paths
184+
set "PROFILE_PATH=%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
185+
set "MODULE_PATH=C:\Program^ Files^ ^(x86^)\ardupilot_methodic_configurator\ardupilot_methodic_configurator_command_line_completion.psm1"
186+
187+
:: Create profile directory if it doesn't exist
188+
if not exist "%USERPROFILE%\Documents\WindowsPowerShell" (
189+
mkdir "%USERPROFILE%\Documents\WindowsPowerShell"
190+
)
191+
192+
:: Check if module exists
193+
if not exist "%MODULE_PATH%" (
194+
echo Error: Module file not found at %MODULE_PATH%
195+
pause
196+
exit /b 1
197+
)
198+
199+
:: Add import line to profile if it doesn't exist
200+
powershell -Command "if (-not (Test-Path '%PROFILE_PATH%')) { New-Item -Path '%PROFILE_PATH%' -Force } else { $content = Get-Content '%PROFILE_PATH%'; if ($content -notcontains 'Import-Module \"%MODULE_PATH%\"') { Add-Content '%PROFILE_PATH%' 'Import-Module \"%MODULE_PATH%\"' }}"
201+
202+
if %errorLevel% equ 0 (
203+
echo PowerShell profile updated successfully.
204+
echo Please restart PowerShell for changes to take effect.
205+
) else (
206+
echo Failed to update PowerShell profile.
207+
)
208+
209+
goto :eof

0 commit comments

Comments
 (0)