-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate-Simple.ps1
69 lines (59 loc) · 2.52 KB
/
Create-Simple.ps1
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
param (
[Parameter(Mandatory=$true)]
[string]$ProjectName,
[Parameter(Mandatory=$false)]
[int] $Unsupervised=0,
[Parameter(Mandatory=$false)]
[string] $axopen_templates_branch_name="dev",
[Parameter(Mandatory=$false)]
[string]$TargetIp = "10.10.10.120"
)
# Check project name defined
$pattern = '^[A-Za-z][A-Za-z0-9_]*$'
# Validate the project name
if (-not ($ProjectName -match $pattern)) {
Write-Host "The project name value does not match the required pattern." -ForegroundColor Red
Write-Host "Rules:"
Write-Host "1. The project name must start with a letter (uppercase or lowercase)."
Write-Host "2. Subsequent characters can include letters, numbers, and underscores (_)."
Write-Host "Example of valid project names: 'ProjectName', 'Project123', 'Valid_Name'." -ForegroundColor Yellow
Write-Host "Example of invalid project names: '123Project', 'Project-Name', 'Project.Name'." -ForegroundColor Yellow
exit 1 # Exit the script with a non-zero status code
}
# Define repository directories
$axopenRepoDir = ".\$ProjectName\axopen"
$axopenTemplatesRepoDir = ".\axopen.templates"
# Check if axopen.templates repository is already cloned
if (-Not (Test-Path -Path $axopenTemplatesRepoDir)) {
git clone -b $axopen_templates_branch_name https://github.com/inxton/axopen.templates.git
Write-Host "AXOpen templates repository cloned."
} else {
Write-Host "AXOpen templates repository already exists. Skipping cloning."
}
# Install dotnet template and create project
dotnet new install "$axopenTemplatesRepoDir\axopen.template.simple\" --force
dotnet new axosimple -n $ProjectName -o "$ProjectName/app/"
Write-Host "New AXOpen project created in '$ProjectName/app/'."
# Copy the workspace_apax.yml file
Copy-Item -Path "$axopenTemplatesRepoDir\apax.yml" -Destination ".\$ProjectName\apax.yml" -Force
Write-Host "Workplace apax.yml copied."
# Check if axopen repository is already cloned
if (-Not (Test-Path -Path $axopenRepoDir)) {
git clone -b dev https://github.com/inxton/AXOpen.git $axopenRepoDir
Write-Host "AXOpen repository cloned."
# Build axopen if it was just cloned or already exists
Set-Location $axopenRepoDir
.\build
Set-Location ..
}
else {
Write-Host "AXOpen repository already exists. Skipping cloning."
}
# Run templates install.ps1 script
Set-Location .\app
.\install.ps1 -Unsupervised 1 -TargetIp $TargetIp
# Clean up
Remove-Item .\install.ps1
Remove-Item .\install.cmd
Set-Location ..\..\
Remove-Item -Path "axopen.templates" -Recurse -Force