LiskArchive / lisk-sdk

🔩 Lisk software development kit
https://lisk.com
Apache License 2.0
2.72k stars 457 forks source link

Make `--output` flag support all types of paths #9169

Closed mosmartin closed 6 months ago

mosmartin commented 7 months ago

What was the problem?

This PR resolves #9090

How was it solved?

Created the handleOutputFlag utility function. With this utiliy, it's now possible to generate output files with following commands

  1. ./bin/run generator export will generate a file with the default namespace name in the cwd.
  2. ./bin/run generator export --output . will generate a file with the default namespace name in the cwd.
  3. ./bin/run generator export --output ./ will generate a file with the default namespace name in the cwd.
  4. ./bin/run generator export --output test.json will generate the file with the provided filename in the cwd.
  5. ./bin/run generator export --output ~ will generate a file with the default namespace name in the user home dir.
  6. ./bin/run generator export --output ~/Desktop/ will generate a file with the default namespace name in the user desktop.
  7. ./bin/run generator export --output exports will generate a file with the default namespace name in the defined dir (exports) in cwd
  8. ./bin/run generator export --output /Users/johndoe/Public/test.json will generate the test.json file in the defined path

How was it tested?

Updated and added new tests

codecov[bot] commented 7 months ago

Codecov Report

Merging #9169 (f92b2c5) into release/6.1.0 (f641009) will decrease coverage by 0.01%. The diff coverage is 93.22%.

:exclamation: Current head f92b2c5 differs from pull request most recent head 4500f0b. Consider uploading reports for the commit 4500f0b to get more accurate results

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169/graphs/tree.svg?width=650&height=150&src=pr&token=2JhT7caf5x&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ)](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ) ```diff @@ Coverage Diff @@ ## release/6.1.0 #9169 +/- ## ================================================= - Coverage 84.65% 84.65% -0.01% ================================================= Files 655 656 +1 Lines 24113 24122 +9 Branches 3497 3497 ================================================= + Hits 20414 20420 +6 - Misses 3699 3702 +3 ``` | [Files](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ) | Coverage Δ | | |---|---|---| | [...der/src/bootstrapping/commands/generator/export.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy9ib290c3RyYXBwaW5nL2NvbW1hbmRzL2dlbmVyYXRvci9leHBvcnQudHM=) | `91.30% <100.00%> (-1.29%)` | :arrow_down: | | [commander/src/bootstrapping/commands/hash-onion.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy9ib290c3RyYXBwaW5nL2NvbW1hbmRzL2hhc2gtb25pb24udHM=) | `82.75% <100.00%> (-3.36%)` | :arrow_down: | | [...ommander/src/bootstrapping/commands/keys/create.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy9ib290c3RyYXBwaW5nL2NvbW1hbmRzL2tleXMvY3JlYXRlLnRz) | `100.00% <100.00%> (ø)` | | | [...ommander/src/bootstrapping/commands/keys/export.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy9ib290c3RyYXBwaW5nL2NvbW1hbmRzL2tleXMvZXhwb3J0LnRz) | `94.73% <100.00%> (-0.51%)` | :arrow_down: | | [...er/src/bootstrapping/commands/passphrase/create.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy9ib290c3RyYXBwaW5nL2NvbW1hbmRzL3Bhc3NwaHJhc2UvY3JlYXRlLnRz) | `100.00% <100.00%> (ø)` | | | [...r/src/bootstrapping/commands/passphrase/encrypt.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy9ib290c3RyYXBwaW5nL2NvbW1hbmRzL3Bhc3NwaHJhc2UvZW5jcnlwdC50cw==) | `100.00% <100.00%> (ø)` | | | [commander/src/utils/flags.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy91dGlscy9mbGFncy50cw==) | `100.00% <ø> (ø)` | | | [commander/src/utils/output.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy91dGlscy9vdXRwdXQudHM=) | `100.00% <100.00%> (ø)` | | | [...mander/src/bootstrapping/commands/config/create.ts](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ#diff-Y29tbWFuZGVyL3NyYy9ib290c3RyYXBwaW5nL2NvbW1hbmRzL2NvbmZpZy9jcmVhdGUudHM=) | `34.28% <20.00%> (-2.08%)` | :arrow_down: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/LiskHQ/lisk-sdk/pull/9169/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LiskHQ)