@fecommunity/reactpress-server 1.0.0-beta.3 → 1.0.0-beta.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.
@@ -42,113 +42,40 @@ 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()}
115
-
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}
123
-
124
- # Server Configuration
125
- SERVER_PORT=${config.SERVER_PORT}
126
- SERVER_API_PREFIX=/api
127
-
128
- # Security
129
- JWT_SECRET=${config.JWT_SECRET}
130
- ADMIN_USER=${config.ADMIN_USER}
131
- ADMIN_PASSWD=${config.ADMIN_PASSWD}
45
+ // 使用最小化配置模板,只包含数据库基础配置
46
+ console.log(chalk.cyan('📋 Creating minimal configuration file...\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 = `DB_HOST=127.0.0.1
54
+ DB_PORT=3306
55
+ DB_USER=reactpress
56
+ DB_PASSWD=reactpress
57
+ DB_DATABASE=reactpress
132
58
 
133
- # Environment
134
- NODE_ENV=development
59
+ JWT_SECRET=${jwtSecret}
135
60
  `;
136
61
 
137
62
  fs.writeFileSync(envPath, envContent);
138
63
  console.log(chalk.green('✅ Configuration saved to .env file'));
139
64
 
140
65
  if (!options.skipDbSetup) {
141
- console.log(chalk.yellow('\n🗄️ Setting up database...'));
66
+ console.log(chalk.yellow('\n🗄️ Database setup:'));
142
67
  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'));
68
+ console.log(chalk.cyan(`CREATE DATABASE reactpress;`));
69
+ console.log(chalk.gray(`CREATE USER 'reactpress'@'localhost' IDENTIFIED BY 'reactpress';`));
70
+ console.log(chalk.gray(`GRANT ALL PRIVILEGES ON reactpress.* TO 'reactpress'@'localhost';`));
71
+ console.log(chalk.gray(`FLUSH PRIVILEGES;`));
145
72
  }
146
73
 
147
74
  console.log(chalk.green('\n🎉 ReactPress Server initialized successfully!'));
148
75
  console.log(chalk.cyan('\nNext steps:'));
149
76
  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)'));
77
+ console.log(chalk.gray('2. Visit API: http://localhost:' + options.port + '/api'));
78
+ console.log(chalk.gray('3. API docs: http://localhost:' + options.port + '/api (Swagger UI)'));
152
79
  });
153
80
 
154
81
  // Start command - 启动服务器
@@ -224,8 +151,8 @@ program
224
151
  env
225
152
  });
226
153
  } else {
227
- console.log(chalk.yellow('⚠️ Development mode requires server source code'));
228
- console.log(chalk.cyan('Starting in production mode instead...'));
154
+ console.log(chalk.yellow('⚠️ Development mode using built server (source code not available)'));
155
+ console.log(chalk.cyan('Starting server with NODE_ENV=development...'));
229
156
  execSync(`node ${serverMainPath}`, {
230
157
  cwd: process.cwd(),
231
158
  stdio: 'inherit',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fecommunity/reactpress-server",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.5",
4
4
  "description": "ReactPress Server - NestJS-based backend API for ReactPress CMS",
5
5
  "author": "fecommunity",
6
6
  "license": "MIT",