Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2760ab4897 | ||
|
|
6e306a9bed | ||
|
|
13a5ede027 | ||
|
|
2a66dd7174 |
70
main.js
70
main.js
@@ -103,6 +103,70 @@ function resolveAssetUrl(release) {
|
|||||||
return asset ? asset.browser_download_url : null;
|
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 current = process.env.APPIMAGE;
|
||||||
|
if (current) { fs.copyFileSync(tmpPath, current); fs.unlinkSync(tmpPath); app.relaunch(); }
|
||||||
|
else app.relaunch({ execPath: tmpPath });
|
||||||
|
app.exit(0);
|
||||||
|
} 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) {
|
async function showUpdateDialog(version, downloadUrl, ignoreSnooze = false) {
|
||||||
const current = app.getVersion();
|
const current = app.getVersion();
|
||||||
if (!isNewerVersion(version, current)) return false;
|
if (!isNewerVersion(version, current)) return false;
|
||||||
@@ -117,14 +181,14 @@ async function showUpdateDialog(version, downloadUrl, ignoreSnooze = false) {
|
|||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'Mise à jour disponible',
|
title: 'Mise à jour disponible',
|
||||||
message: `Version ${version} disponible`,
|
message: `Version ${version} disponible`,
|
||||||
detail: `Version actuelle : ${current}`,
|
detail: `Version actuelle : ${current}\nL'application se relancera automatiquement après la mise à jour.`,
|
||||||
buttons: ['Télécharger', 'Me rappeler dans...'],
|
buttons: ['Installer maintenant', 'Me rappeler dans...'],
|
||||||
defaultId: 0,
|
defaultId: 0,
|
||||||
cancelId: 1
|
cancelId: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response === 0) {
|
if (response === 0) {
|
||||||
shell.openExternal(downloadUrl);
|
downloadAndInstall(downloadUrl, version);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "farm-tracker",
|
"name": "farm-tracker",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "farm-tracker",
|
"name": "farm-tracker",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dist": "^0.1.2",
|
"dist": "^0.1.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "farm-tracker",
|
"name": "farm-tracker",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"description": "Suivi de loot Minecraft en direct, avec sauvegarde automatique des stats et des chances de drop.",
|
"description": "Suivi de loot Minecraft en direct, avec sauvegarde automatique des stats et des chances de drop.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -24,5 +24,6 @@ contextBridge.exposeInMainWorld('api', {
|
|||||||
loadSessionHistory: () => ipcRenderer.invoke('load-session-history'),
|
loadSessionHistory: () => ipcRenderer.invoke('load-session-history'),
|
||||||
saveSessionHistory: (obj) => ipcRenderer.invoke('save-session-history', obj),
|
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))
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -291,6 +291,14 @@
|
|||||||
.sessions-table td.dim{font-size:12px;color:var(--text-dim);}
|
.sessions-table td.dim{font-size:12px;color:var(--text-dim);}
|
||||||
.hist-empty{padding:40px 0;text-align:center;color:var(--text-dim);font-size:14px;line-height:1.8;}
|
.hist-empty{padding:40px 0;text-align:center;color:var(--text-dim);font-size:14px;line-height:1.8;}
|
||||||
@media(max-width:760px){.charts-2col{grid-template-columns:1fr;}}
|
@media(max-width:760px){.charts-2col{grid-template-columns:1fr;}}
|
||||||
|
|
||||||
|
/* ---------- Graphes en direct ---------- */
|
||||||
|
.charts-3col{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;}
|
||||||
|
@media(max-width:760px){.charts-3col{grid-template-columns:1fr;}}
|
||||||
|
.live-chart-header{display:flex;justify-content:space-between;align-items:baseline;
|
||||||
|
font-family:var(--font-mono);font-size:11px;margin-bottom:5px;}
|
||||||
|
.live-chart-header .chart-label{color:var(--text-dim);}
|
||||||
|
.live-chart-header .chart-val{font-size:12px;font-weight:600;}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -394,6 +402,38 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="economy-note">Le jeu ne transmet pas les ventes : fixe un prix par item dans le tableau « Loot » ci-dessous. Tes prix sont sauvegardés automatiquement.</p>
|
<p class="economy-note">Le jeu ne transmet pas les ventes : fixe un prix par item dans le tableau « Loot » ci-dessous. Tes prix sont sauvegardés automatiquement.</p>
|
||||||
|
|
||||||
|
<div class="panel" id="liveChartsPanel" hidden>
|
||||||
|
<div class="panel-head-row">
|
||||||
|
<h2>Progression dans le temps <span class="muted">— snapshot toutes les 30s</span></h2>
|
||||||
|
</div>
|
||||||
|
<div class="charts-3col">
|
||||||
|
<div>
|
||||||
|
<div class="live-chart-header">
|
||||||
|
<span class="chart-label">Kills / min</span>
|
||||||
|
<span class="chart-val" id="liveChartKillsVal" style="color:var(--moss)">—</span>
|
||||||
|
</div>
|
||||||
|
<div class="chart-wrap" id="liveChartKills"></div>
|
||||||
|
<div class="chart-label-row" id="liveChartKillsTime"><span></span><span></span></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="live-chart-header">
|
||||||
|
<span class="chart-label">XP / min</span>
|
||||||
|
<span class="chart-val" id="liveChartExpVal" style="color:var(--gold)">—</span>
|
||||||
|
</div>
|
||||||
|
<div class="chart-wrap" id="liveChartExp"></div>
|
||||||
|
<div class="chart-label-row" id="liveChartExpTime"><span></span><span></span></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="live-chart-header">
|
||||||
|
<span class="chart-label">Cols / min</span>
|
||||||
|
<span class="chart-val" id="liveChartColsVal" style="color:var(--copper)">—</span>
|
||||||
|
</div>
|
||||||
|
<div class="chart-wrap" id="liveChartCols"></div>
|
||||||
|
<div class="chart-label-row" id="liveChartColsTime"><span></span><span></span></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="section-toolbar">
|
<div class="section-toolbar">
|
||||||
<h2>Stats de farm — cette session</h2>
|
<h2>Stats de farm — cette session</h2>
|
||||||
</div>
|
</div>
|
||||||
@@ -875,7 +915,9 @@
|
|||||||
itemRows: new Map(),
|
itemRows: new Map(),
|
||||||
mobFilter: '',
|
mobFilter: '',
|
||||||
itemFilter: '',
|
itemFilter: '',
|
||||||
selectedDropMob: null
|
selectedDropMob: null,
|
||||||
|
timeline: [],
|
||||||
|
timelineTimer: null
|
||||||
};
|
};
|
||||||
|
|
||||||
// Retourne les stats à afficher : communauté si dispo et activé, sinon perso
|
// Retourne les stats à afficher : communauté si dispo et activé, sinon perso
|
||||||
@@ -936,6 +978,8 @@
|
|||||||
renderAll();
|
renderAll();
|
||||||
startPolling();
|
startPolling();
|
||||||
startClock();
|
startClock();
|
||||||
|
if (resetCounters) state.timeline = [];
|
||||||
|
startTimelineTimer();
|
||||||
persistAppState(true);
|
persistAppState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -945,6 +989,7 @@
|
|||||||
state.paused = true;
|
state.paused = true;
|
||||||
state.pauseStartedAt = Date.now();
|
state.pauseStartedAt = Date.now();
|
||||||
stopPolling();
|
stopPolling();
|
||||||
|
stopTimelineTimer();
|
||||||
setStatus('paused', 'En pause');
|
setStatus('paused', 'En pause');
|
||||||
pauseBtn.textContent = '▶ Reprendre';
|
pauseBtn.textContent = '▶ Reprendre';
|
||||||
flashMessage('Suivi en pause — le chrono et les cadences sont gelés.');
|
flashMessage('Suivi en pause — le chrono et les cadences sont gelés.');
|
||||||
@@ -958,6 +1003,7 @@
|
|||||||
setStatus('live', 'En direct — ' + state.logPath);
|
setStatus('live', 'En direct — ' + state.logPath);
|
||||||
pauseBtn.textContent = '⏸ Pause';
|
pauseBtn.textContent = '⏸ Pause';
|
||||||
startPolling();
|
startPolling();
|
||||||
|
startTimelineTimer();
|
||||||
flashMessage('Suivi repris.');
|
flashMessage('Suivi repris.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -977,9 +1023,13 @@
|
|||||||
state.pausedAccum = 0;
|
state.pausedAccum = 0;
|
||||||
if (state.paused) state.pauseStartedAt = Date.now();
|
if (state.paused) state.pauseStartedAt = Date.now();
|
||||||
state.lastEventAt = null;
|
state.lastEventAt = null;
|
||||||
|
state.timeline = [];
|
||||||
const sizeRes = await window.api.getFileSize(state.logPath);
|
const sizeRes = await window.api.getFileSize(state.logPath);
|
||||||
state.lastSize = sizeRes.size || 0;
|
state.lastSize = sizeRes.size || 0;
|
||||||
state.carry = '';
|
state.carry = '';
|
||||||
|
$('liveChartsPanel').hidden = true;
|
||||||
|
stopTimelineTimer();
|
||||||
|
if (!state.paused) startTimelineTimer();
|
||||||
renderAll();
|
renderAll();
|
||||||
persistAppState(true);
|
persistAppState(true);
|
||||||
flashMessage('Session réinitialisée (les chances de drop ne sont pas affectées).');
|
flashMessage('Session réinitialisée (les chances de drop ne sont pas affectées).');
|
||||||
@@ -1222,6 +1272,83 @@
|
|||||||
updateClock();
|
updateClock();
|
||||||
}
|
}
|
||||||
function pad(n){ return String(n).padStart(2,'0'); }
|
function pad(n){ return String(n).padStart(2,'0'); }
|
||||||
|
|
||||||
|
// ---------- Timeline / graphes en direct ----------
|
||||||
|
|
||||||
|
function snapshotTimeline(){
|
||||||
|
if (!state.sessionStart || state.paused) return;
|
||||||
|
const totalKills = sumValues(state.mobCounts);
|
||||||
|
state.timeline.push({ t: Date.now(), kills: totalKills, exp: state.expTotal, cols: state.killCols });
|
||||||
|
if (state.timeline.length > 180) state.timeline.shift();
|
||||||
|
renderLiveCharts();
|
||||||
|
}
|
||||||
|
function startTimelineTimer(){
|
||||||
|
stopTimelineTimer();
|
||||||
|
snapshotTimeline();
|
||||||
|
state.timelineTimer = setInterval(snapshotTimeline, 30000);
|
||||||
|
}
|
||||||
|
function stopTimelineTimer(){
|
||||||
|
if (state.timelineTimer){ clearInterval(state.timelineTimer); state.timelineTimer = null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLiveChart(container, rates, colorHex){
|
||||||
|
if (rates.length < 2){
|
||||||
|
container.innerHTML = '<p class="chart-empty" style="font-size:11px;padding:6px 0;">En attente…</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const W=400,H=55,padL=4,padR=4,padT=6,padB=4;
|
||||||
|
const plotW=W-padL-padR,plotH=H-padT-padB,n=rates.length;
|
||||||
|
const maxV=Math.max(...rates,0.01);
|
||||||
|
const xs=rates.map((_,i)=>padL+(n===1?plotW/2:(i/(n-1))*plotW));
|
||||||
|
const ys=rates.map(v=>padT+plotH-(Math.max(0,v)/maxV)*plotH);
|
||||||
|
const linePath=xs.map((x,i)=>(i===0?'M':'L')+x.toFixed(1)+','+ys[i].toFixed(1)).join(' ');
|
||||||
|
const areaPath=linePath+' L'+xs[n-1].toFixed(1)+','+(padT+plotH)+' L'+xs[0].toFixed(1)+','+(padT+plotH)+' Z';
|
||||||
|
const grid=[0.5,1.0].map(pct=>{
|
||||||
|
const y=(padT+plotH*(1-pct)).toFixed(1);
|
||||||
|
return '<line x1="'+padL+'" y1="'+y+'" x2="'+(W-padR)+'" y2="'+y+'" stroke="#26301F" stroke-width="1"/>';
|
||||||
|
}).join('');
|
||||||
|
container.innerHTML=
|
||||||
|
'<svg viewBox="0 0 '+W+' '+H+'" width="100%" height="'+H+'" xmlns="http://www.w3.org/2000/svg">'
|
||||||
|
+grid
|
||||||
|
+'<path d="'+areaPath+'" fill="'+colorHex+'" fill-opacity="0.13"/>'
|
||||||
|
+'<path d="'+linePath+'" stroke="'+colorHex+'" fill="none" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/>'
|
||||||
|
+'</svg>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function fmtHHMM(ts){ const d=new Date(ts); return pad(d.getHours())+':'+pad(d.getMinutes()); }
|
||||||
|
|
||||||
|
function renderLiveCharts(){
|
||||||
|
const snap = state.timeline;
|
||||||
|
const panel = $('liveChartsPanel');
|
||||||
|
if (snap.length < 1){ panel.hidden = true; return; }
|
||||||
|
panel.hidden = false;
|
||||||
|
|
||||||
|
const killRates=[], expRates=[], colRates=[];
|
||||||
|
for (let i=1; i<snap.length; i++){
|
||||||
|
const dt=(snap[i].t-snap[i-1].t)/60000;
|
||||||
|
if (dt<=0) continue;
|
||||||
|
killRates.push((snap[i].kills-snap[i-1].kills)/dt);
|
||||||
|
expRates.push((snap[i].exp-snap[i-1].exp)/dt);
|
||||||
|
colRates.push((snap[i].cols-snap[i-1].cols)/dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawLiveChart($('liveChartKills'), killRates, '#6B8F5C');
|
||||||
|
drawLiveChart($('liveChartExp'), expRates, '#F2C94C');
|
||||||
|
drawLiveChart($('liveChartCols'), colRates, '#C97B4A');
|
||||||
|
|
||||||
|
const last = arr => arr.length ? arr[arr.length-1] : 0;
|
||||||
|
$('liveChartKillsVal').textContent = fmt(last(killRates),1)+'/min';
|
||||||
|
$('liveChartExpVal').textContent = fmt(last(expRates),1)+'/min';
|
||||||
|
$('liveChartColsVal').textContent = fmt(last(colRates),1)+'/min';
|
||||||
|
|
||||||
|
if (snap.length >= 2){
|
||||||
|
const t1=fmtHHMM(snap[0].t), t2=fmtHHMM(snap[snap.length-1].t);
|
||||||
|
['KillsTime','ExpTime','ColsTime'].forEach(id=>{
|
||||||
|
const el=$('liveChart'+id);
|
||||||
|
if (el) el.innerHTML='<span>'+t1+'</span><span>'+t2+'</span>';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
function sumValues(map){ let t=0; for (const v of map.values()) t+=v; return t; }
|
function sumValues(map){ let t=0; for (const v of map.values()) t+=v; return t; }
|
||||||
|
|
||||||
async function saveCurrentSessionToHistory(){
|
async function saveCurrentSessionToHistory(){
|
||||||
@@ -1875,6 +2002,35 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// ---------- Progression de mise à jour ----------
|
||||||
|
if (window.api && window.api.onUpdateProgress) {
|
||||||
|
const overlay = document.createElement('div');
|
||||||
|
overlay.id = 'updateOverlay';
|
||||||
|
overlay.style.cssText = 'position:fixed;inset:0;background:rgba(11,15,12,0.94);z-index:9999;display:none;align-items:center;justify-content:center;flex-direction:column;gap:18px;';
|
||||||
|
overlay.innerHTML =
|
||||||
|
'<div style="font-family:var(--font-mono);color:var(--text);font-size:14px;letter-spacing:.04em;" id="updateOverlayText">Téléchargement de la mise à jour…</div>' +
|
||||||
|
'<div style="width:320px;height:5px;background:var(--bg-panel-2);border:1px solid var(--border);">' +
|
||||||
|
'<div id="updateProgressBar" style="height:100%;background:var(--corrupt);width:0%;transition:width .25s;"></div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="font-family:var(--font-mono);color:var(--text-dim);font-size:12px;" id="updateOverlayPct">0%</div>';
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
|
||||||
|
window.api.onUpdateProgress(({ percent, status, error }) => {
|
||||||
|
const bar = document.getElementById('updateProgressBar');
|
||||||
|
const pct = document.getElementById('updateOverlayPct');
|
||||||
|
const txt = document.getElementById('updateOverlayText');
|
||||||
|
if (status === 'error') {
|
||||||
|
overlay.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
overlay.style.display = 'flex';
|
||||||
|
bar.style.width = percent + '%';
|
||||||
|
pct.textContent = percent + '%';
|
||||||
|
txt.textContent = status === 'installing' ? 'Installation… l\'application va redémarrer.' : 'Téléchargement de la mise à jour…';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ const VERSION = pkg.version;
|
|||||||
const TAG = `v${VERSION}`;
|
const TAG = `v${VERSION}`;
|
||||||
|
|
||||||
const DIST = path.join(__dirname, '..', 'dist');
|
const DIST = path.join(__dirname, '..', 'dist');
|
||||||
const ASSETS = fs.readdirSync(DIST).filter(f => f.endsWith('.AppImage') || (f.endsWith('.exe') && !f.endsWith('.blockmap')));
|
const ASSETS = fs.readdirSync(DIST).filter(f =>
|
||||||
|
(f.endsWith('.AppImage') || (f.endsWith('.exe') && !f.endsWith('.blockmap'))) && f.includes(VERSION)
|
||||||
|
);
|
||||||
|
|
||||||
if (!ASSETS.length) {
|
if (!ASSETS.length) {
|
||||||
console.error('Aucun binaire trouvé dans dist/. Lance "npm run dist" et "npm run dist:win" d\'abord.');
|
console.error('Aucun binaire trouvé dans dist/. Lance "npm run dist" et "npm run dist:win" d\'abord.');
|
||||||
|
|||||||
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