@fecommunity/reactpress-server 1.0.0-beta.20 → 1.0.0-beta.21
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/bin/reactpress-server.js +45 -0
- package/package.json +4 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ReactPress Server CLI Entry Point
|
|
5
|
+
* This script allows starting the ReactPress server via npx
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
|
|
11
|
+
// Get the directory where this script is located
|
|
12
|
+
const binDir = __dirname;
|
|
13
|
+
const serverDir = path.join(binDir, '..');
|
|
14
|
+
const distPath = path.join(serverDir, 'dist', 'main.js');
|
|
15
|
+
|
|
16
|
+
// Check if the server is built
|
|
17
|
+
if (!fs.existsSync(distPath)) {
|
|
18
|
+
console.log('[ReactPress Server] Server not built yet. Building...');
|
|
19
|
+
|
|
20
|
+
// Try to build the server
|
|
21
|
+
const { spawnSync } = require('child_process');
|
|
22
|
+
const buildResult = spawnSync('npm', ['run', 'build'], {
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
cwd: serverDir
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (buildResult.status !== 0) {
|
|
28
|
+
console.error('[ReactPress Server] Failed to build server');
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Change to the server directory
|
|
34
|
+
process.chdir(serverDir);
|
|
35
|
+
|
|
36
|
+
// Set environment variables
|
|
37
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
38
|
+
|
|
39
|
+
// Import and run the server
|
|
40
|
+
try {
|
|
41
|
+
require(distPath);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('[ReactPress Server] Failed to start server:', error);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fecommunity/reactpress-server",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
4
4
|
"description": "ReactPress Server - NestJS-based backend API for ReactPress CMS",
|
|
5
5
|
"author": "fecommunity",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/main.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"reactpress-server": "./bin/reactpress-server.js"
|
|
11
|
+
},
|
|
9
12
|
"files": [
|
|
10
13
|
"dist/**/*",
|
|
11
14
|
"public/**/*",
|