🐞 fix: Modify output, code cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# VDI WP Bootstrap — Windows (PowerShell + Herd) — local wp-cli.phar via php.exe
|
||||
# Easy WP Bootstrap — Windows (PowerShell + Herd) — local wp-cli.phar via php.exe
|
||||
|
||||
Param(
|
||||
[Parameter(Mandatory=$true)][string]$ProjectName,
|
||||
@@ -139,12 +139,12 @@ function Invoke-WP {
|
||||
$Slug = Slugify $ProjectName
|
||||
$ProjectDir = Join-Path $HerdWorkspace $Slug
|
||||
$LocalUrl = "http://$Slug.$LocalTld"
|
||||
$DbName = "vdi_$Slug"
|
||||
$DbName = "wp_$Slug"
|
||||
$DbUser = $DbName
|
||||
$DbPass = RandPass
|
||||
$AdminPass = RandPass
|
||||
|
||||
Write-Host "Creating project at $ProjectDir..."
|
||||
Write-Host "Creating project at $ProjectDir...`n"
|
||||
New-Item -ItemType Directory -Force -Path $ProjectDir | Out-Null
|
||||
Set-Location $ProjectDir
|
||||
|
||||
@@ -153,14 +153,14 @@ $pathShown = ((Get-Location).Path -replace '\\','/')
|
||||
Write-Host "WP-CLI php: $PhpExe"
|
||||
Write-Host "WP-CLI phar: $PharFullPath"
|
||||
Write-Host "WP-CLI --path: --path=$pathShown"
|
||||
Invoke-WP "cli" "version"
|
||||
|
||||
# ---- WP Core ----
|
||||
Invoke-WP "cli" "version"
|
||||
# Invoke-WP "--info"
|
||||
Write-Host "`nDownloading WordPress core..."
|
||||
Invoke-WP "core" "download" "--force"
|
||||
|
||||
# ---------- Database (DBngin/MySQL) ----------
|
||||
Write-Host "Creating MySQL DB and user..."
|
||||
Write-Host "`nCreating MySQL DB and user..."
|
||||
|
||||
# Build root arg list
|
||||
$mysqlArgsRoot = @("-h", $MysqlHost, "-P", $MysqlPort, "-u", $MysqlRootUser)
|
||||
@@ -253,11 +253,11 @@ RewriteRule . /index.php [L]
|
||||
# END WordPress
|
||||
"@
|
||||
Set-Content -Path $htFile -Value $ht -Encoding ASCII
|
||||
Write-Host "Created default .htaccess"
|
||||
Write-Host "`nCreated default .htaccess"
|
||||
}
|
||||
|
||||
# ---- Theme ----
|
||||
Write-Host "Cloning starter theme..."
|
||||
Write-Host "`nCloning starter theme..."
|
||||
$tmp = ".starter-tmp"
|
||||
if (Test-Path $tmp) { Remove-Item -Recurse -Force $tmp }
|
||||
git clone --depth=1 $ThemeStarterRepo $tmp | Out-Null
|
||||
@@ -268,8 +268,6 @@ New-Item -ItemType Directory -Force -Path (Split-Path $ThemeDir) | Out-Null
|
||||
Move-Item $tmp $ThemeDir
|
||||
if (Test-Path "$ThemeDir\.git") { Remove-Item -Recurse -Force "$ThemeDir\.git" }
|
||||
|
||||
Invoke-WP "theme" "activate" "$Slug"
|
||||
|
||||
# --- Stamp Theme Name + Text Domain into style.css ---
|
||||
$styleCss = Join-Path $ThemeDir "style.css"
|
||||
$TextDomain = "$Slug" # matches your theme folder name
|
||||
@@ -284,16 +282,20 @@ if (Test-Path $styleCss) {
|
||||
)
|
||||
|
||||
Set-Content -Path $styleCss -Value $css -Encoding UTF8
|
||||
Write-Host "Updated style.css header with Theme Name: $ProjectName"
|
||||
Write-Host "`nUpdated style.css header with Theme Name: $ProjectName`n"
|
||||
}
|
||||
|
||||
Invoke-WP "theme" "activate" "$Slug"
|
||||
|
||||
Push-Location $ThemeDir
|
||||
# ---- Init theme dependencies and build Tailwind ----
|
||||
Write-Host "`nInstalling theme dependencies and building assets..."
|
||||
composer install 2>$null
|
||||
npm install 2>$null
|
||||
npm run build 2>$null
|
||||
|
||||
# ---- Init new git repo ----
|
||||
Write-Host "`nInitializing new git repo for theme..."
|
||||
git init -b main | Out-Null
|
||||
git add -A
|
||||
git commit -m "feat: bootstrap ${ProjectName} theme from starter" | Out-Null
|
||||
@@ -309,7 +311,7 @@ $PluginsFile = if (Test-Path $PluginsFileProject) { $PluginsFileProject }
|
||||
|
||||
if ($PluginsFile) {
|
||||
try {
|
||||
Write-Host "Installing plugins from $PluginsFile..."
|
||||
Write-Host "`nInstalling plugins from $PluginsFile..."
|
||||
$plugins = Get-Content $PluginsFile -Raw | ConvertFrom-Json
|
||||
foreach ($plugin in $plugins) {
|
||||
if ($plugin.zip) {
|
||||
@@ -324,36 +326,39 @@ if ($PluginsFile) {
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Plugin install error: $_"
|
||||
Write-Host "`nPlugin install error: $_"
|
||||
}
|
||||
} else {
|
||||
Write-Host "No plugins.json found in project or script folder; skipping plugins."
|
||||
Write-Host "`nNo plugins.json found in project or script folder; skipping plugins."
|
||||
}
|
||||
|
||||
# ---- Summary ----
|
||||
$Summary = @"
|
||||
VDI WP Bootstrap — Summary
|
||||
Easy WP Bootstrap — Summary
|
||||
===========================
|
||||
|
||||
Project: $ProjectName
|
||||
Slug: $Slug
|
||||
Folder: $ProjectDir
|
||||
Local URL: $LocalUrl
|
||||
Local Admin URL: $LocalUrl/wp-admin/
|
||||
Project: $ProjectName
|
||||
Slug: $Slug
|
||||
Folder: $ProjectDir
|
||||
Theme Dir: $ThemeDir
|
||||
|
||||
DB Host: $MysqlHost
|
||||
DB Port: $MysqlPort
|
||||
DB Name: $DbName
|
||||
DB User: $DbUser
|
||||
DB Pass: $DbPass
|
||||
DB Host: $MysqlHost
|
||||
DB Port: $MysqlPort
|
||||
DB Name: $DbName
|
||||
DB User: $DbUser
|
||||
DB Pass: $DbPass
|
||||
|
||||
WP Admin User: $AdminUser
|
||||
WP Admin Pass: $AdminPass
|
||||
WP Admin Email: $AdminEmail
|
||||
Local URL: $LocalUrl
|
||||
Local Admin URL: $LocalUrl/wp-admin/
|
||||
|
||||
Theme Dir: $ThemeDir
|
||||
WP Admin Email: $AdminEmail
|
||||
WP Admin User: $AdminUser
|
||||
WP Admin Pass: $AdminPass
|
||||
"@
|
||||
|
||||
$SummaryFile = Join-Path $ProjectDir "bootstrap-summary.txt"
|
||||
|
||||
$Summary | Out-File -FilePath $SummaryFile -Encoding utf8
|
||||
Write-Host $Summary
|
||||
Write-Host "Saved summary to $SummaryFile"
|
||||
|
||||
Write-Host "`n`n$Summary"
|
||||
Write-Host "`nSaved summary to $SummaryFile"
|
||||
|
||||
Reference in New Issue
Block a user