fix: Fix backup command getting version (#27780)
This broke when we changed the way RTS stores version information. This was never the right way to get the version in the `backup` command and this PR fixes it, by getting the version from `info.json`. Failure error: ``` Error: ENOENT: no such file or directory, open '/opt/appsmith/rts/version.js' ```
This commit is contained in:
parent
14e75be6d2
commit
cc2ced886a
|
|
@ -6,7 +6,7 @@ const utils = require('./utils');
|
|||
const shell = require('shelljs');
|
||||
|
||||
describe('Backup Tests', () => {
|
||||
|
||||
|
||||
test('Timestamp string in ISO format', () => {
|
||||
console.log(backup.getTimeStampInISO())
|
||||
expect(backup.getTimeStampInISO()).toMatch(/(\d{4})-(\d{2})-(\d{2})T(\d{2})\-(\d{2})\-(\d{2})\.(\d{3})Z/)
|
||||
|
|
@ -78,14 +78,8 @@ test('Test ln command generation', async () => {
|
|||
})
|
||||
|
||||
it('Checks for the current Appsmith Version.', async () => {
|
||||
|
||||
fsPromises.readFile = jest.fn().mockImplementation(async (a) =>
|
||||
`Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.VERSION = void 0;
|
||||
exports.VERSION = "v0.0.0-SNAPSHOT";`);
|
||||
const res = await utils.getCurrentAppsmithVersion()
|
||||
expect(res).toBe("v0.0.0-SNAPSHOT")
|
||||
console.log(res)
|
||||
fsPromises.readFile = jest.fn().mockImplementation(async () => `{"githubRef":"refs/tags/v1.2.3"}`);
|
||||
await expect(utils.getCurrentAppsmithVersion()).resolves.toBe("v1.2.3")
|
||||
})
|
||||
|
||||
test('If Encryption env values are being removed', () => {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const shell = require('shelljs');
|
|||
|
||||
const utils = require('./utils');
|
||||
const Constants = require('./constants');
|
||||
const {getCurrentAppsmithVersion} = require("./utils")
|
||||
|
||||
async function getBackupFileName() {
|
||||
|
||||
|
|
@ -101,8 +102,7 @@ async function restoreGitStorageArchive(restoreContentsPath, backupName) {
|
|||
}
|
||||
|
||||
async function checkRestoreVersionCompatability(restoreContentsPath) {
|
||||
const content = await fsPromises.readFile('/opt/appsmith/rts/version.js', { encoding: 'utf8' });
|
||||
const currentVersion = content.match(/\bexports\.VERSION\s*=\s*["']([^"]+)["']/)[1];
|
||||
const currentVersion = await getCurrentAppsmithVersion();
|
||||
const manifest_data = await fsPromises.readFile(restoreContentsPath + '/manifest.json', { encoding: 'utf8' });
|
||||
const manifest_json = JSON.parse(manifest_data);
|
||||
const restoreVersion = manifest_json["appsmithVersion"];
|
||||
|
|
|
|||
|
|
@ -98,8 +98,9 @@ async function getLastBackupErrorMailSentInMilliSec() {
|
|||
}
|
||||
|
||||
async function getCurrentAppsmithVersion() {
|
||||
const content = await fsPromises.readFile('/opt/appsmith/rts/version.js', { encoding: 'utf8' });
|
||||
return content.match(/\bexports\.VERSION\s*=\s*["']([^"]+)["']/)[1];
|
||||
const githubRef = JSON.parse(await fsPromises.readFile("/opt/appsmith/info.json", "utf8")).githubRef;
|
||||
// This will be of the form "refs/tags/v1.2.3".
|
||||
return githubRef.split("/").pop() ?? "";
|
||||
}
|
||||
|
||||
function preprocessMongoDBURI(uri /* string */) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user