librats 0.3.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/README.md +405 -0
- package/binding.gyp +95 -0
- package/lib/index.d.ts +522 -0
- package/lib/index.js +82 -0
- package/package.json +68 -0
- package/scripts/build-librats.js +194 -0
- package/scripts/postinstall.js +52 -0
- package/scripts/prepare-package.js +91 -0
- package/scripts/verify-installation.js +119 -0
- package/src/librats_node.cpp +1174 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
|
|
8
|
+
// Determine platform
|
|
9
|
+
const isWindows = process.platform === 'win32';
|
|
10
|
+
const isMac = process.platform === 'darwin';
|
|
11
|
+
const isLinux = process.platform === 'linux';
|
|
12
|
+
|
|
13
|
+
// Paths
|
|
14
|
+
const nodejsRoot = path.resolve(__dirname, '..');
|
|
15
|
+
const projectRoot = path.resolve(__dirname, '..', '..');
|
|
16
|
+
const buildDir = path.resolve(nodejsRoot, 'build-native'); // Build dir inside nodejs/
|
|
17
|
+
const srcDir = path.resolve(projectRoot, 'src');
|
|
18
|
+
const cmakeLists = path.resolve(projectRoot, 'CMakeLists.txt');
|
|
19
|
+
|
|
20
|
+
console.log('Building librats native library...');
|
|
21
|
+
console.log(`Platform: ${process.platform}`);
|
|
22
|
+
console.log(`Project root: ${projectRoot}`);
|
|
23
|
+
console.log(`Build directory: ${buildDir}`);
|
|
24
|
+
|
|
25
|
+
// Check if CMake is installed
|
|
26
|
+
try {
|
|
27
|
+
execSync('cmake --version', { stdio: 'pipe' });
|
|
28
|
+
console.log('✓ CMake found');
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('\n❌ ERROR: CMake is not installed or not in PATH');
|
|
31
|
+
console.error('\nCMake is required to build librats.');
|
|
32
|
+
console.error('Please install CMake:');
|
|
33
|
+
if (isWindows) {
|
|
34
|
+
console.error(' - Download from: https://cmake.org/download/');
|
|
35
|
+
console.error(' - Or use: winget install Kitware.CMake');
|
|
36
|
+
console.error(' - Or use: choco install cmake');
|
|
37
|
+
} else if (isMac) {
|
|
38
|
+
console.error(' - Use Homebrew: brew install cmake');
|
|
39
|
+
console.error(' - Or download from: https://cmake.org/download/');
|
|
40
|
+
} else if (isLinux) {
|
|
41
|
+
console.error(' - Use: sudo apt install cmake');
|
|
42
|
+
console.error(' - Or: sudo yum install cmake');
|
|
43
|
+
console.error(' - Or download from: https://cmake.org/download/');
|
|
44
|
+
}
|
|
45
|
+
console.error('\nAfter installing CMake, run: npm install\n');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Check if CMakeLists.txt exists
|
|
50
|
+
if (!fs.existsSync(cmakeLists)) {
|
|
51
|
+
console.error('ERROR: CMakeLists.txt not found in project root.');
|
|
52
|
+
console.error('Make sure all source files are included in the npm package.');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Check if src directory exists
|
|
57
|
+
if (!fs.existsSync(srcDir)) {
|
|
58
|
+
console.error('ERROR: src directory not found.');
|
|
59
|
+
console.error('Make sure all source files are included in the npm package.');
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Create build directory if it doesn't exist
|
|
64
|
+
if (!fs.existsSync(buildDir)) {
|
|
65
|
+
console.log(`Creating build directory: ${buildDir}`);
|
|
66
|
+
fs.mkdirSync(buildDir, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Helper function to execute commands
|
|
70
|
+
function exec(command, options = {}) {
|
|
71
|
+
console.log(`> ${command}`);
|
|
72
|
+
try {
|
|
73
|
+
execSync(command, {
|
|
74
|
+
cwd: buildDir,
|
|
75
|
+
stdio: 'inherit',
|
|
76
|
+
...options
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error(`Command failed: ${command}`);
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
// Configure CMake with appropriate options
|
|
86
|
+
console.log('\nConfiguring CMake...');
|
|
87
|
+
|
|
88
|
+
let cmakeArgs = [
|
|
89
|
+
'-DRATS_BUILD_TESTS=OFF',
|
|
90
|
+
'-DRATS_BUILD_EXAMPLES=OFF',
|
|
91
|
+
'-DRATS_STATIC_LIBRARY=ON',
|
|
92
|
+
'-DRATS_BINDINGS=ON',
|
|
93
|
+
'-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL'
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
// Add platform-specific CMake arguments
|
|
97
|
+
if (isWindows) {
|
|
98
|
+
// Try to detect Visual Studio version
|
|
99
|
+
const vsVersions = ['2022', '2019', '2017'];
|
|
100
|
+
let generator = null;
|
|
101
|
+
|
|
102
|
+
for (const version of vsVersions) {
|
|
103
|
+
try {
|
|
104
|
+
execSync(`where "C:\\Program Files\\Microsoft Visual Studio\\${version}"`, { stdio: 'ignore' });
|
|
105
|
+
generator = `Visual Studio ${version === '2022' ? '17' : version === '2019' ? '16' : '15'} ${version}`;
|
|
106
|
+
break;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
// Try next version
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (generator) {
|
|
113
|
+
cmakeArgs.push(`-G "${generator}"`);
|
|
114
|
+
cmakeArgs.push('-A x64');
|
|
115
|
+
}
|
|
116
|
+
} else if (isMac) {
|
|
117
|
+
// Use Unix Makefiles on macOS
|
|
118
|
+
cmakeArgs.push('-G "Unix Makefiles"');
|
|
119
|
+
} else if (isLinux) {
|
|
120
|
+
// Use Unix Makefiles on Linux
|
|
121
|
+
cmakeArgs.push('-G "Unix Makefiles"');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const cmakeConfigCmd = `cmake ${cmakeArgs.join(' ')} ../..`;
|
|
125
|
+
exec(cmakeConfigCmd);
|
|
126
|
+
|
|
127
|
+
// Build the library
|
|
128
|
+
console.log('\nBuilding librats library...');
|
|
129
|
+
|
|
130
|
+
if (isWindows) {
|
|
131
|
+
// Build both Debug and Release configurations on Windows
|
|
132
|
+
exec('cmake --build . --config Debug --parallel');
|
|
133
|
+
exec('cmake --build . --config Release --parallel');
|
|
134
|
+
console.log('\nLibrats built successfully (Debug and Release)');
|
|
135
|
+
} else {
|
|
136
|
+
exec('cmake --build . -- -j4');
|
|
137
|
+
console.log('\nLibrats built successfully');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Verify the library was built
|
|
141
|
+
const expectedLibPaths = isWindows
|
|
142
|
+
? [
|
|
143
|
+
path.join(buildDir, 'lib', 'Debug', 'rats.lib'),
|
|
144
|
+
path.join(buildDir, 'lib', 'Release', 'rats.lib')
|
|
145
|
+
]
|
|
146
|
+
: [
|
|
147
|
+
path.join(buildDir, 'lib', 'librats.a')
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
console.log('\nBuild directory:', buildDir);
|
|
151
|
+
|
|
152
|
+
let foundLib = false;
|
|
153
|
+
for (const libPath of expectedLibPaths) {
|
|
154
|
+
if (fs.existsSync(libPath)) {
|
|
155
|
+
console.log(`✓ Found library: ${libPath}`);
|
|
156
|
+
foundLib = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!foundLib) {
|
|
161
|
+
console.warn('WARNING: Could not find built library files.');
|
|
162
|
+
console.warn('Expected paths:');
|
|
163
|
+
expectedLibPaths.forEach(p => console.warn(` - ${p}`));
|
|
164
|
+
console.warn('The build may have failed. Check the output above.');
|
|
165
|
+
// Don't exit with error - let node-gyp try anyway
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
console.log('\n✓ Librats build completed successfully!\n');
|
|
169
|
+
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error('\n✗ Failed to build librats library');
|
|
172
|
+
console.error('Error:', error.message);
|
|
173
|
+
|
|
174
|
+
// Provide helpful error messages
|
|
175
|
+
console.error('\nTroubleshooting:');
|
|
176
|
+
|
|
177
|
+
if (isWindows) {
|
|
178
|
+
console.error('- Ensure Visual Studio Build Tools or Visual Studio is installed');
|
|
179
|
+
console.error('- Download from: https://visualstudio.microsoft.com/downloads/');
|
|
180
|
+
console.error('- Or run: npm install --global windows-build-tools');
|
|
181
|
+
} else if (isMac) {
|
|
182
|
+
console.error('- Ensure Xcode Command Line Tools are installed');
|
|
183
|
+
console.error('- Run: xcode-select --install');
|
|
184
|
+
} else if (isLinux) {
|
|
185
|
+
console.error('- Ensure build-essential is installed');
|
|
186
|
+
console.error('- Run: sudo apt install build-essential cmake');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
console.error('- Ensure CMake is installed and available in PATH');
|
|
190
|
+
console.error('- CMake download: https://cmake.org/download/');
|
|
191
|
+
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
// Check if we're in a development install (node_modules doesn't contain librats)
|
|
7
|
+
const isDev = !__dirname.includes('node_modules');
|
|
8
|
+
|
|
9
|
+
if (isDev) {
|
|
10
|
+
console.log('\n✨ Development installation detected');
|
|
11
|
+
console.log(' Librats native addon has been built for local development\n');
|
|
12
|
+
} else {
|
|
13
|
+
console.log('\n✅ Librats installed successfully!');
|
|
14
|
+
console.log(' Native addon is ready to use\n');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Check if the addon was built successfully
|
|
18
|
+
const possiblePaths = [
|
|
19
|
+
path.join(__dirname, '..', 'build', 'Release', 'librats.node'),
|
|
20
|
+
path.join(__dirname, '..', 'build', 'Debug', 'librats.node'),
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
let addonFound = false;
|
|
24
|
+
for (const addonPath of possiblePaths) {
|
|
25
|
+
if (fs.existsSync(addonPath)) {
|
|
26
|
+
addonFound = true;
|
|
27
|
+
if (process.env.LIBRATS_DEBUG) {
|
|
28
|
+
console.log(` Native addon: ${addonPath}`);
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!addonFound) {
|
|
35
|
+
console.warn('⚠️ Warning: Native addon not found');
|
|
36
|
+
console.warn(' The build may have failed. Try running:');
|
|
37
|
+
console.warn(' npm rebuild librats\n');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Show quick start example
|
|
41
|
+
if (!process.env.CI && !process.env.npm_config_global) {
|
|
42
|
+
console.log('Verify installation:');
|
|
43
|
+
console.log(' npm run verify\n');
|
|
44
|
+
console.log('Quick start:');
|
|
45
|
+
console.log('```javascript');
|
|
46
|
+
console.log("const { RatsClient } = require('librats');");
|
|
47
|
+
console.log('const client = new RatsClient(8080);');
|
|
48
|
+
console.log('client.start();');
|
|
49
|
+
console.log('```\n');
|
|
50
|
+
console.log('Documentation: https://github.com/librats/librats/tree/main/nodejs\n');
|
|
51
|
+
}
|
|
52
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Prepare package script
|
|
8
|
+
*
|
|
9
|
+
* This script runs before packing and publishing to ensure the package
|
|
10
|
+
* is ready for distribution. It checks that all necessary files are present.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
console.log('Preparing package for distribution...');
|
|
14
|
+
|
|
15
|
+
const projectRoot = path.resolve(__dirname, '..', '..');
|
|
16
|
+
const nodejsRoot = path.resolve(__dirname, '..');
|
|
17
|
+
|
|
18
|
+
// Critical files that must be included in the package
|
|
19
|
+
const criticalFiles = [
|
|
20
|
+
// Node.js binding files
|
|
21
|
+
{ path: path.join(nodejsRoot, 'binding.gyp'), desc: 'Node.js binding configuration' },
|
|
22
|
+
{ path: path.join(nodejsRoot, 'lib', 'index.js'), desc: 'JavaScript wrapper' },
|
|
23
|
+
{ path: path.join(nodejsRoot, 'lib', 'index.d.ts'), desc: 'TypeScript definitions' },
|
|
24
|
+
{ path: path.join(nodejsRoot, 'src', 'librats_node.cpp'), desc: 'Node.js binding source' },
|
|
25
|
+
{ path: path.join(nodejsRoot, 'scripts', 'build-librats.js'), desc: 'Build script' },
|
|
26
|
+
{ path: path.join(nodejsRoot, 'scripts', 'postinstall.js'), desc: 'Post-install script' },
|
|
27
|
+
|
|
28
|
+
// Librats C++ library files
|
|
29
|
+
{ path: path.join(projectRoot, 'CMakeLists.txt'), desc: 'CMake configuration' },
|
|
30
|
+
{ path: path.join(projectRoot, 'src', 'librats.cpp'), desc: 'Librats main source' },
|
|
31
|
+
{ path: path.join(projectRoot, 'src', 'librats.h'), desc: 'Librats main header' },
|
|
32
|
+
{ path: path.join(projectRoot, 'src', 'librats_c.cpp'), desc: 'Librats C API' },
|
|
33
|
+
{ path: path.join(projectRoot, 'src', 'librats_c.h'), desc: 'Librats C API header' },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
let allFilesPresent = true;
|
|
37
|
+
let missingFiles = [];
|
|
38
|
+
|
|
39
|
+
console.log('\nChecking required files:');
|
|
40
|
+
for (const file of criticalFiles) {
|
|
41
|
+
if (fs.existsSync(file.path)) {
|
|
42
|
+
console.log(` ✓ ${file.desc}`);
|
|
43
|
+
} else {
|
|
44
|
+
console.log(` ✗ ${file.desc} - MISSING`);
|
|
45
|
+
allFilesPresent = false;
|
|
46
|
+
missingFiles.push(file);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!allFilesPresent) {
|
|
51
|
+
console.error('\n❌ ERROR: Some required files are missing!');
|
|
52
|
+
console.error('\nMissing files:');
|
|
53
|
+
missingFiles.forEach(file => {
|
|
54
|
+
console.error(` - ${file.path}`);
|
|
55
|
+
console.error(` (${file.desc})`);
|
|
56
|
+
});
|
|
57
|
+
console.error('\nThe package cannot be published without these files.');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Check that lib directory exists and has content
|
|
62
|
+
const libDir = path.join(nodejsRoot, 'lib');
|
|
63
|
+
if (!fs.existsSync(libDir)) {
|
|
64
|
+
console.error('\n❌ ERROR: lib directory does not exist!');
|
|
65
|
+
console.error('Create it with the JavaScript wrapper and TypeScript definitions.');
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Check that scripts directory exists
|
|
70
|
+
const scriptsDir = path.join(nodejsRoot, 'scripts');
|
|
71
|
+
if (!fs.existsSync(scriptsDir)) {
|
|
72
|
+
console.error('\n❌ ERROR: scripts directory does not exist!');
|
|
73
|
+
console.error('This directory is required for the build process.');
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Count source files
|
|
78
|
+
const srcDir = path.join(projectRoot, 'src');
|
|
79
|
+
if (fs.existsSync(srcDir)) {
|
|
80
|
+
const sourceFiles = fs.readdirSync(srcDir)
|
|
81
|
+
.filter(f => f.endsWith('.cpp') || f.endsWith('.h'));
|
|
82
|
+
console.log(`\n✓ Found ${sourceFiles.length} source files in src/`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log('\n✅ Package is ready for distribution!\n');
|
|
86
|
+
console.log('When users install this package via npm:');
|
|
87
|
+
console.log(' 1. The preinstall script will build the librats C++ library');
|
|
88
|
+
console.log(' 2. The install script will build the Node.js native addon');
|
|
89
|
+
console.log(' 3. The postinstall script will verify the installation');
|
|
90
|
+
console.log('\nNo manual build steps are required by users!\n');
|
|
91
|
+
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Installation Verification Script
|
|
5
|
+
*
|
|
6
|
+
* Checks if librats was installed correctly and all components are working.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
console.log('🔍 Verifying librats installation...\n');
|
|
13
|
+
|
|
14
|
+
let allChecksPassed = true;
|
|
15
|
+
|
|
16
|
+
// Check 1: Can we load the module?
|
|
17
|
+
console.log('1. Loading librats module...');
|
|
18
|
+
try {
|
|
19
|
+
const librats = require('../lib/index.js');
|
|
20
|
+
console.log(' ✅ Module loaded successfully\n');
|
|
21
|
+
|
|
22
|
+
// Check 2: Version info
|
|
23
|
+
console.log('2. Checking version info...');
|
|
24
|
+
try {
|
|
25
|
+
const versionString = librats.getVersionString();
|
|
26
|
+
const version = librats.getVersion();
|
|
27
|
+
console.log(` ✅ Version: ${versionString}`);
|
|
28
|
+
console.log(` ✅ Components: ${version.major}.${version.minor}.${version.patch}.${version.build}\n`);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.log(' ❌ Failed to get version info:', err.message);
|
|
31
|
+
allChecksPassed = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Check 3: Constants
|
|
35
|
+
console.log('3. Checking constants...');
|
|
36
|
+
try {
|
|
37
|
+
if (typeof librats.ConnectionStrategy.DIRECT_ONLY === 'number') {
|
|
38
|
+
console.log(' ✅ ConnectionStrategy constants defined');
|
|
39
|
+
}
|
|
40
|
+
if (typeof librats.ErrorCodes.SUCCESS === 'number') {
|
|
41
|
+
console.log(' ✅ ErrorCodes constants defined\n');
|
|
42
|
+
}
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.log(' ❌ Constants check failed:', err.message);
|
|
45
|
+
allChecksPassed = false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Check 4: Can we create a client?
|
|
49
|
+
console.log('4. Testing client creation...');
|
|
50
|
+
try {
|
|
51
|
+
const RatsClient = librats.RatsClient;
|
|
52
|
+
const testPort = 19999;
|
|
53
|
+
const client = new RatsClient(testPort);
|
|
54
|
+
console.log(' ✅ Client created successfully\n');
|
|
55
|
+
|
|
56
|
+
// Check 5: Can we start and stop?
|
|
57
|
+
console.log('5. Testing start/stop...');
|
|
58
|
+
try {
|
|
59
|
+
const started = client.start();
|
|
60
|
+
if (started) {
|
|
61
|
+
console.log(' ✅ Client started successfully');
|
|
62
|
+
|
|
63
|
+
const peerId = client.getOurPeerId();
|
|
64
|
+
if (peerId && typeof peerId === 'string') {
|
|
65
|
+
console.log(` ✅ Got peer ID: ${peerId}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const peerCount = client.getPeerCount();
|
|
69
|
+
console.log(` ✅ Peer count: ${peerCount}`);
|
|
70
|
+
|
|
71
|
+
client.stop();
|
|
72
|
+
console.log(' ✅ Client stopped successfully\n');
|
|
73
|
+
} else {
|
|
74
|
+
console.log(' ⚠️ Warning: Client failed to start (port may be in use)\n');
|
|
75
|
+
}
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.log(' ❌ Start/stop test failed:', err.message);
|
|
78
|
+
allChecksPassed = false;
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.log(' ❌ Client creation failed:', err.message);
|
|
82
|
+
allChecksPassed = false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Check 6: TypeScript definitions
|
|
86
|
+
console.log('6. Checking TypeScript definitions...');
|
|
87
|
+
const tsDefsPath = path.join(__dirname, '..', 'lib', 'index.d.ts');
|
|
88
|
+
if (fs.existsSync(tsDefsPath)) {
|
|
89
|
+
console.log(' ✅ TypeScript definitions found\n');
|
|
90
|
+
} else {
|
|
91
|
+
console.log(' ⚠️ Warning: TypeScript definitions not found\n');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.log(' ❌ Failed to load module:', err.message);
|
|
96
|
+
console.log('\nError details:');
|
|
97
|
+
console.log(err.stack);
|
|
98
|
+
allChecksPassed = false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Summary
|
|
102
|
+
console.log('━'.repeat(60));
|
|
103
|
+
if (allChecksPassed) {
|
|
104
|
+
console.log('✅ All checks passed! Librats is installed correctly.\n');
|
|
105
|
+
console.log('You can now use librats in your project:');
|
|
106
|
+
console.log(" const { RatsClient } = require('librats');");
|
|
107
|
+
console.log(' const client = new RatsClient(8080);');
|
|
108
|
+
console.log(' client.start();\n');
|
|
109
|
+
process.exit(0);
|
|
110
|
+
} else {
|
|
111
|
+
console.log('❌ Some checks failed. Installation may be incomplete.\n');
|
|
112
|
+
console.log('Troubleshooting:');
|
|
113
|
+
console.log(' 1. Try rebuilding: npm rebuild librats');
|
|
114
|
+
console.log(' 2. Check build tools are installed (CMake, C++ compiler)');
|
|
115
|
+
console.log(' 3. Check the logs above for specific errors');
|
|
116
|
+
console.log(' 4. See: https://github.com/librats/librats/tree/main/nodejs\n');
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|