collabdocchat 2.0.6 → 2.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",
@@ -0,0 +1,71 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ // 递归查找所有 .js 文件
9
+ function findJsFiles(dir, fileList = []) {
10
+ const files = fs.readdirSync(dir);
11
+
12
+ files.forEach(file => {
13
+ const filePath = path.join(dir, file);
14
+ const stat = fs.statSync(filePath);
15
+
16
+ if (stat.isDirectory()) {
17
+ if (file !== 'node_modules' && file !== '.git') {
18
+ findJsFiles(filePath, fileList);
19
+ }
20
+ } else if (file.endsWith('.js')) {
21
+ fileList.push(filePath);
22
+ }
23
+ });
24
+
25
+ return fileList;
26
+ }
27
+
28
+ // 替换文件中的端口
29
+ function replacePort(filePath) {
30
+ try {
31
+ let content = fs.readFileSync(filePath, 'utf8');
32
+ const originalContent = content;
33
+
34
+ // 替换所有 8765 端口为 3000
35
+ content = content.replace(/http:\/\/localhost:8765/g, 'http://localhost:3000');
36
+ content = content.replace(/ws:\/\/localhost:8765/g, 'ws://localhost:3000');
37
+
38
+ if (content !== originalContent) {
39
+ fs.writeFileSync(filePath, content, 'utf8');
40
+ console.log(`✅ 已修复: ${filePath}`);
41
+ return true;
42
+ }
43
+ return false;
44
+ } catch (error) {
45
+ console.error(`❌ 处理失败: ${filePath}`, error.message);
46
+ return false;
47
+ }
48
+ }
49
+
50
+ // 主函数
51
+ function main() {
52
+ console.log('🔍 开始扫描并修复端口配置...\n');
53
+
54
+ const projectRoot = path.join(__dirname, '..');
55
+ const srcDir = path.join(projectRoot, 'src');
56
+ const jsFiles = findJsFiles(srcDir);
57
+
58
+ console.log(`📁 找到 ${jsFiles.length} 个 JavaScript 文件\n`);
59
+
60
+ let fixedCount = 0;
61
+ jsFiles.forEach(file => {
62
+ if (replacePort(file)) {
63
+ fixedCount++;
64
+ }
65
+ });
66
+
67
+ console.log(`\n✅ 修复完成!共修复 ${fixedCount} 个文件`);
68
+ }
69
+
70
+ main();
71
+