Compare commits

..

5 Commits

Author SHA1 Message Date
fdf7737fb9 added release-widget-fideuram command 2025-08-11 15:54:23 +02:00
983291082c Refactor batch scripts and cleanup
- Refactored `cmd/build-commit.bat` and `cmd/release-commit.bat` to improve commit message handling and force push logic.
- Deleted obsolete `cmd/pdca0-fe.bat`.
- Added new command: `cmd/pdca0-fe.ps1`, that uses the new script implementation of the old `cmd/pdca0-fe.bat` using the `src/darwin/frontend` scripts folder.
- Removed unused or obsolete files.
2025-08-07 23:15:44 +02:00
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
8bad382371 renamed update npm to npm u 2025-07-22 10:33:04 +02:00
16 changed files with 485 additions and 211 deletions

View File

@ -1,7 +1,13 @@
@echo off @echo off
setlocal enabledelayedexpansion
call git commit --allow-empty -m "build" set "commit_message=build"
if "%~1" neq "" (
set "commit_message=build %~1"
)
if "%~1" neq "false" ( call git commit --allow-empty -m "!commit_message!"
call git push
if "%~2" neq "false" (
call git push -f
) )

View File

@ -1,164 +0,0 @@
@echo off
setlocal enabledelayedexpansion
set "current_dir=%~dp0..\..\pdca0\"
set "is_test=false"
if "%~1" == "test" (
set "is_test=true"
set "current_dir=%~dp0..\..\target\"
if not exist "!current_dir!" (
mkdir "!current_dir!"
)
)
set "default_modules="
set "config_file=%~dp0pdc-xdce-setup.conf"
set "module_name_key=watched_modules"
if exist %config_file% (
for /f "tokens=1,2 delims==" %%A in ('findstr /R "^%module_name_key%=.*" %config_file%') do (
set "default_modules=%%B"
)
)
:: Prompt for the module to watch
set /p modules="Enter the module or modules (separated with coma) to watch [!default_modules!]: "
if "!modules!"=="" set "modules=!default_modules!"
:: Scrivi il valore nel file pdc-xdce-setup.conf
echo %module_name_key%=%modules%> "%~dp0pdc-xdce-setup.conf"
echo Watched module/s: %modules%
:: Sostituisce le virgole con spazi
set "modules=!modules:,= !"
echo !modules!
:: Itera sulla stringa modificata
for %%a in (!modules!) do (
echo %%a
set "module=%%a"
set "module_dir=!current_dir!!module!"
cd /d !module_dir!
echo Eseguo controlli su !cd!
:: Controlla se local-gulpfile.js esiste
if not exist "!cd!\local-gulpfile.js" (
(
echo var gulp = require('gulp'^);
echo var path = require('path'^);
echo var fileSystem = require('fs'^);
echo.
echo function emptyFolder(directoryPath^) ^{
echo if (fileSystem.existsSync(directoryPath^)^) ^{
echo fileSystem.readdirSync(directoryPath^).forEach(function (file^) ^{
echo var curPath = path.join(directoryPath, file^);
echo if (fileSystem.lstatSync(curPath^).isDirectory(^)^) ^{
echo emptyFolder(curPath^);
echo fileSystem.rmdirSync(curPath^);
echo ^} else ^{
echo fileSystem.unlinkSync(curPath^);
echo ^}
echo ^}^);
echo ^}
echo ^}
echo.
echo gulp.task('custom:after-all', function (^)^{
echo var mainTask = process.argv.slice(2^)^[0^];
echo if (mainTask === 'build:watch_local'^) ^{
echo var dest = path.join(process.cwd(^), '..', 'pdca0-deploy-arch', 'node_modules', '@isp', '!module!'^);
echo if (!fileSystem.existsSync(dest^)^)^{
echo emptyFolder(dest^);
echo ^}
echo return gulp.src(^`${configuration.distFolder}/**^`^)
echo .pipe(gulp.dest(dest^)^);
echo ^}
echo ^}^);
) > "!cd!\local-gulpfile.js"
) else (
findstr /C:"require('gulp')" "!cd!\local-gulpfile.js" >nul || (
echo.
echo var gulp = require('gulp'^);
echo.
) >> "!cd!\local-gulpfile.js"
findstr /C:"require('path')" "!cd!\local-gulpfile.js" >nul || (
echo.
echo var path = require('path'^);
echo.
) >> "!cd!\local-gulpfile.js"
findstr /C:"require('path')" "!cd!\local-gulpfile.js" >nul || (
echo.
echo var path = require('path'^);
echo.
) >> "!cd!\local-gulpfile.js"
findstr /C:"custom:after-all" "!cd!\local-gulpfile.js" >nul || (
echo.
echo var fileSystem = require('fs'^);
echo.
echo function emptyFolder(directoryPath^) ^{
echo if (fileSystem.existsSync(directoryPath^)^) ^{
echo fileSystem.readdirSync(directoryPath^).forEach(function (file^) ^{
echo var curPath = path.join(directoryPath, file^);
echo if (fileSystem.lstatSync(curPath^).isDirectory(^)^) ^{
echo emptyFolder(curPath^);
echo fileSystem.rmdirSync(curPath^);
echo ^} else ^{
echo fileSystem.unlinkSync(curPath^);
echo ^}
echo ^}^);
echo ^}
echo ^}
echo.
echo gulp.task('custom:after-all', function (^)^{
echo var mainTask = process.argv.slice(2^)^[0^];
echo if (mainTask === 'build:watch_local'^) ^{
echo var dest = path.join(process.cwd(^), '..', 'pdca0-deploy-arch', 'node_modules', '@isp', '!module!'^);
echo if (!fileSystem.existsSync(dest^)^)^{
echo emptyFolder(dest^);
echo ^}
echo return gulp.src(^`${configuration.distFolder}/**^`^)
echo .pipe(gulp.dest(dest^)^);
echo ^}
echo ^}^);
) >> "!cd!\local-gulpfile.js"
)
:: Controllo esistenza node_modules e package-lock.json
if not exist "!cd!\node_modules" (
echo node_modules non esiste, eseguo npm install...
npm install
) else if not exist "!cd!\package-lock.json" (
echo package-lock.json non esiste, eseguo npm install...
npm install
)
echo Avvio e !module!
:: Esegue npm run build:watch_local
start cmd /k "npm run build:watch_local"
)
netstat -ano | findstr :4200 >nul
if errorlevel 1 (
set "deploy_name=pdca0-deploy-arch"
echo Attendi 15 secondi prima di avviare !deploy_name!...
:: Attendi 15 secondi
timeout /t 15 /nobreak
set "deploy_dir=!current_dir!!deploy_name!"
cd /d !deploy_dir!
echo Avvio !deploy_name!
start cmd /k "npm start"
)
endlocal
exit

10
cmd/pdca0-fe.ps1 Normal file
View File

@ -0,0 +1,10 @@
# Avvia la UI dei tool backend PDCA0
$scriptPath = Resolve-Path (Join-Path $PSScriptRoot '../src/darwin/frontend/ui.ps1')
if (Test-Path $scriptPath) {
& $scriptPath
} else {
Write-Host "File non trovato: $scriptPath" -ForegroundColor Red
exit 1
}

View File

@ -14,13 +14,23 @@
.\set-git-config-new.ps1 -Username "Mario Rossi" -Email "mario.rossi@intesasanpaolo.com" -RootDir "C:\Users\MarioRossi\progetti" .\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 ( param (
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$false)]
[string]$Username, [string]$Username,
[Parameter(Mandatory=$false)]
[Parameter(Mandatory=$true)]
[string]$Email, [string]$Email,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$RootDir [string]$RootDir
) )
@ -91,7 +101,7 @@ foreach ($dir in $directories) {
Write-Host "Repository trovato: $dirPath" -ForegroundColor Blue Write-Host "Repository trovato: $dirPath" -ForegroundColor Blue
# Imposta la configurazione Git # Imposta la configurazione Git
Set-GitConfig -RepoPath $dirPath -Username $Username -Email $Email Set-GitConfig -RepoPath $dirPath
$successfulRepos++ $successfulRepos++
} }
} }

View File

@ -1,7 +1,13 @@
@echo off @echo off
setlocal enabledelayedexpansion
call git commit --allow-empty -m "RELEASE" set "commit_message=RELEASE"
if "%~1" neq "" (
set "commit_message=RELEASE %~1"
)
if "%~1" neq "false" ( call git commit --allow-empty -m "!commit_message!"
call git push
if "%~2" neq "false" (
call git push -f
) )

View File

@ -0,0 +1,22 @@
@echo off
setlocal enabledelayedexpansion
echo Hai aggiornato il changelog? [s/n]
set /p changelog_ok=
if /I not "!changelog_ok!"=="s" (
echo Aggiorna prima il changelog. Operazione annullata.
exit /b 1
)
set "commit_message=RELEASE"
if "%~1" neq "" (
set "commit_message=RELEASE %~1"
)
cd ..\..\pdca0\xdce-module-widget-fideuram-v1
call git commit --allow-empty -m "!commit_message!"
if "%~2" neq "false" (
call git push -f
)

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": [ "xdce_modules": [
"pdca0-ui", "pdca0-ui",
"xdce-module-arc-v1", "xdce-module-sost-esg-v1",
"xdce-module-widget-fideuram-v1" "xdce-module-widget-fideuram-v1"
], ],
"backend_modules": [ "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" "deploy_module": "pdca0-deploy-arch"
} }

View File

@ -136,7 +136,7 @@ $btnInstall.Add_Click({
return return
} }
$form.Enabled = $false $form.Enabled = $false
$positions = Get-TerminalPositions $modules.Count # $positions = Get-TerminalPositions $modules.Count
foreach ($mod in $selected) { foreach ($mod in $selected) {
$index = [Array]::IndexOf($modules, $mod) $index = [Array]::IndexOf($modules, $mod)
if ($index -lt 0) { continue } 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) [System.Windows.Forms.MessageBox]::Show("Modulo non trovato: $modPathRaw", "Errore", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
continue 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 + "`"" $cmd = "cd /d $ScriptDir && install.bat `"" + $modPath + "`""
$pos = $positions[$index] # $pos = $positions[$index]
powershell -ExecutionPolicy Bypass -File $startCmdPosScript -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height # 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) [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 $form.Enabled = $true
@ -164,7 +166,7 @@ $btnStart.Add_Click({
return return
} }
$form.Enabled = $false $form.Enabled = $false
$positions = Get-TerminalPositions $modules.Count # $positions = Get-TerminalPositions $modules.Count FIX-ME: non funziona
foreach ($mod in $selected) { foreach ($mod in $selected) {
$index = [Array]::IndexOf($modules, $mod) $index = [Array]::IndexOf($modules, $mod)
if ($index -lt 0) { continue } 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) [System.Windows.Forms.MessageBox]::Show("Modulo non trovato: $modPathRaw", "Errore", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
continue 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 + "`"" $cmd = "cd /d $ScriptDir && $batName `"" + $modPath + "`""
$pos = $positions[$index] # $pos = $positions[$index]
powershell -ExecutionPolicy Bypass -File $startCmdPosScript -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height # 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) [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 $form.Enabled = $true

View File

@ -2,30 +2,13 @@
setlocal enableDelayedExpansion setlocal enableDelayedExpansion
:: Install dependencies if either node_modules or package-lock.json does not exist @echo off
setlocal enabledelayedexpansion
set "current_dir=%~1" set "module_name=%~1"
set "folder_name=%~2" call echo Installo %module_name%... && cd %module_name% && call npm install
if "%~2" neq "" ( if !errorlevel! neq 0 (
set "folder_name=%~2\" exit /b
) )
exit
set "is_test=false"
if "%~3" neq "" (
set "is_test=%~3"
)
if "!is_test!" == "false" (
if not exist "%current_dir%!folder_name!node_modules" (
cd "%current_dir%!folder_name!"
npm install
cd "%current_dir%"
)
if not exist "%current_dir%!folder_name!package-lock.json" (
cd "%current_dir%!folder_name!"
npm install
cd "%current_dir%"
)
)
exit /b

View File

@ -0,0 +1,25 @@
@echo off
setlocal enabledelayedexpansion
set deploy_path=%~1
for %%f in ("%deploy_path%") do set "deploy_name=%%~nxf"
cd /d %deploy_path%
netstat -ano | findstr :4200 >nul
if errorlevel 1 (
echo Attendi 15 secondi prima di avviare %deploy_name%...
:: Attendi 15 secondi
timeout /t 15 /nobreak
echo Avvio %deploy_name%
call npm start
endlocal
exit
)
echo %deploy_name% gia' in esecuzione.
endlocal
exit /b

198
src/darwin/frontend/ui.ps1 Normal file
View File

@ -0,0 +1,198 @@
#requires -Version 5.1
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# Percorso file config
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$jsonPath = Resolve-Path (Join-Path $ScriptDir "..\..\..\resources\pdca0-config.json")
if (!(Test-Path $jsonPath)) {
[System.Windows.Forms.MessageBox]::Show("File di configurazione non trovato: $jsonPath", "Errore", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
exit 1
}
. "$ScriptDir\..\..\general\get-terminal-positions.ps1"
$pdca0Path = Join-Path $ScriptDir "..\..\..\..\pdca0"
# Lettura moduli dal file JSON
$json = Get-Content $jsonPath -Raw | ConvertFrom-Json
$modules = @()
if ($json.xdce_modules) { $modules += $json.xdce_modules }
if ($json.deploy_module) { $modules += $json.deploy_module }
$modules = $modules | Sort-Object -Unique
if ($modules.Count -eq 0) {
[System.Windows.Forms.MessageBox]::Show("Nessun modulo trovato nel file di configurazione.", "Errore", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
exit 1
}
# Crea form in stile setup-conf.ps1
$form = New-Object System.Windows.Forms.Form
$form.Text = "Darwin PDCA0 Frontend Util"
$form.Size = New-Object System.Drawing.Size(600, 500)
$form.StartPosition = "CenterScreen"
# TableLayoutPanel principale
$mainPanel = New-Object System.Windows.Forms.TableLayoutPanel
$mainPanel.Dock = [System.Windows.Forms.DockStyle]::Fill
$mainPanel.RowCount = 2
$mainPanel.ColumnCount = 1
$mainPanel.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 100)))
$mainPanel.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Absolute, 35)))
$form.Controls.Add($mainPanel)
# Pannello bianco con bordo per i checkbox
$dictPanel = New-Object System.Windows.Forms.Panel
$dictPanel.Dock = [System.Windows.Forms.DockStyle]::Fill
$dictPanel.BorderStyle = 'Fixed3D'
$dictPanel.BackColor = 'White'
$dictPanel.AutoScroll = $true
$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)
# Suddividi moduli in core e modules
$deployModule = @()
$xdceModules = @()
if ($json.deploy_module) { $deployModule += $json.deploy_module }
if ($json.xdce_modules) { $xdceModules += $json.xdce_modules }
$deployModule = $deployModule | Sort-Object -Unique
$xdceModules = $xdceModules | Sort-Object -Unique
$checkboxes = @()
$y = 10
# Label deploy_module
$deployLabel = New-Object System.Windows.Forms.Label
$deployLabel.Text = "deploy_module"
$deployLabel.Font = New-Object System.Drawing.Font('Segoe UI', 9, [System.Drawing.FontStyle]::Regular)
$deployLabel.Location = New-Object System.Drawing.Point(10, $y)
$deployLabel.Size = New-Object System.Drawing.Size(200, 20)
$dictPanel.Controls.Add($deployLabel)
$y += 22
# Checkbox core
foreach ($mod in $deployModule) {
$cb = New-Object System.Windows.Forms.CheckBox
$cb.Text = $mod
$cb.Font = New-Object System.Drawing.Font('Segoe UI', 9, [System.Drawing.FontStyle]::Regular)
$cb.Location = New-Object System.Drawing.Point(30, $y)
$cb.Size = New-Object System.Drawing.Size(510, 22)
$cb.Checked = $true
$dictPanel.Controls.Add($cb)
$checkboxes += $cb
$y += 24
}
$y += 10
# Label xdce_modules
$modulesLabel = New-Object System.Windows.Forms.Label
$modulesLabel.Text = "frontend_modules"
$modulesLabel.Font = New-Object System.Drawing.Font('Segoe UI', 9, [System.Drawing.FontStyle]::Regular)
$modulesLabel.Location = New-Object System.Drawing.Point(10, $y)
$modulesLabel.Size = New-Object System.Drawing.Size(200, 20)
$dictPanel.Controls.Add($modulesLabel)
$y += 22
# Checkbox modules
foreach ($mod in $xdceModules) {
$cb = New-Object System.Windows.Forms.CheckBox
$cb.Text = $mod
$cb.Font = New-Object System.Drawing.Font('Segoe UI', 9, [System.Drawing.FontStyle]::Regular)
$cb.Location = New-Object System.Drawing.Point(30, $y)
$cb.Size = New-Object System.Drawing.Size(510, 22)
$cb.Checked = $true
$dictPanel.Controls.Add($cb)
$checkboxes += $cb
$y += 24
}
# Pannello per il bottone in basso
$buttonPanel = New-Object System.Windows.Forms.Panel
$buttonPanel.Dock = [System.Windows.Forms.DockStyle]::Fill
$buttonPanel.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Left -bor [System.Windows.Forms.AnchorStyles]::Right
$buttonPanel.Height = 45
$mainPanel.Controls.Add($buttonPanel, 0, 1)
# Bottone installa
$btnInstall = New-Object System.Windows.Forms.Button
$btnInstall.Text = "Installa selezionati"
$btnInstall.Size = New-Object System.Drawing.Size(120, 25)
$btnInstall.Font = New-Object System.Drawing.Font('Segoe UI', 9, [System.Drawing.FontStyle]::Regular)
$btnInstall.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right
$btnInstall.Location = New-Object System.Drawing.Point(320, 0)
$buttonPanel.Controls.Add($btnInstall)
# Bottone avvia
$btnStart = New-Object System.Windows.Forms.Button
$btnStart.Text = "Avvia selezionati"
$btnStart.Size = New-Object System.Drawing.Size(120, 25)
$btnStart.Font = New-Object System.Drawing.Font('Segoe UI', 9, [System.Drawing.FontStyle]::Regular)
$btnStart.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right
$btnStart.Location = New-Object System.Drawing.Point(450, 0)
$buttonPanel.Controls.Add($btnStart)
# Azione installazione
$btnInstall.Add_Click({
$selected = $checkboxes | Where-Object { $_.Checked } | ForEach-Object { $_.Text }
if ($selected.Count -eq 0) {
[System.Windows.Forms.MessageBox]::Show("Seleziona almeno un modulo.", "Attenzione", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Warning)
return
}
$form.Enabled = $false
# $positions = Get-TerminalPositions $modules.Count
foreach ($mod in $selected) {
$index = [Array]::IndexOf($modules, $mod)
if ($index -lt 0) { continue }
$modPathRaw = Join-Path $pdca0Path $mod
try {
$modPath = Resolve-Path $modPathRaw -ErrorAction Stop | Select-Object -ExpandProperty Path
} catch {
[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"
$startCmdScript = Join-Path $ScriptDir "..\..\general\start-cmd.ps1"
$cmd = "cd /d $ScriptDir && install.bat `"" + $modPath + "`""
# $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
})
# Azione avvio
$btnStart.Add_Click({
$selected = $checkboxes | Where-Object { $_.Checked } | ForEach-Object { $_.Text }
if ($selected.Count -eq 0) {
[System.Windows.Forms.MessageBox]::Show("Seleziona almeno un modulo.", "Attenzione", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Warning)
return
}
$form.Enabled = $false
# $positions = Get-TerminalPositions $modules.Count FIX-ME: non funziona
foreach ($mod in $selected) {
$index = [Array]::IndexOf($modules, $mod)
if ($index -lt 0) { continue }
$isCore = $deployModule -contains $mod
if ($isCore) {
$batName = "start_deploy.bat"
} else {
$batName = "watch_module.bat"
}
$modPathRaw = Join-Path $pdca0Path $mod
try {
$modPath = Resolve-Path $modPathRaw -ErrorAction Stop | Select-Object -ExpandProperty Path
} catch {
[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"
$startCmdScript = Join-Path $ScriptDir "..\..\general\start-cmd.ps1"
$cmd = "cd /d $ScriptDir && $batName `"" + $modPath + "`""
# $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
})
# Avvia la UI
[void]$form.ShowDialog()

View File

@ -0,0 +1,102 @@
@echo off
setlocal enabledelayedexpansion
set module_path=%~1
for %%f in ("%module_path%") do set "module_name=%%~nxf"
cd /d %module_path%
echo Eseguo controlli su !cd!
:: Controlla se local-gulpfile.js esiste
if not exist "!cd!\local-gulpfile.js" (
(
echo var gulp = require('gulp'^);
echo var path = require('path'^);
echo var fileSystem = require('fs'^);
echo.
echo function emptyFolder(directoryPath^) ^{
echo if (fileSystem.existsSync(directoryPath^)^) ^{
echo fileSystem.readdirSync(directoryPath^).forEach(function (file^) ^{
echo var curPath = path.join(directoryPath, file^);
echo if (fileSystem.lstatSync(curPath^).isDirectory(^)^) ^{
echo emptyFolder(curPath^);
echo fileSystem.rmdirSync(curPath^);
echo ^} else ^{
echo fileSystem.unlinkSync(curPath^);
echo ^}
echo ^}^);
echo ^}
echo ^}
echo.
echo gulp.task('custom:after-all', function (^)^{
echo var mainTask = process.argv.slice(2^)^[0^];
echo if (mainTask === 'build:watch_local'^) ^{
echo var dest = path.join(process.cwd(^), '..', 'pdca0-deploy-arch', 'node_modules', '@isp', '%module_name%'^);
echo if (!fileSystem.existsSync(dest^)^)^{
echo emptyFolder(dest^);
echo ^}
echo return gulp.src(^`${configuration.distFolder}/**^`^)
echo .pipe(gulp.dest(dest^)^);
echo ^}
echo ^}^);
) > "!cd!\local-gulpfile.js"
) else (
findstr /C:"require('gulp')" "!cd!\local-gulpfile.js" >nul || (
echo.
echo var gulp = require('gulp'^);
echo.
) >> "!cd!\local-gulpfile.js"
findstr /C:"require('path')" "!cd!\local-gulpfile.js" >nul || (
echo.
echo var path = require('path'^);
echo.
) >> "!cd!\local-gulpfile.js"
findstr /C:"require('path')" "!cd!\local-gulpfile.js" >nul || (
echo.
echo var path = require('path'^);
echo.
) >> "!cd!\local-gulpfile.js"
findstr /C:"custom:after-all" "!cd!\local-gulpfile.js" >nul || (
echo.
echo var fileSystem = require('fs'^);
echo.
echo function emptyFolder(directoryPath^) ^{
echo if (fileSystem.existsSync(directoryPath^)^) ^{
echo fileSystem.readdirSync(directoryPath^).forEach(function (file^) ^{
echo var curPath = path.join(directoryPath, file^);
echo if (fileSystem.lstatSync(curPath^).isDirectory(^)^) ^{
echo emptyFolder(curPath^);
echo fileSystem.rmdirSync(curPath^);
echo ^} else ^{
echo fileSystem.unlinkSync(curPath^);
echo ^}
echo ^}^);
echo ^}
echo ^}
echo.
echo gulp.task('custom:after-all', function (^)^{
echo var mainTask = process.argv.slice(2^)^[0^];
echo if (mainTask === 'build:watch_local'^) ^{
echo var dest = path.join(process.cwd(^), '..', 'pdca0-deploy-arch', 'node_modules', '@isp', '%module_name%'^);
echo if (!fileSystem.existsSync(dest^)^)^{
echo emptyFolder(dest^);
echo ^}
echo return gulp.src(^`${configuration.distFolder}/**^`^)
echo .pipe(gulp.dest(dest^)^);
echo ^}
echo ^}^);
) >> "!cd!\local-gulpfile.js"
)
echo Avvio %module_name%
:: Esegue npm run build:watch_local
call npm run build:watch_local
endlocal
exit

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 $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) $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) { foreach ($key in $modulesDict.Keys) {
$label = New-Object Windows.Forms.Label $label = New-Object Windows.Forms.Label
$label.Text = $key $label.Text = $key
@ -135,6 +165,10 @@ function Show-ConfigForm {
$btnSave.Size = New-Object Drawing.Size(80, 25) $btnSave.Size = New-Object Drawing.Size(80, 25)
$btnSave.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right $btnSave.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right
$btnSave.Add_Click({ $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) { foreach ($key in $modulesDict.Keys) {
$controlsForKey = $controls[$key] $controlsForKey = $controls[$key]
if ($controlsForKey[0] -is [Windows.Forms.CheckBox]) { 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