Skip to content

Commit 3fc2fc8

Browse files
add build script powershell
gug fix with categories
1 parent 750a0f5 commit 3fc2fc8

File tree

13 files changed

+219
-11
lines changed

13 files changed

+219
-11
lines changed

Client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sunengine-client",
3-
"version": "2.12.3",
3+
"version": "2.12.4",
44
"description": "SunEngine - web engine with support of blog, forum and articles functionality",
55
"productName": "SunEngine",
66
"author": "Dmitrij Polianin",

Client/src/admin/menuItems/CreateMenuItem.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default {
7878
.then(() => {
7979
this.$successNotify();
8080
this.$store.dispatch("loadAllMenuItems");
81-
this.$router.replace({ name: "MenuItemsAdmin" });
81+
this.$router.push({ name: "MenuItemsAdmin" });
8282
})
8383
.catch(error => {
8484
this.$errorNotify(error);

Client/src/comp/LinksMenu.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
v-if="menuItem.subMenuItems"
66
v-for="(subItem, index) of menuItem.subMenuItems"
77
>
8-
<router-link :class="classes" v-if="subItem.to" :to="subItem.to">{{
8+
<router-link :class="classes + ' ' + subItem.cssClass" v-if="subItem.to" :to="subItem.to">{{
99
subItem.title
1010
}}</router-link>
1111
<a
12-
:class="classes"
12+
:class="classes + ' ' + subItem.cssClass"
1313
:href="subItem.externalUrl"
1414
target="_blank"
1515
v-else-if="subItem.externalUrl"
@@ -40,7 +40,8 @@ export default {
4040
computed: {
4141
classes() {
4242
let rez = "links-menu__link";
43-
if (this.linkClasses) return (rez += " " + this.linkClasses);
43+
if (this.linkClasses)
44+
return rez + " " + this.linkClasses;
4445
return rez;
4546
}
4647
},

Client/src/modules/articles/articles1Layout.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
params: {}
99
};
1010

11+
if(!category.subCategories)
12+
return;
13+
1114
for (const cat of category.subCategories) {
1215
cat.route = {
1316
name: `cat-${category.name}-cat`,

Client/src/modules/articles/articles2Layout.js

+7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
params: {}
99
};
1010

11+
if(!category.subCategories)
12+
return;
13+
1114
for (const cat0 of category.subCategories) {
15+
16+
if(!cat0.subCategories)
17+
continue;
18+
1219
for (const cat1 of cat0.subCategories) {
1320
cat1.route = {
1421
name: `cat-${category.name}-cat`,

Client/src/modules/forum/forum1Layout.js

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export default {
1111
params: {}
1212
};
1313

14+
if(!category.subCategories)
15+
return;
16+
1417
for (const cat of category.subCategories) {
1518
cat.route = {
1619
name: `cat-${category.name}-cat`,

Client/src/modules/forum/forum2Layout.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ export default {
1212
params: {}
1313
};
1414

15-
for (const cat0 of category.subCategories) {
15+
if(!category.subCategories)
16+
return;
17+
18+
for (const cat0 of category.subCategories) {
19+
20+
if(!cat0.subCategories)
21+
continue;
22+
1623
for (const cat1 of cat0.subCategories) {
1724
cat1.route = {
1825
name: `cat-${category.name}-cat`,

README.RU.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# SunEngine
1111

12-
<a href="#"><img src="https://img.shields.io/static/v1?label=%D0%92%D0%B5%D1%80%D1%81%D0%B8%D1%8F&message=v2.12.3&color=green"></a>
12+
<a href="#"><img src="https://img.shields.io/static/v1?label=%D0%92%D0%B5%D1%80%D1%81%D0%B8%D1%8F&message=v2.12.4&color=green"></a>
1313
<a href="#"><img src="https://github.com/sunengine/SunEngine/workflows/.NET%20Core/badge.svg" ></a>
1414
<a href="#"><img src="https://github.com/sunengine/SunEngine/workflows/Quasar/badge.svg" ></a>
1515
<br/>

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Build on AspNet Core, VueJS, Quasar.</h3>
88

99
# SunEngine
1010

11-
<a href="#"><img src="https://img.shields.io/static/v1?label=Version&message=v2.12.3&color=green"></a>
11+
<a href="#"><img src="https://img.shields.io/static/v1?label=Version&message=v2.12.4&color=green"></a>
1212
<a href="#"><img src="https://github.com/sunengine/SunEngine/workflows/.NET%20Core/badge.svg" ></a>
1313
<a href="#"><img src="https://github.com/sunengine/SunEngine/workflows/Quasar/badge.svg" ></a>
1414
<br/>

Scripts/build.ps1

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
function Get-VariablesFromFile($filename = "BUILD") {
2+
$fullPath = Join-Path -Path $PWD -ChildPath $filename
3+
if (-not(Test-Path -Path $fullPath -PathType Leaf)) {
4+
Write-Output "BUILD file is missing"
5+
Write-Output "Script should execute from ""Scripts"" directory"
6+
exit
7+
}
8+
$content = Get-Content -Path $fullPath -Raw
9+
$pattern = @"
10+
(?<key>^[A-Z]\w+)="(?<value>.+)"
11+
"@
12+
$dict = New-Object "System.Collections.Generic.Dictionary[String,String]"
13+
$_matches = [System.Text.RegularExpressions.Regex]::Matches($content, $pattern,
14+
[System.Text.RegularExpressions.RegexOptions]::Multiline)
15+
foreach ($match in $_matches) {
16+
$key = $match.Groups["key"].Value
17+
$value = $match.Groups["value"].Value
18+
$dict.Add($key, $value)
19+
}
20+
return $dict
21+
}
22+
23+
function Remove-RootProjectFromString([string]$str) {
24+
$n = $str.IndexOf('/')
25+
return $str.Substring($n)
26+
}
27+
28+
function Write-FormattedOutput {
29+
[CmdletBinding()]
30+
Param(
31+
[Parameter(Mandatory=$True,Position=1,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)][Object] $Object,
32+
[Parameter(Mandatory=$False)][ConsoleColor] $BackgroundColor,
33+
[Parameter(Mandatory=$False)][ConsoleColor] $ForegroundColor
34+
)
35+
36+
# save the current color
37+
$bc = $host.UI.RawUI.BackgroundColor
38+
$fc = $host.UI.RawUI.ForegroundColor
39+
40+
# set the new color
41+
if($BackgroundColor -ne $null) {
42+
$host.UI.RawUI.BackgroundColor = $BackgroundColor
43+
}
44+
45+
if($ForegroundColor -ne $null) {
46+
$host.UI.RawUI.ForegroundColor = $ForegroundColor
47+
}
48+
49+
Write-Output $Object
50+
51+
# restore the original color
52+
$host.UI.RawUI.BackgroundColor = $bc
53+
$host.UI.RawUI.ForegroundColor = $fc
54+
}
55+
56+
$d = Get-VariablesFromFile -filename "BUILD"
57+
58+
$project_root
59+
$server_path
60+
$client_path
61+
$config_path
62+
$build_path
63+
$npm_util = $d["NPM_UTIL"]
64+
65+
if ($d["PROJECT_ROOT"] -eq "auto") {
66+
while (-not (Test-Path -Path (Join-Path -Path $PWD -ChildPath "SunEngine.md"))) {
67+
Set-Location ..\ | Out-Null
68+
}
69+
$project_root = $PWD
70+
71+
}
72+
else {
73+
$project_root = $d["PROJECT_ROOT"]
74+
}
75+
76+
$server_path = Join-Path -Path $PWD -ChildPath (Remove-RootProjectFromString($d["SERVER_PATH"]))
77+
$client_path = Join-Path -Path $PWD -ChildPath (Remove-RootProjectFromString($d["CLIENT_PATH"]))
78+
$config_path = Join-Path -Path $PWD -ChildPath (Remove-RootProjectFromString($d["CONFIG_PATH"]))
79+
$build_path = Join-Path -Path $PWD -ChildPath (Remove-RootProjectFromString($d["BUILD_PATH"]))
80+
81+
Write-FormattedOutput -Object "Building $($d["PROJECT_NAME"]) project." -ForegroundColor Green
82+
83+
Write-FormattedOutput -Object "PROJECT_ROOT = $($project_root)." -ForegroundColor Green
84+
Write-FormattedOutput -Object "SERVER_PATH = $($server_path)." -ForegroundColor Green
85+
Write-FormattedOutput -Object "CLIENT_PATH = $($client_path)." -ForegroundColor Green
86+
Write-FormattedOutput -Object "CONFIG_PATH = $($config_path)." -ForegroundColor Green
87+
Write-FormattedOutput -Object "BUILD_PATH = $($build_path)." -ForegroundColor Green
88+
89+
# check Config directory exists
90+
if (Test-Path -Path (Join-Path -Path $project_root -ChildPath "Config.template")) {
91+
Write-FormattedOutput -Object "Creating Config directory from Config.template" -ForegroundColor Green
92+
$p = Join-Path -Path $project_root -ChildPath "Config.template"
93+
Copy-Item -Source $p -Destination $config_path -Force
94+
}
95+
96+
Write-FormattedOutput -Object "Deleting old build" -ForegroundColor Green
97+
Remove-Item -Path $build_path -Recurse
98+
New-Item -Path $build_path -ItemType Directory | Out-Null
99+
100+
# dotnet build
101+
try {
102+
$path1 = Join-Path -Path $server_path -ChildPath "SunEngine.Cli"
103+
$path2 = Join-Path -Path $build_path -ChildPath "Server"
104+
& dotnet publish --configuration Release $path1 --output $path2 | Out-Null
105+
if ($LASTEXITCODE -ne 0) {
106+
throw new [System.Exception]
107+
}
108+
}
109+
catch [System.Management.Automation.CommandNotFoundException] {
110+
Write-FormattedOutput -Object ".NET Core not install." -ForegroundColor Red
111+
exit
112+
}
113+
catch {
114+
Set-Location -Path (Join-Path -Path $project_root -ChildPath "Scripts")
115+
Write-FormattedOutput -Object "Crush build .net applicaton" -ForegroundColor Red
116+
exit
117+
}
118+
119+
Write-FormattedOutput -Object "Building Client" -ForegroundColor Green
120+
Set-Location -Path $client_path | Out-Null
121+
# install node_modules
122+
try {
123+
& $npm_util install | Out-Null
124+
if ($LASTEXITCODE -ne 0) {
125+
throw new [System.Exception]
126+
}
127+
}
128+
catch [System.Management.Automation.CommandNotFoundException] {
129+
Write-FormattedOutput -Object "npm util not found" -ForegroundColor Red
130+
exit
131+
}
132+
catch {
133+
Set-Location -Path (Join-Path -Path $project_root -ChildPath "Scripts")
134+
Write-FormattedOutput -Object "Fail npm install" -ForegroundColor Red
135+
exit
136+
}
137+
138+
# check Client/src/site exists
139+
if (-not(Test-Path -Path (Join-Path -Path $client_path -ChildPath "src/site"))) {
140+
Write-FormattedOutput -Object "Copying $($client_path)/src/site.template => $($client_path)/src/site" -ForegroundColor Green
141+
$path1 = Join-Path -Path $client_path -ChildPath "src\site.template\*"
142+
$path2 = Join-Path -Path $client_path -ChildPath "src\site"
143+
New-Item -Path $path2 -ItemType Directory | Out-Null
144+
Copy-Item -Path $path1 -Destination $path2 -Recurse
145+
}
146+
# quasar build
147+
Write-FormattedOutput -Object "Quasar building" -ForegroundColor Blue
148+
try {
149+
& quasar build | Out-Null
150+
if ($LASTEXITCODE -ne 0) {
151+
throw new [System.Exception]
152+
}
153+
}
154+
catch [System.Management.Automation.CommandNotFoundException] {
155+
Write-FormattedOutput -Object "Quasar not install please install by command ""npm install -g @quasar/cli""" -ForegroundColor Red
156+
exit
157+
}
158+
catch {
159+
Set-Location -Path (Join-Path -Path $project_root -ChildPath "Scripts")
160+
Write-FormattedOutput -Object "Quasar build was failed" -ForegroundColor Red
161+
exit
162+
}
163+
164+
# copy dirs and files
165+
Write-FormattedOutput -Object "Copying Client to wwwroot directory" -ForegroundColor Green
166+
New-Item -Path (Join-Path -Path $build_path -ChildPath "wwwroot") -ItemType Directory | Out-Null
167+
Copy-Item -Path (Join-Path -Path $client_path -ChildPath "dist\spa\*") -Destination (Join-Path -Path $build_path -ChildPath "wwwroot") -Recurse
168+
169+
Write-FormattedOutput -Object "Clearing dist directory" -ForegroundColor Green
170+
Remove-Item -Path (Join-Path -Path $client_path -ChildPath "dist") -Recurse | Out-Null
171+
172+
Write-FormattedOutput -Object "Copying Config to build directory" -ForegroundColor Green
173+
New-Item -Path (Join-Path -Path $build_path -ChildPath "Сonfig") -ItemType Directory | Out-Null
174+
Copy-Item -Path $config_path -Destination (Join-Path -Path $build_path -ChildPath "Сonfig\") -Recurse
175+
176+
Write-FormattedOutput -Object "Copying Data to build directory" -ForegroundColor Green
177+
New-Item -Path (Join-Path -Path $build_path -ChildPath "Resources") -ItemType Directory | Out-Null
178+
Copy-Item -Path (Join-Path -Path $project_root -ChildPath "Resources\*") -Destination (Join-Path -Path $build_path -ChildPath "Resources\") -Recurse
179+
180+
Write-FormattedOutput -Object "Copying SunEngine.md file" -ForegroundColor Green
181+
Copy-Item -Path (Join-Path -Path $project_root -ChildPath "SunEngine.md") -Destination $build_path
182+
183+
Set-Location -Path (Join-Path -Path $project_root -ChildPath "Scripts")
184+
Write-FormattedOutput -Object "All Done!" -ForegroundColor Blue
185+
[System.Media.SystemSounds]::Beep.Play()
186+
Add-Type -AssemblyName System.Windows.Forms
187+
[System.Windows.Forms.MessageBox]::Show("All Done!")

Server/SunEngine.Cli/SunEngine.Cli.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
6-
<Version>2.12.3</Version>
6+
<Version>2.12.4</Version>
77
<Title>SunEngine</Title>
88
<Authors>Dmitrij Polianin</Authors>
99
<Description>Site engine with blog, forum and articles functionalities on Asp.Net Core and Vue.Js.</Description>

Server/SunEngine.Core/SunEngine.Core.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5-
<Version>2.12.3</Version>
5+
<Version>2.12.4</Version>
66
<LangVersion>default</LangVersion>
77
</PropertyGroup>
88

SunEngine.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SunEngine
2-
**Version 2.12.3**
2+
**Version 2.12.4**
33
***************************************************************
44
Do not delete this file! This file need to detect project root.
55
***************************************************************

0 commit comments

Comments
 (0)