regen.mde 0.2.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -16
- package/README.md +409 -295
- package/bin/build-corpus-editor.js +83 -81
- package/bin/build-corpus.js +41 -41
- package/bin/postinstall.js +259 -187
- package/bin/regen-mdeditor-install.js +27 -27
- package/bin/regen-mdeditor-uninstall.js +19 -19
- package/bin/validate-katex.js +93 -93
- package/desktop/BuildCorpusEditor/BuildCorpusBridge.cs +493 -270
- package/desktop/BuildCorpusEditor/BuildCorpusEditor.csproj +22 -22
- package/desktop/BuildCorpusEditor/EditorForm.cs +853 -540
- package/desktop/BuildCorpusEditor/Program.cs +85 -81
- package/desktop/BuildCorpusEditor/app.manifest +16 -16
- package/dist/release/regen-mde-0.8.0-win-x64.zip +0 -0
- package/dist/windows-editor/BuildCorpusEditor.dll +0 -0
- package/dist/windows-editor/BuildCorpusEditor.exe +0 -0
- package/dist/windows-editor/BuildCorpusEditor.pdb +0 -0
- package/dist/windows-editor/BuildCorpusEditor.runtimeconfig.json +1 -1
- package/dist/windows-editor/wwwroot/assets/index-C_VxJk4k.js +375 -0
- package/dist/windows-editor/wwwroot/assets/index-Wt9zSjIw.css +1 -0
- package/dist/windows-editor/wwwroot/index.html +22 -22
- package/editor-web/index.html +21 -21
- package/editor-web/src/main.jsx +1044 -399
- package/editor-web/src/styles.css +846 -602
- package/editor-web/vite.config.js +13 -13
- package/examples/build-corpus.config.example.json +21 -21
- package/installer/install-regen-mde.ps1 +214 -175
- package/installer/regen-mde.nsi +81 -81
- package/package.json +10 -6
- package/pyproject.toml +4 -3
- package/requirements.txt +5 -4
- package/scripts/build-windows-editor.ps1 +47 -47
- package/scripts/package-windows-editor.ps1 +90 -90
- package/scripts/release-dual.mjs +105 -0
- package/scripts/run-corpus.ps1 +28 -28
- package/scripts/run-editor-implementation-plane.ps1 +226 -203
- package/scripts/run-required-tests.ps1 +98 -98
- package/scripts/run-smoke.ps1 +28 -28
- package/src/build_corpus/__init__.py +1 -1
- package/src/build_corpus/docx_exporter.py +1055 -798
- package/src/build_corpus/equations.py +1345 -0
- package/src/build_corpus/exporter.py +1488 -1195
- package/src/build_corpus/frontmatter.py +302 -0
- package/src/build_corpus/ppt_exporter.py +543 -532
- package/src/build_corpus/templates/__init__.py +1 -1
- package/src/build_corpus/validate_assets.py +46 -46
- package/tools/audit_corpus.py +203 -203
- package/tools/collect_microsoft_word_templates.py +228 -228
- package/tools/collect_online_docx_corpus.py +272 -272
- package/tools/collect_online_pptx_corpus.py +252 -252
- package/tools/compare_pptx_inputs_outputs.py +87 -87
- package/tools/roundtrip_docx_corpus.py +171 -171
- package/dist/release/regen.mde-0.2.2-win-x64-setup.exe +0 -0
- package/dist/release/regen.mde-0.2.2-win-x64.zip +0 -0
- package/dist/windows-editor/wwwroot/assets/index-DjJ6xmhy.js +0 -326
- package/dist/windows-editor/wwwroot/assets/index-_dwMNNsm.css +0 -1
|
@@ -1,203 +1,226 @@
|
|
|
1
|
-
[CmdletBinding()]
|
|
2
|
-
param(
|
|
3
|
-
[ValidateSet("Plan", "Verify", "Install", "Smoke")]
|
|
4
|
-
[string]$Mode = "Verify",
|
|
5
|
-
[string]$Root = ""
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
$ErrorActionPreference = "Stop"
|
|
9
|
-
|
|
10
|
-
if ([string]::IsNullOrWhiteSpace($Root)) {
|
|
11
|
-
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
12
|
-
$Root = (Resolve-Path (Join-Path $scriptDir "..")).Path
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function Write-Step {
|
|
16
|
-
param([string]$Message)
|
|
17
|
-
Write-Host ""
|
|
18
|
-
Write-Host "==> $Message" -ForegroundColor Cyan
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function Invoke-Checked {
|
|
22
|
-
param(
|
|
23
|
-
[string]$FilePath,
|
|
24
|
-
[string[]]$Arguments,
|
|
25
|
-
[string]$WorkingDirectory = $Root
|
|
26
|
-
)
|
|
27
|
-
Write-Host "+ $FilePath $($Arguments -join ' ')" -ForegroundColor DarkGray
|
|
28
|
-
Push-Location $WorkingDirectory
|
|
29
|
-
try {
|
|
30
|
-
& $FilePath @Arguments
|
|
31
|
-
$exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
|
|
32
|
-
} finally {
|
|
33
|
-
Pop-Location
|
|
34
|
-
}
|
|
35
|
-
if ($exitCode -ne 0) {
|
|
36
|
-
throw "Command failed with exit code ${exitCode}: $FilePath $($Arguments -join ' ')"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function Invoke-HiddenNode {
|
|
41
|
-
param([string[]]$Arguments)
|
|
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
|
-
function Test-
|
|
79
|
-
$
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
$
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
Write-Step "
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Invoke-Checked "
|
|
132
|
-
Invoke-Checked "
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
Invoke-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
1
|
+
[CmdletBinding()]
|
|
2
|
+
param(
|
|
3
|
+
[ValidateSet("Plan", "Verify", "Install", "Smoke")]
|
|
4
|
+
[string]$Mode = "Verify",
|
|
5
|
+
[string]$Root = ""
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
$ErrorActionPreference = "Stop"
|
|
9
|
+
|
|
10
|
+
if ([string]::IsNullOrWhiteSpace($Root)) {
|
|
11
|
+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
12
|
+
$Root = (Resolve-Path (Join-Path $scriptDir "..")).Path
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function Write-Step {
|
|
16
|
+
param([string]$Message)
|
|
17
|
+
Write-Host ""
|
|
18
|
+
Write-Host "==> $Message" -ForegroundColor Cyan
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function Invoke-Checked {
|
|
22
|
+
param(
|
|
23
|
+
[string]$FilePath,
|
|
24
|
+
[string[]]$Arguments,
|
|
25
|
+
[string]$WorkingDirectory = $Root
|
|
26
|
+
)
|
|
27
|
+
Write-Host "+ $FilePath $($Arguments -join ' ')" -ForegroundColor DarkGray
|
|
28
|
+
Push-Location $WorkingDirectory
|
|
29
|
+
try {
|
|
30
|
+
& $FilePath @Arguments
|
|
31
|
+
$exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
|
|
32
|
+
} finally {
|
|
33
|
+
Pop-Location
|
|
34
|
+
}
|
|
35
|
+
if ($exitCode -ne 0) {
|
|
36
|
+
throw "Command failed with exit code ${exitCode}: $FilePath $($Arguments -join ' ')"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function Invoke-HiddenNode {
|
|
41
|
+
param([string[]]$Arguments)
|
|
42
|
+
$effectiveArguments = @($Arguments)
|
|
43
|
+
if ($effectiveArguments.Count -gt 0 -and $effectiveArguments[0] -eq "bin\build-corpus-editor.js" -and -not ($effectiveArguments -contains "--background")) {
|
|
44
|
+
$effectiveArguments += "--background"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Write-Host "+ node $($effectiveArguments -join ' ')" -ForegroundColor DarkGray
|
|
48
|
+
|
|
49
|
+
$outFile = Join-Path ([System.IO.Path]::GetTempPath()) "regen-mde-hidden-node-out-$([System.Guid]::NewGuid().ToString('N')).log"
|
|
50
|
+
$errFile = Join-Path ([System.IO.Path]::GetTempPath()) "regen-mde-hidden-node-err-$([System.Guid]::NewGuid().ToString('N')).log"
|
|
51
|
+
try {
|
|
52
|
+
$result = Start-Process -FilePath "node" `
|
|
53
|
+
-ArgumentList $effectiveArguments `
|
|
54
|
+
-WorkingDirectory $Root `
|
|
55
|
+
-WindowStyle Hidden `
|
|
56
|
+
-Wait `
|
|
57
|
+
-PassThru `
|
|
58
|
+
-RedirectStandardOutput $outFile `
|
|
59
|
+
-RedirectStandardError $errFile
|
|
60
|
+
|
|
61
|
+
if (Test-Path -LiteralPath $outFile) {
|
|
62
|
+
$stdout = Get-Content -LiteralPath $outFile -Raw
|
|
63
|
+
if (-not [string]::IsNullOrWhiteSpace($stdout)) { Write-Host $stdout.TrimEnd() }
|
|
64
|
+
}
|
|
65
|
+
if (Test-Path -LiteralPath $errFile) {
|
|
66
|
+
$stderr = Get-Content -LiteralPath $errFile -Raw
|
|
67
|
+
if (-not [string]::IsNullOrWhiteSpace($stderr)) { Write-Host $stderr.TrimEnd() -ForegroundColor DarkGray }
|
|
68
|
+
}
|
|
69
|
+
$exitCode = $result.ExitCode
|
|
70
|
+
} finally {
|
|
71
|
+
Remove-Item -LiteralPath $outFile, $errFile -Force -ErrorAction SilentlyContinue
|
|
72
|
+
}
|
|
73
|
+
if ($exitCode -ne 0) {
|
|
74
|
+
throw "Command failed with exit code ${exitCode}: node $($effectiveArguments -join ' ')"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function Test-CommandExists {
|
|
79
|
+
param([string]$Name)
|
|
80
|
+
if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) {
|
|
81
|
+
throw "Required command not found on PATH: $Name"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function Read-WorkItems {
|
|
86
|
+
$path = Join-Path $Root "work-items\build-corpus-editor-work-items.json"
|
|
87
|
+
if (-not (Test-Path -LiteralPath $path)) {
|
|
88
|
+
throw "Missing work-item file: $path"
|
|
89
|
+
}
|
|
90
|
+
return Get-Content -LiteralPath $path -Raw | ConvertFrom-Json
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function Show-Plan {
|
|
94
|
+
$items = Read-WorkItems
|
|
95
|
+
Write-Host "# $($items.epic.id): $($items.epic.title)"
|
|
96
|
+
Write-Host $items.epic.goal
|
|
97
|
+
Write-Host ""
|
|
98
|
+
$items.work_items | Format-Table id,title,status -AutoSize
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function Test-ImplementationShape {
|
|
102
|
+
$required = @(
|
|
103
|
+
"work-items\build-corpus-editor-work-items.json",
|
|
104
|
+
"work-items\build-corpus-editor-implementation-plane.md",
|
|
105
|
+
"scripts\run-editor-implementation-plane.ps1",
|
|
106
|
+
"build-corpus-editor-plane.cmd"
|
|
107
|
+
)
|
|
108
|
+
foreach ($rel in $required) {
|
|
109
|
+
$path = Join-Path $Root $rel
|
|
110
|
+
if (-not (Test-Path -LiteralPath $path)) {
|
|
111
|
+
throw "Missing required implementation-plane artifact: $rel"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
$regenEditor = "C:\Dev\regen-root\packages\editor\src\components\MarkdownEditor.tsx"
|
|
116
|
+
if (-not (Test-Path -LiteralPath $regenEditor)) {
|
|
117
|
+
throw "Existing source editor not found: $regenEditor"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
$package = Get-Content -LiteralPath (Join-Path $Root "package.json") -Raw | ConvertFrom-Json
|
|
121
|
+
if (-not $package.bin."build-corpus") {
|
|
122
|
+
throw "package.json no longer exposes build-corpus CLI"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function Invoke-BaseVerification {
|
|
127
|
+
Write-Step "Checking toolchain"
|
|
128
|
+
Test-CommandExists "node"
|
|
129
|
+
Test-CommandExists "npm"
|
|
130
|
+
Test-CommandExists "py"
|
|
131
|
+
Invoke-Checked "node" @("--version")
|
|
132
|
+
Invoke-Checked "npm" @("--version")
|
|
133
|
+
Invoke-Checked "py" @("-3", "--version")
|
|
134
|
+
|
|
135
|
+
Write-Step "Checking implementation-plane artifacts"
|
|
136
|
+
Test-ImplementationShape
|
|
137
|
+
|
|
138
|
+
Write-Step "Running existing CLI smoke"
|
|
139
|
+
Invoke-Checked "node" @("bin\build-corpus.js", "--help")
|
|
140
|
+
Invoke-Checked "node" @("bin\validate-katex.js", "README.md")
|
|
141
|
+
|
|
142
|
+
Write-Step "Running Python unit tests"
|
|
143
|
+
$env:PYTHONPATH = Join-Path $Root "src"
|
|
144
|
+
Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_exporter.py")
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function Invoke-InstallVerification {
|
|
148
|
+
Invoke-BaseVerification
|
|
149
|
+
|
|
150
|
+
Write-Step "Installing current package globally"
|
|
151
|
+
Invoke-Checked "npm" @("install", "-g", ".")
|
|
152
|
+
|
|
153
|
+
Write-Step "Checking installed command resolution"
|
|
154
|
+
Invoke-Checked "where.exe" @("build-corpus")
|
|
155
|
+
Invoke-Checked "build-corpus" @("--help")
|
|
156
|
+
|
|
157
|
+
Write-Step "Checking existing conversion Explorer verbs"
|
|
158
|
+
Invoke-Checked "reg.exe" @("query", "HKCU\Software\Classes\SystemFileAssociations\.docx\shell\BuildCorpusToMarkdown")
|
|
159
|
+
Invoke-Checked "reg.exe" @("query", "HKCU\Software\Classes\SystemFileAssociations\.md\shell\BuildCorpusToWord")
|
|
160
|
+
|
|
161
|
+
$editorVerb = "HKCU\Software\Classes\SystemFileAssociations\.md\shell\BuildCorpusOpenEditor"
|
|
162
|
+
$result = Start-Process -FilePath "reg.exe" -ArgumentList @("query", $editorVerb) -NoNewWindow -Wait -PassThru
|
|
163
|
+
if ($result.ExitCode -ne 0) {
|
|
164
|
+
throw "Editor open verb is not installed yet. Complete BC-EDITOR-04, then rerun Install mode."
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function Invoke-SmokeVerification {
|
|
169
|
+
Invoke-BaseVerification
|
|
170
|
+
|
|
171
|
+
$smokeRoot = Join-Path $Root ".tmp\editor-plane-smoke"
|
|
172
|
+
if (Test-Path -LiteralPath $smokeRoot) {
|
|
173
|
+
Remove-Item -LiteralPath $smokeRoot -Recurse -Force
|
|
174
|
+
}
|
|
175
|
+
New-Item -ItemType Directory -Path $smokeRoot | Out-Null
|
|
176
|
+
|
|
177
|
+
Write-Step "Creating Markdown fixture"
|
|
178
|
+
$md = Join-Path $smokeRoot "sample.md"
|
|
179
|
+
Set-Content -LiteralPath $md -Encoding UTF8 -Value @"
|
|
180
|
+
# Build Corpus Editor Smoke
|
|
181
|
+
|
|
182
|
+
Paragraph with **bold**, *italic*, a [link](https://example.com), and a table.
|
|
183
|
+
|
|
184
|
+
| Name | Value |
|
|
185
|
+
| --- | --- |
|
|
186
|
+
| Alpha | One |
|
|
187
|
+
"@
|
|
188
|
+
|
|
189
|
+
Write-Step "Exporting Markdown fixture to Word"
|
|
190
|
+
Invoke-Checked "node" @("bin\build-corpus.js", $md, "--to", "word", "--out-same-dir")
|
|
191
|
+
$docx = Join-Path $smokeRoot "sample.docx"
|
|
192
|
+
if (-not (Test-Path -LiteralPath $docx)) {
|
|
193
|
+
throw "Expected DOCX output missing: $docx"
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
Write-Step "Converting generated Word fixture back to Markdown"
|
|
197
|
+
$roundTrip = Join-Path $smokeRoot "roundtrip"
|
|
198
|
+
Invoke-Checked "node" @("bin\build-corpus.js", $docx, "--out", $roundTrip)
|
|
199
|
+
$roundTripMarkdown = Get-ChildItem -LiteralPath $roundTrip -Recurse -Filter "*.md" | Select-Object -First 1
|
|
200
|
+
if (-not $roundTripMarkdown) {
|
|
201
|
+
throw "Expected reconverted Markdown output missing under $roundTrip"
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
Write-Step "Checking editor launcher is implemented"
|
|
205
|
+
$editorBin = Join-Path $Root "bin\build-corpus-editor.js"
|
|
206
|
+
if (-not (Test-Path -LiteralPath $editorBin)) {
|
|
207
|
+
throw "Editor launcher is not implemented yet. Complete BC-EDITOR-02, then rerun Smoke mode."
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--no-open", "--self-test")
|
|
211
|
+
Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--no-open", "--self-test")
|
|
212
|
+
Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--document-self-test", "--out", (Join-Path $smokeRoot "md-functional"))
|
|
213
|
+
Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--document-self-test", "--out", (Join-Path $smokeRoot "docx-functional"))
|
|
214
|
+
Invoke-HiddenNode @("bin\build-corpus-editor.js", $md, "--smoke-ui", "--background")
|
|
215
|
+
Invoke-HiddenNode @("bin\build-corpus-editor.js", $docx, "--smoke-ui", "--background")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
switch ($Mode) {
|
|
219
|
+
"Plan" { Show-Plan }
|
|
220
|
+
"Verify" { Invoke-BaseVerification }
|
|
221
|
+
"Install" { Invoke-InstallVerification }
|
|
222
|
+
"Smoke" { Invoke-SmokeVerification }
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
Write-Host ""
|
|
226
|
+
Write-Host "Build Corpus editor plane $Mode completed." -ForegroundColor Green
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
[CmdletBinding()]
|
|
2
|
-
param(
|
|
3
|
-
[ValidateSet("Auto", "Conversion", "Editor", "All")]
|
|
4
|
-
[string]$Suite = "Auto",
|
|
5
|
-
[string]$Root = "",
|
|
6
|
-
[switch]$FromGitDiff
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
$ErrorActionPreference = "Stop"
|
|
10
|
-
|
|
11
|
-
if ([string]::IsNullOrWhiteSpace($Root)) {
|
|
12
|
-
$Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function Write-Step {
|
|
16
|
-
param([string]$Message)
|
|
17
|
-
Write-Host ""
|
|
18
|
-
Write-Host "==> $Message" -ForegroundColor Cyan
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function Invoke-Checked {
|
|
22
|
-
param([string]$FilePath, [string[]]$Arguments)
|
|
23
|
-
Write-Host "+ $FilePath $($Arguments -join ' ')" -ForegroundColor DarkGray
|
|
24
|
-
Push-Location $Root
|
|
25
|
-
try {
|
|
26
|
-
& $FilePath @Arguments
|
|
27
|
-
$exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
|
|
28
|
-
} finally {
|
|
29
|
-
Pop-Location
|
|
30
|
-
}
|
|
31
|
-
if ($exitCode -ne 0) {
|
|
32
|
-
throw "Command failed with exit code ${exitCode}: $FilePath $($Arguments -join ' ')"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function Get-TouchedFiles {
|
|
37
|
-
Push-Location $Root
|
|
38
|
-
try {
|
|
39
|
-
$files = @()
|
|
40
|
-
$files += git diff --name-only
|
|
41
|
-
$files += git diff --name-only --cached
|
|
42
|
-
$files += git ls-files --others --exclude-standard
|
|
43
|
-
return $files | Where-Object { $_ } | Sort-Object -Unique
|
|
44
|
-
} finally {
|
|
45
|
-
Pop-Location
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function Resolve-Suites {
|
|
50
|
-
if ($Suite -eq "All") { return @("Conversion", "Editor") }
|
|
51
|
-
if ($Suite -eq "Conversion") { return @("Conversion") }
|
|
52
|
-
if ($Suite -eq "Editor") { return @("Editor") }
|
|
53
|
-
|
|
54
|
-
$files = Get-TouchedFiles
|
|
55
|
-
$conversion = $false
|
|
56
|
-
$editor = $false
|
|
57
|
-
foreach ($file in $files) {
|
|
58
|
-
if ($file -match '^(src/build_corpus/|tests/|tools/|bin/build-corpus\.js|bin/validate-katex\.js|requirements\.txt|pyproject\.toml)') {
|
|
59
|
-
$conversion = $true
|
|
60
|
-
}
|
|
61
|
-
if ($file -match '^(editor-web/|desktop/|installer/|bin/build-corpus-editor\.js|bin/regen-mdeditor-|scripts/build-windows-editor\.ps1|scripts/package-windows-editor\.ps1|scripts/run-editor-implementation-plane\.ps1|package\.json|package-lock\.json)') {
|
|
62
|
-
$editor = $true
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (-not $conversion -and -not $editor) {
|
|
66
|
-
$conversion = $true
|
|
67
|
-
$editor = $true
|
|
68
|
-
}
|
|
69
|
-
$resolved = @()
|
|
70
|
-
if ($conversion) { $resolved += "Conversion" }
|
|
71
|
-
if ($editor) { $resolved += "Editor" }
|
|
72
|
-
return $resolved
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function Invoke-ConversionSuite {
|
|
76
|
-
Write-Step "Conversion suite"
|
|
77
|
-
$env:PYTHONPATH = Join-Path $Root "src"
|
|
78
|
-
Invoke-Checked "node" @("bin\build-corpus.js", "--help")
|
|
79
|
-
Invoke-Checked "node" @("bin\validate-katex.js", "README.md")
|
|
80
|
-
Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_exporter.py")
|
|
81
|
-
Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_ppt_exporter.py")
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function Invoke-EditorSuite {
|
|
85
|
-
Write-Step "Editor suite"
|
|
86
|
-
Invoke-Checked "npm" @("run", "editor:windows")
|
|
87
|
-
Invoke-Checked "powershell.exe" @("-NoProfile", "-ExecutionPolicy", "Bypass", "-File", "scripts\run-editor-implementation-plane.ps1", "-Mode", "Smoke")
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
$resolved = Resolve-Suites
|
|
91
|
-
Write-Host "Required suites: $($resolved -join ', ')" -ForegroundColor Yellow
|
|
92
|
-
foreach ($item in $resolved) {
|
|
93
|
-
if ($item -eq "Conversion") { Invoke-ConversionSuite }
|
|
94
|
-
if ($item -eq "Editor") { Invoke-EditorSuite }
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
Write-Host ""
|
|
98
|
-
Write-Host "Required test suites passed: $($resolved -join ', ')" -ForegroundColor Green
|
|
1
|
+
[CmdletBinding()]
|
|
2
|
+
param(
|
|
3
|
+
[ValidateSet("Auto", "Conversion", "Editor", "All")]
|
|
4
|
+
[string]$Suite = "Auto",
|
|
5
|
+
[string]$Root = "",
|
|
6
|
+
[switch]$FromGitDiff
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
$ErrorActionPreference = "Stop"
|
|
10
|
+
|
|
11
|
+
if ([string]::IsNullOrWhiteSpace($Root)) {
|
|
12
|
+
$Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function Write-Step {
|
|
16
|
+
param([string]$Message)
|
|
17
|
+
Write-Host ""
|
|
18
|
+
Write-Host "==> $Message" -ForegroundColor Cyan
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function Invoke-Checked {
|
|
22
|
+
param([string]$FilePath, [string[]]$Arguments)
|
|
23
|
+
Write-Host "+ $FilePath $($Arguments -join ' ')" -ForegroundColor DarkGray
|
|
24
|
+
Push-Location $Root
|
|
25
|
+
try {
|
|
26
|
+
& $FilePath @Arguments
|
|
27
|
+
$exitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
|
|
28
|
+
} finally {
|
|
29
|
+
Pop-Location
|
|
30
|
+
}
|
|
31
|
+
if ($exitCode -ne 0) {
|
|
32
|
+
throw "Command failed with exit code ${exitCode}: $FilePath $($Arguments -join ' ')"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function Get-TouchedFiles {
|
|
37
|
+
Push-Location $Root
|
|
38
|
+
try {
|
|
39
|
+
$files = @()
|
|
40
|
+
$files += git diff --name-only
|
|
41
|
+
$files += git diff --name-only --cached
|
|
42
|
+
$files += git ls-files --others --exclude-standard
|
|
43
|
+
return $files | Where-Object { $_ } | Sort-Object -Unique
|
|
44
|
+
} finally {
|
|
45
|
+
Pop-Location
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function Resolve-Suites {
|
|
50
|
+
if ($Suite -eq "All") { return @("Conversion", "Editor") }
|
|
51
|
+
if ($Suite -eq "Conversion") { return @("Conversion") }
|
|
52
|
+
if ($Suite -eq "Editor") { return @("Editor") }
|
|
53
|
+
|
|
54
|
+
$files = Get-TouchedFiles
|
|
55
|
+
$conversion = $false
|
|
56
|
+
$editor = $false
|
|
57
|
+
foreach ($file in $files) {
|
|
58
|
+
if ($file -match '^(src/build_corpus/|tests/|tools/|bin/build-corpus\.js|bin/validate-katex\.js|requirements\.txt|pyproject\.toml)') {
|
|
59
|
+
$conversion = $true
|
|
60
|
+
}
|
|
61
|
+
if ($file -match '^(editor-web/|desktop/|installer/|bin/build-corpus-editor\.js|bin/regen-mdeditor-|scripts/build-windows-editor\.ps1|scripts/package-windows-editor\.ps1|scripts/run-editor-implementation-plane\.ps1|package\.json|package-lock\.json)') {
|
|
62
|
+
$editor = $true
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (-not $conversion -and -not $editor) {
|
|
66
|
+
$conversion = $true
|
|
67
|
+
$editor = $true
|
|
68
|
+
}
|
|
69
|
+
$resolved = @()
|
|
70
|
+
if ($conversion) { $resolved += "Conversion" }
|
|
71
|
+
if ($editor) { $resolved += "Editor" }
|
|
72
|
+
return $resolved
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function Invoke-ConversionSuite {
|
|
76
|
+
Write-Step "Conversion suite"
|
|
77
|
+
$env:PYTHONPATH = Join-Path $Root "src"
|
|
78
|
+
Invoke-Checked "node" @("bin\build-corpus.js", "--help")
|
|
79
|
+
Invoke-Checked "node" @("bin\validate-katex.js", "README.md")
|
|
80
|
+
Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_exporter.py")
|
|
81
|
+
Invoke-Checked "py" @("-3", "-m", "unittest", "discover", "-s", "tests", "-p", "test_ppt_exporter.py")
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function Invoke-EditorSuite {
|
|
85
|
+
Write-Step "Editor suite"
|
|
86
|
+
Invoke-Checked "npm" @("run", "editor:windows")
|
|
87
|
+
Invoke-Checked "powershell.exe" @("-NoProfile", "-ExecutionPolicy", "Bypass", "-File", "scripts\run-editor-implementation-plane.ps1", "-Mode", "Smoke")
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
$resolved = Resolve-Suites
|
|
91
|
+
Write-Host "Required suites: $($resolved -join ', ')" -ForegroundColor Yellow
|
|
92
|
+
foreach ($item in $resolved) {
|
|
93
|
+
if ($item -eq "Conversion") { Invoke-ConversionSuite }
|
|
94
|
+
if ($item -eq "Editor") { Invoke-EditorSuite }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Write-Host ""
|
|
98
|
+
Write-Host "Required test suites passed: $($resolved -join ', ')" -ForegroundColor Green
|