@fecommunity/reactpress-server 1.0.0-beta.2 → 1.0.0-beta.4

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.
@@ -42,93 +42,35 @@ program
42
42
  }
43
43
  }
44
44
 
45
- // 收集配置信息
46
- console.log(chalk.cyan('📋 Please provide the following configuration:\n'));
47
-
48
- const config = await inquirer.prompt([
49
- {
50
- type: 'input',
51
- name: 'DB_HOST',
52
- message: 'Database host:',
53
- default: 'localhost'
54
- },
55
- {
56
- type: 'input',
57
- name: 'DB_PORT',
58
- message: 'Database port:',
59
- default: options.database === 'postgres' ? '5432' : '3306'
60
- },
61
- {
62
- type: 'input',
63
- name: 'DB_USERNAME',
64
- message: 'Database username:',
65
- default: 'root'
66
- },
67
- {
68
- type: 'password',
69
- name: 'DB_PASSWORD',
70
- message: 'Database password:',
71
- mask: '*'
72
- },
73
- {
74
- type: 'input',
75
- name: 'DB_DATABASE',
76
- message: 'Database name:',
77
- default: 'reactpress'
78
- },
79
- {
80
- type: 'input',
81
- name: 'SERVER_PORT',
82
- message: 'Server port:',
83
- default: options.port
84
- },
85
- {
86
- type: 'input',
87
- name: 'JWT_SECRET',
88
- message: 'JWT secret (leave empty to generate):',
89
- default: ''
90
- },
91
- {
92
- type: 'input',
93
- name: 'ADMIN_USER',
94
- message: 'Admin username:',
95
- default: 'admin'
96
- },
97
- {
98
- type: 'password',
99
- name: 'ADMIN_PASSWD',
100
- message: 'Admin password:',
101
- default: 'admin',
102
- mask: '*'
103
- }
104
- ]);
105
-
106
- // 如果没有提供JWT密钥则生成一个
107
- if (!config.JWT_SECRET) {
108
- config.JWT_SECRET = require('crypto').randomBytes(32).toString('hex');
109
- console.log(chalk.green('🔐 Generated JWT secret'));
110
- }
111
-
112
- // 创建.env文件
113
- const envContent = `# ReactPress Server Configuration
114
- # Generated on ${new Date().toISOString()}
45
+ // 使用基础配置模板,基于根目录的.env文件
46
+ console.log(chalk.cyan('📋 Creating configuration file based on default template...\n'));
47
+
48
+ // 生成JWT密钥
49
+ const jwtSecret = require('crypto').randomBytes(32).toString('hex');
50
+ console.log(chalk.green('🔐 Generated JWT secret'));
51
+
52
+ // 创建.env文件 - 基于根目录模板
53
+ const envContent = `# Database Config
54
+ DB_HOST=127.0.0.1
55
+ DB_PORT=3306
56
+ DB_USER=reactpress
57
+ DB_PASSWD=reactpress
58
+ DB_DATABASE=reactpress
59
+
60
+ # JWT Secret
61
+ JWT_SECRET=${jwtSecret}
115
62
 
116
- # Database Configuration
117
- DB_TYPE=${options.database}
118
- DB_HOST=${config.DB_HOST}
119
- DB_PORT=${config.DB_PORT}
120
- DB_USERNAME=${config.DB_USERNAME}
121
- DB_PASSWORD=${config.DB_PASSWORD}
122
- DB_DATABASE=${config.DB_DATABASE}
63
+ # Client Config
64
+ CLIENT_SITE_URL=http://localhost:3001
123
65
 
124
- # Server Configuration
125
- SERVER_PORT=${config.SERVER_PORT}
66
+ # Server Config
67
+ SERVER_SITE_URL=http://localhost:${options.port}
68
+ SERVER_PORT=${options.port}
126
69
  SERVER_API_PREFIX=/api
127
70
 
128
- # Security
129
- JWT_SECRET=${config.JWT_SECRET}
130
- ADMIN_USER=${config.ADMIN_USER}
131
- ADMIN_PASSWD=${config.ADMIN_PASSWD}
71
+ # Admin Config
72
+ ADMIN_USER=admin
73
+ ADMIN_PASSWD=admin
132
74
 
133
75
  # Environment
134
76
  NODE_ENV=development
@@ -138,17 +80,19 @@ NODE_ENV=development
138
80
  console.log(chalk.green('✅ Configuration saved to .env file'));
139
81
 
140
82
  if (!options.skipDbSetup) {
141
- console.log(chalk.yellow('\n🗄️ Setting up database...'));
83
+ console.log(chalk.yellow('\n🗄️ Database setup:'));
142
84
  console.log(chalk.gray(`Please ensure your ${options.database} server is running and create the database:`));
143
- console.log(chalk.cyan(`CREATE DATABASE ${config.DB_DATABASE};`));
144
- console.log(chalk.gray('Then run: npx @reactpress/server start'));
85
+ console.log(chalk.cyan(`CREATE DATABASE reactpress;`));
86
+ console.log(chalk.gray(`CREATE USER 'reactpress'@'localhost' IDENTIFIED BY 'reactpress';`));
87
+ console.log(chalk.gray(`GRANT ALL PRIVILEGES ON reactpress.* TO 'reactpress'@'localhost';`));
88
+ console.log(chalk.gray(`FLUSH PRIVILEGES;`));
145
89
  }
146
90
 
147
91
  console.log(chalk.green('\n🎉 ReactPress Server initialized successfully!'));
148
92
  console.log(chalk.cyan('\nNext steps:'));
149
93
  console.log(chalk.gray('1. Start the server: npx @fecommunity/reactpress-server start'));
150
- console.log(chalk.gray('2. Visit API: http://localhost:' + config.SERVER_PORT + '/api'));
151
- console.log(chalk.gray('3. API docs: http://localhost:' + config.SERVER_PORT + '/api (Swagger UI)'));
94
+ console.log(chalk.gray('2. Visit API: http://localhost:' + options.port + '/api'));
95
+ console.log(chalk.gray('3. API docs: http://localhost:' + options.port + '/api (Swagger UI)'));
152
96
  });
153
97
 
154
98
  // Start command - 启动服务器
@@ -224,8 +168,8 @@ program
224
168
  env
225
169
  });
226
170
  } else {
227
- console.log(chalk.yellow('⚠️ Development mode requires server source code'));
228
- console.log(chalk.cyan('Starting in production mode instead...'));
171
+ console.log(chalk.yellow('⚠️ Development mode using built server (source code not available)'));
172
+ console.log(chalk.cyan('Starting server with NODE_ENV=development...'));
229
173
  execSync(`node ${serverMainPath}`, {
230
174
  cwd: process.cwd(),
231
175
  stdio: 'inherit',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fecommunity/reactpress-server",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "ReactPress Server - NestJS-based backend API for ReactPress CMS",
5
5
  "author": "fecommunity",
6
6
  "license": "MIT",
@@ -96,7 +96,8 @@
96
96
  "segment": "^0.1.3",
97
97
  "swagger-ui-express": "^4.1.6",
98
98
  "typeorm": "^0.2.22",
99
- "ua-parser-js": "^0.7.28"
99
+ "ua-parser-js": "^0.7.28",
100
+ "open": "^8.2.1"
100
101
  },
101
102
  "devDependencies": {
102
103
  "@nestjs/cli": "^6.9.0",
@@ -122,8 +123,7 @@
122
123
  "ts-node": "^8.4.1",
123
124
  "tsconfig-paths": "^3.9.0",
124
125
  "tslint": "^5.20.0",
125
- "typescript": "~4.1.6",
126
- "open": "^8.2.1"
126
+ "typescript": "~4.1.6"
127
127
  },
128
128
  "jest": {
129
129
  "moduleFileExtensions": [