Skip to content

feat(export): refactor code to allow for options#21

Merged
andrevenancio merged 2 commits intodevelopfrom
feature/small_fixes
Jul 25, 2022
Merged

feat(export): refactor code to allow for options#21
andrevenancio merged 2 commits intodevelopfrom
feature/small_fixes

Conversation

@andrevenancio
Copy link
Copy Markdown
Contributor

I've refactored the code quite a bit. This allows for users to pass parameters and being able to skip the inquirer prompt.

I've rename some of the methods too, and changed the logic around logging and error messages.


The command-line interface for versum.

- [versum-cli](#versum-cli)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started to add a list of documents that hopefully will help people (and us in the future) to keep track of everything.

"node-fetch": "2.6.2",
"objects-to-csv": "^1.3.6",
"ora-classic": "^5.4.2",
"ora": "5.4.1",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverting to ora as per this sindresorhus/ora#188

}
error('\nInvalid contract address');
return false;
return ERRORS.ERROR_INVALID_ADDRESS;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is how the inquirer API is meant to be used around validation. by returning a string it gives the users the hability to try again.

src/constants.ts Outdated
export const CONTRACT_VERSUM = 'KT1LjmAdYQCLBjwv4S2oFkEzyHVkomAf5MrW';
export const CONTRACT_FXHASH = 'KT1KEa8z6vWXDJrVqtMrAeDVzsvxat3kHaCE';
export const CONTRACT_FXHASH2 = 'KT1U6EHmNxJTkvaWJ4ThczG4FSDaHC21ssvi';
export const CONTRACT_8BIDOU = 'KT1'; // TODO: get this contract from @xat
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xat what is the right contract?

await csv.toDisk(`./${filename}`);
log('file saved:', `./${filename}`);
await csv.toDisk(`./${parsed}`);
return parsed;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns the parsed filename. This changes any spaces in the name to dashes.

The reason we return it is so we can display an info ora message.

@andrevenancio
Copy link
Copy Markdown
Contributor Author

andrevenancio commented Jul 25, 2022

Considering adding the unique another way...

if (format === 'unique') {
          // Use set to remove duplicates and convert to object[]
          const uniqueData = new Set(data.map((e) => e.address));
          const csvData = [...uniqueData].map((e) => ({ address: e }));
          await SaveToFile(`collectors-${format}-${address}.csv`, csvData);
          return;
        }

If doesn't make sense to be able to export by choosing a platform and then choose unique, maybe this should be its own command.

@andrevenancio andrevenancio merged commit d366593 into develop Jul 25, 2022
@andrevenancio andrevenancio deleted the feature/small_fixes branch July 25, 2022 10:26
andrevenancio added a commit that referenced this pull request Jul 28, 2022
* chore(develop): release 1.1.0 (#5)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(export): add collector export (#17)

* feat(export): add export collectors

* chore(export): add platform param

* refactor(export): rename function

Co-authored-by: d-pettersson <david.pettersson@code.berlin>

* fix(general): refactor build script (#18) (#19)

* feat(export): refactor code to allow for options (#21)

* fix(export): refactor code to allow for options

* feat(export): added 8bidou typed

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: somaticbits <80890151+somaticbits@users.noreply.github.com>
Co-authored-by: d-pettersson <david.pettersson@code.berlin>
andrevenancio added a commit that referenced this pull request Jul 31, 2022
* chore(develop): release 1.1.0 (#5)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(export): add collector export (#17)

* feat(export): add export collectors

* chore(export): add platform param

* refactor(export): rename function

Co-authored-by: d-pettersson <david.pettersson@code.berlin>

* fix(general): refactor build script (#18) (#19)

* feat(export): refactor code to allow for options (#21)

* fix(export): refactor code to allow for options

* feat(export): added 8bidou typed

* chore(develop): release 1.2.0 (#24)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(templates): adding template engine (#25)

* feat: add template submodules

* chore: updated submodules

* chore: removed submodule

* chore(general): refactor to include ncc

* chore: finalise templates

* chore: add missing files

* chore(general): cleanup

* chore: cleanup

* chore: add eslint and prettier

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: somaticbits <80890151+somaticbits@users.noreply.github.com>
Co-authored-by: d-pettersson <david.pettersson@code.berlin>
andrevenancio added a commit that referenced this pull request Jul 31, 2022
* chore(develop): release 1.1.0 (#5)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(export): add collector export (#17)

* feat(export): add export collectors

* chore(export): add platform param

* refactor(export): rename function

Co-authored-by: d-pettersson <david.pettersson@code.berlin>

* fix(general): refactor build script (#18) (#19)

* feat(export): refactor code to allow for options (#21)

* fix(export): refactor code to allow for options

* feat(export): added 8bidou typed

* chore(develop): release 1.2.0 (#24)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(templates): adding template engine (#25)

* feat: add template submodules

* chore: updated submodules

* chore: removed submodule

* chore(general): refactor to include ncc

* chore: finalise templates

* chore: add missing files

* chore(general): cleanup

* chore: cleanup

* chore: add eslint and prettier

* feat: new release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: somaticbits <80890151+somaticbits@users.noreply.github.com>
Co-authored-by: d-pettersson <david.pettersson@code.berlin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant