Display severity of current outdated version
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { execSync } from 'node:child_process';
|
import { execSync } from 'node:child_process';
|
||||||
|
|
||||||
import { checkPendingMigrations } from './migrations.mjs';
|
import { checkPendingMigrations } from './migrations.mjs';
|
||||||
|
|
||||||
function runGitCommand(command) {
|
function runGitCommand(command) {
|
||||||
@@ -15,7 +16,8 @@ function checkMakerkitVersion() {
|
|||||||
|
|
||||||
if (fetchResult === null) {
|
if (fetchResult === null) {
|
||||||
console.info(
|
console.info(
|
||||||
'\x1b[33m%s\x1b[0m', "⚠️ You have not setup 'upstream'. Please set up the upstream remote so you can update your Makerkit version.",
|
'\x1b[33m%s\x1b[0m',
|
||||||
|
"⚠️ You have not setup 'upstream'. Please set up the upstream remote so you can update your Makerkit version.",
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -33,24 +35,58 @@ function checkMakerkitVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const count = parseInt(behindCount, 10);
|
const count = parseInt(behindCount, 10);
|
||||||
|
const { severity } = getSeveriyLevel(count);
|
||||||
|
|
||||||
if (count > 0) {
|
if (severity.critical) {
|
||||||
console.log('\x1b[33m%s\x1b[0m', '⚠️ Your Makerkit version is outdated!');
|
// error emoji: ❌
|
||||||
|
console.log(
|
||||||
|
'\x1b[31m%s\x1b[0m',
|
||||||
|
'❌ Your Makerkit version is outdated. Please update to the latest version.',
|
||||||
|
);
|
||||||
|
} else if (severity.warning) {
|
||||||
console.log(
|
console.log(
|
||||||
'\x1b[33m%s\x1b[0m',
|
'\x1b[33m%s\x1b[0m',
|
||||||
`You are ${count} commit(s) behind the latest version.`,
|
'⚠️ Your Makerkit version is outdated! Best to update to the latest version.',
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(
|
|
||||||
'\x1b[33m%s\x1b[0m',
|
|
||||||
'Please consider updating to the latest version for the best experience.',
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('\x1b[36m%s\x1b[0m', 'To update, run: git pull upstream main');
|
|
||||||
} else {
|
} else {
|
||||||
console.log('\x1b[32m%s\x1b[0m', '✅ Your Makerkit version is up to date!');
|
console.log('\x1b[32m%s\x1b[0m', '✅ Your Makerkit version is up to date!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
logInstructions(count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function logInstructions(count) {
|
||||||
|
console.log(
|
||||||
|
'\x1b[33m%s\x1b[0m',
|
||||||
|
`You are ${count} commit(s) behind the latest version.`,
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
'\x1b[33m%s\x1b[0m',
|
||||||
|
'Please consider updating to the latest version for bug fixes and optimizations that your version does not have.',
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('\x1b[36m%s\x1b[0m', 'To update, run: git pull upstream main');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSeveriyLevel(count) {
|
||||||
|
if (count > 5) {
|
||||||
|
return {
|
||||||
|
severity: 'critical',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
return {
|
||||||
|
severity: 'warning',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
severity: 'success',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMakerkitVersion();
|
checkMakerkitVersion();
|
||||||
|
|||||||
Reference in New Issue
Block a user