collabdocchat 1.2.3 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +28 -12
  2. package/bin/cli.js +31 -47
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -21,30 +21,46 @@
21
21
 
22
22
  ## 🚀 快速开始
23
23
 
24
- ### 方式一:使用 npx (推荐)
24
+ ### 方式一:本地安装(推荐)
25
25
 
26
26
  ```bash
27
- npx collabdocchat
27
+ # 1. 安装包
28
+ npm install collabdocchat
29
+
30
+ # 2. 进入目录
31
+ cd node_modules/collabdocchat
32
+
33
+ # 3. 启动应用
34
+ npm start
28
35
  ```
29
36
 
30
- ### 方式二:全局安装
37
+ ### 方式二:克隆仓库
31
38
 
32
39
  ```bash
33
- # 全局安装
34
- npm install -g collabdocchat
40
+ # 1. 克隆项目
41
+ git clone https://github.com/shijinghao/collabdocchat.git
42
+ cd collabdocchat
35
43
 
36
- # 启动应用
37
- collabdocchat
44
+ # 2. 安装依赖
45
+ npm install
46
+
47
+ # 3. 启动应用
48
+ npm start
38
49
  ```
39
50
 
40
- ### 方式三:项目中使用
51
+ ### 方式三:使用安装脚本
41
52
 
53
+ **Windows:**
42
54
  ```bash
43
- # 安装到项目
44
- npm install collabdocchat
55
+ # 下载并运行
56
+ install-and-start.bat
57
+ ```
45
58
 
46
- # 启动
47
- npm start
59
+ **Linux/Mac:**
60
+ ```bash
61
+ # 下载并运行
62
+ chmod +x install-and-start.sh
63
+ ./install-and-start.sh
48
64
  ```
49
65
 
50
66
  ## 📋 系统要求
package/bin/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawn } from 'child_process';
3
+ import { spawn, exec } from 'child_process';
4
4
  import { platform } from 'os';
5
5
  import { fileURLToPath } from 'url';
6
6
  import { dirname, join } from 'path';
@@ -9,74 +9,58 @@ import { existsSync } from 'fs';
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = dirname(__filename);
11
11
  const rootDir = join(__dirname, '..');
12
- const CLIENT_URL = 'http://localhost:5173';
13
12
  const isWindows = platform() === 'win32';
14
13
 
15
- // 打开浏览器
16
- function openBrowser(url) {
17
- const command = isWindows ? 'cmd' : (platform() === 'darwin' ? 'open' : 'xdg-open');
18
- const args = isWindows ? ['/c', 'start', url] : [url];
19
- const browser = spawn(command, args, { stdio: 'ignore', detached: true });
20
- browser.unref();
21
- }
14
+ console.log('\n🎉 欢迎使用 CollabDocChat!\n');
15
+ console.log('📦 开源的实时协作文档聊天平台\n');
22
16
 
23
17
  // 检查是否在正确的目录
24
- function checkEnvironment() {
25
- const serverPath = join(rootDir, 'server', 'index.js');
26
- if (!existsSync(serverPath)) {
27
- console.error('❌ 错误:找不到服务器文件');
28
- console.error(' 请确保在正确的目录运行此命令');
29
- process.exit(1);
30
- }
18
+ const serverPath = join(rootDir, 'server', 'index.js');
19
+ if (!existsSync(serverPath)) {
20
+ console.error('❌ 错误:找不到服务器文件');
21
+ console.error(' 这个包需要在安装后的目录中运行');
22
+ console.error('\n💡 推荐使用方式:');
23
+ console.error(' 1. npm install collabdocchat');
24
+ console.error(' 2. cd node_modules/collabdocchat');
25
+ console.error(' 3. npm start');
26
+ console.error('\n 或者直接运行: npm start (在安装了 collabdocchat 的项目中)');
27
+ process.exit(1);
31
28
  }
32
29
 
33
- console.log('\n🎉 欢迎使用 CollabDocChat!\n');
34
- console.log('📦 开源的实时协作文档聊天平台\n');
35
- console.log('🚀 正在启动服务器和客户端...\n');
30
+ console.log('🚀 正在启动应用...\n');
36
31
 
37
- checkEnvironment();
38
-
39
- // 启动服务器
40
- const server = spawn('node', ['server/index.js'], {
32
+ // 使用 npm start 脚本来启动
33
+ const npmCmd = isWindows ? 'npm.cmd' : 'npm';
34
+ const startProcess = spawn(npmCmd, ['start'], {
41
35
  cwd: rootDir,
42
36
  stdio: 'inherit',
43
- detached: true,
44
- windowsHide: true
37
+ shell: true
45
38
  });
46
- server.unref();
47
39
 
48
- // 启动客户端
49
- const client = spawn(isWindows ? 'npm.cmd' : 'npm', ['run', 'client'], {
50
- cwd: rootDir,
51
- stdio: 'inherit',
52
- detached: true,
53
- windowsHide: true
40
+ startProcess.on('error', (error) => {
41
+ console.error(' 启动失败:', error.message);
42
+ console.error('\n💡 请尝试手动启动:');
43
+ console.error(` cd ${rootDir}`);
44
+ console.error(' npm start');
45
+ process.exit(1);
54
46
  });
55
- client.unref();
56
47
 
57
- // 8秒后打开浏览器
58
- setTimeout(() => {
59
- console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
60
- openBrowser(CLIENT_URL);
61
- console.log('\n✅ 应用已启动成功!');
62
- console.log(' 如果页面未加载,请稍等片刻后刷新页面。');
63
- console.log('\n💡 提示:');
64
- console.log(' • 服务器运行在: http://localhost:3000');
65
- console.log(' • 客户端运行在: http://localhost:5173');
66
- console.log(' • 默认管理员账号: admin / admin123');
67
- console.log('\n📖 更多信息请访问: https://github.com/shijinghao/collabdocchat');
68
- console.log('\n⚠️ 要停止服务,请运行: npm run stop');
69
- console.log(' 或者关闭终端窗口\n');
70
- }, 8000);
48
+ startProcess.on('exit', (code) => {
49
+ if (code !== 0) {
50
+ console.log(`\n⚠️ 进程退出,代码: ${code}`);
51
+ }
52
+ });
71
53
 
72
54
  // 处理退出信号
73
55
  process.on('SIGINT', () => {
74
56
  console.log('\n\n👋 正在关闭应用...');
57
+ startProcess.kill('SIGINT');
75
58
  process.exit(0);
76
59
  });
77
60
 
78
61
  process.on('SIGTERM', () => {
79
62
  console.log('\n\n👋 正在关闭应用...');
63
+ startProcess.kill('SIGTERM');
80
64
  process.exit(0);
81
65
  });
82
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",