fix path
This commit is contained in:
1 file changed
+142
-63
+142
-63
@@ -223,51 +223,84 @@ jobs:
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Set-Location fluxer-src
|
||||
Set-Location "fluxer-src\fluxer_desktop"
|
||||
|
||||
$PnpmRoot = "node_modules\.pnpm"
|
||||
$LiveKitPath = Join-Path `
|
||||
(Get-Location) `
|
||||
"node_modules\livekit-client"
|
||||
|
||||
if (-not (Test-Path $PnpmRoot)) {
|
||||
throw "pnpm node_modules directory not found"
|
||||
if (-not (Test-Path $LiveKitPath)) {
|
||||
$Entry = (
|
||||
node -e "process.stdout.write(require.resolve('livekit-client'))"
|
||||
).Trim()
|
||||
|
||||
if (-not $Entry) {
|
||||
throw "Unable to resolve livekit-client"
|
||||
}
|
||||
|
||||
$LiveKitPackages = Get-ChildItem `
|
||||
-Path $PnpmRoot `
|
||||
-Directory `
|
||||
-Filter "livekit-client@*" |
|
||||
ForEach-Object {
|
||||
Join-Path $_.FullName "node_modules\livekit-client"
|
||||
} |
|
||||
Where-Object {
|
||||
Test-Path $_
|
||||
$Dir = Split-Path $Entry -Parent
|
||||
|
||||
while ($Dir) {
|
||||
$PackageJson = Join-Path $Dir "package.json"
|
||||
|
||||
if (Test-Path $PackageJson) {
|
||||
$PackageInfo = Get-Content `
|
||||
$PackageJson `
|
||||
-Raw |
|
||||
ConvertFrom-Json
|
||||
|
||||
if ($PackageInfo.name -eq "livekit-client") {
|
||||
$LiveKitPath = $Dir
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $LiveKitPackages) {
|
||||
throw "livekit-client package not found"
|
||||
$Parent = Split-Path $Dir -Parent
|
||||
|
||||
if (
|
||||
-not $Parent -or
|
||||
$Parent -eq $Dir
|
||||
) {
|
||||
break
|
||||
}
|
||||
|
||||
$Dir = $Parent
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path $LiveKitPath)) {
|
||||
throw "livekit-client package directory not found"
|
||||
}
|
||||
|
||||
$LiveKitPath = (
|
||||
Resolve-Path $LiveKitPath
|
||||
).Path
|
||||
|
||||
Write-Host "LiveKit package: $LiveKitPath"
|
||||
|
||||
$PackageJson = Join-Path `
|
||||
$LiveKitPath `
|
||||
"package.json"
|
||||
|
||||
if (Test-Path $PackageJson) {
|
||||
$PackageInfo = Get-Content `
|
||||
$PackageJson `
|
||||
-Raw |
|
||||
ConvertFrom-Json
|
||||
|
||||
Write-Host `
|
||||
"livekit-client version: $($PackageInfo.version)"
|
||||
}
|
||||
|
||||
$Pattern = "(iceTransportPolicy\s*=\s*['""])(relay)(['""])"
|
||||
$TotalReplacements = 0
|
||||
|
||||
foreach ($PackagePath in $LiveKitPackages) {
|
||||
Write-Host "Patching LiveKit package: $PackagePath"
|
||||
|
||||
$PackageJson = Join-Path $PackagePath "package.json"
|
||||
|
||||
if (Test-Path $PackageJson) {
|
||||
$PackageInfo = Get-Content $PackageJson -Raw |
|
||||
ConvertFrom-Json
|
||||
|
||||
Write-Host "livekit-client version: $($PackageInfo.version)"
|
||||
}
|
||||
|
||||
$Files = Get-ChildItem `
|
||||
-Path $PackagePath `
|
||||
-Path $LiveKitPath `
|
||||
-Recurse `
|
||||
-File |
|
||||
Where-Object {
|
||||
$_.Extension -in @(
|
||||
".ts",
|
||||
".js",
|
||||
".mjs",
|
||||
".cjs"
|
||||
@@ -275,7 +308,10 @@ jobs:
|
||||
}
|
||||
|
||||
foreach ($File in $Files) {
|
||||
$Content = Get-Content $File.FullName -Raw
|
||||
$Content = Get-Content `
|
||||
$File.FullName `
|
||||
-Raw
|
||||
|
||||
$Count = [regex]::Matches(
|
||||
$Content,
|
||||
$Pattern
|
||||
@@ -302,7 +338,6 @@ jobs:
|
||||
Write-Host `
|
||||
"Patched $Count occurrence(s): $($File.FullName)"
|
||||
}
|
||||
}
|
||||
|
||||
if ($TotalReplacements -lt 1) {
|
||||
throw "LiveKit relay ICE policy assignment was not found"
|
||||
@@ -799,46 +834,83 @@ jobs:
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
|
||||
cd fluxer-src
|
||||
cd fluxer-src/fluxer_desktop
|
||||
|
||||
LIVEKIT_DIR="node_modules/livekit-client"
|
||||
|
||||
if [ ! -d "${LIVEKIT_DIR}" ]; then
|
||||
LIVEKIT_ENTRY="$(
|
||||
node -e \
|
||||
"process.stdout.write(require.resolve('livekit-client'))"
|
||||
)"
|
||||
|
||||
export LIVEKIT_ENTRY
|
||||
|
||||
LIVEKIT_DIR="$(
|
||||
python3 <<'PY'
|
||||
from pathlib import Path
|
||||
import json
|
||||
import os
|
||||
|
||||
entry = Path(
|
||||
os.environ["LIVEKIT_ENTRY"]
|
||||
).resolve()
|
||||
|
||||
for directory in [
|
||||
entry.parent,
|
||||
*entry.parents,
|
||||
]:
|
||||
package_json = (
|
||||
directory / "package.json"
|
||||
)
|
||||
|
||||
if not package_json.is_file():
|
||||
continue
|
||||
|
||||
try:
|
||||
package = json.loads(
|
||||
package_json.read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if (
|
||||
package.get("name")
|
||||
== "livekit-client"
|
||||
):
|
||||
print(directory)
|
||||
break
|
||||
else:
|
||||
raise SystemExit(
|
||||
"Unable to locate "
|
||||
"livekit-client package directory"
|
||||
)
|
||||
PY
|
||||
)"
|
||||
fi
|
||||
|
||||
LIVEKIT_DIR="$(
|
||||
readlink -f "${LIVEKIT_DIR}"
|
||||
)"
|
||||
|
||||
test -d "${LIVEKIT_DIR}"
|
||||
|
||||
export LIVEKIT_DIR
|
||||
|
||||
python3 <<'PY'
|
||||
from pathlib import Path
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
pnpm_root = Path("node_modules/.pnpm")
|
||||
|
||||
if not pnpm_root.is_dir():
|
||||
raise SystemExit(
|
||||
"pnpm node_modules directory not found"
|
||||
package = Path(
|
||||
os.environ["LIVEKIT_DIR"]
|
||||
)
|
||||
|
||||
packages = sorted(
|
||||
path / "node_modules/livekit-client"
|
||||
for path in pnpm_root.glob(
|
||||
"livekit-client@*"
|
||||
)
|
||||
if (
|
||||
path / "node_modules/livekit-client"
|
||||
).is_dir()
|
||||
)
|
||||
|
||||
if not packages:
|
||||
raise SystemExit(
|
||||
"livekit-client package not found"
|
||||
)
|
||||
|
||||
pattern = re.compile(
|
||||
r"(iceTransportPolicy\s*=\s*['\"])"
|
||||
r"relay"
|
||||
r"(['\"])"
|
||||
)
|
||||
|
||||
total_replacements = 0
|
||||
|
||||
for package in packages:
|
||||
print(
|
||||
f"Patching LiveKit package: {package}"
|
||||
f"LiveKit package: {package}"
|
||||
)
|
||||
|
||||
package_json = (
|
||||
@@ -860,12 +932,19 @@ jobs:
|
||||
),
|
||||
)
|
||||
|
||||
pattern = re.compile(
|
||||
r"(iceTransportPolicy\s*=\s*['\"])"
|
||||
r"relay"
|
||||
r"(['\"])"
|
||||
)
|
||||
|
||||
total_replacements = 0
|
||||
|
||||
for path in package.rglob("*"):
|
||||
if (
|
||||
not path.is_file()
|
||||
or path.suffix
|
||||
not in {
|
||||
".ts",
|
||||
".js",
|
||||
".mjs",
|
||||
".cjs",
|
||||
|
||||
Reference in new issue
Block a user