Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ce8b41a4c | ||
|
|
0562b326c8 | ||
|
|
857a8477d7 | ||
|
|
fdbf57a6d6 | ||
|
|
4f7aab646b | ||
|
|
35481fe7d7 | ||
|
|
26b70d29c4 | ||
|
|
c94cdf679a | ||
|
|
a5d1725ee7 | ||
|
|
23662003da | ||
|
|
34ed92a647 | ||
|
|
2760ab4897 | ||
|
|
6e306a9bed |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,5 +22,8 @@ Thumbs.db
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# Token local (jamais commité)
|
||||
.gitea-token
|
||||
|
||||
# Claude Code
|
||||
.claude/
|
||||
|
||||
@@ -1,37 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# Installe (ou met à jour) l'entrée de menu "Farm Tracker" pointant vers l'AppImage déjà construit.
|
||||
set -e
|
||||
# Installation initiale de Farm Tracker (AppImage + entrée de menu).
|
||||
# À lancer une seule fois. Les mises à jour suivantes sont automatiques.
|
||||
set -euo pipefail
|
||||
|
||||
APPDIR="/home/shamiiow/GitHub/farm-tracker-app/dist"
|
||||
APPIMAGE=$(ls "$APPDIR"/*.AppImage 2>/dev/null | head -n1)
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
DIST_DIR="$SCRIPT_DIR/dist"
|
||||
|
||||
if [ -z "$APPIMAGE" ]; then
|
||||
echo "Aucun fichier .AppImage trouvé dans : $APPDIR"
|
||||
echo "Lance d'abord (depuis le dossier du projet) : npm run dist"
|
||||
# Trouve l'AppImage dans dist/
|
||||
APPIMAGE_SRC=$(ls "$DIST_DIR"/*.AppImage 2>/dev/null | head -n1)
|
||||
if [ -z "$APPIMAGE_SRC" ]; then
|
||||
echo "Aucun .AppImage trouvé dans dist/. Lance d'abord : npm run dist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x "$APPIMAGE"
|
||||
# Chemin stable — indépendant de la version
|
||||
INSTALL_DIR="$HOME/.local/bin"
|
||||
STABLE_PATH="$INSTALL_DIR/farm-tracker.AppImage"
|
||||
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
cp "$APPIMAGE_SRC" "$STABLE_PATH"
|
||||
chmod +x "$STABLE_PATH"
|
||||
|
||||
# Entrée de menu
|
||||
DESKTOP_DIR="$HOME/.local/share/applications"
|
||||
mkdir -p "$DESKTOP_DIR"
|
||||
DESKTOP_FILE="$DESKTOP_DIR/farm-tracker.desktop"
|
||||
|
||||
cat > "$DESKTOP_FILE" << INNEREOF
|
||||
cat > "$DESKTOP_DIR/farm-tracker.desktop" << EOF
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Farm Tracker
|
||||
Comment=Suivi de loot Minecraft en direct
|
||||
Exec="$APPIMAGE" %U
|
||||
Exec="$STABLE_PATH" %U
|
||||
Icon=applications-games
|
||||
Terminal=false
|
||||
Categories=Game;Utility;
|
||||
StartupWMClass=farm-tracker
|
||||
INNEREOF
|
||||
EOF
|
||||
|
||||
chmod +x "$DESKTOP_FILE"
|
||||
chmod +x "$DESKTOP_DIR/farm-tracker.desktop"
|
||||
update-desktop-database "$DESKTOP_DIR" >/dev/null 2>&1 || true
|
||||
|
||||
echo "Entrée installée : $DESKTOP_FILE"
|
||||
echo "AppImage détecté : $APPIMAGE"
|
||||
echo "Cherche \"Farm Tracker\" dans ton menu d'applications (déconnexion/reconnexion parfois nécessaire selon le bureau)."
|
||||
echo "Installé dans : $STABLE_PATH"
|
||||
echo "Entrée de menu : $DESKTOP_DIR/farm-tracker.desktop"
|
||||
echo ""
|
||||
echo "Les prochaines mises à jour s'installeront automatiquement sans rien retoucher."
|
||||
|
||||
@@ -21,12 +21,14 @@ function mergeDropStatsInto(target, source) {
|
||||
|
||||
for (const [mobName, mobData] of Object.entries(sourceMobs)) {
|
||||
if (!mobName) continue;
|
||||
if (!target.mobs[mobName]) target.mobs[mobName] = { kills: 0, items: {} };
|
||||
if (!target.mobs[mobName]) target.mobs[mobName] = { kills: 0, totalExp: 0, totalCols: 0, items: {} };
|
||||
const t = target.mobs[mobName];
|
||||
|
||||
const kills = Number(mobData.kills) || 0;
|
||||
t.kills += kills;
|
||||
addedKills += kills;
|
||||
t.totalExp = (t.totalExp || 0) + (Number(mobData.totalExp) || 0);
|
||||
t.totalCols = (t.totalCols || 0) + (Number(mobData.totalCols) || 0);
|
||||
|
||||
const items = mobData.items || {};
|
||||
for (const [key, item] of Object.entries(items)) {
|
||||
|
||||
83
main.js
83
main.js
@@ -103,6 +103,69 @@ function resolveAssetUrl(release) {
|
||||
return asset ? asset.browser_download_url : null;
|
||||
}
|
||||
|
||||
function sendUpdateProgress(percent, status, error) {
|
||||
if (mainWindow && !mainWindow.isDestroyed())
|
||||
mainWindow.webContents.send('update-progress', { percent, status, error });
|
||||
}
|
||||
|
||||
function downloadFileWithProgress(url, destPath, onProgress) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const follow = (currentUrl, redirects) => {
|
||||
if (redirects > 5) return reject(new Error('Trop de redirections'));
|
||||
const mod = currentUrl.startsWith('https') ? require('https') : require('http');
|
||||
const req = mod.get(currentUrl, { timeout: 120000, headers: { 'User-Agent': 'farm-tracker-updater' } }, (res) => {
|
||||
if ([301, 302, 307, 308].includes(res.statusCode))
|
||||
return follow(res.headers.location, redirects + 1);
|
||||
if (res.statusCode !== 200)
|
||||
return reject(new Error(`HTTP ${res.statusCode}`));
|
||||
const total = parseInt(res.headers['content-length'] || '0', 10);
|
||||
let downloaded = 0;
|
||||
const file = fs.createWriteStream(destPath);
|
||||
res.on('data', chunk => {
|
||||
downloaded += chunk.length;
|
||||
file.write(chunk);
|
||||
if (total > 0 && onProgress) onProgress(Math.round(downloaded / total * 100));
|
||||
});
|
||||
res.on('end', () => file.close(() => resolve(destPath)));
|
||||
res.on('error', err => { file.close(); try { fs.unlinkSync(destPath); } catch (_) {} reject(err); });
|
||||
});
|
||||
req.on('error', reject);
|
||||
req.on('timeout', () => { req.destroy(); reject(new Error('Timeout')); });
|
||||
};
|
||||
follow(url, 0);
|
||||
});
|
||||
}
|
||||
|
||||
async function downloadAndInstall(downloadUrl, version) {
|
||||
if (!app.isPackaged) {
|
||||
dialog.showMessageBox(mainWindow, {
|
||||
type: 'info', title: 'Mode développement',
|
||||
message: 'Auto-install non disponible en mode dev.',
|
||||
buttons: ['OK']
|
||||
});
|
||||
return;
|
||||
}
|
||||
const ext = process.platform === 'win32' ? '.exe' : '.AppImage';
|
||||
const tmpPath = path.join(app.getPath('temp'), `farm-tracker-${version}${ext}`);
|
||||
try {
|
||||
sendUpdateProgress(0, 'downloading');
|
||||
await downloadFileWithProgress(downloadUrl, tmpPath, pct => sendUpdateProgress(pct, 'downloading'));
|
||||
sendUpdateProgress(100, 'installing');
|
||||
if (process.platform === 'linux') {
|
||||
fs.chmodSync(tmpPath, 0o755);
|
||||
const { spawn } = require('child_process');
|
||||
spawn(tmpPath, [], { detached: true, stdio: 'ignore' }).unref();
|
||||
app.quit();
|
||||
} else if (process.platform === 'win32') {
|
||||
const { spawn } = require('child_process');
|
||||
spawn(tmpPath, ['/S'], { detached: true, stdio: 'ignore' }).unref();
|
||||
app.quit();
|
||||
}
|
||||
} catch (e) {
|
||||
sendUpdateProgress(0, 'error', e.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function showUpdateDialog(version, downloadUrl, ignoreSnooze = false) {
|
||||
const current = app.getVersion();
|
||||
if (!isNewerVersion(version, current)) return false;
|
||||
@@ -117,14 +180,14 @@ async function showUpdateDialog(version, downloadUrl, ignoreSnooze = false) {
|
||||
type: 'info',
|
||||
title: 'Mise à jour disponible',
|
||||
message: `Version ${version} disponible`,
|
||||
detail: `Version actuelle : ${current}`,
|
||||
buttons: ['Télécharger', 'Me rappeler dans...'],
|
||||
detail: `Version actuelle : ${current}\nL'application se relancera automatiquement après la mise à jour.`,
|
||||
buttons: ['Installer maintenant', 'Me rappeler dans...'],
|
||||
defaultId: 0,
|
||||
cancelId: 1
|
||||
});
|
||||
|
||||
if (response === 0) {
|
||||
shell.openExternal(downloadUrl);
|
||||
downloadAndInstall(downloadUrl, version);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -181,7 +244,21 @@ function createWindow() {
|
||||
mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html'));
|
||||
}
|
||||
|
||||
function selfInstallLinux() {
|
||||
if (process.platform !== 'linux' || !app.isPackaged) return;
|
||||
const appImagePath = process.env.APPIMAGE;
|
||||
if (!appImagePath) return;
|
||||
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
|
||||
if (appImagePath === stablePath) return;
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(stablePath), { recursive: true });
|
||||
fs.copyFileSync(appImagePath, stablePath);
|
||||
fs.chmodSync(stablePath, 0o755);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
selfInstallLinux();
|
||||
createWindow();
|
||||
setTimeout(() => checkForUpdates(false), 5000);
|
||||
});
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "farm-tracker",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "farm-tracker",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dist": "^0.1.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "farm-tracker",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.9",
|
||||
"description": "Suivi de loot Minecraft en direct, avec sauvegarde automatique des stats et des chances de drop.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -24,5 +24,6 @@ contextBridge.exposeInMainWorld('api', {
|
||||
loadSessionHistory: () => ipcRenderer.invoke('load-session-history'),
|
||||
saveSessionHistory: (obj) => ipcRenderer.invoke('save-session-history', obj),
|
||||
|
||||
checkUpdateManual: () => ipcRenderer.invoke('check-update-manual')
|
||||
checkUpdateManual: () => ipcRenderer.invoke('check-update-manual'),
|
||||
onUpdateProgress: (cb) => ipcRenderer.on('update-progress', (_, data) => cb(data))
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
BIN
renderer/levelup.ogg
Normal file
BIN
renderer/levelup.ogg
Normal file
Binary file not shown.
56
tools/release.sh
Executable file
56
tools/release.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# ---------- Token ----------
|
||||
TOKEN="${GITEA_TOKEN:-}"
|
||||
if [ -z "$TOKEN" ] && [ -f ".gitea-token" ]; then
|
||||
TOKEN=$(tr -d '[:space:]' < .gitea-token)
|
||||
fi
|
||||
if [ -z "$TOKEN" ]; then
|
||||
read -rsp "Token Gitea : " TOKEN
|
||||
echo
|
||||
fi
|
||||
|
||||
# ---------- Version ----------
|
||||
CURRENT=$(node -p "require('./package.json').version")
|
||||
if [ -n "${1:-}" ]; then
|
||||
VERSION="$1"
|
||||
else
|
||||
echo "Version actuelle : v$CURRENT"
|
||||
read -rp "Nouvelle version [patch / minor / major / X.Y.Z] : " VERSION
|
||||
fi
|
||||
|
||||
npm version "$VERSION" --no-git-tag-version --silent
|
||||
NEW=$(node -p "require('./package.json').version")
|
||||
echo "→ v$NEW"
|
||||
|
||||
# ---------- Build ----------
|
||||
echo ""
|
||||
echo "Nettoyage des anciens binaires..."
|
||||
find dist -maxdepth 1 \( -name "*.AppImage" -o -name "*.exe" -o -name "*.blockmap" \) -delete 2>/dev/null || true
|
||||
|
||||
echo "Build Linux (AppImage)..."
|
||||
npm run dist --silent
|
||||
|
||||
if command -v wine &>/dev/null; then
|
||||
echo "Build Windows (exe)..."
|
||||
npm run dist:win --silent
|
||||
else
|
||||
echo "(Wine non trouvé — build Windows ignoré)"
|
||||
fi
|
||||
|
||||
# ---------- Release Gitea ----------
|
||||
echo ""
|
||||
GITEA_TOKEN="$TOKEN" node tools/release.js
|
||||
|
||||
# ---------- Git ----------
|
||||
git add package.json package-lock.json
|
||||
git commit -m "chore: release v$NEW" --quiet
|
||||
git remote set-url origin "https://shamiiow:${TOKEN}@git.shamiiow.com/shamiiow/farm-tracker-sao.git"
|
||||
git push --quiet
|
||||
git remote set-url origin "https://git.shamiiow.com/shamiiow/farm-tracker-sao.git"
|
||||
|
||||
echo ""
|
||||
echo "Release v$NEW publiée."
|
||||
Reference in New Issue
Block a user