UNPKG

create-next-pro-cli

Version:

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

374 lines (301 loc) β€’ 10.7 kB
<img src="./public/cnp-banner.svg" alt="create-next-pro logo" style="width:100%;" /> ## Runtime Support [![Bun](https://img.shields.io/badge/Bun-%23000000?logo=bun&logoColor=white&style=for-the-badge)](https://bun.sh) [![Node.js](https://img.shields.io/badge/Node.js-%23339933?logo=node.js&logoColor=white&style=for-the-badge)](https://nodejs.org) <!-- [![Deno](https://img.shields.io/badge/Deno-%23000000?logo=deno&logoColor=white&style=for-the-badge)](https://deno.land) --> ![npm](https://img.shields.io/npm/v/create-next-pro-cli?logo=npm&color=orange) ![npm dependencies](https://img.shields.io/librariesio/release/npm/create-next-pro-cli?logo=npm) ![npm downloads](https://img.shields.io/npm/dw/create-next-pro-cli?logo=npm) ![GitHub](https://img.shields.io/github/stars/Rising-Corporation/create-next-pro-cli?style=social&logo=github) ![GitHub forks](https://img.shields.io/github/forks/Rising-Corporation/create-next-pro-cli?style=social&logo=github) ![GitHub issues](https://img.shields.io/github/issues/Rising-Corporation/create-next-pro-cli?logo=github) ![CI](https://github.com/Rising-Corporation/typed-sse/actions/workflows/ci.yml/badge.svg) ![status](https://img.shields.io/badge/status-beta-orange) ![license](https://img.shields.io/github/license/Rising-Corporation/create-next-pro-cli?logo=open-source-initiative&logoColor=white) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-blue.svg?logo=conventionalcommits)](https://www.conventionalcommits.org/en/v1.0.0/) > ⚠️ This project is under active development and currently in beta testing. You may encounter bugs or crashes until the first release. 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 ``` ### Create a library ```bash create-next-pro addlib mylib ``` ### Add a file to a library ```bash create-next-pro addlib mylib.foo ``` ### Create an API route ```bash create-next-pro addapi hello ``` ### 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 β”‚ β”‚ └── UserInfo.json β”‚ β”œβ”€β”€ en.ts β”‚ β”œβ”€β”€ fr β”‚ β”‚ β”œβ”€β”€ Dashboard.json β”‚ β”‚ β”œβ”€β”€ _global_ui.json β”‚ β”‚ β”œβ”€β”€ _home.json β”‚ β”‚ β”œβ”€β”€ Login.json β”‚ β”‚ β”œβ”€β”€ Register.json β”‚ β”‚ β”œβ”€β”€ Settings.json β”‚ β”‚ └── UserInfo.json β”‚ β”œβ”€β”€ fr.ts β”‚ └── getMergedMessages.ts β”œβ”€β”€ middleware.ts β”œβ”€β”€ next.config.ts β”œβ”€β”€ next-env.d.ts β”œβ”€β”€ package.json β”œβ”€β”€ postcss.config.mjs β”œβ”€β”€ public β”‚ β”œβ”€β”€ cnp-logo.png β”‚ └── cnp-logo.svg β”œβ”€β”€ README.md β”œβ”€β”€ src β”‚ β”œβ”€β”€ app β”‚ β”‚ β”œβ”€β”€ api β”‚ β”‚ β”‚ └── auth β”‚ β”‚ β”‚ β”œβ”€β”€ [...nextauth] β”‚ β”‚ β”‚ β”‚ └── route.ts β”‚ β”‚ β”‚ └── post-login β”‚ β”‚ β”‚ └── 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 β”‚ β”‚ β”‚ └── UserInfo β”‚ β”‚ β”‚ β”œβ”€β”€ loading.tsx β”‚ β”‚ β”‚ └── page.tsx β”‚ β”‚ β”œβ”€β”€ not-found.tsx β”‚ β”‚ β”œβ”€β”€ page.tsx β”‚ β”‚ β”œβ”€β”€ sitemap.ts β”‚ β”‚ └── styles β”‚ β”‚ └── globals.css β”‚ β”œβ”€β”€ auth.config.ts β”‚ β”œβ”€β”€ config.ts β”‚ β”œβ”€β”€ lib β”‚ β”‚ β”œβ”€β”€ auth β”‚ β”‚ β”‚ β”œβ”€β”€ disconnect.ts β”‚ β”‚ β”‚ └── isConnected.ts β”‚ β”‚ β”œβ”€β”€ i18n β”‚ β”‚ β”‚ β”œβ”€β”€ navigation.ts β”‚ β”‚ β”‚ β”œβ”€β”€ request.ts β”‚ β”‚ β”‚ └── routing.ts β”‚ β”‚ └── utils.ts β”‚ └── ui β”‚ β”œβ”€β”€ Dashboard β”‚ β”‚ β”œβ”€β”€ LogoutButton.tsx β”‚ β”‚ β”œβ”€β”€ page-ui.tsx β”‚ β”‚ β”œβ”€β”€ StatsCard.tsx β”‚ β”‚ └── WelcomeCard.tsx β”‚ β”œβ”€β”€ _global β”‚ β”‚ β”œβ”€β”€ BackButton.tsx β”‚ β”‚ β”œβ”€β”€ Button.tsx β”‚ β”‚ β”œβ”€β”€ GlobalHeader.tsx β”‚ β”‚ β”œβ”€β”€ GlobalMain.tsx β”‚ β”‚ β”œβ”€β”€ Loading.tsx β”‚ β”‚ β”œβ”€β”€ LocaleSwitcher.tsx β”‚ β”‚ β”œβ”€β”€ PublicNav.tsx β”‚ β”‚ β”œβ”€β”€ ThemeToggle.tsx β”‚ β”‚ └── UserNav.tsx β”‚ β”œβ”€β”€ _home β”‚ β”‚ └── page-ui.tsx β”‚ β”œβ”€β”€ Login β”‚ β”‚ └── page-ui.tsx β”‚ β”œβ”€β”€ Register β”‚ β”‚ └── page-ui.tsx β”‚ β”œβ”€β”€ Settings β”‚ β”‚ └── page-ui.tsx β”‚ └── UserInfo β”‚ └── page-ui.tsx β”œβ”€β”€ tailwind.config.ts └── tsconfig.json ``` --- ## βœ… Main Features - Interactive CLI available for Bun, Node.js, or Deno - Multi-runtime support: Bun, Node.js, Deno - Features: - TypeScript integration - ESLint configuration - Tailwind CSS setup - App Router support (with or without `src/` directory) - Internationalization using `next-intl` - Turbopack or Webpack support - Custom path aliases (e.g., `@/*`, `@core/*`) - Next-auth with custom cookies - Automatic generation of pages and components - Clean i18n structure: `/messages/en/*.json`, `/lib/i18n/` - Add or remove pages and components via CLI - Bash and Zsh autocompletion - Interactive installation and runtime detection --- ## πŸ“ CLI Structure ```plaintext create-next-pro/ . β”œβ”€β”€ bin.ts β”œβ”€β”€ create-next-pro-completion.sh β”œβ”€β”€ install.sh β”œβ”€β”€ package.json β”œβ”€β”€ public β”‚ β”œβ”€β”€ cnp-banner.svg β”‚ └── logo.svg β”œβ”€β”€ src β”‚ β”œβ”€β”€ index.ts β”‚ β”œβ”€β”€ lib β”‚ β”‚ β”œβ”€β”€ addComponent.ts β”‚ β”‚ β”œβ”€β”€ addPage.ts β”‚ β”‚ β”œβ”€β”€ createProject.ts β”‚ β”‚ β”œβ”€β”€ createProjectWithPrompt.ts β”‚ β”‚ β”œβ”€β”€ rmPage.ts β”‚ β”‚ β”œβ”€β”€ utils.test.ts β”‚ β”‚ └── utils.ts β”‚ β”œβ”€β”€ scaffold-dev.ts β”‚ └── scaffold.ts └── tsconfig.json ``` --- ## πŸš€ Install & Usage ### Local from git ( dev & bun only ) ```bash git clone https://github.com/Rising-Corporation/create-next-pro-cli.git bun install bun dev ``` - then Global ( on your machine ) ```bash bun link create-next-pro-cli create-next-pro my-next-project ``` ### From npm (via bunx , npx ... or global install) ```bash bunx create-next-pro-cli # to try without install ``` - or ```bash 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 > ``` > > || > > ```bash > source ~/.zshrc > ``` --- ## πŸ›£οΈ Roadmap in coming for beta v0.2.0 - [ ] Implementation of interactive prompts - [ ] Create library features - [ ] Create API features - [ ] Generation of `.env.*` - [ ] Multi-platform testing (`bunx`, `link`, `npm`, etc.) - [ ] Additional Components templates (admin panel, landing page, etc.) - [Β ] Auto deployment to Vercel --- ## πŸ‘¨β€πŸ’» Author MrRise@RisingCorporation Made with ❀️ and Bun πŸ‡