@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
83 lines (71 loc) โข 2.83 kB
JavaScript
/**
* 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();