fix path
This commit is contained in:
1 file changed
+223
-144
+223
-144
@@ -223,85 +223,120 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
$ErrorActionPreference = "Stop"
|
$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)) {
|
if (-not (Test-Path $LiveKitPath)) {
|
||||||
throw "pnpm node_modules directory not found"
|
$Entry = (
|
||||||
}
|
node -e "process.stdout.write(require.resolve('livekit-client'))"
|
||||||
|
).Trim()
|
||||||
|
|
||||||
$LiveKitPackages = Get-ChildItem `
|
if (-not $Entry) {
|
||||||
-Path $PnpmRoot `
|
throw "Unable to resolve livekit-client"
|
||||||
-Directory `
|
|
||||||
-Filter "livekit-client@*" |
|
|
||||||
ForEach-Object {
|
|
||||||
Join-Path $_.FullName "node_modules\livekit-client"
|
|
||||||
} |
|
|
||||||
Where-Object {
|
|
||||||
Test-Path $_
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $LiveKitPackages) {
|
$Dir = Split-Path $Entry -Parent
|
||||||
throw "livekit-client package not found"
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$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)(['""])"
|
$Pattern = "(iceTransportPolicy\s*=\s*['""])(relay)(['""])"
|
||||||
$TotalReplacements = 0
|
$TotalReplacements = 0
|
||||||
|
|
||||||
foreach ($PackagePath in $LiveKitPackages) {
|
$Files = Get-ChildItem `
|
||||||
Write-Host "Patching LiveKit package: $PackagePath"
|
-Path $LiveKitPath `
|
||||||
|
-Recurse `
|
||||||
$PackageJson = Join-Path $PackagePath "package.json"
|
-File |
|
||||||
|
Where-Object {
|
||||||
if (Test-Path $PackageJson) {
|
$_.Extension -in @(
|
||||||
$PackageInfo = Get-Content $PackageJson -Raw |
|
".js",
|
||||||
ConvertFrom-Json
|
".mjs",
|
||||||
|
".cjs"
|
||||||
Write-Host "livekit-client version: $($PackageInfo.version)"
|
|
||||||
}
|
|
||||||
|
|
||||||
$Files = Get-ChildItem `
|
|
||||||
-Path $PackagePath `
|
|
||||||
-Recurse `
|
|
||||||
-File |
|
|
||||||
Where-Object {
|
|
||||||
$_.Extension -in @(
|
|
||||||
".ts",
|
|
||||||
".js",
|
|
||||||
".mjs",
|
|
||||||
".cjs"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($File in $Files) {
|
|
||||||
$Content = Get-Content $File.FullName -Raw
|
|
||||||
$Count = [regex]::Matches(
|
|
||||||
$Content,
|
|
||||||
$Pattern
|
|
||||||
).Count
|
|
||||||
|
|
||||||
if ($Count -eq 0) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
$PatchedContent = [regex]::Replace(
|
|
||||||
$Content,
|
|
||||||
$Pattern,
|
|
||||||
'$1all$3'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Set-Content `
|
|
||||||
-Path $File.FullName `
|
|
||||||
-Value $PatchedContent `
|
|
||||||
-NoNewline `
|
|
||||||
-Encoding utf8
|
|
||||||
|
|
||||||
$TotalReplacements += $Count
|
|
||||||
|
|
||||||
Write-Host `
|
|
||||||
"Patched $Count occurrence(s): $($File.FullName)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($File in $Files) {
|
||||||
|
$Content = Get-Content `
|
||||||
|
$File.FullName `
|
||||||
|
-Raw
|
||||||
|
|
||||||
|
$Count = [regex]::Matches(
|
||||||
|
$Content,
|
||||||
|
$Pattern
|
||||||
|
).Count
|
||||||
|
|
||||||
|
if ($Count -eq 0) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
$PatchedContent = [regex]::Replace(
|
||||||
|
$Content,
|
||||||
|
$Pattern,
|
||||||
|
'$1all$3'
|
||||||
|
)
|
||||||
|
|
||||||
|
Set-Content `
|
||||||
|
-Path $File.FullName `
|
||||||
|
-Value $PatchedContent `
|
||||||
|
-NoNewline `
|
||||||
|
-Encoding utf8
|
||||||
|
|
||||||
|
$TotalReplacements += $Count
|
||||||
|
|
||||||
|
Write-Host `
|
||||||
|
"Patched $Count occurrence(s): $($File.FullName)"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($TotalReplacements -lt 1) {
|
if ($TotalReplacements -lt 1) {
|
||||||
@@ -799,33 +834,102 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -euxo pipefail
|
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'
|
python3 <<'PY'
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
pnpm_root = Path("node_modules/.pnpm")
|
package = Path(
|
||||||
|
os.environ["LIVEKIT_DIR"]
|
||||||
if not pnpm_root.is_dir():
|
|
||||||
raise SystemExit(
|
|
||||||
"pnpm node_modules directory not found"
|
|
||||||
)
|
|
||||||
|
|
||||||
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:
|
print(
|
||||||
raise SystemExit(
|
f"LiveKit package: {package}"
|
||||||
"livekit-client package not found"
|
)
|
||||||
|
|
||||||
|
package_json = (
|
||||||
|
package / "package.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
if package_json.is_file():
|
||||||
|
package_info = json.loads(
|
||||||
|
package_json.read_text(
|
||||||
|
encoding="utf-8"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
print(
|
||||||
|
"livekit-client version:",
|
||||||
|
package_info.get(
|
||||||
|
"version",
|
||||||
|
"unknown",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
pattern = re.compile(
|
pattern = re.compile(
|
||||||
@@ -836,67 +940,42 @@ jobs:
|
|||||||
|
|
||||||
total_replacements = 0
|
total_replacements = 0
|
||||||
|
|
||||||
for package in packages:
|
for path in package.rglob("*"):
|
||||||
|
if (
|
||||||
|
not path.is_file()
|
||||||
|
or path.suffix
|
||||||
|
not in {
|
||||||
|
".js",
|
||||||
|
".mjs",
|
||||||
|
".cjs",
|
||||||
|
}
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
|
data = path.read_text(
|
||||||
|
encoding="utf-8"
|
||||||
|
)
|
||||||
|
|
||||||
|
patched, count = pattern.subn(
|
||||||
|
r"\1all\2",
|
||||||
|
data,
|
||||||
|
)
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
path.write_text(
|
||||||
|
patched,
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
|
||||||
|
total_replacements += count
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"Patching LiveKit package: {package}"
|
f"Patched {count} occurrence(s): "
|
||||||
|
f"{path}"
|
||||||
)
|
)
|
||||||
|
|
||||||
package_json = (
|
|
||||||
package / "package.json"
|
|
||||||
)
|
|
||||||
|
|
||||||
if package_json.is_file():
|
|
||||||
package_info = json.loads(
|
|
||||||
package_json.read_text(
|
|
||||||
encoding="utf-8"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
print(
|
|
||||||
"livekit-client version:",
|
|
||||||
package_info.get(
|
|
||||||
"version",
|
|
||||||
"unknown",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
for path in package.rglob("*"):
|
|
||||||
if (
|
|
||||||
not path.is_file()
|
|
||||||
or path.suffix
|
|
||||||
not in {
|
|
||||||
".ts",
|
|
||||||
".js",
|
|
||||||
".mjs",
|
|
||||||
".cjs",
|
|
||||||
}
|
|
||||||
):
|
|
||||||
continue
|
|
||||||
|
|
||||||
data = path.read_text(
|
|
||||||
encoding="utf-8"
|
|
||||||
)
|
|
||||||
|
|
||||||
patched, count = pattern.subn(
|
|
||||||
r"\1all\2",
|
|
||||||
data,
|
|
||||||
)
|
|
||||||
|
|
||||||
if count == 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
path.write_text(
|
|
||||||
patched,
|
|
||||||
encoding="utf-8",
|
|
||||||
)
|
|
||||||
|
|
||||||
total_replacements += count
|
|
||||||
|
|
||||||
print(
|
|
||||||
f"Patched {count} occurrence(s): "
|
|
||||||
f"{path}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if total_replacements < 1:
|
if total_replacements < 1:
|
||||||
raise SystemExit(
|
raise SystemExit(
|
||||||
"LiveKit relay ICE policy "
|
"LiveKit relay ICE policy "
|
||||||
|
|||||||
Reference in new issue
Block a user