Add check for outdated packages, and show on the help screen.
This commit is contained in:
parent
9ef5c6c67e
commit
20816d509d
@ -1932,12 +1932,14 @@ part/quit messages where we don't load previews (adds a blank line otherwise) */
|
||||
content: "\f253"; /* https://fontawesome.com/icons/hourglass-end?style=solid */
|
||||
}
|
||||
|
||||
#version-checker.new-version {
|
||||
#version-checker.new-version,
|
||||
#version-checker.new-packages {
|
||||
color: #8a6d3b;
|
||||
background-color: #fcf8e3;
|
||||
}
|
||||
|
||||
#version-checker.new-version::before {
|
||||
#version-checker.new-version::before,
|
||||
#version-checker.new-packages::before {
|
||||
content: "\f164"; /* https://fontawesome.com/icons/thumbs-up?style=solid */
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@ socket.on("changelog", function(data) {
|
||||
|
||||
if (data.latest) {
|
||||
status = "new-version";
|
||||
} else if (data.packages) {
|
||||
status = "new-packages";
|
||||
} else if (data.current.changelog) {
|
||||
status = "up-to-date";
|
||||
} else {
|
||||
|
@ -12,6 +12,12 @@
|
||||
Read more on GitHub
|
||||
</a>
|
||||
</p>
|
||||
{{else equal status "new-packages"}}
|
||||
<p>
|
||||
The Lounge is up to date, but there are out of date packages
|
||||
|
||||
Run <code>thelounge upgrade</code> on the server to upgrade packages.
|
||||
</p>
|
||||
{{else equal status "up-to-date"}}
|
||||
<p>
|
||||
The Lounge is up to date!
|
||||
|
@ -60,6 +60,7 @@ if (!Helper.config.public && !Helper.config.ldap.enable) {
|
||||
require("./install");
|
||||
require("./uninstall");
|
||||
require("./upgrade");
|
||||
require("./outdated");
|
||||
|
||||
// `parse` expects to be passed `process.argv`, but we need to remove to give it
|
||||
// a version of `argv` that does not contain options already parsed by
|
||||
|
27
src/command-line/outdated.js
Normal file
27
src/command-line/outdated.js
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
const program = require("commander");
|
||||
const Utils = require("./utils");
|
||||
const packageManager = require("../plugins/packages");
|
||||
const log = require("../log");
|
||||
|
||||
program
|
||||
.command("outdated")
|
||||
.description("Check for any outdated packages")
|
||||
.on("--help", Utils.extraHelp)
|
||||
.action(async () => {
|
||||
log.info("Checking for outdated packages");
|
||||
|
||||
await packageManager
|
||||
.outdated(0)
|
||||
.then((outdated) => {
|
||||
if (outdated) {
|
||||
log.info("There are outdated packages");
|
||||
} else {
|
||||
log.info("No outdated packages");
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
log.error("Error finding outdated packages.");
|
||||
});
|
||||
});
|
@ -7,13 +7,22 @@ const Helper = require("../../helper");
|
||||
const themes = require("./themes");
|
||||
const packageMap = new Map();
|
||||
const inputs = require("../inputs");
|
||||
const fs = require("fs");
|
||||
const Utils = require("../../command-line/utils");
|
||||
|
||||
const stylesheets = [];
|
||||
|
||||
const TIME_TO_LIVE = 15 * 60 * 1000; // 15 minutes, in milliseconds
|
||||
|
||||
const cache = {
|
||||
outdated: undefined,
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getStylesheets,
|
||||
getPackage,
|
||||
loadPackages,
|
||||
outdated,
|
||||
};
|
||||
|
||||
const packageApis = function(packageName) {
|
||||
@ -99,3 +108,46 @@ function loadPackages() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function outdated(cacheTimeout = TIME_TO_LIVE) {
|
||||
if (cache.outdated !== undefined) {
|
||||
return cache.outdated;
|
||||
}
|
||||
|
||||
// Get paths to the location of packages directory
|
||||
const packagesPath = Helper.getPackagesPath();
|
||||
const packagesConfig = path.join(packagesPath, "package.json");
|
||||
const argsList = [
|
||||
"outdated",
|
||||
"--latest",
|
||||
"--json",
|
||||
"--production",
|
||||
"--ignore-scripts",
|
||||
"--non-interactive",
|
||||
"--cwd",
|
||||
packagesPath,
|
||||
];
|
||||
|
||||
// Check if the configuration file exists
|
||||
if (!fs.existsSync(packagesConfig)) {
|
||||
log.warn("There are no packages installed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we get an error from calling outdated and the code isn't 0, then there are no outdated packages
|
||||
await Utils.executeYarnCommand(...argsList)
|
||||
.then(() => updateOutdated(false))
|
||||
.catch((code) => updateOutdated(code !== 0));
|
||||
|
||||
if (cacheTimeout > 0) {
|
||||
setTimeout(() => {
|
||||
delete cache.outdated;
|
||||
}, cacheTimeout);
|
||||
}
|
||||
|
||||
return cache.outdated;
|
||||
}
|
||||
|
||||
function updateOutdated(outdatedPackages) {
|
||||
cache.outdated = outdatedPackages;
|
||||
}
|
||||
|
@ -454,9 +454,13 @@ function initializeClient(socket, client, token, lastMessage) {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("changelog", async () => {
|
||||
const data = await changelog.fetch();
|
||||
socket.emit("changelog", data);
|
||||
socket.on("changelog", () => {
|
||||
Promise.all([changelog.fetch(), packages.outdated()]).then(
|
||||
([changelogData, packageUpdate]) => {
|
||||
changelogData.packages = packageUpdate;
|
||||
socket.emit("changelog", changelogData);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
socket.on("msg:preview:toggle", (data) => {
|
||||
|
Loading…
Reference in New Issue
Block a user