create-airbnb-x-config 2.3.2 → 3.0.0-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +3 -3
  2. package/dist/constants/index.mjs +1 -0
  3. package/dist/helpers/createEslintConfigFile.mjs +1 -0
  4. package/dist/helpers/getArgs.mjs +1 -0
  5. package/dist/helpers/getCommands.mjs +1 -0
  6. package/dist/helpers/getConfigUrl.mjs +1 -0
  7. package/dist/helpers/getPackageManager.mjs +1 -0
  8. package/dist/helpers/getProgramOptions.mjs +1 -0
  9. package/dist/helpers/installPackages.mjs +1 -0
  10. package/dist/index.d.mts +1 -0
  11. package/dist/index.mjs +2 -0
  12. package/dist/package.mjs +1 -0
  13. package/dist/utils/index.mjs +2 -0
  14. package/package.json +19 -18
  15. package/dist/constants/index.d.ts +0 -38
  16. package/dist/constants/index.js +0 -41
  17. package/dist/helpers/createEslintConfigFile.d.ts +0 -4
  18. package/dist/helpers/createEslintConfigFile.js +0 -67
  19. package/dist/helpers/getArgs.d.ts +0 -44
  20. package/dist/helpers/getArgs.js +0 -90
  21. package/dist/helpers/getCommands.d.ts +0 -4
  22. package/dist/helpers/getCommands.js +0 -53
  23. package/dist/helpers/getConfigUrl.d.ts +0 -10
  24. package/dist/helpers/getConfigUrl.js +0 -49
  25. package/dist/helpers/getPackageManager.d.ts +0 -6
  26. package/dist/helpers/getPackageManager.js +0 -28
  27. package/dist/helpers/installPackages.d.ts +0 -7
  28. package/dist/helpers/installPackages.js +0 -39
  29. package/dist/helpers/program.d.ts +0 -7
  30. package/dist/helpers/program.js +0 -36
  31. package/dist/index.d.ts +0 -2
  32. package/dist/index.js +0 -290
  33. package/dist/lib/templates/configs.d.ts +0 -13
  34. package/dist/lib/templates/configs.js +0 -205
  35. package/dist/lib/templates/constants.d.ts +0 -24
  36. package/dist/lib/templates/constants.js +0 -11
  37. package/dist/lib/templates/contentFormatter.d.ts +0 -4
  38. package/dist/lib/templates/contentFormatter.js +0 -12
  39. package/dist/lib/templates/createDirectories.d.ts +0 -3
  40. package/dist/lib/templates/createDirectories.js +0 -31
  41. package/dist/lib/templates/getAllFolders.d.ts +0 -19
  42. package/dist/lib/templates/getAllFolders.js +0 -29
  43. package/dist/lib/templates/getContent.d.ts +0 -17
  44. package/dist/lib/templates/getContent.js +0 -39
  45. package/dist/lib/templates/getDefaultSubFolders.d.ts +0 -7
  46. package/dist/lib/templates/getDefaultSubFolders.js +0 -102
  47. package/dist/lib/templates/getFolders.d.ts +0 -4
  48. package/dist/lib/templates/getFolders.js +0 -61
  49. package/dist/lib/templates/index.d.ts +0 -1
  50. package/dist/lib/templates/index.js +0 -25
  51. package/dist/lib/templates/writeFiles.d.ts +0 -3
  52. package/dist/lib/templates/writeFiles.js +0 -41
  53. package/dist/package.json +0 -62
  54. package/dist/utils/index.d.ts +0 -26
  55. package/dist/utils/index.js +0 -63
  56. package/dist/utils/types.d.ts +0 -5
  57. package/dist/utils/types.js +0 -2
  58. package/templates/legacy/base/js/default/eslint.config.mjs +0 -31
  59. package/templates/legacy/base/prettier/js/default/eslint.config.mjs +0 -53
  60. package/templates/legacy/base/prettier/ts/default/eslint.config.mjs +0 -60
  61. package/templates/legacy/base/ts/default/eslint.config.mjs +0 -38
  62. package/templates/legacy/react/js/default/eslint.config.mjs +0 -36
  63. package/templates/legacy/react/prettier/js/default/eslint.config.mjs +0 -58
  64. package/templates/legacy/react/prettier/ts/default/eslint.config.mjs +0 -65
  65. package/templates/legacy/react/ts/default/eslint.config.mjs +0 -43
  66. package/templates/legacy/react-hooks/js/default/eslint.config.mjs +0 -38
  67. package/templates/legacy/react-hooks/prettier/js/default/eslint.config.mjs +0 -60
  68. package/templates/legacy/react-hooks/prettier/ts/default/eslint.config.mjs +0 -67
  69. package/templates/legacy/react-hooks/ts/default/eslint.config.mjs +0 -45
  70. package/templates/next/js/default/eslint.config.mjs +0 -50
  71. package/templates/next/js/strict/import/eslint.config.mjs +0 -52
  72. package/templates/next/js/strict/import-react/eslint.config.mjs +0 -54
  73. package/templates/next/js/strict/react/eslint.config.mjs +0 -52
  74. package/templates/next/prettier/js/default/eslint.config.mjs +0 -72
  75. package/templates/next/prettier/js/strict/import/eslint.config.mjs +0 -74
  76. package/templates/next/prettier/js/strict/import-react/eslint.config.mjs +0 -76
  77. package/templates/next/prettier/js/strict/react/eslint.config.mjs +0 -74
  78. package/templates/next/prettier/ts/default/eslint.config.mjs +0 -83
  79. package/templates/next/prettier/ts/strict/import/eslint.config.mjs +0 -85
  80. package/templates/next/prettier/ts/strict/import-react/eslint.config.mjs +0 -87
  81. package/templates/next/prettier/ts/strict/import-react-typescript/eslint.config.mjs +0 -89
  82. package/templates/next/prettier/ts/strict/import-typescript/eslint.config.mjs +0 -87
  83. package/templates/next/prettier/ts/strict/react/eslint.config.mjs +0 -85
  84. package/templates/next/prettier/ts/strict/react-typescript/eslint.config.mjs +0 -87
  85. package/templates/next/prettier/ts/strict/typescript/eslint.config.mjs +0 -85
  86. package/templates/next/ts/default/eslint.config.mjs +0 -61
  87. package/templates/next/ts/strict/import/eslint.config.mjs +0 -63
  88. package/templates/next/ts/strict/import-react/eslint.config.mjs +0 -65
  89. package/templates/next/ts/strict/import-react-typescript/eslint.config.mjs +0 -67
  90. package/templates/next/ts/strict/import-typescript/eslint.config.mjs +0 -65
  91. package/templates/next/ts/strict/react/eslint.config.mjs +0 -63
  92. package/templates/next/ts/strict/react-typescript/eslint.config.mjs +0 -65
  93. package/templates/next/ts/strict/typescript/eslint.config.mjs +0 -63
  94. package/templates/node/js/default/eslint.config.mjs +0 -44
  95. package/templates/node/js/strict/import/eslint.config.mjs +0 -46
  96. package/templates/node/prettier/js/default/eslint.config.mjs +0 -66
  97. package/templates/node/prettier/js/strict/import/eslint.config.mjs +0 -68
  98. package/templates/node/prettier/ts/default/eslint.config.mjs +0 -75
  99. package/templates/node/prettier/ts/strict/import/eslint.config.mjs +0 -77
  100. package/templates/node/prettier/ts/strict/import-typescript/eslint.config.mjs +0 -79
  101. package/templates/node/prettier/ts/strict/typescript/eslint.config.mjs +0 -77
  102. package/templates/node/ts/default/eslint.config.mjs +0 -53
  103. package/templates/node/ts/strict/import/eslint.config.mjs +0 -55
  104. package/templates/node/ts/strict/import-typescript/eslint.config.mjs +0 -57
  105. package/templates/node/ts/strict/typescript/eslint.config.mjs +0 -55
  106. package/templates/react/js/default/eslint.config.mjs +0 -48
  107. package/templates/react/js/strict/import/eslint.config.mjs +0 -50
  108. package/templates/react/js/strict/import-react/eslint.config.mjs +0 -52
  109. package/templates/react/js/strict/react/eslint.config.mjs +0 -50
  110. package/templates/react/prettier/js/default/eslint.config.mjs +0 -70
  111. package/templates/react/prettier/js/strict/import/eslint.config.mjs +0 -72
  112. package/templates/react/prettier/js/strict/import-react/eslint.config.mjs +0 -74
  113. package/templates/react/prettier/js/strict/react/eslint.config.mjs +0 -72
  114. package/templates/react/prettier/ts/default/eslint.config.mjs +0 -81
  115. package/templates/react/prettier/ts/strict/import/eslint.config.mjs +0 -83
  116. package/templates/react/prettier/ts/strict/import-react/eslint.config.mjs +0 -85
  117. package/templates/react/prettier/ts/strict/import-react-typescript/eslint.config.mjs +0 -87
  118. package/templates/react/prettier/ts/strict/import-typescript/eslint.config.mjs +0 -85
  119. package/templates/react/prettier/ts/strict/react/eslint.config.mjs +0 -83
  120. package/templates/react/prettier/ts/strict/react-typescript/eslint.config.mjs +0 -85
  121. package/templates/react/prettier/ts/strict/typescript/eslint.config.mjs +0 -83
  122. package/templates/react/ts/default/eslint.config.mjs +0 -59
  123. package/templates/react/ts/strict/import/eslint.config.mjs +0 -61
  124. package/templates/react/ts/strict/import-react/eslint.config.mjs +0 -63
  125. package/templates/react/ts/strict/import-react-typescript/eslint.config.mjs +0 -65
  126. package/templates/react/ts/strict/import-typescript/eslint.config.mjs +0 -63
  127. package/templates/react/ts/strict/react/eslint.config.mjs +0 -61
  128. package/templates/react/ts/strict/react-typescript/eslint.config.mjs +0 -63
  129. package/templates/react/ts/strict/typescript/eslint.config.mjs +0 -61
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # `create-airbnb-x-config`
2
2
 
3
- [![NPM Version](https://img.shields.io/npm/v/create-airbnb-x-config)](https://www.npmjs.com/package/create-airbnb-x-config)
4
- [![NPM Downloads](https://img.shields.io/npm/dw/create-airbnb-x-config)](https://www.npmjs.com/package/create-airbnb-x-config)
5
- [![NPM Last Update](https://img.shields.io/npm/last-update/create-airbnb-x-config)](https://www.npmjs.com/package/create-airbnb-x-config)
3
+ [![NPM Version](https://img.shields.io/npm/v/create-airbnb-x-config?style=flat&labelColor=ffffff&color=5a36e6)](https://www.npmjs.com/package/create-airbnb-x-config)
4
+ [![NPM Downloads](https://img.shields.io/npm/dw/create-airbnb-x-config?style=flat&labelColor=ffffff&color=5a36e6)](https://www.npmjs.com/package/create-airbnb-x-config)
5
+ [![NPM Last Update](https://img.shields.io/npm/last-update/create-airbnb-x-config?style=flat&labelColor=ffffff&color=5a36e6)](https://www.npmjs.com/package/create-airbnb-x-config)
6
6
 
7
7
  The easiest way to get started with `eslint-config-airbnb-extended` is by using the CLI tool `create-airbnb-x-config`. It helps you set up ESLint quickly with all the right settings for your project.
8
8
 
@@ -0,0 +1 @@
1
+ const e={EXTENDED:`extended`,LEGACY:`legacy`},t={JAVASCRIPT:`javascript`,TYPESCRIPT:`typescript`},n={PRETTIER:`prettier`},r={REACT:`react`,REACT_ROUTER:`react-router`,REMIX:`remix`,NEXT:`next`,NODE:`node`},i={IMPORT:`import`,REACT:`react`,TYPESCRIPT:`typescript`},a={BASE:`base`,REACT:`react`,REACT_HOOKS:`react-hooks`},o={NPM:`npm`,YARN:`yarn`,PNPM:`pnpm`,BUN:`bun`},s={TRUE:`true`,FALSE:`false`},c={config:e.EXTENDED,language:t.TYPESCRIPT,formatter:n.PRETTIER,strictConfig:!1,legacyReactHooks:!0,createEslintFile:!0,skipInstall:!1},l={DEFAULT:`default`,STRICT:`strict`},u=`eslint.config.mjs`,d=`https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/apps/build-templates/templates`,f=`https://raw.githubusercontent.com/NishargShah/eslint-config-airbnb-extended/refs/heads/canary/apps/build-templates/templates`;export{f as baseGithubRawUrl,d as baseGithubUrl,e as configs,c as defaults,u as eslintConfigName,n as formatters,t as languages,a as legacyConfigs,o as packageManagers,r as runtimes,i as strictConfigs,s as stringBooleans,l as subFolders};
@@ -0,0 +1 @@
1
+ import{baseGithubRawUrl as e,eslintConfigName as t}from"../constants/index.mjs";import n from"./getConfigUrl.mjs";import{rootPath as r}from"../utils/index.mjs";import i from"node:fs/promises";var a=async a=>{try{let o=n(a);if(!o)return;let{path:s}=o,c=`${e}/${s}`,l=await(await fetch(c)).text();await i.writeFile(`${r}/${t}`,l,{encoding:`utf8`})}catch(e){console.error(e)}};export{a as default};
@@ -0,0 +1 @@
1
+ import{configs as e,formatters as t,languages as n,legacyConfigs as r,packageManagers as i,runtimes as a,stringBooleans as o}from"../constants/index.mjs";import s from"./getPackageManager.mjs";import c from"./getProgramOptions.mjs";const l=t=>{let{config:n}=t;return n===e.EXTENDED?e.EXTENDED:n===e.LEGACY?e.LEGACY:null},u=e=>{let{language:t}=e;return t===n.JAVASCRIPT?n.JAVASCRIPT:t===n.TYPESCRIPT?n.TYPESCRIPT:null},d=e=>{let{formatter:n}=e;return n===t.PRETTIER?t.PRETTIER:null},f=e=>{let{runtime:t}=e;return t&&[a.REACT,a.REACT_ROUTER,a.REMIX].includes(t)?a.REACT:t===a.NEXT?a.NEXT:t===a.NODE?a.NODE:null},p=e=>{let{strictConfig:t}=e;return t?.length?t:null},m=e=>{let{legacyConfig:t}=e;return t===r.BASE?r.BASE:t===r.REACT?r.REACT:t===r.REACT_HOOKS?r.REACT_HOOKS:null},h=async e=>{let{packageManager:t}=e;return t===i.NPM?i.NPM:t===i.YARN?i.YARN:t===i.PNPM?i.PNPM:t===i.BUN?i.BUN:s()},g=e=>{let{createEslintFile:t}=e;return t?t===o.TRUE:null},_=e=>{let{skipInstall:t}=e;return t?t===o.TRUE:null};var v=async()=>{let e=c();return console.log(e),{config:l(e),language:u(e),formatter:d(e),runtime:f(e),strictConfig:p(e),legacyConfig:m(e),packageManager:await h(e),createEslintFile:g(e),skipInstall:_(e)}};export{v as default};
@@ -0,0 +1 @@
1
+ import{configs as e,formatters as t,languages as n,legacyConfigs as r,packageManagers as i,runtimes as a}from"../constants/index.mjs";var o=o=>{let{config:s,language:c,formatter:l,runtime:u,packageManager:d,legacyConfig:f}=o,p=[d,{[i.NPM]:`install`,[i.YARN]:`add`,[i.PNPM]:`install`,[i.BUN]:`add`}[d],`-D`,`eslint`,`@eslint/compat`,`@eslint/js`,`eslint-config-airbnb-extended`];return c===n.TYPESCRIPT&&p.push(`eslint-import-resolver-typescript`,`typescript-eslint`),l===t.PRETTIER&&p.push(`prettier`,`eslint-plugin-prettier`,`eslint-config-prettier`),s===e.EXTENDED&&(p.push(`@stylistic/eslint-plugin@^3.1.0`,`eslint-plugin-import-x`),(u===a.REACT||u===a.NEXT)&&p.push(`eslint-plugin-react`,`eslint-plugin-react-hooks`,`eslint-plugin-jsx-a11y`),u===a.NEXT&&p.push(`@next/eslint-plugin-next`),u===a.NODE&&p.push(`eslint-plugin-n`)),s===e.LEGACY&&(p.push(`eslint-plugin-import`),(f===r.REACT||f===r.REACT_HOOKS)&&p.push(`eslint-plugin-react`,`eslint-plugin-jsx-a11y`),f===r.REACT_HOOKS&&p.push(`eslint-plugin-react-hooks`)),p};export{o as default};
@@ -0,0 +1 @@
1
+ import{baseGithubUrl as e,configs as t,eslintConfigName as n,formatters as r,languages as i,subFolders as a}from"../constants/index.mjs";import o from"picocolors";var s=s=>{let{config:c,language:l,formatter:u,strictConfig:d,runtime:f,legacyConfig:p}=s,m=c===t.LEGACY,h=u===r.PRETTIER?`prettier`:null,g=l===i.TYPESCRIPT?`ts`:`js`,_=c===t.EXTENDED?null:p,v=(()=>{if(!d||d.length===0)return[a.DEFAULT];let e=[...d].sort((e,t)=>e.localeCompare(t)).join(`-`);return[a.STRICT,e]})(),y=[...m?[t.LEGACY,_]:[f],h,g,...v,n].filter(Boolean).join(`/`);return{path:y,url:o.blue(`${e}/${y}`)}};export{s as default};
@@ -0,0 +1 @@
1
+ import{packageManagers as e}from"../constants/index.mjs";import{detect as t}from"package-manager-detector/detect";var n=async()=>{let n=await t();if(!n)return e.NPM;let{name:r}=n;return r===e.PNPM?e.PNPM:r===e.YARN?e.YARN:r===e.BUN?e.BUN:e.NPM};export{n as default};
@@ -0,0 +1 @@
1
+ import{configs as e,eslintConfigName as t,formatters as n,languages as r,legacyConfigs as i,packageManagers as a,runtimes as o,strictConfigs as s,stringBooleans as c}from"../constants/index.mjs";import{name as l,version as u}from"../package.mjs";import{Command as d,Option as f}from"commander";var p=()=>{let p=new d().name(l).version(u,`-v, --version`,`Output the current version of create-airbnb-x-config.`).helpOption(`-h, --help`,`Display this help message.`).addOption(new f(`--config <config>`,`Explicitly tell the CLI to use selected config.`).choices(Object.values(e))).addOption(new f(`--lang, --language <lang>`,`Generate configuration for a selected language project.`).choices(Object.values(r))).addOption(new f(`--formatter <formatter>`,`Include selected formatter for specific linting rules.`).choices(Object.values(n))).addOption(new f(`--runtime <runtime>`,`Include selected runtime for specific linting rules.`).choices(Object.values(o)).conflicts([`legacy-config`])).addOption(new f(`--strict, --strict-config <config...>`,`Include the selected strict ESLint config.`).choices(Object.values(s)).argParser((e,t)=>[...new Set([...t||[],e])]).conflicts([`legacy-config`])).addOption(new f(`--legacy, --legacy-config <config>`,`Include the selected legacy ESLint config.`).choices(Object.values(i)).conflicts([`runtime`,`strict-config`])).addOption(new f(`--pm, --package-manager <pm>`,`Explicitly tell the CLI to use selected package manager.`).choices(Object.values(a))).addOption(new f(`--create-eslint-file [bool]`,`Explicitly tell the CLI to create ${t} file.`).choices(Object.values(c))).addOption(new f(`--skip-install [bool]`,`Explicitly tell the CLI to skip installing packages.`).choices(Object.values(c))).parse().opts();return{...p,...p.strictConfig===void 0?null:{strictConfig:p.strictConfig.reduce((e,t)=>{let{language:n,runtime:i}=p,a=t===s.IMPORT,c=i&&[o.REACT,o.NEXT].includes(i)&&t===s.REACT,l=n===r.TYPESCRIPT&&t===s.TYPESCRIPT;return(a||c||l)&&e.push(t),e},[])},...p.createEslintFile===void 0?null:{createEslintFile:p.createEslintFile===!0?c.TRUE:p.createEslintFile},...p.skipInstall===void 0?null:{skipInstall:p.skipInstall===!0?c.TRUE:p.skipInstall}}};export{p as default};
@@ -0,0 +1 @@
1
+ import e from"./getCommands.mjs";import t from"cross-spawn";var n=async n=>{let[r,...i]=e(n);return new Promise((e,n)=>{t(r,i,{stdio:`inherit`,env:{...process.env,ADBLOCK:`1`,NODE_ENV:`development`,DISABLE_OPENCOLLECTIVE:`1`}}).on(`close`,t=>{if(t!==0){n(Error(`${r} ${i.join(` `)}`,{cause:`package-failed`}));return}e()})})};export{n as default};
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{configs as e,defaults as t,eslintConfigName as n,formatters as r,languages as i,legacyConfigs as a,runtimes as o,strictConfigs as s}from"./constants/index.mjs";import c from"./helpers/getConfigUrl.mjs";import{exit as l,handleSigTerm as u,onCancel as d,onPromptState as f}from"./utils/index.mjs";import p from"./helpers/createEslintConfigFile.mjs";import m from"./helpers/getArgs.mjs";import h from"./helpers/getCommands.mjs";import g from"./helpers/installPackages.mjs";import _ from"picocolors";import v from"prompts";process.on(`SIGINT`,u),process.on(`SIGTERM`,u);const y=async()=>{let l=await m();if(l.config===null){let{configBoolean:n}=await v({type:`toggle`,name:`configBoolean`,message:`Config?`,initial:t.config===e.EXTENDED,active:`Extended`,inactive:`Legacy`,onState:f},{onCancel:d}),r=n?e.EXTENDED:e.LEGACY;l={...l,config:r,...r===e.EXTENDED?{legacyConfig:null}:{runtime:null}}}if(l.language===null){let{languageBoolean:e}=await v({type:`toggle`,name:`languageBoolean`,message:`Are you using ${_.blue(`typescript`)}?`,initial:t.language===i.TYPESCRIPT,active:`Yes`,inactive:`No`,onState:f},{onCancel:d}),n=e?i.TYPESCRIPT:i.JAVASCRIPT;l={...l,language:n}}if(l.formatter===null){let{formatterBoolean:e}=await v({type:`toggle`,name:`formatterBoolean`,message:`Are you using ${_.cyan(`prettier`)}?`,initial:t.formatter===r.PRETTIER,active:`Yes`,inactive:`No`,onState:f},{onCancel:d}),n=e?r.PRETTIER:null;l={...l,formatter:n}}if(l.config===e.EXTENDED){if(!l.runtime){let{runtime:e}=await v({type:`select`,name:`runtime`,message:`Are you using?`,choices:[{title:`React/React Router/Remix`,description:_.cyanBright(`You are using React.js library or Remix ( React Router 7 ) framework`),value:o.REACT},{title:`Next`,description:_.blackBright(`You are using Next.js framework`),value:o.NEXT},{title:`Node`,description:_.greenBright(`You are using Node or any other frameworks of it`),value:o.NODE}],onState:f},{onCancel:d});l={...l,runtime:e}}if(!l.strictConfig){let{hasStrictConfig:e}=await v({type:`toggle`,name:`hasStrictConfig`,message:`Do you want to add ${_.cyan(`strict`)} configs?`,initial:t.strictConfig,active:`Yes`,inactive:`No`,onState:f},{onCancel:d});if(e){let{strictConfig:e}=await v({type:`multiselect`,name:`strictConfig`,message:`Select Strict Configs:`,min:1,choices:[{title:`Import`,description:_.yellowBright(`Strict Import config`),value:s.IMPORT},...l.runtime&&[o.REACT,o.NEXT].includes(l.runtime)?[{title:`React`,description:_.cyanBright(`Strict React config`),value:s.REACT}]:[],...l.language===i.TYPESCRIPT?[{title:`TypeScript`,description:_.blueBright(`Strict TypeScript config`),value:s.TYPESCRIPT}]:[]],onState:f},{onCancel:d});l={...l,strictConfig:e}}else l={...l,strictConfig:null}}}if(l.config===e.LEGACY){if(!l.legacyConfig){let{legacyConfig:e}=await v({type:`select`,name:`legacyConfig`,message:`Are you using?`,choices:[{title:`Base Config`,description:_.greenBright(`eslint-config-airbnb-base`),value:a.BASE},{title:`React Config`,description:_.cyanBright(`eslint-config-airbnb`),value:a.REACT}],onState:f},{onCancel:d});l={...l,legacyConfig:e}}if(l.legacyConfig===a.REACT){let{reactHooks:e}=await v({type:`toggle`,name:`reactHooks`,message:`Are you using hooks?`,initial:t.legacyReactHooks,active:`Yes`,inactive:`No`,onState:f},{onCancel:d}),n=e?a.REACT_HOOKS:l.legacyConfig;l={...l,legacyConfig:n}}}if(l.createEslintFile===null){let{createEslintFile:e}=await v({type:`toggle`,name:`createEslintFile`,message:`Should I create an ${_.blue(n)} file for you?`,initial:t.createEslintFile,active:`Yes`,inactive:`No`,onState:f},{onCancel:d});l={...l,createEslintFile:e}}if(l.skipInstall===null){let{skipInstall:e}=await v({type:`toggle`,name:`skipInstall`,message:`Do you want to skip the package installation?`,initial:t.skipInstall,active:`Yes`,inactive:`No`,onState:f},{onCancel:d});l={...l,skipInstall:e}}let u=l,y=h(u).join(` `);console.log(),l.createEslintFile&&await p(u),l.skipInstall?(console.log(`${_.yellowBright(`No Worries`)}, you can install the packages yourself using your ${_.blue(`favourite`)} package manager (${u.packageManager}, maybe? 🤔)`),console.log(),console.log(_.cyan(`Command:`)),console.log(_.blue(y))):(console.log(`${_.blue(`Installing`)} packages using ${_.cyanBright(u.packageManager)}, please wait...`),await g(u),console.log(),console.log(_.yellowBright(`Installation Completed`)),console.log(),console.log(_.cyan(`Executed Command:`)),console.log(_.blue(y))),console.log(),console.log(_.cyan(l.createEslintFile?`Created Config:`:`Config:`)),console.log(c(u)?.url),console.log()};try{await y()}catch(e){e instanceof Error?l(e):console.error(e)}export{};
@@ -0,0 +1 @@
1
+ var e=`create-airbnb-x-config`,t=`3.0.0-beta-2`;export{e as name,t as version};
@@ -0,0 +1,2 @@
1
+ import e from"picocolors";import t from"node:path";const n=t.resolve(`.`),r=()=>process.exit(0),i=e=>{e.aborted&&(process.stdout.write(`\x1B[?25h`),process.stdout.write(`
2
+ `),process.exit(1))},a=()=>{console.error(`👋 Exiting, bye bye.`),process.exit(1)},o=t=>{console.log(`Aborting installation.`),t.cause===`package-failed`?console.log(`${e.red(t.message)} has failed.`):console.log(`${e.red(`Unexpected error. Please report it as a bug:`)}\n`,t),process.exit(1)};export{o as exit,r as handleSigTerm,a as onCancel,i as onPromptState,n as rootPath};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-airbnb-x-config",
3
- "version": "2.3.2",
3
+ "version": "3.0.0-beta-2",
4
4
  "description": "Airbnb Extended Config CLI",
5
5
  "keywords": [
6
6
  "eslint",
@@ -25,38 +25,39 @@
25
25
  },
26
26
  "license": "MIT",
27
27
  "author": "Nisharg Shah <nishargshah3101@gmail.com>",
28
- "type": "commonjs",
29
- "main": "dist/index.js",
30
- "types": "dist/index.d.ts",
28
+ "type": "module",
29
+ "exports": {
30
+ ".": "./dist/index.mjs",
31
+ "./package.json": "./package.json"
32
+ },
33
+ "main": "./dist/index.mjs",
34
+ "module": "./dist/index.mjs",
35
+ "types": "./dist/index.d.mts",
31
36
  "bin": {
32
- "create-airbnb-extended-config": "./dist/index.js",
33
- "create-airbnb-x-config": "./dist/index.js"
37
+ "create-airbnb-extended-config": "./dist/index.mjs",
38
+ "create-airbnb-x-config": "./dist/index.mjs"
34
39
  },
35
40
  "dependencies": {
36
- "commander": "^14.0.1",
41
+ "commander": "^14.0.2",
37
42
  "cross-spawn": "^7.0.6",
38
- "package-manager-detector": "^0.2.11",
43
+ "package-manager-detector": "^1.6.0",
39
44
  "picocolors": "^1.1.1",
40
45
  "prompts": "^2.4.2"
41
46
  },
42
47
  "devDependencies": {
43
48
  "@types/cross-spawn": "^6.0.6",
44
49
  "@types/prompts": "^2.4.9",
45
- "rimraf": "^6.0.1",
46
- "tsc-alias": "^1.8.16",
47
- "tsx": "^4.20.5",
48
- "typescript": "^5.9.2"
50
+ "tsdown": "^0.16.8",
51
+ "tsx": "^4.21.0"
49
52
  },
50
53
  "engines": {
51
- "node": ">=16.0.0"
54
+ "node": ">=18.0.0"
52
55
  },
53
56
  "scripts": {
54
- "prebuild": "rimraf ./dist",
55
- "build": "tsc -b",
56
- "postbuild": "tsc-alias",
57
- "build:templates": "tsx lib/templates/index.ts",
57
+ "build": "tsdown",
58
+ "build:dev": "tsdown --watch",
58
59
  "dev": "tsx index.ts",
59
- "start": "node ./dist/index.js",
60
+ "start": "node ./dist/index.mjs",
60
61
  "typecheck": "tsc --noEmit"
61
62
  }
62
63
  }
@@ -1,38 +0,0 @@
1
- export declare const languages: {
2
- readonly REACT: "react";
3
- readonly NEXT: "next";
4
- readonly NODE: "node";
5
- };
6
- export declare const strictConfigs: {
7
- readonly IMPORT: "import";
8
- readonly REACT: "react";
9
- readonly TYPESCRIPT: "typescript";
10
- };
11
- export declare const configTypes: {
12
- readonly EXTENDED: "extended";
13
- readonly LEGACY: "legacy";
14
- };
15
- export declare const defaults: {
16
- readonly configType: "extended";
17
- readonly typescript: true;
18
- readonly prettier: true;
19
- readonly strictConfig: false;
20
- readonly legacyReactHooks: true;
21
- readonly createESLintFile: true;
22
- readonly skipInstall: false;
23
- };
24
- export declare const packageManagers: {
25
- readonly NPM: "npm";
26
- readonly YARN: "yarn";
27
- readonly PNPM: "pnpm";
28
- readonly BUN: "bun";
29
- };
30
- export declare const legacyConfigs: {
31
- readonly BASE: "base";
32
- readonly REACT: "react";
33
- };
34
- export declare const legacyLanguages: {
35
- readonly BASE: "base";
36
- readonly REACT: "react";
37
- readonly REACT_HOOKS: "react-hooks";
38
- };
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.legacyLanguages = exports.legacyConfigs = exports.packageManagers = exports.defaults = exports.configTypes = exports.strictConfigs = exports.languages = void 0;
4
- exports.languages = {
5
- REACT: 'react',
6
- NEXT: 'next',
7
- NODE: 'node',
8
- };
9
- exports.strictConfigs = {
10
- IMPORT: 'import',
11
- REACT: 'react',
12
- TYPESCRIPT: 'typescript',
13
- };
14
- exports.configTypes = {
15
- EXTENDED: 'extended',
16
- LEGACY: 'legacy',
17
- };
18
- exports.defaults = {
19
- configType: exports.configTypes.EXTENDED,
20
- typescript: true,
21
- prettier: true,
22
- strictConfig: false,
23
- legacyReactHooks: true,
24
- createESLintFile: true,
25
- skipInstall: false,
26
- };
27
- exports.packageManagers = {
28
- NPM: 'npm',
29
- YARN: 'yarn',
30
- PNPM: 'pnpm',
31
- BUN: 'bun',
32
- };
33
- exports.legacyConfigs = {
34
- BASE: 'base',
35
- REACT: 'react',
36
- };
37
- exports.legacyLanguages = {
38
- BASE: 'base',
39
- REACT: 'react',
40
- REACT_HOOKS: 'react-hooks',
41
- };
@@ -1,4 +0,0 @@
1
- import type { GetConfigUrl } from '../helpers/getConfigUrl';
2
- type CreateESLintConfigFile = (args: Parameters<GetConfigUrl>[0]) => Promise<void>;
3
- declare const createESLintConfigFile: CreateESLintConfigFile;
4
- export default createESLintConfigFile;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- const promises_1 = __importDefault(require("node:fs/promises"));
49
- const node_path_1 = __importDefault(require("node:path"));
50
- const getConfigUrl_1 = __importStar(require("../helpers/getConfigUrl"));
51
- const utils_1 = require("../utils");
52
- const createESLintConfigFile = (args) => __awaiter(void 0, void 0, void 0, function* () {
53
- try {
54
- const config = (0, getConfigUrl_1.default)(args);
55
- if (!config)
56
- return;
57
- const configPath = node_path_1.default.join(utils_1.packageRootPath, config.path);
58
- const data = yield promises_1.default.readFile(configPath, { encoding: 'utf8' });
59
- yield promises_1.default.writeFile(`${utils_1.rootPath}/${getConfigUrl_1.eslintConfigName}`, data, {
60
- encoding: 'utf8',
61
- });
62
- }
63
- catch (error) {
64
- console.error(error);
65
- }
66
- });
67
- exports.default = createESLintConfigFile;
@@ -1,44 +0,0 @@
1
- import { configTypes, languages, packageManagers, strictConfigs } from '../constants';
2
- import type { ValueOf } from '../utils/types';
3
- export interface ProgramOpts {
4
- extended: true;
5
- legacy: true;
6
- typescript: true;
7
- javascript: true;
8
- prettier: true;
9
- react: true;
10
- reactRouter: true;
11
- next: true;
12
- node: true;
13
- strictImportConfig: true;
14
- strictReactConfig: true;
15
- strictTypescriptConfig: true;
16
- legacyBaseConfig: true;
17
- legacyReactConfig: true;
18
- legacyReactHooksConfig: true;
19
- useNpm: true;
20
- useYarn: true;
21
- usePnpm: true;
22
- useBun: true;
23
- createEslintFile: true;
24
- skipInstall: true;
25
- }
26
- interface GetArgsLegacyConfig {
27
- base?: boolean | null;
28
- react?: boolean | null;
29
- reactHooks?: boolean | null;
30
- }
31
- export interface GetArgsOutput {
32
- configType: ValueOf<typeof configTypes> | null;
33
- typescript: boolean | null;
34
- prettier: true | null;
35
- strictConfig: ValueOf<typeof strictConfigs>[] | null;
36
- language: ValueOf<typeof languages> | null;
37
- legacyConfig: GetArgsLegacyConfig | null;
38
- packageManager: ValueOf<typeof packageManagers> | null;
39
- createESLintFile: true | null;
40
- skipInstall: true | null;
41
- }
42
- type GetArgs = () => Promise<GetArgsOutput>;
43
- declare const getArgs: GetArgs;
44
- export default getArgs;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const constants_1 = require("../constants");
16
- const getPackageManager_1 = require("../helpers/getPackageManager");
17
- const program_1 = __importDefault(require("../helpers/program"));
18
- const getConfigType = (opts) => {
19
- const { extended, legacy } = opts;
20
- if (extended)
21
- return constants_1.configTypes.EXTENDED;
22
- if (legacy)
23
- return constants_1.configTypes.LEGACY;
24
- return null;
25
- };
26
- const getTypescript = (opts) => {
27
- const { typescript, javascript } = opts;
28
- if (typescript)
29
- return true;
30
- if (javascript)
31
- return false;
32
- return null;
33
- };
34
- const getStrictConfig = (opts) => {
35
- const { strictImportConfig, strictReactConfig, strictTypescriptConfig } = opts;
36
- const strictConfig = [];
37
- if (strictImportConfig)
38
- strictConfig.push(constants_1.strictConfigs.IMPORT);
39
- if (strictReactConfig)
40
- strictConfig.push(constants_1.strictConfigs.REACT);
41
- if (strictTypescriptConfig)
42
- strictConfig.push(constants_1.strictConfigs.TYPESCRIPT);
43
- return strictConfig.length > 0 ? strictConfig : null;
44
- };
45
- const getLanguage = (opts) => {
46
- const { react, reactRouter, next, node } = opts;
47
- if (react || reactRouter)
48
- return constants_1.languages.REACT;
49
- if (next)
50
- return constants_1.languages.NEXT;
51
- if (node)
52
- return constants_1.languages.NODE;
53
- return null;
54
- };
55
- const getLegacyConfig = (opts) => {
56
- const { legacyBaseConfig, legacyReactConfig, legacyReactHooksConfig } = opts;
57
- return {
58
- base: legacyBaseConfig !== null && legacyBaseConfig !== void 0 ? legacyBaseConfig : (legacyReactConfig ? false : null),
59
- react: legacyReactConfig !== null && legacyReactConfig !== void 0 ? legacyReactConfig : (legacyBaseConfig ? false : null),
60
- reactHooks: legacyReactHooksConfig !== null && legacyReactHooksConfig !== void 0 ? legacyReactHooksConfig : null,
61
- };
62
- };
63
- const getPackageManagerFromOpts = (opts) => {
64
- const { useNpm, useYarn, usePnpm, useBun } = opts;
65
- if (useNpm)
66
- return constants_1.packageManagers.NPM;
67
- if (useYarn)
68
- return constants_1.packageManagers.YARN;
69
- if (usePnpm)
70
- return constants_1.packageManagers.PNPM;
71
- if (useBun)
72
- return constants_1.packageManagers.BUN;
73
- return null;
74
- };
75
- const getArgs = () => __awaiter(void 0, void 0, void 0, function* () {
76
- var _a;
77
- const opts = program_1.default.opts();
78
- return {
79
- configType: getConfigType(opts),
80
- typescript: getTypescript(opts),
81
- prettier: opts.prettier ? true : null,
82
- strictConfig: getStrictConfig(opts),
83
- language: getLanguage(opts),
84
- legacyConfig: getLegacyConfig(opts),
85
- packageManager: (_a = getPackageManagerFromOpts(opts)) !== null && _a !== void 0 ? _a : (yield (0, getPackageManager_1.getPackageManager)()),
86
- createESLintFile: opts.createEslintFile ? true : null,
87
- skipInstall: opts.skipInstall ? true : null,
88
- };
89
- });
90
- exports.default = getArgs;
@@ -1,4 +0,0 @@
1
- import type { NonNullableArgsOutput } from '../utils/types';
2
- export type GetCommands = (args: Omit<NonNullableArgsOutput, 'createESLintFile' | 'skipInstall'>) => string[];
3
- declare const getCommands: GetCommands;
4
- export default getCommands;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../constants");
4
- const getCommands = (args) => {
5
- const { configType, typescript, prettier, language, packageManager, legacyConfig } = args;
6
- const pmInstallationCommand = {
7
- [constants_1.packageManagers.NPM]: 'install',
8
- [constants_1.packageManagers.YARN]: 'add',
9
- [constants_1.packageManagers.PNPM]: 'install',
10
- [constants_1.packageManagers.BUN]: 'add',
11
- };
12
- const commands = [
13
- packageManager,
14
- pmInstallationCommand[packageManager],
15
- '-D',
16
- 'eslint',
17
- '@eslint/compat',
18
- '@eslint/js',
19
- 'eslint-config-airbnb-extended',
20
- ];
21
- if (typescript) {
22
- commands.push('eslint-import-resolver-typescript', 'typescript-eslint');
23
- }
24
- if (prettier) {
25
- commands.push('prettier', 'eslint-plugin-prettier', 'eslint-config-prettier');
26
- }
27
- if (configType === constants_1.configTypes.EXTENDED) {
28
- commands.push('@stylistic/eslint-plugin@^3.1.0', 'eslint-plugin-import-x');
29
- if (language === constants_1.languages.REACT || language === constants_1.languages.NEXT) {
30
- commands.push('eslint-plugin-react', 'eslint-plugin-react-hooks', 'eslint-plugin-jsx-a11y');
31
- }
32
- if (language === constants_1.languages.NEXT) {
33
- commands.push('@next/eslint-plugin-next');
34
- }
35
- if (language === constants_1.languages.NODE) {
36
- commands.push('eslint-plugin-n');
37
- }
38
- }
39
- if (configType === constants_1.configTypes.LEGACY) {
40
- commands.push('eslint-plugin-import');
41
- if (legacyConfig) {
42
- const { react, reactHooks } = legacyConfig;
43
- if (react) {
44
- commands.push('eslint-plugin-react', 'eslint-plugin-jsx-a11y');
45
- }
46
- if (reactHooks) {
47
- commands.push('eslint-plugin-react-hooks');
48
- }
49
- }
50
- }
51
- return commands;
52
- };
53
- exports.default = getCommands;
@@ -1,10 +0,0 @@
1
- import type { NonNullableArgsOutput } from '../utils/types';
2
- export declare const eslintConfigName = "eslint.config.mjs";
3
- export declare const baseGithubUrl = "https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/packages/create-airbnb-x-config/templates";
4
- interface GetConfigUrlOutput {
5
- path: string;
6
- url: string;
7
- }
8
- export type GetConfigUrl = (args: Pick<NonNullableArgsOutput, 'configType' | 'typescript' | 'prettier' | 'strictConfig' | 'language' | 'legacyConfig'>) => GetConfigUrlOutput | null;
9
- declare const getConfigUrl: GetConfigUrl;
10
- export default getConfigUrl;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.baseGithubUrl = exports.eslintConfigName = void 0;
7
- const picocolors_1 = __importDefault(require("picocolors"));
8
- const constants_1 = require("../constants");
9
- const constants_2 = require("../lib/templates/constants");
10
- exports.eslintConfigName = 'eslint.config.mjs';
11
- exports.baseGithubUrl = 'https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/packages/create-airbnb-x-config/templates';
12
- const getConfigUrl = (args) => {
13
- const { configType, typescript, prettier, strictConfig, language, legacyConfig } = args;
14
- const isLegacy = configType === constants_1.configTypes.LEGACY;
15
- const prettierText = prettier ? 'prettier' : null;
16
- const tsOrJsText = typescript ? 'ts' : 'js';
17
- const legacyLanguage = (() => {
18
- if (configType === constants_1.configTypes.EXTENDED)
19
- return null;
20
- if (legacyConfig.base)
21
- return constants_1.legacyLanguages.BASE;
22
- // NOTE: React Hooks should come first in the condition, because if someone selects "Yes", it must appear in the config otherwise, it won’t be reached.
23
- if (legacyConfig.reactHooks)
24
- return constants_1.legacyLanguages.REACT_HOOKS;
25
- if (legacyConfig.react)
26
- return constants_1.legacyLanguages.REACT;
27
- return null;
28
- })();
29
- const strictOrDefaultText = (() => {
30
- if (!strictConfig || strictConfig.length === 0)
31
- return [constants_2.subFolders.DEFAULT];
32
- const strictFolder = [...strictConfig].sort((a, b) => a.localeCompare(b)).join('-');
33
- return [constants_2.subFolders.STRICT, strictFolder];
34
- })();
35
- const path = [
36
- ...(isLegacy ? [constants_1.configTypes.LEGACY, legacyLanguage] : [language]),
37
- prettierText,
38
- tsOrJsText,
39
- ...strictOrDefaultText,
40
- exports.eslintConfigName,
41
- ]
42
- .filter(Boolean)
43
- .join('/');
44
- return {
45
- path: `templates/${path}`,
46
- url: picocolors_1.default.blue(`${exports.baseGithubUrl}/${path}`),
47
- };
48
- };
49
- exports.default = getConfigUrl;
@@ -1,6 +0,0 @@
1
- import { packageManagers } from '../constants';
2
- import type { ValueOf } from '../utils/types';
3
- export type PackageManager = ValueOf<typeof packageManagers>;
4
- type GetPackageManager = () => Promise<PackageManager>;
5
- export declare const getPackageManager: GetPackageManager;
6
- export {};
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getPackageManager = void 0;
13
- const detect_1 = require("package-manager-detector/detect");
14
- const constants_1 = require("../constants");
15
- const getPackageManager = () => __awaiter(void 0, void 0, void 0, function* () {
16
- const pm = yield (0, detect_1.detect)();
17
- if (!pm)
18
- return constants_1.packageManagers.NPM;
19
- const { name } = pm;
20
- if (name === constants_1.packageManagers.PNPM)
21
- return constants_1.packageManagers.PNPM;
22
- if (name === constants_1.packageManagers.YARN)
23
- return constants_1.packageManagers.YARN;
24
- if (name === constants_1.packageManagers.BUN)
25
- return constants_1.packageManagers.BUN;
26
- return constants_1.packageManagers.NPM;
27
- });
28
- exports.getPackageManager = getPackageManager;
@@ -1,7 +0,0 @@
1
- import type { GetCommands } from '../helpers/getCommands';
2
- type InstallPackages = (args: Parameters<GetCommands>[0]) => Promise<void>;
3
- /**
4
- * @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/helpers/install.ts
5
- */
6
- declare const installPackages: InstallPackages;
7
- export default installPackages;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const cross_spawn_1 = __importDefault(require("cross-spawn"));
16
- const getCommands_1 = __importDefault(require("../helpers/getCommands"));
17
- /**
18
- * @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/helpers/install.ts
19
- */
20
- const installPackages = (args) => __awaiter(void 0, void 0, void 0, function* () {
21
- const [packageManager, ...commands] = (0, getCommands_1.default)(args);
22
- return new Promise((resolve, reject) => {
23
- const child = (0, cross_spawn_1.default)(packageManager, commands, {
24
- stdio: 'inherit',
25
- env: Object.assign(Object.assign({}, process.env), { ADBLOCK: '1',
26
- // we set NODE_ENV to development as pnpm skips dev
27
- // dependencies when production
28
- NODE_ENV: 'development', DISABLE_OPENCOLLECTIVE: '1' }),
29
- });
30
- child.on('close', (code) => {
31
- if (code !== 0) {
32
- reject(new Error(`${packageManager} ${commands.join(' ')}`, { cause: 'package-failed' }));
33
- return;
34
- }
35
- resolve();
36
- });
37
- });
38
- });
39
- exports.default = installPackages;