UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

83 lines (71 loc) โ€ข 2.83 kB
/** * Debug Generator - JavaScript version to test what's happening */ import fs from 'fs/promises'; import path from 'path'; // Simple test to check if we can write to the generated file async function testGenerator() { console.log('๐Ÿงช TESTING GENERATOR FUNCTIONALITY'); console.log('=================================='); const outputPath = path.join(process.cwd(), 'src/generated/fields.generated.ts'); try { // Test 1: Can we read the current file? console.log('๐Ÿ“– Test 1: Reading current file...'); const currentContent = await fs.readFile(outputPath, 'utf-8'); const timestampMatch = currentContent.match(/Generated at: (.+)/); console.log('โœ… Current timestamp:', timestampMatch ? timestampMatch[1] : 'Not found'); // Test 2: Can we write to the file? console.log('๐Ÿ“ Test 2: Testing file write...'); const testContent = `/** * AUTO-GENERATED FILE - DO NOT EDIT * Generated from: https://api.optimizely.com/v2/swagger.json * Generated at: ${new Date().toISOString()} * * DEBUG TEST - This file was updated by debug script */ export const FIELDS = { // TEST CONTENT - Debug generator ran successfully test: { required: ["debug"], optional: ["test"], defaults: {}, enums: {}, fieldTypes: {}, fieldDescriptions: { "debug": "This proves the generator can write files" }, fieldExamples: { "debug": "Test example" }, endpoints: {}, validation: {} } } as const; export type EntityName = keyof typeof FIELDS; `; await fs.writeFile(outputPath, testContent, 'utf-8'); console.log('โœ… File write successful!'); // Test 3: Verify the write worked console.log('๐Ÿ” Test 3: Verifying write...'); const newContent = await fs.readFile(outputPath, 'utf-8'); const newTimestampMatch = newContent.match(/Generated at: (.+)/); console.log('โœ… New timestamp:', newTimestampMatch ? newTimestampMatch[1] : 'Not found'); if (newContent.includes('DEBUG TEST')) { console.log('๐ŸŽ‰ SUCCESS: File write and read working correctly!'); console.log('๐Ÿ“‹ This means the generator SHOULD be able to write files.'); console.log('๐Ÿ“‹ The issue is either:'); console.log(' 1. The TypeScript generator is not running at all'); console.log(' 2. The TypeScript generator is throwing silent errors'); console.log(' 3. Some other process is overriding the file'); } else { console.log('โŒ FAILED: File write did not work as expected'); } } catch (error) { console.error('โŒ ERROR:', error.message); console.log('๐Ÿ“‹ Possible issues:'); console.log(' - File permissions'); console.log(' - Directory does not exist'); console.log(' - File is locked by another process'); } } testGenerator();