feat(export): refactor code to allow for options#21
Conversation
|
|
||
| The command-line interface for versum. | ||
|
|
||
| - [versum-cli](#versum-cli) |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
reverting to ora as per this sindresorhus/ora#188
| } | ||
| error('\nInvalid contract address'); | ||
| return false; | ||
| return ERRORS.ERROR_INVALID_ADDRESS; |
There was a problem hiding this comment.
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 |
| await csv.toDisk(`./${filename}`); | ||
| log('file saved:', `./${filename}`); | ||
| await csv.toDisk(`./${parsed}`); | ||
| return parsed; |
There was a problem hiding this comment.
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.
|
Considering adding the 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. |
* 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>
* 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>
* 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>
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.