nsbp-cli
v0.2.52
Published
CLI tool for creating NSBP (Node React SSR by Webpack) projects
Maintainers
Readme
NSBP CLI
Command-line interface for creating NSBP (Node React SSR by Webpack) projects.
🌐 Online Demo: https://nsbp.erishen.cn/
📦 Published on npm: https://www.npmjs.com/package/nsbp-cli
Installation
Global Installation (npm)
npm install -g nsbp-cliUsing npx (No Installation)
npx nsbp-cli create my-appVerify Installation
nsbp --versionQuick Start
Create a new NSBP project with a single command:
nsbp create my-app
cd my-app
pnpm install # NSBP CLI uses pnpm as package manager
pnpm run devFor development with Docker (recommended):
cd my-app
make dev # Starts development environment with hot reloadCommand Reference
Create a New Project
nsbp create <app-name> [options]
# Examples
nsbp create my-app
nsbp create my-app --skip-install # Skip npm install
nsbp create my-app --template basic # Specify template (basic is default)Display Framework Information
nsbp infoHelp
nsbp --help # Show all commands
nsbp create --help # Show create command optionsTemplates
The CLI provides project templates to get started quickly:
basic (default) - Complete NSBP stack with React SSR, TypeScript, and Webpack
- Includes full Docker support for development and production
- Pre-configured with Makefile for easy Docker operations
- Ready-to-use project structure
blog - Blog-focused template with article layouts (coming soon)
ecommerce - E-commerce template with product pages (coming soon)
Docker Support
The basic template includes comprehensive Docker configuration:
Docker Files Included
.dockerignore- Docker build ignore rulesdocker-compose.yml- Production environment configurationdocker-compose.dev.yml- Development environment with hot reloadDockerfile- Multi-stage production buildDockerfile.dev- Development buildMakefile- Convenient Docker commands
Available Make Commands
make dev # Start development environment (hot reload)
make prod # Start production environment
make rebuild # Rebuild and restart production containers
make logs # View container logs
make down # Stop and remove containers
make shell # Open shell in production container
make shell-dev # Open shell in development containerHow It Works
The CLI copies the NSBP project structure from templates/basic/ to your target directory and creates a new package.json with appropriate dependencies. You get a fully functional NSBP project ready for development, including complete Docker support.
Template Synchronization
The CLI includes a synchronization script that keeps built-in templates up-to-date with the main NSBP project code.
Sync Script
Location: cli/scripts/sync-template.js
Usage
cd cli
pnpm run update # CLI项目使用pnpm,运行同步脚本
# 或者使用 npm run update(兼容)Features
- Smart copying - Copies only source code and configuration files
- Build artifact filtering - Automatically excludes build artifacts from the public directory
- Template transformation - Converts main project's package.json to template format
- Integrity verification - Checks for required files before synchronization
Synchronized Files
src/- React components and routingpublic/- Static assetsscripts/- Startup and utility scriptswebpack.*.js- Webpack configurationtsconfig.json- TypeScript configurationpostcss.config.js- PostCSS configurationpackage.json- Project configuration (templatized).gitignore,.prettierrc,.prettierignore,README.md- Docker files:
.dockerignore,docker-compose.yml,docker-compose.dev.yml,Dockerfile,Dockerfile.dev,Makefile
Development
To work on the CLI locally:
cd cli
pnpm install # CLI项目使用pnpm作为包管理器
node ./bin/nsbp.js --help # Test CLI locallyPackage Information
- Package Name:
nsbp-cli - Bin Command:
nsbp(install globally and runnsbp --help) - Version:
0.2.52 - Dependencies: chalk, commander, fs-extra, inquirer
- Package Manager: Uses pnpm (also compatible with npm)
- Node Version: >=16.0.0
License
MIT
