@teispace/next-maker 1.17.0 → 1.17.1
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/CHANGELOG.md +7 -0
- package/dist/index.js +7 -7
- package/dist/index.js.map +3 -3
- package/dist/src/commands/component.d.ts.map +1 -1
- package/dist/src/commands/locale.d.ts.map +1 -1
- package/dist/src/commands/page.d.ts.map +1 -1
- package/dist/src/prompts/component.prompt.d.ts +5 -1
- package/dist/src/prompts/component.prompt.d.ts.map +1 -1
- package/dist/src/prompts/locale.prompt.d.ts +5 -1
- package/dist/src/prompts/locale.prompt.d.ts.map +1 -1
- package/dist/src/prompts/page.prompt.d.ts +7 -1
- package/dist/src/prompts/page.prompt.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.17.1](https://github.com/teispace/npm-packages/compare/next-maker-v1.17.0...next-maker-v1.17.1) (2026-04-26)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **next-maker:** respect cli flags in prompts; add type=button to error tsx ([2718aad](https://github.com/teispace/npm-packages/commit/2718aad9f74559e854c7332841daca63b4ec503e))
|
|
9
|
+
|
|
3
10
|
## [1.17.0](https://github.com/teispace/npm-packages/compare/next-maker-v1.16.1...next-maker-v1.17.0) (2026-04-26)
|
|
4
11
|
|
|
5
12
|
|
package/dist/index.js
CHANGED
|
@@ -578,7 +578,7 @@ export default function ${e.componentName}Error({
|
|
|
578
578
|
<div className="flex h-full flex-col items-center justify-center gap-4">
|
|
579
579
|
<h2>Something went wrong!</h2>
|
|
580
580
|
<p>{error.message}</p>
|
|
581
|
-
<button onClick={() => reset()}>Try again</button>
|
|
581
|
+
<button type="button" onClick={() => reset()}>Try again</button>
|
|
582
582
|
</div>
|
|
583
583
|
);
|
|
584
584
|
}
|
|
@@ -663,9 +663,9 @@ describe('${n}', () => {
|
|
|
663
663
|
expect(next).toEqual(initialState);
|
|
664
664
|
});
|
|
665
665
|
});
|
|
666
|
-
`};var Q=async e=>{let{projectPath:r,sourceFile:t,kind:n,symbolName:i}=e,o=je.dirname(t),s=je.basename(t).replace(/\.(tsx?|jsx?)$/i,""),a=n==="component"?".tsx":".ts",p=je.join(o,`${s}.test${a}`),d=`./${s}`,g=Vs(o,je.join(r,"test","test-utils")),h;return n==="component"?h=Rn({componentName:i,sourceImportPath:d,testUtilsImportPath:g,hasRedux:!!e.hasRedux,hasI18n:!!e.hasI18n}):n==="hook"?h=$n({hookName:i,sourceImportPath:d,withStore:!!e.hookUsesStore,testUtilsImportPath:e.hookUsesStore?g:void 0}):h=bn({camelName:i,sourceImportPath:d}),await f(p,h),p},Vs=(e,r)=>{let t=je.relative(e,r).replace(/\\/g,"/");return t.startsWith(".")?t:`./${t}`};import Js from"enquirer";var{prompt:Bs}=Js,Nn=async
|
|
666
|
+
`};var Q=async e=>{let{projectPath:r,sourceFile:t,kind:n,symbolName:i}=e,o=je.dirname(t),s=je.basename(t).replace(/\.(tsx?|jsx?)$/i,""),a=n==="component"?".tsx":".ts",p=je.join(o,`${s}.test${a}`),d=`./${s}`,g=Vs(o,je.join(r,"test","test-utils")),h;return n==="component"?h=Rn({componentName:i,sourceImportPath:d,testUtilsImportPath:g,hasRedux:!!e.hasRedux,hasI18n:!!e.hasI18n}):n==="hook"?h=$n({hookName:i,sourceImportPath:d,withStore:!!e.hookUsesStore,testUtilsImportPath:e.hookUsesStore?g:void 0}):h=bn({camelName:i,sourceImportPath:d}),await f(p,h),p},Vs=(e,r)=>{let t=je.relative(e,r).replace(/\\/g,"/");return t.startsWith(".")?t:`./${t}`};import Js from"enquirer";var{prompt:Bs}=Js,Nn=async(e,r={})=>{let t=[];e||t.push({type:"input",name:"componentName",message:"Component name (kebab-case):",validate:i=>i?/^[a-z][a-z0-9-]*$/.test(i)?!0:"Use lowercase letters, numbers, and hyphens only":"Component name is required"}),r.client===void 0&&t.push({type:"confirm",name:"isClient",message:"Add 'use client' directive?",initial:!1});let n=t.length>0?await Bs(t):{};return{componentName:e??n.componentName,isClient:r.client??n.isClient??!1}};var In=e=>{e.command("component [name]").description("Generate a shared component").option("--client","Add 'use client' directive").option("--i18n","Add useTranslations hook").option("--feature <path>","Generate in feature directory (e.g., src/features/auth)").option("--test","Also generate a sibling test file").option("--no-test","Skip test file generation").action(async(r,t)=>{try{let n=process.cwd();l(q.cyan(`
|
|
667
667
|
\u{1F9E9} Component Generator
|
|
668
|
-
`)),x.start("Detecting project setup...");let i=await I(n);x.succeed("Project setup detected");let o=await Nn(r),s=$(o.componentName),a=
|
|
668
|
+
`)),x.start("Detecting project setup...");let i=await I(n);x.succeed("Project setup detected");let o=await Nn(r,{client:t.client}),s=$(o.componentName),a=o.isClient,p=t.i18n??!1,d=Xs(t,i.hasTests);x.start("Generating component..."),await Dt({name:o.componentName,projectPath:n,isClient:a||p,hasI18n:p,featurePath:t.feature}),x.succeed("Component generated");let g=null;if(d){let y=t.feature?Yt.join(n,t.feature,"components",`${s}.tsx`):Yt.join(n,"src/components/common",s,`${s}.tsx`);x.start("Generating test..."),g=await Q({projectPath:n,sourceFile:y,kind:"component",symbolName:s,hasRedux:i.hasRedux,hasI18n:i.hasI18n}),x.succeed("Test generated")}let h=t.feature?`${t.feature}/components/${s}.tsx`:`src/components/common/${s}/${s}.tsx`;l(q.green(`
|
|
669
669
|
\u2728 Component '${s}' created successfully!
|
|
670
670
|
`)),l(q.dim(` \u{1F4C4} ${h}`)),t.feature||(l(q.dim(` \u{1F4C4} src/components/common/${s}/index.ts`)),l(q.dim(" \u{1F4DD} Updated src/components/common/index.ts")),l(q.dim(" \u{1F4DD} Updated src/components/index.ts"))),g&&l(q.dim(` \u{1F9EA} ${Yt.relative(n,g)}`)),l(""),l(q.cyan("Usage:")),t.feature?l(q.dim(` import { ${s} } from '${t.feature.replace(/^src\//,"@/")}/components/${s}';`)):l(q.dim(` import { ${s} } from '@/components';`)),l("")}catch(n){x.fail("Component generation failed"),v(`${n}`),process.exit(1)}})},Xs=(e,r)=>e.noTest?!1:e.test?!0:r;import j from"picocolors";w();P();import Ks from"node:path";w();import An from"node:path";import Ys from"picocolors";P();var De=async e=>{let r=R("Adding @next/bundle-analyzer...");try{let t=An.join(e,c.NEXT_CONFIG);if(!m(t))throw new Error(`${c.NEXT_CONFIG} not found.`);let n=await u(t);if(n.includes("@next/bundle-analyzer")){r.fail("@next/bundle-analyzer is already configured.");return}n=`import withBundleAnalyzer from '@next/bundle-analyzer';
|
|
671
671
|
${n}`;let i=/export default (.*?);/,o=n.match(i);if(!o)throw new Error("Could not locate `export default` in next.config.ts.");let a=`const bundleAnalyzer = withBundleAnalyzer({
|
|
@@ -983,16 +983,16 @@ ${e.replace(/^\n+/,"")}`;let p=n.slice(0,a),d=n.findIndex((h,y)=>y>a&&!/^export
|
|
|
983
983
|
`)),x.start("Detecting project setup...");let i=await I(n);x.succeed("Project setup detected");let o=i.hasI18n&&t.locale!==!1;l(Pt.dim(` i18n: ${o?"\u2713":"\u2717"}
|
|
984
984
|
`)),x.start("Generating layout...");let s=await Ut({segment:r,at:t.at,projectPath:n,hasI18n:o,withGroup:!!t.group});x.succeed("Layout generated"),l(Pt.green(`
|
|
985
985
|
\u2728 ${s.componentName} created!
|
|
986
|
-
`)),l(Pt.dim(` \u{1F4C4} ${s.displayPath}`)),l("")}catch(n){x.fail("Layout generation failed"),v(`${n instanceof Error?n.message:n}`),process.exit(1)}})};import fc from"node:path";import W from"picocolors";P();L();import dc from"enquirer";var{prompt:uc}=dc,qo=async
|
|
986
|
+
`)),l(Pt.dim(` \u{1F4C4} ${s.displayPath}`)),l("")}catch(n){x.fail("Layout generation failed"),v(`${n instanceof Error?n.message:n}`),process.exit(1)}})};import fc from"node:path";import W from"picocolors";P();L();import dc from"enquirer";var{prompt:uc}=dc,qo=async(e,r={})=>{let t=[];e||t.push({type:"input",name:"code",message:"Locale code (e.g., es, fr, de):",validate:i=>i?/^[a-z]{2}(-[A-Z]{2})?$/.test(i)?!0:"Use format: xx or xx-XX (e.g., es, pt-BR)":"Locale code is required"}),t.push({type:"input",name:"name",message:"Language name (e.g., Spanish, French):",validate:i=>i?!0:"Language name is required"},{type:"input",name:"country",message:"Country (e.g., Spain, France):",validate:i=>i?!0:"Country is required"},{type:"input",name:"flag",message:"Flag emoji (e.g., \u{1F1EA}\u{1F1F8}, \u{1F1EB}\u{1F1F7}):",validate:i=>i?!0:"Flag emoji is required"}),r.copyTranslations===void 0&&t.push({type:"confirm",name:"copyTranslations",message:"Copy translations from English? (No = empty values)",initial:!1});let n=await uc(t);return{code:e??n.code,name:n.name,country:n.country,flag:n.flag,copyTranslations:r.copyTranslations??n.copyTranslations??!1}};var Wo=e=>{e.command("locale [code]").description("Add a new locale/language").option("--copy-translations","Copy translations from English instead of empty values").action(async(r,t)=>{try{let n=process.cwd();l(W.cyan(`
|
|
987
987
|
\u{1F30D} Locale Generator
|
|
988
988
|
`)),x.start("Detecting project setup...");let i=await I(n);x.succeed("Project setup detected"),i.hasI18n||(x.fail("i18n is not set up in this project"),v("Please set up internationalization first"),l(W.dim(`
|
|
989
989
|
Run: npx @teispace/next-maker setup --i18n
|
|
990
|
-
`)),process.exit(1));let o=await qo(r),s=fc.join(n,"src","i18n","translations",`${o.code}.json`);m(s)&&(v(`Locale '${o.code}' already exists!`),process.exit(1)),x.start("Adding locale..."),await zt({...o,projectPath:n
|
|
990
|
+
`)),process.exit(1));let o=await qo(r,{copyTranslations:t.copyTranslations}),s=fc.join(n,"src","i18n","translations",`${o.code}.json`);m(s)&&(v(`Locale '${o.code}' already exists!`),process.exit(1)),x.start("Adding locale..."),await zt({...o,projectPath:n}),x.succeed("Locale added"),l(W.green(`
|
|
991
991
|
\u2728 Locale '${o.code}' (${o.name}) added successfully!
|
|
992
|
-
`)),l(W.dim("Updated files:")),l(W.dim(` \u{1F4C4} src/i18n/translations/${o.code}.json`)),l(W.dim(" \u{1F4DD} src/types/i18n.ts (SupportedLocale type)")),l(W.dim(" \u{1F4DD} src/lib/config/app-locales.ts")),l(""),l(W.cyan("Next steps:")),l(W.dim(` 1. Translate: src/i18n/translations/${o.code}.json`)),l(W.dim(` 2. Visit: http://localhost:3000/${o.code}`)),l("")}catch(n){x.fail("Locale generation failed"),v(`${n}`),process.exit(1)}})};import Qo from"node:path";import J from"picocolors";L();import gc from"enquirer";var{prompt:hc}=gc,Zo=async
|
|
992
|
+
`)),l(W.dim("Updated files:")),l(W.dim(` \u{1F4C4} src/i18n/translations/${o.code}.json`)),l(W.dim(" \u{1F4DD} src/types/i18n.ts (SupportedLocale type)")),l(W.dim(" \u{1F4DD} src/lib/config/app-locales.ts")),l(""),l(W.cyan("Next steps:")),l(W.dim(` 1. Translate: src/i18n/translations/${o.code}.json`)),l(W.dim(` 2. Visit: http://localhost:3000/${o.code}`)),l("")}catch(n){x.fail("Locale generation failed"),v(`${n}`),process.exit(1)}})};import Qo from"node:path";import J from"picocolors";L();import gc from"enquirer";var{prompt:hc}=gc,Zo=async(e,r={})=>{let t=[];e||t.push({type:"input",name:"pageName",message:"Page name (kebab-case):",validate:i=>i?/^[a-z][a-z0-9-]*$/.test(i)?!0:"Use lowercase letters, numbers, and hyphens only":"Page name is required"}),r.loading===void 0&&t.push({type:"confirm",name:"withLoading",message:"Generate loading.tsx?",initial:!0}),r.error===void 0&&t.push({type:"confirm",name:"withError",message:"Generate error.tsx?",initial:!0});let n=t.length>0?await hc(t):{};return{pageName:e??n.pageName,withLoading:r.loading??n.withLoading??!0,withError:r.error??n.withError??!0}};var ei=e=>{e.command("page [name]").description("Generate a new page/route").option("--dynamic <param>","Create dynamic route with parameter (e.g., id)").option("--loading","Generate loading.tsx").option("--error","Generate error.tsx").action(async(r,t)=>{try{let n=process.cwd();l(J.cyan(`
|
|
993
993
|
\u{1F4C4} Page Generator
|
|
994
994
|
`)),x.start("Detecting project setup...");let i=await I(n);x.succeed("Project setup detected"),l(J.dim(` i18n: ${i.hasI18n?"\u2713":"\u2717"}
|
|
995
|
-
`));let o=await Zo(r),s=o.pageName,a=$(s),p=i.hasI18n?"src/app/[locale]":"src/app";await ie(n,s,p)&&(v(`Page '${s}' already exists at ${p}/${s}!`),process.exit(1)),x.start("Generating page files..."),await Jt({name:s,projectPath:n,hasI18n:i.hasI18n,dynamic:t.dynamic,withLoading:t.loading??o.withLoading,withError:t.error??o.withError}),x.succeed("Page files generated"),x.start("Registering route...");let g=t.dynamic?`/${s}/[${t.dynamic}]`:`/${s}`;await lr(n,s,g),x.succeed("Route registered"),i.hasI18n&&(x.start("Adding translation namespace..."),await dr(n,a),x.succeed("Translation namespace added"));let h=t.dynamic?Qo.join(p,s,`[${t.dynamic}]`):Qo.join(p,s);l(J.green(`
|
|
995
|
+
`));let o=await Zo(r,{loading:t.loading,error:t.error}),s=o.pageName,a=$(s),p=i.hasI18n?"src/app/[locale]":"src/app";await ie(n,s,p)&&(v(`Page '${s}' already exists at ${p}/${s}!`),process.exit(1)),x.start("Generating page files..."),await Jt({name:s,projectPath:n,hasI18n:i.hasI18n,dynamic:t.dynamic,withLoading:t.loading??o.withLoading,withError:t.error??o.withError}),x.succeed("Page files generated"),x.start("Registering route...");let g=t.dynamic?`/${s}/[${t.dynamic}]`:`/${s}`;await lr(n,s,g),x.succeed("Route registered"),i.hasI18n&&(x.start("Adding translation namespace..."),await dr(n,a),x.succeed("Translation namespace added"));let h=t.dynamic?Qo.join(p,s,`[${t.dynamic}]`):Qo.join(p,s);l(J.green(`
|
|
996
996
|
\u2728 Page '${s}' created successfully!
|
|
997
997
|
`)),l(J.dim("Generated files:")),l(J.dim(` \u{1F4C2} ${h}/`)),l(J.dim(" \u251C\u2500\u2500 page.tsx")),(t.loading??o.withLoading)&&l(J.dim(" \u251C\u2500\u2500 loading.tsx")),(t.error??o.withError)&&l(J.dim(" \u2514\u2500\u2500 error.tsx")),l(""),i.hasI18n&&(l(J.cyan("Next steps:")),l(J.dim(` 1. Add translations in: src/i18n/translations/en.json \u2192 "${a}"`)),l(J.dim(` 2. Visit: http://localhost:3000/${s}`)),l(""))}catch(n){x.fail("Page generation failed"),v(`${n}`),process.exit(1)}})};import yr from"node:path";import pe from"picocolors";var ti=e=>{e.command("provider <name>").description("Generate a context provider in src/providers/ and wire it into RootProvider").action(async r=>{try{let t=process.cwd();l(pe.cyan(`
|
|
998
998
|
\u{1F50C} Provider Generator
|