coolify-deployment-cli
Version:
CLI tool for Coolify deployments
79 lines (66 loc) ⢠2.49 kB
JavaScript
const ResourceDetector = require('./resource-detector');
class DeployerHelper {
constructor() {
this.detector = new ResourceDetector();
}
extractAllResources(html) {
const patterns = [
/<a[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>/gi,
/data-project-id="([^"]+)"/gi,
/data-environment-id="([^"]+)"/gi,
/data-application-id="([^"]+)"/gi
];
patterns.forEach(pattern => {
let match;
while ((match = pattern.exec(html)) !== null) {
console.log(` Found: ${match[0]}`);
}
});
// Extract all domains found
const domains = this.detector.extractAllDomains(html);
if (domains.length > 0) {
console.log(' Domains found:');
domains.forEach(domain => console.log(` ⢠${domain}`));
}
// Extract project data
const projectData = this.detector.extractProjectData(html);
if (projectData.projects.length > 0) {
console.log(' Projects found:');
projectData.projects.forEach(id => console.log(` ⢠${id}`));
}
}
searchInContent(content, resourceDomain, context = '', verbose = false) {
const result = this.detector.searchForDomain(content, resourceDomain);
if (result.found) {
if (verbose) console.log(`ā
Found ${resourceDomain} ${context}!`);
// Display exact matches
if (result.exactMatches.length > 0 && verbose) {
console.log(`\nš Exact matches found ${context}:`);
result.exactMatches.forEach((match, index) => {
console.log(` ${index + 1}. Pattern: "${match.pattern}"`);
match.context.forEach(ctx => {
if (ctx.cleanLine && ctx.cleanLine.length > 10) {
console.log(` Line ${ctx.lineNumber}: ${ctx.cleanLine}`);
}
});
});
}
// Display partial matches if no exact matches
if (result.exactMatches.length === 0 && result.partialMatches.length > 0 && verbose) {
console.log(`\nš Partial matches found ${context}:`);
result.partialMatches.forEach((match, index) => {
console.log(` ${index + 1}. Partial: "${match.pattern}" (${match.type})`);
match.context.forEach(ctx => {
if (ctx.cleanLine && ctx.cleanLine.length > 10) {
console.log(` Line ${ctx.lineNumber}: ${ctx.cleanLine}`);
}
});
});
}
return true;
}
return false;
}
}
module.exports = DeployerHelper;