recoder-crystal/scripts/test-license-generation.js
2025-06-16 15:22:30 -04:00

75 lines
2.1 KiB
JavaScript
Executable File
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.

#!/usr/bin/env node
/**
* Test script to verify license generation works correctly
*/
const fs = require('fs');
const path = require('path');
const { generateNotices } = require('./generate-notices');
console.log('Testing license generation...\n');
// List some key production dependencies we expect to find
const expectedPackages = [
'@anthropic-ai/claude-code',
'@anthropic-ai/sdk',
'better-sqlite3',
'electron-updater',
'react',
'react-dom',
'zustand',
'@xterm/xterm'
];
// Check if node_modules exists
const nodeModulesExists = fs.existsSync(path.join(__dirname, '..', 'node_modules'));
if (!nodeModulesExists) {
console.log('โš ๏ธ Warning: node_modules not found. Run "pnpm install" first.\n');
}
// Run the generation
try {
const startTime = Date.now();
const notices = generateNotices();
const duration = Date.now() - startTime;
console.log(`\nโœ… Generation completed in ${duration}ms`);
// Check results
const packageCount = (notices.match(/Package:/g) || []).length;
console.log(`\n๐Ÿ“ฆ Total packages found: ${packageCount}`);
if (nodeModulesExists) {
console.log('\n๐Ÿ” Checking for expected packages:');
for (const pkg of expectedPackages) {
if (notices.includes(`Package: ${pkg}`)) {
console.log(` โœ… ${pkg}`);
} else {
console.log(` โŒ ${pkg} (not found)`);
}
}
}
// Check for potential issues
console.log('\nโš ๏ธ Checking for potential issues:');
const missingLicenses = notices.match(/No license found for: .+/g) || [];
if (missingLicenses.length > 0) {
console.log(` - ${missingLicenses.length} packages missing license information`);
} else {
console.log(' - All packages have license information โœ…');
}
// Check file size
const noticesPath = path.join(__dirname, '..', 'NOTICES');
if (fs.existsSync(noticesPath)) {
const stats = fs.statSync(noticesPath);
console.log(`\n๐Ÿ“„ NOTICES file size: ${(stats.size / 1024).toFixed(2)} KB`);
}
console.log('\nโœ… Test completed successfully!');
} catch (error) {
console.error('\nโŒ Test failed:', error);
process.exit(1);
}