MCPcopy Index your code
hub / github.com/awesome-opencode/awesome-opencode / main

Function main

scripts/generate-readme.js:82–144  ·  view source on GitHub ↗

* Main function to generate the README

()

Source from the content-addressed store, hash-verified

80 * Main function to generate the README
81 */
82async function main() {
83 console.log('Starting README generation...\n');
84
85 // Read template
86 let template;
87 try {
88 template = readTemplate();
89 console.log('Template loaded successfully');
90 } catch (err) {
91 throw new Error(`Failed to read template: ${err.message}`);
92 }
93
94 // Process each category in order
95 const results = {};
96 let totalEntries = 0;
97 let allErrors = [];
98
99 for (const category of CATEGORIES) {
100 const placeholder = CATEGORY_PLACEHOLDERS[category];
101 console.log(`Processing ${category}...`);
102
103 try {
104 const result = await generateCategorySection(category);
105 results[placeholder] = result.html;
106 totalEntries += result.count;
107 allErrors = allErrors.concat(result.errors);
108
109 if (result.count > 0) {
110 console.log(` - Found ${result.count} valid entries`);
111 } else {
112 console.log(` - No entries found`);
113 }
114 } catch (err) {
115 console.error(` - Error processing ${category}: ${err.message}`);
116 results[placeholder] = '';
117 }
118 }
119
120 // Replace each placeholder in template
121 let content = template;
122 for (const [placeholder, html] of Object.entries(results)) {
123 content = replacePlaceholder(content, placeholder, html);
124 }
125
126 // Write final README
127 try {
128 writeReadme(content);
129 console.log('\nREADME.md written successfully');
130 } catch (err) {
131 throw new Error(`Failed to write README.md: ${err.message}`);
132 }
133
134 // Log summary
135 const errorCount = allErrors.length;
136 if (errorCount > 0) {
137 console.log(`\n⚠️ Generated README.md with ${totalEntries} entries across ${CATEGORIES.length} categories`);
138 console.log(` ${errorCount} validation error(s) were logged (affected entries were skipped)`);
139 } else {

Callers 1

generate-readme.jsFile · 0.70

Calls 4

readTemplateFunction · 0.85
generateCategorySectionFunction · 0.85
replacePlaceholderFunction · 0.85
writeReadmeFunction · 0.85

Tested by

no test coverage detected