mirror of
https://github.com/thelounge/thelounge
synced 2024-11-10 06:34:21 +00:00
Add version support for packages.
This commit is contained in:
parent
7bf4f68ff8
commit
86e570efb2
3 changed files with 29 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
const log = require("../log");
|
||||
const colors = require("chalk");
|
||||
const semver = require("semver");
|
||||
const program = require("commander");
|
||||
const Helper = require("../helper");
|
||||
const Utils = require("./utils");
|
||||
|
@ -40,6 +41,21 @@ program
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
if (
|
||||
json.thelounge.supports &&
|
||||
!semver.satisfies(Helper.getVersionNumber(), json.thelounge.supports)
|
||||
) {
|
||||
log.error(
|
||||
`${colors.red(
|
||||
json.name + " v" + json.version
|
||||
)} does not support The Lounge v${Helper.getVersionNumber()}. Supported version(s): ${
|
||||
json.thelounge.supports
|
||||
}`
|
||||
);
|
||||
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
log.info(`Installing ${colors.green(json.name + " v" + json.version)}...`);
|
||||
|
||||
return Utils.executeYarnCommand("add", "--exact", `${json.name}@${json.version}`)
|
||||
|
|
|
@ -36,6 +36,7 @@ const Helper = {
|
|||
setHome,
|
||||
getVersion,
|
||||
getVersionCacheBust,
|
||||
getVersionNumber,
|
||||
getGitCommit,
|
||||
ip2hex,
|
||||
mergeConfig,
|
||||
|
@ -60,6 +61,10 @@ function getVersion() {
|
|||
return gitCommit ? `source (${gitCommit} / ${version})` : version;
|
||||
}
|
||||
|
||||
function getVersionNumber() {
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
let _gitCommit;
|
||||
|
||||
function getGitCommit() {
|
||||
|
|
|
@ -4,6 +4,7 @@ const _ = require("lodash");
|
|||
const log = require("../../log");
|
||||
const colors = require("chalk");
|
||||
const path = require("path");
|
||||
const semver = require("semver");
|
||||
const Helper = require("../../helper");
|
||||
const themes = require("./themes");
|
||||
const packageMap = new Map();
|
||||
|
@ -93,6 +94,13 @@ function loadPackage(packageName) {
|
|||
throw "'thelounge' is not present in package.json";
|
||||
}
|
||||
|
||||
if (
|
||||
packageInfo.thelounge.supports &&
|
||||
!semver.satisfies(Helper.getVersionNumber(), packageInfo.thelounge.supports)
|
||||
) {
|
||||
throw `v${packageInfo.version} does not support this version of The Lounge. Supports: ${packageInfo.thelounge.supports}`;
|
||||
}
|
||||
|
||||
packageFile = require(packagePath);
|
||||
} catch (e) {
|
||||
log.error(`Package ${colors.bold(packageName)} could not be loaded: ${colors.red(e)}`);
|
||||
|
|
Loading…
Reference in a new issue