UNPKG

4.38 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../cli/next-telemetry.ts"],"names":["nextTelemetry","argv","validArgs","Boolean","args","error","code","message","console","log","chalk","cyan","telemetry","Telemetry","distDir","process","cwd","isEnabled","_","setEnabled","yellow","bold","green","red"],"mappings":"AAAA;kEACA,oDACA,8EACA,0CAEA,6C,mFAEA,KAAMA,CAAAA,aAAyB,CAAIC,IAAD,EAAU,CAC1C,KAAMC,CAAAA,SAAmB,CAAG,CAC1B;AACA,SAAUC,OAFgB,CAG1B,WAAYA,OAHc,CAI1B,YAAaA,OAJa,CAK1B;AACA,KAAM,QANoB,CAA5B,CAQA,GAAIC,CAAAA,IAAJ,CACA,GAAI,CACFA,IAAI,CAAG,mBAAIF,SAAJ,CAAe,CAAED,IAAF,CAAf,CAAP,CACD,CAAC,MAAOI,KAAP,CAAc,CACd,GAAIA,KAAK,CAACC,IAAN,GAAe,oBAAnB,CAAyC,CACvC,MAAO,wBAAaD,KAAK,CAACE,OAAnB,CAA4B,CAA5B,CAAP,CACD,CACD,KAAMF,CAAAA,KAAN,CACD,CAED,GAAID,IAAI,CAAC,QAAD,CAAR,CAAoB,CAClBI,OAAO,CAACC,GAAR,CACG;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoBC,eAAMC,IAAN,CAAW,8BAAX,CAA2C;AAC/D,KAXI,EAaA,OACD,CAED,KAAMC,CAAAA,SAAS,CAAG,GAAIC,mBAAJ,CAAc,CAAEC,OAAO,CAAEC,OAAO,CAACC,GAAR,EAAX,CAAd,CAAlB,CAEA,GAAIC,CAAAA,SAAS,CAAGL,SAAS,CAACK,SAA1B,CAEA,GAAIb,IAAI,CAAC,UAAD,CAAJ,EAAoBA,IAAI,CAACc,CAAL,CAAO,CAAP,IAAc,QAAtC,CAAgD,CAC9CN,SAAS,CAACO,UAAV,CAAqB,IAArB,EACAX,OAAO,CAACC,GAAR,CAAYC,eAAMC,IAAN,CAAW,UAAX,CAAZ,EACAH,OAAO,CAACC,GAAR,GAEAQ,SAAS,CAAG,IAAZ,CACD,CAND,IAMO,IAAIb,IAAI,CAAC,WAAD,CAAJ,EAAqBA,IAAI,CAACc,CAAL,CAAO,CAAP,IAAc,SAAvC,CAAkD,CACvDN,SAAS,CAACO,UAAV,CAAqB,KAArB,EACA,GAAIF,SAAJ,CAAe,CACbT,OAAO,CAACC,GAAR,CAAYC,eAAMC,IAAN,CAAW,iCAAX,CAAZ,EACD,CAFD,IAEO,CACLH,OAAO,CAACC,GAAR,CACEC,eAAMU,MAAN,CAAc,oDAAd,CADF,EAGD,CACDZ,OAAO,CAACC,GAAR,GAEAQ,SAAS,CAAG,KAAZ,CACD,CAZM,IAYA,CACLT,OAAO,CAACC,GAAR,CAAYC,eAAMW,IAAN,CAAW,mBAAX,CAAZ,EACAb,OAAO,CAACC,GAAR,GACD,CAEDD,OAAO,CAACC,GAAR,CACG,WACCQ,SAAS,CAAGP,eAAMW,IAAN,CAAWC,KAAX,CAAiB,SAAjB,CAAH,CAAiCZ,eAAMW,IAAN,CAAWE,GAAX,CAAe,UAAf,CAC3C,EAHH,EAKAf,OAAO,CAACC,GAAR,GAEA,GAAIQ,SAAJ,CAAe,CACbT,OAAO,CAACC,GAAR,CACG,yEADH,EAGD,CAJD,IAIO,CACLD,OAAO,CAACC,GAAR,CAAa,6DAAb,EACAD,OAAO,CAACC,GAAR,CAAa,8CAAb,EACD,CAEDD,OAAO,CAACC,GAAR,CAAa,0CAAb,EACAD,OAAO,CAACC,GAAR,GACD,CAjFD,C","sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk'\nimport arg from 'next/dist/compiled/arg/index.js'\nimport { printAndExit } from '../server/lib/utils'\nimport { cliCommand } from '../bin/next'\nimport { Telemetry } from '../telemetry/storage'\n\nconst nextTelemetry: cliCommand = (argv) => {\n const validArgs: arg.Spec = {\n // Types\n '--help': Boolean,\n '--enable': Boolean,\n '--disable': Boolean,\n // Aliases\n '-h': '--help',\n }\n let args: arg.Result<arg.Spec>\n try {\n args = arg(validArgs, { argv })\n } catch (error) {\n if (error.code === 'ARG_UNKNOWN_OPTION') {\n return printAndExit(error.message, 1)\n }\n throw error\n }\n\n if (args['--help']) {\n console.log(\n `\n Description\n Allows you to control Next.js' telemetry collection\n\n Usage\n $ next telemetry [enable/disable]\n\n You may pass the 'enable' or 'disable' argument to turn Next.js' telemetry collection on or off.\n\n Learn more: ${chalk.cyan('https://nextjs.org/telemetry')}\n `\n )\n return\n }\n\n const telemetry = new Telemetry({ distDir: process.cwd() })\n\n let isEnabled = telemetry.isEnabled\n\n if (args['--enable'] || args._[0] === 'enable') {\n telemetry.setEnabled(true)\n console.log(chalk.cyan('Success!'))\n console.log()\n\n isEnabled = true\n } else if (args['--disable'] || args._[0] === 'disable') {\n telemetry.setEnabled(false)\n if (isEnabled) {\n console.log(chalk.cyan('Your preference has been saved.'))\n } else {\n console.log(\n chalk.yellow(`Next.js' telemetry collection is already disabled.`)\n )\n }\n console.log()\n\n isEnabled = false\n } else {\n console.log(chalk.bold('Next.js Telemetry'))\n console.log()\n }\n\n console.log(\n `Status: ${\n isEnabled ? chalk.bold.green('Enabled') : chalk.bold.red('Disabled')\n }`\n )\n console.log()\n\n if (isEnabled) {\n console.log(\n `Next.js telemetry is completely anonymous. Thank you for participating!`\n )\n } else {\n console.log(`You have opted-out of Next.js' anonymous telemetry program.`)\n console.log(`No data will be collected from your machine.`)\n }\n\n console.log(`Learn more: https://nextjs.org/telemetry`)\n console.log()\n}\n\nexport { nextTelemetry }\n"]}
\No newline at end of file