rsnext/packages/next/compiled/cross-spawn/index.js
Houssein Djirdeh 7a1c9eb17e
[ESLint] Introduce a new setup process when next lint is run for the first time (#26584)
This PR introduces an improved developer experience when `next lint` is run for the first time.

### Current behavior

`eslint-config-next` is a required package that must be installed before proceeding with `next lint` or `next build`:

![image](https://user-images.githubusercontent.com/12476932/123468791-43088100-d5c0-11eb-9ad0-5beb80b6c968.png)

Although this has helped many developers start using the new ESLint config, this has also resulted in a few issues:

- Users are required to install the full config (`eslint-config-next`) even if they do not use it or use the Next.js plugin directly (`eslint-plugin-next`).
  - #26348

- There's some confusion  on why `eslint-config-next` needs to be installed or how it should be used instead of `eslint-plugin-next`.
  - #26574
  - #26475
  - #26438

### New behavior

Instead of enforcing `eslint-config-next` as a required package, this PR prompts the user by asking what config they would like to start. This happens when `next lint` is run for the first time **and** if no ESLint configuration is detected in the application.

<img src="https://user-images.githubusercontent.com/12476932/124331177-e1668a80-db5c-11eb-8915-38d3dc20f5d4.gif" width="800" />

- The CLI will take care of installing `eslint` or `eslint-config-next` if either is not already installed
- Users now have the option to choose between a strict configuration (`next/core-web-vitals`) or just the base configuration (`next`)
- For users that decide to create their own ESLint configuration, or already have an existing one, **installing `eslint-config-next` will not be a requirement for `next lint` or `next build` to run**. A warning message will just show if the Next.js ESLint plugin is not detected in an ESLint config. 

  <img width="682" alt="Screen Shot 2021-06-25 at 3 02 12 PM" src="https://user-images.githubusercontent.com/12476932/123473329-6cc4a680-d5c6-11eb-9a57-d5c0b89a2732.png">

---

In addition, this PR also:

- Fixes #26348
- Updates documentation to make it more clear what approach to take for new and existing ESLint configurations
2021-08-04 21:53:15 +00:00

1 line
No EOL
8.1 KiB
JavaScript

module.exports=(()=>{var e={875:(e,t,r)=>{"use strict";const n=r(129);const o=r(915);const s=r(985);function spawn(e,t,r){const c=o(e,t,r);const i=n.spawn(c.command,c.args,c.options);s.hookChildProcess(i,c);return i}function spawnSync(e,t,r){const c=o(e,t,r);const i=n.spawnSync(c.command,c.args,c.options);i.error=i.error||s.verifyENOENTSync(i.status,c);return i}e.exports=spawn;e.exports.spawn=spawn;e.exports.sync=spawnSync;e.exports._parse=o;e.exports._enoent=s},985:e=>{"use strict";const t=process.platform==="win32";function notFoundError(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function hookChildProcess(e,r){if(!t){return}const n=e.emit;e.emit=function(t,o){if(t==="exit"){const t=verifyENOENT(o,r,"spawn");if(t){return n.call(e,"error",t)}}return n.apply(e,arguments)}}function verifyENOENT(e,r){if(t&&e===1&&!r.file){return notFoundError(r.original,"spawn")}return null}function verifyENOENTSync(e,r){if(t&&e===1&&!r.file){return notFoundError(r.original,"spawnSync")}return null}e.exports={hookChildProcess:hookChildProcess,verifyENOENT:verifyENOENT,verifyENOENTSync:verifyENOENTSync,notFoundError:notFoundError}},915:(e,t,r)=>{"use strict";const n=r(622);const o=r(458);const s=r(921);const c=r(266);const i=r(217);const a=r(519);const u=process.platform==="win32";const f=/\.(?:com|exe)$/i;const l=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;const p=o(()=>a.satisfies(process.version,"^4.8.0 || ^5.7.0 || >= 6.0.0",true))||false;function detectShebang(e){e.file=s(e);const t=e.file&&i(e.file);if(t){e.args.unshift(e.file);e.command=t;return s(e)}return e.file}function parseNonShell(e){if(!u){return e}const t=detectShebang(e);const r=!f.test(t);if(e.options.forceShell||r){const r=l.test(t);e.command=n.normalize(e.command);e.command=c.command(e.command);e.args=e.args.map(e=>c.argument(e,r));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`];e.command=process.env.comspec||"cmd.exe";e.options.windowsVerbatimArguments=true}return e}function parseShell(e){if(p){return e}const t=[e.command].concat(e.args).join(" ");if(u){e.command=typeof e.options.shell==="string"?e.options.shell:process.env.comspec||"cmd.exe";e.args=["/d","/s","/c",`"${t}"`];e.options.windowsVerbatimArguments=true}else{if(typeof e.options.shell==="string"){e.command=e.options.shell}else if(process.platform==="android"){e.command="/system/bin/sh"}else{e.command="/bin/sh"}e.args=["-c",t]}return e}function parse(e,t,r){if(t&&!Array.isArray(t)){r=t;t=null}t=t?t.slice(0):[];r=Object.assign({},r);const n={command:e,args:t,options:r,file:undefined,original:{command:e,args:t}};return r.shell?parseShell(n):parseNonShell(n)}e.exports=parse},266:e=>{"use strict";const t=/([()\][%!^"`<>&|;, *?])/g;function escapeCommand(e){e=e.replace(t,"^$1");return e}function escapeArgument(e,r){e=`${e}`;e=e.replace(/(\\*)"/g,'$1$1\\"');e=e.replace(/(\\*)$/,"$1$1");e=`"${e}"`;e=e.replace(t,"^$1");if(r){e=e.replace(t,"^$1")}return e}e.exports.command=escapeCommand;e.exports.argument=escapeArgument},217:(e,t,r)=>{"use strict";const n=r(747);const o=r(598);function readShebang(e){const t=150;let r;if(Buffer.alloc){r=Buffer.alloc(t)}else{r=new Buffer(t);r.fill(0)}let s;try{s=n.openSync(e,"r");n.readSync(s,r,0,t,0);n.closeSync(s)}catch(e){}return o(r.toString())}e.exports=readShebang},921:(e,t,r)=>{"use strict";const n=r(622);const o=r(753);const s=r(226)();function resolveCommandAttempt(e,t){const r=process.cwd();const c=e.options.cwd!=null;if(c){try{process.chdir(e.options.cwd)}catch(e){}}let i;try{i=o.sync(e.command,{path:(e.options.env||process.env)[s],pathExt:t?n.delimiter:undefined})}catch(e){}finally{process.chdir(r)}if(i){i=n.resolve(c?e.options.cwd:"",i)}return i}function resolveCommand(e){return resolveCommandAttempt(e)||resolveCommandAttempt(e,true)}e.exports=resolveCommand},226:e=>{"use strict";e.exports=(e=>{e=e||{};const t=e.env||process.env;const r=e.platform||process.platform;if(r!=="win32"){return"PATH"}return Object.keys(t).find(e=>e.toUpperCase()==="PATH")||"Path"})},607:(e,t,r)=>{var n=r(747);var o;if(process.platform==="win32"||global.TESTING_WINDOWS){o=r(750)}else{o=r(821)}e.exports=isexe;isexe.sync=sync;function isexe(e,t,r){if(typeof t==="function"){r=t;t={}}if(!r){if(typeof Promise!=="function"){throw new TypeError("callback not provided")}return new Promise(function(r,n){isexe(e,t||{},function(e,t){if(e){n(e)}else{r(t)}})})}o(e,t||{},function(e,n){if(e){if(e.code==="EACCES"||t&&t.ignoreErrors){e=null;n=false}}r(e,n)})}function sync(e,t){try{return o.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code==="EACCES"){return false}else{throw e}}}},821:(e,t,r)=>{e.exports=isexe;isexe.sync=sync;var n=r(747);function isexe(e,t,r){n.stat(e,function(e,n){r(e,e?false:checkStat(n,t))})}function sync(e,t){return checkStat(n.statSync(e),t)}function checkStat(e,t){return e.isFile()&&checkMode(e,t)}function checkMode(e,t){var r=e.mode;var n=e.uid;var o=e.gid;var s=t.uid!==undefined?t.uid:process.getuid&&process.getuid();var c=t.gid!==undefined?t.gid:process.getgid&&process.getgid();var i=parseInt("100",8);var a=parseInt("010",8);var u=parseInt("001",8);var f=i|a;var l=r&u||r&a&&o===c||r&i&&n===s||r&f&&s===0;return l}},750:(e,t,r)=>{e.exports=isexe;isexe.sync=sync;var n=r(747);function checkPathExt(e,t){var r=t.pathExt!==undefined?t.pathExt:process.env.PATHEXT;if(!r){return true}r=r.split(";");if(r.indexOf("")!==-1){return true}for(var n=0;n<r.length;n++){var o=r[n].toLowerCase();if(o&&e.substr(-o.length).toLowerCase()===o){return true}}return false}function checkStat(e,t,r){if(!e.isSymbolicLink()&&!e.isFile()){return false}return checkPathExt(t,r)}function isexe(e,t,r){n.stat(e,function(n,o){r(n,n?false:checkStat(o,e,t))})}function sync(e,t){return checkStat(n.statSync(e),e,t)}},458:e=>{"use strict";e.exports=function(e){try{return e()}catch(e){}}},598:(e,t,r)=>{"use strict";var n=r(829);e.exports=function(e){var t=e.match(n);if(!t){return null}var r=t[0].replace(/#! ?/,"").split(" ");var o=r[0].split("/").pop();var s=r[1];return o==="env"?s:o+(s?" "+s:"")}},829:e=>{"use strict";e.exports=/^#!.*/},753:(e,t,r)=>{e.exports=which;which.sync=whichSync;var n=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys";var o=r(622);var s=n?";":":";var c=r(607);function getNotFoundError(e){var t=new Error("not found: "+e);t.code="ENOENT";return t}function getPathInfo(e,t){var r=t.colon||s;var o=t.path||process.env.PATH||"";var c=[""];o=o.split(r);var i="";if(n){o.unshift(process.cwd());i=t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM";c=i.split(r);if(e.indexOf(".")!==-1&&c[0]!=="")c.unshift("")}if(e.match(/\//)||n&&e.match(/\\/))o=[""];return{env:o,ext:c,extExe:i}}function which(e,t,r){if(typeof t==="function"){r=t;t={}}var n=getPathInfo(e,t);var s=n.env;var i=n.ext;var a=n.extExe;var u=[];(function F(n,f){if(n===f){if(t.all&&u.length)return r(null,u);else return r(getNotFoundError(e))}var l=s[n];if(l.charAt(0)==='"'&&l.slice(-1)==='"')l=l.slice(1,-1);var p=o.join(l,e);if(!l&&/^\.[\\\/]/.test(e)){p=e.slice(0,2)+p}(function E(e,o){if(e===o)return F(n+1,f);var s=i[e];c(p+s,{pathExt:a},function(n,c){if(!n&&c){if(t.all)u.push(p+s);else return r(null,p+s)}return E(e+1,o)})})(0,i.length)})(0,s.length)}function whichSync(e,t){t=t||{};var r=getPathInfo(e,t);var n=r.env;var s=r.ext;var i=r.extExe;var a=[];for(var u=0,f=n.length;u<f;u++){var l=n[u];if(l.charAt(0)==='"'&&l.slice(-1)==='"')l=l.slice(1,-1);var p=o.join(l,e);if(!l&&/^\.[\\\/]/.test(e)){p=e.slice(0,2)+p}for(var m=0,h=s.length;m<h;m++){var v=p+s[m];var d;try{d=c.sync(v,{pathExt:i});if(d){if(t.all)a.push(v);else return v}}catch(e){}}}if(t.all&&a.length)return a;if(t.nothrow)return null;throw getNotFoundError(e)}},129:e=>{"use strict";e.exports=require("child_process")},747:e=>{"use strict";e.exports=require("fs")},519:e=>{"use strict";e.exports=require("next/dist/compiled/semver")},622:e=>{"use strict";e.exports=require("path")}};var t={};function __nccwpck_require__(r){if(t[r]){return t[r].exports}var n=t[r]={exports:{}};var o=true;try{e[r](n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return n.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(875)})();