UNPKG

create-next-pro-cli

Version:

Advanced Next.js project scaffolder with i18n, Tailwind, App Router and more.

324 lines (262 loc) β€’ 8.7 kB
![create-next-pro logo](./public/logo.svg) > ⚠️ This project is under active development and currently in beta testing. Not all features are implemented yet, and contributions are welcome! Initially, changes will be accepted or rejected by the creator, but in a few weeks, contributions will be submitted to a community vote. # create-next-pro-cli > πŸš€ An advanced CLI scaffolder to create professional Next.js projects instantly. --- > 🀩 Can't wait and too excited to read more? Just want to try it now? > > ℹ️ To enable autocompletion automatically, add the `--trust` option when installing globally with Bun: > > ```bash > bun install -g create-next-pro-cli --trust > ``` --- ## 🎯 Purpose Create an enhanced alternative to `bun create next-app` with an interactive interface to generate Next.js projects tailored to real-world professional needs. This open-source, community-driven project aims to gather and share best practices to help standardize Next.js project structures. It includes many other features to facilitate modern development workflows and encourage collaboration. The CLI also enables you to instantly create pages and components, automatically placing them in the correct location within your project’s architecture for seamless organization and scalability. You can also customize the templates used for pages and components to fit your own needs. --- ## πŸ› οΈ Commands & Examples ### Create a new project ```bash create-next-pro MyProjectName ``` > ⚠️ The interactive prompt for features and customization is not yet implemented, but will be available very soon! ### Create a page ```bash create-next-pro addpage MyPage ``` ### Create a nested page ```bash create-next-pro addpage ParentPage.ChildPage ``` ### Create a component (global) ```bash create-next-pro addcomponent MyComponent ``` ### Create a component in a page ```bash create-next-pro addcomponent MyComponent -P MyPage ``` ### Create a component in a nested page ```bash create-next-pro addcomponent MyComponent -P ParentPage.ChildPage ``` ### Remove a page ```bash create-next-pro rmpage MyPage ``` ### Remove a nested page ```bash create-next-pro rmpage ParentPage.ChildPage ``` --- ## πŸ“ Expected Structure of a Generated Project ```plaintext my-next-app/ β”œβ”€β”€ eslint.config.mjs β”œβ”€β”€ messages β”‚ β”œβ”€β”€ en β”‚ β”‚ β”œβ”€β”€ dashboard.json β”‚ β”‚ β”œβ”€β”€ _global_ui.json β”‚ β”‚ β”œβ”€β”€ _home.json β”‚ β”‚ β”œβ”€β”€ login.json β”‚ β”‚ β”œβ”€β”€ register.json β”‚ β”‚ β”œβ”€β”€ settings.json β”‚ β”‚ └── user_info.json β”‚ β”œβ”€β”€ en.ts β”‚ β”œβ”€β”€ fr β”‚ β”‚ β”œβ”€β”€ dashboard.json β”‚ β”‚ β”œβ”€β”€ _global_ui.json β”‚ β”‚ β”œβ”€β”€ _home.json β”‚ β”‚ β”œβ”€β”€ login.json β”‚ β”‚ β”œβ”€β”€ register.json β”‚ β”‚ β”œβ”€β”€ settings.json β”‚ β”‚ └── user_info.json β”‚ β”œβ”€β”€ fr.ts β”‚ └── getMergedMessages.ts β”œβ”€β”€ middleware.ts β”œβ”€β”€ next.config.ts β”œβ”€β”€ next-env.d.ts β”œβ”€β”€ package.json β”œβ”€β”€ postcss.config.mjs β”œβ”€β”€ public β”‚ β”œβ”€β”€ cnp-logo.ico β”‚ β”œβ”€β”€ cnp-logo.png β”‚ β”œβ”€β”€ cnp-logo.svg β”‚ β”œβ”€β”€ file.svg β”‚ β”œβ”€β”€ globe.svg β”‚ β”œβ”€β”€ next.svg β”‚ β”œβ”€β”€ vercel.svg β”‚ └── window.svg β”œβ”€β”€ README.md β”œβ”€β”€ src β”‚ β”œβ”€β”€ app β”‚ β”‚ β”œβ”€β”€ api β”‚ β”‚ β”‚ β”œβ”€β”€ auth β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ [...nextauth] β”‚ β”‚ β”‚ β”‚ β”‚ └── route.ts β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ [...nextauth].ts β”‚ β”‚ β”‚ β”‚ └── post-login β”‚ β”‚ β”‚ β”‚ └── route.ts β”‚ β”‚ β”‚ └── me β”‚ β”‚ β”‚ └── route.ts β”‚ β”‚ β”œβ”€β”€ favicon.ico β”‚ β”‚ β”œβ”€β”€ layout.tsx β”‚ β”‚ β”œβ”€β”€ [locale] β”‚ β”‚ β”‚ β”œβ”€β”€ layout.tsx β”‚ β”‚ β”‚ β”œβ”€β”€ loading.tsx β”‚ β”‚ β”‚ β”œβ”€β”€ not-found.tsx β”‚ β”‚ β”‚ β”œβ”€β”€ page.tsx β”‚ β”‚ β”‚ β”œβ”€β”€ (public) β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ _home β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ loading.tsx β”‚ β”‚ β”‚ β”‚ β”‚ └── page.tsx β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ layout.tsx β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ login β”‚ β”‚ β”‚ β”‚ β”‚ └── page.tsx β”‚ β”‚ β”‚ β”‚ └── register β”‚ β”‚ β”‚ β”‚ └── page.tsx β”‚ β”‚ β”‚ └── (user) β”‚ β”‚ β”‚ β”œβ”€β”€ dashboard β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ error.tsx β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ loading.tsx β”‚ β”‚ β”‚ β”‚ └── page.tsx β”‚ β”‚ β”‚ β”œβ”€β”€ layout.tsx β”‚ β”‚ β”‚ β”œβ”€β”€ settings β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ loading.tsx β”‚ β”‚ β”‚ β”‚ └── page.tsx β”‚ β”‚ β”‚ └── user_info β”‚ β”‚ β”‚ β”œβ”€β”€ loading.tsx β”‚ β”‚ β”‚ └── page.tsx β”‚ β”‚ β”œβ”€β”€ not-found.tsx β”‚ β”‚ β”œβ”€β”€ page.tsx β”‚ β”‚ β”œβ”€β”€ sitemap.ts β”‚ β”‚ └── styles β”‚ β”‚ └── globals.css β”‚ β”œβ”€β”€ auth.config.ts β”‚ β”œβ”€β”€ config.ts β”‚ β”œβ”€β”€ lib β”‚ β”‚ β”œβ”€β”€ auth β”‚ β”‚ β”‚ └── isConnected.ts β”‚ β”‚ └── i18n β”‚ β”‚ β”œβ”€β”€ navigation.ts β”‚ β”‚ β”œβ”€β”€ request.ts β”‚ β”‚ └── routing.ts β”‚ └── ui β”‚ β”œβ”€β”€ dashboard β”‚ β”‚ β”œβ”€β”€ page.tsx β”‚ β”‚ β”œβ”€β”€ StatsCard.tsx β”‚ β”‚ └── WelcomeCard.tsx β”‚ β”œβ”€β”€ _global β”‚ β”‚ β”œβ”€β”€ BackButton.tsx β”‚ β”‚ β”œβ”€β”€ GlobalHeader.tsx β”‚ β”‚ β”œβ”€β”€ GlobalMain.tsx β”‚ β”‚ β”œβ”€β”€ LocaleSwitcher.tsx β”‚ β”‚ β”œβ”€β”€ PublicNav.tsx β”‚ β”‚ └── UserNav.tsx β”‚ └── _home β”œβ”€β”€ tailwind.config.ts └── tsconfig.json ``` --- ## βœ… Main Features - Interactive CLI via `bun` or `bunx` - Supports: - TypeScript - ESLint - Tailwind CSS - App Router (with or without `src/`) - i18n (`next-intl`) - Turbopack / Webpack - Custom aliases (`@/*`, `@core/*`, etc.) - Automatic generation: - Folders - Base pages: `page.tsx`, `layout.tsx`, `loading.tsx`, `not-found.tsx`, `error.tsx` - `.env`, `.env.local`, `.env.production`, etc. - Clean i18n structure: `/messages/en/*.json`, `/lib/i18n/` --- ## πŸ“ CLI Structure ```plaintext create-next-pro/ . β”œβ”€β”€ bin.ts # CLI entry point (#!/usr/bin/env bun) β”œβ”€β”€ bun.lock β”œβ”€β”€ create-next-pro-completion.sh # Auto completion for source β”œβ”€β”€ FONCTIONALITY.md β”œβ”€β”€ install.sh β”œβ”€β”€ package.json # Binary declaration β”œβ”€β”€ README.md β”œβ”€β”€ src β”‚ β”œβ”€β”€ index.ts # Interactive logic (prompts, generation) β”‚ β”œβ”€β”€ logo.svg β”‚ β”œβ”€β”€ scaffold-dev.ts β”‚ └── scaffold.ts └── tsconfig.json # Bun/TypeScript config ``` --- ## πŸš€ Install & Usage ### Local from git (dev) ```bash bun install bun dev ``` ### Global (on your machine) ```bash bun link create-next-pro-cli create-next-pro my-next-project ``` ### From another PC (via bunx or global install) ```bash bunx create-next-pro-cli # to try without install # or bun install -g create-next-pro-cli ``` > ℹ️ To enable autocompletion automatically, add the `--trust` option when installing globally with Bun: > > ```bash > bun install -g create-next-pro-cli --trust > ``` > Otherwise, run the autocompletion install script from binary manually: > > ```bash > bash install.sh > ``` > or add the autocompletion line to your `.bashrc`/`.zshrc` : > > ```bash > source ~/.bun/install/global/node_modules/create-next-pro-cli/create-next-pro-completion.sh > ``` > > Then restart your terminal or run > > ```bash > source ~/.bashrc > ``` --- ## πŸ›£οΈ Roadmap - [x] Bun config + `tsconfig.json` - [x] `bin.ts` CLI entry point - [x] CLI project structure `src/index.ts` - [ ] Implementation of interactive prompts - [x] Basic Next.js project scaffolding - [x] CLI file/page generation - [x] Custom alias support - [x] Next-auth with custom cookies - [x] Full `next-intl` support with `lib/i18n/` and `messages/` - [ ] Generation of `.env.*` - [ ] Multi-platform testing (`bunx`, `link`, `npm`, etc.) - [x] Publish to npm or Bun registry --- ## ✨ Coming Soon - Additional Components templates (admin panel, landing page, etc.) - Library templates - API templates - Prettier / Husky / Commitlint integration - Auto deployment to Vercel --- ## πŸ‘¨β€πŸ’» Author MrRise@RisingCorporation Made with ❀️ and Bun πŸ‡