wiki-plugin-allyabase 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/allyabase.js +55 -0
- package/package.json +1 -1
- package/server/server.js +51 -0
package/client/allyabase.js
CHANGED
|
@@ -405,8 +405,21 @@ function emit($item, item) {
|
|
|
405
405
|
launchButton.style.padding = '10px 20px';
|
|
406
406
|
launchButton.style.marginBottom = '15px';
|
|
407
407
|
launchButton.style.cursor = 'pointer';
|
|
408
|
+
launchButton.style.marginRight = '10px';
|
|
408
409
|
container.appendChild(launchButton);
|
|
409
410
|
|
|
411
|
+
// Add update button
|
|
412
|
+
const updateButton = document.createElement('button');
|
|
413
|
+
updateButton.textContent = 'Check for Updates';
|
|
414
|
+
updateButton.style.padding = '10px 20px';
|
|
415
|
+
updateButton.style.marginBottom = '15px';
|
|
416
|
+
updateButton.style.cursor = 'pointer';
|
|
417
|
+
updateButton.style.backgroundColor = '#0066cc';
|
|
418
|
+
updateButton.style.color = 'white';
|
|
419
|
+
updateButton.style.border = 'none';
|
|
420
|
+
updateButton.style.borderRadius = '4px';
|
|
421
|
+
container.appendChild(updateButton);
|
|
422
|
+
|
|
410
423
|
// Add status container
|
|
411
424
|
const statusContainer = document.createElement('div');
|
|
412
425
|
statusContainer.id = 'allyabase-status';
|
|
@@ -652,6 +665,48 @@ function emit($item, item) {
|
|
|
652
665
|
}
|
|
653
666
|
});
|
|
654
667
|
|
|
668
|
+
// Update button click handler
|
|
669
|
+
updateButton.addEventListener('click', async () => {
|
|
670
|
+
updateButton.disabled = true;
|
|
671
|
+
updateButton.textContent = 'Updating...';
|
|
672
|
+
|
|
673
|
+
try {
|
|
674
|
+
const response = await post('/plugin/allyabase/update');
|
|
675
|
+
const result = await response.json();
|
|
676
|
+
|
|
677
|
+
const msg = document.createElement('div');
|
|
678
|
+
msg.style.marginTop = '10px';
|
|
679
|
+
msg.style.fontSize = '12px';
|
|
680
|
+
msg.style.fontFamily = 'monospace';
|
|
681
|
+
|
|
682
|
+
if (result.success) {
|
|
683
|
+
const failed = Object.entries(result.results).filter(([, v]) => v.startsWith('error'));
|
|
684
|
+
if (failed.length === 0) {
|
|
685
|
+
msg.style.color = 'green';
|
|
686
|
+
msg.textContent = '✓ All services updated and restarted.';
|
|
687
|
+
} else {
|
|
688
|
+
msg.style.color = 'orange';
|
|
689
|
+
msg.innerHTML = `⚠️ Updated with errors:<br>` +
|
|
690
|
+
failed.map(([svc, err]) => `${svc}: ${err}`).join('<br>');
|
|
691
|
+
}
|
|
692
|
+
} else {
|
|
693
|
+
msg.style.color = 'red';
|
|
694
|
+
msg.textContent = `✗ Update failed: ${result.error}`;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
container.insertBefore(msg, statusContainer);
|
|
698
|
+
setTimeout(() => {
|
|
699
|
+
msg.remove();
|
|
700
|
+
updateStatus();
|
|
701
|
+
}, 5000);
|
|
702
|
+
} catch (err) {
|
|
703
|
+
console.error('[allyabase] update error:', err);
|
|
704
|
+
} finally {
|
|
705
|
+
updateButton.disabled = false;
|
|
706
|
+
updateButton.textContent = 'Check for Updates';
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
|
|
655
710
|
// Initial status check
|
|
656
711
|
updateStatus();
|
|
657
712
|
|
package/package.json
CHANGED
package/server/server.js
CHANGED
|
@@ -768,6 +768,57 @@ async function startServer(params) {
|
|
|
768
768
|
}
|
|
769
769
|
});
|
|
770
770
|
|
|
771
|
+
// Endpoint to update all allyabase services (git pull + npm install + pm2 restart)
|
|
772
|
+
app.post('/plugin/allyabase/update', owner, async function(req, res) {
|
|
773
|
+
const services = [
|
|
774
|
+
'addie', 'aretha', 'bdo', 'continuebee', 'covenant',
|
|
775
|
+
'dolores', 'fount', 'joan', 'julia', 'minnie', 'pref', 'prof', 'sanora'
|
|
776
|
+
];
|
|
777
|
+
const buildDir = '/var/lib/allyabase';
|
|
778
|
+
const results = {};
|
|
779
|
+
|
|
780
|
+
for (const service of services) {
|
|
781
|
+
const serviceDir = `${buildDir}/${service}`;
|
|
782
|
+
try {
|
|
783
|
+
await new Promise((resolve, reject) => {
|
|
784
|
+
exec(
|
|
785
|
+
`git -C "${serviceDir}" pull --ff-only && npm install --prefix "${serviceDir}/src/server/node" --silent`,
|
|
786
|
+
{ timeout: 60000 },
|
|
787
|
+
(err, stdout, stderr) => {
|
|
788
|
+
if (err) return reject(err);
|
|
789
|
+
resolve(stdout);
|
|
790
|
+
}
|
|
791
|
+
);
|
|
792
|
+
});
|
|
793
|
+
results[service] = 'updated';
|
|
794
|
+
} catch (err) {
|
|
795
|
+
results[service] = `error: ${err.message}`;
|
|
796
|
+
console.error(`[allyabase] update ${service}:`, err.message);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// Restart all services via pm2
|
|
801
|
+
let restartOutput = '';
|
|
802
|
+
try {
|
|
803
|
+
await new Promise((resolve, reject) => {
|
|
804
|
+
exec(
|
|
805
|
+
`cd "${buildDir}" && ./node_modules/.bin/pm2 restart ecosystem.config.js`,
|
|
806
|
+
{ timeout: 30000 },
|
|
807
|
+
(err, stdout) => {
|
|
808
|
+
if (err) return reject(err);
|
|
809
|
+
restartOutput = stdout;
|
|
810
|
+
resolve();
|
|
811
|
+
}
|
|
812
|
+
);
|
|
813
|
+
});
|
|
814
|
+
} catch (err) {
|
|
815
|
+
console.error('[allyabase] pm2 restart error:', err.message);
|
|
816
|
+
restartOutput = `restart error: ${err.message}`;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
res.send({ success: true, results, restart: restartOutput.trim() });
|
|
820
|
+
});
|
|
821
|
+
|
|
771
822
|
// Endpoint to get healthcheck
|
|
772
823
|
app.get('/plugin/allyabase/healthcheck', async function(req, res) {
|
|
773
824
|
try {
|