-
Notifications
You must be signed in to change notification settings - Fork 0
/
Create-Simple.ps1
53 lines (45 loc) · 2 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
param (
[Parameter(Mandatory=$true)]
[string]$ProjectName
)
# 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 = ".\axopen"
$axopenTemplatesRepoDir = ".\axopen.templates"
# Check if axopen repository is already cloned
if (-Not (Test-Path -Path $axopenRepoDir)) {
git clone -b dev https://github.com/ix-ax/AXOpen.git axopen
Write-Host "AXOpen repository cloned."
# Build axopen if it was just cloned or already exists
cd $axopenRepoDir
.\build
cd ..
}
else {
Write-Host "AXOpen repository already exists. Skipping cloning."
}
# Check if axopen.templates repository is already cloned
if (-Not (Test-Path -Path $axopenTemplatesRepoDir)) {
git clone -b dev https://github.com/ix-ax/axopen.templates.git
Write-Host "AXOpen templates repository cloned."
} else {
Write-Host "AXOpen templates repository already exists. Skipping cloning."
}
# Copy the workspace_apax.yml file
Copy-Item -Path "$axopenTemplatesRepoDir\workspace_apax.yml" -Destination "apax.yml" -Force
Write-Host "workspace_apax.yml copied."
# 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/'."