@in-ch/setup
Version:
A tool for quick setup and configuration of essential project files.
106 lines (88 loc) • 23.3 kB
JavaScript
import{Command as lo}from"commander";import{Command as Nt}from"commander";import{Command as ct}from"commander";import{existsSync as lt}from"fs";import{execSync as q}from"child_process";var y={NPM:"npm",PNPM:"pnpm",YARN:"yarn"},A={NPM:"npm",PNPM:"pnpm",YARN:"yarn"},T={NPM:"npm install",PNPM:"pnpm add",YARN:"yarn add"},X=[{name:y.NPM,value:A.NPM},{name:y.PNPM,value:A.PNPM},{name:y.YARN,value:A.YARN},{name:"cancel",value:"cancel"}],c=[{name:y.NPM,value:T.NPM},{name:y.PNPM,value:T.PNPM},{name:y.YARN,value:T.YARN},{name:"cancel",value:"cancel"}];import qe from"fs";var Qe=()=>{let t=qe.readdirSync(process.cwd());return t.includes("yarn.lock")?"yarn add":t.includes("pnpm-lock.yaml")?"pnpm add":t.includes("package-lock.json")?"npm install":"default"},l=Qe;import Ze from"path";import{select as et}from"@inquirer/prompts";var Q=async()=>{console.log(`
Installing husky dependencies...
`);try{let t="husky -D",e=l();if(e==="default"&&(console.log(`The package manager could not be detected.
1. If this is not the project root, please run the command from the root directory.
2. If you have not installed the packages beforehand, please install them first and then try again.
`),e==="default")){let n=await et({message:`Which package manager would you like to use for installation?
`,choices:c});if(n==="cancel")return;e=n}let o=`${e} ${t}`;q(`${o} -D`,{stdio:"inherit"})}catch{console.error("\u{1F972} \u{1F972} \u{1F972} Failed to install dependencies..."),process.exit(1)}},Z=async()=>{q("npx husky init",{stdio:"inherit"})},ee=async()=>{let t=Ze.resolve(process.cwd(),"package.json"),e=await import("fs-extra");try{await e.access(t)}catch{console.error("Could not find the package.json file.");return}try{let o=await e.readFile(t,"utf-8"),n=JSON.parse(o);n.scripts||(n.scripts={}),n.scripts.test='echo "Error: no test specified" && exit 1',await e.writeFile(t,JSON.stringify(n,null,2),"utf-8"),console.log("package.json file updated successfully.")}catch(o){console.error("An error occurred while reading or modifying the package.json file:",o)}};import{execSync as ne}from"child_process";import{execSync as tt}from"child_process";import{Command as ot}from"commander";import{select as nt}from"@inquirer/prompts";var te=new ot().command("pm").description("Initialize package manager").action(async()=>x()),x=async()=>{try{let t=await nt({message:`Which package manager would you like to use?
`,choices:X});if(t==="cancel")return;tt(`${t} init`,{stdio:"inherit"})}catch(t){console.error(`\u{1F972} \u{1F972} \u{1F972} Failed to init package manager... to
`,t),process.exit(1)}};import{confirm as at}from"@inquirer/prompts";import{exec as it}from"child_process";function u(t){return new Promise((e,o)=>{it(`npm show ${t} version`,(n,a,s)=>{if(n){o(`Error fetching latest version: ${n.message}`);return}if(s){o(`Error: ${s}`);return}e(a.trim())})})}import{execSync as rt}from"child_process";import oe from"fs-extra";import st from"path";function C(t="@in-ch/setup"){try{let e=rt("npm root -g",{encoding:"utf-8"}).trim(),o=st.join(e,t,"package.json");if(oe.existsSync(o))return JSON.parse(oe.readFileSync(o,"utf-8"));throw new Error("package.json not found")}catch(e){return console.error("Error fetching global package.json:",e),null}}function j(){try{ne("npm --version",{stdio:"ignore"})}catch{x()}}async function r(){j();let t=await u("@in-ch/setup"),e=await C().version;e!==t&&await at({message:`The latest version is ${t}, but the current version is ${e}. An update is needed. Would you like to update?`})&&(ne("npm install @in-ch/setup@latest -g",{stdio:"inherit"}),console.log("Update completed successfully."))}import{confirm as mt}from"@inquirer/prompts";var ie=new ct().command("husky").description("Setup husky").action(async()=>w()),w=async()=>{if(await r(),[".husky"].filter(o=>lt(o)).length>0&&!await mt({message:"Husky settings are already configured. Do you still want to proceed with the setup?"})){console.log("canceled!");return}await Q(),await Z(),await ee()};import{existsSync as $t}from"fs";import{execSync as jt}from"child_process";import{Command as gt}from"commander";import{existsSync as ut}from"fs";import{execSync as b}from"child_process";import se from"fs";import{execSync as pt}from"child_process";import dt from"path";function F(t){try{let e=pt("npm root -g",{encoding:"utf8"}).trim();return dt.resolve(e,t)}catch(e){return console.error("Error resolving global package path:",e),null}}import re from"path";function p(t){if(!t)throw new Error("File name is required");if(process.env.NODE_ENV==="development")return re.resolve(process.cwd(),"const/config",t)+N[t];{let o=F("@in-ch/setup");if(!o)throw new Error("Could not resolve global path for @in-ch/setup");return re.resolve(o,"const/config",t)+N[t]}}import ft from"path";import{select as S}from"@inquirer/prompts";var ae=async()=>{console.log(`
Installing eslint dependencies...
`);try{let t="eslint @types/eslint eslint-plugin-jsdoc eslint-plugin-no-for-of-array eslint-plugin-vue @eslint/js typescript-eslint globals",e=l();if(e==="default"&&(console.log(`The package manager could not be detected.
1. If this is not the project root, please run the command from the root directory.
2. If you have not installed the packages beforehand, please install them first and then try again.
`),e==="default")){let n=await S({message:`Which package manager would you like to use for installation?
`,choices:c});if(n==="cancel")return;e=n}let o=`${e} ${t}`;b(`${o} -D`,{stdio:"inherit"})}catch{console.error("\u{1F972} \u{1F972} \u{1F972} Failed to install dependencies..."),process.exit(1)}},ce=async()=>{console.log(`
Installing eslint dependencies...
`);try{let t="eslint eslint-config-airbnb-base eslint-plugin-import @typescript-eslint/parser @typescript-eslint/eslint-plugin",e=l();if(e==="default"&&(console.log(`The package manager could not be detected.
1. If this is not the project root, please run the command from the root directory.
2. If you have not installed the packages beforehand, please install them first and then try again.
`),e==="default")){let n=await S({message:`Which package manager would you like to use for installation?
`,choices:c});if(n==="cancel")return;e=n}let o=`${e} ${t}`;b(`${o} -D`,{stdio:"inherit"})}catch{console.error("\u{1F972} \u{1F972} \u{1F972} Failed to install dependencies..."),process.exit(1)}},le=async()=>{console.log(`
Installing eslint dependencies...
`);try{let t="eslint eslint-config-google",e=l();if(e==="default"&&(console.log(`The package manager could not be detected.
1. If this is not the project root, please run the command from the root directory.
2. If you have not installed the packages beforehand, please install them first and then try again.
`),e==="default")){let n=await S({message:`Which package manager would you like to use for installation?
`,choices:c});if(n==="cancel")return;e=n}let o=`${e} ${t}`;b(`${o} -D`,{stdio:"inherit"})}catch{console.error("\u{1F972} \u{1F972} \u{1F972} Failed to install dependencies..."),process.exit(1)}},me=async()=>{console.log(`
Installing eslint dependencies...
`);try{let t="eslint eslint-config-xo",e=l();if(e==="default"&&(console.log(`The package manager could not be detected.
1. If this is not the project root, please run the command from the root directory.
2. If you have not installed the packages beforehand, please install them first and then try again.
`),e==="default")){let n=await S({message:`Which package manager would you like to use for installation?
`,choices:c});if(n==="cancel")return;e=n}let o=`${e} ${t}`;b(`${o} -D`,{stdio:"inherit"})}catch{console.error("\u{1F972} \u{1F972} \u{1F972} Failed to install dependencies..."),process.exit(1)}},v=t=>{let e=process.cwd(),o=se.readFileSync(p(t),"utf-8");try{se.writeFileSync(ft.join(e,"eslint.config.mjs"),o,"utf-8"),console.log(`
\u{1F389} Successfully created the ESLint configuration file.`)}catch(n){console.error(`\u{1F972} \u{1F972} \u{1F972} Failed to setup eslint... to
`,n),process.exit(1)}};import{confirm as ht,select as yt}from"@inquirer/prompts";var pe=new gt().command("eslint").description("Setup eslint file").action(async()=>$()),$=async()=>{if(await r(),[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml",".eslintrc.config.mjs",".eslintrc"].filter(n=>ut(n)).length>0&&!await ht({message:"At least one ESLint file exists. Do you still want to proceed with the setup?"})){console.log("canceled!");return}let o=await yt({message:"Choose an ESLint configuration type:",choices:L});o===P.airbnb?(console.log("Setting up Airbnb ESLint configuration..."),ce(),v(i.AIRBNB)):o===P.google?(console.log("Setting up Google ESLint configuration..."),le(),v(i.GOOGLE)):o===P.xo?(console.log("Setting up XO ESLint configuration..."),me(),v(i.XO)):(console.log("Setting up Import Sort ESLint configuration..."),ae(),v(i.ESLINT))};import{Command as kt}from"commander";import{existsSync as xt}from"fs";import{execSync as O}from"child_process";import de from"fs";import Ct from"path";var fe=async()=>{O("git init",{stdio:"inherit"})},ge=()=>{let t=process.cwd(),e=de.readFileSync(p(i.GITMESSAGE),"utf-8");try{de.writeFileSync(Ct.join(t,".gitmessage"),e,"utf-8"),O("git config commit.template .gitmessage"),O("git config init.defaultBranch main"),console.log("\u{1F389} Successfully created the git message configuration file. \u{1F389}"),console.log("You can now write commits following the template using the commit button in your IDE tool or the `git commit` command in the terminal.")}catch(o){console.error(`\u{1F972} \u{1F972} \u{1F972} Failed to setup git message... to
`,o),process.exit(1)}};import{confirm as wt}from"@inquirer/prompts";var ue=new kt().command("gitmessage").description("Setup git message file").action(async()=>D()),D=async()=>{if(await r(),!xt(".git")){if(!await wt({message:"Git is not initialized. Would you like to initialize it?"})){console.log("canceled!");return}await fe()}ge()};import{Command as St}from"commander";import{existsSync as Pt}from"fs";import{execSync as vt}from"child_process";import G from"fs";import he from"path";import{select as bt}from"@inquirer/prompts";var ye=async()=>{console.log(`
Installing prettier dependencies...
`);try{let t="prettier prettier-plugin-sort-re-exports @trivago/prettier-plugin-sort-imports",e=l();if(e==="default"&&(console.log(`The package manager could not be detected.
1. If this is not the project root, please run the command from the root directory.
2. If you have not installed the packages beforehand, please install them first and then try again.
`),e==="default")){let n=await bt({message:`Which package manager would you like to use for installation?
`,choices:c});if(n==="cancel")return;e=n}let o=`${e} ${t}`;vt(`${o} -D`,{stdio:"inherit"})}catch(t){console.error(`\u{1F972} Fail to install prettier dependencies.... to
`+t),process.exit(1)}},Ce=()=>{let t=process.cwd(),e=G.readFileSync(p(i.PRETTIER),"utf-8"),o=`node_modules/
dist/
build/
coverage/
*.min.js
*.bundle.js
*.config.js
*.cjs
logs/
*.log
.vscode/
.DS_Store
.env
.env.*
package-lock.json
yarn.lock
pnpm-lock.yaml`;try{G.writeFileSync(he.join(t,".prettierrc.cjs"),e,"utf-8"),G.writeFileSync(he.join(t,".prettierignore"),o,"utf-8"),console.log("\u{1F389} Prettier configuration file has been created.")}catch(n){console.error(`\u{1F972} Failed to setup prettier... to
`,n),process.exit(1)}};import{confirm as It}from"@inquirer/prompts";var ke=new St().command("prettier").description("Setup prettier file").action(async()=>R()),R=async()=>{if(await r(),[".prettierrc",".prettierrc.json",".prettierrc.yml",".prettierrc.yaml",".prettierrc.js",".prettierrc.cjs","prettier.config.js","prettier.config.cjs"].filter(o=>Pt(o)).length>0&&!await It({message:"At least one Prettier file exists. Do you still want to proceed with the setup?"})){console.log("canceled!");return}ye(),Ce()};import{Command as Et}from"commander";import{existsSync as At}from"fs";import{execSync as xe}from"child_process";import{select as Mt}from"@inquirer/prompts";var we=async()=>{console.log(`
Installing typescript dependencies...
`);try{let t="typescript @types/node @types/react",e=l();if(e==="default"&&(console.log(`The package manager could not be detected.
1. If this is not the project root, please run the command from the root directory.
2. If you have not installed the packages beforehand, please install them first and then try again.
`),e==="default")){let n=await Mt({message:`Which package manager would you like to use for installation?
`,choices:c});if(n==="cancel")return;e=n}let o=`${e} ${t}`;xe(`${o} -D`,{stdio:"inherit"})}catch{console.error("\u{1F972} \u{1F972} \u{1F972} Failed to install dependencies..."),process.exit(1)}},ve=()=>{console.log("Configure Typescript"),xe("npx tsc --init")};var be=new Et().command("typescript").description("Setup typescript file").action(async()=>U()),U=async()=>{if(await r(),[".tsconfig.json"].filter(o=>At(o)).length>0){console.error("At least one Typescript file exists.");return}we(),ve()};var i={ESLINT:"eslint",PRETTIER:"prettier",TYPESCRIPT:"typescript",GITMESSAGE:"gitmessage",HUSKY:"husky",COMMIT_LINT:"commitlint",LINT_STAGE:"lintstage",AIRBNB:"airbnb",GOOGLE:"google",XO:"xo"},Tt=Object.entries(i).filter(([t])=>![i.AIRBNB,i.GOOGLE,i.XO].includes(t)).map(([t,e])=>({name:t,value:e})),Se=Tt.map(t=>t.value),V={[i.ESLINT]:()=>$(),[i.PRETTIER]:()=>R(),[i.TYPESCRIPT]:()=>U(),[i.GITMESSAGE]:()=>D(),[i.HUSKY]:()=>w(),[i.COMMIT_LINT]:()=>_()},N={[i.ESLINT]:".js",[i.PRETTIER]:".js",[i.TYPESCRIPT]:".json",[i.GITMESSAGE]:".txt",[i.COMMIT_LINT]:".json",[i.LINT_STAGE]:".json",[i.AIRBNB]:".js",[i.GOOGLE]:".js",[i.XO]:".js"},Pe=[{name:i.ESLINT,value:i.ESLINT},{name:i.PRETTIER,value:i.PRETTIER},{name:i.TYPESCRIPT,value:i.TYPESCRIPT},{name:i.GITMESSAGE,value:i.GITMESSAGE},{name:i.HUSKY,value:i.HUSKY},{name:i.COMMIT_LINT,value:i.COMMIT_LINT}],L=[{name:"Import Sort",value:"import-sort"},{name:"Airbnb",value:"airbnb"},{name:"Google",value:"google"},{name:"XO",value:"xo"}],P=L.reduce((t,e)=>(t[e.value]=e.value,t),{});import I from"fs";import Ie from"path";import{select as Ft}from"@inquirer/prompts";var Me=async()=>{console.log(`
Installing eslint dependencies...
`);try{let t=["@commitlint/config-conventional","@commitlint/cli","lint-staged"],e=l();if(e==="default"&&(console.log(`The package manager could not be detected.
1. If this is not the project root, please run the command from the root directory.
2. If you have not installed the packages beforehand, please install them first and then try again.
`),e==="default")){let n=await Ft({message:`Which package manager would you like to use for installation?
`,choices:c});if(n==="cancel")return;e=n}let o=`${e} ${t.join(" ")}`;jt(`${o} -D`,{stdio:"inherit"})}catch{console.error("\u{1F972} \u{1F972} \u{1F972} Failed to install commitlint's dependencies..."),process.exit(1)}},Ee=()=>{let t=process.cwd(),e=I.readFileSync(p(i.COMMIT_LINT),"utf-8"),o=I.readFileSync(p(i.LINT_STAGE),"utf-8");try{I.writeFileSync(Ie.join(t,".commitlintrc.json"),e,"utf-8"),I.writeFileSync(Ie.join(t,".lintstagedrc.json"),o,"utf-8"),console.log(`
\u{1F389} Successfully created the Commitlint configuration file.`)}catch(n){console.error(`\u{1F972} \u{1F972} \u{1F972} Failed to setup commit lint... to
`,n),process.exit(1)}};import{confirm as Lt}from"@inquirer/prompts";var Ae=new Nt().command("commitlint").description("Setup commit lint").action(async()=>_()),_=async()=>{if(await r(),!$t(".husky")){if(!await Lt({message:"Husky is not initialized. Would you like to initialize it?"})){console.log("canceled!");return}await w()}Me(),Ee()};import{exec as Gt}from"child_process";import{Command as Rt}from"commander";import{execSync as Ot}from"child_process";import Dt from"os";var Te=t=>{try{return Ot(`which ${t}`,{stdio:"ignore"}),!0}catch{return!1}};function B(t){let e=Dt.platform(),o;if(e==="win32")o=`start "" "notepad" "${t}"`;else if(e==="darwin")Te("code")?o=`open -a "Visual Studio Code" "${t}"`:o=`open -a "TextEdit" "${t}"`;else if(e==="linux")Te("code")?o=`code "${t}"`:o=`xdg-open "${t}"`;else return console.error("Unsupported platform"),"";return o}import{select as Ut}from"@inquirer/prompts";var je=new Rt().command("edit").description("edit config file").action(async()=>{await r();let t=await Ut({message:"What do you want to edit config file.",choices:Pe}),e=p(t),o=B(e);Gt(o,n=>{n?console.error("Failed to open file or folder:",n):console.log(`Opened: ${e}`)})});import{Command as Vt}from"commander";import{checkbox as _t}from"@inquirer/prompts";var Fe=new Vt().command("init").description("Easy Setup various configs").action(async()=>{await r();let t=await _t({message:`Which files do you want to install?
`,choices:Se});for(let e of t)V[e]!==void 0&&await V[e]()});import{Command as Bt}from"commander";var Ne=new Bt().command("latest").description("Check latest version of @in-ch/cli package").action(()=>Yt()),Yt=async()=>{await r();let t=await u("@in-ch/setup");console.log(`The latest version of @in-ch/setup is v${t}`)};import{Command as Jt}from"commander";import{execSync as Y}from"child_process";import{confirm as Wt,input as Ht}from"@inquirer/prompts";var $e=async()=>{console.log(`
Checking Lighthouse dependencies...
`);try{let t=Y("lighthouse --version",{encoding:"utf-8"});console.log("Lighouse version: ",t.trim()+`
`)}catch{await Wt({message:"Lighthouse is not installed. Would you like to install it?"})&&Y("npm i lighthouse -g",{stdio:"inherit"})}},Le=async(t=!1)=>{let e=await Ht({message:"Enter the web address:",default:"http://localhost:3000"}),o=!1;try{let n=new URL(e);o=n.protocol==="http:"||n.protocol==="https:"}catch{o=!1}if(!o){console.error("Invalid web address. Please enter a valid URL.");return}Y(`lighthouse ${e} ${t?'--chrome-flags="--headless"':" --output=html --view"} `,{stdio:"inherit"})};var Oe=new Jt().command("lg").description("Run a Lighthouse test").option("--headless","Run Lighthouse in headless mode").action(async t=>zt(t.headless)),zt=async(t=!1)=>{await r(),await $e(),await Le(t)};import{Command as Xt}from"commander";import qt from"fs";var Kt={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",orange:"\x1B[38;5;214m",white:"\x1B[37m",lightBlack:"\x1B[90m",lightRed:"\x1B[91m",lightGreen:"\x1B[92m",lightYellow:"\x1B[93m",lightBlue:"\x1B[94m",lightMagenta:"\x1B[95m",lightCyan:"\x1B[96m",lightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgLightBlack:"\x1B[100m",bgLightRed:"\x1B[101m",bgLightGreen:"\x1B[102m",bgLightYellow:"\x1B[103m",bgLightBlue:"\x1B[104m",bgLightMagenta:"\x1B[105m",bgLightCyan:"\x1B[106m",bgLightWhite:"\x1B[107m",default:"\x1B[0m"},f=Kt;function W(t){if(t.length===0||t[0]===void 0)return{column:[],rows:[]};let e=Object.keys(t.reduce((n,a)=>({...n,...a}),{})),o=t.map(n=>e.map(a=>n[a]||""));return{column:e,rows:o}}function H({data:t,textColor:e=f.default,headerColor:o=f.default,borderColor:n=f.default}){let{rows:a,column:s}=W(t),g=f[n??"default"],E=f[o??"default"],Be=f[e??"default"],k=s.map(m=>m.length+2).map((m,d)=>a.reduce((Ke,Xe)=>Math.max(Xe[d].length+2,Ke),m)),Ye=(m,d)=>`${Be}${m.padEnd(k[d])}`,We=(m,d)=>`${E}${m.padEnd(k[d])}`,He=()=>`${g}\u250C${s.map((m,d)=>"".padEnd(k[d]+1,"\u2500")).join("\u252C")}\u2510`,Je=()=>`${g}\u251C${s.map((m,d)=>"".padEnd(k[d]+1,"\u2500")).join("\u253C")}\u2524`,ze=()=>`${g}\u2514${s.map((m,d)=>"".padEnd(k[d]+1,"\u2500")).join("\u2534")}\u2518`,h="";return h+=He()+`
`,h+=`${g}\u2502 ${s.map(We).join(`${g}\u2502 `)}${g}\u2502
`,h+=Je()+`
`,a.forEach(m=>{h+=`${g}\u2502 ${m.map(Ye).join(`${g}\u2502 `)}\u2502
`}),h+=`${ze()}${f.default}
`,h}import{fileURLToPath as Qt}from"url";var De=new Xt().command("list").description("list all commands").action(async()=>{await r();let e=typeof import.meta<"u"?Qt(import.meta.url):__filename,o=qt.readFileSync(e,"utf-8"),n=/command\("(.+?)"\)\.description\("(.+?)"\)/g,a,s=[];for(;(a=n.exec(o))!==null;){let g=a[1],E=a[2];s.push({command:g,description:E})}console.log(`${f.orange}@in-ch/setup${f.white}'s commands
${H({data:s,borderColor:"lightBlack",textColor:"default",headerColor:"orange"})}
`)});import{execSync as Zt}from"child_process";import{Command as eo}from"commander";var Ge=new eo().command("update").description("Update package version").action(async()=>to()),to=async()=>{await j();let t=await u("@in-ch/setup");await C().version!==t?Zt("npm install @in-ch/setup@latest -g",{stdio:"inherit"}):console.log("@in-ch/setup package is already up to date.")};import{Command as so}from"commander";import Re from"fs";import io from"os";import M from"path";import{execSync as oo}from"child_process";async function J(t){try{let e=oo("code --list-extensions",{stdio:"pipe"}).toString();return e?e.split(`
`).map(n=>n.trim()).includes(t):(console.error("No extensions found or error executing the command."),!1)}catch(e){e instanceof Error?console.error(e.message):console.error("An unknown error occurred")}}import{execSync as no}from"child_process";async function z(t){try{await no(`code --install-extension ${t}`)}catch(e){e instanceof Error?console.error(e.message):console.error("An unknown error occurred")}}var Ue=(()=>{let t=io.platform();return t==="win32"?M.join(process.env.APPDATA||M.join(process.env.HOME,"AppData","Roaming"),"Code","User","settings.json"):t==="darwin"?M.join(process.env.HOME,"Library","Application Support","Code","User","settings.json"):M.join(process.env.HOME,".config","Code","User","settings.json")})(),ro={"[javascript]":{"editor.defaultFormatter":"esbenp.prettier-vscode","editor.formatOnSave":!0},"[typescript]":{"editor.defaultFormatter":"esbenp.prettier-vscode","editor.formatOnSave":!0},"[javascriptreact]":{"editor.defaultFormatter":"esbenp.prettier-vscode","editor.formatOnSave":!0},"[typescriptreact]":{"editor.defaultFormatter":"esbenp.prettier-vscode","editor.formatOnSave":!0}};function K(){Re.readFile(Ue,"utf8",async(t,e)=>{if(t&&t.code!=="ENOENT"){console.error("Error reading VSCode settings.json:",t);return}await J("esbenp.prettier-vscode")||await z("esbenp.prettier-vscode");let n={};if(e)try{n=JSON.parse(e)}catch(s){console.error("Error parsing settings.json:",s);return}let a={...n,...ro};Re.writeFile(Ue,JSON.stringify(a,null,2),"utf8",s=>{s?console.error("Error writing to settings.json:",s):console.log("VSCode settings.json updated successfully!")})})}var Ve=new so().command("autoPrefix").description("Update VSCode Auto Prefix Settings").action(async()=>{await r(),K()});import ao from"fs-extra";import co from"path";function _e(){let t=co.join("package.json");ao.existsSync(t)||x()}process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function mo(){await _e();let t=await C(),e=new lo().name("@in-ch/setup").description("Quick config: Download and apply settings in seconds.").version(`@in-ch/setup v${t.version||"1.0.0"}`,"-v, --version","display the version number");e.addCommand(De),e.addCommand(Fe),e.addCommand(pe),e.addCommand(ke),e.addCommand(je),e.addCommand(be),e.addCommand(ue),e.addCommand(ie),e.addCommand(Ae),e.addCommand(te),e.addCommand(Oe),e.addCommand(Ve),e.addCommand(Ne),e.addCommand(Ge),e.parse()}mo();
//# sourceMappingURL=index.js.map