From f13b3752b2c8badf13e457703ce34fdcc33dcba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 22 May 2020 20:51:53 +0200 Subject: [PATCH] feat: experimental nuxt telemetry (#7408) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [release] Co-authored-by: Sébastien Chopin Co-authored-by: pooya parsa --- distributions/nuxt-start/package.json | 1 + distributions/nuxt/package.json | 1 + packages/config/package.json | 1 + packages/config/src/options.js | 17 +++++- yarn.lock | 77 ++++++++++++++++++++++++++- 5 files changed, 94 insertions(+), 3 deletions(-) diff --git a/distributions/nuxt-start/package.json b/distributions/nuxt-start/package.json index 59fac5bd42..3969ceb8ea 100644 --- a/distributions/nuxt-start/package.json +++ b/distributions/nuxt-start/package.json @@ -57,6 +57,7 @@ "dependencies": { "@nuxt/cli": "2.12.1", "@nuxt/core": "2.12.1", + "@nuxt/telemetry": "^0.0.3", "node-fetch": "^2.6.0", "vue": "^2.6.11", "vue-client-only": "^2.0.0", diff --git a/distributions/nuxt/package.json b/distributions/nuxt/package.json index d00254467f..ea8bfaab9e 100644 --- a/distributions/nuxt/package.json +++ b/distributions/nuxt/package.json @@ -65,6 +65,7 @@ "@nuxt/generator": "2.12.1", "@nuxt/loading-screen": "^1.2.0", "@nuxt/opencollective": "^0.3.0", + "@nuxt/telemetry": "^0.0.3", "@nuxt/webpack": "2.12.1" }, "engines": { diff --git a/packages/config/package.json b/packages/config/package.json index b787ff8298..e7a009cef8 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -13,6 +13,7 @@ "@nuxt/utils": "2.12.1", "consola": "^2.12.1", "defu": "^2.0.2", + "destr": "^0.1.4", "dotenv": "^8.2.0", "esm": "^3.2.25", "std-env": "^2.2.1" diff --git a/packages/config/src/options.js b/packages/config/src/options.js index b4baa0dd0e..a28608aa6f 100644 --- a/packages/config/src/options.js +++ b/packages/config/src/options.js @@ -5,7 +5,8 @@ import defu from 'defu' import pick from 'lodash/pick' import uniq from 'lodash/uniq' import consola from 'consola' -import { TARGETS, MODES, guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule, urlJoin } from '@nuxt/utils' +import destr from 'destr' +import { TARGETS, MODES, guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule, urlJoin, getPKG } from '@nuxt/utils' import { defaultNuxtConfigFile, getDefaultNuxtConfig } from './config' export function getNuxtConfig (_options) { @@ -473,5 +474,19 @@ export function getNuxtConfig (_options) { staticAssets.versionBase = urlJoin(staticAssets.base, staticAssets.version) } + // Nuxt Telemetry + if ( + options.telemetry !== false && + !options.test && + !destr(process.env.NUXT_TELEMETRY_DISABLED) && + getPKG('@nuxt/telemetry') + ) { + // TODO: Remove before 2.13 in favor of checking .nuxrc for first run message + if (typeof options.telemetry === 'undefined') { + consola.warn('Experimental `@nuxt/telemetry` enabled. You can disable this message by explicitly setting `telemetry: false` or `telemetry: true` in `nuxt.config`') + } + options.modules.push('@nuxt/telemetry') + } + return options } diff --git a/yarn.lock b/yarn.lock index d1b9be722c..58370c6120 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1860,6 +1860,22 @@ consola "^2.10.1" node-fetch "^2.6.0" +"@nuxt/telemetry@^0.0.3": + version "0.0.3" + resolved "https://registry.npmjs.org/@nuxt/telemetry/-/telemetry-0.0.3.tgz#996b634363c47a5bf278e945d247b6353e2ac946" + integrity sha512-QQ+H0mW9O/Tpv0ebDaixbQ6y1rW6s0BfAcEPDK/x7mzV9ThZYpZTHblkyAmF7uvEv/1dCw51/edltfwtK1s5og== + dependencies: + ci-info "^2.0.0" + consola "^2.11.3" + defu "^2.0.4" + destr "^0.1.4" + fs-extra "^9.0.0" + git-url-parse "^11.1.2" + is-docker "^2.0.0" + node-fetch "^2.6.0" + node-machine-id "^1.1.12" + parse-git-config "^3.0.0" + "@nuxtjs/eslint-config@^3.0.0": version "3.0.0" resolved "https://registry.npmjs.org/@nuxtjs/eslint-config/-/eslint-config-3.0.0.tgz#34f4a4ad9133f0c7e64bbcd2ab5315a821d173a4" @@ -2997,6 +3013,11 @@ asynckit@^0.4.0: resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= +at-least-node@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" + integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== + atob-lite@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz#0fef5ad46f1bd7a8502c65727f0367d5ee43d696" @@ -4084,7 +4105,7 @@ connect@^3.7.0: parseurl "~1.3.3" utils-merge "1.0.1" -consola@^2.10.0, consola@^2.10.1, consola@^2.12.1, consola@^2.6.0, consola@^2.9.0: +consola@^2.10.0, consola@^2.10.1, consola@^2.11.3, consola@^2.12.1, consola@^2.6.0, consola@^2.9.0: version "2.12.1" resolved "https://registry.npmjs.org/consola/-/consola-2.12.1.tgz#88e9311a02cb88a7f6f9488239dd30b6ba99cbb0" integrity sha512-aEkkju9ZcEa9y2MhzNhfmTUws/CEZZ0LKu0FxftSU3HygPfVMMIMSYyYct+xBN6XNRhsaDZjw2HAv3m2ammXSA== @@ -4760,6 +4781,11 @@ defu@^2.0.2: resolved "https://registry.npmjs.org/defu/-/defu-2.0.2.tgz#9a3d4c1330d60c0ed4812e51864b948c51f7ad45" integrity sha512-E5dO3ji0TmVcZaB/2G6Ovu5zNHbWkgCU7v+EoE/Jj1Lbwv1BB6hNNKLkio2ZLI3/e3avlO634QUhQl4iCpm3Bg== +defu@^2.0.4: + version "2.0.4" + resolved "https://registry.npmjs.org/defu/-/defu-2.0.4.tgz#09659a6e87a8fd7178be13bd43e9357ebf6d1c46" + integrity sha512-G9pEH1UUMxShy6syWk01VQSRVs3CDWtlxtZu7A+NyqjxaCA4gSlWAKDBx6QiUEKezqS8+DUlXLI14Fp05Hmpwg== + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -4788,6 +4814,11 @@ des.js@^1.0.0: inherits "^2.0.1" minimalistic-assert "^1.0.0" +destr@^0.1.4: + version "0.1.4" + resolved "https://registry.npmjs.org/destr/-/destr-0.1.4.tgz#5ade43c2c02ffa7ad80e4d1516db309158d03d90" + integrity sha512-jGvlTgd/uZHtImTF8idU1FGu0Sg2/KBRp17HdsZ9dgZSkjt6lJRp/YW1gzHb1iEk0yJ4RrSQ3ujxbswa0gmwzQ== + destroy@^1.0.4, destroy@~1.0.4: version "1.0.4" resolved "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" @@ -5951,6 +5982,16 @@ fs-extra@^8.1.0: jsonfile "^4.0.0" universalify "^0.1.0" +fs-extra@^9.0.0: + version "9.0.0" + resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.0.tgz#b6afc31036e247b2466dc99c29ae797d5d4580a3" + integrity sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g== + dependencies: + at-least-node "^1.0.0" + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^1.0.0" + fs-minipass@^1.2.5: version "1.2.7" resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" @@ -6101,6 +6142,11 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +git-config-path@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/git-config-path/-/git-config-path-2.0.0.tgz#62633d61af63af4405a5024efd325762f58a181b" + integrity sha512-qc8h1KIQbJpp+241id3GuAtkdyJ+IK+LIVtkiFTRKRrmddDzs3SI9CvP1QYmWBFvm1I/PWRwj//of8bgAc0ltA== + git-hooks-list@1.0.3: version "1.0.3" resolved "https://registry.npmjs.org/git-hooks-list/-/git-hooks-list-1.0.3.tgz#be5baaf78203ce342f2f844a9d2b03dba1b45156" @@ -6789,7 +6835,7 @@ inherits@2.0.3: resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= -ini@^1.3.2, ini@^1.3.4: +ini@^1.3.2, ini@^1.3.4, ini@^1.3.5: version "1.3.5" resolved "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== @@ -7795,6 +7841,15 @@ jsonfile@^4.0.0: optionalDependencies: graceful-fs "^4.1.6" +jsonfile@^6.0.1: + version "6.0.1" + resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz#98966cba214378c8c84b82e085907b40bf614179" + integrity sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg== + dependencies: + universalify "^1.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" @@ -8804,6 +8859,11 @@ node-libs-browser@^2.2.1: util "^0.11.0" vm-browserify "^1.0.1" +node-machine-id@^1.1.12: + version "1.1.12" + resolved "https://registry.npmjs.org/node-machine-id/-/node-machine-id-1.1.12.tgz#37904eee1e59b320bb9c5d6c0a59f3b469cb6267" + integrity sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ== + node-modules-regexp@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40" @@ -9373,6 +9433,14 @@ parse-asn1@^5.0.0, parse-asn1@^5.1.5: pbkdf2 "^3.0.3" safe-buffer "^5.1.1" +parse-git-config@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/parse-git-config/-/parse-git-config-3.0.0.tgz#4a2de08c7b74a2555efa5ae94d40cd44302a6132" + integrity sha512-wXoQGL1D+2COYWCD35/xbiKma1Z15xvZL8cI25wvxzled58V51SJM04Urt/uznS900iQor7QO04SgdfT/XlbuA== + dependencies: + git-config-path "^2.0.0" + ini "^1.3.5" + parse-github-repo-url@^1.3.0: version "1.4.1" resolved "https://registry.npmjs.org/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz#9e7d8bb252a6cb6ba42595060b7bf6df3dbc1f50" @@ -12580,6 +12648,11 @@ universalify@^0.1.0: resolved "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== +universalify@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d" + integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug== + unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"