nsbp-cli 0.2.3 → 0.2.5

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/README.md CHANGED
@@ -4,149 +4,152 @@ Command-line interface for creating NSBP (Node React SSR by Webpack) projects.
4
4
 
5
5
  📦 **Published on npm**: [https://www.npmjs.com/package/nsbp-cli](https://www.npmjs.com/package/nsbp-cli)
6
6
 
7
- ## Installation from npm
7
+ ## Installation
8
8
 
9
- Install globally from npm registry:
10
-
11
- \`\`\`bash
12
- # Install globally
9
+ ### Global Installation (npm)
10
+ ```bash
13
11
  npm install -g nsbp-cli
12
+ ```
14
13
 
15
- # Or use npx (no installation required)
14
+ ### Using npx (No Installation)
15
+ ```bash
16
16
  npx nsbp-cli create my-app
17
+ ```
17
18
 
18
- # Verify installation
19
- nsbp-cli --version
20
- \`\`\`
21
-
22
- ## Local Usage
19
+ ### Verify Installation
20
+ ```bash
21
+ nsbp --version
22
+ ```
23
23
 
24
- The CLI is also located in \`cli/\` directory of the NSBP project. Run it locally for development:
25
-
26
- \`\`\`bash
27
- # Navigate to CLI directory
28
- cd cli
24
+ ## Quick Start
29
25
 
30
- # Show help
31
- node ./bin/nsbp-cli.js --help
26
+ Create a new NSBP project with a single command:
32
27
 
33
- # Show NSBP information
34
- node ./bin/nsbp-cli.js info
28
+ ```bash
29
+ nsbp create my-app
30
+ cd my-app
31
+ pnpm install # NSBP CLI uses pnpm as package manager
32
+ pnpm run dev
33
+ ```
35
34
 
36
- # Create a new project
37
- node ./bin/nsbp-cli.js create my-app
35
+ For development with Docker (recommended):
36
+ ```bash
37
+ cd my-app
38
+ make dev # Starts development environment with hot reload
39
+ ```
38
40
 
39
- # Skip npm install
40
- node ./bin/nsbp-cli.js create my-app --skip-install
41
- \`\`\`
41
+ ## Command Reference
42
42
 
43
- ## Usage
43
+ ### Create a New Project
44
+ ```bash
45
+ nsbp create <app-name> [options]
44
46
 
45
- ### Create a new project
46
-
47
- \`\`\`bash
48
- # From npm (after global install)
49
- nsbp-cli create my-app
50
-
51
- # From npx
52
- npx nsbp-cli create my-app
47
+ # Examples
48
+ nsbp create my-app
49
+ nsbp create my-app --skip-install # Skip npm install
50
+ nsbp create my-app --template basic # Specify template (basic is default)
51
+ ```
53
52
 
54
- # From local CLI directory
55
- node ./bin/nsbp-cli.js create my-app
53
+ ### Display Framework Information
54
+ ```bash
55
+ nsbp info
56
+ ```
56
57
 
57
- # Skip npm install
58
- nsbp-cli create my-app --skip-install
58
+ ### Help
59
+ ```bash
60
+ nsbp --help # Show all commands
61
+ nsbp create --help # Show create command options
62
+ ```
59
63
 
60
- # Specify template (currently only basic is available)
61
- nsbp-cli create my-app --template basic
62
- \`\`\`
64
+ ## Templates
63
65
 
64
- ### Display information
66
+ The CLI provides project templates to get started quickly:
65
67
 
66
- \`\`\`bash
67
- # Show NSBP framework information
68
- nsbp-cli info
69
- \`\`\`
68
+ - **basic** (default) - Complete NSBP stack with React SSR, TypeScript, and Webpack
69
+ - Includes full Docker support for development and production
70
+ - Pre-configured with Makefile for easy Docker operations
71
+ - Ready-to-use project structure
70
72
 
71
- ### Help
73
+ - **blog** - Blog-focused template with article layouts (coming soon)
74
+ - **ecommerce** - E-commerce template with product pages (coming soon)
72
75
 
73
- \`\`\`bash
74
- # Show all commands
75
- nsbp-cli --help
76
+ ## Docker Support
76
77
 
77
- # Show create command help
78
- nsbp-cli create --help
79
- \`\`\`
78
+ The **basic** template includes comprehensive Docker configuration:
80
79
 
81
- ## Templates
80
+ ### Docker Files Included
81
+ - `.dockerignore` - Docker build ignore rules
82
+ - `docker-compose.yml` - Production environment configuration
83
+ - `docker-compose.dev.yml` - Development environment with hot reload
84
+ - `Dockerfile` - Multi-stage production build
85
+ - `Dockerfile.dev` - Development build
86
+ - `Makefile` - Convenient Docker commands
82
87
 
83
- - **basic**: Default template with core NSBP features (currently available)
84
- - **blog**: Blog-focused template with article layouts (coming soon)
85
- - **ecommerce**: E-commerce template with product pages (coming soon)
88
+ ### Available Make Commands
89
+ ```bash
90
+ make dev # Start development environment (hot reload)
91
+ make prod # Start production environment
92
+ make rebuild # Rebuild and restart production containers
93
+ make logs # View container logs
94
+ make down # Stop and remove containers
95
+ make shell # Open shell in production container
96
+ make shell-dev # Open shell in development container
97
+ ```
86
98
 
87
- ## How it works
99
+ ## How It Works
88
100
 
89
- The CLI copies 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.
101
+ 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.
90
102
 
91
103
  ## Template Synchronization
92
104
 
93
105
  The CLI includes a synchronization script that keeps built-in templates up-to-date with the main NSBP project code.
94
106
 
95
107
  ### Sync Script
96
- Location: \`cli/scripts/sync-template.js\`
108
+ Location: `cli/scripts/sync-template.js`
97
109
 
98
110
  ### Usage
99
- \`\`\`bash
100
- # From CLI directory
101
- cd /path/to/nsbp-cli/cli
102
-
103
- # Run sync script
104
- pnpm run sync-template
105
- # or
106
- npm run sync-template
107
-
108
- # Or use to update shortcut
109
- pnpm run update
110
- # or
111
- npm run update
112
- \`\`\`
111
+ ```bash
112
+ cd cli
113
+ pnpm run update # CLI项目使用pnpm,运行同步脚本
114
+ # 或者使用 npm run update(兼容)
115
+ ```
113
116
 
114
117
  ### Features
115
- - **Smart copying**: Copies only source code and configuration files
116
- - **Build artifact filtering**: Automatically excludes .js.map, .css.map, .txt, .json, and .LICENSE.txt files from the public directory
117
- - **Template transformation**: Converts main project's package.json to template format (name: "nsbp-cli-template")
118
- - **Integrity verification**: Checks for required files like src/Routers.tsx, scripts/start.js, and package.json
119
-
120
- ### What gets synchronized
121
- - \`src/\` - React components and routing
122
- - \`public/\` - Static assets (images, favicon.ico)
123
- - \`scripts/\` - Startup and utility scripts
124
- - \`webpack.*.js\` - Webpack configuration files
125
- - \`tsconfig.json\` - TypeScript configuration
126
- - \`postcss.config.js\` - PostCSS configuration
127
- - \`package.json\` - Project configuration (automatically templatized)
128
- - \`.gitignore\`, \`.prettierrc\`, \`.prettierignore\`, \`README.md\`
118
+ - **Smart copying** - Copies only source code and configuration files
119
+ - **Build artifact filtering** - Automatically excludes build artifacts from the public directory
120
+ - **Template transformation** - Converts main project's package.json to template format
121
+ - **Integrity verification** - Checks for required files before synchronization
122
+
123
+ ### Synchronized Files
124
+ - `src/` - React components and routing
125
+ - `public/` - Static assets
126
+ - `scripts/` - Startup and utility scripts
127
+ - `webpack.*.js` - Webpack configuration
128
+ - `tsconfig.json` - TypeScript configuration
129
+ - `postcss.config.js` - PostCSS configuration
130
+ - `package.json` - Project configuration (templatized)
131
+ - `.gitignore`, `.prettierrc`, `.prettierignore`, `README.md`
132
+ - **Docker files**: `.dockerignore`, `docker-compose.yml`, `docker-compose.dev.yml`, `Dockerfile`, `Dockerfile.dev`, `Makefile`
129
133
 
130
134
  ## Development
131
135
 
132
136
  To work on the CLI locally:
133
137
 
134
- \`\`\`bash
138
+ ```bash
135
139
  cd cli
136
- pnpm install
137
- # or
138
- npm install
139
- node ./bin/nsbp-cli.js create test-app
140
- \`\`\`
140
+ pnpm install # CLI项目使用pnpm作为包管理器
141
+ node ./bin/nsbp.js --help # Test CLI locally
142
+ ```
141
143
 
142
144
  ## Package Information
143
145
 
144
- - **Package Name**: \`nsbp-cli\`
145
- - **Bin Command**: \`nsbp-cli\`
146
- - **Version**: \`0.1.0\`
146
+ - **Package Name**: `nsbp-cli`
147
+ - **Bin Command**: `nsbp` (install globally and run `nsbp --help`)
148
+ - **Version**: `0.2.4`
147
149
  - **Dependencies**: chalk, commander, fs-extra, inquirer
148
- - **Package Manager**: Supports both npm and pnpm
150
+ - **Package Manager**: Uses pnpm (also compatible with npm)
151
+ - **Node Version**: >=16.0.0
149
152
 
150
153
  ## License
151
154
 
152
- ISC
155
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsbp-cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "CLI tool for creating NSBP (Node React SSR by Webpack) projects",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,4 +1,4 @@
1
- .PHONY: help build dev prod down clean logs restart publish-cli
1
+ .PHONY: help build dev prod down clean logs restart
2
2
 
3
3
  help: ## Show this help message
4
4
  @echo 'Usage: make [target]'
@@ -51,16 +51,4 @@ shell-dev: ## Open shell in development container
51
51
  docker-compose -f docker-compose.dev.yml exec app sh
52
52
 
53
53
  test: ## Run tests (if configured)
54
- docker-compose exec app npm test
55
-
56
- publish-cli: ## Publish CLI to npm registry
57
- @echo "🚀 Starting CLI publish process..."
58
- cd cli && npm run update
59
- @echo "📦 Template updated, committing changes..."
60
- git add .
61
- git diff --quiet && git diff --cached --quiet || git commit -m "chore: update cli template"
62
- cd cli && npm version patch
63
- cd cli && npm publish
64
- @echo "📤 Pushing to git repository..."
65
- git push --follow-tags
66
- @echo "✅ CLI published successfully!"
54
+ docker-compose exec app npm test
@@ -134,4 +134,14 @@ make rebuild-dev # 重新构建并启动开发环境
134
134
  可在 `docker-compose.yml` 或 `docker-compose.dev.yml` 中配置环境变量:
135
135
 
136
136
  - `NODE_ENV`: 运行环境 (production/development)
137
- - `PORT`: 服务端口 (默认 3001)
137
+ - `PORT`: 服务端口 (默认 3001)
138
+
139
+ ### CLI 发布
140
+
141
+ 从项目根目录发布 CLI 到 npm 注册表:
142
+
143
+ ```bash
144
+ make publish-cli # 同步模板、更新版本、发布到 npm
145
+ ```
146
+
147
+ 注意:此命令仅在项目根目录可用,生成的 NSBP 项目不包含此目标。