NewProject config workflow integration
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
set "CONFIG_LOADER=%SCRIPT_DIR%ConfigLoader.ps1"
|
||||
set "CONFIG_PATH=%SCRIPT_DIR%config.json"
|
||||
|
||||
if not exist "%CONFIG_LOADER%" (
|
||||
echo [ERROR] ConfigLoader.ps1 not found next to NewProject.bat.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%CONFIG_PATH%" (
|
||||
echo [ERROR] config.json not found next to NewProject.bat.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Search for .config directory in current working directory (including subdirectories) to find ProjectStructure location
|
||||
set "STRUCT_DIR="
|
||||
for /f "usebackq delims=" %%I in (`powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
||||
"Set-StrictMode -Version Latest; $loader = Resolve-Path -LiteralPath '%CONFIG_LOADER%' -ErrorAction Stop; . $loader.Path; Write-Output (Get-StructDirectory)"`) do set "STRUCT_DIR=%%I"
|
||||
"$ErrorActionPreference = 'Continue'; $searchDir = '%CD%'; try { $subDirs = Get-ChildItem -LiteralPath $searchDir -Directory -Force -ErrorAction Stop; $configDirs = @(); foreach ($subDir in $subDirs) { $configPath = Join-Path $subDir.FullName '.config\config.json'; if (Test-Path -LiteralPath $configPath -PathType Leaf) { $configDirs += $configPath } }; if ($configDirs.Count -gt 0) { $configPath = $configDirs[0]; $config = Get-Content -LiteralPath $configPath -Raw | ConvertFrom-Json; if ($config.structDir) { $structDir = $config.structDir.ToString().Trim(); if ([System.IO.Path]::IsPathRooted($structDir)) { try { $resolved = Resolve-Path -LiteralPath $structDir -ErrorAction Stop; Write-Output $resolved.Path } catch { Write-Output $structDir } } else { $candidate = Join-Path (Split-Path -Parent $configPath) $structDir; try { $resolvedCandidate = Resolve-Path -LiteralPath $candidate -ErrorAction Stop; Write-Output $resolvedCandidate.Path } catch { Write-Output $candidate } } } } } catch { }"`) do set "STRUCT_DIR=%%I"
|
||||
|
||||
if not defined STRUCT_DIR (
|
||||
echo [ERROR] Unable to resolve ProjectStructure directory from config.
|
||||
echo [ERROR] Unable to find .config directory or resolve ProjectStructure directory.
|
||||
echo Please ensure you are running NewProject.bat from a directory containing projects with .config folders.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Debug: Show discovered structDir
|
||||
echo Found ProjectStructure directory: %STRUCT_DIR%
|
||||
|
||||
:: Locate ConfigLoader.ps1 in the ProjectStructure directory
|
||||
set "CONFIG_LOADER=%STRUCT_DIR%\ConfigLoader.ps1"
|
||||
|
||||
if not exist "%CONFIG_LOADER%" (
|
||||
echo [ERROR] ConfigLoader.ps1 not found at: %CONFIG_LOADER%
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
@@ -79,5 +79,16 @@ git add . -v
|
||||
git commit -m "init"
|
||||
popd >nul
|
||||
|
||||
:: Deploy config workflow using ConfigLoader.ps1
|
||||
echo.
|
||||
echo Deploying config workflow...
|
||||
for %%P in ("%projectRoot%") do set "PROJECT_ROOT_ABS=%%~fP"
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%CONFIG_LOADER%' -ProjectPath '%PROJECT_ROOT_ABS%'"
|
||||
if errorlevel 1 (
|
||||
echo [WARNING] Config workflow deployment failed. You may need to run ConfigLoader.ps1 manually.
|
||||
) else (
|
||||
echo Config workflow deployed successfully.
|
||||
)
|
||||
|
||||
echo Project structure created successfully in folder: %projectRoot%
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user