Compare commits
147 Commits
1dbc7d6cc4
...
v4.11.191
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | |||
|
|
c0266903ec | ||
| 81964d6f14 | |||
|
|
47e025cf55 | ||
| b400070ad0 | |||
| 529694ce66 | |||
|
|
791c3ab4df | ||
| de8d9db795 | |||
|
|
ffaf9ff66a | ||
| f0891ba4cc | |||
| 627b117119 | |||
|
|
b6c6659a5a | ||
| d7a73afebc | |||
| e469d51ba4 | |||
|
|
6ba03277e5 | ||
| fdb2dca794 | |||
|
|
8797bb5a22 | ||
| 4d154fd4f3 | |||
| 42e8fb71ef | |||
|
|
ff2c284984 | ||
| 75be84e472 | |||
| a3c91b306a | |||
|
|
20edc293bb | ||
| 6803eac8fb | |||
| fa5592f1e4 | |||
|
|
78601be6f4 | ||
| c940bdc78c | |||
|
|
9471fe2f5d | ||
| 57f7fe7086 | |||
| a2364f2622 | |||
|
|
df2220581d | ||
| 198eb0fe04 | |||
| fff114abef | |||
|
|
7013f1c22d |
@@ -8,6 +8,9 @@ on:
|
||||
tags:
|
||||
- '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.
|
||||
|
||||
jobs:
|
||||
increment-version:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -105,84 +108,101 @@ jobs:
|
||||
echo "VERSION=${{ steps.decide.outputs.CURRENT_VERSION }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
build-windows:
|
||||
runs-on: windows
|
||||
prepare-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: increment-version
|
||||
if: always() && (needs.increment-version.outputs.should_build == 'true' || needs.increment-version.result == 'skipped')
|
||||
if: always() && needs.increment-version.outputs.should_build == 'true'
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.VERSION }}
|
||||
tag: ${{ steps.version.outputs.TAG_NAME }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.ref_name }}
|
||||
|
||||
- name: Checkout submodules manually
|
||||
shell: powershell
|
||||
run: |
|
||||
git submodule sync --recursive
|
||||
|
||||
if (git submodule update --init --recursive) {
|
||||
Write-Host "Submodules checked out at pinned commits."
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Warning "Pinned submodule commit is unavailable on remote. Falling back to remote submodule HEAD."
|
||||
git submodule deinit -f --all
|
||||
git submodule update --init --recursive --remote
|
||||
|
||||
Write-Host "Resolved submodule commit:"
|
||||
git -C cinny rev-parse HEAD
|
||||
|
||||
- name: Pull latest (after version bump)
|
||||
if: github.ref == 'refs/heads/main'
|
||||
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
|
||||
- name: Resolve version
|
||||
id: version
|
||||
run: |
|
||||
if (Test-Path cinny/dist) { Remove-Item -Recurse -Force cinny/dist }
|
||||
if (Test-Path dist-electron) { Remove-Item -Recurse -Force dist-electron }
|
||||
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 "TAG_NAME=v$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Version: $VERSION"
|
||||
|
||||
- name: Build Electron app
|
||||
run: npm run build:local -- --win
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
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
|
||||
|
||||
- name: Ensure Gitea release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
API_BASE="${{ github.server_url }}/api/v1"
|
||||
REPO="${{ github.repository }}"
|
||||
|
||||
RELEASE_ID=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty' || true)
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "Creating Gitea release ${TAG_NAME}..."
|
||||
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
|
||||
|
||||
echo "Gitea release id: ${RELEASE_ID}"
|
||||
|
||||
- name: Ensure GitHub release
|
||||
env:
|
||||
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: |
|
||||
Get-ChildItem -Path dist-electron -Recurse | Select-Object FullName
|
||||
set -euo pipefail
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
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
|
||||
needs: increment-version
|
||||
if: always() && (needs.increment-version.outputs.should_build == 'true' || needs.increment-version.result == 'skipped')
|
||||
needs: [increment-version, prepare-release]
|
||||
if: always() && needs.prepare-release.result == 'success'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -194,6 +214,14 @@ jobs:
|
||||
- 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
|
||||
@@ -202,7 +230,165 @@ jobs:
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
echo "Resolved submodule commit:"
|
||||
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
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install Wine (NSIS cross-build)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# electron-builder spawns `wine` by name; wine64 alone is not enough.
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
wine \
|
||||
wine64 \
|
||||
wine32 \
|
||||
|| sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends wine64
|
||||
|
||||
if ! command -v wine >/dev/null 2>&1; then
|
||||
WINE64_BIN=$(command -v 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)
|
||||
run: npm ci --prefer-offline
|
||||
|
||||
- name: Install dependencies (cinny)
|
||||
working-directory: ./cinny
|
||||
run: npm ci --prefer-offline
|
||||
|
||||
- name: Clean previous builds
|
||||
run: |
|
||||
rm -rf cinny/dist dist-electron
|
||||
|
||||
- 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: |
|
||||
set -euo pipefail
|
||||
TAG_NAME="${{ needs.prepare-release.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: [increment-version, prepare-release]
|
||||
if: always() && needs.prepare-release.result == 'success'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
ref: ${{ github.ref_name }}
|
||||
|
||||
- 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:"
|
||||
@@ -233,208 +419,126 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||
|
||||
- name: Upload AppImage
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Paarrot-Linux-x64.AppImage
|
||||
path: dist-electron/Paarrot-*.AppImage
|
||||
|
||||
- name: Upload latest-linux.yml
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: latest-linux.yml
|
||||
path: dist-electron/latest-linux.yml
|
||||
- name: Upload Linux assets to releases
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION="${{ needs.prepare-release.outputs.version }}"
|
||||
TAG_NAME="${{ needs.prepare-release.outputs.tag }}"
|
||||
API_BASE="${{ github.server_url }}/api/v1"
|
||||
REPO="${{ github.repository }}"
|
||||
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||
|
||||
create-release:
|
||||
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-*.AppImage dist-electron/latest-linux.yml; do
|
||||
upload_one "$FILE"
|
||||
done
|
||||
|
||||
finalize-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [increment-version, build-windows, build-linux]
|
||||
if: always() && (needs.build-windows.result == 'success' || needs.build-linux.result == 'success')
|
||||
needs: [increment-version, prepare-release, build-windows, build-linux]
|
||||
if: always() && needs.prepare-release.result == 'success' && (needs.build-windows.result == 'success' || needs.build-linux.result == 'success')
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
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
|
||||
- name: Cleanup old Gitea releases
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
API_BASE="http://synbox.ruv.wtf:8418/api/v1"
|
||||
REPO="litruv/cinny-desktop"
|
||||
|
||||
# Delete old releases (keep only current)
|
||||
echo "Cleaning up old releases..."
|
||||
OLD_RELEASES=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases" | jq -r '.[] | select(.tag_name != "'${TAG_NAME}'") | .id')
|
||||
|
||||
set -euo pipefail
|
||||
TAG_NAME="${{ needs.prepare-release.outputs.tag }}"
|
||||
API_BASE="${{ github.server_url }}/api/v1"
|
||||
REPO="${{ github.repository }}"
|
||||
|
||||
echo "Cleaning up old Gitea releases (keeping ${TAG_NAME})..."
|
||||
OLD_RELEASES=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases" | jq -r --arg t "$TAG_NAME" '.[] | select(.tag_name != $t) | .id')
|
||||
|
||||
for OLD_ID in $OLD_RELEASES; do
|
||||
echo "Deleting old release ${OLD_ID}..."
|
||||
OLD_TAG=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
[ -n "$OLD_ID" ] || continue
|
||||
OLD_TAG=$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/${OLD_ID}" | jq -r '.tag_name')
|
||||
|
||||
# Delete release
|
||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/${OLD_ID}"
|
||||
|
||||
# Delete tag
|
||||
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}"
|
||||
echo "Deleting Gitea release ${OLD_ID} (${OLD_TAG})..."
|
||||
curl -fsS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/${OLD_ID}" >/dev/null || true
|
||||
if [ -n "$OLD_TAG" ] && [ "$OLD_TAG" != "null" ]; then
|
||||
curl -fsS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/tags/${OLD_TAG}" >/dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
# Check if release exists
|
||||
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
|
||||
- name: Cleanup old GitHub releases
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
set -euo pipefail
|
||||
TAG_NAME="${{ needs.prepare-release.outputs.tag }}"
|
||||
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||
|
||||
# Delete old GitHub releases (keep only current)
|
||||
echo "Cleaning up old GitHub releases..."
|
||||
OLD_RELEASES=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/releases" | jq -r '.[] | select(.tag_name != "'${TAG_NAME}'") | .id')
|
||||
|
||||
|
||||
echo "Cleaning up old GitHub releases (keeping ${TAG_NAME})..."
|
||||
OLD_RELEASES=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/releases" | jq -r --arg t "$TAG_NAME" '.[] | select(.tag_name != $t) | .id')
|
||||
|
||||
for OLD_ID in $OLD_RELEASES; do
|
||||
echo "Deleting old GitHub release ${OLD_ID}..."
|
||||
OLD_TAG=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
||||
[ -n "$OLD_ID" ] || continue
|
||||
OLD_TAG=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/${OLD_ID}" | jq -r '.tag_name')
|
||||
|
||||
# Delete release
|
||||
curl -s -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/${OLD_ID}"
|
||||
|
||||
# Delete tag
|
||||
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}"
|
||||
echo "Deleting GitHub release ${OLD_ID} (${OLD_TAG})..."
|
||||
curl -fsS -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/${OLD_ID}" >/dev/null || true
|
||||
if [ -n "$OLD_TAG" ] && [ "$OLD_TAG" != "null" ]; then
|
||||
curl -fsS -X DELETE -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/git/refs/tags/${OLD_TAG}" >/dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
# Check if release exists on GitHub
|
||||
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!"
|
||||
|
||||
echo "Release finalize complete for ${TAG_NAME}"
|
||||
|
||||
35
.github/workflows/update-manifest.yml
vendored
Normal file
35
.github/workflows/update-manifest.yml
vendored
Normal file
@@ -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
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "cinny"]
|
||||
path = cinny
|
||||
url = http://synbox.ruv.wtf:8418/litruv/cinny.git
|
||||
url = ../cinny.git
|
||||
|
||||
2
cinny
2
cinny
Submodule cinny updated: c2fc71ddca...47979718eb
Binary file not shown.
@@ -36,6 +36,12 @@
|
||||
"filter": ["**/*"]
|
||||
}
|
||||
],
|
||||
"protocols": [
|
||||
{
|
||||
"name": "Paarrot URL",
|
||||
"schemes": ["paarrot"]
|
||||
}
|
||||
],
|
||||
"linux": {
|
||||
"target": [
|
||||
{
|
||||
@@ -51,6 +57,7 @@
|
||||
"Name": "Paarrot",
|
||||
"GenericName": "Matrix Client",
|
||||
"Comment": "A Matrix client built with Cinny",
|
||||
"MimeType": "x-scheme-handler/paarrot;",
|
||||
"Categories": "Network;InstantMessaging;",
|
||||
"Keywords": "matrix;chat;messaging;",
|
||||
"StartupWMClass": "paarrot"
|
||||
|
||||
@@ -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
|
||||
this.app.use((req, res) => {
|
||||
res.status(404).json({
|
||||
@@ -169,7 +235,13 @@ class PaarrotAPIServer {
|
||||
'GET /channels',
|
||||
'POST /message',
|
||||
'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/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);
|
||||
}).on('error', (err) => {
|
||||
if (err.code === 'EADDRINUSE') {
|
||||
|
||||
381
electron/discord-collectibles.js
Normal file
381
electron/discord-collectibles.js
Normal file
@@ -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 };
|
||||
981
electron/main.js
981
electron/main.js
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,8 @@ const commandMap = {
|
||||
'check_for_updates': 'check-for-updates',
|
||||
'download_update': 'download-update',
|
||||
'install_update': 'install-update',
|
||||
'get_desktop_sources': 'get-desktop-sources'
|
||||
'get_desktop_sources': 'get-desktop-sources',
|
||||
'get_protocol_status': 'protocol:get-status'
|
||||
};
|
||||
|
||||
// Shared invoke function for legacy API compatibility
|
||||
@@ -103,6 +104,12 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
readImage: () => ipcRenderer.invoke('read-clipboard-image'),
|
||||
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: {
|
||||
playNotificationSound: (soundType = 'message') => ipcRenderer.invoke('play-notification-sound', soundType),
|
||||
@@ -129,6 +136,7 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
updater: {
|
||||
checkForUpdates: () => ipcRenderer.invoke('check-for-updates'),
|
||||
downloadAndInstallUpdate: () => ipcRenderer.invoke('download-and-install-update'),
|
||||
isMock: () => ipcRenderer.invoke('updater-is-mock'),
|
||||
onUpdateAvailable: (callback) => {
|
||||
ipcRenderer.on('update-available', (_, info) => callback(info));
|
||||
},
|
||||
@@ -138,6 +146,9 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
onUpdateDownloaded: (callback) => {
|
||||
ipcRenderer.on('update-downloaded', (_, info) => callback(info));
|
||||
},
|
||||
onUpdateNotAvailable: (callback) => {
|
||||
ipcRenderer.on('update-not-available', (_, info) => callback(info));
|
||||
},
|
||||
downloadUpdate: () => ipcRenderer.invoke('download-update'),
|
||||
installUpdate: () => ipcRenderer.invoke('install-update'),
|
||||
},
|
||||
@@ -176,7 +187,19 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
list: () => ipcRenderer.invoke('plugin:list'),
|
||||
uninstall: (pluginId) => ipcRenderer.invoke('plugin:uninstall', pluginId),
|
||||
readPluginCode: (pluginId) => ipcRenderer.invoke('plugin:read-code', pluginId)
|
||||
}
|
||||
},
|
||||
|
||||
// Desktop protocol diagnostics
|
||||
protocol: {
|
||||
getStatus: () => ipcRenderer.invoke('protocol:get-status'),
|
||||
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
|
||||
|
||||
@@ -208,6 +208,81 @@
|
||||
{
|
||||
"name": "Messaging",
|
||||
"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",
|
||||
"request": {
|
||||
|
||||
3521
package-lock.json
generated
3521
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paarrot",
|
||||
"version": "4.11.122",
|
||||
"version": "4.11.191",
|
||||
"description": "Paarrot - A Matrix client based on Cinny",
|
||||
"homepage": "https://github.com/Paarrot/Paarrot-Desktop",
|
||||
"repository": {
|
||||
@@ -13,13 +13,15 @@
|
||||
},
|
||||
"scripts": {
|
||||
"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 .",
|
||||
"build": "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": "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 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: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",
|
||||
"playground": "npm --prefix cinny run playground"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": {
|
||||
@@ -28,24 +30,28 @@
|
||||
},
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.5.16",
|
||||
"body-parser": "2.2.2",
|
||||
"adm-zip": "^0.5.18",
|
||||
"body-parser": "2.3.0",
|
||||
"cors": "2.8.6",
|
||||
"electron-store": "^8.2.0",
|
||||
"electron-updater": "^6.3.9",
|
||||
"electron-store": "^11.0.2",
|
||||
"electron-updater": "^6.8.9",
|
||||
"express": "5.2.1",
|
||||
"open": "11.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@actions/github": "6.0.0",
|
||||
"@electron/rebuild": "4.0.3",
|
||||
"concurrently": "9.2.1",
|
||||
"@actions/github": "9.1.1",
|
||||
"@electron/rebuild": "4.2.0",
|
||||
"concurrently": "10.0.3",
|
||||
"cross-env": "10.1.0",
|
||||
"electron": "40.6.0",
|
||||
"electron-builder": "26.8.1",
|
||||
"electron": "43.1.0",
|
||||
"electron-builder": "26.15.3",
|
||||
"node-fetch": "3.3.2",
|
||||
"png2icons": "2.0.1",
|
||||
"sharp": "0.34.5",
|
||||
"wait-on": "9.0.4"
|
||||
"sharp": "0.35.3",
|
||||
"wait-on": "9.0.10"
|
||||
},
|
||||
"allowScripts": {
|
||||
"electron-winstaller@5.4.0": true,
|
||||
"electron@43.1.0": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +164,87 @@ const collection = {
|
||||
{
|
||||
name: 'Messaging',
|
||||
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',
|
||||
request: {
|
||||
|
||||
18
scripts/generate-update-manifest.mjs
Normal file
18
scripts/generate-update-manifest.mjs
Normal file
@@ -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);
|
||||
104
scripts/migrate-icons.mjs
Normal file
104
scripts/migrate-icons.mjs
Normal file
@@ -0,0 +1,104 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const srcRoot = path.resolve(__dirname, '../cinny/src');
|
||||
const iconsModule = path.resolve(srcRoot, 'app/components/icons');
|
||||
|
||||
const ICON_SYMBOLS = new Set(['Icon', 'Icons', 'IconName', 'IconSrc']);
|
||||
|
||||
function walk(dir, files = []) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
walk(fullPath, files);
|
||||
} else if (/\.(tsx?)$/.test(entry.name)) {
|
||||
files.push(fullPath);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
function getIconsImportPath(filePath) {
|
||||
const rel = path.relative(path.dirname(filePath), iconsModule).replace(/\\/g, '/');
|
||||
return rel.startsWith('.') ? rel : `./${rel}`;
|
||||
}
|
||||
|
||||
function splitFoldsImport(importClause) {
|
||||
const match = importClause.match(/^\{([^}]+)\}(?:\s+as\s+\w+)?$/);
|
||||
if (!match) return null;
|
||||
|
||||
const specifiers = match[1]
|
||||
.split(',')
|
||||
.map((part) => part.trim())
|
||||
.filter(Boolean)
|
||||
.map((part) => {
|
||||
const [local, imported] = part.split(/\s+as\s+/).map((s) => s.trim());
|
||||
return { local: local ?? imported, imported: imported ?? local };
|
||||
});
|
||||
|
||||
const iconSpecs = specifiers.filter((s) => ICON_SYMBOLS.has(s.imported));
|
||||
const foldsSpecs = specifiers.filter((s) => !ICON_SYMBOLS.has(s.imported));
|
||||
|
||||
if (iconSpecs.length === 0) return null;
|
||||
|
||||
return { iconSpecs, foldsSpecs };
|
||||
}
|
||||
|
||||
function migrateFile(filePath) {
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
const importRegex = /import\s+(\{[^}]+\})\s+from\s+['"]folds['"];?/g;
|
||||
let changed = false;
|
||||
const iconImports = new Map();
|
||||
|
||||
content = content.replace(importRegex, (fullMatch, importClause) => {
|
||||
const split = splitFoldsImport(importClause);
|
||||
if (!split) return fullMatch;
|
||||
|
||||
changed = true;
|
||||
for (const spec of split.iconSpecs) {
|
||||
iconImports.set(spec.local, spec.imported);
|
||||
}
|
||||
|
||||
if (split.foldsSpecs.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const foldsImport = split.foldsSpecs.map((s) => (s.local === s.imported ? s.local : `${s.imported} as ${s.local}`)).join(', ');
|
||||
return `import { ${foldsImport} } from 'folds';`;
|
||||
});
|
||||
|
||||
if (!changed) return false;
|
||||
|
||||
const iconsPath = getIconsImportPath(filePath);
|
||||
const iconExportList = [...iconImports.entries()]
|
||||
.map(([local, imported]) => (local === imported ? imported : `${imported} as ${local}`))
|
||||
.join(', ');
|
||||
|
||||
const iconsImportLine = `import { ${iconExportList} } from '${iconsPath}';`;
|
||||
|
||||
const foldsImportMatch = content.match(/^import\s+\{[^}]+\}\s+from\s+['"]folds['"];?\s*$/m);
|
||||
if (foldsImportMatch) {
|
||||
const insertAt = content.indexOf(foldsImportMatch[0]) + foldsImportMatch[0].length;
|
||||
content = `${content.slice(0, insertAt)}\n${iconsImportLine}${content.slice(insertAt)}`;
|
||||
} else {
|
||||
content = `${iconsImportLine}\n${content}`;
|
||||
}
|
||||
|
||||
content = content.replace(/\n{3,}/g, '\n\n');
|
||||
fs.writeFileSync(filePath, content);
|
||||
return true;
|
||||
}
|
||||
|
||||
const files = walk(srcRoot);
|
||||
let migrated = 0;
|
||||
|
||||
for (const file of files) {
|
||||
if (file.includes(`${path.sep}components${path.sep}icons${path.sep}`)) continue;
|
||||
if (migrateFile(file)) {
|
||||
migrated += 1;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Migrated ${migrated} files.`);
|
||||
@@ -18,6 +18,17 @@
|
||||
"updater:allow-download",
|
||||
"updater:allow-download-and-install",
|
||||
"dialog:default",
|
||||
"fs:default",
|
||||
"fs:allow-write-file",
|
||||
{
|
||||
"identifier": "fs:scope",
|
||||
"allow": [
|
||||
{ "path": "$HOME/**" },
|
||||
{ "path": "$DOWNLOAD/**" },
|
||||
{ "path": "$DESKTOP/**" },
|
||||
{ "path": "$DOCUMENT/**" }
|
||||
]
|
||||
},
|
||||
"process:allow-restart",
|
||||
{
|
||||
"identifier": "http:default",
|
||||
|
||||
10
test-api.js
10
test-api.js
@@ -60,6 +60,16 @@ async function runTests() {
|
||||
|
||||
// Get current room
|
||||
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
|
||||
await testEndpoint('Toggle Mute', 'POST', '/mute/toggle');
|
||||
|
||||
Reference in New Issue
Block a user