NewProject config workflow integration
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,9 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[string]$ProjectPath
|
||||||
|
)
|
||||||
|
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
@@ -210,7 +216,28 @@ if ($MyInvocation.InvocationName -ne '.') {
|
|||||||
# Update config.json to use script's directory as structDir for portability
|
# Update config.json to use script's directory as structDir for portability
|
||||||
Update-ConfigStructDir -StructDir $script:LoaderRoot
|
Update-ConfigStructDir -StructDir $script:LoaderRoot
|
||||||
|
|
||||||
$projectPath = Get-ProjectPathFromUser
|
# Use provided ProjectPath parameter, or prompt user if not provided
|
||||||
|
if ([string]::IsNullOrWhiteSpace($ProjectPath)) {
|
||||||
|
$projectPath = Get-ProjectPathFromUser
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Remove quotes if present and resolve the provided path
|
||||||
|
$ProjectPath = $ProjectPath.Trim('"', "'")
|
||||||
|
try {
|
||||||
|
if (Test-Path -LiteralPath $ProjectPath -PathType Container) {
|
||||||
|
$projectPath = (Resolve-Path -LiteralPath $ProjectPath -ErrorAction Stop).Path
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Error "Project path does not exist or is not a directory: $ProjectPath"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "Unable to resolve project directory: $($_.Exception.Message)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($null -ne $projectPath) {
|
if ($null -ne $projectPath) {
|
||||||
# Deploy batch files and config to the project
|
# Deploy batch files and config to the project
|
||||||
$structDir = Get-StructDirectory
|
$structDir = Get-StructDirectory
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
@echo off
|
@echo off
|
||||||
setlocal EnableExtensions
|
setlocal EnableExtensions
|
||||||
|
|
||||||
set "SCRIPT_DIR=%~dp0"
|
:: Search for .config directory in current working directory (including subdirectories) to find ProjectStructure location
|
||||||
set "CONFIG_LOADER=%SCRIPT_DIR%ConfigLoader.ps1"
|
set "STRUCT_DIR="
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
for /f "usebackq delims=" %%I in (`powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
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 (
|
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
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -79,5 +79,16 @@ git add . -v
|
|||||||
git commit -m "init"
|
git commit -m "init"
|
||||||
popd >nul
|
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%
|
echo Project structure created successfully in folder: %projectRoot%
|
||||||
pause
|
pause
|
||||||
|
|||||||
Reference in New Issue
Block a user