@fecommunity/reactpress 2.0.0-beta-4-beta.1
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/CONTRIBUTING.md +122 -0
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/client/bin/reactpress-client.js +190 -0
- package/package.json +92 -0
- package/scripts/reactpress-cli.js +90 -0
- package/scripts/reactpress-deploy.sh +47 -0
- package/scripts/reactpress-dev.js +39 -0
- package/scripts/reactpress-publish.js +945 -0
- package/scripts/reactpress.js +90 -0
- package/server/bin/reactpress-server.js +203 -0
|
@@ -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,0 +1,47 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Exit on any error
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
# Logging function
|
|
7
|
+
log() {
|
|
8
|
+
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
# Error handling
|
|
12
|
+
error_exit() {
|
|
13
|
+
log "ERROR: $1"
|
|
14
|
+
exit 1
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
log "Starting deployment process..."
|
|
18
|
+
|
|
19
|
+
# Update code
|
|
20
|
+
log "Updating code from repository..."
|
|
21
|
+
git checkout master || error_exit "Failed to checkout master branch"
|
|
22
|
+
git pull || error_exit "Failed to pull latest changes"
|
|
23
|
+
|
|
24
|
+
# Install dependencies
|
|
25
|
+
log "Installing dependencies..."
|
|
26
|
+
pnpm install || error_exit "Failed to install dependencies"
|
|
27
|
+
|
|
28
|
+
# Build all packages using the unified build command
|
|
29
|
+
log "Building all packages..."
|
|
30
|
+
pnpm run build || error_exit "Failed to build packages"
|
|
31
|
+
|
|
32
|
+
# Kill existing PM2 processes
|
|
33
|
+
log "Stopping existing PM2 processes..."
|
|
34
|
+
pm2 kill || log "No existing PM2 processes found"
|
|
35
|
+
|
|
36
|
+
# Start services with PM2
|
|
37
|
+
log "Starting services with PM2..."
|
|
38
|
+
pnpm run pm2 || error_exit "Failed to start services with PM2"
|
|
39
|
+
|
|
40
|
+
# Set up PM2 startup script
|
|
41
|
+
log "Setting up PM2 startup script..."
|
|
42
|
+
pm2 startup || log "Failed to setup PM2 startup script"
|
|
43
|
+
pm2 save || error_exit "Failed to save PM2 configuration"
|
|
44
|
+
|
|
45
|
+
log "Deployment completed successfully!"
|
|
46
|
+
|
|
47
|
+
exit 0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// scripts/dev.js
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
// 获取当前工作目录
|
|
6
|
+
const currentWorkingDir = process.cwd();
|
|
7
|
+
|
|
8
|
+
// 设置环境变量
|
|
9
|
+
process.env.REACTPRESS_ORIGINAL_CWD = currentWorkingDir;
|
|
10
|
+
|
|
11
|
+
console.log(`设置 REACTPRESS_ORIGINAL_CWD: ${currentWorkingDir}`);
|
|
12
|
+
|
|
13
|
+
// 执行构建命令
|
|
14
|
+
const build = spawn('pnpm', ['build:toolkit'], {
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
shell: true
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
build.on('close', (code) => {
|
|
20
|
+
if (code !== 0) {
|
|
21
|
+
console.error(`构建失败,退出码: ${code}`);
|
|
22
|
+
process.exit(code);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 执行并发命令
|
|
26
|
+
const concurrently = spawn('npx', [
|
|
27
|
+
'concurrently',
|
|
28
|
+
'pnpm:dev:server',
|
|
29
|
+
'pnpm:dev:client'
|
|
30
|
+
], {
|
|
31
|
+
stdio: 'inherit',
|
|
32
|
+
shell: true,
|
|
33
|
+
cwd: currentWorkingDir
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
concurrently.on('close', (code) => {
|
|
37
|
+
process.exit(code);
|
|
38
|
+
});
|
|
39
|
+
});
|