Compare commits

...

2 Commits

Author SHA1 Message Date
08b2e3ac1a added title cmd execution and created start-cmd.ps1 2025-07-30 18:18:34 +02:00
f93e9eaf69 Modificato script set user e nuovo switch branch:
- Aggiunti input username ed email nella UI di setup-conf.ps1 e salvataggio automatico nel file di configurazione JSON
- Modificato script di settaggio Git user per leggere username/email dal file di configurazione centralizzato (pdca0-config.json)
- Aggiornato switch-branch.bat: ora effettua stash delle modifiche locali prima dello switch, esegue il checkout, fa pull e riapplica lo stash se necessario
- Rinominato set-git-config.ps1 in pdca0-set-git-user.ps1 per maggiore chiarezza
2025-07-29 19:16:53 +02:00
6 changed files with 103 additions and 17 deletions

View File

@ -14,13 +14,23 @@
.\set-git-config-new.ps1 -Username "Mario Rossi" -Email "mario.rossi@intesasanpaolo.com" -RootDir "C:\Users\MarioRossi\progetti"
#>
# Carica username/email dal file di configurazione se non specificati
$ConfigPath = Resolve-Path (Join-Path $PSScriptRoot '../resources/pdca0-config.json')
if (Test-Path $ConfigPath) {
$configJson = Get-Content $ConfigPath -Raw | ConvertFrom-Json
if (-not $PSBoundParameters.ContainsKey('Username') -and $configJson.PSObject.Properties['username']) {
$Username = $configJson.username
}
if (-not $PSBoundParameters.ContainsKey('Email') -and $configJson.PSObject.Properties['email']) {
$Email = $configJson.email
}
}
param (
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$false)]
[string]$Username,
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$false)]
[string]$Email,
[Parameter(Mandatory=$true)]
[string]$RootDir
)
@ -91,7 +101,7 @@ foreach ($dir in $directories) {
Write-Host "Repository trovato: $dirPath" -ForegroundColor Blue
# Imposta la configurazione Git
Set-GitConfig -RepoPath $dirPath -Username $Username -Email $Email
Set-GitConfig -RepoPath $dirPath
$successfulRepos++
}
}

20
cmd/switch-branch.bat Normal file
View File

@ -0,0 +1,20 @@
@echo off
REM Verifica se ci sono modifiche locali
call git diff-index --quiet HEAD --
if %errorlevel% neq 0 (
set STASHED=1
echo Modifiche locali trovate, eseguo stash...
call git stash
) else (
set STASHED=0
)
call git checkout %~1
call git pull
if %STASHED%==1 (
echo Riapplico lo stash...
call git stash pop
)

View File

@ -1,13 +1,15 @@
{
"username": "SERAVALLI ALESSANDRO",
"email": "aseravalli@consulenti.fideuram.it",
"xdce_modules": [
"pdca0-ui",
"xdce-module-arc-v1",
"xdce-module-sost-esg-v1",
"xdce-module-widget-fideuram-v1"
],
"backend_modules": [
"pdca0-arc-v1",
"pdca0-sessionmanager-v1"
"pdca0-sessionmanager-v1",
"pdca0-sost-esg-v1"
],
"core_module": "core-arc-v1",
"core_module": "core-sost-esg-v1",
"deploy_module": "pdca0-deploy-arch"
}

View File

@ -136,7 +136,7 @@ $btnInstall.Add_Click({
return
}
$form.Enabled = $false
$positions = Get-TerminalPositions $modules.Count
# $positions = Get-TerminalPositions $modules.Count
foreach ($mod in $selected) {
$index = [Array]::IndexOf($modules, $mod)
if ($index -lt 0) { continue }
@ -147,10 +147,12 @@ $btnInstall.Add_Click({
[System.Windows.Forms.MessageBox]::Show("Modulo non trovato: $modPathRaw", "Errore", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
continue
}
$startCmdPosScript = Join-Path $ScriptDir "..\..\general\start-cmd-pos.ps1"
#$startCmdPosScript = Join-Path $ScriptDir "..\..\general\start-cmd-pos.ps1"
$startCmdScript = Join-Path $ScriptDir "..\..\general\start-cmd.ps1"
$cmd = "cd /d $ScriptDir && install.bat `"" + $modPath + "`""
$pos = $positions[$index]
powershell -ExecutionPolicy Bypass -File $startCmdPosScript -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height
# $pos = $positions[$index]
# powershell -ExecutionPolicy Bypass -File $startCmdScript -Name "install $mod" -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height
powershell -ExecutionPolicy Bypass -File $startCmdScript -Name "install $mod" -CommandLine $cmd
}
[System.Windows.Forms.MessageBox]::Show("Installazione avviata in nuove finestre terminale.", "Info", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
$form.Enabled = $true
@ -164,7 +166,7 @@ $btnStart.Add_Click({
return
}
$form.Enabled = $false
$positions = Get-TerminalPositions $modules.Count
# $positions = Get-TerminalPositions $modules.Count FIX-ME: non funziona
foreach ($mod in $selected) {
$index = [Array]::IndexOf($modules, $mod)
if ($index -lt 0) { continue }
@ -181,10 +183,12 @@ $btnStart.Add_Click({
[System.Windows.Forms.MessageBox]::Show("Modulo non trovato: $modPathRaw", "Errore", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
continue
}
$startCmdPosScript = Join-Path $ScriptDir "..\..\general\start-cmd-pos.ps1"
#$startCmdPosScript = Join-Path $ScriptDir "..\..\general\start-cmd-pos.ps1"
$startCmdScript = Join-Path $ScriptDir "..\..\general\start-cmd.ps1"
$cmd = "cd /d $ScriptDir && $batName `"" + $modPath + "`""
$pos = $positions[$index]
powershell -ExecutionPolicy Bypass -File $startCmdPosScript -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height
# $pos = $positions[$index]
# powershell -ExecutionPolicy Bypass -File $startCmdPosScript -Name "start $mod" -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height
powershell -ExecutionPolicy Bypass -File $startCmdScript -Name "start $mod" -CommandLine $cmd
}
[System.Windows.Forms.MessageBox]::Show("Avvio progetti in nuove finestre terminale.", "Info", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
$form.Enabled = $true

View File

@ -54,6 +54,36 @@ function Show-ConfigForm {
$dictPanel.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Left -bor [System.Windows.Forms.AnchorStyles]::Right
$mainPanel.Controls.Add($dictPanel, 0, 0)
# --- Input Username ---
$lblUsername = New-Object Windows.Forms.Label
$lblUsername.Text = "Username:"
$lblUsername.Location = New-Object Drawing.Point(10, $y)
$lblUsername.Size = New-Object Drawing.Size(80, 20)
$dictPanel.Controls.Add($lblUsername)
$txtUsername = New-Object Windows.Forms.TextBox
$txtUsername.Location = New-Object Drawing.Point(100, $y)
$txtUsername.Size = New-Object Drawing.Size(200, 20)
if ($json.PSObject.Properties["username"]) { $txtUsername.Text = $json.username }
$dictPanel.Controls.Add($txtUsername)
$controls["username"] = $txtUsername
$y += 28
# --- Input Email ---
$lblEmail = New-Object Windows.Forms.Label
$lblEmail.Text = "Email:"
$lblEmail.Location = New-Object Drawing.Point(10, $y)
$lblEmail.Size = New-Object Drawing.Size(80, 20)
$dictPanel.Controls.Add($lblEmail)
$txtEmail = New-Object Windows.Forms.TextBox
$txtEmail.Location = New-Object Drawing.Point(100, $y)
$txtEmail.Size = New-Object Drawing.Size(200, 20)
if ($json.PSObject.Properties["email"]) { $txtEmail.Text = $json.email }
$dictPanel.Controls.Add($txtEmail)
$controls["email"] = $txtEmail
$y += 28
foreach ($key in $modulesDict.Keys) {
$label = New-Object Windows.Forms.Label
$label.Text = $key
@ -135,6 +165,10 @@ function Show-ConfigForm {
$btnSave.Size = New-Object Drawing.Size(80, 25)
$btnSave.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right
$btnSave.Add_Click({
# Salva username ed email
$json | Add-Member -MemberType NoteProperty -Name 'username' -Value $controls['username'].Text -Force
$json | Add-Member -MemberType NoteProperty -Name 'email' -Value $controls['email'].Text -Force
foreach ($key in $modulesDict.Keys) {
$controlsForKey = $controls[$key]
if ($controlsForKey[0] -is [Windows.Forms.CheckBox]) {

16
src/general/start-cmd.ps1 Normal file
View File

@ -0,0 +1,16 @@
param(
[Parameter(Mandatory=$true)]
[string]$CommandLine,
[Parameter(Mandatory=$false)]
[string]$Name
)
# Prepara la command line con il titolo, se richiesto
if ($Name) {
$cmdline = "title $Name && $CommandLine"
} else {
$cmdline = $CommandLine
}
# Avvia il processo cmd
Start-Process -FilePath "cmd.exe" -ArgumentList "/k $cmdline" -PassThru