-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
142 code generator main #182
Conversation
affects: @commercetools/discount-code-generator 142
affects: @commercetools/discount-code-generator
Implement CLI to read attributes/parameters from user and output/save generated codes affects: @commercetools/discount-code-generator
…#150) affects: @commercetools/discount-code-generator
correct readme links
affects: @commercetools/discount-code-generator
Codecov Report
@@ Coverage Diff @@
## master #182 +/- ##
========================================
Coverage ? 96.6%
========================================
Files ? 56
Lines ? 1061
Branches ? 0
========================================
Hits ? 1025
Misses ? 36
Partials ? 0
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't I review this already? It looks fine anyway ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌻
--output, -o Path to store generated output file. [default: "stdout"] | ||
--delimiter, -d Used CSV delimiter for input and/or output file. [default: ","] | ||
--multivalueDelimiter, -m Used CSV delimiter in multivalue fields for input/output file. [default: ";"] | ||
--logLevel, Logging level: error, warn, info or verbose. [default: "info"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nitpick - some params are written in camelCase
and some in kebab-case
"type": "git", | ||
"url": "https://github.com/commercetools/nodejs/tree/master/packages/discount-code-generator" | ||
}, | ||
"homepage": "https://commercetools.github.io/nodejs/sdk/api/discountCodeGenerator.html", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this URL correct? Shouldn't there be cli/...
?
|
||
Generate discount codes to be imported to the commercetools platform. | ||
|
||
https://commercetools.github.io/nodejs/docs/cli/discount-code-generator.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Url should be something like this: https://commercetools.github.io/nodejs/cli/csv-parser-price.html
reject(error) | ||
}) | ||
.on('data', (data) => { | ||
_attributes = data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be _attributes += data
because the input file is loaded in chunks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That also works; but it's expecting just one line, so this is better; the data event gets fired once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the input file can have only 64kb including those descriptions in multiple languages.
outputStream.on('finish', () => { | ||
resolve(total) | ||
}) | ||
} else reject(new Error('Invalid file format. Must be CSV or JSON')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already handled when parsing input arguments.
See #184 |
Summary
As part of this project, implement a package to generate discount codes
Description
This package is now complete and should be merged and released
resolves #142