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 #198 from LiskHQ/197-move-the-lisk-core-config-dir…
Browse files Browse the repository at this point in the history
…ectory-to-src

Move the lisk core config directory to src
  • Loading branch information
sameersubudhi authored Nov 1, 2023
2 parents 18c5964 + 926ac70 commit 23d7bef
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 43 deletions.
2 changes: 1 addition & 1 deletion docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ OPTIONS
--auto-start-lisk-core-v4 Start Lisk Core v4 automatically. Defaults to false. When using this flag, kindly open another terminal window to stop Lisk Core v3.1.x for when the migrator prompts.
--snapshot-path=snapshot-path Local filepath to the state snapshot to run the migration offline. It could point either to a directory or a tarball (tar.gz).
--snapshot-path=snapshot-path Local filepath to the state snapshot to run the migration offline. It could either point to a directory or a tarball (tar.gz).
--snapshot-url=snapshot-url URL to download the state snapshot from. Use to run the migration offline. URL must end with tar.gz.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lisk-migrator",
"version": "2.0.0-rc.4",
"version": "2.0.0-rc.5",
"description": "A command-line tool for migrating the blockchain state to the latest protocol after a hard fork",
"author": "Lisk Foundation <[email protected]>, lightcurve GmbH <[email protected]>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -56,7 +56,8 @@
"/npm-shrinkwrap.json",
"/oclif.manifest.json",
"/dist",
"/docs"
"/docs",
"/config"
],
"dependencies": {
"@liskhq/lisk-api-client": "5.2.0",
Expand Down
18 changes: 12 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ class LiskMigrator extends Command {
description:
'Path where the Lisk Core v3.x instance is running. When not supplied, defaults to the default data directory for Lisk Core.',
}),
config: flagsParser.string({
char: 'c',
required: false,
description: 'Custom configuration file path for Lisk Core v3.1.x.',
}),
'snapshot-height': flagsParser.integer({
char: 's',
required: true,
env: 'SNAPSHOT_HEIGHT',
description:
'The height at which re-genesis block will be generated. Can be specified with SNAPSHOT_HEIGHT as well.',
}),
config: flagsParser.string({
char: 'c',
required: false,
description: 'Custom configuration file path for Lisk Core v3.1.x.',
}),
'auto-migrate-config': flagsParser.boolean({
required: false,
env: 'AUTO_MIGRATE_CONFIG',
Expand All @@ -127,7 +127,7 @@ class LiskMigrator extends Command {
required: false,
env: 'SNAPSHOT_PATH',
description:
'Local filepath to the state snapshot to run the migration offline. It could point either to a directory or a tarball (tar.gz).',
'Local filepath to the state snapshot to run the migration offline. It could either point to a directory or a tarball (tar.gz).',
dependsOn: ['network'],
exclusive: ['snapshot-url'],
}),
Expand All @@ -146,6 +146,12 @@ class LiskMigrator extends Command {
description:
"Network to be considered for the migration. Depends on the '--snapshot-path' flag.",
options: ['mainnet', 'testnet'],
exclusive: [
'lisk-core-v3-data-path',
'config',
'auto-migrate-config',
'auto-start-lisk-core-v4',
],
}),
};

Expand Down
6 changes: 3 additions & 3 deletions src/utils/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const copyLegacyDB = async (_this: Command) => {

export const getFinalConfigPath = async (outputDir: string, network: string) =>
(await exists(`${outputDir}/config.json`))
? outputDir
: path.resolve(__dirname, '../..', 'config', network);
? path.resolve(outputDir, 'config.json')
: path.resolve(__dirname, '../..', 'config', network, 'config.json');

export const validateStartCommandFlags = async (
allowedFlags: string[],
Expand Down Expand Up @@ -149,7 +149,7 @@ const resolveLiskCoreStartCommand = async (_this: Command, network: string, conf
const baseStartCommand = `lisk-core start --network ${network}`;

if (!isUserConfirmed) {
const defaultStartCommand = `${baseStartCommand} --config ${configPath}/config.json`;
const defaultStartCommand = `${baseStartCommand} --config ${configPath}`;
liskCoreStartCommand = defaultStartCommand;
return defaultStartCommand;
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/utils/node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ describe('Test getFinalConfigPath method', () => {
const outputDir = join(__dirname, '../../..', 'test/unit/fixtures/outputDir');
const configPath = await getFinalConfigPath(outputDir, network);

const expectedResponse = join(__dirname, '../../..', 'config/mainnet');
const expectedResponse = join(__dirname, '../../..', 'config/mainnet/config.json');
expect(configPath).toBe(expectedResponse);
});

it('should return correct config filepath when output directory exists', async () => {
const outputDir = join(__dirname, '../../..', 'config');
const configPath = await getFinalConfigPath(outputDir, network);

const expectedResponse = join(__dirname, '../../..', 'config/mainnet');
const expectedResponse = join(__dirname, '../../..', 'config/mainnet/config.json');
expect(configPath).toBe(expectedResponse);
});
});
Expand Down
60 changes: 31 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,9 @@
"@types/jest" "*"

"@types/jest@*":
version "29.5.6"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.6.tgz#f4cf7ef1b5b0bfc1aa744e41b24d9cc52533130b"
integrity sha512-/t9NnzkOpXb4Nfvg17ieHE6EeSjDS2SGSpNYfoLbUAeL/EOueU/RSdOWFpfQTXBEM7BguYW1XQ0EbM+6RlIh6w==
version "29.5.7"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.7.tgz#2c0dafe2715dd958a455bc10e2ec3e1ec47b5036"
integrity sha512-HLyetab6KVPSiF+7pFcUyMeLsx25LDNDemw9mGsJBkai/oouwrjTycocSDYopMEwFhN2Y4s9oPyOCZNofgSt2g==
dependencies:
expect "^29.0.0"
pretty-format "^29.0.0"
Expand Down Expand Up @@ -1223,11 +1223,11 @@
integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==

"@types/node@*":
version "20.8.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.8.tgz#adee050b422061ad5255fc38ff71b2bb96ea2a0e"
integrity sha512-YRsdVxq6OaLfmR9Hy816IMp33xOBjfyOgUd77ehqg96CFywxAPbDbXvAsuN2KVg2HOT8Eh6uAfU+l4WffwPVrQ==
version "20.8.10"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.10.tgz#a5448b895c753ae929c26ce85cab557c6d4a365e"
integrity sha512-TlgT8JntpcbmKUFzjhsyhGfP2fsiz1Mv56im6enJ905xG1DAYesxJaeSbGqQmAw8OWPdhyJGhGSQGKRNJ45u9w==
dependencies:
undici-types "~5.25.1"
undici-types "~5.26.4"

"@types/[email protected]":
version "11.11.6"
Expand All @@ -1240,9 +1240,11 @@
integrity sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==

"@types/node@^16 || ^18":
version "18.18.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.6.tgz#26da694f75cdb057750f49d099da5e3f3824cb3e"
integrity sha512-wf3Vz+jCmOQ2HV1YUJuCWdL64adYxumkrxtc+H1VUQlnQI04+5HtH+qZCOE21lBE7gIrt+CwX2Wv8Acrw5Ak6w==
version "18.18.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.8.tgz#2b285361f2357c8c8578ec86b5d097c7f464cfd6"
integrity sha512-OLGBaaK5V3VRBS1bAkMVP2/W9B+H8meUfl866OrMNQqt7wDgdpWPp5o6gmIc9pB+lIQHSq4ZL8ypeH1vPxcPaQ==
dependencies:
undici-types "~5.26.4"

"@types/parse-json@^4.0.0":
version "4.0.1"
Expand Down Expand Up @@ -1587,19 +1589,19 @@ acorn-walk@^7.1.1:
integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==

acorn-walk@^8.1.1:
version "8.2.0"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1"
integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==
version "8.3.0"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.0.tgz#2097665af50fd0cf7a2dfccd2b9368964e66540f"
integrity sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==

acorn@^7.1.1, acorn@^7.4.0:
version "7.4.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==

acorn@^8.2.4, acorn@^8.4.1, acorn@^8.9.0:
version "8.10.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5"
integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==
version "8.11.2"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.2.tgz#ca0d78b51895be5390a5903c5b3bdcdaf78ae40b"
integrity sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==

agent-base@6, agent-base@^6.0.2:
version "6.0.2"
Expand Down Expand Up @@ -2081,9 +2083,9 @@ camelcase@^6.2.0:
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==

caniuse-lite@^1.0.30001541:
version "1.0.30001553"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001553.tgz#e64e7dc8fd4885cd246bb476471420beb5e474b5"
integrity sha512-N0ttd6TrFfuqKNi+pMgWJTb9qrdJu4JSpgPFLe/lrD19ugC6fZgF0pUewRowDwzdDnb9V41mFcdlYgl/PyKf4A==
version "1.0.30001559"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001559.tgz#95a982440d3d314c471db68d02664fb7536c5a30"
integrity sha512-cPiMKZgqgkg5LY3/ntGeLFUpi6tzddBNS58A4tnTgQw1zON7u2sZMU7SzOeVH4tj20++9ggL+V6FDOFMTaFFYA==

cardinal@^2.1.1:
version "2.1.1"
Expand Down Expand Up @@ -2662,9 +2664,9 @@ [email protected]:
tweetnacl "1.x.x"

electron-to-chromium@^1.4.535:
version "1.4.565"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.565.tgz#205f3746a759ec3c43bce98b9eef5445f2721ea9"
integrity sha512-XbMoT6yIvg2xzcbs5hCADi0dXBh4//En3oFXmtPX+jiyyiCTiM9DGFT2SLottjpEs9Z8Mh8SqahbR96MaHfuSg==
version "1.4.572"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.572.tgz#ed9876658998138fe9e3aa47ecfa0bf914192a86"
integrity sha512-RlFobl4D3ieetbnR+2EpxdzFl9h0RAJkPK3pfiwMug2nhBin2ZCsGIAJWdpNniLz43sgXam/CgipOmvTA+rUiA==

emittery@^0.8.1:
version "0.8.1"
Expand Down Expand Up @@ -5830,9 +5832,9 @@ pump@^3.0.0:
once "^1.3.1"

punycode@^2.1.0, punycode@^2.1.1:
version "2.3.0"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f"
integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==
version "2.3.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5"
integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==

qqjs@^0.3.10:
version "0.3.11"
Expand Down Expand Up @@ -6948,10 +6950,10 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2"

undici-types@~5.25.1:
version "5.25.3"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.25.3.tgz#e044115914c85f0bcbb229f346ab739f064998c3"
integrity sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==
undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

unique-filename@^1.1.1:
version "1.1.1"
Expand Down

0 comments on commit 23d7bef

Please sign in to comment.