-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
enh(Add open collective prompt) #755
enh(Add open collective prompt) #755
Conversation
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 left few comments and enhancements! Overall looks good to me!
Should we show the banner only once a week though? Better to not be too invasive
Thanks @ematipico for your feedback, I've included those changes. I've improved the formatting of the output, now it's prettier and well centered: Also, this is showed once a week, I do this by saving the timestamp of the last print in a file called I think this is complete, feedback are welcome 👍 |
@ematipico you can review this if you want |
@misterdev Thanks for your update. I labeled the Pull Request so reviewers will review it again. @evenstensberg Please review the new changes. |
There were the following issues with this Pull Request
You may need to change the commit messages to comply with the repository contributing guidelines. 🤖 This comment was generated by commitlint[bot]. Please report issues here. Happy coding! |
ead8caa
to
dd9d528
Compare
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
The prompt shows only on Monday if the last time it has been shown was more than 6 days earlier. |
bin/cli.js
Outdated
@@ -473,6 +473,22 @@ For more information, see https://webpack.js.org/api/cli/.`); | |||
const statsString = stats.toString(outputOptions); | |||
const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` : ""; | |||
if (statsString) stdout.write(`${statsString}\n${delimiter}`); | |||
|
|||
|
|||
const now = new Date(); |
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.
add comment here , maybe abstract to a local function. Needs more comments and explaination.
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.
I've added this comment on top:
/**
* Show a hint to donate to our Opencollective
* once a week, only on Monday
*/
bin/cli.js
Outdated
const { statSync, utimesSync } = require("fs"); | ||
const lastPrint = statSync(openCollectivePath).atime; | ||
const lastPrintTS = new Date(lastPrint).getTime(); | ||
if (now.getTime() - lastPrintTS > SIX_DAYS) { |
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.
abstract to expression or function that has the naming installedLaterThanSixDays
or similar.
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.
I've abstracted to a variable:
const timeSinceLastPrint = now.getTime() - lastPrintTS;
if (timeSinceLastPrint > SIX_DAYS) {
Thanks for your comments, let me know if I can make any other improvements 👍
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.
lgtm
if (timeSinceLastPrint > SIX_DAYS) { | ||
require(openCollectivePath); | ||
// On windows we need to manually update the atime | ||
utimesSync(openCollectivePath, now, now); |
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 line breaks the build on Linux when we install Webpack globally :-(
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.
:( Could you please open an issue with some details about the error?
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.
=> #870 :-)
See: webpack/webpack-cli#755 Commit in a patch version :-(
See: webpack/webpack-cli#755 Commit in a patch version :-(
See: webpack/webpack-cli#755 Commit in a patch version :-(
I'm adding a console message to ask the users for donations, following how it is implemented in opencollective-cli
OSX
Windows
At the moment this is printed by the postinstall script. It can be improved by printing the banner sometimes during the cli usage as suggested in @evenstensberg example
I think we can print it during cli usage with probability 1/50, I will work on this.
Did you add tests for your changes?
No. Should I?
If relevant, did you update the documentation?
It's not relevant
Summary
Adds a "support us on open collective" closing #752
Closes #752
Does this PR introduce a breaking change?
No