vaadin / vaadin-usage-statistics

Development-time usage statistics collector.
Apache License 2.0
8 stars 6 forks source link

Output message only once per installation #39

Open Artur- opened 5 years ago

Artur- commented 5 years ago

With the latest Flow, that uses shrinkwrap packages, you see the info message three times during npm install


> @vaadin/vaadin-usage-statistics@2.0.4 postinstall .../node_modules/@vaadin/vaadin-core-shrinkwrap/node_modules/@vaadin/vaadin-usage-statistics
> node check.js

    Vaadin collects development time usage statistics to improve this product. To opt-out, either run:
    npm explore @vaadin/vaadin-usage-statistics -- npm run disable
    to store disable statistics for the machine, or add
    "vaadin": { "disableUsageStatistics": true }
    to the project package.json and re-run npm install to disable statistics for the project.

    For more details, see https://github.com/vaadin/vaadin-usage-statistics

> @vaadin/vaadin-usage-statistics@2.0.4 postinstall .../node_modules/@vaadin/vaadin-shrinkwrap/node_modules/@vaadin/vaadin-usage-statistics
> node check.js

    Vaadin collects development time usage statistics to improve this product. To opt-out, either run:
    npm explore @vaadin/vaadin-usage-statistics -- npm run disable
    to store disable statistics for the machine, or add
    "vaadin": { "disableUsageStatistics": true }
    to the project package.json and re-run npm install to disable statistics for the project.

    For more details, see https://github.com/vaadin/vaadin-usage-statistics

> @vaadin/vaadin-usage-statistics@2.0.4 postinstall .../node_modules/@vaadin/vaadin-usage-statistics
> node check.js

    Vaadin collects development time usage statistics to improve this product. To opt-out, either run:
    npm explore @vaadin/vaadin-usage-statistics -- npm run disable
    to store disable statistics for the machine, or add
    "vaadin": { "disableUsageStatistics": true }
    to the project package.json and re-run npm install to disable statistics for the project.

    For more details, see https://github.com/vaadin/vaadin-usage-statistics
web-padawan commented 5 years ago

This most likely indicates that there are duplicate dependencies 😱

Does Flow run npm dedupe after installing dependencies?

Artur- commented 5 years ago

The shrinkwrap packages install all their dependencies inside the corresponding folder even though they are also in the main node_modules

web-padawan commented 5 years ago

I think this should be resolved by npm dedupe. Will double check if we can avoid that.

Artur- commented 5 years ago

Can we make the message show up e.g max once per day/week instead of all the time? Having it spam the build log only makes me want to turn the whole thing off

web-padawan commented 5 years ago

Will investigate the options.

ZheSun88 commented 5 years ago

This is issue should not be closed, when i run mvn jetty:run on the starters, it prints the info 3 times..

tested with platform 14.0.4 which is using vaadin-usage-statistics 2.0.10

Artur- commented 5 years ago

Indeed, the fix was reverted because it did not work properly and was also tied to npm I think. Any other ideas for this @web-padawan ?

web-padawan commented 5 years ago

Yes, the problem was that npm could not be resolved in case of local Node installation.

I think we can try storing an info in the node_modules/.cache folder (if there are folder write permissions, which might not be always true, so need to try / catch).

Here is a library which could help to read / create such a cache folder: https://github.com/avajs/find-cache-dir

Artur- commented 5 years ago

How about using the global ~/.vaadin folder which is already used for e.g. proKey and other data. If you store it inside node_modules, it would be per project which is probably not what you want?