Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4079 from LiskHQ/4037-commander_install_upgrade_bug
Browse files Browse the repository at this point in the history
Lisk core upgrade to latest version using Lisk commander failed - Closes #4037
  • Loading branch information
shuse2 authored Aug 14, 2019
2 parents 123fcb4 + fa02dc0 commit 2202504
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 9 additions & 4 deletions commander/src/commands/core/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import * as fsExtra from 'fs-extra';
import Listr from 'listr';
import * as os from 'os';
import BaseCommand from '../../base';
import { NETWORK, SNAPSHOT_URL } from '../../utils/constants';
import { NETWORK, RELEASE_URL, SNAPSHOT_URL } from '../../utils/constants';
import {
createDirectory,
generateEnvConfig,
getDownloadedFileInfo,
getVersionToInstall,
isSupportedOS,
liskInstall,
liskLatestUrl,
liskSnapshotUrl,
validateNetwork,
validateNotARootUser,
Expand Down Expand Up @@ -65,6 +66,7 @@ interface Options {
readonly liskTarSHA256Url: string;
readonly liskTarUrl: string;
readonly version: string;
readonly latestUrl: string;
}

const validatePrerequisite = (installPath: string): void => {
Expand Down Expand Up @@ -103,14 +105,16 @@ const installOptions = async (
): Promise<Options> => {
const installPath = liskInstall(installationPath);
const installDir = `${installPath}/${name}/`;
const latestUrl = releaseUrl || liskLatestUrl(RELEASE_URL, network);

const installVersion: string = await getVersionToInstall(
network,
liskVersion,
releaseUrl,
);

const { version, liskTarUrl, liskTarSHA256Url } = await getReleaseInfo(
releaseUrl,
latestUrl,
network,
installVersion,
);
Expand All @@ -120,6 +124,7 @@ const installOptions = async (
version,
liskTarUrl,
liskTarSHA256Url,
latestUrl,
};
};

Expand Down Expand Up @@ -225,12 +230,12 @@ export default class InstallCommand extends BaseCommand {
{
title: 'Validate root user, flags, prerequisites',
task: async ctx => {
const { installDir, releaseUrl } = ctx.options;
const { installDir, latestUrl } = ctx.options;
validateNotARootUser();
validateFlags(flags as Flags);
validatePrerequisite(installDir);
if (liskVersion) {
await validateVersion(releaseUrl, liskVersion);
await validateVersion(latestUrl, liskVersion);
ctx.options.version = liskVersion;
}
},
Expand Down
6 changes: 5 additions & 1 deletion commander/src/commands/core/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import * as fsExtra from 'fs-extra';
import Listr from 'listr';
import semver from 'semver';
import BaseCommand from '../../base';
import { RELEASE_URL } from '../../utils/constants';
import { isCacheRunning, startCache, stopCache } from '../../utils/core/cache';
import {
backupLisk,
generateEnvConfig,
getDownloadedFileInfo,
getVersionToInstall,
liskLatestUrl,
upgradeLisk,
validateVersion,
} from '../../utils/core/commons';
Expand Down Expand Up @@ -125,7 +127,9 @@ export default class UpgradeCommand extends BaseCommand {
`Upgrade version:${upgradeVersion} should be greater than current version: ${currentVersion}`,
);
}
await validateVersion(releaseUrl, upgradeVersion);
const latestUrl = releaseUrl || liskLatestUrl(RELEASE_URL, network);

await validateVersion(latestUrl, upgradeVersion);
},
},
{
Expand Down

0 comments on commit 2202504

Please sign in to comment.