ruvector/npm/core/test-package.cjs
rUv d242a428b4 feat: Configure npm packages for multi-platform publishing
Package Configuration:
-  Linux x64: Complete with binary and passing tests
-  macOS x64 (Intel): Package structure ready, awaiting binary
-  macOS ARM64 (Apple Silicon): Package structure ready, awaiting binary
- 🔧 Updated package.json files for all platforms
- 🔧 Created module loaders (index.js) for native bindings
- 🔧 Added README documentation for each platform

Testing:
-  Created comprehensive test suite (test-package.cjs)
-  All 4 test suites passing on linux-x64-gnu:
  - File structure verification
  - Native module loading
  - Database instance creation
  - Basic CRUD operations (insert, search, count, delete)

Documentation:
- 📚 docs/NPM_PUBLISHING.md - Complete publishing guide
- 📚 docs/NPM_READY_STATUS.md - Linux package verification
- 📚 docs/MACOS_PACKAGES_SETUP.md - macOS setup details
- 📚 docs/ALL_PACKAGES_STATUS.md - All packages status
- 📚 docs/CURRENT_STATUS.md - Overall project status

Changes:
- npm/core/platforms/linux-x64-gnu/: Binary + config + tests 
- npm/core/platforms/darwin-x64/: Config + loader + README 
- npm/core/platforms/darwin-arm64/: Config + loader + README 
- npm/core/test-package.cjs: Automated testing suite 

Next Steps:
- GitHub Actions will build darwin-x64 and darwin-arm64 binaries
- After builds complete: test, verify, and publish to npm

🚀 This commit triggers multi-platform builds via GitHub Actions
2025-11-21 16:24:50 +00:00

124 lines
3.6 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* Test script for @ruvector/core-linux-x64-gnu package
* Verifies that the native binary loads correctly
*/
const fs = require('fs');
const path = require('path');
console.log('🧪 Testing @ruvector/core-linux-x64-gnu package...\n');
// Test 1: Check files exist
console.log('📁 Test 1: Checking file structure...');
const platformDir = path.join(__dirname, 'platforms/linux-x64-gnu');
const requiredFiles = [
'index.js',
'ruvector.node',
'package.json',
'README.md'
];
let filesOk = true;
for (const file of requiredFiles) {
const filePath = path.join(platformDir, file);
if (fs.existsSync(filePath)) {
const stats = fs.statSync(filePath);
const size = stats.size > 1024 * 1024
? `${(stats.size / (1024 * 1024)).toFixed(2)} MB`
: `${(stats.size / 1024).toFixed(2)} KB`;
console.log(`${file} (${size})`);
} else {
console.log(`${file} - MISSING`);
filesOk = false;
}
}
if (!filesOk) {
console.error('\n❌ File structure test FAILED');
process.exit(1);
}
console.log('\n✅ File structure test PASSED\n');
// Test 2: Load native module
console.log('📦 Test 2: Loading native module...');
try {
const nativeModule = require(path.join(platformDir, 'index.js'));
console.log(' ✅ Native module loaded successfully');
console.log(' Module exports:', Object.keys(nativeModule).join(', '));
console.log('\n✅ Native module test PASSED\n');
} catch (error) {
console.error(' ❌ Failed to load native module:', error.message);
console.error('\n❌ Native module test FAILED');
process.exit(1);
}
// Test 3: Create database instance
console.log('🗄️ Test 3: Creating database instance...');
try {
const { VectorDb } = require(path.join(platformDir, 'index.js'));
const db = new VectorDb({
dimensions: 128,
maxElements: 1000,
storagePath: `/tmp/ruvector-test-${Date.now()}-1.db`
});
console.log(' ✅ Database instance created successfully');
console.log('\n✅ Database creation test PASSED\n');
} catch (error) {
console.error(' ❌ Failed to create database:', error.message);
console.error('\n❌ Database creation test FAILED');
process.exit(1);
}
// Test 4: Basic operations
console.log('🔧 Test 4: Testing basic operations...');
(async () => {
try {
const { VectorDb } = require(path.join(platformDir, 'index.js'));
const db = new VectorDb({
dimensions: 3,
maxElements: 100,
storagePath: `/tmp/ruvector-test-${Date.now()}-2.db`
});
// Insert vector
const vector = new Float32Array([0.1, 0.2, 0.3]);
const id = await db.insert({
id: 'test_vector',
vector: vector
});
console.log(` ✅ Inserted vector with ID: ${id}`);
// Count vectors
const count = await db.len();
console.log(` ✅ Vector count: ${count}`);
// Search
const queryVector = new Float32Array([0.1, 0.2, 0.3]);
const results = await db.search({
vector: queryVector,
k: 1
});
console.log(` ✅ Search returned ${results.length} result(s)`);
if (results.length > 0) {
console.log(` - ID: ${results[0].id}, Score: ${results[0].score.toFixed(6)}`);
}
// Delete
const deleted = await db.delete('test_vector');
console.log(` ✅ Deleted vector: ${deleted}`);
console.log('\n✅ Basic operations test PASSED\n');
console.log('🎉 All tests PASSED!\n');
console.log('Package is ready for publishing.');
} catch (error) {
console.error(' ❌ Basic operations failed:', error.message);
console.error(error.stack);
console.error('\n❌ Basic operations test FAILED');
process.exit(1);
}
})();