Skip to content

Commit f63d5b7

Browse files
Merge pull request #1210 from icsharpcode/vite
Vite
2 parents fb20877 + 2682205 commit f63d5b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3980
-20584
lines changed

.github/workflows/dotnet.yml

Lines changed: 95 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,33 @@ on:
55
branches: [ master, main ]
66
pull_request:
77
branches: [ master, main ]
8+
workflow_dispatch:
9+
inputs:
10+
publishNuget:
11+
description: "Publish NuGet package and dotnet tool"
12+
required: false
13+
type: boolean
14+
default: false
15+
deployWebFunc:
16+
description: "Deploy web/func artifacts"
17+
required: false
18+
type: boolean
19+
default: false
20+
createRelease:
21+
description: "Create GitHub release"
22+
required: false
23+
type: boolean
24+
default: false
25+
nugetApiKey:
26+
description: "NuGet API key (required if Publish NuGet is checked)"
27+
required: false
28+
type: string
829

930
env:
1031
BuildVersion: '10.0.0'
1132

1233
jobs:
13-
build:
34+
build:
1435
runs-on: windows-2022
1536
env:
1637
BuildPlatform: Any CPU
@@ -51,6 +72,10 @@ jobs:
5172
env:
5273
Tests1: Tests/bin/${{ env.BuildTarget }}/ICSharpCode.CodeConverter.Tests.dll
5374

75+
- name: Run vitest
76+
working-directory: Web
77+
run: npm test -- --run
78+
5479
- name: Upload NuGet package
5580
uses: actions/upload-artifact@v4
5681
with:
@@ -70,31 +95,81 @@ jobs:
7095
uses: actions/upload-artifact@v4
7196
with:
7297
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
73-
path: Web/bin/${{ env.BuildTarget }}/publish/
98+
path: web/dist/
7499
- name: Upload Function
75100
uses: actions/upload-artifact@v4
76101
with:
77102
name: ICSharpCode.CodeConverter.Func.${{ env.BuildVersion }}.zip
78103
path: Func/bin/${{ env.BuildTarget }}/publish/
79104

80-
deploy:
81-
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
82-
concurrency: ci-${{ github.ref }}
83-
needs: [build] # The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows.
84-
runs-on: ubuntu-latest
85-
steps:
86-
- name: Checkout 🛎️
87-
uses: actions/checkout@v4
105+
deploy:
106+
if: ${{ github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') }}
107+
concurrency: ci-${{ github.ref }}
108+
needs: [build] # The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows.
109+
runs-on: ubuntu-latest
110+
permissions:
111+
contents: write
112+
steps:
113+
- name: Checkout 🛎️
114+
uses: actions/checkout@v4
88115

89-
- name: Download Artifacts 🔻 # The built project is downloaded into the 'site' folder.
90-
uses: actions/download-artifact@v4
91-
with:
92-
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
93-
path: site
116+
- name: Download web artifact 🔻 # The built project is downloaded into the 'site' folder.
117+
if: ${{ inputs.deployWebFunc }}
118+
uses: actions/download-artifact@v4
119+
with:
120+
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
121+
path: site
122+
123+
- name: Download release artifacts
124+
if: ${{ inputs.createRelease || inputs.publishNuget }}
125+
uses: actions/download-artifact@v4
126+
with:
127+
pattern: ICSharpCode.CodeConverter.*
128+
path: release-artifacts
129+
merge-multiple: true
130+
131+
- name: Extract latest changelog section
132+
id: changelog
133+
shell: pwsh
134+
if: ${{ inputs.createRelease }}
135+
run: |
136+
./Get-LatestChangelog.ps1 -Path CHANGELOG.md | Tee-Object -FilePath release-notes.md
137+
"notes<<EOF" >> $env:GITHUB_OUTPUT
138+
Get-Content release-notes.md >> $env:GITHUB_OUTPUT
139+
"EOF" >> $env:GITHUB_OUTPUT
94140
95-
- name: Deploy 🚀
96-
uses: JamesIves/github-pages-deploy-action@v4
97-
with:
98-
branch: 'autoupdated/gh-pages'
99-
folder: 'site/wwwroot'
141+
- name: Deploy 🚀
142+
if: ${{ inputs.deployWebFunc }}
143+
uses: JamesIves/github-pages-deploy-action@v4
144+
with:
145+
branch: 'autoupdated/gh-pages'
146+
folder: 'site/wwwroot'
147+
148+
- name: Publish NuGet packages
149+
if: ${{ inputs.publishNuget }}
150+
shell: pwsh
151+
env:
152+
NUGET_API_KEY: ${{ inputs.nugetApiKey }}
153+
run: |
154+
if (-not $env:NUGET_API_KEY) { throw "nugetApiKey input is required when Publish NuGet is checked." }
155+
Write-Output "::add-mask::$env:NUGET_API_KEY"
156+
$source = "https://api.nuget.org/v3/index.json"
157+
$packages = @(
158+
"release-artifacts/ICSharpCode.CodeConverter.*.nupkg",
159+
"release-artifacts/ICSharpCode.CodeConverter.CodeConv.*.nupkg"
160+
)
161+
foreach ($pattern in $packages) {
162+
Get-ChildItem -Path $pattern -File | ForEach-Object {
163+
dotnet nuget push $_.FullName -k $env:NUGET_API_KEY -s $source --skip-duplicate
164+
}
165+
}
166+
167+
- name: Create GitHub release
168+
if: ${{ inputs.createRelease }}
169+
uses: softprops/action-gh-release@v2
170+
with:
171+
tag_name: v${{ env.BuildVersion }}.${{ github.run_number }}
172+
name: v${{ env.BuildVersion }}.${{ github.run_number }}
173+
body: ${{ steps.changelog.outputs.notes }}
174+
files: release-artifacts/**
100175

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,4 @@ __pycache__/
287287
*.odx.cs
288288
*.xsd.cs
289289
/.nuget
290+
/web/.vite/

CodeConverter.slnLaunch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[
22
{
3-
"Name": "Func \u002B Web",
3+
"Name": "Func + Web",
44
"Projects": [
55
{
6-
"Name": "Web\\Web.csproj",
6+
"Path": "Func\\Func.csproj",
77
"Action": "Start"
88
},
99
{
10-
"Name": "Func\\Func.csproj",
11-
"Action": "Start"
10+
"Path": "Web\\web.esproj",
11+
"Action": "StartWithoutDebugging"
1212
}
1313
]
1414
}

CodeConverter.slnx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
<Project Path="Func/Func.csproj" />
1313
<Project Path="Tests/Tests.csproj" />
1414
<Project Path="Vsix/Vsix.csproj" Id="99498ef8-c9e0-433b-8d7b-ea8e9e66f0c7" />
15-
<Project Path="Web/Web.csproj" />
15+
<Project Path="Web/web.esproj">
16+
<Build />
17+
<Deploy />
18+
</Project>
1619
</Solution>

DotNetBuildable.slnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"CodeConv\\CodeConv.csproj",
77
"Func\\Func.csproj",
88
"Tests\\Tests.csproj",
9-
"Web\\Web.csproj"
9+
"Web\\web.esproj"
1010
]
1111
}
1212
}

DotNetPublishable.slnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"path": "CodeConverter.slnx",
44
"projects": [
55
"Func\\Func.csproj",
6-
"Web\\Web.csproj"
6+
"Web\\web.esproj"
77
]
88
}
99
}

Func/Program.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
{
99
services.AddApplicationInsightsTelemetryWorkerService();
1010
services.ConfigureFunctionsApplicationInsights();
11+
12+
services.AddCors(options =>
13+
{
14+
options.AddPolicy("AllowWeb", builder =>
15+
{
16+
builder.WithOrigins("http://localhost:5173")
17+
.AllowAnyMethod()
18+
.AllowAnyHeader();
19+
});
20+
});
1121
})
1222
.Build();
1323

Func/host.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,16 @@
88
},
99
"enableLiveMetricsFilters": true
1010
}
11+
},
12+
"extensions": {
13+
"http": {
14+
"routePrefix": "api"
15+
}
16+
},
17+
"cors": {
18+
"allowedOrigins": [
19+
"http://localhost:5173"
20+
],
21+
"supportCredentials": false
1122
}
1223
}

Func/local.settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"Values": {
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
55
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
6+
},
7+
"Host": {
8+
"CORS": "*"
69
}
710
}

Get-LatestChangelog.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Param(
2+
[string]$Path = 'CHANGELOG.md'
3+
)
4+
5+
if (-not [System.IO.Path]::IsPathRooted($Path)) {
6+
$Path = Join-Path $PSScriptRoot $Path
7+
}
8+
9+
if (-not (Test-Path -Path $Path)) {
10+
throw "Changelog not found at '$Path'."
11+
}
12+
13+
$lines = Get-Content -Path $Path
14+
$inSection = $false
15+
$collected = New-Object System.Collections.Generic.List[string]
16+
17+
foreach ($line in $lines) {
18+
if ($line -match '^## \[') {
19+
if (-not $inSection) {
20+
if ($line -match '^## \[Unreleased\]') {
21+
continue
22+
}
23+
$inSection = $true
24+
}
25+
elseif ($inSection) {
26+
break
27+
}
28+
}
29+
30+
if ($inSection) {
31+
$collected.Add($line) | Out-Null
32+
}
33+
}
34+
35+
if (-not $inSection -or $collected.Count -eq 0) {
36+
throw "No released changelog section found in '$Path'."
37+
}
38+
39+
$collected | Write-Output

0 commit comments

Comments
 (0)