Compare commits
226
Commits
c0266903ec
...
v4.11.223
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f5dd660c7 | ||
|
|
7c33ae587d | ||
|
|
2444654a58 | ||
|
|
e021368628 | ||
|
|
238b969d38 | ||
|
|
5026f0efc2 | ||
|
|
1cbf407f9e | ||
|
|
ec4976293f | ||
|
|
16f4127ed3 | ||
|
|
ce4d13740c | ||
|
|
95ef4261ed | ||
|
|
9143ef18e1 | ||
|
|
60b3706b22 | ||
|
|
8d2de8ee44 | ||
|
|
ae77701424 | ||
|
|
3546e166b0 | ||
|
|
42be279a31 | ||
|
|
f8b4f8cd5a | ||
|
|
f01be83a71 | ||
|
|
86dc5ec9e3 | ||
|
|
06be5c9aaf | ||
|
|
1fc1e5e830 | ||
|
|
609a822777 | ||
|
|
d017cf1959 | ||
|
|
cfc7e5fca3 | ||
|
|
979f7a6ddb | ||
|
|
d402f4dcfd | ||
|
|
b477977a7b | ||
|
|
96f011defc | ||
|
|
1b414d23de | ||
|
|
527cc8fdf4 | ||
|
|
85766610d9 | ||
|
|
cf9899391c | ||
|
|
e7e2a43037 | ||
|
|
4dc6c8c427 | ||
|
|
121244e97b | ||
|
|
54c4cf4386 | ||
|
|
9cc406b770 | ||
|
|
9595b9922d | ||
|
|
33af5c9abf | ||
|
|
999d5da26c | ||
|
|
0ed6df6e97 | ||
|
|
b78e8187ca | ||
|
|
0bbca0d94d | ||
|
|
8afd17e176 | ||
|
|
7adc4cdec0 | ||
|
|
dd2916c30e | ||
|
|
4c6b71fc3b | ||
|
|
5970c5fb7a | ||
|
|
84296e7f87 | ||
|
|
da763937de | ||
|
|
4bbffdb840 | ||
|
|
230171e16c | ||
|
|
e23c40585f | ||
|
|
b2f6c732e4 | ||
|
|
a2b0a3f930 | ||
|
|
adf6329149 | ||
|
|
3382db4603 | ||
|
|
bbaf526e5f | ||
|
|
667aed487a | ||
|
|
0cbee9a436 | ||
|
|
ba6832371a | ||
|
|
402eb29f06 | ||
|
|
64863057be | ||
|
|
6966e44830 | ||
|
|
78850488c7 | ||
|
|
480771b4ab | ||
|
|
d6d6b99e38 | ||
|
|
abbd1c953b | ||
|
|
72b749e933 | ||
|
|
a2a2fe39e0 | ||
|
|
cb4b447de7 | ||
|
|
c01aba04f8 | ||
|
|
284c88b775 | ||
|
|
12532f7d8b | ||
|
|
eaa90d83df | ||
|
|
5b3b71c278 | ||
|
|
f403515f29 | ||
|
|
4f02e12231 | ||
|
|
09813a4dc0 | ||
|
|
532455309c | ||
|
|
615356ca1f | ||
|
|
cee7bb5a20 | ||
|
|
4efc74eea3 | ||
|
|
f444e7e8a7 | ||
|
|
6488d31e77 | ||
|
|
f69c481a35 | ||
|
|
9458ede739 | ||
|
|
5832e3e2ec | ||
|
|
9bbe8d6814 | ||
|
|
d4ccf479a9 | ||
|
|
cee44b3dbd | ||
|
|
805c32cf75 | ||
|
|
4c1c76096b | ||
|
|
15a2b4add2 | ||
|
|
427e148a15 | ||
|
|
440f0d7ae4 | ||
|
|
9bc270ad49 | ||
|
|
1cbd0c59bb | ||
|
|
e67e15ad37 | ||
|
|
e8745d4fb9 | ||
|
|
a48a96fb84 | ||
|
|
5f78ef721f | ||
|
|
fc9679b4de | ||
|
|
e5a6a16463 | ||
|
|
7821c23878 | ||
|
|
cb4445f812 | ||
|
|
cc45650d8c | ||
|
|
af674be546 | ||
|
|
63ce548072 | ||
|
|
863352fc7c | ||
|
|
ec23124722 | ||
|
|
afc4ba1087 | ||
|
|
f022155aa1 | ||
|
|
f4ec39f229 | ||
|
|
848283da42 | ||
|
|
2cd9409e3d | ||
|
|
b85774e911 | ||
|
|
73d31a2cb4 | ||
|
|
f9bc1c7c2f | ||
|
|
85995d0744 | ||
|
|
9d7ae1d63b | ||
|
|
ce7b2104ad | ||
|
|
60d65a29ff | ||
|
|
ce29b24c28 | ||
|
|
608cbaf682 | ||
|
|
8ca7be8b42 | ||
|
|
3c55fe65a3 | ||
|
|
f99b3c85d4 | ||
|
|
fc4f087c68 | ||
|
|
6d347a6f6b | ||
|
|
316a5514e6 | ||
|
|
8392e3f7f5 | ||
|
|
61b3cbc6d8 | ||
|
|
9befaa14a5 | ||
|
|
ea45c4551b | ||
|
|
146927fc10 | ||
|
|
8edbc1b19a | ||
|
|
9700c645a3 | ||
|
|
2828ae425c | ||
|
|
5e06256973 | ||
|
|
28c7dedf65 | ||
|
|
ca10121796 | ||
|
|
1ad1fc7b70 | ||
|
|
f16b84a9f1 | ||
|
|
e917193b0d | ||
|
|
fc5d498673 | ||
|
|
c01bd9a43e | ||
|
|
3f4b1b3fc4 | ||
|
|
24b59a454a | ||
|
|
fac9a49d56 | ||
|
|
83993efc83 | ||
|
|
44a9230df3 | ||
|
|
658ff1215c | ||
|
|
829e9b06cb | ||
|
|
e64279db74 | ||
|
|
85d95faf11 | ||
|
|
61de658029 | ||
|
|
c8b57ba217 | ||
|
|
8d8809d0c7 | ||
|
|
55a0f4f566 | ||
|
|
f488f32d88 | ||
|
|
9154929de9 | ||
|
|
c2cc0d5ed5 | ||
|
|
aa38348fdd | ||
|
|
02ab544a37 | ||
|
|
3707a6d38a | ||
|
|
fe1f4abf2d | ||
|
|
147389724e | ||
|
|
d4d4c73c2b | ||
|
|
73fbc1c77a | ||
|
|
3dc732521f | ||
|
|
b76aa3fe4a | ||
|
|
c0d1e87b8d | ||
|
|
04d4026e78 | ||
|
|
cfbc59d6a9 | ||
|
|
dfe42fa942 | ||
|
|
6a8397425e | ||
|
|
641ec26142 | ||
|
|
1eaf246806 | ||
|
|
0e97e4d3b6 | ||
|
|
1636a8d0c6 | ||
|
|
ac236750aa | ||
|
|
7e747e6c36 | ||
|
|
1b2cae5b12 | ||
|
|
76921c4e79 | ||
|
|
688efff7c9 | ||
|
|
9bc377b62a | ||
|
|
836ccce7a3 | ||
|
|
34c8e6e38c | ||
|
|
e69bda3aa6 | ||
|
|
5d55e5d826 | ||
|
|
b5902b9fc3 | ||
|
|
f60cf0bd3c | ||
|
|
83dec0ef54 | ||
|
|
40a76f02cd | ||
|
|
3def3cc456 | ||
|
|
30bd67d43a | ||
|
|
ffeccee680 | ||
|
|
facbeee024 | ||
|
|
09102c7903 | ||
|
|
fa33ec7ac8 | ||
|
|
c44f5cf14a | ||
|
|
27793d7c4f | ||
|
|
32b2902ef7 | ||
|
|
5cdb318854 | ||
|
|
a28f05bb88 | ||
|
|
cecfe73b2e | ||
|
|
b458c7918c | ||
|
|
d8660f4822 | ||
|
|
dad83773a6 | ||
|
|
d2d35de46b | ||
|
|
c752ec0b38 | ||
|
|
28752eb56e | ||
|
|
4f243a0fcf | ||
|
|
9bce616f26 | ||
|
|
f16ab73c9a | ||
|
|
c29a15e073 | ||
|
|
f5fe61e3eb | ||
|
|
a1a752b0fb | ||
|
|
7769250875 | ||
|
|
b3af9f3185 | ||
|
|
7906326790 | ||
|
|
3b4babb9d7 | ||
|
|
4b284ec747 | ||
|
|
e1b4cfb9c8 |
+375
-262
@@ -8,11 +8,21 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
|
# Large AppImage/exe uploads time out on Gitea's actions artifact pipeline.
|
||||||
|
# Build jobs publish assets straight to Gitea/GitHub releases via the REST API.
|
||||||
|
|
||||||
|
# actions/cache works on the self-hosted runner (pizzabox): act_runner runs its own
|
||||||
|
# cache server, so its port must be reachable from the job container. Fixed ports
|
||||||
|
# (34085 docker runner, 34086 host runner) plus a ufw rule for the docker range.
|
||||||
|
# Saves are confirmed working, so runs after the first should hit.
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
increment-version:
|
prepare:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.finalize.outputs.VERSION }}
|
version: ${{ steps.finalize.outputs.VERSION }}
|
||||||
|
tag: ${{ steps.finalize.outputs.TAG_NAME }}
|
||||||
|
commit_sha: ${{ steps.finalize.outputs.COMMIT_SHA }}
|
||||||
should_build: ${{ steps.decide.outputs.SHOULD_BUILD }}
|
should_build: ${{ steps.decide.outputs.SHOULD_BUILD }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -39,6 +49,11 @@ jobs:
|
|||||||
SHOULD_BUILD=false
|
SHOULD_BUILD=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# [skip build] runs the checks workflow but skips the Electron build.
|
||||||
|
if echo "$COMMIT_MSG" | grep -qi '\[skip build\]'; then
|
||||||
|
SHOULD_BUILD=false
|
||||||
|
fi
|
||||||
|
|
||||||
echo "CURRENT_VERSION=$CURRENT" >> $GITHUB_OUTPUT
|
echo "CURRENT_VERSION=$CURRENT" >> $GITHUB_OUTPUT
|
||||||
echo "SHOULD_BUMP=$SHOULD_BUMP" >> $GITHUB_OUTPUT
|
echo "SHOULD_BUMP=$SHOULD_BUMP" >> $GITHUB_OUTPUT
|
||||||
echo "SHOULD_BUILD=$SHOULD_BUILD" >> $GITHUB_OUTPUT
|
echo "SHOULD_BUILD=$SHOULD_BUILD" >> $GITHUB_OUTPUT
|
||||||
@@ -49,7 +64,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Bump patch version
|
- name: Bump patch version
|
||||||
id: bump
|
id: bump
|
||||||
if: ${{ steps.decide.outputs.SHOULD_BUMP == 'true' }}
|
if: steps.decide.outputs.SHOULD_BUILD == 'true' && steps.decide.outputs.SHOULD_BUMP == 'true'
|
||||||
run: |
|
run: |
|
||||||
# Get current version from package.json
|
# Get current version from package.json
|
||||||
CURRENT=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
CURRENT=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
||||||
@@ -72,7 +87,7 @@ jobs:
|
|||||||
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
|
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Commit and push version bump
|
- name: Commit and push version bump
|
||||||
if: ${{ steps.decide.outputs.SHOULD_BUMP == 'true' }}
|
if: steps.decide.outputs.SHOULD_BUILD == 'true' && steps.decide.outputs.SHOULD_BUMP == 'true'
|
||||||
run: |
|
run: |
|
||||||
git config user.name "GitHub Actions"
|
git config user.name "GitHub Actions"
|
||||||
git config user.email "actions@github.com"
|
git config user.email "actions@github.com"
|
||||||
@@ -96,104 +111,106 @@ jobs:
|
|||||||
echo "Failed to push version bump after 3 attempts"
|
echo "Failed to push version bump after 3 attempts"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Finalize version output
|
- name: Resolve version and commit
|
||||||
id: finalize
|
id: finalize
|
||||||
|
if: steps.decide.outputs.SHOULD_BUILD == 'true'
|
||||||
run: |
|
run: |
|
||||||
if [ -n "${{ steps.bump.outputs.VERSION }}" ]; then
|
if [ -n "${{ steps.bump.outputs.VERSION }}" ]; then
|
||||||
echo "VERSION=${{ steps.bump.outputs.VERSION }}" >> $GITHUB_OUTPUT
|
VERSION="${{ steps.bump.outputs.VERSION }}"
|
||||||
else
|
else
|
||||||
echo "VERSION=${{ steps.decide.outputs.CURRENT_VERSION }}" >> $GITHUB_OUTPUT
|
VERSION=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
||||||
|
fi
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "TAG_NAME=v$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
echo "Version: $VERSION"
|
||||||
|
|
||||||
|
- name: Create and push tag
|
||||||
|
if: steps.decide.outputs.SHOULD_BUILD == 'true'
|
||||||
|
run: |
|
||||||
|
TAG_NAME="${{ steps.finalize.outputs.TAG_NAME }}"
|
||||||
|
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
|
||||||
|
echo "Tag $TAG_NAME already exists"
|
||||||
|
else
|
||||||
|
git config user.name "GitHub Actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
|
git tag -a "$TAG_NAME" -m "Release $TAG_NAME"
|
||||||
|
git push origin "$TAG_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build-windows:
|
- name: Ensure Gitea release
|
||||||
runs-on: windows
|
if: steps.decide.outputs.SHOULD_BUILD == 'true'
|
||||||
needs: increment-version
|
env:
|
||||||
if: always() && (needs.increment-version.outputs.should_build == 'true' || needs.increment-version.result == 'skipped')
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: false
|
|
||||||
ref: ${{ github.ref_name }}
|
|
||||||
|
|
||||||
- name: Checkout submodules manually
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
run: |
|
||||||
git submodule sync --recursive
|
set -euo pipefail
|
||||||
|
VERSION="${{ steps.finalize.outputs.VERSION }}"
|
||||||
|
TAG_NAME="${{ steps.finalize.outputs.TAG_NAME }}"
|
||||||
|
API_BASE="${{ github.server_url }}/api/v1"
|
||||||
|
REPO="${{ github.repository }}"
|
||||||
|
|
||||||
if (git submodule update --init --recursive) {
|
RELEASE_ID=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
Write-Host "Submodules checked out at pinned commits."
|
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty' || true)
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Warning "Pinned submodule commit is unavailable on remote. Falling back to remote submodule HEAD."
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
git submodule deinit -f --all
|
echo "Creating Gitea release ${TAG_NAME}..."
|
||||||
git submodule update --init --recursive --remote
|
RELEASE_ID=$(curl -fsS -X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${TAG_NAME}\", \"body\": \"Release ${VERSION}\", \"draft\": false, \"prerelease\": false}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
|
||||||
|
fi
|
||||||
|
|
||||||
Write-Host "Resolved submodule commit:"
|
echo "Gitea release id: ${RELEASE_ID}"
|
||||||
git -C cinny rev-parse HEAD
|
|
||||||
|
|
||||||
- name: Pull latest (after version bump)
|
- name: Ensure GitHub release
|
||||||
if: github.ref == 'refs/heads/main'
|
if: steps.decide.outputs.SHOULD_BUILD == 'true'
|
||||||
shell: powershell
|
|
||||||
run: git pull origin main
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
|
|
||||||
- name: Install dependencies (root)
|
|
||||||
run: npm ci --prefer-offline
|
|
||||||
|
|
||||||
- name: Install dependencies (cinny)
|
|
||||||
working-directory: ./cinny
|
|
||||||
run: npm ci --prefer-offline
|
|
||||||
|
|
||||||
- name: Clean previous builds
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
if (Test-Path cinny/dist) { Remove-Item -Recurse -Force cinny/dist }
|
|
||||||
if (Test-Path dist-electron) { Remove-Item -Recurse -Force dist-electron }
|
|
||||||
|
|
||||||
- name: Build Electron app
|
|
||||||
run: npm run build:local -- --win
|
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||||
|
|
||||||
- name: Upload NSIS Installer (x64)
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: Paarrot-Setup-x64.exe
|
|
||||||
path: dist-electron/Paarrot-*-win-x64.exe
|
|
||||||
|
|
||||||
- name: Upload latest.yml
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: latest.yml
|
|
||||||
path: dist-electron/latest.yml
|
|
||||||
|
|
||||||
- name: List build output
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
run: |
|
||||||
Get-ChildItem -Path dist-electron -Recurse | Select-Object FullName
|
set -euo pipefail
|
||||||
|
VERSION="${{ steps.finalize.outputs.VERSION }}"
|
||||||
|
TAG_NAME="${{ steps.finalize.outputs.TAG_NAME }}"
|
||||||
|
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||||
|
|
||||||
build-linux:
|
RELEASE_ID=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty' || true)
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "Creating GitHub release ${TAG_NAME}..."
|
||||||
|
RELEASE_ID=$(curl -fsS -X POST \
|
||||||
|
-H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${TAG_NAME}\", \"body\": \"Release ${VERSION}\", \"draft\": false, \"prerelease\": false}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases" | jq -r '.id')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "GitHub release id: ${RELEASE_ID}"
|
||||||
|
|
||||||
|
build-windows:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: increment-version
|
needs: prepare
|
||||||
if: always() && (needs.increment-version.outputs.should_build == 'true' || needs.increment-version.result == 'skipped')
|
if: always() && needs.prepare.result == 'success' && needs.prepare.outputs.should_build == 'true'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: false
|
submodules: false
|
||||||
ref: ${{ github.ref_name }}
|
fetch-depth: 1
|
||||||
|
ref: ${{ needs.prepare.outputs.commit_sha }}
|
||||||
|
|
||||||
- name: Checkout submodules manually
|
- name: Checkout submodules manually
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
# Use the same host/scheme the runner already used for origin (not public HTTPS).
|
||||||
|
ORIGIN_URL=$(git remote get-url origin)
|
||||||
|
ORIGIN_URL=${ORIGIN_URL%/}
|
||||||
|
ORIGIN_URL=${ORIGIN_URL%.git}
|
||||||
|
BASE_URL=${ORIGIN_URL%/*}
|
||||||
|
CINNY_URL="${BASE_URL}/cinny.git"
|
||||||
|
echo "Rewriting submodule URL to ${CINNY_URL}"
|
||||||
|
git config submodule.cinny.url "${CINNY_URL}"
|
||||||
git submodule sync --recursive
|
git submodule sync --recursive
|
||||||
|
|
||||||
if git submodule update --init --recursive; then
|
if git submodule update --init --recursive; then
|
||||||
@@ -202,20 +219,62 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Pinned submodule commit is unavailable on remote. Falling back to remote submodule HEAD."
|
echo "Pinned submodule commit is unavailable on remote. Falling back to remote submodule HEAD."
|
||||||
git submodule deinit -f --all
|
git submodule deinit -f --all || true
|
||||||
|
rm -rf cinny .git/modules/cinny
|
||||||
|
git config submodule.cinny.url "${CINNY_URL}"
|
||||||
|
git submodule sync --recursive
|
||||||
git submodule update --init --recursive --remote
|
git submodule update --init --recursive --remote
|
||||||
|
|
||||||
echo "Resolved submodule commit:"
|
echo "Resolved submodule commit:"
|
||||||
git -C cinny rev-parse HEAD
|
git -C cinny rev-parse HEAD
|
||||||
|
|
||||||
- name: Pull latest (after version bump)
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
run: git pull origin main
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '22'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: |
|
||||||
|
package-lock.json
|
||||||
|
cinny/package-lock.json
|
||||||
|
|
||||||
|
- name: Cache Electron downloads
|
||||||
|
uses: actions/cache@v4
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/electron
|
||||||
|
~/.cache/electron-builder
|
||||||
|
key: electron-${{ hashFiles('package-lock.json') }}
|
||||||
|
restore-keys: electron-
|
||||||
|
|
||||||
|
- name: Install Wine (NSIS cross-build)
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# wine + wine32 + wine64 are prebaked in the runner image used on pizzabox,
|
||||||
|
# so this is normally a no-op. Fallback below covers runners without it.
|
||||||
|
# (act_runner takes the image from the label stored in Gitea, so the baked
|
||||||
|
# image is tagged as gitea/runner-images:ubuntu-latest on that host.)
|
||||||
|
# force_pull must stay false on that runner, otherwise the shadowed tag is
|
||||||
|
# replaced by the upstream image and this step installs wine again.
|
||||||
|
# NSIS's makensis.exe is 32-bit, so wine32 is required; the wine64 package
|
||||||
|
# alone ships only /usr/lib/wine/wine64 (no `wine` on PATH).
|
||||||
|
if command -v wine >/dev/null 2>&1; then
|
||||||
|
echo "wine already present: $(wine --version)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
|
sudo apt-get update
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends wine wine32 wine64
|
||||||
|
|
||||||
|
if ! command -v wine >/dev/null 2>&1; then
|
||||||
|
WINE64_BIN=$(command -v wine64 || echo /usr/lib/wine/wine64)
|
||||||
|
echo "No wine binary; linking wine64 -> /usr/local/bin/wine (${WINE64_BIN})"
|
||||||
|
sudo ln -sf "${WINE64_BIN}" /usr/local/bin/wine
|
||||||
|
fi
|
||||||
|
|
||||||
|
command -v wine
|
||||||
|
wine --version
|
||||||
|
|
||||||
- name: Install dependencies (root)
|
- name: Install dependencies (root)
|
||||||
run: npm ci --prefer-offline
|
run: npm ci --prefer-offline
|
||||||
@@ -224,217 +283,271 @@ jobs:
|
|||||||
working-directory: ./cinny
|
working-directory: ./cinny
|
||||||
run: npm ci --prefer-offline
|
run: npm ci --prefer-offline
|
||||||
|
|
||||||
- name: Clean previous builds
|
- name: Build Electron app
|
||||||
|
run: npm run build:local -- --win
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||||
|
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
|
||||||
|
|
||||||
|
- name: Upload Windows assets to releases
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||||
run: |
|
run: |
|
||||||
rm -rf cinny/dist dist-electron
|
set -euo pipefail
|
||||||
|
TAG_NAME="${{ needs.prepare.outputs.tag }}"
|
||||||
|
API_BASE="${{ github.server_url }}/api/v1"
|
||||||
|
REPO="${{ github.repository }}"
|
||||||
|
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||||
|
|
||||||
|
GITEA_RELEASE_ID=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id')
|
||||||
|
GH_RELEASE_ID=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/tags/${TAG_NAME}" | jq -r '.id')
|
||||||
|
GH_UPLOAD_URL=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/${GH_RELEASE_ID}" | jq -r '.upload_url' | sed 's/{?name,label}//')
|
||||||
|
|
||||||
|
upload_one() {
|
||||||
|
local FILE="$1"
|
||||||
|
local FILENAME
|
||||||
|
FILENAME=$(basename "$FILE")
|
||||||
|
echo "Uploading ${FILENAME} ($(du -h "$FILE" | cut -f1))..."
|
||||||
|
|
||||||
|
OLD_ID=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/${GITEA_RELEASE_ID}/assets" \
|
||||||
|
| jq -r --arg n "$FILENAME" '.[] | select(.name == $n) | .id' || true)
|
||||||
|
if [ -n "${OLD_ID:-}" ]; then
|
||||||
|
curl -fsS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/${GITEA_RELEASE_ID}/assets/${OLD_ID}" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -fsS --max-time 0 --retry 5 --retry-delay 10 \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary @"${FILE}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/${GITEA_RELEASE_ID}/assets?name=${FILENAME}" \
|
||||||
|
>/dev/null
|
||||||
|
echo " Gitea: ok"
|
||||||
|
|
||||||
|
OLD_GH=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/${GH_RELEASE_ID}/assets" \
|
||||||
|
| jq -r --arg n "$FILENAME" '.[] | select(.name == $n) | .id' || true)
|
||||||
|
if [ -n "${OLD_GH:-}" ]; then
|
||||||
|
curl -fsS -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/assets/${OLD_GH}" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -fsS --max-time 0 --retry 5 --retry-delay 10 \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary @"${FILE}" \
|
||||||
|
"${GH_UPLOAD_URL}?name=${FILENAME}" \
|
||||||
|
>/dev/null
|
||||||
|
echo " GitHub: ok"
|
||||||
|
}
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
for FILE in dist-electron/Paarrot-*-win-x64.exe dist-electron/latest.yml; do
|
||||||
|
upload_one "$FILE"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: List build output
|
||||||
|
run: |
|
||||||
|
find dist-electron -type f -printf '%p\n' | sort
|
||||||
|
|
||||||
|
build-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare
|
||||||
|
if: always() && needs.prepare.result == 'success' && needs.prepare.outputs.should_build == 'true'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: false
|
||||||
|
fetch-depth: 1
|
||||||
|
ref: ${{ needs.prepare.outputs.commit_sha }}
|
||||||
|
|
||||||
|
- name: Checkout submodules manually
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# Use the same host/scheme the runner already used for origin (not public HTTPS).
|
||||||
|
ORIGIN_URL=$(git remote get-url origin)
|
||||||
|
ORIGIN_URL=${ORIGIN_URL%/}
|
||||||
|
ORIGIN_URL=${ORIGIN_URL%.git}
|
||||||
|
BASE_URL=${ORIGIN_URL%/*}
|
||||||
|
CINNY_URL="${BASE_URL}/cinny.git"
|
||||||
|
echo "Rewriting submodule URL to ${CINNY_URL}"
|
||||||
|
git config submodule.cinny.url "${CINNY_URL}"
|
||||||
|
git submodule sync --recursive
|
||||||
|
|
||||||
|
if git submodule update --init --recursive; then
|
||||||
|
echo "Submodules checked out at pinned commits."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Pinned submodule commit is unavailable on remote. Falling back to remote submodule HEAD."
|
||||||
|
git submodule deinit -f --all || true
|
||||||
|
rm -rf cinny .git/modules/cinny
|
||||||
|
git config submodule.cinny.url "${CINNY_URL}"
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update --init --recursive --remote
|
||||||
|
|
||||||
|
echo "Resolved submodule commit:"
|
||||||
|
git -C cinny rev-parse HEAD
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: |
|
||||||
|
package-lock.json
|
||||||
|
cinny/package-lock.json
|
||||||
|
|
||||||
|
- name: Cache Electron downloads
|
||||||
|
uses: actions/cache@v4
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/electron
|
||||||
|
~/.cache/electron-builder
|
||||||
|
key: electron-${{ hashFiles('package-lock.json') }}
|
||||||
|
restore-keys: electron-
|
||||||
|
|
||||||
|
- name: Install dependencies (root)
|
||||||
|
run: npm ci --prefer-offline
|
||||||
|
|
||||||
|
- name: Install dependencies (cinny)
|
||||||
|
working-directory: ./cinny
|
||||||
|
run: npm ci --prefer-offline
|
||||||
|
|
||||||
- name: Build Electron app
|
- name: Build Electron app
|
||||||
run: npm run build:local -- --linux
|
run: npm run build:local -- --linux
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||||
|
|
||||||
- name: Upload AppImage
|
- name: Upload Linux assets to releases
|
||||||
uses: actions/upload-artifact@v3
|
env:
|
||||||
with:
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
name: Paarrot-Linux-x64.AppImage
|
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||||
path: dist-electron/Paarrot-*.AppImage
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
TAG_NAME="${{ needs.prepare.outputs.tag }}"
|
||||||
|
API_BASE="${{ github.server_url }}/api/v1"
|
||||||
|
REPO="${{ github.repository }}"
|
||||||
|
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||||
|
|
||||||
- name: Upload latest-linux.yml
|
GITEA_RELEASE_ID=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
uses: actions/upload-artifact@v3
|
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id')
|
||||||
with:
|
GH_RELEASE_ID=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
name: latest-linux.yml
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/tags/${TAG_NAME}" | jq -r '.id')
|
||||||
path: dist-electron/latest-linux.yml
|
GH_UPLOAD_URL=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/${GH_RELEASE_ID}" | jq -r '.upload_url' | sed 's/{?name,label}//')
|
||||||
|
|
||||||
create-release:
|
upload_one() {
|
||||||
|
local FILE="$1"
|
||||||
|
local FILENAME
|
||||||
|
FILENAME=$(basename "$FILE")
|
||||||
|
echo "Uploading ${FILENAME} ($(du -h "$FILE" | cut -f1))..."
|
||||||
|
|
||||||
|
OLD_ID=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/${GITEA_RELEASE_ID}/assets" \
|
||||||
|
| jq -r --arg n "$FILENAME" '.[] | select(.name == $n) | .id' || true)
|
||||||
|
if [ -n "${OLD_ID:-}" ]; then
|
||||||
|
curl -fsS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/${GITEA_RELEASE_ID}/assets/${OLD_ID}" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -fsS --max-time 0 --retry 5 --retry-delay 10 \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary @"${FILE}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/${GITEA_RELEASE_ID}/assets?name=${FILENAME}" \
|
||||||
|
>/dev/null
|
||||||
|
echo " Gitea: ok"
|
||||||
|
|
||||||
|
OLD_GH=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/${GH_RELEASE_ID}/assets" \
|
||||||
|
| jq -r --arg n "$FILENAME" '.[] | select(.name == $n) | .id' || true)
|
||||||
|
if [ -n "${OLD_GH:-}" ]; then
|
||||||
|
curl -fsS -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/assets/${OLD_GH}" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -fsS --max-time 0 --retry 5 --retry-delay 10 \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${GH_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary @"${FILE}" \
|
||||||
|
"${GH_UPLOAD_URL}?name=${FILENAME}" \
|
||||||
|
>/dev/null
|
||||||
|
echo " GitHub: ok"
|
||||||
|
}
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
for FILE in dist-electron/Paarrot-*.AppImage dist-electron/latest-linux.yml; do
|
||||||
|
upload_one "$FILE"
|
||||||
|
done
|
||||||
|
|
||||||
|
finalize-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [increment-version, build-windows, build-linux]
|
needs: [prepare, build-windows, build-linux]
|
||||||
if: always() && (needs.build-windows.result == 'success' || needs.build-linux.result == 'success')
|
if: always() && needs.prepare.result == 'success' && needs.prepare.outputs.should_build == 'true' && (needs.build-windows.result == 'success' || needs.build-linux.result == 'success')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Cleanup old Gitea releases
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
ref: ${{ github.ref_name }}
|
|
||||||
|
|
||||||
- name: Pull latest (after version bump)
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
run: git pull origin main
|
|
||||||
|
|
||||||
- name: Get version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
# Use version from increment-version job if available, otherwise read from file
|
|
||||||
if [ -n "${{ needs.increment-version.outputs.version }}" ]; then
|
|
||||||
VERSION="${{ needs.increment-version.outputs.version }}"
|
|
||||||
else
|
|
||||||
VERSION=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
|
||||||
fi
|
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "Version: $VERSION"
|
|
||||||
|
|
||||||
- name: Check if tag exists
|
|
||||||
id: tag_check
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
|
||||||
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
|
||||||
echo "Tag v$VERSION already exists"
|
|
||||||
echo "exists=true" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "Tag v$VERSION does not exist"
|
|
||||||
echo "exists=false" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Create and push tag
|
|
||||||
if: steps.tag_check.outputs.exists == 'false'
|
|
||||||
run: |
|
|
||||||
git config user.name "GitHub Actions"
|
|
||||||
git config user.email "actions@github.com"
|
|
||||||
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "Release v${{ steps.version.outputs.VERSION }}"
|
|
||||||
git push origin "v${{ steps.version.outputs.VERSION }}"
|
|
||||||
|
|
||||||
- name: Download all artifacts
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
path: artifacts
|
|
||||||
|
|
||||||
- name: Prepare release files
|
|
||||||
run: |
|
|
||||||
mkdir -p release-files
|
|
||||||
find artifacts -type f \( -name "*.exe" -o -name "*.AppImage" -o -name "*.yml" \) -exec cp {} release-files/ \;
|
|
||||||
ls -la release-files/
|
|
||||||
|
|
||||||
- name: Create or Update Release
|
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
set -euo pipefail
|
||||||
TAG_NAME="v${VERSION}"
|
TAG_NAME="${{ needs.prepare.outputs.tag }}"
|
||||||
API_BASE="http://synbox.ruv.wtf:8418/api/v1"
|
API_BASE="${{ github.server_url }}/api/v1"
|
||||||
REPO="litruv/cinny-desktop"
|
REPO="${{ github.repository }}"
|
||||||
|
|
||||||
# Delete old releases (keep only current)
|
echo "Cleaning up old Gitea releases (keeping ${TAG_NAME})..."
|
||||||
echo "Cleaning up old releases..."
|
OLD_RELEASES=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
OLD_RELEASES=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
"${API_BASE}/repos/${REPO}/releases" | jq -r --arg t "$TAG_NAME" '.[] | select(.tag_name != $t) | .id')
|
||||||
"${API_BASE}/repos/${REPO}/releases" | jq -r '.[] | select(.tag_name != "'${TAG_NAME}'") | .id')
|
|
||||||
|
|
||||||
for OLD_ID in $OLD_RELEASES; do
|
for OLD_ID in $OLD_RELEASES; do
|
||||||
echo "Deleting old release ${OLD_ID}..."
|
[ -n "$OLD_ID" ] || continue
|
||||||
OLD_TAG=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
OLD_TAG=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
"${API_BASE}/repos/${REPO}/releases/${OLD_ID}" | jq -r '.tag_name')
|
"${API_BASE}/repos/${REPO}/releases/${OLD_ID}" | jq -r '.tag_name')
|
||||||
|
echo "Deleting Gitea release ${OLD_ID} (${OLD_TAG})..."
|
||||||
# Delete release
|
curl -fsS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
"${API_BASE}/repos/${REPO}/releases/${OLD_ID}" >/dev/null || true
|
||||||
"${API_BASE}/repos/${REPO}/releases/${OLD_ID}"
|
if [ -n "$OLD_TAG" ] && [ "$OLD_TAG" != "null" ]; then
|
||||||
|
curl -fsS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
# Delete tag
|
"${API_BASE}/repos/${REPO}/tags/${OLD_TAG}" >/dev/null || true
|
||||||
if [ -n "$OLD_TAG" ]; then
|
|
||||||
echo "Deleting old tag ${OLD_TAG}..."
|
|
||||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
"${API_BASE}/repos/${REPO}/tags/${OLD_TAG}"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if release exists
|
- name: Cleanup old GitHub releases
|
||||||
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
|
|
||||||
|
|
||||||
if [ -z "$RELEASE_ID" ]; then
|
|
||||||
echo "Creating new release for ${TAG_NAME}..."
|
|
||||||
RELEASE_ID=$(curl -s -X POST \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${TAG_NAME}\", \"body\": \"Release ${VERSION}\", \"draft\": false, \"prerelease\": false}" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
|
|
||||||
echo "Created release with ID: ${RELEASE_ID}"
|
|
||||||
else
|
|
||||||
echo "Release exists with ID: ${RELEASE_ID}"
|
|
||||||
# Delete existing assets
|
|
||||||
echo "Deleting existing assets..."
|
|
||||||
ASSETS=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets" | jq -r '.[].id')
|
|
||||||
for ASSET_ID in $ASSETS; do
|
|
||||||
echo "Deleting asset ${ASSET_ID}..."
|
|
||||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Upload new assets
|
|
||||||
echo "Uploading assets..."
|
|
||||||
for FILE in release-files/*; do
|
|
||||||
FILENAME=$(basename "$FILE")
|
|
||||||
echo "Uploading ${FILENAME}..."
|
|
||||||
curl -s -X POST \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary "@${FILE}" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
|
||||||
echo ""
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Release complete!"
|
|
||||||
|
|
||||||
- name: Create GitHub Release
|
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
set -euo pipefail
|
||||||
TAG_NAME="v${VERSION}"
|
TAG_NAME="${{ needs.prepare.outputs.tag }}"
|
||||||
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||||
|
|
||||||
# Delete old GitHub releases (keep only current)
|
echo "Cleaning up old GitHub releases (keeping ${TAG_NAME})..."
|
||||||
echo "Cleaning up old GitHub releases..."
|
OLD_RELEASES=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
OLD_RELEASES=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
"https://api.github.com/repos/${GITHUB_REPO}/releases" | jq -r --arg t "$TAG_NAME" '.[] | select(.tag_name != $t) | .id')
|
||||||
"https://api.github.com/repos/${GITHUB_REPO}/releases" | jq -r '.[] | select(.tag_name != "'${TAG_NAME}'") | .id')
|
|
||||||
|
|
||||||
for OLD_ID in $OLD_RELEASES; do
|
for OLD_ID in $OLD_RELEASES; do
|
||||||
echo "Deleting old GitHub release ${OLD_ID}..."
|
[ -n "$OLD_ID" ] || continue
|
||||||
OLD_TAG=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
OLD_TAG=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/${OLD_ID}" | jq -r '.tag_name')
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/${OLD_ID}" | jq -r '.tag_name')
|
||||||
|
echo "Deleting GitHub release ${OLD_ID} (${OLD_TAG})..."
|
||||||
# Delete release
|
curl -fsS -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
||||||
curl -s -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
"https://api.github.com/repos/${GITHUB_REPO}/releases/${OLD_ID}" >/dev/null || true
|
||||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/${OLD_ID}"
|
if [ -n "$OLD_TAG" ] && [ "$OLD_TAG" != "null" ]; then
|
||||||
|
curl -fsS -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
||||||
# Delete tag
|
"https://api.github.com/repos/${GITHUB_REPO}/git/refs/tags/${OLD_TAG}" >/dev/null || true
|
||||||
if [ -n "$OLD_TAG" ]; then
|
|
||||||
echo "Deleting old GitHub tag ${OLD_TAG}..."
|
|
||||||
curl -s -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
|
||||||
"https://api.github.com/repos/${GITHUB_REPO}/git/refs/tags/${OLD_TAG}"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if release exists on GitHub
|
echo "Release finalize complete for ${TAG_NAME}"
|
||||||
RELEASE_ID=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
|
||||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
|
|
||||||
|
|
||||||
if [ -z "$RELEASE_ID" ]; then
|
|
||||||
echo "Creating new GitHub release for ${TAG_NAME}..."
|
|
||||||
RELEASE_ID=$(curl -s -X POST \
|
|
||||||
-H "Authorization: token ${GH_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${TAG_NAME}\", \"body\": \"Release ${VERSION}\", \"draft\": false, \"prerelease\": false}" \
|
|
||||||
"https://api.github.com/repos/${GITHUB_REPO}/releases" | jq -r '.id')
|
|
||||||
echo "Created GitHub release with ID: ${RELEASE_ID}"
|
|
||||||
else
|
|
||||||
echo "GitHub release exists with ID: ${RELEASE_ID}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Upload assets to GitHub
|
|
||||||
echo "Uploading assets to GitHub..."
|
|
||||||
UPLOAD_URL=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
|
||||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/${RELEASE_ID}" | jq -r '.upload_url' | sed 's/{?name,label}//')
|
|
||||||
|
|
||||||
for FILE in release-files/*; do
|
|
||||||
FILENAME=$(basename "$FILE")
|
|
||||||
echo "Uploading ${FILENAME} to GitHub..."
|
|
||||||
curl -s -X POST \
|
|
||||||
-H "Authorization: token ${GH_TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary "@${FILE}" \
|
|
||||||
"${UPLOAD_URL}?name=${FILENAME}"
|
|
||||||
echo ""
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "GitHub release complete!"
|
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
name: Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: false
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Checkout submodules manually
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# Use the same host/scheme the runner already used for origin (not public HTTPS).
|
||||||
|
ORIGIN_URL=$(git remote get-url origin)
|
||||||
|
ORIGIN_URL=${ORIGIN_URL%/}
|
||||||
|
ORIGIN_URL=${ORIGIN_URL%.git}
|
||||||
|
BASE_URL=${ORIGIN_URL%/*}
|
||||||
|
CINNY_URL="${BASE_URL}/cinny.git"
|
||||||
|
echo "Rewriting submodule URL to ${CINNY_URL}"
|
||||||
|
git config submodule.cinny.url "${CINNY_URL}"
|
||||||
|
git submodule sync --recursive
|
||||||
|
|
||||||
|
if git submodule update --init --recursive; then
|
||||||
|
echo "Submodules checked out at pinned commits."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Pinned submodule commit is unavailable on remote. Falling back to remote submodule HEAD."
|
||||||
|
git submodule deinit -f --all || true
|
||||||
|
rm -rf cinny .git/modules/cinny
|
||||||
|
git config submodule.cinny.url "${CINNY_URL}"
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update --init --recursive --remote
|
||||||
|
|
||||||
|
echo "Resolved submodule commit:"
|
||||||
|
git -C cinny rev-parse HEAD
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: cinny/package-lock.json
|
||||||
|
|
||||||
|
- name: Install dependencies (cinny)
|
||||||
|
working-directory: ./cinny
|
||||||
|
run: npm ci --prefer-offline
|
||||||
|
|
||||||
|
# ci-checks.sh always exits 0: findings become issues, not failed builds.
|
||||||
|
- name: Run checks
|
||||||
|
env:
|
||||||
|
API_BASE: ${{ github.server_url }}/api/v1
|
||||||
|
# github.server_url is the internal runner host, so the commit link needs the public one.
|
||||||
|
WEB_BASE: https://git.ruv.wtf
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
SHA: ${{ github.sha }}
|
||||||
|
# Prefer a PAT with issue write scope (secret: GITEA_TOKEN).
|
||||||
|
# Default GITHUB_TOKEN is usually scoped to this repo only.
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
TOKEN="${GITEA_TOKEN:-${GITHUB_TOKEN:-}}"
|
||||||
|
if [ -z "$TOKEN" ]; then
|
||||||
|
echo "No GITEA_TOKEN/GITHUB_TOKEN available to file issues"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
export TOKEN
|
||||||
|
bash cinny/scripts/ci-checks.sh
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
unit:
|
||||||
|
# act_runner mounts /var/run/docker.sock into every container job, so a fork PR reaches
|
||||||
|
# the Docker daemon on the runner host. Both jobs need the same guard.
|
||||||
|
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Run unit tests
|
||||||
|
run: npm run test:unit
|
||||||
|
|
||||||
|
e2e:
|
||||||
|
# A fork PR controls both the test files and these steps, so only same-repository
|
||||||
|
# PRs can be trusted with the E2E_PASSWORD secret.
|
||||||
|
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Needs the DOCKER-USER exception on the runner host: ruv.wtf is a macvlan interface on a
|
||||||
|
# container there, so the reply to a bridge-networked job arrives on that container's bridge
|
||||||
|
# and Docker's inter-bridge isolation drops it. The exception is host-wide, so it also covers
|
||||||
|
# fork PR jobs, and the bridge name is Docker-generated: recreating the caddy container
|
||||||
|
# renames it and the test fails closed.
|
||||||
|
env:
|
||||||
|
# Dedicated test account on the homeserver, not a personal one.
|
||||||
|
E2E_HOMESERVER: ruv.wtf
|
||||||
|
E2E_USER: giteaci
|
||||||
|
# Repo secret: E2E_PASSWORD. The test fails with a clear message when it is missing.
|
||||||
|
E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
|
||||||
|
steps:
|
||||||
|
# .gitmodules uses a relative URL, so the runner resolves it against origin.
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
# The E2E run drives the vite dev server, so cinny's dependencies are needed too.
|
||||||
|
- name: Install dependencies (cinny)
|
||||||
|
working-directory: ./cinny
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
# Electron needs system libraries the runner image does not ship. Do not narrow this to
|
||||||
|
# chromium: Playwright's chromium dep set covers its own bundled browser, not Electron,
|
||||||
|
# and drops libgtk-3-0t64, libegl1, libegl-mesa0, libgles2, libsecret-1-0, libxtst6 and
|
||||||
|
# libxss1, which Electron needs to launch. Narrowing it fails with "Process failed to
|
||||||
|
# launch!".
|
||||||
|
- name: Install system libraries for Electron
|
||||||
|
run: npx playwright install-deps
|
||||||
|
|
||||||
|
# The container runner image has no xvfb and no fresh apt lists. The host runner already
|
||||||
|
# has xvfb, so the guard skips the install there; both share the ubuntu-latest label, so
|
||||||
|
# which one runs is not fixed.
|
||||||
|
- name: Ensure a display for Electron
|
||||||
|
run: command -v xvfb-run >/dev/null || (sudo apt-get update && sudo apt-get install -y xvfb)
|
||||||
|
|
||||||
|
# The login form only renders after the auth-flows request succeeds, so an
|
||||||
|
# unreachable homeserver shows up as a 30s locator timeout. Fail fast instead, on
|
||||||
|
# connect failure or a non-2xx status.
|
||||||
|
- name: Homeserver reachable from the runner
|
||||||
|
run: curl -sSf --max-time 20 -o /dev/null -w '%{http_code}\n' "https://$E2E_HOMESERVER/.well-known/matrix/client"
|
||||||
|
|
||||||
|
- name: Run login E2E
|
||||||
|
run: xvfb-run -a npm run test:e2e
|
||||||
|
|
||||||
|
# Gitea implements the v3 artifact protocol; v4 rejects it as GHES.
|
||||||
|
- name: Upload test artifacts
|
||||||
|
if: failure()
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: e2e-artifacts
|
||||||
|
path: |
|
||||||
|
test-results
|
||||||
|
playwright-report
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
name: Update release notes manifest
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'cinny/public/update/*.md'
|
||||||
|
- 'cinny/scripts/generate-update-manifest.mjs'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
manifest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Generate manifest.json
|
||||||
|
run: node cinny/scripts/generate-update-manifest.mjs
|
||||||
|
|
||||||
|
- name: Commit manifest if changed
|
||||||
|
run: |
|
||||||
|
if git diff --quiet -- cinny/public/update/manifest.json; then
|
||||||
|
echo "manifest.json unchanged"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add cinny/public/update/manifest.json
|
||||||
|
git commit -m "chore: regenerate update manifest.json"
|
||||||
|
git push
|
||||||
@@ -5,3 +5,5 @@ devAssets
|
|||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
dist-electron/
|
dist-electron/
|
||||||
|
playwright-report/
|
||||||
|
test-results/
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
[submodule "cinny"]
|
[submodule "cinny"]
|
||||||
path = cinny
|
path = cinny
|
||||||
url = http://synbox.ruv.wtf:8418/litruv/cinny.git
|
url = ../cinny.git
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Checks backlog
|
||||||
|
|
||||||
|
Lint and typecheck fix commits carry `[skip build]` in the commit message while
|
||||||
|
the `ci-checks` issues are being worked down across the cinny repos. The checks
|
||||||
|
workflow still runs; the Electron and mobile builds do not.
|
||||||
|
|
||||||
|
Honored in `cinny-desktop/.gitea/workflows/build.yml` and
|
||||||
|
`cinny-mobile/.gitea/workflows/build.yml`.
|
||||||
|
|
||||||
|
Do not use `[skip ci]` for these commits. It also suppresses the version bump.
|
||||||
@@ -30,6 +30,28 @@ To build the app locally, run:
|
|||||||
To start local dev server, run:
|
To start local dev server, run:
|
||||||
* `npm run dev`
|
* `npm run dev`
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
* `npm run test` - unit and E2E
|
||||||
|
* `npm run test:unit` - Vitest
|
||||||
|
* `npm run test:e2e` - Playwright driving Electron
|
||||||
|
|
||||||
|
The E2E test drives the real Electron app against the vite dev server, so it needs the
|
||||||
|
cinny dependencies installed and an X display. On a headless machine run it under xvfb:
|
||||||
|
`xvfb-run -a npm run test:e2e`.
|
||||||
|
|
||||||
|
The E2E test logs in to a live homeserver over the network, so it needs network access and a
|
||||||
|
working test account. It uses a dedicated account, never a personal one:
|
||||||
|
|
||||||
|
Variable | Default
|
||||||
|
---|---
|
||||||
|
`E2E_HOMESERVER` | `ruv.wtf`
|
||||||
|
`E2E_USER` | `giteaci`
|
||||||
|
`E2E_PASSWORD` | required, read from the environment, never committed
|
||||||
|
|
||||||
|
A failed E2E run attaches a screenshot and the main and renderer console logs to the
|
||||||
|
report. CI uploads `test-results/` and `playwright-report/` as artifacts.
|
||||||
|
|
||||||
## Plugin System
|
## Plugin System
|
||||||
|
|
||||||
Paarrot includes a plugin system for extending and customising the app with JavaScript modules.
|
Paarrot includes a plugin system for extending and customising the app with JavaScript modules.
|
||||||
@@ -38,7 +60,7 @@ Paarrot includes a plugin system for extending and customising the app with Java
|
|||||||
|
|
||||||
1. Drop a plugin folder into your plugins directory:
|
1. Drop a plugin folder into your plugins directory:
|
||||||
- **Windows**: `%APPDATA%\paarrot\plugins\<plugin-name>\`
|
- **Windows**: `%APPDATA%\paarrot\plugins\<plugin-name>\`
|
||||||
- **Linux**: `~/.config/Paarrot/plugins/<plugin-name>/`
|
- **Linux**: `~/.config/Paarrot/plugins/<plugin-name>/` for the packaged app, `~/.config/paarrot/plugins/<plugin-name>/` when running from source
|
||||||
- **macOS**: `~/Library/Application Support/Paarrot/plugins/<plugin-name>/`
|
- **macOS**: `~/Library/Application Support/Paarrot/plugins/<plugin-name>/`
|
||||||
2. Enable it in **Settings → Plugins → Installed**
|
2. Enable it in **Settings → Plugins → Installed**
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule cinny updated: b4258278d8...9b3956d85f
+79
-1
@@ -153,6 +153,72 @@ class PaarrotAPIServer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Recent messages across group channels (non-DMs)
|
||||||
|
this.app.get('/messages/groups', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await this.executeAction('get-messages-groups', {
|
||||||
|
limit: req.query.limit,
|
||||||
|
});
|
||||||
|
res.json({ success: true, data: result });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ success: false, error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Recent messages across DMs
|
||||||
|
this.app.get('/messages/dms', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await this.executeAction('get-messages-dms', {
|
||||||
|
limit: req.query.limit,
|
||||||
|
});
|
||||||
|
res.json({ success: true, data: result });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ success: false, error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Recent messages across groups + DMs
|
||||||
|
this.app.get('/messages/combined', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await this.executeAction('get-messages-combined', {
|
||||||
|
limit: req.query.limit,
|
||||||
|
});
|
||||||
|
res.json({ success: true, data: result });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ success: false, error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Unread conversations across group channels (non-DMs)
|
||||||
|
this.app.get('/unreads/groups', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await this.executeAction('get-unreads-groups');
|
||||||
|
res.json({ success: true, data: result });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ success: false, error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Unread conversations across DMs
|
||||||
|
this.app.get('/unreads/dms', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await this.executeAction('get-unreads-dms');
|
||||||
|
res.json({ success: true, data: result });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ success: false, error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Unread conversations across groups + DMs
|
||||||
|
this.app.get('/unreads/combined', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await this.executeAction('get-unreads-combined');
|
||||||
|
res.json({ success: true, data: result });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ success: false, error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 404 handler
|
// 404 handler
|
||||||
this.app.use((req, res) => {
|
this.app.use((req, res) => {
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
@@ -169,7 +235,13 @@ class PaarrotAPIServer {
|
|||||||
'GET /channels',
|
'GET /channels',
|
||||||
'POST /message',
|
'POST /message',
|
||||||
'POST /message/current',
|
'POST /message/current',
|
||||||
'GET /room/current'
|
'GET /room/current',
|
||||||
|
'GET /messages/groups',
|
||||||
|
'GET /messages/dms',
|
||||||
|
'GET /messages/combined',
|
||||||
|
'GET /unreads/groups',
|
||||||
|
'GET /unreads/dms',
|
||||||
|
'GET /unreads/combined'
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -237,6 +309,12 @@ class PaarrotAPIServer {
|
|||||||
console.log(' POST /message');
|
console.log(' POST /message');
|
||||||
console.log(' POST /message/current');
|
console.log(' POST /message/current');
|
||||||
console.log(' GET /room/current');
|
console.log(' GET /room/current');
|
||||||
|
console.log(' GET /messages/groups');
|
||||||
|
console.log(' GET /messages/dms');
|
||||||
|
console.log(' GET /messages/combined');
|
||||||
|
console.log(' GET /unreads/groups');
|
||||||
|
console.log(' GET /unreads/dms');
|
||||||
|
console.log(' GET /unreads/combined');
|
||||||
resolve(port);
|
resolve(port);
|
||||||
}).on('error', (err) => {
|
}).on('error', (err) => {
|
||||||
if (err.code === 'EADDRINUSE') {
|
if (err.code === 'EADDRINUSE') {
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Debug Packets</title>
|
||||||
|
<style>
|
||||||
|
:root { color-scheme: dark; }
|
||||||
|
body { margin: 0; background: #14161a; color: #d9dce1; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
||||||
|
main { display: flex; flex-direction: column; height: 100vh; }
|
||||||
|
header { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid #262a31; flex-wrap: wrap; }
|
||||||
|
input[type="search"] { flex: 1 1 160px; min-width: 120px; background: #1b1f25; color: inherit; border: 1px solid #2b3038; border-radius: 4px; padding: 6px 8px; font: inherit; }
|
||||||
|
button { background: #1b1f25; color: inherit; border: 1px solid #2b3038; border-radius: 4px; padding: 6px 10px; font: inherit; cursor: pointer; }
|
||||||
|
button:hover { border-color: #3b424d; }
|
||||||
|
label { display: flex; gap: 6px; align-items: center; }
|
||||||
|
#count { color: #8b93a1; }
|
||||||
|
#list { flex: 1; overflow: auto; }
|
||||||
|
table { width: 100%; border-collapse: collapse; }
|
||||||
|
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid #21252b; white-space: nowrap; }
|
||||||
|
th { position: sticky; top: 0; background: #171a1f; color: #8b93a1; }
|
||||||
|
tbody tr { cursor: pointer; }
|
||||||
|
tbody tr:hover, tbody tr.sel { background: #1b1f25; }
|
||||||
|
#detail { max-height: 40vh; overflow: auto; margin: 0; padding: 10px; border-top: 1px solid #262a31; white-space: pre-wrap; word-break: break-word; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<header>
|
||||||
|
<input id="filter" type="search" placeholder="Filter (method, path, status, txnId, eventId, body)" aria-label="Filter packets">
|
||||||
|
<label><input id="autoscroll" type="checkbox" checked> Autoscroll</label>
|
||||||
|
<button id="clear">Clear</button>
|
||||||
|
<button id="copy">Copy all</button>
|
||||||
|
<button id="download">Download JSON lines</button>
|
||||||
|
<span id="count">0</span>
|
||||||
|
</header>
|
||||||
|
<div id="list">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr><th>Time</th><th>Phase</th><th>Method</th><th>Path</th><th>Status</th><th>ms</th><th>txnId / eventId</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="rows"></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<pre id="detail"></pre>
|
||||||
|
</main>
|
||||||
|
<script>
|
||||||
|
const MAX = 2000;
|
||||||
|
const packets = [];
|
||||||
|
const rows = document.getElementById('rows');
|
||||||
|
const list = document.getElementById('list');
|
||||||
|
const detail = document.getElementById('detail');
|
||||||
|
const filter = document.getElementById('filter');
|
||||||
|
const autoscroll = document.getElementById('autoscroll');
|
||||||
|
const count = document.getElementById('count');
|
||||||
|
|
||||||
|
const text = (v) => (v === undefined || v === null ? '' : String(v));
|
||||||
|
|
||||||
|
function matches(p) {
|
||||||
|
const q = filter.value.trim().toLowerCase();
|
||||||
|
if (!q) return true;
|
||||||
|
return [p.method, p.path, p.status, p.txnId, p.eventId, p.error, p.req, p.res]
|
||||||
|
.some((f) => text(f).toLowerCase().includes(q));
|
||||||
|
}
|
||||||
|
|
||||||
|
function addRow(p) {
|
||||||
|
const tr = document.createElement('tr');
|
||||||
|
[new Date(p.ts).toLocaleTimeString(), p.phase, p.method, p.path, p.status, p.ms, p.txnId || p.eventId]
|
||||||
|
.forEach((v) => {
|
||||||
|
const td = document.createElement('td');
|
||||||
|
td.textContent = text(v);
|
||||||
|
tr.appendChild(td);
|
||||||
|
});
|
||||||
|
tr.addEventListener('click', () => {
|
||||||
|
document.querySelectorAll('tr.sel').forEach((r) => r.classList.remove('sel'));
|
||||||
|
tr.classList.add('sel');
|
||||||
|
detail.textContent = JSON.stringify(p, null, 2);
|
||||||
|
});
|
||||||
|
rows.appendChild(tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
function render() {
|
||||||
|
rows.textContent = '';
|
||||||
|
packets.filter(matches).forEach(addRow);
|
||||||
|
count.textContent = packets.length;
|
||||||
|
if (autoscroll.checked) list.scrollTop = list.scrollHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
function add(p) {
|
||||||
|
packets.push(p);
|
||||||
|
if (packets.length > MAX) packets.shift();
|
||||||
|
count.textContent = packets.length;
|
||||||
|
if (!matches(p)) return;
|
||||||
|
addRow(p);
|
||||||
|
if (autoscroll.checked) list.scrollTop = list.scrollHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
filter.addEventListener('input', render);
|
||||||
|
document.getElementById('clear').addEventListener('click', () => {
|
||||||
|
packets.length = 0;
|
||||||
|
detail.textContent = '';
|
||||||
|
render();
|
||||||
|
});
|
||||||
|
const lines = () => packets.map((p) => JSON.stringify(p)).join('\n');
|
||||||
|
|
||||||
|
document.getElementById('copy').addEventListener('click', () => {
|
||||||
|
window.electron?.clipboard?.writeText(lines());
|
||||||
|
});
|
||||||
|
document.getElementById('download').addEventListener('click', () => {
|
||||||
|
window.electron?.media?.saveFile({
|
||||||
|
filename: 'packets.jsonl',
|
||||||
|
mimeType: 'application/x-jsonlines',
|
||||||
|
data: lines(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Main sends the backlog as one batch (array), later packets one at a time
|
||||||
|
const unsubscribe = window.electron?.debug?.onPacket((data) => {
|
||||||
|
(Array.isArray(data) ? data : [data]).forEach(add);
|
||||||
|
});
|
||||||
|
window.addEventListener('beforeunload', () => unsubscribe?.());
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,381 @@
|
|||||||
|
/**
|
||||||
|
* Discord shop collectibles: fetch a published catalog and download selected assets from Discord CDN.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const ITEM_TYPE_FOLDER = {
|
||||||
|
0: 'avatar-decorations',
|
||||||
|
1: 'profile-effects',
|
||||||
|
2: 'nameplates',
|
||||||
|
};
|
||||||
|
|
||||||
|
const ITEM_TYPE_KEY = {
|
||||||
|
0: 'avatar_decoration',
|
||||||
|
1: 'profile_effect',
|
||||||
|
2: 'nameplate',
|
||||||
|
};
|
||||||
|
|
||||||
|
const CDN_BASE = 'https://cdn.discordapp.com';
|
||||||
|
const CDN_HOST_RE = /(^|\.)(discordapp\.com|discordapp\.net|discord\.com)$/i;
|
||||||
|
const DEFAULT_USER_AGENT =
|
||||||
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0 Chrome/120 Electron/28 Safari/537.36';
|
||||||
|
const PUBLISHED_CATALOG_URLS = [
|
||||||
|
'https://github.com/litruv/discord-collectibles/releases/download/latest/profileeffects.json',
|
||||||
|
'https://github.com/litruv/discord-collectibles/releases/download/latest/nameplate.json',
|
||||||
|
'https://github.com/litruv/discord-collectibles/releases/download/latest/avatardecorations.json',
|
||||||
|
];
|
||||||
|
|
||||||
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||||
|
|
||||||
|
function isCdnUrl(value) {
|
||||||
|
if (typeof value !== 'string' || !value.startsWith('http')) return false;
|
||||||
|
try {
|
||||||
|
return CDN_HOST_RE.test(new URL(value).hostname);
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function basenameFromUrl(url) {
|
||||||
|
try {
|
||||||
|
const { pathname } = new URL(url);
|
||||||
|
const last = decodeURIComponent(pathname.split('/').filter(Boolean).pop() || '');
|
||||||
|
return last || 'asset';
|
||||||
|
} catch {
|
||||||
|
return 'asset';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function guessMimeType(filename) {
|
||||||
|
const lower = String(filename).toLowerCase();
|
||||||
|
if (lower.endsWith('.png')) return 'image/png';
|
||||||
|
if (lower.endsWith('.webp')) return 'image/webp';
|
||||||
|
if (lower.endsWith('.webm')) return 'video/webm';
|
||||||
|
if (lower.endsWith('.gif')) return 'image/gif';
|
||||||
|
if (lower.endsWith('.jpg') || lower.endsWith('.jpeg')) return 'image/jpeg';
|
||||||
|
return 'application/octet-stream';
|
||||||
|
}
|
||||||
|
|
||||||
|
function deepCollectUrls(node, acc = new Set()) {
|
||||||
|
if (node == null) return acc;
|
||||||
|
if (typeof node === 'string') {
|
||||||
|
if (isCdnUrl(node)) acc.add(node);
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
if (Array.isArray(node)) {
|
||||||
|
for (const v of node) deepCollectUrls(v, acc);
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
if (typeof node === 'object') {
|
||||||
|
for (const v of Object.values(node)) deepCollectUrls(v, acc);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
function urlsForItem(item) {
|
||||||
|
const out = [];
|
||||||
|
const seen = new Set();
|
||||||
|
|
||||||
|
function push(url, filename, role) {
|
||||||
|
if (!url || seen.has(url)) return;
|
||||||
|
seen.add(url);
|
||||||
|
out.push({ url, filename, role: role || filename });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const url of deepCollectUrls(item)) {
|
||||||
|
let role = basenameFromUrl(url);
|
||||||
|
if (item.thumbnailPreviewSrc === url) role = 'thumbnail';
|
||||||
|
else if (item.reducedMotionSrc === url) role = 'reduced_motion';
|
||||||
|
else if (Array.isArray(item.effects)) {
|
||||||
|
const effectIndex = item.effects.findIndex((effect) => effect?.src === url);
|
||||||
|
if (effectIndex >= 0) role = `effect_${effectIndex}`;
|
||||||
|
}
|
||||||
|
push(url, basenameFromUrl(url), role);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.type === 0 && item.asset) {
|
||||||
|
const base = `${CDN_BASE}/avatar-decoration-presets/${item.asset}.png`;
|
||||||
|
push(`${base}?passthrough=true`, 'animated.png', 'animated');
|
||||||
|
push(`${base}?passthrough=false`, 'static.png', 'static');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.type === 2 && item.asset) {
|
||||||
|
const assetPath = String(item.asset).replace(/^\/+/, '');
|
||||||
|
push(`${CDN_BASE}/assets/collectibles/${assetPath}static.png`, 'static.png', 'static');
|
||||||
|
push(`${CDN_BASE}/assets/collectibles/${assetPath}asset.webm`, 'asset.webm', 'animated');
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function decimalRgbToCss(color) {
|
||||||
|
const value = Number(color) >>> 0;
|
||||||
|
const r = (value >> 16) & 0xff;
|
||||||
|
const g = (value >> 8) & 0xff;
|
||||||
|
const b = value & 0xff;
|
||||||
|
return `rgb(${r}, ${g}, ${b})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function gradientFromColors(colors) {
|
||||||
|
if (!Array.isArray(colors) || colors.length === 0) return undefined;
|
||||||
|
if (colors.length === 1) return decimalRgbToCss(colors[0]);
|
||||||
|
return `linear-gradient(135deg, ${decimalRgbToCss(colors[0])}, ${decimalRgbToCss(colors[1])})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function previewAspectRatioForItem(item) {
|
||||||
|
if (item.type === 0) return 1;
|
||||||
|
if (item.type === 2) return 448 / 84;
|
||||||
|
const firstEffect = item.effects?.[0];
|
||||||
|
if (firstEffect?.width && firstEffect?.height) {
|
||||||
|
return firstEffect.width / firstEffect.height;
|
||||||
|
}
|
||||||
|
return 450 / 880;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatPaletteName(palette) {
|
||||||
|
if (!palette) return undefined;
|
||||||
|
return String(palette)
|
||||||
|
.split('_')
|
||||||
|
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
||||||
|
.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
const NAMEPLATE_PALETTE_GRADIENTS = {
|
||||||
|
crimson: 'linear-gradient(135deg, #5c0a1c, #dc143c)',
|
||||||
|
berry: 'linear-gradient(135deg, #4a1030, #c42d78)',
|
||||||
|
sky: 'linear-gradient(135deg, #0a2a5c, #3b8eed)',
|
||||||
|
teal: 'linear-gradient(135deg, #0a3d3d, #2dd4bf)',
|
||||||
|
forest: 'linear-gradient(135deg, #0a2e1a, #22c55e)',
|
||||||
|
bubble_gum: 'linear-gradient(135deg, #4a1038, #f472b6)',
|
||||||
|
violet: 'linear-gradient(135deg, #2d1050, #8b5cf6)',
|
||||||
|
cobalt: 'linear-gradient(135deg, #0a1448, #3b5bdb)',
|
||||||
|
clover: 'linear-gradient(135deg, #0a3d20, #4ade80)',
|
||||||
|
lemon: 'linear-gradient(135deg, #4a3d0a, #fbbf24)',
|
||||||
|
white: 'linear-gradient(135deg, #888888, #f0f0f0)',
|
||||||
|
black: 'linear-gradient(135deg, #1a1a1a, #404040)',
|
||||||
|
};
|
||||||
|
|
||||||
|
function nameplatePaletteGradient(palette) {
|
||||||
|
if (!palette) return undefined;
|
||||||
|
return NAMEPLATE_PALETTE_GRADIENTS[palette];
|
||||||
|
}
|
||||||
|
|
||||||
|
function thumbnailForItem(item) {
|
||||||
|
if (item.thumbnailPreviewSrc && isCdnUrl(item.thumbnailPreviewSrc)) {
|
||||||
|
return item.thumbnailPreviewSrc;
|
||||||
|
}
|
||||||
|
if (item.type === 0 && item.asset) {
|
||||||
|
return `${CDN_BASE}/avatar-decoration-presets/${item.asset}.png?passthrough=false`;
|
||||||
|
}
|
||||||
|
if (item.type === 2 && item.asset) {
|
||||||
|
const assetPath = String(item.asset).replace(/^\/+/, '');
|
||||||
|
return `${CDN_BASE}/assets/collectibles/${assetPath}static.png`;
|
||||||
|
}
|
||||||
|
const assets = urlsForItem(item);
|
||||||
|
return assets[0]?.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
function* walkProduct(product, category) {
|
||||||
|
yield { product, category };
|
||||||
|
for (const bundled of product.bundled_products ?? []) {
|
||||||
|
yield* walkProduct(bundled, category);
|
||||||
|
}
|
||||||
|
for (const variant of product.variants ?? []) {
|
||||||
|
yield* walkProduct(variant, category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function* walkProducts(categories) {
|
||||||
|
for (const category of categories ?? []) {
|
||||||
|
for (const product of category.products ?? []) {
|
||||||
|
yield* walkProduct(product, category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractCollectibleItems(categories) {
|
||||||
|
const items = [];
|
||||||
|
const seenItems = new Set();
|
||||||
|
|
||||||
|
for (const { product, category } of walkProducts(categories)) {
|
||||||
|
const categoryName = category?.name || 'Unknown';
|
||||||
|
for (const item of product.items ?? []) {
|
||||||
|
if (![0, 1, 2].includes(item.type)) continue;
|
||||||
|
|
||||||
|
const skuId = String(item.sku_id ?? item.id ?? product.sku_id ?? 'unknown');
|
||||||
|
const itemKey = `${item.type}:${skuId}:${item.id ?? ''}`;
|
||||||
|
if (seenItems.has(itemKey)) continue;
|
||||||
|
seenItems.add(itemKey);
|
||||||
|
|
||||||
|
const assets = urlsForItem(item);
|
||||||
|
if (assets.length === 0) continue;
|
||||||
|
|
||||||
|
const productName = product.name || item.title || item.label || skuId;
|
||||||
|
const typeKey = ITEM_TYPE_KEY[item.type];
|
||||||
|
|
||||||
|
const entry = {
|
||||||
|
id: `${typeKey}:${skuId}`,
|
||||||
|
skuId,
|
||||||
|
name: productName,
|
||||||
|
type: typeKey,
|
||||||
|
category: categoryName,
|
||||||
|
label: item.label ?? item.title ?? productName,
|
||||||
|
thumbnailUrl: thumbnailForItem(item),
|
||||||
|
previewAspectRatio: previewAspectRatioForItem(item),
|
||||||
|
previewColors: product.styles?.background_colors,
|
||||||
|
palette: item.type === 2 ? item.palette : undefined,
|
||||||
|
paletteLabel: item.type === 2 ? formatPaletteName(item.palette) : undefined,
|
||||||
|
previewGradient: item.type === 2 ? nameplatePaletteGradient(item.palette) : undefined,
|
||||||
|
assets: assets.map((a) => ({
|
||||||
|
role: a.role,
|
||||||
|
url: a.url,
|
||||||
|
filename: a.filename,
|
||||||
|
mimeType: guessMimeType(a.filename),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (item.type === 1) {
|
||||||
|
entry.effect = {
|
||||||
|
animationType: item.animationType,
|
||||||
|
thumbnailPreviewSrc: item.thumbnailPreviewSrc,
|
||||||
|
reducedMotionSrc: item.reducedMotionSrc,
|
||||||
|
effects: item.effects,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
items.push(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPublishedCatalog(document) {
|
||||||
|
return (
|
||||||
|
document &&
|
||||||
|
document.schema_version === 1 &&
|
||||||
|
typeof document.type === 'string' &&
|
||||||
|
Array.isArray(document.items) &&
|
||||||
|
document.items.every(
|
||||||
|
(item) =>
|
||||||
|
item &&
|
||||||
|
typeof item.id === 'string' &&
|
||||||
|
typeof item.skuId === 'string' &&
|
||||||
|
typeof item.type === 'string' &&
|
||||||
|
Array.isArray(item.assets)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchPublishedCatalog() {
|
||||||
|
const documents = await Promise.all(
|
||||||
|
PUBLISHED_CATALOG_URLS.map(async (url) => {
|
||||||
|
const response = await fetch(url, { headers: { Accept: 'application/json' } });
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Published collectibles catalog request failed with HTTP ${response.status}.`);
|
||||||
|
}
|
||||||
|
const document = await response.json();
|
||||||
|
if (!isPublishedCatalog(document)) {
|
||||||
|
throw new Error('Published collectibles catalog has an unsupported schema.');
|
||||||
|
}
|
||||||
|
return document;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const items = documents.flatMap((document) => document.items);
|
||||||
|
if (items.length === 0) {
|
||||||
|
throw new Error('Published collectibles catalog is empty.');
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadAsset(url, { retries = 4 } = {}) {
|
||||||
|
for (let attempt = 0; ; attempt++) {
|
||||||
|
let res;
|
||||||
|
try {
|
||||||
|
res = await fetch(url, {
|
||||||
|
headers: { 'User-Agent': DEFAULT_USER_AGENT, Accept: '*/*' },
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
if (attempt >= retries) throw err;
|
||||||
|
await sleep(500 * 2 ** attempt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.status === 429) {
|
||||||
|
const retryAfter = Number(res.headers.get('retry-after')) || 1;
|
||||||
|
await sleep((retryAfter + 0.5) * 1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
if (attempt >= retries) {
|
||||||
|
throw new Error(`Failed to download asset: ${res.status} ${res.statusText}`);
|
||||||
|
}
|
||||||
|
await sleep(500 * 2 ** attempt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const buf = Buffer.from(await res.arrayBuffer());
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDiscordCollectiblesService(store) {
|
||||||
|
let catalogCache = store.get('discordCollectiblesCatalog') || null;
|
||||||
|
if (
|
||||||
|
!catalogCache ||
|
||||||
|
!Array.isArray(catalogCache.items) ||
|
||||||
|
typeof catalogCache.fetchedAt !== 'string'
|
||||||
|
) {
|
||||||
|
catalogCache = null;
|
||||||
|
}
|
||||||
|
let catalogCacheAt = catalogCache?.fetchedAt ? Date.parse(catalogCache.fetchedAt) : 0;
|
||||||
|
const CATALOG_TTL_MS = 6 * 60 * 60 * 1000;
|
||||||
|
store.delete('discordCollectiblesToken');
|
||||||
|
|
||||||
|
async function getCatalog({ force = false } = {}) {
|
||||||
|
const now = Date.now();
|
||||||
|
if (!force && catalogCache && now - catalogCacheAt < CATALOG_TTL_MS) {
|
||||||
|
return { success: true, data: catalogCache };
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const items = await fetchPublishedCatalog();
|
||||||
|
catalogCache = { items, fetchedAt: new Date().toISOString() };
|
||||||
|
catalogCacheAt = now;
|
||||||
|
store.set('discordCollectiblesCatalog', catalogCache);
|
||||||
|
return { success: true, data: catalogCache };
|
||||||
|
} catch (err) {
|
||||||
|
if (catalogCache) {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: { ...catalogCache, stale: true },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadAssets(assetUrls) {
|
||||||
|
const results = [];
|
||||||
|
for (const asset of assetUrls) {
|
||||||
|
const buffer = await downloadAsset(asset.url);
|
||||||
|
results.push({
|
||||||
|
role: asset.role,
|
||||||
|
url: asset.url,
|
||||||
|
filename: asset.filename,
|
||||||
|
mimeType: asset.mimeType || guessMimeType(asset.filename),
|
||||||
|
data: buffer,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
getCatalog,
|
||||||
|
downloadAssets,
|
||||||
|
ITEM_TYPE_FOLDER,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { createDiscordCollectiblesService, extractCollectibleItems, urlsForItem };
|
||||||
+487
-36
@@ -1,4 +1,4 @@
|
|||||||
const { app, BrowserWindow, ipcMain, shell, Tray, Menu, nativeImage, clipboard, session, desktopCapturer } = require('electron');
|
const { app, BrowserWindow, ipcMain, shell, Tray, Menu, nativeImage, clipboard, session, desktopCapturer, dialog } = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { exec, execFile, execFileSync } = require('child_process');
|
const { exec, execFile, execFileSync } = require('child_process');
|
||||||
@@ -8,6 +8,7 @@ const openPkg = require('open');
|
|||||||
const open = openPkg.default;
|
const open = openPkg.default;
|
||||||
const openApps = openPkg.apps;
|
const openApps = openPkg.apps;
|
||||||
const PaarrotAPIServer = require('./api-server');
|
const PaarrotAPIServer = require('./api-server');
|
||||||
|
const { createDiscordCollectiblesService } = require('./discord-collectibles');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const AdmZip = require('adm-zip');
|
const AdmZip = require('adm-zip');
|
||||||
@@ -104,6 +105,7 @@ function isAppOwnedUrl(targetUrl, currentUrl) {
|
|||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
const store = new Store();
|
const store = new Store();
|
||||||
|
const discordCollectibles = createDiscordCollectiblesService(store);
|
||||||
const PROTOCOL_SCHEME = 'paarrot';
|
const PROTOCOL_SCHEME = 'paarrot';
|
||||||
|
|
||||||
let mainWindow = null;
|
let mainWindow = null;
|
||||||
@@ -111,6 +113,9 @@ let tray = null;
|
|||||||
let isQuitting = false;
|
let isQuitting = false;
|
||||||
let apiServer = null;
|
let apiServer = null;
|
||||||
let pendingDeepLink = null;
|
let pendingDeepLink = null;
|
||||||
|
let debugWindow = null;
|
||||||
|
const debugPacketBacklog = [];
|
||||||
|
const DEBUG_PACKET_LIMIT = 2000;
|
||||||
let protocolRegistrationState = {
|
let protocolRegistrationState = {
|
||||||
before: false,
|
before: false,
|
||||||
registerCall: false,
|
registerCall: false,
|
||||||
@@ -247,6 +252,10 @@ function extractDeepLinkFromArgv(argv) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a paarrot:// deep link into an in-app hash route.
|
* Converts a paarrot:// deep link into an in-app hash route.
|
||||||
|
* Supports:
|
||||||
|
* - Hash routes: paarrot://anything/#/login/server/
|
||||||
|
* - Path routes (SSO-safe): paarrot://desktop/login/server/?loginToken=...
|
||||||
|
* Preserves SSO loginToken from the URL query (Synapse inserts it before `#`).
|
||||||
* @param {string} deepLink - The incoming protocol URL.
|
* @param {string} deepLink - The incoming protocol URL.
|
||||||
* @returns {string|null} Hash route value without leading #.
|
* @returns {string|null} Hash route value without leading #.
|
||||||
*/
|
*/
|
||||||
@@ -259,17 +268,63 @@ function deepLinkToHashRoute(deepLink) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hashRoute = null;
|
||||||
|
let loginToken = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const parsed = new URL(deepLink);
|
||||||
|
loginToken = parsed.searchParams.get('loginToken');
|
||||||
|
|
||||||
|
if (parsed.hash && parsed.hash.length > 1) {
|
||||||
|
const hashValue = parsed.hash.slice(1);
|
||||||
|
hashRoute = hashValue.startsWith('/') ? hashValue : `/${hashValue}`;
|
||||||
|
} else if (parsed.pathname && parsed.pathname !== '/') {
|
||||||
|
// paarrot://desktop/login/... → /login/...
|
||||||
|
hashRoute = parsed.pathname;
|
||||||
|
if (parsed.search && parsed.search.length > 1) {
|
||||||
|
// Keep non-loginToken query on the route; loginToken merged below
|
||||||
|
const params = new URLSearchParams(parsed.search);
|
||||||
|
params.delete('loginToken');
|
||||||
|
const rest = params.toString();
|
||||||
|
if (rest) {
|
||||||
|
hashRoute += `?${rest}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
const hashIndex = deepLink.indexOf('#');
|
const hashIndex = deepLink.indexOf('#');
|
||||||
if (hashIndex === -1) {
|
if (hashIndex !== -1) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hashValue = deepLink.slice(hashIndex + 1);
|
const hashValue = deepLink.slice(hashIndex + 1);
|
||||||
if (!hashValue) {
|
if (hashValue) {
|
||||||
return null;
|
hashRoute = hashValue.startsWith('/') ? hashValue : `/${hashValue}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hashValue.startsWith('/') ? hashValue : `/${hashValue}`;
|
const match = deepLink.match(/[?&]loginToken=([^&#]+)/i);
|
||||||
|
if (match) {
|
||||||
|
try {
|
||||||
|
loginToken = decodeURIComponent(match[1]);
|
||||||
|
} catch {
|
||||||
|
loginToken = match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loginToken) {
|
||||||
|
if (!hashRoute) {
|
||||||
|
hashRoute = '/';
|
||||||
|
}
|
||||||
|
const queryIndex = hashRoute.indexOf('?');
|
||||||
|
const pathPart = queryIndex === -1 ? hashRoute : hashRoute.slice(0, queryIndex);
|
||||||
|
const params = new URLSearchParams(queryIndex === -1 ? '' : hashRoute.slice(queryIndex + 1));
|
||||||
|
if (!params.has('loginToken')) {
|
||||||
|
params.set('loginToken', loginToken);
|
||||||
|
}
|
||||||
|
const query = params.toString();
|
||||||
|
hashRoute = query ? `${pathPart}?${query}` : pathPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -389,6 +444,129 @@ function syncProtocolRegistrationState() {
|
|||||||
console.log(`[Protocol] ${PROTOCOL_SCHEME}:// before=${protocolRegistrationState.before} registerCall=${protocolRegistrationState.registerCall} after=${protocolRegistrationState.after}${protocolRegistrationState.error ? ` error=${protocolRegistrationState.error}` : ''}`);
|
console.log(`[Protocol] ${PROTOCOL_SCHEME}:// before=${protocolRegistrationState.before} registerCall=${protocolRegistrationState.registerCall} after=${protocolRegistrationState.after}${protocolRegistrationState.error ? ` error=${protocolRegistrationState.error}` : ''}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh Linux xdg-mime association for paarrot:// to the current app desktop file.
|
||||||
|
* AppImage upgrades often leave a stale desktop id in mimeapps.list.
|
||||||
|
*/
|
||||||
|
async function ensureLinuxProtocolHandler() {
|
||||||
|
const home = app.getPath('home');
|
||||||
|
const searchDirs = [
|
||||||
|
path.join(home, '.local', 'share', 'applications'),
|
||||||
|
'/usr/share/applications',
|
||||||
|
'/var/lib/flatpak/exports/share/applications',
|
||||||
|
];
|
||||||
|
|
||||||
|
let desktopId = null;
|
||||||
|
for (const dir of searchDirs) {
|
||||||
|
try {
|
||||||
|
if (!fs.existsSync(dir)) continue;
|
||||||
|
const entries = fs.readdirSync(dir);
|
||||||
|
// Prefer the newest AppImageLauncher desktop entry when several exist.
|
||||||
|
const matches = entries
|
||||||
|
.filter((name) => /paarrot/i.test(name) && name.endsWith('.desktop'))
|
||||||
|
.map((name) => {
|
||||||
|
try {
|
||||||
|
return { name, mtime: fs.statSync(path.join(dir, name)).mtimeMs };
|
||||||
|
} catch {
|
||||||
|
return { name, mtime: 0 };
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.sort((a, b) => b.mtime - a.mtime);
|
||||||
|
if (matches.length > 0) {
|
||||||
|
desktopId = matches[0].name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// keep looking
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!desktopId) {
|
||||||
|
desktopId = 'paarrot.desktop';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite mimeapps.list so stale AppImage ids cannot win over xdg-mime default.
|
||||||
|
try {
|
||||||
|
const mimeappsPath = path.join(home, '.config', 'mimeapps.list');
|
||||||
|
let content = '';
|
||||||
|
try {
|
||||||
|
content = fs.readFileSync(mimeappsPath, 'utf8');
|
||||||
|
} catch {
|
||||||
|
content = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const schemeLine = `x-scheme-handler/${PROTOCOL_SCHEME}=${desktopId}`;
|
||||||
|
const lines = content ? content.split(/\r?\n/) : [];
|
||||||
|
let section = null;
|
||||||
|
const next = [];
|
||||||
|
let wroteDefault = false;
|
||||||
|
let wroteAdded = false;
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (trimmed === '[Default Applications]' || trimmed === '[Added Associations]') {
|
||||||
|
section = trimmed;
|
||||||
|
next.push(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trimmed.startsWith('x-scheme-handler/paarrot=')) {
|
||||||
|
if (section === '[Default Applications]') {
|
||||||
|
next.push(schemeLine);
|
||||||
|
wroteDefault = true;
|
||||||
|
} else if (section === '[Added Associations]') {
|
||||||
|
next.push(`${schemeLine};`);
|
||||||
|
wroteAdded = true;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
next.push(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!next.some((l) => l.trim() === '[Default Applications]')) {
|
||||||
|
next.push('', '[Default Applications]');
|
||||||
|
}
|
||||||
|
if (!wroteDefault) {
|
||||||
|
const idx = next.findIndex((l) => l.trim() === '[Default Applications]');
|
||||||
|
next.splice(idx + 1, 0, schemeLine);
|
||||||
|
}
|
||||||
|
if (!next.some((l) => l.trim() === '[Added Associations]')) {
|
||||||
|
next.unshift('[Added Associations]');
|
||||||
|
}
|
||||||
|
if (!wroteAdded) {
|
||||||
|
const idx = next.findIndex((l) => l.trim() === '[Added Associations]');
|
||||||
|
next.splice(idx + 1, 0, `${schemeLine};`);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.mkdirSync(path.dirname(mimeappsPath), { recursive: true });
|
||||||
|
fs.writeFileSync(mimeappsPath, `${next.join('\n').replace(/\n{3,}/g, '\n\n').trim()}\n`);
|
||||||
|
console.log(`[Protocol] mimeapps.list → ${desktopId} for x-scheme-handler/${PROTOCOL_SCHEME}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('[Protocol] Failed to rewrite mimeapps.list:', error);
|
||||||
|
}
|
||||||
|
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
execFile(
|
||||||
|
'xdg-mime',
|
||||||
|
['default', desktopId, `x-scheme-handler/${PROTOCOL_SCHEME}`],
|
||||||
|
{ timeout: 5000 },
|
||||||
|
(error, _stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.warn(`[Protocol] xdg-mime default failed (${desktopId}):`, error.message, stderr);
|
||||||
|
} else {
|
||||||
|
console.log(`[Protocol] xdg-mime default → ${desktopId} for x-scheme-handler/${PROTOCOL_SCHEME}`);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
execFile('update-desktop-database', [path.join(home, '.local', 'share', 'applications')], { timeout: 5000 }, () => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a named Windows registry value.
|
* Reads a named Windows registry value.
|
||||||
* @param {string} keyPath - Registry key path.
|
* @param {string} keyPath - Registry key path.
|
||||||
@@ -920,6 +1098,12 @@ app.whenReady().then(() => {
|
|||||||
|
|
||||||
syncProtocolRegistrationState();
|
syncProtocolRegistrationState();
|
||||||
|
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
ensureLinuxProtocolHandler().catch((error) => {
|
||||||
|
console.warn('[Protocol] Startup Linux protocol ensure failed:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
createWindow();
|
createWindow();
|
||||||
createTray();
|
createTray();
|
||||||
|
|
||||||
@@ -933,18 +1117,27 @@ app.whenReady().then(() => {
|
|||||||
console.error('Failed to start API server:', err);
|
console.error('Failed to start API server:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check for updates on startup (not in development mode)
|
// Check for updates on startup
|
||||||
if (!isDev) {
|
|
||||||
// Check for updates on start (after 3 seconds)
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
autoUpdater.checkForUpdates().catch(err => {
|
if (isDev) {
|
||||||
|
// Exercise the title-bar updater UI with a mock update.
|
||||||
|
sendUpdaterEvent('update-available', {
|
||||||
|
version: '99.0.0-dev',
|
||||||
|
releaseNotes: 'Mock update for development — download to preview the title-bar progress UI.',
|
||||||
|
releaseDate: new Date().toISOString(),
|
||||||
|
mock: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
autoUpdater.checkForUpdates().catch((err) => {
|
||||||
console.error('Failed to check for updates:', err);
|
console.error('Failed to check for updates:', err);
|
||||||
});
|
});
|
||||||
}, 3000);
|
}, 2500);
|
||||||
|
|
||||||
|
if (!isDev) {
|
||||||
// Check for updates every 6 hours
|
// Check for updates every 6 hours
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
autoUpdater.checkForUpdates().catch(err => {
|
autoUpdater.checkForUpdates().catch((err) => {
|
||||||
console.error('Failed to check for updates:', err);
|
console.error('Failed to check for updates:', err);
|
||||||
});
|
});
|
||||||
}, 6 * 60 * 60 * 1000);
|
}, 6 * 60 * 60 * 1000);
|
||||||
@@ -1053,6 +1246,14 @@ ipcMain.handle('protocol:repair', async () => {
|
|||||||
|
|
||||||
syncProtocolRegistrationState();
|
syncProtocolRegistrationState();
|
||||||
|
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
try {
|
||||||
|
await ensureLinuxProtocolHandler();
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('[Protocol] Failed to refresh Linux protocol handler:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const status = await getProtocolStatusPayload();
|
const status = await getProtocolStatusPayload();
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@@ -1079,14 +1280,104 @@ ipcMain.handle('open-external-url', async (event, url) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save a media blob from the renderer via a native Save dialog.
|
||||||
|
* Payload: { filename, mimeType?, data: Uint8Array | ArrayBuffer | number[] }
|
||||||
|
*/
|
||||||
|
ipcMain.handle('media:save-file', async (event, payload = {}) => {
|
||||||
|
try {
|
||||||
|
const filename = typeof payload.filename === 'string' && payload.filename.trim()
|
||||||
|
? path.basename(payload.filename.trim()) || 'download'
|
||||||
|
: 'download';
|
||||||
|
const mimeType = typeof payload.mimeType === 'string' ? payload.mimeType : '';
|
||||||
|
const raw = payload.data;
|
||||||
|
if (!raw) {
|
||||||
|
return { success: false, error: 'Missing file data' };
|
||||||
|
}
|
||||||
|
|
||||||
|
const buffer = Buffer.from(
|
||||||
|
raw instanceof ArrayBuffer
|
||||||
|
? new Uint8Array(raw)
|
||||||
|
: ArrayBuffer.isView(raw)
|
||||||
|
? new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength)
|
||||||
|
: raw
|
||||||
|
);
|
||||||
|
|
||||||
|
const ext = path.extname(filename).replace(/^\./, '').toLowerCase();
|
||||||
|
const filters = (() => {
|
||||||
|
if (mimeType.startsWith('image/') || ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext)) {
|
||||||
|
return [
|
||||||
|
{ name: 'Images', extensions: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'] },
|
||||||
|
{ name: 'All Files', extensions: ['*'] },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if (mimeType.startsWith('video/') || ['mp4', 'webm', 'mkv', 'mov'].includes(ext)) {
|
||||||
|
return [
|
||||||
|
{ name: 'Videos', extensions: ['mp4', 'webm', 'mkv', 'mov'] },
|
||||||
|
{ name: 'All Files', extensions: ['*'] },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if (mimeType.startsWith('audio/') || ['mp3', 'ogg', 'wav', 'm4a', 'flac'].includes(ext)) {
|
||||||
|
return [
|
||||||
|
{ name: 'Audio', extensions: ['mp3', 'ogg', 'wav', 'm4a', 'flac'] },
|
||||||
|
{ name: 'All Files', extensions: ['*'] },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if (mimeType === 'application/pdf' || ext === 'pdf') {
|
||||||
|
return [
|
||||||
|
{ name: 'PDF', extensions: ['pdf'] },
|
||||||
|
{ name: 'All Files', extensions: ['*'] },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if (ext) {
|
||||||
|
return [
|
||||||
|
{ name: ext.toUpperCase(), extensions: [ext] },
|
||||||
|
{ name: 'All Files', extensions: ['*'] },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [{ name: 'All Files', extensions: ['*'] }];
|
||||||
|
})();
|
||||||
|
|
||||||
|
const win = BrowserWindow.fromWebContents(event.sender) || mainWindow;
|
||||||
|
const result = await dialog.showSaveDialog(win || undefined, {
|
||||||
|
title: 'Save file',
|
||||||
|
defaultPath: filename,
|
||||||
|
filters,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.canceled || !result.filePath) {
|
||||||
|
return { success: true, canceled: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.promises.writeFile(result.filePath, buffer);
|
||||||
|
return { success: true, path: result.filePath };
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[media:save-file] failed:', error);
|
||||||
|
return { success: false, error: error.message || String(error) };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Read clipboard image
|
// Read clipboard image
|
||||||
ipcMain.handle('read-clipboard-image', async () => {
|
ipcMain.handle('read-clipboard-image', async () => {
|
||||||
try {
|
try {
|
||||||
|
// Extra Things: only trust an image when the clipboard actually advertises one.
|
||||||
|
// On Linux, readImage() can return a stale bitmap after copying plain text/URLs.
|
||||||
|
const formats = clipboard.availableFormats();
|
||||||
|
const hasImageFormat = formats.some((format) => format.startsWith('image/'));
|
||||||
|
if (!hasImageFormat) {
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
const image = clipboard.readImage();
|
const image = clipboard.readImage();
|
||||||
if (image.isEmpty()) {
|
if (image.isEmpty()) {
|
||||||
return { success: true, data: null };
|
return { success: true, data: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { width, height } = image.getSize();
|
||||||
|
if (width < 2 || height < 2) {
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to PNG base64
|
// Convert to PNG base64
|
||||||
const pngBuffer = image.toPNG();
|
const pngBuffer = image.toPNG();
|
||||||
const base64 = pngBuffer.toString('base64');
|
const base64 = pngBuffer.toString('base64');
|
||||||
@@ -1137,33 +1428,33 @@ ipcMain.handle('play-notification-sound', async (event, soundType = 'message') =
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get YouTube stream using yt-dlp
|
// Get a direct YouTube stream using yt-dlp.
|
||||||
ipcMain.handle('get-youtube-stream', async (event, url) => {
|
async function getYouTubeStream(url) {
|
||||||
try {
|
try {
|
||||||
// Check if yt-dlp is available
|
|
||||||
try {
|
try {
|
||||||
await execAsync('yt-dlp --version');
|
await execFileAsync('yt-dlp', ['--version']);
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: 'yt-dlp is not installed. Please install yt-dlp to use YouTube features.'
|
error: 'yt-dlp is not installed. Please install yt-dlp to use YouTube features.',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get title
|
|
||||||
let title = 'YouTube Video';
|
let title = 'YouTube Video';
|
||||||
try {
|
try {
|
||||||
const titleResult = await execAsync(`yt-dlp --get-title "${url}"`);
|
const titleResult = await execFileAsync('yt-dlp', ['--no-playlist', '--get-title', url]);
|
||||||
title = titleResult.stdout.trim();
|
title = titleResult.stdout.trim();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Failed to get video title:', e.message);
|
console.warn('Failed to get video title:', e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get video URL
|
const result = await execFileAsync('yt-dlp', [
|
||||||
const result = await execAsync(
|
'--no-playlist',
|
||||||
`yt-dlp -g -f "best[height<=1080]/bestvideo[height<=1080]+bestaudio/best" "${url}"`
|
'-g',
|
||||||
);
|
'-f',
|
||||||
|
'best[height<=1080]/bestvideo[height<=1080]+bestaudio/best',
|
||||||
|
url,
|
||||||
|
]);
|
||||||
const videoUrl = result.stdout.trim().split('\n')[0];
|
const videoUrl = result.stdout.trim().split('\n')[0];
|
||||||
|
|
||||||
if (!videoUrl) {
|
if (!videoUrl) {
|
||||||
@@ -1172,14 +1463,41 @@ ipcMain.handle('get-youtube-stream', async (event, url) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: { video_url: videoUrl, title }
|
data: { video_url: videoUrl, title },
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: `yt-dlp error: ${error.message}`
|
error: `yt-dlp error: ${error.message}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get YouTube stream using yt-dlp
|
||||||
|
ipcMain.handle('get-youtube-stream', async (event, url) => {
|
||||||
|
return getYouTubeStream(url);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TikTok oEmbed. TikTok blocks the Electron user agent, so this runs in the main
|
||||||
|
// process with a plain browser UA and is not subject to CORS.
|
||||||
|
ipcMain.handle('tiktok:oembed', async (event, url) => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`https://www.tiktok.com/oembed?url=${encodeURIComponent(url)}`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent':
|
||||||
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
||||||
|
Accept: 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
console.warn('[tiktok:oembed]', response.status, url);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return await response.json();
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('[tiktok:oembed] failed:', error?.message || error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Background sync stubs (desktop doesn't need it)
|
// Background sync stubs (desktop doesn't need it)
|
||||||
@@ -1195,10 +1513,61 @@ ipcMain.handle('get-background-sync-state', async () => {
|
|||||||
return { success: true, data: 'NotApplicable' };
|
return { success: true, data: 'NotApplicable' };
|
||||||
});
|
});
|
||||||
|
|
||||||
// Auto-updater IPC handlers
|
// Auto-updater IPC handlers (mock in development so title-bar UI can be exercised)
|
||||||
|
let mockDownloadTimer = null;
|
||||||
|
let mockDownloadPercent = 0;
|
||||||
|
|
||||||
|
function sendUpdaterEvent(channel, payload) {
|
||||||
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||||
|
mainWindow.webContents.send(channel, payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startMockDownload() {
|
||||||
|
if (mockDownloadTimer) {
|
||||||
|
clearInterval(mockDownloadTimer);
|
||||||
|
}
|
||||||
|
mockDownloadPercent = 0;
|
||||||
|
sendUpdaterEvent('update-download-progress', {
|
||||||
|
percent: 0,
|
||||||
|
transferred: 0,
|
||||||
|
total: 100,
|
||||||
|
mock: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
mockDownloadTimer = setInterval(() => {
|
||||||
|
mockDownloadPercent = Math.min(100, mockDownloadPercent + 4 + Math.random() * 6);
|
||||||
|
const percent = Math.round(mockDownloadPercent);
|
||||||
|
sendUpdaterEvent('update-download-progress', {
|
||||||
|
percent,
|
||||||
|
transferred: percent,
|
||||||
|
total: 100,
|
||||||
|
mock: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (percent >= 100) {
|
||||||
|
clearInterval(mockDownloadTimer);
|
||||||
|
mockDownloadTimer = null;
|
||||||
|
sendUpdaterEvent('update-downloaded', {
|
||||||
|
version: '99.0.0-dev',
|
||||||
|
releaseNotes: 'Mock update for development.',
|
||||||
|
mock: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 180);
|
||||||
|
}
|
||||||
|
|
||||||
ipcMain.handle('check-for-updates', async () => {
|
ipcMain.handle('check-for-updates', async () => {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return { success: false, error: 'Updates are not available in development mode' };
|
sendUpdaterEvent('update-checking', { mock: true });
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 600));
|
||||||
|
sendUpdaterEvent('update-available', {
|
||||||
|
version: '99.0.0-dev',
|
||||||
|
releaseNotes: 'Mock update for development — download to preview the title-bar progress UI.',
|
||||||
|
releaseDate: new Date().toISOString(),
|
||||||
|
mock: true,
|
||||||
|
});
|
||||||
|
return { success: true, data: { updateInfo: { version: '99.0.0-dev' }, mock: true } };
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const result = await autoUpdater.checkForUpdates();
|
const result = await autoUpdater.checkForUpdates();
|
||||||
@@ -1210,7 +1579,8 @@ ipcMain.handle('check-for-updates', async () => {
|
|||||||
|
|
||||||
ipcMain.handle('download-update', async () => {
|
ipcMain.handle('download-update', async () => {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return { success: false, error: 'Updates are not available in development mode' };
|
startMockDownload();
|
||||||
|
return { success: true, data: { mock: true } };
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await autoUpdater.downloadUpdate();
|
await autoUpdater.downloadUpdate();
|
||||||
@@ -1222,7 +1592,12 @@ ipcMain.handle('download-update', async () => {
|
|||||||
|
|
||||||
ipcMain.handle('install-update', () => {
|
ipcMain.handle('install-update', () => {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return { success: false, error: 'Updates are not available in development mode' };
|
sendUpdaterEvent('update-not-available', {
|
||||||
|
version: app.getVersion(),
|
||||||
|
mock: true,
|
||||||
|
message: 'Mock install — restart skipped in development.',
|
||||||
|
});
|
||||||
|
return { success: true, data: { mock: true } };
|
||||||
}
|
}
|
||||||
autoUpdater.quitAndInstall();
|
autoUpdater.quitAndInstall();
|
||||||
return { success: true };
|
return { success: true };
|
||||||
@@ -1230,7 +1605,8 @@ ipcMain.handle('install-update', () => {
|
|||||||
|
|
||||||
ipcMain.handle('download-and-install-update', async () => {
|
ipcMain.handle('download-and-install-update', async () => {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return { success: false, error: 'Updates are not available in development mode' };
|
startMockDownload();
|
||||||
|
return { success: true, data: { mock: true } };
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await autoUpdater.downloadUpdate();
|
await autoUpdater.downloadUpdate();
|
||||||
@@ -1241,6 +1617,8 @@ ipcMain.handle('download-and-install-update', async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('updater-is-mock', () => ({ success: true, data: { mock: isDev } }));
|
||||||
|
|
||||||
// Screen capture / desktopCapturer handler
|
// Screen capture / desktopCapturer handler
|
||||||
ipcMain.handle('get-desktop-sources', async (event, opts) => {
|
ipcMain.handle('get-desktop-sources', async (event, opts) => {
|
||||||
try {
|
try {
|
||||||
@@ -1405,7 +1783,7 @@ ipcMain.handle('plugin:download', async (event, { pluginId, downloadUrl, name })
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).on('error', (err) => {
|
}).on('error', (err) => {
|
||||||
fs.unlinkSync(tempZipPath);
|
fs.rmSync(tempZipPath, { force: true });
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1435,13 +1813,14 @@ ipcMain.handle('plugin:download', async (event, { pluginId, downloadUrl, name })
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move contents to final plugin directory
|
// Move contents to final plugin directory. renameSync throws EXDEV when
|
||||||
|
// temp and userData are on different filesystems (Linux: /tmp is tmpfs).
|
||||||
fs.mkdirSync(pluginDir, { recursive: true });
|
fs.mkdirSync(pluginDir, { recursive: true });
|
||||||
const files = fs.readdirSync(sourceDir);
|
const files = fs.readdirSync(sourceDir);
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const srcPath = path.join(sourceDir, file);
|
const srcPath = path.join(sourceDir, file);
|
||||||
const destPath = path.join(pluginDir, file);
|
const destPath = path.join(pluginDir, file);
|
||||||
fs.renameSync(srcPath, destPath);
|
fs.cpSync(srcPath, destPath, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up temp extract dir
|
// Clean up temp extract dir
|
||||||
@@ -1555,6 +1934,78 @@ ipcMain.handle('plugin:read-code', async (event, pluginId) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('discord-collectibles:fetch-catalog', async (event, { force } = {}) => {
|
||||||
|
try {
|
||||||
|
return await discordCollectibles.getCatalog({ force: Boolean(force) });
|
||||||
|
} catch (error) {
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('discord-collectibles:download-assets', async (event, { assets }) => {
|
||||||
|
try {
|
||||||
|
if (!Array.isArray(assets) || assets.length === 0) {
|
||||||
|
return { success: false, error: 'No assets to download' };
|
||||||
|
}
|
||||||
|
const downloaded = await discordCollectibles.downloadAssets(assets);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: downloaded.map((item) => ({
|
||||||
|
role: item.role,
|
||||||
|
url: item.url,
|
||||||
|
filename: item.filename,
|
||||||
|
mimeType: item.mimeType,
|
||||||
|
data: item.data,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Debug packet window
|
||||||
|
ipcMain.handle('debug:open-window', () => {
|
||||||
|
if (debugWindow && !debugWindow.isDestroyed()) {
|
||||||
|
debugWindow.focus();
|
||||||
|
return { success: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
debugWindow = new BrowserWindow({
|
||||||
|
width: 900,
|
||||||
|
height: 600,
|
||||||
|
title: 'Debug Packets',
|
||||||
|
webPreferences: {
|
||||||
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
|
contextIsolation: true,
|
||||||
|
nodeIntegration: false,
|
||||||
|
webSecurity: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
debugWindow.on('closed', () => {
|
||||||
|
debugWindow = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Send the backlog as one batch once the page has registered its listener
|
||||||
|
debugWindow.webContents.on('did-finish-load', () => {
|
||||||
|
debugWindow.webContents.send('debug:packet', debugPacketBacklog);
|
||||||
|
});
|
||||||
|
|
||||||
|
debugWindow.loadFile(path.join(__dirname, 'debug.html'));
|
||||||
|
return { success: true };
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('debug:packet', (event, packet) => {
|
||||||
|
if (!packet || typeof packet !== 'object') return;
|
||||||
|
|
||||||
|
debugPacketBacklog.push(packet);
|
||||||
|
if (debugPacketBacklog.length > DEBUG_PACKET_LIMIT) debugPacketBacklog.shift(); // Keep last 2000
|
||||||
|
|
||||||
|
if (debugWindow && !debugWindow.isDestroyed()) {
|
||||||
|
debugWindow.webContents.send('debug:packet', packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
console.log('Paarrot Electron main process started');
|
console.log('Paarrot Electron main process started');
|
||||||
console.log('Development mode:', isDev);
|
console.log('Development mode:', isDev);
|
||||||
console.log('Platform:', process.platform);
|
console.log('Platform:', process.platform);
|
||||||
|
|||||||
+33
-1
@@ -104,6 +104,12 @@ contextBridge.exposeInMainWorld('electron', {
|
|||||||
readImage: () => ipcRenderer.invoke('read-clipboard-image'),
|
readImage: () => ipcRenderer.invoke('read-clipboard-image'),
|
||||||
writeText: (text) => ipcRenderer.invoke('write-clipboard-text', text)
|
writeText: (text) => ipcRenderer.invoke('write-clipboard-text', text)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Media save (native Save dialog for images / videos / files)
|
||||||
|
media: {
|
||||||
|
saveFile: ({ filename, mimeType, data }) =>
|
||||||
|
ipcRenderer.invoke('media:save-file', { filename, mimeType, data }),
|
||||||
|
},
|
||||||
// Audio
|
// Audio
|
||||||
audio: {
|
audio: {
|
||||||
playNotificationSound: (soundType = 'message') => ipcRenderer.invoke('play-notification-sound', soundType),
|
playNotificationSound: (soundType = 'message') => ipcRenderer.invoke('play-notification-sound', soundType),
|
||||||
@@ -119,6 +125,11 @@ contextBridge.exposeInMainWorld('electron', {
|
|||||||
getStream: (url) => ipcRenderer.invoke('get-youtube-stream', url)
|
getStream: (url) => ipcRenderer.invoke('get-youtube-stream', url)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// TikTok oEmbed (fetched in the main process)
|
||||||
|
tiktok: {
|
||||||
|
getOEmbed: (url) => ipcRenderer.invoke('tiktok:oembed', url)
|
||||||
|
},
|
||||||
|
|
||||||
// Background sync (stubs for desktop)
|
// Background sync (stubs for desktop)
|
||||||
sync: {
|
sync: {
|
||||||
start: (args) => ipcRenderer.invoke('start-background-sync', args),
|
start: (args) => ipcRenderer.invoke('start-background-sync', args),
|
||||||
@@ -130,6 +141,7 @@ contextBridge.exposeInMainWorld('electron', {
|
|||||||
updater: {
|
updater: {
|
||||||
checkForUpdates: () => ipcRenderer.invoke('check-for-updates'),
|
checkForUpdates: () => ipcRenderer.invoke('check-for-updates'),
|
||||||
downloadAndInstallUpdate: () => ipcRenderer.invoke('download-and-install-update'),
|
downloadAndInstallUpdate: () => ipcRenderer.invoke('download-and-install-update'),
|
||||||
|
isMock: () => ipcRenderer.invoke('updater-is-mock'),
|
||||||
onUpdateAvailable: (callback) => {
|
onUpdateAvailable: (callback) => {
|
||||||
ipcRenderer.on('update-available', (_, info) => callback(info));
|
ipcRenderer.on('update-available', (_, info) => callback(info));
|
||||||
},
|
},
|
||||||
@@ -139,6 +151,9 @@ contextBridge.exposeInMainWorld('electron', {
|
|||||||
onUpdateDownloaded: (callback) => {
|
onUpdateDownloaded: (callback) => {
|
||||||
ipcRenderer.on('update-downloaded', (_, info) => callback(info));
|
ipcRenderer.on('update-downloaded', (_, info) => callback(info));
|
||||||
},
|
},
|
||||||
|
onUpdateNotAvailable: (callback) => {
|
||||||
|
ipcRenderer.on('update-not-available', (_, info) => callback(info));
|
||||||
|
},
|
||||||
downloadUpdate: () => ipcRenderer.invoke('download-update'),
|
downloadUpdate: () => ipcRenderer.invoke('download-update'),
|
||||||
installUpdate: () => ipcRenderer.invoke('install-update'),
|
installUpdate: () => ipcRenderer.invoke('install-update'),
|
||||||
},
|
},
|
||||||
@@ -170,6 +185,17 @@ contextBridge.exposeInMainWorld('electron', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Debug packet recorder
|
||||||
|
debug: {
|
||||||
|
openWindow: () => ipcRenderer.invoke('debug:open-window'),
|
||||||
|
send: (packet) => ipcRenderer.send('debug:packet', packet),
|
||||||
|
onPacket: (callback) => {
|
||||||
|
const handler = (_, data) => callback(data);
|
||||||
|
ipcRenderer.on('debug:packet', handler);
|
||||||
|
return () => ipcRenderer.removeListener('debug:packet', handler);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Plugin management
|
// Plugin management
|
||||||
plugins: {
|
plugins: {
|
||||||
getPath: () => ipcRenderer.invoke('plugin:get-path'),
|
getPath: () => ipcRenderer.invoke('plugin:get-path'),
|
||||||
@@ -183,7 +209,13 @@ contextBridge.exposeInMainWorld('electron', {
|
|||||||
protocol: {
|
protocol: {
|
||||||
getStatus: () => ipcRenderer.invoke('protocol:get-status'),
|
getStatus: () => ipcRenderer.invoke('protocol:get-status'),
|
||||||
repair: () => ipcRenderer.invoke('protocol:repair')
|
repair: () => ipcRenderer.invoke('protocol:repair')
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// Discord shop collectibles (published catalog + on-demand CDN download)
|
||||||
|
discordCollectibles: {
|
||||||
|
fetchCatalog: (force = false) => ipcRenderer.invoke('discord-collectibles:fetch-catalog', { force }),
|
||||||
|
downloadAssets: (assets) => ipcRenderer.invoke('discord-collectibles:download-assets', { assets }),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Preload script ready
|
// Preload script ready
|
||||||
|
|||||||
@@ -208,6 +208,81 @@
|
|||||||
{
|
{
|
||||||
"name": "Messaging",
|
"name": "Messaging",
|
||||||
"item": [
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "Get Group Messages",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "{{baseUrl}}/messages/groups?limit=10",
|
||||||
|
"host": [
|
||||||
|
"{{baseUrl}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"messages",
|
||||||
|
"groups"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "10",
|
||||||
|
"description": "Number of recent messages (1-100, default 10)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"description": "Get the most recent messages across joined group channels (non-DMs)."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get DM Messages",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "{{baseUrl}}/messages/dms?limit=10",
|
||||||
|
"host": [
|
||||||
|
"{{baseUrl}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"messages",
|
||||||
|
"dms"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "10",
|
||||||
|
"description": "Number of recent messages (1-100, default 10)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"description": "Get the most recent messages across joined direct messages."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get Combined Messages",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "{{baseUrl}}/messages/combined?limit=10",
|
||||||
|
"host": [
|
||||||
|
"{{baseUrl}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"messages",
|
||||||
|
"combined"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "10",
|
||||||
|
"description": "Number of recent messages (1-100, default 10)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"description": "Get the most recent messages across groups and DMs together."
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Send Message to Room",
|
"name": "Send Message to Room",
|
||||||
"request": {
|
"request": {
|
||||||
|
|||||||
Generated
+1120
-5
File diff suppressed because it is too large
Load Diff
+15
-5
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "paarrot",
|
"name": "paarrot",
|
||||||
"version": "4.11.135",
|
"version": "4.11.223",
|
||||||
"description": "Paarrot - A Matrix client based on Cinny",
|
"description": "Paarrot - A Matrix client based on Cinny",
|
||||||
"homepage": "https://github.com/Paarrot/Paarrot-Desktop",
|
"homepage": "https://github.com/Paarrot/Paarrot-Desktop",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -13,13 +13,17 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently \"npm run dev:vite\" \"npm run dev:electron\"",
|
"dev": "concurrently \"npm run dev:vite\" \"npm run dev:electron\"",
|
||||||
"dev:vite": "cd cinny && npm start",
|
"dev:vite": "cross-env BROWSER=none sh -c 'cd cinny && npm start'",
|
||||||
"dev:electron": "wait-on http://localhost:38347 && cross-env NODE_ENV=development electron .",
|
"dev:electron": "wait-on http://localhost:38347 && cross-env NODE_ENV=development electron .",
|
||||||
"build": "node -e \"require('fs').copyFileSync('config.json', 'cinny/config.json')\" && cd cinny && npm run build && cd .. && electron-builder --publish always",
|
"build": "node scripts/generate-update-manifest.mjs && node -e \"require('fs').copyFileSync('config.json', 'cinny/config.json')\" && cd cinny && npm run build && cd .. && electron-builder --publish always",
|
||||||
"build:local": "node -e \"require('fs').copyFileSync('config.json', 'cinny/config.json')\" && cd cinny && npm run build && cd .. && electron-builder",
|
"build:local": "node scripts/generate-update-manifest.mjs && node -e \"require('fs').copyFileSync('config.json', 'cinny/config.json')\" && cd cinny && npm run build && cd .. && electron-builder",
|
||||||
"build:linux": "npm run build -- --linux",
|
"build:linux": "npm run build -- --linux",
|
||||||
"build:win": "npm run build -- --win",
|
"build:win": "npm run build -- --win",
|
||||||
"postman:generate": "node scripts/generate-postman-collection.js"
|
"postman:generate": "node scripts/generate-postman-collection.js",
|
||||||
|
"generate:update-manifest": "node scripts/generate-update-manifest.mjs",
|
||||||
|
"test": "npm run test:unit && npm run test:e2e",
|
||||||
|
"test:unit": "vitest run",
|
||||||
|
"test:e2e": "playwright test"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": {
|
"author": {
|
||||||
@@ -39,6 +43,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/github": "9.1.1",
|
"@actions/github": "9.1.1",
|
||||||
"@electron/rebuild": "4.2.0",
|
"@electron/rebuild": "4.2.0",
|
||||||
|
"@playwright/test": "1.64.1",
|
||||||
"concurrently": "10.0.3",
|
"concurrently": "10.0.3",
|
||||||
"cross-env": "10.1.0",
|
"cross-env": "10.1.0",
|
||||||
"electron": "43.1.0",
|
"electron": "43.1.0",
|
||||||
@@ -46,6 +51,11 @@
|
|||||||
"node-fetch": "3.3.2",
|
"node-fetch": "3.3.2",
|
||||||
"png2icons": "2.0.1",
|
"png2icons": "2.0.1",
|
||||||
"sharp": "0.35.3",
|
"sharp": "0.35.3",
|
||||||
|
"vitest": "5.1.0",
|
||||||
"wait-on": "9.0.10"
|
"wait-on": "9.0.10"
|
||||||
|
},
|
||||||
|
"allowScripts": {
|
||||||
|
"electron-winstaller@5.4.0": true,
|
||||||
|
"electron@43.1.0": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { defineConfig } from '@playwright/test';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: './tests/e2e',
|
||||||
|
// Electron launch plus first paint is far slower than a page load.
|
||||||
|
timeout: 120_000,
|
||||||
|
expect: { timeout: 30_000 },
|
||||||
|
// One Electron process at a time: the app takes a single-instance lock and
|
||||||
|
// every test shares the same vite dev server.
|
||||||
|
workers: 1,
|
||||||
|
// The suite logs in to a live homeserver, where Synapse login rate limiting is a real flake.
|
||||||
|
retries: process.env.CI ? 1 : 0,
|
||||||
|
// An explicit reporter replaces the default, so list stays for the CI log.
|
||||||
|
reporter: [['list'], ['html']],
|
||||||
|
// A trace captures the login POST body, which contains the password. Pin it off rather than
|
||||||
|
// relying on the version default.
|
||||||
|
trace: 'off',
|
||||||
|
// cinny/vite.config.js binds 0.0.0.0 with fs.allow: ['..'], which is exposed on a shared
|
||||||
|
// CI runner, so pin the dev server to loopback. The flag has to reach vite itself:
|
||||||
|
// `npm run dev:vite -- --host` lands on sh's positional params, not on vite.
|
||||||
|
// localhost is also the URL electron/main.js loads, so the page keeps that origin.
|
||||||
|
webServer: {
|
||||||
|
command: 'sh -c "cd cinny && npm start -- --host localhost"',
|
||||||
|
url: 'http://localhost:38347',
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -164,6 +164,87 @@ const collection = {
|
|||||||
{
|
{
|
||||||
name: 'Messaging',
|
name: 'Messaging',
|
||||||
item: [
|
item: [
|
||||||
|
{
|
||||||
|
name: 'Get Group Messages',
|
||||||
|
request: {
|
||||||
|
method: 'GET',
|
||||||
|
header: [],
|
||||||
|
url: {
|
||||||
|
raw: '{{baseUrl}}/messages/groups?limit=10',
|
||||||
|
host: ['{{baseUrl}}'],
|
||||||
|
path: ['messages', 'groups'],
|
||||||
|
query: [{ key: 'limit', value: '10', description: 'Number of recent messages (1-100, default 10)' }],
|
||||||
|
},
|
||||||
|
description: 'Get the most recent messages across joined group channels (non-DMs).',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get DM Messages',
|
||||||
|
request: {
|
||||||
|
method: 'GET',
|
||||||
|
header: [],
|
||||||
|
url: {
|
||||||
|
raw: '{{baseUrl}}/messages/dms?limit=10',
|
||||||
|
host: ['{{baseUrl}}'],
|
||||||
|
path: ['messages', 'dms'],
|
||||||
|
query: [{ key: 'limit', value: '10', description: 'Number of recent messages (1-100, default 10)' }],
|
||||||
|
},
|
||||||
|
description: 'Get the most recent messages across joined direct messages.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get Combined Messages',
|
||||||
|
request: {
|
||||||
|
method: 'GET',
|
||||||
|
header: [],
|
||||||
|
url: {
|
||||||
|
raw: '{{baseUrl}}/messages/combined?limit=10',
|
||||||
|
host: ['{{baseUrl}}'],
|
||||||
|
path: ['messages', 'combined'],
|
||||||
|
query: [{ key: 'limit', value: '10', description: 'Number of recent messages (1-100, default 10)' }],
|
||||||
|
},
|
||||||
|
description: 'Get the most recent messages across groups and DMs together.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get Group Unreads',
|
||||||
|
request: {
|
||||||
|
method: 'GET',
|
||||||
|
header: [],
|
||||||
|
url: {
|
||||||
|
raw: '{{baseUrl}}/unreads/groups',
|
||||||
|
host: ['{{baseUrl}}'],
|
||||||
|
path: ['unreads', 'groups'],
|
||||||
|
},
|
||||||
|
description: 'List unread group conversations (non-DMs), including counts and latest message preview.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get DM Unreads',
|
||||||
|
request: {
|
||||||
|
method: 'GET',
|
||||||
|
header: [],
|
||||||
|
url: {
|
||||||
|
raw: '{{baseUrl}}/unreads/dms',
|
||||||
|
host: ['{{baseUrl}}'],
|
||||||
|
path: ['unreads', 'dms'],
|
||||||
|
},
|
||||||
|
description: 'List unread DM conversations, including counts and latest message preview.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get Combined Unreads',
|
||||||
|
request: {
|
||||||
|
method: 'GET',
|
||||||
|
header: [],
|
||||||
|
url: {
|
||||||
|
raw: '{{baseUrl}}/unreads/combined',
|
||||||
|
host: ['{{baseUrl}}'],
|
||||||
|
path: ['unreads', 'combined'],
|
||||||
|
},
|
||||||
|
description: 'List unread conversations across groups and DMs.',
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Send Message to Room',
|
name: 'Send Message to Room',
|
||||||
request: {
|
request: {
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Desktop repo wrapper — manifest generator lives in cinny/scripts/.
|
||||||
|
*/
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const script = path.join(
|
||||||
|
path.dirname(fileURLToPath(import.meta.url)),
|
||||||
|
'..',
|
||||||
|
'cinny',
|
||||||
|
'scripts',
|
||||||
|
'generate-update-manifest.mjs'
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = spawnSync(process.execPath, [script], { stdio: 'inherit' });
|
||||||
|
process.exit(result.status ?? 1);
|
||||||
@@ -18,6 +18,17 @@
|
|||||||
"updater:allow-download",
|
"updater:allow-download",
|
||||||
"updater:allow-download-and-install",
|
"updater:allow-download-and-install",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
|
"fs:default",
|
||||||
|
"fs:allow-write-file",
|
||||||
|
{
|
||||||
|
"identifier": "fs:scope",
|
||||||
|
"allow": [
|
||||||
|
{ "path": "$HOME/**" },
|
||||||
|
{ "path": "$DOWNLOAD/**" },
|
||||||
|
{ "path": "$DESKTOP/**" },
|
||||||
|
{ "path": "$DOCUMENT/**" }
|
||||||
|
]
|
||||||
|
},
|
||||||
"process:allow-restart",
|
"process:allow-restart",
|
||||||
{
|
{
|
||||||
"identifier": "http:default",
|
"identifier": "http:default",
|
||||||
|
|||||||
+10
@@ -61,6 +61,16 @@ async function runTests() {
|
|||||||
// Get current room
|
// Get current room
|
||||||
await testEndpoint('Get Current Room', 'GET', '/room/current');
|
await testEndpoint('Get Current Room', 'GET', '/room/current');
|
||||||
|
|
||||||
|
// Recent messages by scope
|
||||||
|
await testEndpoint('Get Group Messages', 'GET', '/messages/groups');
|
||||||
|
await testEndpoint('Get DM Messages', 'GET', '/messages/dms');
|
||||||
|
await testEndpoint('Get Combined Messages', 'GET', '/messages/combined?limit=10');
|
||||||
|
|
||||||
|
// Unread conversations by scope
|
||||||
|
await testEndpoint('Get Group Unreads', 'GET', '/unreads/groups');
|
||||||
|
await testEndpoint('Get DM Unreads', 'GET', '/unreads/dms');
|
||||||
|
await testEndpoint('Get Combined Unreads', 'GET', '/unreads/combined');
|
||||||
|
|
||||||
// Toggle mute
|
// Toggle mute
|
||||||
await testEndpoint('Toggle Mute', 'POST', '/mute/toggle');
|
await testEndpoint('Toggle Mute', 'POST', '/mute/toggle');
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import { test, expect, _electron } from '@playwright/test';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
|
const HOMESERVER = process.env.E2E_HOMESERVER ?? 'ruv.wtf';
|
||||||
|
const USER = process.env.E2E_USER ?? 'giteaci';
|
||||||
|
const PASSWORD = process.env.E2E_PASSWORD;
|
||||||
|
|
||||||
|
let app;
|
||||||
|
let page;
|
||||||
|
let logs = [];
|
||||||
|
let profile;
|
||||||
|
let crashed = false;
|
||||||
|
|
||||||
|
// ServerPicker gives its input no name or test id, so position is the only handle on it;
|
||||||
|
// this breaks if the form ever gains a field before the ones below.
|
||||||
|
const serverInput = () => page.locator('input').first();
|
||||||
|
const usernameInput = () => page.locator('input[name="usernameInput"]');
|
||||||
|
const passwordInput = () => page.locator('input[name="passwordInput"]');
|
||||||
|
const submitButton = () => page.locator('button[type="submit"]');
|
||||||
|
|
||||||
|
async function expectLoginForm() {
|
||||||
|
await expect(serverInput()).toBeVisible();
|
||||||
|
await expect(usernameInput()).toBeVisible();
|
||||||
|
await expect(passwordInput()).toBeVisible();
|
||||||
|
await expect(submitButton()).toBeVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function chooseServer(server) {
|
||||||
|
await serverInput().fill(server);
|
||||||
|
// The server field commits on Enter, which re-runs discovery and reloads the auth flows.
|
||||||
|
await serverInput().press('Enter');
|
||||||
|
// fill() does not prove the value stuck; a cancelled debounce would keep matrix.org.
|
||||||
|
await expect(serverInput()).toHaveValue(server);
|
||||||
|
await expectLoginForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitLogin(username, password) {
|
||||||
|
await usernameInput().fill(username);
|
||||||
|
await passwordInput().fill(password);
|
||||||
|
await submitButton().click();
|
||||||
|
}
|
||||||
|
|
||||||
|
test.beforeEach(async () => {
|
||||||
|
logs = [];
|
||||||
|
crashed = false;
|
||||||
|
|
||||||
|
if (!PASSWORD) {
|
||||||
|
throw new Error('E2E_PASSWORD is not set. Export it, or add it as the CI secret.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fresh profile per run. electron/main.js takes a single-instance lock keyed to
|
||||||
|
// the user data dir, so a shared profile collides with a running Paarrot.
|
||||||
|
profile = fs.mkdtempSync(path.join(os.tmpdir(), 'paarrot-e2e-'));
|
||||||
|
app = await _electron.launch({ args: ['.', `--user-data-dir=${profile}`] });
|
||||||
|
|
||||||
|
app.on('console', (msg) => logs.push(`[main] ${msg.type()}: ${msg.text()}`));
|
||||||
|
|
||||||
|
page = await app.firstWindow();
|
||||||
|
// main.js opens DevTools in dev mode, and that window can be the first one registered.
|
||||||
|
while (page.url().startsWith('devtools://')) {
|
||||||
|
// Recorded so a hang here names which windows existed instead of reporting a bare timeout.
|
||||||
|
logs.push(`[window] ${page.url()}`);
|
||||||
|
page = app.windows().find((w) => !w.url().startsWith('devtools://'))
|
||||||
|
?? await new Promise((resolve) => app.once('window', resolve));
|
||||||
|
}
|
||||||
|
page.on('console', (msg) => logs.push(`[renderer] ${msg.type()}: ${msg.text()}`));
|
||||||
|
page.on('pageerror', (err) => logs.push(`[renderer] pageerror: ${err}`));
|
||||||
|
// crash is render-process-gone, so it does not fire on the MatrixError or the ServiceWorker error.
|
||||||
|
page.on('crash', () => {
|
||||||
|
crashed = true;
|
||||||
|
logs.push('[renderer] page crashed');
|
||||||
|
});
|
||||||
|
|
||||||
|
await chooseServer(HOMESERVER);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Config-based screenshots do not fire for a page taken from app.firstWindow(), and console
|
||||||
|
// capture is not covered by config at all, so this hook stays manual.
|
||||||
|
test.afterEach(async ({}, testInfo) => {
|
||||||
|
if (testInfo.status !== testInfo.expectedStatus) {
|
||||||
|
// Console first: a failed launch has no app and no page, so this is the only artifact that
|
||||||
|
// path can produce, and it is empty by construction because no handler is attached before
|
||||||
|
// launch — the failure message in the report is the diagnosis there. A crashed page produces
|
||||||
|
// no screenshot; the crash line in the console names it.
|
||||||
|
await testInfo.attach('console.log', { body: logs.join('\n'), contentType: 'text/plain' });
|
||||||
|
if (page && !page.isClosed()) {
|
||||||
|
// screenshot() throws on a crashed page, which would mask the original failure.
|
||||||
|
const shot = await page.screenshot().catch(() => null);
|
||||||
|
if (shot) await testInfo.attach('failure.png', { body: shot, contentType: 'image/png' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app) {
|
||||||
|
await app
|
||||||
|
.close()
|
||||||
|
// main.js preventDefault()s window close to minimise to tray, so close can hang.
|
||||||
|
.catch(() => app.process().kill('SIGTERM'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reachable on launch failure, so the temp profile does not leak.
|
||||||
|
if (profile) fs.rmSync(profile, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
async function expectAuthenticated() {
|
||||||
|
// Login complete reloads into the client shell, which lands on the last active path
|
||||||
|
// (state/lastActivePath.ts) or the inbox, so assert a shell route rather than any URL.
|
||||||
|
await expect(page).toHaveURL(/#\/(inbox|home|room|space)/);
|
||||||
|
|
||||||
|
await expect
|
||||||
|
.poll(() => page.evaluate(() => JSON.parse(localStorage.getItem('currentSessionUserId') ?? 'null')))
|
||||||
|
.toBe(`@${USER}:${HOMESERVER}`);
|
||||||
|
|
||||||
|
// A truthy accessToken only proves a string exists, so prove it authenticates. Only the
|
||||||
|
// status is asserted, so a failure cannot put a live token into the CI log or the report.
|
||||||
|
await expect
|
||||||
|
.poll(async () => {
|
||||||
|
const token = await page.evaluate(() => JSON.parse(localStorage.getItem('matrixSessions') ?? '[]')[0]?.accessToken);
|
||||||
|
if (!token) return 0;
|
||||||
|
// /versions and /account 404 on ruv.wtf; /capabilities exists and requires a valid token.
|
||||||
|
const res = await fetch(`https://${HOMESERVER}/_matrix/client/v3/capabilities`, { headers: { Authorization: `Bearer ${token}` } });
|
||||||
|
return res.status;
|
||||||
|
})
|
||||||
|
.toBe(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
test('test account can log in and reaches the authenticated app', async () => {
|
||||||
|
await submitLogin(USER, PASSWORD);
|
||||||
|
await expectAuthenticated();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failed login reports an error and keeps the renderer alive', async () => {
|
||||||
|
await submitLogin(USER, 'not-the-password');
|
||||||
|
|
||||||
|
// A rate-limited run renders LoginError.RateLimited instead of the wrong-password message,
|
||||||
|
// so accept both branches rather than asserting one exact string.
|
||||||
|
await expect(page.getByText(/Invalid Username or Password\.|rate-limited by server/)).toBeVisible();
|
||||||
|
|
||||||
|
// Asserted before the form check: on a crashed page the locator throws TargetClosedError,
|
||||||
|
// which names the wrong thing. Pageerrors go into the artifact but are not asserted — the
|
||||||
|
// failed login itself produces MatrixError, and dev mode produces a ServiceWorker registration
|
||||||
|
// error. No second login here: every run costs Synapse rc_login budget, and the re-login was
|
||||||
|
// the main flake source.
|
||||||
|
await expect(crashed).toBe(false);
|
||||||
|
await expect(usernameInput()).toBeVisible();
|
||||||
|
});
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { afterAll, beforeAll, expect, test } from 'vitest';
|
||||||
|
|
||||||
|
import PaarrotAPIServer from '../../electron/api-server.js';
|
||||||
|
|
||||||
|
const api = new PaarrotAPIServer(null);
|
||||||
|
let base;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
// Port 0 lets the OS pick a free port, so the test never collides with a running Paarrot.
|
||||||
|
await api.start(0);
|
||||||
|
base = `http://127.0.0.1:${api.server.address().port}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await api.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('GET /health reports the API server is up', async () => {
|
||||||
|
const res = await fetch(`${base}/health`);
|
||||||
|
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
expect(await res.json()).toEqual({ status: 'ok', app: 'Paarrot API', version: '1.0.0' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('unknown endpoint answers 404 with the endpoint list', async () => {
|
||||||
|
const res = await fetch(`${base}/not-an-endpoint`);
|
||||||
|
|
||||||
|
expect(res.status).toBe(404);
|
||||||
|
|
||||||
|
const body = await res.json();
|
||||||
|
expect(body.error).toBe('Endpoint not found');
|
||||||
|
expect(body.availableEndpoints).toContain('GET /health');
|
||||||
|
});
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
// The default pattern would also pick up the Electron spec in tests/e2e.
|
||||||
|
include: ['tests/unit/**/*.test.js'],
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user