@teispace/next-maker 1.8.0 → 1.10.0

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.
package/dist/index.js CHANGED
@@ -1,41 +1,41 @@
1
1
  #!/usr/bin/env node
2
- var ci=Object.defineProperty;var Ce=(e,i)=>()=>(e&&(i=e(e=0)),i);var Xe=(e,i)=>{for(var t in i)ci(e,t,{get:i[t],enumerable:!0})};import Z from"node:fs/promises";import We from"node:path";import{existsSync as Te}from"node:fs";var m,u,F,C,P,re,l,T=Ce(()=>{"use strict";m=async e=>Z.readFile(e,"utf-8"),u=async(e,i)=>{await Z.mkdir(We.dirname(e),{recursive:!0}),await Z.writeFile(e,i,"utf-8")},F=async(e,i)=>{await Z.mkdir(We.dirname(i),{recursive:!0}),await Z.copyFile(e,i)},C=async e=>{Te(e)&&await Z.unlink(e)},P=async e=>{Te(e)&&await Z.rm(e,{recursive:!0,force:!0})},re=async(e,i)=>{let t=await m(e),r=JSON.parse(t),s=i(r);await u(e,JSON.stringify(s,null,2))},l=e=>Te(e)});var Ze={};Xe(Ze,{PROJECT_PATHS:()=>a});var a,A=Ce(()=>{"use strict";a={NEXT_CONFIG:"next.config.ts",TAILWIND_CONFIG:"tailwind.config.ts",POSTCSS_CONFIG:"postcss.config.mjs",ESLINT_CONFIG:"eslint.config.mjs",TS_CONFIG:"tsconfig.json",PACKAGE_JSON:"package.json",ENV_EXAMPLE:".env.example",GITIGNORE:".gitignore",README:"README.md",LICENSE:"LICENSE",CHANGELOG:"CHANGELOG.md",NVM_RC:".nvmrc",NPM_RC:".npmrc",SRC:"src",APP:"src/app",COMPONENTS:"src/components",LIB:"src/lib",PROVIDERS:"src/providers",STYLES:"src/styles",TYPES:"src/types",UTILS:"src/lib/utils",HOOKS:"src/hooks",SERVICES:"src/services",STORE:"src/store",I18N:"src/i18n",GLOBALS_CSS:"src/styles/globals.css",ROOT_LAYOUT:"src/app/layout.tsx",ROOT_PAGE:"src/app/page.tsx",ROOT_PROVIDER:"src/providers/RootProvider.tsx",PROVIDERS_INDEX:"src/providers/index.ts",COMPONENTS_INDEX:"src/components/index.ts",TYPES_INDEX:"src/types/index.ts",UTILS_INDEX:"src/lib/utils/index.ts",CONFIG_INDEX:"src/lib/config/index.ts",CONSTANTS:"src/lib/config/constants.ts",APP_LOCALES:"src/lib/config/app-locales.ts",MIDDLEWARE:"src/middleware.ts",PROXY:"src/proxy.ts",I18N_TYPES:"src/types/i18n.ts",HTTP_UTILS:"src/lib/utils/http",AXIOS_CLIENT:"src/lib/utils/http/axios-client",FETCH_CLIENT:"src/lib/utils/http/fetch-client",AXIOS_CLIENT_FILE:"src/lib/utils/http/axios-client/index.ts",FETCH_CLIENT_FILE:"src/lib/utils/http/fetch-client/index.ts",CLIENT_UTILS:"src/lib/utils/http/client-utils.ts",APP_APIS:"src/lib/config/app-apis.ts",STORAGE_SERVICE:"src/services/storage",COUNTER_FEATURE:"src/features/counter",I18N_DIR:"src/i18n",LOCALE_DIR:"src/app/[locale]",ERRORS_DIR:"src/lib/errors",UTILITY_TYPES_DIR:"src/types/utility",COMMON_TYPES_DIR:"src/types/common",HTTP_TYPES:"src/types/common/http.types.ts",GITHUB_DIR:".github",HUSKY_DIR:".husky",STORE_PROVIDER:"src/providers/StoreProvider.tsx",THEME_PROVIDER:"src/providers/CustomThemeProvider.tsx",COUNTER_COMPONENT:"src/features/counter/components/Counter.tsx",LOCALE_PAGE:"src/app/[locale]/page.tsx",COMMITLINT_CONFIG:"commitlint.config.mjs",LINTSTAGED_RC:".lintstagedrc.mjs",CZRC:".czrc",DOCKERIGNORE:".dockerignore",DOCKERFILE:"Dockerfile",DOCKER_COMPOSE:"docker-compose.yml",GITHUB_WORKFLOWS:".github/workflows",GITHUB_ISSUE_TEMPLATE:"ISSUE_TEMPLATE",GITHUB_PR_TEMPLATE:"PULL_REQUEST_TEMPLATE.md",CODE_OF_CONDUCT:"CODE_OF_CONDUCT.md",CONTRIBUTING:"CONTRIBUTING.md",SECURITY:"SECURITY.md"}});var et={};Xe(et,{cleanupHttpTypes:()=>ie,isFileUsed:()=>Ni,isStringUsed:()=>Ai,migrateClientUsages:()=>$e,removeHttpExports:()=>_e,updateConfigIndex:()=>Oe,updateHttpIndex:()=>Re,updateTypesIndex:()=>Ae,updateUtilsIndex:()=>Ne});import O from"node:path";import{exec as Ii}from"node:child_process";import{promisify as Ri}from"node:util";var Ie,Re,Ne,Ae,Oe,ie,$e,_e,Ni,Ai,ge=Ce(()=>{"use strict";T();A();Ie=Ri(Ii),Re=async(e,i)=>{let t=O.join(e,a.HTTP_UTILS,"index.ts");if(l(t)){let r=await m(t);r=r.replace(/export .* from '\.\/axios-client';?\n?/g,""),r=r.replace(/export .* from '\.\/fetch-client';?\n?/g,""),i.includes("fetch")&&!r.includes("fetch-client")&&(r+=`export * from './fetch-client';
3
- `),i.includes("axios")&&!r.includes("axios-client")&&(r+=`export * from './axios-client';
4
- `),await u(t,r)}},Ne=async e=>{let i=O.join(e,a.UTILS_INDEX);if(l(i)){let t=await m(i);t.includes("./http")||(t+=`export * from './http';
5
- `,await u(i,t))}},Ae=async e=>{let i=O.join(e,a.TYPES_INDEX);if(l(i)){let t=await m(i);t.includes("./common")||(t+=`export * from './common';
6
- `),t.includes("./utility")||(t+=`export * from './utility';
7
- `),await u(i,t)}},Oe=async e=>{let i=O.join(e,a.CONFIG_INDEX);if(l(i)){let t=await m(i);t.includes("./app-apis")||(t+=`export * from './app-apis';
8
- `,await u(i,t))}},ie=async(e,i)=>{let t=O.join(e,a.HTTP_TYPES);if(l(t)){let r=await m(t);i.includes("axios")||(r=r.replace(/declare module 'axios'\s*\{\s*export interface AxiosRequestConfig\s*\{[\s\S]*?\}\s*\}/g,""),r=r.replace(/\n\s*\n/g,`
2
+ var ai=Object.defineProperty;var Ce=(e,t)=>()=>(e&&(t=e(e=0)),t);var Xe=(e,t)=>{for(var i in t)ai(e,i,{get:t[i],enumerable:!0})};import q from"node:fs/promises";import We from"node:path";import{existsSync as Te}from"node:fs";var d,u,b,C,S,ne,l,T=Ce(()=>{"use strict";d=async e=>q.readFile(e,"utf-8"),u=async(e,t)=>{await q.mkdir(We.dirname(e),{recursive:!0}),await q.writeFile(e,t,"utf-8")},b=async(e,t)=>{await q.mkdir(We.dirname(t),{recursive:!0}),await q.copyFile(e,t)},C=async e=>{Te(e)&&await q.unlink(e)},S=async e=>{Te(e)&&await q.rm(e,{recursive:!0,force:!0})},ne=async(e,t)=>{let i=await d(e),r=JSON.parse(i),s=t(r);await u(e,JSON.stringify(s,null,2))},l=e=>Te(e)});var Ze={};Xe(Ze,{PROJECT_PATHS:()=>a});var a,N=Ce(()=>{"use strict";a={NEXT_CONFIG:"next.config.ts",TAILWIND_CONFIG:"tailwind.config.ts",POSTCSS_CONFIG:"postcss.config.mjs",ESLINT_CONFIG:"eslint.config.mjs",TS_CONFIG:"tsconfig.json",PACKAGE_JSON:"package.json",ENV_EXAMPLE:".env.example",GITIGNORE:".gitignore",README:"README.md",LICENSE:"LICENSE",CHANGELOG:"CHANGELOG.md",NVM_RC:".nvmrc",NPM_RC:".npmrc",SRC:"src",APP:"src/app",COMPONENTS:"src/components",LIB:"src/lib",PROVIDERS:"src/providers",STYLES:"src/styles",TYPES:"src/types",UTILS:"src/lib/utils",HOOKS:"src/hooks",SERVICES:"src/services",STORE:"src/store",I18N:"src/i18n",GLOBALS_CSS:"src/styles/globals.css",ROOT_LAYOUT:"src/app/layout.tsx",ROOT_PAGE:"src/app/page.tsx",ROOT_PROVIDER:"src/providers/RootProvider.tsx",PROVIDERS_INDEX:"src/providers/index.ts",COMPONENTS_INDEX:"src/components/index.ts",TYPES_INDEX:"src/types/index.ts",UTILS_INDEX:"src/lib/utils/index.ts",CONFIG_INDEX:"src/lib/config/index.ts",CONSTANTS:"src/lib/config/constants.ts",APP_LOCALES:"src/lib/config/app-locales.ts",MIDDLEWARE:"src/middleware.ts",PROXY:"src/proxy.ts",I18N_TYPES:"src/types/i18n.ts",HTTP_UTILS:"src/lib/utils/http",AXIOS_CLIENT:"src/lib/utils/http/axios-client",FETCH_CLIENT:"src/lib/utils/http/fetch-client",AXIOS_CLIENT_FILE:"src/lib/utils/http/axios-client/index.ts",FETCH_CLIENT_FILE:"src/lib/utils/http/fetch-client/index.ts",CLIENT_UTILS:"src/lib/utils/http/client-utils.ts",APP_APIS:"src/lib/config/app-apis.ts",STORAGE_SERVICE:"src/services/storage",COUNTER_FEATURE:"src/features/counter",I18N_DIR:"src/i18n",LOCALE_DIR:"src/app/[locale]",ERRORS_DIR:"src/lib/errors",UTILITY_TYPES_DIR:"src/types/utility",COMMON_TYPES_DIR:"src/types/common",HTTP_TYPES:"src/types/common/http.types.ts",GITHUB_DIR:".github",HUSKY_DIR:".husky",STORE_PROVIDER:"src/providers/StoreProvider.tsx",THEME_PROVIDER:"src/providers/CustomThemeProvider.tsx",COUNTER_COMPONENT:"src/features/counter/components/Counter.tsx",LOCALE_PAGE:"src/app/[locale]/page.tsx",COMMITLINT_CONFIG:"commitlint.config.mjs",LINTSTAGED_RC:".lintstagedrc.mjs",CZRC:".czrc",DOCKERIGNORE:".dockerignore",DOCKERFILE:"Dockerfile",DOCKER_COMPOSE:"docker-compose.yml",GITHUB_WORKFLOWS:".github/workflows",GITHUB_ISSUE_TEMPLATE:"ISSUE_TEMPLATE",GITHUB_PR_TEMPLATE:"PULL_REQUEST_TEMPLATE.md",CODE_OF_CONDUCT:"CODE_OF_CONDUCT.md",CONTRIBUTING:"CONTRIBUTING.md",SECURITY:"SECURITY.md"}});var et={};Xe(et,{cleanupHttpTypes:()=>oe,isFileUsed:()=>Ri,isStringUsed:()=>Ni,migrateClientUsages:()=>$e,removeHttpExports:()=>_e,updateConfigIndex:()=>Oe,updateHttpIndex:()=>Re,updateTypesIndex:()=>Ae,updateUtilsIndex:()=>Ne});import A from"node:path";import{exec as Ei}from"node:child_process";import{promisify as Ii}from"node:util";var Ie,Re,Ne,Ae,Oe,oe,$e,_e,Ri,Ni,fe=Ce(()=>{"use strict";T();N();Ie=Ii(Ei),Re=async(e,t)=>{let i=A.join(e,a.HTTP_UTILS,"index.ts");if(l(i)){let r=await d(i);r=r.replace(/export .* from '\.\/axios-client';?\n?/g,""),r=r.replace(/export .* from '\.\/fetch-client';?\n?/g,""),t.includes("fetch")&&!r.includes("fetch-client")&&(r+=`export * from './fetch-client';
3
+ `),t.includes("axios")&&!r.includes("axios-client")&&(r+=`export * from './axios-client';
4
+ `),await u(i,r)}},Ne=async e=>{let t=A.join(e,a.UTILS_INDEX);if(l(t)){let i=await d(t);i.includes("./http")||(i+=`export * from './http';
5
+ `,await u(t,i))}},Ae=async e=>{let t=A.join(e,a.TYPES_INDEX);if(l(t)){let i=await d(t);i.includes("./common")||(i+=`export * from './common';
6
+ `),i.includes("./utility")||(i+=`export * from './utility';
7
+ `),await u(t,i)}},Oe=async e=>{let t=A.join(e,a.CONFIG_INDEX);if(l(t)){let i=await d(t);i.includes("./app-apis")||(i+=`export * from './app-apis';
8
+ `,await u(t,i))}},oe=async(e,t)=>{let i=A.join(e,a.HTTP_TYPES);if(l(i)){let r=await d(i);t.includes("axios")||(r=r.replace(/declare module 'axios'\s*\{\s*export interface AxiosRequestConfig\s*\{[\s\S]*?\}\s*\}/g,""),r=r.replace(/\n\s*\n/g,`
9
9
 
10
10
  `).trim()+`
11
- `,await u(t,r))}},$e=async(e,i,t)=>{if(i===t)return;let r=i==="fetch"?"fetchClient":"axiosClient",s=t==="fetch"?"fetchClient":"axiosClient",o=i==="fetch"?"fetch-client":"axios-client",n=t==="fetch"?"fetch-client":"axios-client",c=O.join(e,"src");try{let p=`grep -rl "${r}" "${c}" --include="*.ts" --include="*.tsx" || true`,{stdout:d}=await Ie(p);if(!d.trim())return;let h=d.trim().split(`
12
- `).filter(y=>y);for(let y of h){if(!l(y))continue;let g=await m(y),v=!1,R=new RegExp(`(import\\s*\\{[^}]*?)\\b${r}\\b([^}]*?\\}\\s*from\\s*['"][^'"]*?/http['"])`,"g");R.test(g)&&(g=g.replace(R,`$1${s}$2`),v=!0);let E=new RegExp(`import\\s+${r}\\s+from\\s+['"]([^'"]*?)/${o}['"]`,"g");E.test(g)&&(g=g.replace(E,`import ${s} from '$1/${n}'`),v=!0);let D=new RegExp(`\\b${r}\\b(?=\\.)`,"g");D.test(g)&&(g=g.replace(D,s),v=!0);let U=new RegExp(`\\b${r}\\b(?![.\\w])`,"g");U.test(g)&&(g=g.replace(U,s),v=!0),v&&await u(y,g)}}catch(p){console.warn("Warning: Could not scan for HTTP client usages:",p)}},_e=async e=>{let i=O.join(e,a.UTILS_INDEX);if(l(i)){let r=await m(i);r=r.replace(/export \* from '\.\/http';\n?/g,""),await u(i,r)}let t=O.join(e,a.TYPES_INDEX);if(l(t)){let r=await m(t),s=O.join(e,a.COMMON_TYPES_DIR);if(!l(s))r=r.replace(/export \* from '\.\/common';\n?/g,"");else{let o=O.join(s,"index.ts");if(l(o)){let n=await m(o);n=n.replace(/export \* from '\.\/http\.types';\n?/g,""),await u(o,n)}}l(O.join(e,a.UTILITY_TYPES_DIR))||(r=r.replace(/export \* from '\.\/utility';\n?/g,"")),await u(t,r)}},Ni=async(e,i,t=[])=>{let r=O.join(e,"src"),o=`grep -r "from ['\\"].*${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*['\\"]" "${r}" --include="*.ts" --include="*.tsx" || true`;try{let{stdout:n}=await Ie(o);return n.trim()?n.trim().split(`
13
- `).filter(d=>{let[h]=d.split(":"),y=O.resolve(e,h);return!t.some(g=>!!(y===g||y.startsWith(g+O.sep)))}).length>0:!1}catch(n){return console.warn(`Warning: Failed to check usage for ${i}:`,n),!0}},Ai=async(e,i,t=[])=>{let r=O.join(e,"src"),o=`grep -r "${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}" "${r}" --include="*.ts" --include="*.tsx" || true`;try{let{stdout:n}=await Ie(o);return n.trim()?n.trim().split(`
14
- `).filter(d=>{let[h]=d.split(":"),y=O.resolve(e,h);return!t.some(g=>!!(y===g||y.startsWith(g+O.sep)))}).length>0:!1}catch(n){return console.warn(`Warning: Failed to check usage for string ${i}:`,n),!0}}});import{Command as Mo}from"commander";import Fe from"node:path";import K from"picocolors";import li from"ora";function _(e="",i){let t=li({text:e,...i});return t.start(),t}import pi from"enquirer";var{prompt:mi}=pi,Je=async e=>{let i=await mi([{type:"input",name:"projectName",message:"What is the project name?",initial:e||"my-app",skip:!!e,validate:t=>/^[a-z0-9-_]+$/.test(t)?!0:"Project name must be lowercase and contain only alphanumeric characters, hyphens, and underscores."},{type:"input",name:"description",message:"Project description:",initial:"A Next.js application"},{type:"input",name:"author",message:"Author:",initial:"Teispace"},{type:"input",name:"version",message:"Version:",initial:"0.1.0",validate:t=>/^\d+\.\d+\.\d+$/.test(t)?!0:"Version must be a valid semantic version (x.y.z)."},{type:"input",name:"email",message:"Support email:",initial:"support@example.com",validate:t=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?!0:"Please enter a valid email address."},{type:"select",name:"packageManager",message:"Which package manager would you like to use?",choices:["npm","yarn","pnpm","bun"],initial:1},{type:"input",name:"gitRemote",message:"GitHub repository URL (optional):",validate:t=>{if(!t)return!0;let r=/^https:\/\/github\.com\/[\w-]+\/[\w.-]+$/,s=/^git@github\.com:[\w-]+\/[\w.-]+\.git$/;return!r.test(t)&&!s.test(t)?"Please enter a valid GitHub repository URL (e.g., https://github.com/user/repo)":!0}},{type:"confirm",name:"keepTemplates",message:"Do you want to keep GitHub issue and pull request templates?",initial:!1},{type:"select",name:"httpClient",message:"Which HTTP client do you want to use?",choices:["axios","fetch","both","none"],initial:1},{type:"confirm",name:"reactSecureStorage",message:"Do you want to include react-secure-storage?",initial:!0,skip:function(){let t=this.state?.answers??this.enquirer?.answers??{};return!!(t.httpClient&&t.httpClient!=="none")}},{type:"confirm",name:"darkMode",message:"Do you want to include Dark Mode (Tailwind + next-themes)?",initial:!0},{type:"confirm",name:"redux",message:"Do you want to include Redux Toolkit?",initial:!0},{type:"confirm",name:"i18n",message:"Do you want to include Internationalization (next-intl)?",initial:!0},{type:"multiselect",name:"communityFiles",message:"Select community files to include:",choices:[{name:"CODE_OF_CONDUCT.md",value:"CODE_OF_CONDUCT.md"},{name:"CONTRIBUTING.md",value:"CONTRIBUTING.md"},{name:"SECURITY.md",value:"SECURITY.md"}],initial:[]},{type:"confirm",name:"readme",message:"Do you want to create a README.md?",initial:!0},{type:"confirm",name:"docker",message:"Do you want to include Docker configuration?",initial:!1},{type:"input",name:"containerName",message:"Docker Container Name:",initial:"next-app",skip:function(){return!(this.state?.answers??this.enquirer?.answers??{}).docker},validate:t=>/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(t)?!0:"Invalid Docker container name."},{type:"input",name:"imageName",message:"Docker Image Name:",initial:"nextjs-starter",skip:function(){return!(this.state?.answers??this.enquirer?.answers??{}).docker},validate:t=>/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(t)?!0:"Invalid Docker image name (must be lowercase)."},{type:"input",name:"imageTag",message:"Docker Image Tag:",initial:"latest",skip:function(){return!(this.state?.answers??this.enquirer?.answers??{}).docker},validate:t=>/^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$/.test(t)?!0:"Invalid Docker image tag."},{type:"confirm",name:"ci",message:"Do you want to include GitHub Actions (CI/CD)?",initial:!1},{type:"confirm",name:"preCommitHooks",message:"Do you want to setup pre-commit hooks (Husky, Commitlint, Lint-staged)?",initial:!0},{type:"confirm",name:"commitizen",message:"Do you want to setup Commitizen?",initial:!0},{type:"confirm",name:"copyEnv",message:"Want to copy .env.example to .env?",initial:!0}]);if(i.company=i.author,i.gitRemote&&!i.gitHomepage){let t=i.gitRemote.replace("git@github.com:","https://github.com/").replace(/\.git$/,"");i.gitHomepage=`${t}#readme`,i.gitIssues=`${t}/issues`}return i};T();import{exec as di}from"node:child_process";import{promisify as ui}from"node:util";var de=ui(di),ze=async(e,i)=>{try{await de("git init",{cwd:e}),await de("git add .",{cwd:e}),await de('git commit -m "Initial commit from @teispace/next-maker"',{cwd:e}),i&&await de(`git remote add origin ${i}`,{cwd:e})}catch(t){console.warn("Failed to initialize git repository",t)}};import{exec as fi}from"node:child_process";import{promisify as gi}from"node:util";var ue=gi(fi),Ve=async(e,i)=>{let t=`${i} install`;try{await ue(t,{cwd:e})}catch(r){throw new Error(`Failed to install dependencies with ${i}: ${r}`)}},G=async(e,i,t)=>{let r=i==="npm"?`${i} run ${t}`:`${i} ${t}`;try{await ue(r,{cwd:e})}catch(s){console.warn(`Warning: Failed to run script '${t}': ${s}`)}},xi=()=>{let e=process.env.npm_config_user_agent;if(e){if(e.startsWith("yarn"))return"yarn";if(e.startsWith("pnpm"))return"pnpm";if(e.startsWith("bun"))return"bun"}return"npm"},Y=async e=>{let{existsSync:i}=await import("node:fs"),t=await import("node:path");return i(t.join(e,"pnpm-lock.yaml"))?"pnpm":i(t.join(e,"yarn.lock"))?"yarn":i(t.join(e,"bun.lockb"))?"bun":i(t.join(e,"package-lock.json"))?"npm":xi()},hi=async(e,i,t)=>{if(t.length===0)return;let s=`${yi(i)} ${t.join(" ")}`;try{await ue(s,{cwd:e})}catch(o){throw new Error(`Failed to install packages with ${i}: ${o}`)}},yi=e=>{switch(e){case"npm":return"npm install";case"yarn":return"yarn add";case"pnpm":return"pnpm add";case"bun":return"bun add";default:return"npm install"}},M=async(e,i)=>{let t=await Y(e);await hi(e,t,[i])},Si=async(e,i,t)=>{if(t.length===0)return;let s=`${Pi(i)} ${t.join(" ")}`;try{await ue(s,{cwd:e})}catch(o){throw new Error(`Failed to uninstall packages with ${i}: ${o}`)}},Pi=e=>{switch(e){case"npm":return"npm uninstall";case"yarn":return"yarn remove";case"pnpm":return"pnpm remove";case"bun":return"bun remove";default:return"npm uninstall"}},Ee=async(e,i)=>{let t=await Y(e);await Si(e,t,[i])};import X from"picocolors";var vi={reset:e=>e,red:X.red,green:X.green,yellow:X.yellow,blue:X.blue,cyan:X.cyan,magenta:X.magenta,white:X.white,gray:X.gray,bright:X.bold,dim:X.dim};function Q(e,i="reset"){let t=vi[i]??(r=>r);console.log(t(e))}function fe(e){Q(`\u2716 ${e}`,"red")}var N=fe;function f(e){Q(e)}function Ke(){console.log(""),Q("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","cyan"),Q("\u2551 \u2551","cyan"),Q("\u2551 \u{1F680} Create Teispace Next.js App \u{1F680} \u2551","cyan"),Q("\u2551 \u2551","cyan"),Q("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D","cyan"),console.log("")}function Be(e){let{logger:i=n=>console.error(n),exitOnCancel:t=process.env.NODE_ENV!=="test"}=e??{},r=()=>{console.log(""),console.log(""),i("Setup cancelled by user"),console.log(""),t&&process.exit(0)},s=n=>{if(n!==null&&typeof n=="object"&&"code"in n&&n.code==="ERR_USE_AFTER_CLOSE"){r();return}if(n instanceof Error){i(`Uncaught exception: ${n.message}`);return}i(`Uncaught exception: ${String(n)}`)},o=n=>{if(n instanceof Error){i(`Unhandled promise rejection: ${n.message}`);return}i(`Unhandled promise rejection: ${String(n)}`)};return process.on("SIGINT",r),process.on("SIGTERM",r),process.on("uncaughtException",s),process.on("unhandledRejection",o),()=>{process.off("SIGINT",r),process.off("SIGTERM",r),process.off("uncaughtException",s),process.off("unhandledRejection",o)}}var wi=e=>e.charAt(0).toUpperCase()+e.slice(1),L=e=>e.replace(/-([a-z])/g,(i,t)=>t.toUpperCase()),V=e=>wi(L(e));import Ci from"ora";var w=Ci();import Ti from"degit";var qe=async e=>{let i=_("Downloading template...");try{await Ti("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!0}).clone(e),i.succeed("Template downloaded successfully.")}catch(t){throw i.fail("Failed to download template."),t}};T();import Ei from"node:path";A();var b={REDUX_TOOLKIT:"@reduxjs/toolkit",REACT_REDUX:"react-redux",REDUX_PERSIST:"redux-persist",REACT_SECURE_STORAGE:"react-secure-storage",NEXT_INTL:"next-intl",NEXT_THEMES:"next-themes",AXIOS:"axios",HUSKY:"husky",COMMITLINT_CLI:"@commitlint/cli",COMMITLINT_CONFIG:"@commitlint/config-conventional",LINT_STAGED:"lint-staged",COMMITIZEN:"commitizen",CZ_CONVENTIONAL_CHANGELOG:"cz-conventional-changelog"};var Qe=async(e,i)=>{let t=_("Configuring package.json...");try{let r=i.gitRemote,s=i.gitHomepage,o=i.gitIssues;i.gitRemote&&(i.gitRemote.startsWith("git@github.com:")&&(r=i.gitRemote.replace("git@github.com:","https://github.com/").replace(/\.git$/,"")),s||(s=`${r.replace(/\.git$/,"")}#readme`),o||(o=`${r.replace(/\.git$/,"")}/issues`),r.endsWith(".git")||(r=`${r}.git`)),await re(Ei.join(e,a.PACKAGE_JSON),n=>(n.name=i.projectName,n.version=i.version,n.description=i.description,n.author=i.author,delete n.packageManager,i.gitRemote?(s&&(n.homepage=s),o&&(n.bugs={url:o}),r&&(n.repository={type:"git",url:r})):(delete n.homepage,delete n.bugs,delete n.repository),i.redux||(delete n.dependencies[b.REDUX_TOOLKIT],delete n.dependencies[b.REACT_REDUX],delete n.dependencies[b.REDUX_PERSIST]),i.httpClient!=="none"||i.reactSecureStorage||delete n.dependencies[b.REACT_SECURE_STORAGE],i.i18n||delete n.dependencies[b.NEXT_INTL],i.darkMode||delete n.dependencies[b.NEXT_THEMES],i.httpClient==="none"?delete n.dependencies[b.AXIOS]:i.httpClient==="fetch"&&delete n.dependencies[b.AXIOS],n)),t.succeed("package.json configured.")}catch(r){throw t.fail("Failed to configure package.json."),r}};T();import x from"node:path";A();ge();var tt=async(e,i)=>{let t=_("Customizing features...");try{await Oi(e,i),await $i(e,i),await _i(e,i),await bi(e,i),await Fi(e,i),await ji(e),await ki(e),await Di(e),t.succeed("Features customized.")}catch(r){throw t.fail("Failed to customize features."),r}},Oi=async(e,i)=>{let t=x.join(e,a.HTTP_UTILS),r=i.httpClient!=="none"||i.reactSecureStorage;if(i.httpClient==="none"){if(await P(x.join(e,a.AXIOS_CLIENT)),await P(x.join(e,a.FETCH_CLIENT)),r)await u(x.join(t,"index.ts"),`export * from './token-store';
15
- `),await C(x.join(e,a.CLIENT_UTILS)),await ie(e,[]);else{await P(t);let o=x.join(e,a.UTILS_INDEX);if(l(o)){let c=await m(o);c=c.replace(/export \* from '\.\/http';\n/,""),await u(o,c)}await C(x.join(e,a.APP_APIS));let n=x.join(e,a.CONFIG_INDEX);if(l(n)){let c=await m(n);c=c.replace(/export \* from '\.\/app-apis';\n/,""),await u(n,c)}}let s=x.join(e,a.CONSTANTS);if(l(s)){let o=await m(s);o=o.replace(/export const API_RESPONSE_DATA_KEY = 'data';\n/,""),o=o.replace(/export const SAVE_AUTH_TOKENS = false;\n/,""),await u(s,o)}if(await P(x.join(e,a.ERRORS_DIR)),!r){await P(x.join(e,a.COMMON_TYPES_DIR)),await P(x.join(e,a.UTILITY_TYPES_DIR));let o=x.join(e,a.TYPES_INDEX);if(l(o)){let n=await m(o);n=n.replace(/export \* from '\.\/utility';\n/,""),n=n.replace(/export \* from '\.\/common';\n/,""),await u(o,n)}}}else if(i.httpClient==="axios"){await P(x.join(e,a.FETCH_CLIENT));let s=await m(x.join(t,"index.ts"));s=s.replace(/export .* from '\.\/fetch-client';\n/g,""),await u(x.join(t,"index.ts"),s);let o=x.join(e,a.HTTP_TYPES);if(l(o)){let n=await m(o);n=n.replace(/export interface FetchClientOptions \{[\s\S]*?\}\n\n/,""),n=n.replace(/export interface ExtendedRequestInit extends RequestInit \{[\s\S]*?\}\n\n/,""),await u(o,n)}}else if(i.httpClient==="fetch"){await P(x.join(e,a.AXIOS_CLIENT));let s=await m(x.join(t,"index.ts"));s=s.replace(/export .* from '\.\/axios-client';\n/g,""),await u(x.join(t,"index.ts"),s),await ie(e,["fetch"]);let o=x.join(e,a.HTTP_TYPES);if(l(o)){let n=await m(o);n=n.replace(/export interface AxiosClientOptions \{[\s\S]*?\}\n\n/,""),await u(o,n)}}},$i=async(e,i)=>{i.httpClient!=="none"||i.reactSecureStorage||await P(x.join(e,a.STORAGE_SERVICE))},_i=async(e,i)=>{if(!i.redux){await P(x.join(e,a.STORE)),await P(x.join(e,a.COUNTER_FEATURE)),await C(x.join(e,a.STORE_PROVIDER));let t=x.join(e,a.PROVIDERS_INDEX),r=await m(t);r=r.replace(/export \* from '\.\/StoreProvider';\n/,""),await u(t,r);let s=[x.join(e,a.ROOT_PAGE),x.join(e,a.LOCALE_PAGE)];for(let o of s)if(l(o)){let n=await m(o);n=n.replace(/import\s+\{\s*Counter\s*\}\s+from\s+['"]@\/features\/counter['"];\n?/,""),n=n.replace(/<Counter\s*\/>\n?/g,""),await u(o,n)}}},bi=async(e,i)=>{if(!i.darkMode){await C(x.join(e,a.THEME_PROVIDER));let t=x.join(e,a.PROVIDERS_INDEX),r=await m(t);r=r.replace(/export \* from '\.\/CustomThemeProvider';\n/,""),await u(t,r);let s=x.join(e,a.GLOBALS_CSS);if(l(s)){let o=await m(s);o=o.replace(/@custom-variant dark \(.*?\);\n\n/,""),o=o.replace(/@theme \{[\s\S]*?\}\n/,""),await u(s,o)}if(!i.i18n){let o=x.join(e,a.ROOT_LAYOUT);if(l(o)){let n=await m(o);n=n.replace(/bg-light dark:bg-dark /g,""),await u(o,n)}}}},Fi=async(e,i)=>{if(!i.i18n){await P(x.join(e,a.I18N_DIR)),await P(x.join(e,a.LOCALE_DIR)),await C(x.join(e,a.PROXY)),await C(x.join(e,a.MIDDLEWARE)),await C(x.join(e,a.I18N_TYPES)),await C(x.join(e,a.APP_LOCALES));let t=x.join(e,a.TYPES_INDEX);if(l(t)){let n=await m(t);n=n.replace(/export \* from '\.\/i18n';\n/,""),await u(t,n)}let r=x.join(e,a.CONFIG_INDEX);if(l(r)){let n=await m(r);n=n.replace(/export \* from '\.\/app-locales';\n/,""),await u(r,n)}let s=x.join(e,a.NEXT_CONFIG);if(l(s)){let n=await m(s);n=n.replace(/import createNextIntlPlugin from 'next-intl\/plugin';\n/,""),n=n.replace(/const withNextIntl = createNextIntlPlugin\(\);\n/,""),n=n.replace(/export default withNextIntl\(nextConfig\);/,"export default nextConfig;"),await u(s,n)}let o=x.join(e,a.COUNTER_COMPONENT);if(l(o)){let n=await m(o);n=n.replace(/import\s+\{\s*useTranslations\s*\}\s+from\s+['"]next-intl['"];\n/,""),n=n.replace(/\s*const\s+t\s*=\s*useTranslations\(['"]Count['"]\);\n/,""),n=n.replace(/\{t\('currentCount',\s*\{\s*count:\s*value\s*\}\)\}/g,"{value}"),n=n.replace(/\{t\(['"]increment['"]\)\}/g,"Increment"),n=n.replace(/\{t\(['"]decrement['"]\)\}/g,"Decrement"),n=n.replace(/\{t\(['"]reset['"]\)\}/g,"Reset"),await u(o,n)}}},ji=async e=>{await C(x.join(e,a.LICENSE))},ki=async e=>{await C(x.join(e,a.CHANGELOG))},Di=async e=>{await C(x.join(e,a.NVM_RC)),await C(x.join(e,a.NPM_RC))};T();A();import be from"node:path";var it=async(e,i)=>{let t=[],r=[];i.redux&&(t.push("import { StoreProvider } from '@/providers';"),r.push("StoreProvider")),i.darkMode&&(t.push("import { CustomThemeProvider } from '@/providers';"),r.push("CustomThemeProvider")),i.i18n&&(t.push("import { NextIntlClientProvider, AbstractIntlMessages } from 'next-intl';"),t.push("import { SupportedLocale } from '@/types/i18n';"));let s=`'use client';
16
- ${t.join(`
11
+ `,await u(i,r))}},$e=async(e,t,i)=>{if(t===i)return;let r=t==="fetch"?"fetchClient":"axiosClient",s=i==="fetch"?"fetchClient":"axiosClient",o=t==="fetch"?"fetch-client":"axios-client",n=i==="fetch"?"fetch-client":"axios-client",c=A.join(e,"src");try{let p=`grep -rl "${r}" "${c}" --include="*.ts" --include="*.tsx" || true`,{stdout:m}=await Ie(p);if(!m.trim())return;let h=m.trim().split(`
12
+ `).filter(y=>y);for(let y of h){if(!l(y))continue;let x=await d(y),w=!1,D=new RegExp(`(import\\s*\\{[^}]*?)\\b${r}\\b([^}]*?\\}\\s*from\\s*['"][^'"]*?/http['"])`,"g");D.test(x)&&(x=x.replace(D,`$1${s}$2`),w=!0);let I=new RegExp(`import\\s+${r}\\s+from\\s+['"]([^'"]*?)/${o}['"]`,"g");I.test(x)&&(x=x.replace(I,`import ${s} from '$1/${n}'`),w=!0);let F=new RegExp(`\\b${r}\\b(?=\\.)`,"g");F.test(x)&&(x=x.replace(F,s),w=!0);let ie=new RegExp(`\\b${r}\\b(?![.\\w])`,"g");ie.test(x)&&(x=x.replace(ie,s),w=!0),w&&await u(y,x)}}catch(p){console.warn("Warning: Could not scan for HTTP client usages:",p)}},_e=async e=>{let t=A.join(e,a.UTILS_INDEX);if(l(t)){let r=await d(t);r=r.replace(/^\s*export\s+\*\s+from\s+['"]\.\/http['"];?.*$/gm,""),await u(t,r)}let i=A.join(e,a.TYPES_INDEX);if(l(i)){let r=await d(i),s=A.join(e,a.COMMON_TYPES_DIR);if(!l(s))r=r.replace(/^\s*export\s+\*\s+from\s+['"]\.\/common['"];?.*$/gm,"");else{let o=A.join(s,"index.ts");if(l(o)){let n=await d(o);n=n.replace(/^\s*export\s+\*\s+from\s+['"]\.\/http\.types['"];?.*$/gm,""),await u(o,n)}}l(A.join(e,a.UTILITY_TYPES_DIR))||(r=r.replace(/^\s*export\s+\*\s+from\s+['"]\.\/utility['"];?.*$/gm,"")),await u(i,r)}},Ri=async(e,t,i=[])=>{let r=A.join(e,"src"),o=`grep -r "from ['\\"].*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*['\\"]" "${r}" --include="*.ts" --include="*.tsx" || true`;try{let{stdout:n}=await Ie(o);return n.trim()?n.trim().split(`
13
+ `).filter(m=>{let[h]=m.split(":"),y=A.resolve(e,h);return!i.some(x=>!!(y===x||y.startsWith(x+A.sep)))}).length>0:!1}catch(n){return console.warn(`Warning: Failed to check usage for ${t}:`,n),!0}},Ni=async(e,t,i=[])=>{let r=A.join(e,"src"),o=`grep -r "${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}" "${r}" --include="*.ts" --include="*.tsx" || true`;try{let{stdout:n}=await Ie(o);return n.trim()?n.trim().split(`
14
+ `).filter(m=>{let[h]=m.split(":"),y=A.resolve(e,h);return!i.some(x=>!!(y===x||y.startsWith(x+A.sep)))}).length>0:!1}catch(n){return console.warn(`Warning: Failed to check usage for string ${t}:`,n),!0}}});import{Command as Mo}from"commander";import Fe from"node:path";import V from"picocolors";import ci from"ora";function $(e="",t){let i=ci({text:e,...t});return i.start(),i}import li from"enquirer";var{prompt:pi}=li,Je=async e=>{let t=await pi([{type:"input",name:"projectName",message:"What is the project name?",initial:e||"my-app",skip:!!e,validate:i=>/^[a-z0-9-_]+$/.test(i)?!0:"Project name must be lowercase and contain only alphanumeric characters, hyphens, and underscores."},{type:"input",name:"description",message:"Project description:",initial:"A Next.js application"},{type:"input",name:"author",message:"Author:",initial:"Teispace"},{type:"input",name:"version",message:"Version:",initial:"0.1.0",validate:i=>/^\d+\.\d+\.\d+$/.test(i)?!0:"Version must be a valid semantic version (x.y.z)."},{type:"input",name:"email",message:"Support email:",initial:"support@example.com",validate:i=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i)?!0:"Please enter a valid email address."},{type:"select",name:"packageManager",message:"Which package manager would you like to use?",choices:["npm","yarn","pnpm","bun"],initial:1},{type:"input",name:"gitRemote",message:"GitHub repository URL (optional):",initial:""},{type:"confirm",name:"pushToRemote",message:"Would you like to push the changes to the remote repository?",initial:!0,skip:function(){return!this.state?.answers?.gitRemote}},{type:"input",name:"gitIssues",message:"GitHub issues URL (optional):",initial:"",skip:function(){return!this.state?.answers?.gitRemote},validate:i=>i?/^https:\/\/github\.com\/[\w-]+\/[\w.-]+\/issues$/.test(i)?!0:"Please enter a valid GitHub issues URL (e.g., https://github.com/user/repo/issues)":!0},{type:"input",name:"gitHomepage",message:"GitHub homepage URL (optional):",initial:"",skip:function(){return!this.state?.answers?.gitRemote},validate:i=>i?/^https:\/\/github\.com\/[\w-]+\/[\w.-]+#readme$/.test(i)?!0:"Please enter a valid GitHub homepage URL (e.g., https://github.com/user/repo#readme)":!0},{type:"confirm",name:"keepTemplates",message:"Do you want to keep GitHub issue and pull request templates?",initial:!1},{type:"select",name:"httpClient",message:"Which HTTP client do you want to use?",choices:["axios","fetch","both","none"],initial:1},{type:"confirm",name:"reactSecureStorage",message:"Do you want to include react-secure-storage?",initial:!0,skip:function(){let i=this.state?.answers??this.enquirer?.answers??{};return!!(i.httpClient&&i.httpClient!=="none")}},{type:"confirm",name:"darkMode",message:"Do you want to include Dark Mode (Tailwind + next-themes)?",initial:!0},{type:"confirm",name:"redux",message:"Do you want to include Redux Toolkit?",initial:!0},{type:"confirm",name:"i18n",message:"Do you want to include Internationalization (next-intl)?",initial:!0},{type:"multiselect",name:"communityFiles",message:"Select community files to include:",choices:[{name:"CODE_OF_CONDUCT.md",value:"CODE_OF_CONDUCT.md"},{name:"CONTRIBUTING.md",value:"CONTRIBUTING.md"},{name:"SECURITY.md",value:"SECURITY.md"}],initial:[]},{type:"confirm",name:"readme",message:"Do you want to create a README.md?",initial:!0},{type:"confirm",name:"docker",message:"Do you want to include Docker configuration?",initial:!1},{type:"input",name:"containerName",message:"Docker Container Name:",initial:"next-app",skip:function(){return!(this.state?.answers??this.enquirer?.answers??{}).docker},validate:i=>/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(i)?!0:"Invalid Docker container name."},{type:"input",name:"imageName",message:"Docker Image Name:",initial:"nextjs-starter",skip:function(){return!(this.state?.answers??this.enquirer?.answers??{}).docker},validate:i=>/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(i)?!0:"Invalid Docker image name (must be lowercase)."},{type:"input",name:"imageTag",message:"Docker Image Tag:",initial:"latest",skip:function(){return!(this.state?.answers??this.enquirer?.answers??{}).docker},validate:i=>/^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$/.test(i)?!0:"Invalid Docker image tag."},{type:"confirm",name:"ci",message:"Do you want to include GitHub Actions (CI/CD)?",initial:!1},{type:"confirm",name:"preCommitHooks",message:"Do you want to setup pre-commit hooks (Husky, Commitlint, Lint-staged)?",initial:!0},{type:"confirm",name:"commitizen",message:"Do you want to setup Commitizen?",initial:!0},{type:"confirm",name:"copyEnv",message:"Want to copy .env.example to .env?",initial:!0}]);if(t.company=t.author,t.gitRemote&&!t.gitHomepage){let i=t.gitRemote.replace("git@github.com:","https://github.com/").replace(/\.git$/,"");t.gitHomepage=`${i}#readme`,t.gitIssues=`${i}/issues`}return t};T();import{exec as mi}from"node:child_process";import{promisify as di}from"node:util";var Z=di(mi),ze=async(e,t,i)=>{try{await Z("git init",{cwd:e}),await Z("git add .",{cwd:e}),await Z('git commit -m "Initial commit from @teispace/next-maker"',{cwd:e}),t&&(await Z(`git remote add origin ${t}`,{cwd:e}),i&&(await Z("git fetch origin",{cwd:e}),await Z("git merge origin/main --allow-unrelated-histories",{cwd:e}),await Z("git push origin HEAD:main",{cwd:e})))}catch(r){console.warn("Failed to initialize git repository",r)}};import{exec as ui}from"node:child_process";import{promisify as fi}from"node:util";var de=fi(ui),Ve=async(e,t)=>{let i=`${t} install`;try{await de(i,{cwd:e})}catch(r){throw new Error(`Failed to install dependencies with ${t}: ${r}`)}},H=async(e,t,i)=>{let r=t==="npm"?`${t} run ${i}`:`${t} ${i}`;try{await de(r,{cwd:e})}catch(s){console.warn(`Warning: Failed to run script '${i}': ${s}`)}},gi=()=>{let e=process.env.npm_config_user_agent;if(e){if(e.startsWith("yarn"))return"yarn";if(e.startsWith("pnpm"))return"pnpm";if(e.startsWith("bun"))return"bun"}return"npm"},G=async e=>{let{existsSync:t}=await import("node:fs"),i=await import("node:path");return t(i.join(e,"pnpm-lock.yaml"))?"pnpm":t(i.join(e,"yarn.lock"))?"yarn":t(i.join(e,"bun.lockb"))?"bun":t(i.join(e,"package-lock.json"))?"npm":gi()},xi=async(e,t,i)=>{if(i.length===0)return;let s=`${hi(t)} ${i.join(" ")}`;try{await de(s,{cwd:e})}catch(o){throw new Error(`Failed to install packages with ${t}: ${o}`)}},hi=e=>{switch(e){case"npm":return"npm install";case"yarn":return"yarn add";case"pnpm":return"pnpm add";case"bun":return"bun add";default:return"npm install"}},M=async(e,t)=>{let i=await G(e);await xi(e,i,[t])},yi=async(e,t,i)=>{if(i.length===0)return;let s=`${Si(t)} ${i.join(" ")}`;try{await de(s,{cwd:e})}catch(o){throw new Error(`Failed to uninstall packages with ${t}: ${o}`)}},Si=e=>{switch(e){case"npm":return"npm uninstall";case"yarn":return"yarn remove";case"pnpm":return"pnpm remove";case"bun":return"bun remove";default:return"npm uninstall"}},Ee=async(e,t)=>{let i=await G(e);await yi(e,i,[t])};import U from"picocolors";var Pi={reset:e=>e,red:U.red,green:U.green,yellow:U.yellow,blue:U.blue,cyan:U.cyan,magenta:U.magenta,white:U.white,gray:U.gray,bright:U.bold,dim:U.dim};function Q(e,t="reset"){let i=Pi[t]??(r=>r);console.log(i(e))}function ue(e){Q(`\u2716 ${e}`,"red")}var R=ue;function f(e){Q(e)}function Ke(){console.log(""),Q("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","cyan"),Q("\u2551 \u2551","cyan"),Q("\u2551 \u{1F680} Create Teispace Next.js App \u{1F680} \u2551","cyan"),Q("\u2551 \u2551","cyan"),Q("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D","cyan"),console.log("")}function Be(e){let{logger:t=n=>console.error(n),exitOnCancel:i=process.env.NODE_ENV!=="test"}=e??{},r=()=>{console.log(""),console.log(""),t("Setup cancelled by user"),console.log(""),i&&process.exit(0)},s=n=>{if(n!==null&&typeof n=="object"&&"code"in n&&n.code==="ERR_USE_AFTER_CLOSE"){r();return}if(n instanceof Error){t(`Uncaught exception: ${n.message}`);return}t(`Uncaught exception: ${String(n)}`)},o=n=>{if(n instanceof Error){t(`Unhandled promise rejection: ${n.message}`);return}t(`Unhandled promise rejection: ${String(n)}`)};return process.on("SIGINT",r),process.on("SIGTERM",r),process.on("uncaughtException",s),process.on("unhandledRejection",o),()=>{process.off("SIGINT",r),process.off("SIGTERM",r),process.off("uncaughtException",s),process.off("unhandledRejection",o)}}var vi=e=>e.charAt(0).toUpperCase()+e.slice(1),L=e=>e.replace(/-([a-z])/g,(t,i)=>i.toUpperCase()),z=e=>vi(L(e));import wi from"ora";var v=wi();import Ci from"degit";var qe=async e=>{let t=$("Downloading template...");try{await Ci("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!0}).clone(e),t.succeed("Template downloaded successfully.")}catch(i){throw t.fail("Failed to download template."),i}};T();import Ti from"node:path";N();var _={REDUX_TOOLKIT:"@reduxjs/toolkit",REACT_REDUX:"react-redux",REDUX_PERSIST:"redux-persist",REACT_SECURE_STORAGE:"react-secure-storage",NEXT_INTL:"next-intl",NEXT_THEMES:"next-themes",AXIOS:"axios",HUSKY:"husky",COMMITLINT_CLI:"@commitlint/cli",COMMITLINT_CONFIG:"@commitlint/config-conventional",LINT_STAGED:"lint-staged",COMMITIZEN:"commitizen",CZ_CONVENTIONAL_CHANGELOG:"cz-conventional-changelog"};var Qe=async(e,t)=>{let i=$("Configuring package.json...");try{let r=t.gitRemote,s=t.gitHomepage,o=t.gitIssues;t.gitRemote&&(t.gitRemote.startsWith("git@github.com:")&&(r=t.gitRemote.replace("git@github.com:","https://github.com/").replace(/\.git$/,"")),s||(s=`${r.replace(/\.git$/,"")}#readme`),o||(o=`${r.replace(/\.git$/,"")}/issues`),r.endsWith(".git")||(r=`${r}.git`)),await ne(Ti.join(e,a.PACKAGE_JSON),n=>(n.name=t.projectName,n.version=t.version,n.description=t.description,n.author=t.author,delete n.packageManager,t.gitRemote?(s&&(n.homepage=s),o&&(n.bugs={url:o}),r&&(n.repository={type:"git",url:r})):(delete n.homepage,delete n.bugs,delete n.repository),t.redux||(delete n.dependencies[_.REDUX_TOOLKIT],delete n.dependencies[_.REACT_REDUX],delete n.dependencies[_.REDUX_PERSIST]),t.httpClient!=="none"||t.reactSecureStorage||delete n.dependencies[_.REACT_SECURE_STORAGE],t.i18n||delete n.dependencies[_.NEXT_INTL],t.darkMode||delete n.dependencies[_.NEXT_THEMES],t.httpClient==="none"?delete n.dependencies[_.AXIOS]:t.httpClient==="fetch"&&delete n.dependencies[_.AXIOS],n)),i.succeed("package.json configured.")}catch(r){throw i.fail("Failed to configure package.json."),r}};T();import g from"node:path";N();fe();var tt=async(e,t)=>{let i=$("Customizing features...");try{await Ai(e,t),await Oi(e,t),await $i(e,t),await _i(e,t),await bi(e,t),await Fi(e),await ji(e),await ki(e),i.succeed("Features customized.")}catch(r){throw i.fail("Failed to customize features."),r}},Ai=async(e,t)=>{let i=g.join(e,a.HTTP_UTILS),r=t.httpClient!=="none"||t.reactSecureStorage;if(t.httpClient==="none"){if(await S(g.join(e,a.AXIOS_CLIENT)),await S(g.join(e,a.FETCH_CLIENT)),r)await u(g.join(i,"index.ts"),`export * from './token-store';
15
+ `),await C(g.join(e,a.CLIENT_UTILS)),await oe(e,[]);else{await S(i);let o=g.join(e,a.UTILS_INDEX);if(l(o)){let c=await d(o);c=c.replace(/export \* from '\.\/http';\n/,""),await u(o,c)}await C(g.join(e,a.APP_APIS));let n=g.join(e,a.CONFIG_INDEX);if(l(n)){let c=await d(n);c=c.replace(/export \* from '\.\/app-apis';\n/,""),await u(n,c)}}let s=g.join(e,a.CONSTANTS);if(l(s)){let o=await d(s);o=o.replace(/export const API_RESPONSE_DATA_KEY = 'data';\n/,""),o=o.replace(/export const SAVE_AUTH_TOKENS = false;\n/,""),await u(s,o)}if(await S(g.join(e,a.ERRORS_DIR)),!r){await S(g.join(e,a.COMMON_TYPES_DIR)),await S(g.join(e,a.UTILITY_TYPES_DIR));let o=g.join(e,a.TYPES_INDEX);if(l(o)){let n=await d(o);n=n.replace(/export \* from '\.\/utility';\n/,""),n=n.replace(/export \* from '\.\/common';\n/,""),await u(o,n)}}}else if(t.httpClient==="axios"){await S(g.join(e,a.FETCH_CLIENT));let s=await d(g.join(i,"index.ts"));s=s.replace(/export .* from '\.\/fetch-client';\n/g,""),await u(g.join(i,"index.ts"),s);let o=g.join(e,a.HTTP_TYPES);if(l(o)){let n=await d(o);n=n.replace(/export interface FetchClientOptions \{[\s\S]*?\}\n\n/,""),n=n.replace(/export interface ExtendedRequestInit extends RequestInit \{[\s\S]*?\}\n\n/,""),await u(o,n)}}else if(t.httpClient==="fetch"){await S(g.join(e,a.AXIOS_CLIENT));let s=await d(g.join(i,"index.ts"));s=s.replace(/export .* from '\.\/axios-client';\n/g,""),await u(g.join(i,"index.ts"),s),await oe(e,["fetch"]);let o=g.join(e,a.HTTP_TYPES);if(l(o)){let n=await d(o);n=n.replace(/export interface AxiosClientOptions \{[\s\S]*?\}\n\n/,""),await u(o,n)}}},Oi=async(e,t)=>{t.httpClient!=="none"||t.reactSecureStorage||await S(g.join(e,a.STORAGE_SERVICE))},$i=async(e,t)=>{if(!t.redux){await S(g.join(e,a.STORE)),await S(g.join(e,a.COUNTER_FEATURE)),await C(g.join(e,a.STORE_PROVIDER));let i=g.join(e,a.PROVIDERS_INDEX),r=await d(i);r=r.replace(/export \* from '\.\/StoreProvider';\n/,""),await u(i,r);let s=[g.join(e,a.ROOT_PAGE),g.join(e,a.LOCALE_PAGE)];for(let o of s)if(l(o)){let n=await d(o);n=n.replace(/import\s+\{\s*Counter\s*\}\s+from\s+['"]@\/features\/counter['"];\n?/,""),n=n.replace(/<Counter\s*\/>\n?/g,""),await u(o,n)}}},_i=async(e,t)=>{if(!t.darkMode){await C(g.join(e,a.THEME_PROVIDER));let i=g.join(e,a.PROVIDERS_INDEX),r=await d(i);r=r.replace(/export \* from '\.\/CustomThemeProvider';\n/,""),await u(i,r);let s=g.join(e,a.GLOBALS_CSS);if(l(s)){let o=await d(s);o=o.replace(/@custom-variant dark \(.*?\);\n\n/,""),o=o.replace(/@theme \{[\s\S]*?\}\n/,""),await u(s,o)}if(!t.i18n){let o=g.join(e,a.ROOT_LAYOUT);if(l(o)){let n=await d(o);n=n.replace(/bg-light dark:bg-dark /g,""),await u(o,n)}}}},bi=async(e,t)=>{if(!t.i18n){await S(g.join(e,a.I18N_DIR)),await S(g.join(e,a.LOCALE_DIR)),await C(g.join(e,a.PROXY)),await C(g.join(e,a.MIDDLEWARE)),await C(g.join(e,a.I18N_TYPES)),await C(g.join(e,a.APP_LOCALES));let i=g.join(e,a.TYPES_INDEX);if(l(i)){let n=await d(i);n=n.replace(/export \* from '\.\/i18n';\n/,""),await u(i,n)}let r=g.join(e,a.CONFIG_INDEX);if(l(r)){let n=await d(r);n=n.replace(/export \* from '\.\/app-locales';\n/,""),await u(r,n)}let s=g.join(e,a.NEXT_CONFIG);if(l(s)){let n=await d(s);n=n.replace(/import createNextIntlPlugin from 'next-intl\/plugin';\n/,""),n=n.replace(/const withNextIntl = createNextIntlPlugin\(\);\n/,""),n=n.replace(/export default withNextIntl\(nextConfig\);/,"export default nextConfig;"),await u(s,n)}let o=g.join(e,a.COUNTER_COMPONENT);if(l(o)){let n=await d(o);n=n.replace(/import\s+\{\s*useTranslations\s*\}\s+from\s+['"]next-intl['"];\n/,""),n=n.replace(/\s*const\s+t\s*=\s*useTranslations\(['"]Count['"]\);\n/,""),n=n.replace(/\{t\('currentCount',\s*\{\s*count:\s*value\s*\}\)\}/g,"{value}"),n=n.replace(/\{t\(['"]increment['"]\)\}/g,"Increment"),n=n.replace(/\{t\(['"]decrement['"]\)\}/g,"Decrement"),n=n.replace(/\{t\(['"]reset['"]\)\}/g,"Reset"),await u(o,n)}}},Fi=async e=>{await C(g.join(e,a.LICENSE))},ji=async e=>{await C(g.join(e,a.CHANGELOG))},ki=async e=>{await C(g.join(e,a.NVM_RC)),await C(g.join(e,a.NPM_RC))};T();N();import be from"node:path";var it=async(e,t)=>{let i=[],r=[];t.redux&&(i.push("import { StoreProvider } from '@/providers';"),r.push("StoreProvider")),t.darkMode&&(i.push("import { CustomThemeProvider } from '@/providers';"),r.push("CustomThemeProvider")),t.i18n&&(i.push("import { NextIntlClientProvider, AbstractIntlMessages } from 'next-intl';"),i.push("import { SupportedLocale } from '@/types/i18n';"));let s=`'use client';
16
+ ${i.join(`
17
17
  `)}
18
18
 
19
19
  export const RootProvider = ({
20
20
  children,
21
- ${i.i18n?`locale,
21
+ ${t.i18n?`locale,
22
22
  messages,`:""}
23
23
  }: {
24
24
  children: React.ReactNode;
25
- ${i.i18n?`locale: SupportedLocale;
25
+ ${t.i18n?`locale: SupportedLocale;
26
26
  messages: AbstractIntlMessages;`:""}
27
27
  }) => {
28
28
  return (
29
- `,o="{children}";i.i18n&&(o=`<NextIntlClientProvider locale={locale} messages={messages}>
29
+ `,o="{children}";t.i18n&&(o=`<NextIntlClientProvider locale={locale} messages={messages}>
30
30
  ${o}
31
- </NextIntlClientProvider>`),i.darkMode&&(o=`<CustomThemeProvider>
31
+ </NextIntlClientProvider>`),t.darkMode&&(o=`<CustomThemeProvider>
32
32
  ${o}
33
- </CustomThemeProvider>`),i.redux&&(o=`<StoreProvider>
33
+ </CustomThemeProvider>`),t.redux&&(o=`<StoreProvider>
34
34
  ${o}
35
35
  </StoreProvider>`),o==="{children}"&&(o="<>{children}</>"),s+=` ${o}
36
36
  );
37
37
  };
38
- `,await u(be.join(e,a.ROOT_PROVIDER),s)},ot=async(e,i)=>{if(!i.i18n){let t=`import type { Metadata } from 'next';
38
+ `,await u(be.join(e,a.ROOT_PROVIDER),s)},ot=async(e,t)=>{if(!t.i18n){let i=`import type { Metadata } from 'next';
39
39
  import '@/styles/globals.css';
40
40
  import { Livvic } from 'next/font/google';
41
41
  import { RootProvider } from '@/providers';
@@ -48,8 +48,8 @@ const livvic = Livvic({
48
48
  });
49
49
 
50
50
  export const metadata: Metadata = {
51
- title: '${i.projectName}',
52
- description: '${i.description}',
51
+ title: '${t.projectName}',
52
+ description: '${t.description}',
53
53
  };
54
54
 
55
55
  export default function RootLayout({
@@ -58,8 +58,8 @@ export default function RootLayout({
58
58
  children: React.ReactNode;
59
59
  }>) {
60
60
  return (
61
- <html lang="en" suppressHydrationWarning={${i.darkMode?"true":"false"}}>
62
- <body className={\`\${livvic.variable} ${i.darkMode?"bg-light dark:bg-dark ":""}antialiased\`}>
61
+ <html lang="en" suppressHydrationWarning={${t.darkMode?"true":"false"}}>
62
+ <body className={\`\${livvic.variable} ${t.darkMode?"bg-light dark:bg-dark ":""}antialiased\`}>
63
63
  <RootProvider>
64
64
  {children}
65
65
  </RootProvider>
@@ -67,34 +67,34 @@ export default function RootLayout({
67
67
  </html>
68
68
  );
69
69
  }
70
- `;await u(be.join(e,a.ROOT_LAYOUT),t);let r=i.redux?`import { Counter } from '@/features/counter';
70
+ `;await u(be.join(e,a.ROOT_LAYOUT),i);let r=t.redux?`import { Counter } from '@/features/counter';
71
71
 
72
- `:"",s=i.redux?`
72
+ `:"",s=t.redux?`
73
73
  <Counter />`:"",o=`${r}export default function Home() {
74
74
  return (
75
75
  <div className="flex min-h-screen flex-col items-center justify-center p-24">
76
- <h1 className="text-4xl font-bold">Welcome to ${i.projectName}</h1>
76
+ <h1 className="text-4xl font-bold">Welcome to ${t.projectName}</h1>
77
77
  <p className="mt-4 text-xl">Get started by editing src/app/page.tsx</p>${s}
78
78
  </div>
79
79
  );
80
80
  }
81
- `;await u(be.join(e,a.ROOT_PAGE),o)}};T();A();import I from"node:path";import{readdir as rt}from"node:fs/promises";var nt=async(e,i)=>{await Li(e,i),await Mi(e,i),await Hi(e,i),await Gi(e,i),await Ui(e,i),await Yi(e,i),await Xi(e,i)},Li=async(e,i)=>{i.preCommitHooks||(await P(I.join(e,a.HUSKY_DIR)),await C(I.join(e,a.COMMITLINT_CONFIG)),await C(I.join(e,a.LINTSTAGED_RC)),await re(I.join(e,a.PACKAGE_JSON),t=>(delete t.devDependencies[b.HUSKY],delete t.devDependencies[b.COMMITLINT_CLI],delete t.devDependencies[b.COMMITLINT_CONFIG],delete t.devDependencies[b.LINT_STAGED],delete t.scripts.prepare,delete t.scripts.postinstall,delete t.commitlint,delete t["lint-staged"],t)))},Mi=async(e,i)=>{i.commitizen||(await C(I.join(e,a.CZRC)),await re(I.join(e,a.PACKAGE_JSON),t=>(delete t.devDependencies[b.COMMITIZEN],delete t.devDependencies[b.CZ_CONVENTIONAL_CHANGELOG],delete t.config?.commitizen,t.config&&Object.keys(t.config).length===0&&delete t.config,delete t.scripts.commit,t)))},Hi=async(e,i)=>{i.ci||await P(I.join(e,a.GITHUB_WORKFLOWS))},Gi=async(e,i)=>{let t=I.join(e,a.GITHUB_DIR);if(!i.keepTemplates)await P(I.join(t,a.GITHUB_ISSUE_TEMPLATE)),await C(I.join(t,a.GITHUB_PR_TEMPLATE));else{let r=I.join(t,a.GITHUB_ISSUE_TEMPLATE),s=I.join(t,a.GITHUB_PR_TEMPLATE),o=n=>n.replace(/Teispace/g,i.company).replace(/support@teispace\.com/g,i.email).replace(/Next\.js Starter/g,i.projectName).replace(/\[AUTHOR\]/g,i.author).replace(/\[COMPANY\]/g,i.company).replace(/\[EMAIL\]/g,i.email);if(l(s)){let n=await m(s);n=o(n),await u(s,n)}try{if(l(r)){let n=await rt(r);for(let c of n){let p=I.join(r,c),d=await m(p);d=o(d),await u(p,d)}}}catch{}}},Ui=async(e,i)=>{let t=[a.CODE_OF_CONDUCT,a.CONTRIBUTING,a.SECURITY];for(let r of t)i.communityFiles.includes(r)||await C(I.join(e,r))},Yi=async(e,i)=>{if(i.docker){let t=I.join(e,a.ENV_EXAMPLE);if(l(t)){let r=await m(t),s=(o,n)=>{let c=new RegExp(`${o}=.*`);c.test(r)?r=r.replace(c,`${o}=${n}`):r+=`${o}=${n}
82
- `};s("CONTAINER_NAME",i.containerName||"next-app"),s("IMAGE_NAME",i.imageName||"nextjs-starter"),s("IMAGE_TAG",i.imageTag||"latest"),await u(t,r)}}else{await C(I.join(e,a.DOCKERFILE)),await C(I.join(e,a.DOCKER_COMPOSE)),await C(I.join(e,a.DOCKERIGNORE));let t=I.join(e,a.ENV_EXAMPLE);if(l(t)){let r=await m(t);r=r.replace(/# Docker Compose Configuration\n/,""),r=r.replace(/CONTAINER_NAME=.*\n/,""),r=r.replace(/IMAGE_NAME=.*\n/,""),r=r.replace(/IMAGE_TAG=.*\n/,""),await u(t,r)}}},Xi=async(e,i)=>{let t=async o=>{let n=await rt(o,{withFileTypes:!0}),c=[];for(let p of n){let d=I.join(o,p.name);p.isDirectory()&&p.name!=="node_modules"&&p.name!==".git"?c.push(...await t(d)):p.isFile()&&p.name.toLowerCase()==="readme.md"&&c.push(d)}return c},r=await t(e),s=I.join(e,a.README);for(let o of r)o!==s&&await C(o);if(i.readme){let o=`# ${i.projectName}
81
+ `;await u(be.join(e,a.ROOT_PAGE),o)}};T();N();import E from"node:path";import{readdir as rt}from"node:fs/promises";var nt=async(e,t)=>{await Di(e,t),await Li(e,t),await Mi(e,t),await Hi(e,t),await Gi(e,t),await Ui(e,t),await Yi(e,t)},Di=async(e,t)=>{t.preCommitHooks||(await S(E.join(e,a.HUSKY_DIR)),await C(E.join(e,a.COMMITLINT_CONFIG)),await C(E.join(e,a.LINTSTAGED_RC)),await ne(E.join(e,a.PACKAGE_JSON),i=>(delete i.devDependencies[_.HUSKY],delete i.devDependencies[_.COMMITLINT_CLI],delete i.devDependencies[_.COMMITLINT_CONFIG],delete i.devDependencies[_.LINT_STAGED],delete i.scripts.prepare,delete i.scripts.postinstall,delete i.commitlint,delete i["lint-staged"],i)))},Li=async(e,t)=>{t.commitizen||(await C(E.join(e,a.CZRC)),await ne(E.join(e,a.PACKAGE_JSON),i=>(delete i.devDependencies[_.COMMITIZEN],delete i.devDependencies[_.CZ_CONVENTIONAL_CHANGELOG],delete i.config?.commitizen,i.config&&Object.keys(i.config).length===0&&delete i.config,delete i.scripts.commit,i)))},Mi=async(e,t)=>{t.ci||await S(E.join(e,a.GITHUB_WORKFLOWS))},Hi=async(e,t)=>{let i=E.join(e,a.GITHUB_DIR);if(!t.keepTemplates)await S(E.join(i,a.GITHUB_ISSUE_TEMPLATE)),await C(E.join(i,a.GITHUB_PR_TEMPLATE));else{let r=E.join(i,a.GITHUB_ISSUE_TEMPLATE),s=E.join(i,a.GITHUB_PR_TEMPLATE),o=n=>n.replace(/Teispace/g,t.company).replace(/support@teispace\.com/g,t.email).replace(/Next\.js Starter/g,t.projectName).replace(/\[AUTHOR\]/g,t.author).replace(/\[COMPANY\]/g,t.company).replace(/\[EMAIL\]/g,t.email);if(l(s)){let n=await d(s);n=o(n),await u(s,n)}try{if(l(r)){let n=await rt(r);for(let c of n){let p=E.join(r,c),m=await d(p);m=o(m),await u(p,m)}}}catch{}}},Gi=async(e,t)=>{let i=[a.CODE_OF_CONDUCT,a.CONTRIBUTING,a.SECURITY];for(let r of i)t.communityFiles.includes(r)||await C(E.join(e,r))},Ui=async(e,t)=>{if(t.docker){let i=E.join(e,a.ENV_EXAMPLE);if(l(i)){let r=await d(i),s=(o,n)=>{let c=new RegExp(`${o}=.*`);c.test(r)?r=r.replace(c,`${o}=${n}`):r+=`${o}=${n}
82
+ `};s("CONTAINER_NAME",t.containerName||"next-app"),s("IMAGE_NAME",t.imageName||"nextjs-starter"),s("IMAGE_TAG",t.imageTag||"latest"),await u(i,r)}}else{await C(E.join(e,a.DOCKERFILE)),await C(E.join(e,a.DOCKER_COMPOSE)),await C(E.join(e,a.DOCKERIGNORE));let i=E.join(e,a.ENV_EXAMPLE);if(l(i)){let r=await d(i);r=r.replace(/# Docker Compose Configuration\n/,""),r=r.replace(/CONTAINER_NAME=.*\n/,""),r=r.replace(/IMAGE_NAME=.*\n/,""),r=r.replace(/IMAGE_TAG=.*\n/,""),await u(i,r)}}},Yi=async(e,t)=>{let i=async o=>{let n=await rt(o,{withFileTypes:!0}),c=[];for(let p of n){let m=E.join(o,p.name);p.isDirectory()&&p.name!=="node_modules"&&p.name!==".git"?c.push(...await i(m)):p.isFile()&&p.name.toLowerCase()==="readme.md"&&c.push(m)}return c},r=await i(e),s=E.join(e,a.README);for(let o of r)o!==s&&await C(o);if(t.readme){let o=`# ${t.projectName}
83
83
 
84
- ${i.description}
84
+ ${t.description}
85
85
 
86
86
  ## Getting Started
87
87
 
88
88
  First, run the development server:
89
89
 
90
90
  \`\`\`bash
91
- ${i.packageManager==="npm"?"npm run dev":i.packageManager+" dev"}
91
+ ${t.packageManager==="npm"?"npm run dev":t.packageManager+" dev"}
92
92
  \`\`\`
93
93
 
94
94
  Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
95
- `;await u(s,o)}else await C(s)};var st=e=>{e.command("init").description("Initialize a new Next.js project").argument("[name]","Project name").action(async i=>{await Ji(i)})},Ji=async e=>{Ke(),f("Welcome to the Teispace Next.js App Creator!"),f("");let i=await Je(e),t=Fe.resolve(process.cwd(),i.projectName);l(t)&&(console.error(K.red(`Error: Directory ${i.projectName} already exists.`)),process.exit(1));let r=_("Initializing project..."),s=async()=>{if(l(t)){r.stop(),console.log(K.yellow(`
96
- Cleaning up: Deleting directory ${i.projectName}...`));try{await P(t),console.log(K.green("Cleanup successful."))}catch(n){console.error(K.red(`Failed to clean up directory ${i.projectName}:`),n)}}},o=async()=>{console.log(K.red(`
97
- Process interrupted. Cleaning up...`)),await s(),process.exit(1)};process.on("SIGINT",o),process.on("SIGTERM",o);try{if(await qe(t),await Qe(t,i),await tt(t,i),r.text="Generating code...",await it(t,i),await ot(t,i),r.text="Setting up developer tools...",await nt(t,i),r.text="Initializing Git...",await ze(t,i.gitRemote),r.text="Installing dependencies...",await Ve(t,i.packageManager),r.text="Formatting and Linting...",await G(t,i.packageManager,"format"),await G(t,i.packageManager,"lint:fix"),i.copyEnv){r.text="Creating .env file...";let n=Fe.join(t,".env.example"),c=Fe.join(t,".env");l(n)&&await(await import("node:fs/promises")).copyFile(n,c)}process.off("SIGINT",o),process.off("SIGTERM",o),r.succeed(K.green(`Project ${i.projectName} created successfully!`)),f(""),f("To get started:"),f(K.cyan(` cd ${i.projectName}`)),f(K.cyan(` ${i.packageManager==="npm"?"npm run dev":i.packageManager+" dev"}`)),f("")}catch(n){r.fail("Failed to create project."),console.error(n),await s(),process.exit(1)}};import $ from"picocolors";import De from"node:path";import Wi from"enquirer";var{prompt:zi}=Wi,at=async(e,i,t,r,s,o,n)=>{let c=[];e||c.push({type:"input",name:"featureName",message:"What is the feature name?",initial:"my-feature",validate:d=>/^[a-z0-9-]+$/.test(d)?!0:"Feature name must be lowercase and contain only alphanumeric characters and hyphens."}),i&&r===void 0&&s===void 0&&(c.push({type:"confirm",name:"createStore",message:"Generate Redux store for this feature?",initial:!0}),c.push({type:"confirm",name:"persistStore",message:"Enable persistence for this store?",initial:!1,skip(){return!this.state.answers.createStore}})),t&&t!=="none"&&o===void 0&&n===void 0&&(c.push({type:"confirm",name:"createService",message:"Generate API service for this feature?",initial:!0}),t==="both"&&c.push({type:"select",name:"selectedHttpClient",message:"Which HTTP client to use for the service?",choices:["fetch","axios"],initial:0,skip(){return!this.state.answers.createService}}));let p=c.length>0?await zi(c):{};return{featureName:e||p.featureName,hasRedux:i||!1,createStore:r===!0?!1:s!==void 0?!0:p.createStore||!1,persistStore:s==="persist"?!0:s==="no-persist"?!1:p.persistStore||!1,httpClient:t||"none",createService:o===!0?!1:n!==void 0?!0:p.createService||!1,selectedHttpClient:n||p.selectedHttpClient||(t==="both"?"fetch":t!=="none"?t:void 0)}};import{readFile as Vi,access as je}from"node:fs/promises";import ne from"node:path";var oe=async e=>{let i=!1,t=!1,r=!1,s=!1;try{let o=ne.join(e,"package.json"),n=await Vi(o,"utf-8"),c=JSON.parse(n),p={...c.dependencies,...c.devDependencies};i=!!(p["@reduxjs/toolkit"]&&p["react-redux"]),t=!!p.axios,s=!!p["next-intl"];let d=ne.join(e,"src","lib","utils","http","axios-client");try{await je(d),t=t&&!0}catch{t=!1}let h=ne.join(e,"src","lib","utils","http","fetch-client");try{await je(h),r=!0}catch{r=!1}let y;return t&&r?y="both":t?y="axios":r?y="fetch":y="none",{hasRedux:i,httpClient:y,hasI18n:s}}catch(o){throw new Error(`Failed to detect project setup: ${o}`)}},ct=async(e,i,t=ne.join("src","features"))=>{let r=ne.join(e,t,i);try{return await je(r),!0}catch{return!1}};import{writeFile as J,mkdir as se}from"node:fs/promises";import j from"node:path";var lt=async e=>{let{featurePath:i}=e;await se(j.join(i,"components"),{recursive:!0}),await se(j.join(i,"hooks"),{recursive:!0}),await se(j.join(i,"types"),{recursive:!0}),e.createStore&&await se(j.join(i,"store"),{recursive:!0}),e.createService&&await se(j.join(i,"services"),{recursive:!0}),await Ki(e),await Bi(e),await qi(e),await eo(e),e.createStore&&await Zi(e),e.createService&&e.httpClient&&await Qi(e)};var Ki=async e=>{let{featureName:i,featurePath:t}=e,r=V(i),s=`use${r}`,o=`'use client';
95
+ `;await u(s,o)}else await C(s)};var st=e=>{e.command("init").description("Initialize a new Next.js project").argument("[name]","Project name").action(async t=>{await Xi(t)})},Xi=async e=>{Ke(),f("Welcome to the Teispace Next.js App Creator!"),f("");let t=await Je(e),i=Fe.resolve(process.cwd(),t.projectName);l(i)&&(console.error(V.red(`Error: Directory ${t.projectName} already exists.`)),process.exit(1));let r=$("Initializing project..."),s=async()=>{if(l(i)){r.stop(),console.log(V.yellow(`
96
+ Cleaning up: Deleting directory ${t.projectName}...`));try{await S(i),console.log(V.green("Cleanup successful."))}catch(n){console.error(V.red(`Failed to clean up directory ${t.projectName}:`),n)}}},o=async()=>{console.log(V.red(`
97
+ Process interrupted. Cleaning up...`)),await s(),process.exit(1)};process.on("SIGINT",o),process.on("SIGTERM",o);try{if(await qe(i),await Qe(i,t),await tt(i,t),r.text="Generating code...",await it(i,t),await ot(i,t),r.text="Setting up developer tools...",await nt(i,t),r.text="Initializing Git...",await ze(i,t.gitRemote,t.pushToRemote),r.text="Installing dependencies...",await Ve(i,t.packageManager),r.text="Formatting and Linting...",await H(i,t.packageManager,"format"),await H(i,t.packageManager,"lint:fix"),t.copyEnv){r.text="Creating .env file...";let n=Fe.join(i,".env.example"),c=Fe.join(i,".env");l(n)&&await(await import("node:fs/promises")).copyFile(n,c)}process.off("SIGINT",o),process.off("SIGTERM",o),r.succeed(V.green(`Project ${t.projectName} created successfully!`)),f(""),f("To get started:"),f(V.cyan(` cd ${t.projectName}`)),f(V.cyan(` ${t.packageManager==="npm"?"npm run dev":t.packageManager+" dev"}`)),f("")}catch(n){r.fail("Failed to create project."),console.error(n),await s(),process.exit(1)}};import O from"picocolors";import De from"node:path";import Ji from"enquirer";var{prompt:Wi}=Ji,at=async(e,t,i,r,s,o,n)=>{let c=[];e||c.push({type:"input",name:"featureName",message:"What is the feature name?",initial:"my-feature",validate:m=>/^[a-z0-9-]+$/.test(m)?!0:"Feature name must be lowercase and contain only alphanumeric characters and hyphens."}),t&&r===void 0&&s===void 0&&(c.push({type:"confirm",name:"createStore",message:"Generate Redux store for this feature?",initial:!0}),c.push({type:"confirm",name:"persistStore",message:"Enable persistence for this store?",initial:!1,skip(){return!this.state.answers.createStore}})),i&&i!=="none"&&o===void 0&&n===void 0&&(c.push({type:"confirm",name:"createService",message:"Generate API service for this feature?",initial:!0}),i==="both"&&c.push({type:"select",name:"selectedHttpClient",message:"Which HTTP client to use for the service?",choices:["fetch","axios"],initial:0,skip(){return!this.state.answers.createService}}));let p=c.length>0?await Wi(c):{};return{featureName:e||p.featureName,hasRedux:t||!1,createStore:r===!0?!1:s!==void 0?!0:p.createStore||!1,persistStore:s==="persist"?!0:s==="no-persist"?!1:p.persistStore||!1,httpClient:i||"none",createService:o===!0?!1:n!==void 0?!0:p.createService||!1,selectedHttpClient:n||p.selectedHttpClient||(i==="both"?"fetch":i!=="none"?i:void 0)}};import{readFile as zi,access as je}from"node:fs/promises";import se from"node:path";var re=async e=>{let t=!1,i=!1,r=!1,s=!1;try{let o=se.join(e,"package.json"),n=await zi(o,"utf-8"),c=JSON.parse(n),p={...c.dependencies,...c.devDependencies};t=!!(p["@reduxjs/toolkit"]&&p["react-redux"]),i=!!p.axios,s=!!p["next-intl"];let m=se.join(e,"src","lib","utils","http","axios-client");try{await je(m),i=i&&!0}catch{i=!1}let h=se.join(e,"src","lib","utils","http","fetch-client");try{await je(h),r=!0}catch{r=!1}let y;return i&&r?y="both":i?y="axios":r?y="fetch":y="none",{hasRedux:t,httpClient:y,hasI18n:s}}catch(o){throw new Error(`Failed to detect project setup: ${o}`)}},ct=async(e,t,i=se.join("src","features"))=>{let r=se.join(e,i,t);try{return await je(r),!0}catch{return!1}};import{writeFile as Y,mkdir as ae}from"node:fs/promises";import j from"node:path";var lt=async e=>{let{featurePath:t}=e;await ae(j.join(t,"components"),{recursive:!0}),await ae(j.join(t,"hooks"),{recursive:!0}),await ae(j.join(t,"types"),{recursive:!0}),e.createStore&&await ae(j.join(t,"store"),{recursive:!0}),e.createService&&await ae(j.join(t,"services"),{recursive:!0}),await Vi(e),await Ki(e),await Bi(e),await Qi(e),e.createStore&&await qi(e),e.createService&&e.httpClient&&await Zi(e)};var Vi=async e=>{let{featureName:t,featurePath:i}=e,r=z(t),s=`use${r}`,o=`'use client';
98
98
  import { ${s} } from '../hooks/${s}';
99
99
 
100
100
  export function ${r}() {
@@ -109,9 +109,9 @@ export function ${r}() {
109
109
  }
110
110
 
111
111
  export default ${r};
112
- `;await J(j.join(t,"components",`${r}.tsx`),o)},Bi=async e=>{let{featureName:i,featurePath:t,createStore:r}=e,s=V(i),o=`use${s}`,n;r?n=`'use client';
112
+ `;await Y(j.join(i,"components",`${r}.tsx`),o)},Ki=async e=>{let{featureName:t,featurePath:i,createStore:r}=e,s=z(t),o=`use${s}`,n;r?n=`'use client';
113
113
  import { useAppDispatch, useAppSelector } from '@/store/hooks';
114
- import { select${s}State, setLoading, setError } from '../store/${i}.selectors';
114
+ import { select${s}State, setLoading, setError } from '../store/${t}.selectors';
115
115
 
116
116
  export const ${o} = () => {
117
117
  const dispatch = useAppDispatch();
@@ -145,13 +145,13 @@ export const ${o} = () => {
145
145
  // Add your methods here
146
146
  } as const;
147
147
  };
148
- `,await J(j.join(t,"hooks",`${o}.ts`),n)},qi=async e=>{let{featureName:i,featurePath:t,createStore:r}=e,n=`export interface ${`${V(i)}State`} {
148
+ `,await Y(j.join(i,"hooks",`${o}.ts`),n)},Bi=async e=>{let{featureName:t,featurePath:i,createStore:r}=e,n=`export interface ${`${z(t)}State`} {
149
149
  // Add your state properties here
150
150
  ${r?`loading: boolean;
151
151
  error: string | null;`:"// example: value: string;"}
152
152
  }
153
- `;await J(j.join(t,"types",`${i}.types.ts`),n)},Zi=async e=>{let{featureName:i,featurePath:t,persistStore:r}=e,s=V(i),o=L(i),n=`import { createSlice, PayloadAction } from '@reduxjs/toolkit';
154
- import { ${s}State } from '../types/${i}.types';
153
+ `;await Y(j.join(i,"types",`${t}.types.ts`),n)},qi=async e=>{let{featureName:t,featurePath:i,persistStore:r}=e,s=z(t),o=L(t),n=`import { createSlice, PayloadAction } from '@reduxjs/toolkit';
154
+ import { ${s}State } from '../types/${t}.types';
155
155
 
156
156
  const initialState: ${s}State = {
157
157
  loading: false,
@@ -179,23 +179,23 @@ export const ${o}Slice = createSlice({
179
179
  export const { setLoading, setError, resetState } = ${o}Slice.actions;
180
180
 
181
181
  export const ${o}Reducer = ${o}Slice.reducer;
182
- `;await J(j.join(t,"store",`${i}.slice.ts`),n);let c=`import { RootState } from '@/store/rootReducer';
182
+ `;await Y(j.join(i,"store",`${t}.slice.ts`),n);let c=`import { RootState } from '@/store/rootReducer';
183
183
 
184
184
  export const select${s}State = (state: RootState) => state.${o};
185
- export { setLoading, setError, resetState } from './${i}.slice';
186
- `;if(await J(j.join(t,"store",`${i}.selectors.ts`),c),r){let d=`import { PersistConfig } from 'redux-persist';
185
+ export { setLoading, setError, resetState } from './${t}.slice';
186
+ `;if(await Y(j.join(i,"store",`${t}.selectors.ts`),c),r){let m=`import { PersistConfig } from 'redux-persist';
187
187
  import storage from 'redux-persist/lib/storage';
188
- import { ${s}State } from '../types/${i}.types';
188
+ import { ${s}State } from '../types/${t}.types';
189
189
 
190
190
  export const ${o}PersistConfig: PersistConfig<${s}State> = {
191
191
  key: '${o}',
192
192
  storage,
193
193
  // whitelist: ['someField'], // Specify which fields to persist
194
194
  };
195
- `;await J(j.join(t,"store","persist.ts"),d)}let p=`export * from './${i}.slice';
196
- export * from './${i}.selectors';${r?`
195
+ `;await Y(j.join(i,"store","persist.ts"),m)}let p=`export * from './${t}.slice';
196
+ export * from './${t}.selectors';${r?`
197
197
  export * from './persist';`:""}
198
- `;await J(j.join(t,"store","index.ts"),p)},Qi=async e=>{let{featureName:i,featurePath:t,httpClient:r}=e,s=L(i),o;r==="axios"?o=`import { AppApis } from '@/lib/config';
198
+ `;await Y(j.join(i,"store","index.ts"),p)},Zi=async e=>{let{featureName:t,featurePath:i,httpClient:r}=e,s=L(t),o;r==="axios"?o=`import { AppApis } from '@/lib/config';
199
199
  import { axiosClient } from '@/lib/utils/http';
200
200
  import { ResultAsync } from '@/types';
201
201
 
@@ -213,43 +213,43 @@ export const ${s}Service = {
213
213
  return fetchClient.get<string>(AppApis.${s}.getAll);
214
214
  },
215
215
  };
216
- `,await J(j.join(t,"services",`${i}.service.ts`),o)},eo=async e=>{let{featureName:i,featurePath:t,createStore:r,createService:s}=e,o=V(i),n=`export { default as ${o} } from './components/${o}';
216
+ `,await Y(j.join(i,"services",`${t}.service.ts`),o)},Qi=async e=>{let{featureName:t,featurePath:i,createStore:r,createService:s}=e,o=z(t),n=`export { default as ${o} } from './components/${o}';
217
217
  export { use${o} } from './hooks/use${o}';
218
- export * from './types/${i}.types';${r?`
218
+ export * from './types/${t}.types';${r?`
219
219
  export * from './store';`:""}${s?`
220
- export * from './services/${i}.service';`:""}
221
- `;await J(j.join(t,"index.ts"),n)};import{readFile as pt,writeFile as mt}from"node:fs/promises";import ke from"node:path";var dt=async(e,i,t,r=ke.join("src","features"))=>{let s=ke.join(e,"src","store","rootReducer.ts");try{let o=await pt(s,"utf-8"),n=L(i),c=`${n}Reducer`,p=t?`${n}PersistConfig`:"",d=r.replace(/^src\//,"@/"),h=t?`import { ${c}, ${p} } from '${d}/${i}/store';`:`import { ${c} } from '${d}/${i}/store';`,y=/import\s+.*\s+from\s+['"].*['"];?\n/g,g=o.match(y);if(g&&g.length>0){let E=g[g.length-1],D=o.lastIndexOf(E);o=o.slice(0,D+E.length)+h+`
222
- `+o.slice(D+E.length)}else o=h+`
223
- `+o;let v=/combineReducers\(\{([^}]*)\}\)/s,R=o.match(v);if(R){let E=R[1],D=t?`
220
+ export * from './services/${t}.service';`:""}
221
+ `;await Y(j.join(i,"index.ts"),n)};import{readFile as pt,writeFile as mt}from"node:fs/promises";import ke from"node:path";var dt=async(e,t,i,r=ke.join("src","features"))=>{let s=ke.join(e,"src","store","rootReducer.ts");try{let o=await pt(s,"utf-8"),n=L(t),c=`${n}Reducer`,p=i?`${n}PersistConfig`:"",m=r.replace(/^src\//,"@/"),h=i?`import { ${c}, ${p} } from '${m}/${t}/store';`:`import { ${c} } from '${m}/${t}/store';`,y=/import\s+.*\s+from\s+['"].*['"];?\n/g,x=o.match(y);if(x&&x.length>0){let I=x[x.length-1],F=o.lastIndexOf(I);o=o.slice(0,F+I.length)+h+`
222
+ `+o.slice(F+I.length)}else o=h+`
223
+ `+o;let w=/combineReducers\(\{([^}]*)\}\)/s,D=o.match(w);if(D){let I=D[1],F=i?`
224
224
  ${n}: persistReducer(${p}, ${c}),`:`
225
- ${n}: ${c},`,U=E.trimEnd()+D;o=o.replace(v,`combineReducers({${U}
226
- })`)}else throw new Error("Could not find combineReducers in rootReducer.ts");await mt(s,o)}catch(o){throw new Error(`Failed to register feature in rootReducer: ${o}`)}},ut=async(e,i,t,r)=>{let s=ke.join(e,"src","store","rootReducer.ts");try{let o=await pt(s,"utf-8"),n=L(i),c=`${n}Reducer`,p=t?`${n}PersistConfig`:"",d=r.replace(/^src\//,"@/"),h=t?`import { ${c}, ${p} } from '${d}/${i}';`:`import { ${c} } from '${d}/${i}';`,y=/import\s+.*\s+from\s+['"].*['"];?\n/g,g=o.match(y);if(g&&g.length>0){let E=g[g.length-1],D=o.lastIndexOf(E);o=o.slice(0,D+E.length)+h+`
227
- `+o.slice(D+E.length)}else o=h+`
228
- `+o;let v=/combineReducers\(\{([^}]*)\}\)/s,R=o.match(v);if(R){let E=R[1],D=t?`
225
+ ${n}: ${c},`,ie=I.trimEnd()+F;o=o.replace(w,`combineReducers({${ie}
226
+ })`)}else throw new Error("Could not find combineReducers in rootReducer.ts");await mt(s,o)}catch(o){throw new Error(`Failed to register feature in rootReducer: ${o}`)}},ut=async(e,t,i,r)=>{let s=ke.join(e,"src","store","rootReducer.ts");try{let o=await pt(s,"utf-8"),n=L(t),c=`${n}Reducer`,p=i?`${n}PersistConfig`:"",m=r.replace(/^src\//,"@/"),h=i?`import { ${c}, ${p} } from '${m}/${t}';`:`import { ${c} } from '${m}/${t}';`,y=/import\s+.*\s+from\s+['"].*['"];?\n/g,x=o.match(y);if(x&&x.length>0){let I=x[x.length-1],F=o.lastIndexOf(I);o=o.slice(0,F+I.length)+h+`
227
+ `+o.slice(F+I.length)}else o=h+`
228
+ `+o;let w=/combineReducers\(\{([^}]*)\}\)/s,D=o.match(w);if(D){let I=D[1],F=i?`
229
229
  ${n}: persistReducer(${p}, ${c}),`:`
230
- ${n}: ${c},`,U=E.trimEnd()+D;o=o.replace(v,`combineReducers({${U}
231
- })`)}else throw new Error("Could not find combineReducers in rootReducer.ts");await mt(s,o)}catch(o){throw new Error(`Failed to register slice in rootReducer: ${o}`)}};import{readFile as to,writeFile as io}from"node:fs/promises";import oo from"node:path";var xe=async e=>{let{serviceName:i,projectPath:t}=e,r=L(i),s=oo.join(t,"src","lib","config","app-apis.ts");try{let o=await to(s,"utf-8");if(o.includes(`${r}:`))return;if(!o.match(/export const AppApis = \{[\s\S]*?\} as const;/))throw new Error("Could not find AppApis object in app-apis.ts");let c=` ${r}: {
232
- base: \`\${API_PREFIX}/${i}\`,
233
- getAll: \`\${API_PREFIX}/${i}\`,
234
- },`,p=/(\s*)\} as const;/;if(!o.match(p))throw new Error("Could not find closing brace of AppApis object");let h=o.lastIndexOf("} as const;"),y=o.substring(0,h),g=o.substring(h),v=y.trim().endsWith(","),R=y.match(/:\s*\{[^}]*\},\s*$/),E;R||v?E=`${y}
230
+ ${n}: ${c},`,ie=I.trimEnd()+F;o=o.replace(w,`combineReducers({${ie}
231
+ })`)}else throw new Error("Could not find combineReducers in rootReducer.ts");await mt(s,o)}catch(o){throw new Error(`Failed to register slice in rootReducer: ${o}`)}};import{readFile as eo,writeFile as to}from"node:fs/promises";import io from"node:path";var ge=async e=>{let{serviceName:t,projectPath:i}=e,r=L(t),s=io.join(i,"src","lib","config","app-apis.ts");try{let o=await eo(s,"utf-8");if(o.includes(`${r}:`))return;if(!o.match(/export const AppApis = \{[\s\S]*?\} as const;/))throw new Error("Could not find AppApis object in app-apis.ts");let c=` ${r}: {
232
+ base: \`\${API_PREFIX}/${t}\`,
233
+ getAll: \`\${API_PREFIX}/${t}\`,
234
+ },`,p=/(\s*)\} as const;/;if(!o.match(p))throw new Error("Could not find closing brace of AppApis object");let h=o.lastIndexOf("} as const;"),y=o.substring(0,h),x=o.substring(h),w=y.trim().endsWith(","),D=y.match(/:\s*\{[^}]*\},\s*$/),I;D||w?I=`${y}
235
235
  ${c}
236
- ${g}`:E=y.trimEnd()+`
236
+ ${x}`:I=y.trimEnd()+`
237
237
  `+c+`
238
- `+g,await io(s,E)}catch(o){throw new Error(`Failed to register API endpoints: ${o}`)}};var ft=e=>{e.command("feature [name]").description("Generate a new feature module").option("--skip-store","Skip Redux store generation").option("--store <type>","Generate Redux store with persistence option (persist|no-persist)").option("--skip-service","Skip API service generation").option("--service <client>","Generate API service with specific HTTP client (axios|fetch)").option("--path <path>","Custom path for feature generation (default: src/features)").action(async(i,t)=>{try{let r=process.cwd();t.store&&!["persist","no-persist"].includes(t.store)&&(N("Invalid --store option. Use: persist or no-persist"),process.exit(1)),t.service&&!["axios","fetch"].includes(t.service)&&(N("Invalid --service option. Use: axios or fetch"),process.exit(1)),t.skipStore&&t.store&&(N("Cannot use --skip-store and --store together"),process.exit(1)),t.skipService&&t.service&&(N("Cannot use --skip-service and --service together"),process.exit(1)),f($.cyan(`
238
+ `+x,await to(s,I)}catch(o){throw new Error(`Failed to register API endpoints: ${o}`)}};var ft=e=>{e.command("feature [name]").description("Generate a new feature module").option("--skip-store","Skip Redux store generation").option("--store <type>","Generate Redux store with persistence option (persist|no-persist)").option("--skip-service","Skip API service generation").option("--service <client>","Generate API service with specific HTTP client (axios|fetch)").option("--path <path>","Custom path for feature generation (default: src/features)").action(async(t,i)=>{try{let r=process.cwd();i.store&&!["persist","no-persist"].includes(i.store)&&(R("Invalid --store option. Use: persist or no-persist"),process.exit(1)),i.service&&!["axios","fetch"].includes(i.service)&&(R("Invalid --service option. Use: axios or fetch"),process.exit(1)),i.skipStore&&i.store&&(R("Cannot use --skip-store and --store together"),process.exit(1)),i.skipService&&i.service&&(R("Cannot use --skip-service and --service together"),process.exit(1)),f(O.cyan(`
239
239
  \u{1F3AF} Feature Generator
240
- `)),w.start("Detecting project setup...");let s=await oe(r);w.succeed("Project setup detected"),f($.dim(` Redux: ${s.hasRedux?"\u2713":"\u2717"}`)),f($.dim(` HTTP Client: ${s.httpClient}`)),f($.dim(` i18n: ${s.hasI18n?"\u2713":"\u2717"}
241
- `));let o=await at(i,s.hasRedux,s.httpClient,t.skipStore,t.store,t.skipService,t.service),n=t.path||De.join("src","features"),c=De.join(r,n,o.featureName);await ct(r,o.featureName,n)&&(N(`Feature '${o.featureName}' already exists at ${n}!`),process.exit(1)),w.start("Generating feature files..."),await lt({featureName:o.featureName,featurePath:c,createStore:o.createStore,persistStore:o.persistStore,createService:o.createService,httpClient:o.selectedHttpClient}),w.succeed("Feature files generated"),o.createService&&(w.start("Registering API endpoints..."),await xe({serviceName:o.featureName,projectPath:r}),w.succeed("API endpoints registered")),o.createStore&&s.hasRedux&&(w.start("Registering feature in rootReducer..."),await dt(r,o.featureName,o.persistStore,n),w.succeed("Feature registered in rootReducer"));let d=De.join(n,o.featureName);f($.green(`
240
+ `)),v.start("Detecting project setup...");let s=await re(r);v.succeed("Project setup detected"),f(O.dim(` Redux: ${s.hasRedux?"\u2713":"\u2717"}`)),f(O.dim(` HTTP Client: ${s.httpClient}`)),f(O.dim(` i18n: ${s.hasI18n?"\u2713":"\u2717"}
241
+ `));let o=await at(t,s.hasRedux,s.httpClient,i.skipStore,i.store,i.skipService,i.service),n=i.path||De.join("src","features"),c=De.join(r,n,o.featureName);await ct(r,o.featureName,n)&&(R(`Feature '${o.featureName}' already exists at ${n}!`),process.exit(1)),v.start("Generating feature files..."),await lt({featureName:o.featureName,featurePath:c,createStore:o.createStore,persistStore:o.persistStore,createService:o.createService,httpClient:o.selectedHttpClient}),v.succeed("Feature files generated"),o.createService&&(v.start("Registering API endpoints..."),await ge({serviceName:o.featureName,projectPath:r}),v.succeed("API endpoints registered")),o.createStore&&s.hasRedux&&(v.start("Registering feature in rootReducer..."),await dt(r,o.featureName,o.persistStore,n),v.succeed("Feature registered in rootReducer"));let m=De.join(n,o.featureName);f(O.green(`
242
242
  \u2728 Feature '${o.featureName}' created successfully!
243
- `)),f($.dim("Generated files:")),f($.dim(` \u{1F4C2} ${d}/`)),f($.dim(" \u251C\u2500\u2500 components/")),f($.dim(" \u251C\u2500\u2500 hooks/")),f($.dim(" \u251C\u2500\u2500 types/")),o.createStore&&f($.dim(" \u251C\u2500\u2500 store/")),o.createService&&f($.dim(" \u251C\u2500\u2500 services/")),f($.dim(` \u2514\u2500\u2500 index.ts
244
- `)),f($.cyan("Next steps:"));let h=n.replace(/^src\//,"@/");f($.dim(` 1. Import and use the feature: import { ${o.featureName} } from '${h}/${o.featureName}'`)),o.createStore&&f($.dim(` 2. Customize your Redux slice in: ${d}/store/`)),o.createService&&f($.dim(` 3. Add API methods in: ${d}/services/${o.featureName}.service.ts`)),f("")}catch(r){w.fail("Feature generation failed"),N(`${r}`),process.exit(1)}})};import k from"picocolors";import B from"node:path";import{existsSync as fo}from"node:fs";import{mkdir as go}from"node:fs/promises";import ro from"enquirer";var{prompt:no}=ro,gt=async(e,i,t)=>{let r=[];e||r.push({type:"input",name:"sliceName",message:"What is the slice name?",initial:"my-slice",validate:o=>/^[a-z0-9-]+$/.test(o)?!0:"Slice name must be lowercase and contain only alphanumeric characters and hyphens."}),i===void 0&&t===void 0&&r.push({type:"confirm",name:"persistSlice",message:"Enable persistence for this slice?",initial:!1});let s=r.length>0?await no(r):{};return{sliceName:e||s.sliceName,persistSlice:i===!0?!0:t===!1?!1:s.persistSlice||!1}};import{writeFile as ae,mkdir as so}from"node:fs/promises";import ce from"node:path";var xt=async e=>{let{sliceName:i,slicePath:t,persistSlice:r}=e;await so(t,{recursive:!0});let s=V(i),o=L(i);await ao(i,t,s),await co(i,t,s,o),await lo(i,t,s,o),r&&await po(i,t,s,o),await mo(i,t,r)},ao=async(e,i,t)=>{let r=`export interface ${t}State {
243
+ `)),f(O.dim("Generated files:")),f(O.dim(` \u{1F4C2} ${m}/`)),f(O.dim(" \u251C\u2500\u2500 components/")),f(O.dim(" \u251C\u2500\u2500 hooks/")),f(O.dim(" \u251C\u2500\u2500 types/")),o.createStore&&f(O.dim(" \u251C\u2500\u2500 store/")),o.createService&&f(O.dim(" \u251C\u2500\u2500 services/")),f(O.dim(` \u2514\u2500\u2500 index.ts
244
+ `)),f(O.cyan("Next steps:"));let h=n.replace(/^src\//,"@/");f(O.dim(` 1. Import and use the feature: import { ${o.featureName} } from '${h}/${o.featureName}'`)),o.createStore&&f(O.dim(` 2. Customize your Redux slice in: ${m}/store/`)),o.createService&&f(O.dim(` 3. Add API methods in: ${m}/services/${o.featureName}.service.ts`)),f("")}catch(r){v.fail("Feature generation failed"),R(`${r}`),process.exit(1)}})};import k from"picocolors";import K from"node:path";import{existsSync as uo}from"node:fs";import{mkdir as fo}from"node:fs/promises";import oo from"enquirer";var{prompt:ro}=oo,gt=async(e,t,i)=>{let r=[];e||r.push({type:"input",name:"sliceName",message:"What is the slice name?",initial:"my-slice",validate:o=>/^[a-z0-9-]+$/.test(o)?!0:"Slice name must be lowercase and contain only alphanumeric characters and hyphens."}),t===void 0&&i===void 0&&r.push({type:"confirm",name:"persistSlice",message:"Enable persistence for this slice?",initial:!1});let s=r.length>0?await ro(r):{};return{sliceName:e||s.sliceName,persistSlice:t===!0?!0:i===!1?!1:s.persistSlice||!1}};import{writeFile as ce,mkdir as no}from"node:fs/promises";import le from"node:path";var xt=async e=>{let{sliceName:t,slicePath:i,persistSlice:r}=e;await no(i,{recursive:!0});let s=z(t),o=L(t);await so(t,i,s),await ao(t,i,s,o),await co(t,i,s,o),r&&await lo(t,i,s,o),await po(t,i,r)},so=async(e,t,i)=>{let r=`export interface ${i}State {
245
245
  loading: boolean;
246
246
  error: string | null;
247
247
  // Add your state properties here
248
248
  }
249
- `;await ae(ce.join(i,`${e}.types.ts`),r)},co=async(e,i,t,r)=>{let s=`import { createSlice, PayloadAction } from '@reduxjs/toolkit';
250
- import { ${t}State } from './${e}.types';
249
+ `;await ce(le.join(t,`${e}.types.ts`),r)},ao=async(e,t,i,r)=>{let s=`import { createSlice, PayloadAction } from '@reduxjs/toolkit';
250
+ import { ${i}State } from './${e}.types';
251
251
 
252
- const initialState: ${t}State = {
252
+ const initialState: ${i}State = {
253
253
  loading: false,
254
254
  error: null,
255
255
  // Add your initial state here
@@ -275,32 +275,32 @@ export const ${r}Slice = createSlice({
275
275
  export const { setLoading, setError, resetState } = ${r}Slice.actions;
276
276
 
277
277
  export const ${r}Reducer = ${r}Slice.reducer;
278
- `;await ae(ce.join(i,`${e}.slice.ts`),s)},lo=async(e,i,t,r)=>{let s=`import { RootState } from '@/store/rootReducer';
278
+ `;await ce(le.join(t,`${e}.slice.ts`),s)},co=async(e,t,i,r)=>{let s=`import { RootState } from '@/store/rootReducer';
279
279
 
280
- export const select${t}State = (state: RootState) => state.${r};
280
+ export const select${i}State = (state: RootState) => state.${r};
281
281
  export { setLoading, setError, resetState } from './${e}.slice';
282
- `;await ae(ce.join(i,`${e}.selectors.ts`),s)},po=async(e,i,t,r)=>{let s=`import { PersistConfig } from 'redux-persist';
282
+ `;await ce(le.join(t,`${e}.selectors.ts`),s)},lo=async(e,t,i,r)=>{let s=`import { PersistConfig } from 'redux-persist';
283
283
  import storage from 'redux-persist/lib/storage';
284
- import { ${t}State } from './${e}.types';
284
+ import { ${i}State } from './${e}.types';
285
285
 
286
- export const ${r}PersistConfig: PersistConfig<${t}State> = {
286
+ export const ${r}PersistConfig: PersistConfig<${i}State> = {
287
287
  key: '${r}',
288
288
  storage,
289
289
  // whitelist: ['someField'], // Specify which fields to persist
290
290
  };
291
- `;await ae(ce.join(i,"persist.ts"),s)},mo=async(e,i,t)=>{let r=`export * from './${e}.slice';
291
+ `;await ce(le.join(t,"persist.ts"),s)},po=async(e,t,i)=>{let r=`export * from './${e}.slice';
292
292
  export * from './${e}.selectors';
293
- export * from './${e}.types';${t?`
293
+ export * from './${e}.types';${i?`
294
294
  export * from './persist';`:""}
295
- `;await ae(ce.join(i,"index.ts"),r)};import{access as uo}from"node:fs/promises";import ht from"node:path";var yt=async(e,i,t=ht.join("src","store","slices"))=>{let r=ht.join(e,t,i);try{return await uo(r),!0}catch{return!1}};var St=e=>{e.command("slice [name]").description("Generate a Redux slice").option("--path <path>","Custom path for slice generation (default: create new feature)").option("--persist","Enable persistence for this slice").option("--no-persist","Disable persistence for this slice").action(async(i,t)=>{try{let r=process.cwd();t.persist&&t.noPersist===!0&&(N("Cannot use --persist and --no-persist together"),process.exit(1)),f(k.cyan(`
295
+ `;await ce(le.join(t,"index.ts"),r)};import{access as mo}from"node:fs/promises";import ht from"node:path";var yt=async(e,t,i=ht.join("src","store","slices"))=>{let r=ht.join(e,i,t);try{return await mo(r),!0}catch{return!1}};var St=e=>{e.command("slice [name]").description("Generate a Redux slice").option("--path <path>","Custom path for slice generation (default: create new feature)").option("--persist","Enable persistence for this slice").option("--no-persist","Disable persistence for this slice").action(async(t,i)=>{try{let r=process.cwd();i.persist&&i.noPersist===!0&&(R("Cannot use --persist and --no-persist together"),process.exit(1)),f(k.cyan(`
296
296
  \u{1F527} Slice Generator
297
- `)),w.start("Detecting project setup...");let s=await oe(r);w.succeed("Project setup detected"),s.hasRedux||(w.fail("Redux is not setup in this project"),N("Please install @reduxjs/toolkit and react-redux first"),f(k.dim(`
297
+ `)),v.start("Detecting project setup...");let s=await re(r);v.succeed("Project setup detected"),s.hasRedux||(v.fail("Redux is not setup in this project"),R("Please install @reduxjs/toolkit and react-redux first"),f(k.dim(`
298
298
  Run: npm install @reduxjs/toolkit react-redux
299
299
  `)),process.exit(1)),f(k.dim(` Redux: \u2713
300
- `));let o=await gt(i,t.persist,t.noPersist===!0?!1:void 0),n,c,p;if(t.path){let v=t.path.replace(/^src\//,"");v.startsWith("features/")?(c=v.split("/")[1],n=B.join("src","features",c,"store"),p=B.join(r,n,o.sliceName)):(n=B.join("src",v),c=v.split("/")[0],p=B.join(r,n,o.sliceName))}else c=o.sliceName,n=B.join("src","features",c,"store"),p=B.join(r,n,o.sliceName);let d=B.join(r,n);fo(d)||await go(d,{recursive:!0}),await yt(r,o.sliceName,n)&&(N(`Slice '${o.sliceName}' already exists at ${n}!`),process.exit(1)),w.start("Generating slice files..."),await xt({sliceName:o.sliceName,slicePath:p,persistSlice:o.persistSlice}),w.succeed("Slice files generated"),w.start("Registering slice in rootReducer..."),await ut(r,o.sliceName,o.persistSlice,n),w.succeed("Slice registered in rootReducer");let y=B.join(n,o.sliceName);f(k.green(`
300
+ `));let o=await gt(t,i.persist,i.noPersist===!0?!1:void 0),n,c,p;if(i.path){let w=i.path.replace(/^src\//,"");w.startsWith("features/")?(c=w.split("/")[1],n=K.join("src","features",c,"store"),p=K.join(r,n,o.sliceName)):(n=K.join("src",w),c=w.split("/")[0],p=K.join(r,n,o.sliceName))}else c=o.sliceName,n=K.join("src","features",c,"store"),p=K.join(r,n,o.sliceName);let m=K.join(r,n);uo(m)||await fo(m,{recursive:!0}),await yt(r,o.sliceName,n)&&(R(`Slice '${o.sliceName}' already exists at ${n}!`),process.exit(1)),v.start("Generating slice files..."),await xt({sliceName:o.sliceName,slicePath:p,persistSlice:o.persistSlice}),v.succeed("Slice files generated"),v.start("Registering slice in rootReducer..."),await ut(r,o.sliceName,o.persistSlice,n),v.succeed("Slice registered in rootReducer");let y=K.join(n,o.sliceName);f(k.green(`
301
301
  \u2728 Slice '${o.sliceName}' created successfully!
302
302
  `)),f(k.dim("Generated files:")),f(k.dim(` \u{1F4C2} ${y}/`)),f(k.dim(` \u251C\u2500\u2500 ${o.sliceName}.slice.ts`)),f(k.dim(` \u251C\u2500\u2500 ${o.sliceName}.selectors.ts`)),o.persistSlice&&f(k.dim(" \u251C\u2500\u2500 persist.ts")),f(k.dim(` \u251C\u2500\u2500 ${o.sliceName}.types.ts`)),f(k.dim(` \u2514\u2500\u2500 index.ts
303
- `)),f(k.cyan("Next steps:"));let g=n.replace(/^src\//,"@/");f(k.dim(` 1. Import actions: import { setLoading, setError } from '${g}/${o.sliceName}'`)),f(k.dim(" 2. Use in component: dispatch(setLoading(true))")),f("")}catch(r){w.fail("Slice generation failed"),N(`${r}`),process.exit(1)}})};import W from"picocolors";import ee from"node:path";import{existsSync as vo}from"node:fs";import{mkdir as wo}from"node:fs/promises";import Pt from"enquirer";var vt=async(e,i,t,r)=>{let s=e||(await Pt.prompt({type:"input",name:"serviceName",message:"Service name (kebab-case):",validate:n=>n?/^[a-z0-9-]+$/.test(n)?!0:"Service name must be lowercase with hyphens only":"Service name is required"})).serviceName,o;return i!==void 0?o="axios":t!==void 0?o="fetch":r==="axios"?o="axios":r==="fetch"?o="fetch":r==="both"?o=(await Pt.prompt({type:"select",name:"httpClient",message:"Choose HTTP client:",choices:["axios","fetch"]})).httpClient:o="axios",{serviceName:s,httpClient:o}};import{writeFile as xo}from"node:fs/promises";import ho from"node:path";var wt=async e=>{await yo(e)},yo=async e=>{let{serviceName:i,servicePath:t,httpClient:r}=e,s=L(i),o;r==="axios"?o=`import { AppApis } from '@/lib/config';
303
+ `)),f(k.cyan("Next steps:"));let x=n.replace(/^src\//,"@/");f(k.dim(` 1. Import actions: import { setLoading, setError } from '${x}/${o.sliceName}'`)),f(k.dim(" 2. Use in component: dispatch(setLoading(true))")),f("")}catch(r){v.fail("Slice generation failed"),R(`${r}`),process.exit(1)}})};import X from"picocolors";import ee from"node:path";import{existsSync as Po}from"node:fs";import{mkdir as vo}from"node:fs/promises";import Pt from"enquirer";var vt=async(e,t,i,r)=>{let s=e||(await Pt.prompt({type:"input",name:"serviceName",message:"Service name (kebab-case):",validate:n=>n?/^[a-z0-9-]+$/.test(n)?!0:"Service name must be lowercase with hyphens only":"Service name is required"})).serviceName,o;return t!==void 0?o="axios":i!==void 0?o="fetch":r==="axios"?o="axios":r==="fetch"?o="fetch":r==="both"?o=(await Pt.prompt({type:"select",name:"httpClient",message:"Choose HTTP client:",choices:["axios","fetch"]})).httpClient:o="axios",{serviceName:s,httpClient:o}};import{writeFile as go}from"node:fs/promises";import xo from"node:path";var wt=async e=>{await ho(e)},ho=async e=>{let{serviceName:t,servicePath:i,httpClient:r}=e,s=L(t),o;r==="axios"?o=`import { AppApis } from '@/lib/config';
304
304
  import { axiosClient } from '@/lib/utils/http';
305
305
  import { ResultAsync } from '@/types';
306
306
 
@@ -318,25 +318,25 @@ export const ${s}Service = {
318
318
  return fetchClient.get<string>(AppApis.${s}.getAll);
319
319
  },
320
320
  };
321
- `;let n=`${i}.service.ts`;await xo(ho.join(t,n),o)};import{existsSync as So}from"node:fs";import Po from"node:path";var Ct=async(e,i,t)=>{let r=Po.join(e,t,`${i}.service.ts`);return So(r)};var Tt=e=>{e.command("service [name]").description("Generate an API service").option("--path <path>","Custom path for service generation (default: create new feature)").option("--axios","Use Axios HTTP client").option("--fetch","Use Fetch HTTP client").action(async(i,t)=>{try{let r=process.cwd();t.axios&&t.fetch&&(N("Cannot use --axios and --fetch together"),process.exit(1)),f(W.cyan(`
321
+ `;let n=`${t}.service.ts`;await go(xo.join(i,n),o)};import{existsSync as yo}from"node:fs";import So from"node:path";var Ct=async(e,t,i)=>{let r=So.join(e,i,`${t}.service.ts`);return yo(r)};var Tt=e=>{e.command("service [name]").description("Generate an API service").option("--path <path>","Custom path for service generation (default: create new feature)").option("--axios","Use Axios HTTP client").option("--fetch","Use Fetch HTTP client").action(async(t,i)=>{try{let r=process.cwd();i.axios&&i.fetch&&(R("Cannot use --axios and --fetch together"),process.exit(1)),f(X.cyan(`
322
322
  \u{1F527} Service Generator
323
- `)),w.start("Detecting project setup...");let s=await oe(r);w.succeed("Project setup detected"),s.httpClient==="none"&&(w.fail("No HTTP client is setup in this project"),N("Please setup either AxiosClient or FetchClient first"),f(W.dim(`
323
+ `)),v.start("Detecting project setup...");let s=await re(r);v.succeed("Project setup detected"),s.httpClient==="none"&&(v.fail("No HTTP client is setup in this project"),R("Please setup either AxiosClient or FetchClient first"),f(X.dim(`
324
324
  Check: lib/utils/http/axios-client or lib/utils/http/fetch-client
325
- `)),process.exit(1));let o=[];(s.httpClient==="axios"||s.httpClient==="both")&&o.push("Axios \u2713"),(s.httpClient==="fetch"||s.httpClient==="both")&&o.push("Fetch \u2713"),f(W.dim(` HTTP Clients: ${o.join(", ")}
326
- `));let n=await vt(i,t.axios,t.fetch,s.httpClient),c,p,d;if(t.path){let v=t.path.replace(/^src\//,"");v.startsWith("features/")?(p=v.split("/")[1],c=ee.join("src","features",p,"services"),d=ee.join(r,c)):(c=ee.join("src",v),p=v.split("/")[0],d=ee.join(r,c))}else p=n.serviceName,c=ee.join("src","features",p,"services"),d=ee.join(r,c);vo(d)||await wo(d,{recursive:!0}),await Ct(r,n.serviceName,c)&&(N(`Service '${n.serviceName}' already exists at ${c}!`),process.exit(1)),w.start("Generating service files..."),await wt({serviceName:n.serviceName,servicePath:d,httpClient:n.httpClient}),w.succeed("Service files generated"),w.start("Registering API endpoints..."),await xe({serviceName:n.serviceName,projectPath:r}),w.succeed("API endpoints registered");let y=ee.join(c,`${n.serviceName}.service.ts`);f(W.green(`
325
+ `)),process.exit(1));let o=[];(s.httpClient==="axios"||s.httpClient==="both")&&o.push("Axios \u2713"),(s.httpClient==="fetch"||s.httpClient==="both")&&o.push("Fetch \u2713"),f(X.dim(` HTTP Clients: ${o.join(", ")}
326
+ `));let n=await vt(t,i.axios,i.fetch,s.httpClient),c,p,m;if(i.path){let w=i.path.replace(/^src\//,"");w.startsWith("features/")?(p=w.split("/")[1],c=ee.join("src","features",p,"services"),m=ee.join(r,c)):(c=ee.join("src",w),p=w.split("/")[0],m=ee.join(r,c))}else p=n.serviceName,c=ee.join("src","features",p,"services"),m=ee.join(r,c);Po(m)||await vo(m,{recursive:!0}),await Ct(r,n.serviceName,c)&&(R(`Service '${n.serviceName}' already exists at ${c}!`),process.exit(1)),v.start("Generating service files..."),await wt({serviceName:n.serviceName,servicePath:m,httpClient:n.httpClient}),v.succeed("Service files generated"),v.start("Registering API endpoints..."),await ge({serviceName:n.serviceName,projectPath:r}),v.succeed("API endpoints registered");let y=ee.join(c,`${n.serviceName}.service.ts`);f(X.green(`
327
327
  \u2728 Service '${n.serviceName}' created successfully!
328
- `)),f(W.dim("Generated files:")),f(W.dim(` \u{1F4C4} ${y}
329
- `)),f(W.cyan("Next steps:"));let g=c.replace(/^src\//,"@/");f(W.dim(` 1. Import service: import { ${n.serviceName}Service } from '${g}/${n.serviceName}.service'`)),f(W.dim(` 2. Use in component: const data = await ${n.serviceName}Service.getAll()`)),f("")}catch(r){w.fail("Service generation failed"),N(`${r}`),process.exit(1)}})};import we from"picocolors";import Do from"enquirer";T();import To from"node:path";import Eo from"picocolors";T();A();import le from"node:path";T();A();import Et from"node:path";var he=async e=>{let i=[Et.join(e,a.ROOT_LAYOUT),Et.join(e,"src/app/[locale]/layout.tsx")];for(let t of i)if(l(t)&&(await m(t)).includes("<body"))return t;for(let t of i)if(l(t))return t;return""};var It=async e=>{let i=le.join(e,a.THEME_PROVIDER),t=le.join(e,a.GLOBALS_CSS),r=le.join(e,"package.json");if(l(i))return{isSetup:!0,reason:"CustomThemeProvider.tsx exists"};if(l(r)){let s=JSON.parse(await m(r));if(s.dependencies&&s.dependencies["next-themes"]||s.devDependencies&&s.devDependencies["next-themes"])return{isSetup:!0,reason:"next-themes is installed"}}return l(t)&&(await m(t)).includes("@custom-variant dark")?{isSetup:!0,reason:"Dark theme CSS found in globals.css"}:{isSetup:!1,reason:""}},Rt=async e=>{let i=le.join(e,a.GLOBALS_CSS),t=le.join(e,a.PROVIDERS_INDEX),r=await he(e);if(!l(i)||!r||!l(t))throw new Error("Project structure mismatch. Ensure src/styles/globals.css, src/app/layout.tsx (or src/app/[locale]/layout.tsx), and src/providers/index.ts exist.");return r};T();A();import Nt from"node:path";import Co from"degit";var At=async(e,i)=>{i.text="Fetching assets from starter repo...",await Co("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!1}).clone(e)},Ot=async(e,i)=>{let t=Nt.join(e,a.THEME_PROVIDER),r=Nt.join(i,"src/providers/CustomThemeProvider.tsx");await F(r,t)};T();A();import ye from"node:path";var $t=async e=>{let i=ye.join(e,a.PROVIDERS_INDEX),t=await m(i);t.includes("CustomThemeProvider")||(t+=`export * from './CustomThemeProvider';
330
- `,await u(i,t))},_t=async e=>{let i=ye.join(e,"src/providers/RootProvider.tsx");if(l(i)){let t=await m(i),r="'use client';",s=t.includes(r);if(s&&(t=t.replace(r,"").trim()),t.includes("CustomThemeProvider")||(t=t.replace(/import \{ StoreProvider \} from '@\/providers';\n/,`import { StoreProvider, CustomThemeProvider } from '@/providers';
331
- `),t.includes("CustomThemeProvider")||(t.includes("from '@/providers'")?t=t.replace(/\} from '@\/providers'/,", CustomThemeProvider } from '@/providers'"):t=`import { CustomThemeProvider } from '@/providers';
332
- `+t)),s&&(t=r+`
333
- `+t),!t.includes("<CustomThemeProvider>")){if(t.includes("<StoreProvider>"))t=t.replace(/<StoreProvider>/,`<StoreProvider>
334
- <CustomThemeProvider>`),t=t.replace(/<\/StoreProvider>/,`</CustomThemeProvider>
335
- </StoreProvider>`);else{let o=t.match(/return\s*(?:\(\s*)?([\s\S]*?)(?:\s*\))?;/);if(o){let n=o[1];t=t.replace(o[0],`return (
328
+ `)),f(X.dim("Generated files:")),f(X.dim(` \u{1F4C4} ${y}
329
+ `)),f(X.cyan("Next steps:"));let x=c.replace(/^src\//,"@/");f(X.dim(` 1. Import service: import { ${n.serviceName}Service } from '${x}/${n.serviceName}.service'`)),f(X.dim(` 2. Use in component: const data = await ${n.serviceName}Service.getAll()`)),f("")}catch(r){v.fail("Service generation failed"),R(`${r}`),process.exit(1)}})};import we from"picocolors";import Do from"enquirer";T();import Co from"node:path";import To from"picocolors";T();N();import pe from"node:path";T();N();import Et from"node:path";var xe=async e=>{let t=[Et.join(e,a.ROOT_LAYOUT),Et.join(e,"src/app/[locale]/layout.tsx")];for(let i of t)if(l(i)&&(await d(i)).includes("<body"))return i;for(let i of t)if(l(i))return i;return""};var It=async e=>{let t=pe.join(e,a.THEME_PROVIDER),i=pe.join(e,a.GLOBALS_CSS),r=pe.join(e,"package.json");if(l(t))return{isSetup:!0,reason:"CustomThemeProvider.tsx exists"};if(l(r)){let s=JSON.parse(await d(r));if(s.dependencies&&s.dependencies["next-themes"]||s.devDependencies&&s.devDependencies["next-themes"])return{isSetup:!0,reason:"next-themes is installed"}}return l(i)&&(await d(i)).includes("@custom-variant dark")?{isSetup:!0,reason:"Dark theme CSS found in globals.css"}:{isSetup:!1,reason:""}},Rt=async e=>{let t=pe.join(e,a.GLOBALS_CSS),i=pe.join(e,a.PROVIDERS_INDEX),r=await xe(e);if(!l(t)||!r||!l(i))throw new Error("Project structure mismatch. Ensure src/styles/globals.css, src/app/layout.tsx (or src/app/[locale]/layout.tsx), and src/providers/index.ts exist.");return r};T();N();import Nt from"node:path";import wo from"degit";var At=async(e,t)=>{t.text="Fetching assets from starter repo...",await wo("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!1}).clone(e)},Ot=async(e,t)=>{let i=Nt.join(e,a.THEME_PROVIDER),r=Nt.join(t,"src/providers/CustomThemeProvider.tsx");await b(r,i)};T();N();import he from"node:path";var $t=async e=>{let t=he.join(e,a.PROVIDERS_INDEX),i=await d(t);i.includes("CustomThemeProvider")||(i+=`export * from './CustomThemeProvider';
330
+ `,await u(t,i))},_t=async e=>{let t=he.join(e,"src/providers/RootProvider.tsx");if(l(t)){let i=await d(t),r="'use client';",s=i.includes(r);if(s&&(i=i.replace(r,"").trim()),i.includes("CustomThemeProvider")||(i=i.replace(/import \{ StoreProvider \} from '@\/providers';\n/,`import { StoreProvider, CustomThemeProvider } from '@/providers';
331
+ `),i.includes("CustomThemeProvider")||(i.includes("from '@/providers'")?i=i.replace(/\} from '@\/providers'/,", CustomThemeProvider } from '@/providers'"):i=`import { CustomThemeProvider } from '@/providers';
332
+ `+i)),s&&(i=r+`
333
+ `+i),!i.includes("<CustomThemeProvider>")){if(i.includes("<StoreProvider>"))i=i.replace(/<StoreProvider>/,`<StoreProvider>
334
+ <CustomThemeProvider>`),i=i.replace(/<\/StoreProvider>/,`</CustomThemeProvider>
335
+ </StoreProvider>`);else{let o=i.match(/return\s*(?:\(\s*)?([\s\S]*?)(?:\s*\))?;/);if(o){let n=o[1];i=i.replace(o[0],`return (
336
336
  <CustomThemeProvider>
337
337
  ${n}
338
338
  </CustomThemeProvider>
339
- );`)}}await u(i,t)}}},bt=async(e,i)=>{let t=ye.join(e,a.GLOBALS_CSS),r=ye.join(i,"src/styles/globals.css"),s="";if(l(r)){let n=await m(r),c=n.match(/@custom-variant dark \(.*?\);/),p=n.match(/@theme \{[\s\S]*?\}/);c&&(s+=`
339
+ );`)}}await u(t,i)}}},bt=async(e,t)=>{let i=he.join(e,a.GLOBALS_CSS),r=he.join(t,"src/styles/globals.css"),s="";if(l(r)){let n=await d(r),c=n.match(/@custom-variant dark \(.*?\);/),p=n.match(/@theme \{[\s\S]*?\}/);c&&(s+=`
340
340
  ${c[0]}
341
341
  `),p&&(s+=`
342
342
  ${p[0]}
@@ -347,32 +347,32 @@ ${p[0]}
347
347
  --color-dark: #202938;
348
348
  --color-light: #f5f5f5;
349
349
  }
350
- `);let o=await m(t);if(!o.includes("@custom-variant dark")){if(o.includes("@import")){let n=o.lastIndexOf("@import"),c=o.indexOf(`
351
- `,n);o=o.slice(0,c+1)+s+o.slice(c+1)}else o=s+o;await u(t,o)}},Ft=async e=>{let i=await m(e);i.includes("dark:bg-dark")||(i=i.replace(/className="([^"]*)"/,'className="$1 bg-light dark:bg-dark"'),await u(e,i))};var Le=async e=>{let i=_("Setting up Dark Theme..."),t=To.join(e,".next-maker-temp");try{let{isSetup:r,reason:s}=await It(e);if(r){i.fail(`Dark Theme is already set up (${s}).`);return}let o=await Rt(e);await At(t,i),await Ot(e,t),await $t(e),await _t(e),await bt(e,t),await Ft(o),i.text="Installing next-themes...",await M(e,"next-themes"),i.text="Formatting code...";let n=await Y(e);await G(e,n,"format"),i.succeed(Eo.green("Dark Theme setup successfully!"))}catch(r){throw i.fail("Failed to setup Dark Theme."),r}finally{await P(t)}};T();import Ro from"node:path";import No from"picocolors";T();A();import Me from"node:path";var jt=async e=>{let i=Me.join(e,a.STORE),t=Me.join(e,"package.json");if(l(i))return{isSetup:!0,reason:"src/store directory exists"};if(l(t)){let r=JSON.parse(await m(t));if(r.dependencies&&r.dependencies["@reduxjs/toolkit"]||r.devDependencies&&r.devDependencies["@reduxjs/toolkit"])return{isSetup:!0,reason:"@reduxjs/toolkit is installed"}}return{isSetup:!1,reason:""}},kt=async e=>{let i=Me.join(e,a.PROVIDERS_INDEX);if(!await he(e)||!l(i))throw new Error("Project structure mismatch. Ensure src/app/layout.tsx (or src/app/[locale]/layout.tsx) and src/providers/index.ts exist.")};T();A();import te from"node:path";import Io from"degit";import Dt from"node:fs/promises";var Lt=async(e,i)=>{i.text="Fetching assets from starter repo...",await Io("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!1}).clone(e)},Mt=async(e,i)=>{let t=te.join(i,"src/providers/StoreProvider.tsx"),r=te.join(e,a.STORE_PROVIDER);await F(t,r);let s=te.join(i,"src/store"),o=te.join(e,a.STORE);await Dt.cp(s,o,{recursive:!0})},Ht=async(e,i)=>{let t=te.join(i,"src/features/counter"),r=te.join(e,a.COUNTER_FEATURE);await Dt.cp(t,r,{recursive:!0});let s=te.join(r,"components/Counter.tsx");if(await l(s)){let o=await m(s);o=o.replace(/import \{ useTranslations \} from 'next-intl';\n?/,""),o=o.replace(/const t = useTranslations\('Count'\);\n?/,""),o=o.replace(/\{t\('currentCount', \{ count: value \}\)\}/g,"Current Count: {value}"),o=o.replace(/\{t\('increment'\)\}/g,"Increment"),o=o.replace(/\{t\('decrement'\)\}/g,"Decrement"),o=o.replace(/\{t\('reset'\)\}/g,"Reset"),await u(s,o)}};T();A();import Se from"node:path";var Gt=async e=>{let i=Se.join(e,a.PROVIDERS_INDEX),t=await m(i);t.includes("StoreProvider")||(t+=`export * from './StoreProvider';
352
- `,await u(i,t))},Ut=async e=>{let i=Se.join(e,"src/providers/RootProvider.tsx");if(l(i)){let t=await m(i),r="'use client';",s=t.includes(r);if(s&&(t=t.replace(r,"").trim()),t.includes("StoreProvider")||(t=t.replace(/import \{ (.*?) \} from '@\/providers';/,"import { $1, StoreProvider } from '@/providers';"),t.includes("StoreProvider")||(t.includes("from '@/providers'")?t=t.replace(/\} from '@\/providers'/,", StoreProvider } from '@/providers'"):t=`import { StoreProvider } from '@/providers';
353
- `+t)),s&&(t=r+`
354
- `+t),!t.includes("<StoreProvider>")){let o=t.match(/return\s*(?:\(\s*)?([\s\S]*?)(?:\s*\))?;/);if(o){let n=o[1];t=t.replace(o[0],`return (
350
+ `);let o=await d(i);if(!o.includes("@custom-variant dark")){if(o.includes("@import")){let n=o.lastIndexOf("@import"),c=o.indexOf(`
351
+ `,n);o=o.slice(0,c+1)+s+o.slice(c+1)}else o=s+o;await u(i,o)}},Ft=async e=>{let t=await d(e);t.includes("dark:bg-dark")||(t=t.replace(/className="([^"]*)"/,'className="$1 bg-light dark:bg-dark"'),await u(e,t))};var Le=async e=>{let t=$("Setting up Dark Theme..."),i=Co.join(e,".next-maker-temp");try{let{isSetup:r,reason:s}=await It(e);if(r){t.fail(`Dark Theme is already set up (${s}).`);return}let o=await Rt(e);await At(i,t),await Ot(e,i),await $t(e),await _t(e),await bt(e,i),await Ft(o),t.text="Installing next-themes...",await M(e,"next-themes"),t.text="Formatting code...";let n=await G(e);await H(e,n,"format"),t.succeed(To.green("Dark Theme setup successfully!"))}catch(r){throw t.fail("Failed to setup Dark Theme."),r}finally{await S(i)}};T();import Io from"node:path";import Ro from"picocolors";T();N();import Me from"node:path";var jt=async e=>{let t=Me.join(e,a.STORE),i=Me.join(e,"package.json");if(l(t))return{isSetup:!0,reason:"src/store directory exists"};if(l(i)){let r=JSON.parse(await d(i));if(r.dependencies&&r.dependencies["@reduxjs/toolkit"]||r.devDependencies&&r.devDependencies["@reduxjs/toolkit"])return{isSetup:!0,reason:"@reduxjs/toolkit is installed"}}return{isSetup:!1,reason:""}},kt=async e=>{let t=Me.join(e,a.PROVIDERS_INDEX);if(!await xe(e)||!l(t))throw new Error("Project structure mismatch. Ensure src/app/layout.tsx (or src/app/[locale]/layout.tsx) and src/providers/index.ts exist.")};T();N();import te from"node:path";import Eo from"degit";import Dt from"node:fs/promises";var Lt=async(e,t)=>{t.text="Fetching assets from starter repo...",await Eo("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!1}).clone(e)},Mt=async(e,t)=>{let i=te.join(t,"src/providers/StoreProvider.tsx"),r=te.join(e,a.STORE_PROVIDER);await b(i,r);let s=te.join(t,"src/store"),o=te.join(e,a.STORE);await Dt.cp(s,o,{recursive:!0})},Ht=async(e,t)=>{let i=te.join(t,"src/features/counter"),r=te.join(e,a.COUNTER_FEATURE);await Dt.cp(i,r,{recursive:!0});let s=te.join(r,"components/Counter.tsx");if(await l(s)){let o=await d(s);o=o.replace(/import \{ useTranslations \} from 'next-intl';\n?/,""),o=o.replace(/const t = useTranslations\('Count'\);\n?/,""),o=o.replace(/\{t\('currentCount', \{ count: value \}\)\}/g,"Current Count: {value}"),o=o.replace(/\{t\('increment'\)\}/g,"Increment"),o=o.replace(/\{t\('decrement'\)\}/g,"Decrement"),o=o.replace(/\{t\('reset'\)\}/g,"Reset"),await u(s,o)}};T();N();import ye from"node:path";var Gt=async e=>{let t=ye.join(e,a.PROVIDERS_INDEX),i=await d(t);i.includes("StoreProvider")||(i+=`export * from './StoreProvider';
352
+ `,await u(t,i))},Ut=async e=>{let t=ye.join(e,"src/providers/RootProvider.tsx");if(l(t)){let i=await d(t),r="'use client';",s=i.includes(r);if(s&&(i=i.replace(r,"").trim()),i.includes("StoreProvider")||(i=i.replace(/import \{ (.*?) \} from '@\/providers';/,"import { $1, StoreProvider } from '@/providers';"),i.includes("StoreProvider")||(i.includes("from '@/providers'")?i=i.replace(/\} from '@\/providers'/,", StoreProvider } from '@/providers'"):i=`import { StoreProvider } from '@/providers';
353
+ `+i)),s&&(i=r+`
354
+ `+i),!i.includes("<StoreProvider>")){let o=i.match(/return\s*(?:\(\s*)?([\s\S]*?)(?:\s*\))?;/);if(o){let n=o[1];i=i.replace(o[0],`return (
355
355
  <StoreProvider>
356
356
  ${n}
357
357
  </StoreProvider>
358
- );`),await u(i,t)}}}},Yt=async e=>{let i=[Se.join(e,a.ROOT_PAGE),Se.join(e,"src/app/[locale]/page.tsx")],t="";for(let r of i)if(l(r)){t=r;break}if(t){let r=await m(t);if(r.includes("Counter")||(r=`import { Counter } from '@/features/counter/components/Counter';
358
+ );`),await u(t,i)}}}},Yt=async e=>{let t=[ye.join(e,a.ROOT_PAGE),ye.join(e,"src/app/[locale]/page.tsx")],i="";for(let r of t)if(l(r)){i=r;break}if(i){let r=await d(i);if(r.includes("Counter")||(r=`import { Counter } from '@/features/counter/components/Counter';
359
359
  `+r),!r.includes("<Counter />")){let s=r.lastIndexOf("</div>"),o=r.lastIndexOf("</main>"),n=o!==-1?o:s;n!==-1&&(r=r.slice(0,n)+`
360
360
  <div className="mt-8">
361
361
  <h2 className="text-2xl font-bold mb-4">Redux Counter</h2>
362
362
  <Counter />
363
363
  </div>
364
- `+r.slice(n),await u(t,r))}}};var He=async e=>{let i=_("Setting up Redux Toolkit..."),t=Ro.join(e,".next-maker-temp-redux");try{let{isSetup:r,reason:s}=await jt(e);if(r){i.fail(`Redux is already set up (${s}).`);return}await kt(e),await Lt(t,i),i.text="Copying Redux files...",await Mt(e,t),i.text="Creating Counter feature...",await Ht(e,t),i.text="Updating providers and pages...",await Gt(e),await Ut(e),await Yt(e),i.text="Installing dependencies...",await M(e,"@reduxjs/toolkit"),await M(e,"react-redux"),await M(e,"redux-persist"),await M(e,"react-secure-storage"),i.text="Formatting code...";let o=await Y(e);await G(e,o,"format"),i.succeed(No.green("Redux Toolkit setup successfully!"))}catch(r){throw i.fail("Failed to setup Redux Toolkit."),r}finally{await P(t)}};T();import _o from"node:path";import bo from"picocolors";T();A();import Pe from"node:path";var Xt=async e=>{let i=Pe.join(e,a.I18N_DIR),t=Pe.join(e,"package.json");if(l(i))return{isSetup:!0,reason:"src/i18n directory exists"};if(l(t)){let r=JSON.parse(await m(t));if(r.dependencies&&r.dependencies["next-intl"]||r.devDependencies&&r.devDependencies["next-intl"])return{isSetup:!0,reason:"next-intl is installed"}}return{isSetup:!1,reason:""}},Jt=async e=>{let i=Pe.join(e,a.ROOT_LAYOUT),t=Pe.join(e,"src/app/[locale]/layout.tsx");if(!l(i)&&!l(t))throw new Error("Project structure mismatch. Ensure src/app/layout.tsx exists.")};T();A();import q from"node:path";import Ao from"degit";import Oo from"node:fs/promises";var Wt=async(e,i)=>{i.text="Fetching assets from starter repo...",await Ao("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!1}).clone(e)},zt=async(e,i)=>{let t=q.join(i,"src/i18n"),r=q.join(e,a.I18N_DIR);await Oo.cp(t,r,{recursive:!0});let s=q.join(i,"src/proxy.ts"),o=q.join(e,a.PROXY);await F(s,o);let n=q.join(i,"src/types/i18n.ts"),c=q.join(e,a.I18N_TYPES);await F(n,c);let p=q.join(i,"src/lib/config/app-locales.ts"),d=q.join(e,a.APP_LOCALES);await F(p,d)};T();A();import z from"node:path";import $o from"node:fs/promises";var Vt=async e=>{let i=z.join(e,a.NEXT_CONFIG);if(l(i)){let t=await m(i);if(!t.includes("createNextIntlPlugin")){t=`import createNextIntlPlugin from 'next-intl/plugin';
365
- `+t;let r=/export default (.*?);/;r.test(t)?t=t.replace(r,`
364
+ `+r.slice(n),await u(i,r))}}};var He=async e=>{let t=$("Setting up Redux Toolkit..."),i=Io.join(e,".next-maker-temp-redux");try{let{isSetup:r,reason:s}=await jt(e);if(r){t.fail(`Redux is already set up (${s}).`);return}await kt(e),await Lt(i,t),t.text="Copying Redux files...",await Mt(e,i),t.text="Creating Counter feature...",await Ht(e,i),t.text="Updating providers and pages...",await Gt(e),await Ut(e),await Yt(e),t.text="Installing dependencies...",await M(e,"@reduxjs/toolkit"),await M(e,"react-redux"),await M(e,"redux-persist"),await M(e,"react-secure-storage"),t.text="Formatting code...";let o=await G(e);await H(e,o,"format"),t.succeed(Ro.green("Redux Toolkit setup successfully!"))}catch(r){throw t.fail("Failed to setup Redux Toolkit."),r}finally{await S(i)}};T();import $o from"node:path";import _o from"picocolors";T();N();import Se from"node:path";var Xt=async e=>{let t=Se.join(e,a.I18N_DIR),i=Se.join(e,"package.json");if(l(t))return{isSetup:!0,reason:"src/i18n directory exists"};if(l(i)){let r=JSON.parse(await d(i));if(r.dependencies&&r.dependencies["next-intl"]||r.devDependencies&&r.devDependencies["next-intl"])return{isSetup:!0,reason:"next-intl is installed"}}return{isSetup:!1,reason:""}},Jt=async e=>{let t=Se.join(e,a.ROOT_LAYOUT),i=Se.join(e,"src/app/[locale]/layout.tsx");if(!l(t)&&!l(i))throw new Error("Project structure mismatch. Ensure src/app/layout.tsx exists.")};T();N();import B from"node:path";import No from"degit";import Ao from"node:fs/promises";var Wt=async(e,t)=>{t.text="Fetching assets from starter repo...",await No("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!1}).clone(e)},zt=async(e,t)=>{let i=B.join(t,"src/i18n"),r=B.join(e,a.I18N_DIR);await Ao.cp(i,r,{recursive:!0});let s=B.join(t,"src/proxy.ts"),o=B.join(e,a.PROXY);await b(s,o);let n=B.join(t,"src/types/i18n.ts"),c=B.join(e,a.I18N_TYPES);await b(n,c);let p=B.join(t,"src/lib/config/app-locales.ts"),m=B.join(e,a.APP_LOCALES);await b(p,m)};T();N();import J from"node:path";import Oo from"node:fs/promises";var Vt=async e=>{let t=J.join(e,a.NEXT_CONFIG);if(l(t)){let i=await d(t);if(!i.includes("createNextIntlPlugin")){i=`import createNextIntlPlugin from 'next-intl/plugin';
365
+ `+i;let r=/export default (.*?);/;r.test(i)?i=i.replace(r,`
366
366
  const withNextIntl = createNextIntlPlugin();
367
- export default withNextIntl($1);`):(t+=`
367
+ export default withNextIntl($1);`):(i+=`
368
368
  const withNextIntl = createNextIntlPlugin();
369
- `,t+=`export default withNextIntl(nextConfig);
370
- `),await u(i,t)}}},Kt=async e=>{let i=z.join(e,a.TYPES_INDEX);if(l(i)){let t=await m(i);t.includes("./i18n")||(t+=`export * from './i18n';
371
- `,await u(i,t))}},Bt=async e=>{let i=z.join(e,a.CONFIG_INDEX);if(l(i)){let t=await m(i);t.includes("./app-locales")||(t+=`export * from './app-locales';
372
- `,await u(i,t))}},qt=async e=>{let i=z.join(e,"src/providers/RootProvider.tsx");if(l(i)){let t=await m(i),r="'use client';",s=t.includes(r);if(s&&(t=t.replace(r,"").trim()),t.includes("next-intl")||(t=`import { SupportedLocale } from '@/types/i18n';
369
+ `,i+=`export default withNextIntl(nextConfig);
370
+ `),await u(t,i)}}},Kt=async e=>{let t=J.join(e,a.TYPES_INDEX);if(l(t)){let i=await d(t);i.includes("./i18n")||(i+=`export * from './i18n';
371
+ `,await u(t,i))}},Bt=async e=>{let t=J.join(e,a.CONFIG_INDEX);if(l(t)){let i=await d(t);i.includes("./app-locales")||(i+=`export * from './app-locales';
372
+ `,await u(t,i))}},qt=async e=>{let t=J.join(e,"src/providers/RootProvider.tsx");if(l(t)){let i=await d(t),r="'use client';",s=i.includes(r);if(s&&(i=i.replace(r,"").trim()),i.includes("next-intl")||(i=`import { SupportedLocale } from '@/types/i18n';
373
373
  import { NextIntlClientProvider, AbstractIntlMessages } from 'next-intl';
374
- `+t),s&&(t=r+`
375
- `+t),!t.includes("locale: SupportedLocale")){let o=/export const RootProvider = \(\{([\s\S]*?)\}: \{([\s\S]*?)\}\) => \{/,n=t.match(o);n&&(t=t.replace(n[0],`export const RootProvider = ({
374
+ `+i),s&&(i=r+`
375
+ `+i),!i.includes("locale: SupportedLocale")){let o=/export const RootProvider = \(\{([\s\S]*?)\}: \{([\s\S]*?)\}\) => \{/,n=i.match(o);n&&(i=i.replace(n[0],`export const RootProvider = ({
376
376
  children,
377
377
  locale,
378
378
  messages,
@@ -380,26 +380,26 @@ import { NextIntlClientProvider, AbstractIntlMessages } from 'next-intl';
380
380
  children: React.ReactNode;
381
381
  locale: SupportedLocale;
382
382
  messages: AbstractIntlMessages;
383
- }) => {`))}if(!t.includes("<NextIntlClientProvider")){let o=t.match(/return\s*(?:\(\s*)?([\s\S]*?)(?:\s*\))?;/);if(o){let n=o[1];if(n.includes("{children}")){let c=n.replace("{children}",`<NextIntlClientProvider locale={locale} messages={messages}>
383
+ }) => {`))}if(!i.includes("<NextIntlClientProvider")){let o=i.match(/return\s*(?:\(\s*)?([\s\S]*?)(?:\s*\))?;/);if(o){let n=o[1];if(n.includes("{children}")){let c=n.replace("{children}",`<NextIntlClientProvider locale={locale} messages={messages}>
384
384
  {children}
385
- </NextIntlClientProvider>`);t=t.replace(o[0],`return (
385
+ </NextIntlClientProvider>`);i=i.replace(o[0],`return (
386
386
  ${c}
387
- );`)}else t=t.replace(o[0],`return (
387
+ );`)}else i=i.replace(o[0],`return (
388
388
  <NextIntlClientProvider locale={locale} messages={messages}>
389
389
  ${n}
390
390
  </NextIntlClientProvider>
391
- );`)}}await u(i,t)}},Zt=async e=>{let i=z.join(e,a.ROOT_LAYOUT),t=z.join(e,a.ROOT_PAGE),r=z.join(e,"src/app/[locale]");if(await $o.mkdir(r,{recursive:!0}),l(i)){let s=z.join(r,"layout.tsx"),o=await m(i);if(o.includes("next-intl")||(o=`import { routing } from '@/i18n/routing';
391
+ );`)}}await u(t,i)}},Zt=async e=>{let t=J.join(e,a.ROOT_LAYOUT),i=J.join(e,a.ROOT_PAGE),r=J.join(e,"src/app/[locale]");if(await Oo.mkdir(r,{recursive:!0}),l(t)){let s=J.join(r,"layout.tsx"),o=await d(t);if(o.includes("next-intl")||(o=`import { routing } from '@/i18n/routing';
392
392
  import { hasLocale } from 'next-intl';
393
393
  import { notFound } from 'next/navigation';
394
394
  import { setRequestLocale, getMessages } from 'next-intl/server';
395
- `+o),!o.includes("generateStaticParams")){let p=o.indexOf("};",o.indexOf("export const metadata"));if(p!==-1){let d=p+2;o=o.slice(0,d)+`
395
+ `+o),!o.includes("generateStaticParams")){let p=o.indexOf("};",o.indexOf("export const metadata"));if(p!==-1){let m=p+2;o=o.slice(0,m)+`
396
396
 
397
397
  export function generateStaticParams() {
398
398
  return routing.locales.map((locale) => ({ locale }));
399
- }`+o.slice(d)}}o=o.replace(/Readonly<\{\s*children:\s*React\.ReactNode;\s*}>/,`Readonly<{
399
+ }`+o.slice(m)}}o=o.replace(/Readonly<\{\s*children:\s*React\.ReactNode;\s*}>/,`Readonly<{
400
400
  children: React.ReactNode;
401
401
  params: Promise<{ locale: string }>;
402
- }>`);let n=/export default (async )?function RootLayout\(\{\s*children,?\s*\}\s*:/,c=o.match(n);if(c){c[1]||(o=o.replace("export default function","export default async function")),o=o.replace(/export default (async )?function RootLayout\(\{\s*children,?\s*\}\s*:/,"export default async function RootLayout({ children, params }:");let d=/export default async function RootLayout[\s\S]*?\)\s*\{/,h=o.match(d);if(h&&h.index!==void 0){let y=h.index+h[0].length-1;o=o.slice(0,y+1)+`
402
+ }>`);let n=/export default (async )?function RootLayout\(\{\s*children,?\s*\}\s*:/,c=o.match(n);if(c){c[1]||(o=o.replace("export default function","export default async function")),o=o.replace(/export default (async )?function RootLayout\(\{\s*children,?\s*\}\s*:/,"export default async function RootLayout({ children, params }:");let m=/export default async function RootLayout[\s\S]*?\)\s*\{/,h=o.match(m);if(h&&h.index!==void 0){let y=h.index+h[0].length-1;o=o.slice(0,y+1)+`
403
403
  const { locale } = await params;
404
404
 
405
405
  if (!hasLocale(routing.locales, locale)) {
@@ -409,7 +409,7 @@ export function generateStaticParams() {
409
409
  setRequestLocale(locale);
410
410
 
411
411
  const messages = await getMessages();
412
- `+o.slice(y+1)}o=o.replace(/<RootProvider>/,"<RootProvider locale={locale} messages={messages}>"),o=o.replace(/<html lang="en"/,"<html lang={locale}")}await u(s,o),await C(i)}if(l(t)){let s=z.join(r,"page.tsx"),o=await m(t);o.includes("next-intl")||(o=`import { SupportedLocale } from '@/types/i18n';
412
+ `+o.slice(y+1)}o=o.replace(/<RootProvider>/,"<RootProvider locale={locale} messages={messages}>"),o=o.replace(/<html lang="en"/,"<html lang={locale}")}await u(s,o),await C(t)}if(l(i)){let s=J.join(r,"page.tsx"),o=await d(i);o.includes("next-intl")||(o=`import { SupportedLocale } from '@/types/i18n';
413
413
  import { setRequestLocale } from 'next-intl/server';
414
414
  `+o),o=o.replace(/export default function Home\(\)/,`type Props = {
415
415
  params: Promise<{ locale: string }>;
@@ -418,14 +418,17 @@ import { setRequestLocale } from 'next-intl/server';
418
418
  export default async function Home(props: Props)`);let n=o.indexOf("export default async function Home(props: Props) {");if(n!==-1){let c=`
419
419
  const locale = (await props.params).locale as SupportedLocale;
420
420
  setRequestLocale(locale);
421
- `,p=o.indexOf("{",n);o=o.slice(0,p+1)+c+o.slice(p+1)}await u(s,o),await C(t)}};var Ge=async e=>{let i=_("Setting up Internationalization (next-intl)..."),t=_o.join(e,".next-maker-temp-i18n");try{let{isSetup:r,reason:s}=await Xt(e);if(r){i.fail(`i18n is already set up (${s}).`);return}await Jt(e),await Wt(t,i),i.text="Copying i18n files...",await zt(e,t),i.text="Configuring project structure...",await Vt(e),await Kt(e),await Bt(e),await qt(e),i.text="Migrating to [locale] structure...",await Zt(e),i.text="Installing dependencies...",await M(e,"next-intl"),i.text="Formatting code...";let o=await Y(e);await G(e,o,"format"),i.succeed(bo.green("Internationalization setup successfully!"))}catch(r){throw i.fail("Failed to setup Internationalization."),r}finally{await P(t)}};T();import me from"node:path";import ri from"node:fs/promises";import Ue from"picocolors";import ve from"enquirer";T();A();import pe from"node:path";var Qt=async e=>{let i=pe.join(e,a.FETCH_CLIENT_FILE),t=pe.join(e,a.AXIOS_CLIENT_FILE),r=l(i),s=l(t);return r&&s?{status:"both",reason:"Both Fetch and Axios clients are detected"}:r?{status:"fetch",reason:"Fetch client is already setup"}:s?{status:"axios",reason:"Axios client is already setup"}:{status:"none"}},ei=async e=>{let t=[pe.join(e,"src/lib"),pe.join(e,"src/types"),pe.join(e,"src/lib/config")].filter(r=>!l(r));if(t.length>0)throw new Error(`Invalid project structure. Missing directories:
422
- ${t.map(r=>`- ${r}`).join(`
423
- `)}`)};T();A();import S from"node:path";import Fo from"degit";import H from"node:fs/promises";var ti=async(e,i)=>{i.text="Downloading assets from starter repository...",await Fo("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!1}).clone(e)},ii=async(e,i,t,r)=>{let s=S.join(e,a.HTTP_UTILS),o=S.join(i,a.HTTP_UTILS);await H.cp(S.join(i,a.ERRORS_DIR),S.join(e,a.ERRORS_DIR),{recursive:!0});let n=S.join(e,a.APP_APIS);l(n)||await F(S.join(i,a.APP_APIS),n);let c=S.join(e,a.CONSTANTS);if(!l(c))await F(S.join(i,a.CONSTANTS),c);else{let d=await m(c),h=!1;d.includes("API_RESPONSE_DATA_KEY")||(d+=`
421
+ `,p=o.indexOf("{",n);o=o.slice(0,p+1)+c+o.slice(p+1)}await u(s,o),await C(i)}};var Ge=async e=>{let t=$("Setting up Internationalization (next-intl)..."),i=$o.join(e,".next-maker-temp-i18n");try{let{isSetup:r,reason:s}=await Xt(e);if(r){t.fail(`i18n is already set up (${s}).`);return}await Jt(e),await Wt(i,t),t.text="Copying i18n files...",await zt(e,i),t.text="Configuring project structure...",await Vt(e),await Kt(e),await Bt(e),await qt(e),t.text="Migrating to [locale] structure...",await Zt(e),t.text="Installing dependencies...",await M(e,"next-intl"),t.text="Formatting code...";let o=await G(e);await H(e,o,"format"),t.succeed(_o.green("Internationalization setup successfully!"))}catch(r){throw t.fail("Failed to setup Internationalization."),r}finally{await S(i)}};T();import Pe from"node:path";import Fo from"node:fs/promises";import Ue from"picocolors";import ve from"enquirer";T();N();import me from"node:path";var Qt=async e=>{let t=me.join(e,a.FETCH_CLIENT_FILE),i=me.join(e,a.AXIOS_CLIENT_FILE),r=l(t),s=l(i);return r&&s?{status:"both",reason:"Both Fetch and Axios clients are detected"}:r?{status:"fetch",reason:"Fetch client is already setup"}:s?{status:"axios",reason:"Axios client is already setup"}:{status:"none"}},ei=async e=>{let i=[me.join(e,"src/lib"),me.join(e,"src/types"),me.join(e,"src/lib/config")].filter(r=>!l(r));if(i.length>0)throw new Error(`Invalid project structure. Missing directories:
422
+ ${i.map(r=>`- ${r}`).join(`
423
+ `)}`)};T();N();import P from"node:path";import bo from"degit";import W from"node:fs/promises";var ti=async(e,t)=>{t.text="Downloading assets from starter repository...",await bo("teispace/nextjs-starter",{cache:!1,force:!0,verbose:!1}).clone(e)},ii=async(e,t,i,r)=>{let s=P.join(e,a.HTTP_UTILS),o=P.join(t,a.HTTP_UTILS);await W.cp(P.join(t,a.ERRORS_DIR),P.join(e,a.ERRORS_DIR),{recursive:!0});let n=P.join(e,a.APP_APIS);l(n)||await b(P.join(t,a.APP_APIS),n);let c=P.join(e,a.CONSTANTS);if(!l(c))await b(P.join(t,a.CONSTANTS),c);else{let m=await d(c),h=!1;m.includes("API_RESPONSE_DATA_KEY")||(m+=`
424
424
  export const API_RESPONSE_DATA_KEY = 'data';
425
- `,h=!0),d.includes("SAVE_AUTH_TOKENS")||(d+=`
425
+ `,h=!0),m.includes("SAVE_AUTH_TOKENS")||(m+=`
426
426
  export const SAVE_AUTH_TOKENS = false;
427
- `,h=!0),h&&await u(c,d)}let p=S.join(e,a.STORAGE_SERVICE);if(l(p)||await H.cp(S.join(i,a.STORAGE_SERVICE),p,{recursive:!0}),await H.cp(S.join(i,a.COMMON_TYPES_DIR),S.join(e,a.COMMON_TYPES_DIR),{recursive:!0}),await H.cp(S.join(i,a.UTILITY_TYPES_DIR),S.join(e,a.UTILITY_TYPES_DIR),{recursive:!0}),await F(S.join(o,"token-store.ts"),S.join(s,"token-store.ts")),await F(S.join(o,"client-utils.ts"),S.join(s,"client-utils.ts")),r&&r.length>0)for(let d of r){let h=S.join(e,d==="fetch"?a.FETCH_CLIENT:a.AXIOS_CLIENT);await P(h)}for(let d of t)d==="fetch"?await H.cp(S.join(i,a.FETCH_CLIENT),S.join(e,a.FETCH_CLIENT),{recursive:!0}):await H.cp(S.join(i,a.AXIOS_CLIENT),S.join(e,a.AXIOS_CLIENT),{recursive:!0});await F(S.join(o,"index.ts"),S.join(s,"index.ts")),await F(S.join(i,a.HTTP_TYPES),S.join(e,a.HTTP_TYPES))},oi=async e=>{let{isFileUsed:i,isStringUsed:t}=await Promise.resolve().then(()=>(ge(),et));await P(S.join(e,a.HTTP_UTILS));let r=S.join(e,a.STORAGE_SERVICE);l(r)&&(await t(e,"SecureStorageService",[r])||await P(r));let s=async(g,v,R,E)=>{if(!l(g))return;if(!await v()&&(await H.unlink(g),l(R))){let U=await m(R);U=U.replace(E,""),await u(R,U)}},o=S.join(e,a.APP_APIS),n=S.join(e,a.CONFIG_INDEX);await s(o,()=>t(e,"AppApis",[o,n]),n,/export \* from '\.\/app-apis';\n?/g);let c=S.join(e,a.CONSTANTS);l(c)&&(await t(e,"API_RESPONSE_DATA_KEY",[c])||await t(e,"SAVE_AUTH_TOKENS",[c])||await H.unlink(c));let p=S.join(e,a.ERRORS_DIR);if(l(p)){let g=await H.readdir(p),v=!1;for(let R of g){let E=S.parse(R).name;if(await i(e,E,[S.join(p,R)])){v=!0;break}}v||await P(p)}let d=S.join(e,a.HTTP_TYPES);l(d)&&await H.unlink(d);let h=S.join(e,a.COMMON_TYPES_DIR);l(h)&&(await H.readdir(h)).length===0&&await P(h);let y=S.join(e,a.UTILITY_TYPES_DIR);l(y)&&(await H.readdir(y)).length===0&&await P(y)};ge();var Ye=async e=>{let i=_("Checking HTTP Client setup..."),t=me.join(e,".next-maker-temp-http");try{let{status:r,reason:s}=await Qt(e);i.stop();let o=await jo(r,s);if(o.type==="cancel"){console.log(Ue.yellow("Setup cancelled."));return}if(i.start("Setting up HTTP client(s)..."),await ei(e),await ti(t,i),o.type==="replace"&&o.fromClient&&(i.text="Migrating client usages...",await $e(e,o.fromClient,o.clients[0])),o.type!=="remove-both"&&o.type!=="remove-one"){i.text="Copying client files...";let h=o.type==="replace"&&o.fromClient?[o.fromClient]:void 0;await ii(e,t,o.clients,h)}if(o.type==="remove-one"||o.type==="remove-both"){i.text="Removing client files...";let{PROJECT_PATHS:h}=await Promise.resolve().then(()=>(A(),Ze));for(let g of o.clients){let v=me.join(e,g==="fetch"?h.FETCH_CLIENT:h.AXIOS_CLIENT);await P(v)}if(ni(r,o).length===0){i.text="Performing full cleanup...",await oi(e),await _e(e),i.text="Uninstalling dependencies...";let g=me.join(e,"package.json"),v=JSON.parse(await ri.readFile(g,"utf-8"));(v.dependencies?.axios||v.devDependencies?.axios)&&await Ee(e,"axios"),(v.dependencies?.["react-secure-storage"]||v.devDependencies?.["react-secure-storage"])&&!l(me.join(e,h.STORAGE_SERVICE))&&await Ee(e,"react-secure-storage")}}if(o.type!=="remove-both"){i.text="Configuring client...";let h=ni(r,o);await Re(e,h),await Ne(e),await Ae(e),await Oe(e),await ie(e,h)}o.clients.includes("axios")&&(o.type==="install"||o.type==="add")&&(i.text="Installing Axios...",await M(e,"axios"));let n=me.join(e,"package.json"),c=JSON.parse(await ri.readFile(n,"utf-8"));!(c.dependencies?.["react-secure-storage"]||c.devDependencies?.["react-secure-storage"])&&o.type!=="remove-both"&&(i.text="Installing react-secure-storage (for token storage)...",await M(e,"react-secure-storage")),i.text="Formatting code...";let d=await Y(e);await G(e,d,"format"),i.succeed(Ue.green(ko(o)))}catch(r){throw i.fail("Failed to setup HTTP Client."),r}finally{await P(t)}};async function jo(e,i){if(e==="none"){let{choice:r}=await ve.prompt({type:"select",name:"choice",message:"Which HTTP client(s) do you want to setup?",choices:[{name:"fetch",message:"Fetch (Native)"},{name:"axios",message:"Axios"},{name:"both",message:"Both (Fetch + Axios)"}]});return r==="both"?{type:"install",clients:["fetch","axios"]}:{type:"install",clients:[r]}}if(e==="fetch"){let{action:r}=await ve.prompt({type:"select",name:"action",message:`${i}. What would you like to do?`,choices:[{name:"cancel",message:"Keep Fetch only (cancel)"},{name:"add",message:"Add Axios (have both)"},{name:"replace",message:"Replace with Axios only"},{name:"remove",message:"Remove Fetch"}]});if(r==="cancel")return{type:"cancel",clients:[]};if(r==="add")return{type:"add",clients:["axios"]};if(r==="replace")return{type:"replace",clients:["axios"],fromClient:"fetch"};if(r==="remove")return{type:"remove-one",clients:["fetch"]}}if(e==="axios"){let{action:r}=await ve.prompt({type:"select",name:"action",message:`${i}. What would you like to do?`,choices:[{name:"cancel",message:"Keep Axios only (cancel)"},{name:"add",message:"Add Fetch (have both)"},{name:"replace",message:"Replace with Fetch only"},{name:"remove",message:"Remove Axios"}]});if(r==="cancel")return{type:"cancel",clients:[]};if(r==="add")return{type:"add",clients:["fetch"]};if(r==="replace")return{type:"replace",clients:["fetch"],fromClient:"axios"};if(r==="remove")return{type:"remove-one",clients:["axios"]}}console.log(Ue.yellow(`\u2716 ${i}`));let{action:t}=await ve.prompt({type:"select",name:"action",message:"What would you like to do?",choices:[{name:"cancel",message:"Keep both (cancel)"},{name:"remove-fetch",message:"Remove Fetch (keep Axios)"},{name:"remove-axios",message:"Remove Axios (keep Fetch)"},{name:"remove-both",message:"Remove both"}]});return t==="cancel"?{type:"cancel",clients:[]}:t==="remove-fetch"?{type:"remove-one",clients:["fetch"]}:t==="remove-axios"?{type:"remove-one",clients:["axios"]}:t==="remove-both"?{type:"remove-both",clients:["fetch","axios"]}:{type:"cancel",clients:[]}}function ni(e,i){return i.type==="install"?i.clients:i.type==="add"?[...e==="fetch"?["fetch"]:["axios"],...i.clients]:i.type==="replace"?i.clients:i.type==="remove-one"?e==="both"?i.clients[0]==="fetch"?["axios"]:["fetch"]:[]:[]}function ko(e){if(e.type==="install")return`HTTP Client (${e.clients.map(t=>t==="fetch"?"Fetch":"Axios").join(" + ")}) setup successfully!`;if(e.type==="add")return`${e.clients[0]==="fetch"?"Fetch":"Axios"} client added successfully! Both clients are now available.`;if(e.type==="replace"){let i=e.fromClient==="fetch"?"Fetch":"Axios",t=e.clients[0]==="fetch"?"Fetch":"Axios";return`Replaced ${i} with ${t} successfully! Imports automatically migrated.`}return e.type==="remove-one"?`${e.clients[0]==="fetch"?"Fetch":"Axios"} client removed successfully!`:e.type==="remove-both"?"Both HTTP clients removed successfully!":"HTTP Client setup completed!"}var{prompt:Lo}=Do,si=e=>{e.command("setup").description("Setup features in an existing Next.js project").option("--http-client","Setup HTTP client (axios|fetch)").option("--dark-theme","Setup Dark Theme (Tailwind + next-themes)").option("--redux","Setup Redux Toolkit").option("--i18n","Setup next-intl for internationalization").action(async i=>{try{if(f(we.cyan(`
427
+ `,h=!0),h&&await u(c,m)}let p=P.join(e,a.STORAGE_SERVICE);if(l(p)||await W.cp(P.join(t,a.STORAGE_SERVICE),p,{recursive:!0}),await W.cp(P.join(t,a.COMMON_TYPES_DIR),P.join(e,a.COMMON_TYPES_DIR),{recursive:!0}),await W.cp(P.join(t,a.UTILITY_TYPES_DIR),P.join(e,a.UTILITY_TYPES_DIR),{recursive:!0}),await b(P.join(o,"token-store.ts"),P.join(s,"token-store.ts")),await b(P.join(o,"client-utils.ts"),P.join(s,"client-utils.ts")),r&&r.length>0)for(let m of r){let h=P.join(e,m==="fetch"?a.FETCH_CLIENT:a.AXIOS_CLIENT);await S(h)}for(let m of i)m==="fetch"?await W.cp(P.join(t,a.FETCH_CLIENT),P.join(e,a.FETCH_CLIENT),{recursive:!0}):await W.cp(P.join(t,a.AXIOS_CLIENT),P.join(e,a.AXIOS_CLIENT),{recursive:!0});await b(P.join(o,"index.ts"),P.join(s,"index.ts")),await b(P.join(t,a.HTTP_TYPES),P.join(e,a.HTTP_TYPES))},oi=async e=>{let{isFileUsed:t,isStringUsed:i}=await Promise.resolve().then(()=>(fe(),et));await S(P.join(e,a.HTTP_UTILS));let r=P.join(e,a.STORAGE_SERVICE);l(r)&&(await i(e,"SecureStorageService",[r])||await S(r));let s=P.join(e,a.CONSTANTS);if(l(s)){let p=await d(s),m=!1;await i(e,"API_RESPONSE_DATA_KEY",[s])||(p=p.replace(/export const API_RESPONSE_DATA_KEY = .*;\n?/g,""),m=!0),await i(e,"SAVE_AUTH_TOKENS",[s])||(p=p.replace(/export const SAVE_AUTH_TOKENS = .*;\n?/g,""),m=!0),m&&(p=p.replace(/\n\s*\n/g,`
428
+
429
+ `).trim()+`
430
+ `,await u(s,p))}let o=P.join(e,a.ERRORS_DIR);if(l(o)){let p=await W.readdir(o),m=!1;for(let h of p){let y=P.parse(h).name;if(await t(e,y,[P.join(o,h)])){m=!0;break}}m||await S(o)}let n=P.join(e,a.COMMON_TYPES_DIR);l(n)&&(await W.readdir(n)).length===0&&await S(n);let c=P.join(e,a.UTILITY_TYPES_DIR);l(c)&&(await W.readdir(c)).length===0&&await S(c)};fe();var Ye=async e=>{let t=$("Checking HTTP Client setup..."),i=Pe.join(e,".next-maker-temp-http");try{let{status:r,reason:s}=await Qt(e);t.stop();let o=await jo(r,s);if(o.type==="cancel"){console.log(Ue.yellow("Setup cancelled."));return}if(t.start("Setting up HTTP client(s)..."),await ei(e),await ti(i,t),o.type==="replace"&&o.fromClient&&(t.text="Migrating client usages...",await $e(e,o.fromClient,o.clients[0])),o.type!=="remove-both"&&o.type!=="remove-one"){t.text="Copying client files...";let w=o.type==="replace"&&o.fromClient?[o.fromClient]:void 0;await ii(e,i,o.clients,w)}if(o.type==="remove-one"||o.type==="remove-both"){t.text="Removing client files...";let{PROJECT_PATHS:w}=await Promise.resolve().then(()=>(N(),Ze));for(let I of o.clients){let F=Pe.join(e,I==="fetch"?w.FETCH_CLIENT:w.AXIOS_CLIENT);await S(F)}ri(r,o).length===0&&(t.text="Performing full cleanup...",await oi(e),await _e(e))}let n=ri(r,o);n.length>0&&(t.text="Configuring client...",await Re(e,n),await Ne(e),await Ae(e),await Oe(e)),await oe(e,n),t.text="Managing dependencies...";let c=Pe.join(e,"package.json"),p=JSON.parse(await Fo.readFile(c,"utf-8")),m={...p.dependencies,...p.devDependencies};n.includes("axios")?m.axios||(t.text="Installing Axios...",await M(e,"axios")):m.axios&&(t.text="Uninstalling Axios...",await Ee(e,"axios"));let h=Pe.join(e,"src/services/storage");n.length>0||l(h)?m["react-secure-storage"]||(t.text="Installing react-secure-storage...",await M(e,"react-secure-storage")):m["react-secure-storage"]&&(t.text="Uninstalling react-secure-storage...",await Ee(e,"react-secure-storage")),t.text="Formatting code...";let x=await G(e);await H(e,x,"format"),t.succeed(Ue.green(ko(o)))}catch(r){throw t.fail("Failed to setup HTTP Client."),r}finally{await S(i)}};async function jo(e,t){if(e==="none"){let{choice:r}=await ve.prompt({type:"select",name:"choice",message:"Which HTTP client(s) do you want to setup?",choices:[{name:"fetch",message:"Fetch (Native)"},{name:"axios",message:"Axios"},{name:"both",message:"Both (Fetch + Axios)"}]});return r==="both"?{type:"install",clients:["fetch","axios"]}:{type:"install",clients:[r]}}if(e==="fetch"){let{action:r}=await ve.prompt({type:"select",name:"action",message:`${t}. What would you like to do?`,choices:[{name:"cancel",message:"Keep Fetch only (cancel)"},{name:"add",message:"Add Axios (have both)"},{name:"replace",message:"Replace with Axios only"},{name:"remove",message:"Remove Fetch"}]});if(r==="cancel")return{type:"cancel",clients:[]};if(r==="add")return{type:"add",clients:["axios"]};if(r==="replace")return{type:"replace",clients:["axios"],fromClient:"fetch"};if(r==="remove")return{type:"remove-one",clients:["fetch"]}}if(e==="axios"){let{action:r}=await ve.prompt({type:"select",name:"action",message:`${t}. What would you like to do?`,choices:[{name:"cancel",message:"Keep Axios only (cancel)"},{name:"add",message:"Add Fetch (have both)"},{name:"replace",message:"Replace with Fetch only"},{name:"remove",message:"Remove Axios"}]});if(r==="cancel")return{type:"cancel",clients:[]};if(r==="add")return{type:"add",clients:["fetch"]};if(r==="replace")return{type:"replace",clients:["fetch"],fromClient:"axios"};if(r==="remove")return{type:"remove-one",clients:["axios"]}}console.log(Ue.yellow(`\u2716 ${t}`));let{action:i}=await ve.prompt({type:"select",name:"action",message:"What would you like to do?",choices:[{name:"cancel",message:"Keep both (cancel)"},{name:"remove-fetch",message:"Remove Fetch (keep Axios)"},{name:"remove-axios",message:"Remove Axios (keep Fetch)"},{name:"remove-both",message:"Remove both"}]});return i==="cancel"?{type:"cancel",clients:[]}:i==="remove-fetch"?{type:"remove-one",clients:["fetch"]}:i==="remove-axios"?{type:"remove-one",clients:["axios"]}:i==="remove-both"?{type:"remove-both",clients:["fetch","axios"]}:{type:"cancel",clients:[]}}function ri(e,t){return t.type==="install"?t.clients:t.type==="add"?[...e==="fetch"?["fetch"]:["axios"],...t.clients]:t.type==="replace"?t.clients:t.type==="remove-one"?e==="both"?t.clients[0]==="fetch"?["axios"]:["fetch"]:[]:[]}function ko(e){if(e.type==="install")return`HTTP Client (${e.clients.map(i=>i==="fetch"?"Fetch":"Axios").join(" + ")}) setup successfully!`;if(e.type==="add")return`${e.clients[0]==="fetch"?"Fetch":"Axios"} client added successfully! Both clients are now available.`;if(e.type==="replace"){let t=e.fromClient==="fetch"?"Fetch":"Axios",i=e.clients[0]==="fetch"?"Fetch":"Axios";return`Replaced ${t} with ${i} successfully! Imports automatically migrated.`}return e.type==="remove-one"?`${e.clients[0]==="fetch"?"Fetch":"Axios"} client removed successfully!`:e.type==="remove-both"?"Both HTTP clients removed successfully!":"HTTP Client setup completed!"}var{prompt:Lo}=Do,ni=e=>{e.command("setup").description("Setup features in an existing Next.js project").option("--http-client","Setup HTTP client (axios|fetch)").option("--dark-theme","Setup Dark Theme (Tailwind + next-themes)").option("--redux","Setup Redux Toolkit").option("--i18n","Setup next-intl for internationalization").action(async t=>{try{if(f(we.cyan(`
428
431
  \u{1F527} Setup Wizard
429
- `)),i.httpClient||i.darkTheme||i.redux||i.i18n){i.httpClient&&await Ye(process.cwd()),i.darkTheme&&await Le(process.cwd()),i.redux&&await He(process.cwd()),i.i18n&&await Ge(process.cwd());return}let r=(await Lo([{type:"select",name:"feature",message:"What would you like to setup?",choices:[{name:"Dark Theme",value:"dark-theme"},{name:"Redux Toolkit",value:"redux"},{name:"HTTP Client (Axios/Fetch)",value:"http-client"},{name:"Internationalization (next-intl)",value:"i18n"},"Cancel"]}])).feature;if(r==="Cancel"){f(we.yellow("Setup cancelled."));return}r==="dark-theme"?await Le(process.cwd()):r==="redux"?await He(process.cwd()):r==="http-client"?await Ye(process.cwd()):r==="i18n"?await Ge(process.cwd()):(f(we.yellow(`
430
- \u26A0\uFE0F ${r} setup is not implemented yet.`)),f(we.dim("This feature will be available in a future update.")))}catch(t){w.fail("Setup failed"),N(`${t}`),process.exit(1)}})};var ai=e=>{st(e),si(e),ft(e),St(e),Tt(e)};var Ho=process.emitWarning;process.emitWarning=function(e,i,t,r){if(!(typeof e=="string"&&e.includes("--localstorage-file")&&e.includes("was provided without a valid path")))return Ho.apply(process,arguments)};async function Go(){Be({logger:i=>fe(i)});let e=new Mo;e.name("next-maker").description("Teispace Next.js Project Generator").version("1.0.0"),ai(e),e.parse()}Go().catch(e=>{let i=e&&typeof e=="object"&&"message"in e?e.message:String(e);fe(`Unexpected error: ${i}`)});
432
+ `)),t.httpClient||t.darkTheme||t.redux||t.i18n){t.httpClient&&await Ye(process.cwd()),t.darkTheme&&await Le(process.cwd()),t.redux&&await He(process.cwd()),t.i18n&&await Ge(process.cwd());return}let r=(await Lo([{type:"select",name:"feature",message:"What would you like to setup?",choices:[{name:"Dark Theme",value:"dark-theme"},{name:"Redux Toolkit",value:"redux"},{name:"HTTP Client (Axios/Fetch)",value:"http-client"},{name:"Internationalization (next-intl)",value:"i18n"},"Cancel"]}])).feature;if(r==="Cancel"){f(we.yellow("Setup cancelled."));return}r==="dark-theme"?await Le(process.cwd()):r==="redux"?await He(process.cwd()):r==="http-client"?await Ye(process.cwd()):r==="i18n"?await Ge(process.cwd()):(f(we.yellow(`
433
+ \u26A0\uFE0F ${r} setup is not implemented yet.`)),f(we.dim("This feature will be available in a future update.")))}catch(i){v.fail("Setup failed"),R(`${i}`),process.exit(1)}})};var si=e=>{st(e),ni(e),ft(e),St(e),Tt(e)};var Ho=process.emitWarning;process.emitWarning=function(e,t,i,r){if(!(typeof e=="string"&&e.includes("--localstorage-file")&&e.includes("was provided without a valid path")))return Ho.apply(process,arguments)};async function Go(){Be({logger:t=>ue(t)});let e=new Mo;e.name("next-maker").description("Teispace Next.js Project Generator").version("1.0.0"),si(e),e.parse()}Go().catch(e=>{let t=e&&typeof e=="object"&&"message"in e?e.message:String(e);ue(`Unexpected error: ${t}`)});
431
434
  //# sourceMappingURL=index.js.map