-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.ps1
More file actions
86 lines (72 loc) · 2.47 KB
/
init.ps1
File metadata and controls
86 lines (72 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#Requires -Version 7.0
<#
.SYNOPSIS
Thin wrapper that collects interactive input, then delegates to NUKE Init target.
.EXAMPLE
./init.ps1
.EXAMPLE
./init.ps1 -ProjectName Acme.Payments -Author "Acme Corp" -Force
#>
param(
[ValidatePattern('^[A-Za-z][A-Za-z0-9.]*$')]
[string]$ProjectName,
[string]$Author,
[switch]$ResetGit,
[switch]$Force
)
$ErrorActionPreference = 'Stop'
$ScriptDir = $PSScriptRoot
# ── Interactive wizard ───────────────────────────────────────────────
if (-not $Force) {
Write-Host ""
Write-Host " ChengYuan - Project Setup" -ForegroundColor Cyan
Write-Host " =========================" -ForegroundColor Cyan
Write-Host ""
Write-Host " This wizard will customize the template for your project."
Write-Host ""
if (-not $ProjectName) {
do {
$ProjectName = Read-Host " ? Project name (e.g. Acme.Payments)"
if ($ProjectName -notmatch '^[A-Za-z][A-Za-z0-9.]*$') {
Write-Host " Must start with a letter and contain only letters, digits, and dots." -ForegroundColor Red
$ProjectName = ''
}
} while (-not $ProjectName)
}
Write-Host " Project name: $ProjectName" -ForegroundColor Green
if (-not $Author) {
$Author = Read-Host " ? Author / organization (leave blank to skip)"
}
if ($Author) {
Write-Host " Author: $Author" -ForegroundColor Green
}
if (-not $ResetGit) {
$resetAnswer = Read-Host " ? Reset git history to a fresh commit? [y/N]"
$ResetGit = $resetAnswer -match '^[Yy]'
}
Write-Host ""
Write-Host " WARNING: This operation is IRREVERSIBLE." -ForegroundColor Red
Write-Host ""
$confirm = Read-Host " ? Proceed? [y/N]"
if ($confirm -notmatch '^[Yy]') {
Write-Host ""
Write-Host " Cancelled." -ForegroundColor Yellow
exit 0
}
Write-Host ""
}
else {
if (-not $ProjectName) {
Write-Error "ProjectName is required when using -Force."
exit 1
}
}
# ── Delegate to NUKE Init target ─────────────────────────────────────
$buildArgs = @("Init", "--ProjectName", $ProjectName)
if ($Author) {
$buildArgs += @("--Author", $Author)
}
if ($ResetGit) {
$buildArgs += "--ResetGit"
}
& "$ScriptDir\build.ps1" @buildArgs