fix: bootstrap local Readest dependencies

This commit is contained in:
an
2026-07-10 12:44:43 +08:00
parent 3938c9c8bd
commit 0d0732e579
3 changed files with 50 additions and 3 deletions
+47 -1
View File
@@ -71,6 +71,18 @@ function Start-ReadestWeb {
Invoke-Checked "pnpm" @("--filter", "@readest/readest-app", "dev-web")
}
function Test-SubmoduleCheckout {
param([string]$RelativePath)
$fullPath = Join-Path $RepoRoot $RelativePath
if (-not (Test-Path -LiteralPath (Join-Path $fullPath ".git"))) {
return $false
}
& git -C $fullPath rev-parse --is-inside-work-tree 2>$null | Out-Null
return $LASTEXITCODE -eq 0
}
function Assert-CleanWorktree {
$status = (& git -C $RepoRoot status --porcelain)
if ($status) {
@@ -130,7 +142,24 @@ try {
$afterHead = (& git -C $RepoRoot rev-parse HEAD).Trim()
Write-Step "Updating submodules"
Invoke-Checked "git" @("-C", $RepoRoot, "submodule", "update", "--init", "--recursive")
$requiredSubmodules = @(
"packages/foliate-js",
"packages/simplecc-wasm",
"packages/js-mdict",
"apps/readest-app/src-tauri/plugins/tauri-plugin-turso"
)
$missingSubmodules = @($requiredSubmodules | Where-Object { -not (Test-SubmoduleCheckout $_) })
if ($missingSubmodules.Count -gt 0) {
$submoduleArgs = @(
"-C", $RepoRoot,
"-c", "http.version=HTTP/1.1",
"-c", "submodule.fetchJobs=1",
"submodule", "update", "--init", "--depth", "1", "--"
) + $missingSubmodules
Invoke-Checked "git" $submoduleArgs
} else {
Write-Host "Required submodules are already initialized."
}
$changedFiles = @()
if ($beforeHead -ne $afterHead) {
@@ -148,6 +177,23 @@ try {
Invoke-Checked "pnpm" @("install", "--frozen-lockfile")
}
Write-Step "Building local submodule dependencies"
Invoke-Checked "pnpm" @(
"--dir",
(Join-Path $RepoRoot "apps\readest-app\src-tauri\plugins\tauri-plugin-turso"),
"install",
"--ignore-workspace",
"--frozen-lockfile"
)
Invoke-Checked "pnpm" @(
"--dir",
(Join-Path $RepoRoot "apps\readest-app\src-tauri\plugins\tauri-plugin-turso"),
"build"
)
Write-Step "Preparing browser runtime assets"
Invoke-Checked "pnpm" @("--filter", "@readest/readest-app", "setup-vendors")
if ($CheckOnly) {
Write-Step "Launcher check complete"
exit 0