Skip to content

Commit d0ca9f9

Browse files
committed
chore: update build script
1 parent b33a509 commit d0ca9f9

File tree

3 files changed

+95
-132
lines changed

3 files changed

+95
-132
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@fecommunity/reactpress",
33
"author": "fecommunity",
4-
"version": "2.0.0",
4+
"version": "2.0.0-beta.0",
55
"description": "ReactPress - A full-stack CMS built with React, Next.js, and NestJS",
66
"keywords": [
77
"reactpress",
@@ -13,10 +13,13 @@
1313
"typescript"
1414
],
1515
"bin": {
16-
"reactpress": "./bin/reactpress.js",
16+
"reactpress": "./scripts/reactpress.js",
1717
"reactpress-server": "./scripts/reactpress-server.js",
1818
"reactpress-client": "./client/bin/reactpress-client.js"
1919
},
20+
"publishConfig": {
21+
"access": "public"
22+
},
2023
"files": [
2124
"bin/**/*",
2225
"scripts/**/*",

scripts/reactpress-server-old.js

Lines changed: 0 additions & 130 deletions
This file was deleted.

scripts/reactpress.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* ReactPress CLI - Main entry point for all ReactPress commands
5+
* This script allows users to run reactpress commands after installing the package globally
6+
*/
7+
8+
const { Command } = require('commander');
9+
const { spawn } = require('child_process');
10+
const path = require('path');
11+
const chalk = require('chalk');
12+
13+
// Create the CLI program
14+
const program = new Command();
15+
16+
// Get the directory where this script is located
17+
const binDir = __dirname;
18+
const rootDir = path.join(binDir, '..');
19+
20+
// Server command
21+
program
22+
.command('server')
23+
.description('Manage the ReactPress server')
24+
.option('install', 'Launch the installation wizard')
25+
.option('start', 'Start the ReactPress server')
26+
.option('--pm2', 'Start server with PM2 process manager')
27+
.action((options) => {
28+
const serverScript = path.join(rootDir, 'scripts', 'reactpress-server.js');
29+
30+
let args = [];
31+
if (options.install) {
32+
args.push('install');
33+
} else if (options.start) {
34+
args.push('start');
35+
}
36+
37+
if (options.pm2) {
38+
args.push('--pm2');
39+
}
40+
41+
const serverProcess = spawn('node', [serverScript, ...args], {
42+
stdio: 'inherit'
43+
});
44+
45+
serverProcess.on('error', (error) => {
46+
console.error(chalk.red('[ReactPress CLI] Failed to start server:'), error);
47+
process.exit(1);
48+
});
49+
});
50+
51+
// Client command
52+
program
53+
.command('client')
54+
.description('Manage the ReactPress client')
55+
.option('--pm2', 'Start client with PM2 process manager')
56+
.action((options) => {
57+
const clientScript = path.join(rootDir, 'client', 'bin', 'reactpress-client.js');
58+
59+
let args = [];
60+
if (options.pm2) {
61+
args.push('--pm2');
62+
}
63+
64+
const clientProcess = spawn('node', [clientScript, ...args], {
65+
stdio: 'inherit'
66+
});
67+
68+
clientProcess.on('error', (error) => {
69+
console.error(chalk.red('[ReactPress CLI] Failed to start client:'), error);
70+
process.exit(1);
71+
});
72+
});
73+
74+
// Set the version from package.json
75+
const packageJson = require(path.join(rootDir, 'package.json'));
76+
program.version(packageJson.version);
77+
78+
// Configure help text
79+
program.on('--help', () => {
80+
console.log('');
81+
console.log('For more information, visit: https://github.com/fecommunity/reactpress');
82+
});
83+
84+
// Parse the command line arguments
85+
program.parse(process.argv);
86+
87+
// If no command is provided, show help
88+
if (!process.argv.slice(2).length) {
89+
program.outputHelp();
90+
}

0 commit comments

Comments
 (0)