coolify-deploy-logs-cli
Version:
CLI tool for Coolify deployments
42 lines (31 loc) ⢠1.53 kB
JavaScript
const fs = require('fs');
// Read original file
const original = fs.readFileSync('index.js', 'utf8');
// Find and replace the problematic getEnvironment method
const originalMethod = /async getEnvironment\(\) \{[\s\S]*?\n \}/m;
const newMethod = `async getEnvironment() {
if (this.environmentId) {
console.log('\\nš Environment already set, skipping...');
return;
}
console.log('\\nš Getting environment...');
console.log(\`š” Requesting: \${this.baseURL}/project/\${this.projectId}\`);
const page = await this.request(\`\${this.baseURL}/project/\${this.projectId}\`);
// Enhanced environment detection
console.log('\\n=== Enhanced Environment Detection ===');
// Try multiple patterns for environment IDs
const allHexStrings = page.raw.match(/[a-z0-9]{24}/g) || [];
const filteredIds = allHexStrings.filter(id => id !== this.projectId);
if (filteredIds.length > 0) {
this.environmentId = filteredIds[0];
console.log(\`ā
Environment: \${this.environmentId}\`);
console.log(\`š Found IDs: \${filteredIds.slice(0, 3).join(', ')}\`);
} else {
throw new Error('Could not find environment');
}
}`;
// Replace the method
const fixed = original.replace(originalMethod, newMethod);
// Write the fixed version
fs.writeFileSync('index_simple_fix.js', fixed);
console.log('ā
Created simple fixed version');