MCPcopy Create free account
hub / github.com/apache/camel-website / main

Function main

scripts/generate-offline-bundle.js:77–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75}
76
77function main() {
78 const version = process.argv[2];
79 if (!version) {
80 console.error('Usage: node scripts/generate-offline-bundle.js <version>');
81 console.error('Example: node scripts/generate-offline-bundle.js 4.18');
82 process.exit(1);
83 }
84
85 const versionDir = `${version}.x`;
86 const bundleName = `camel-docs-${version}.zip`;
87 const bundlePath = path.join(PUBLIC_DIR, bundleName);
88
89 if (!fs.existsSync(PUBLIC_DIR)) {
90 console.error(`Cannot generate ${bundleName}: '${PUBLIC_DIR}' directory not found`);
91 process.exit(1);
92 }
93
94 // collect paths to include (relative to public/)
95 const includePaths = [];
96
97 for (const dir of VERSION_DIRS) {
98 const fullPath = path.join(PUBLIC_DIR, dir, versionDir);
99 if (fs.existsSync(fullPath)) {
100 includePaths.push(`${dir}/${versionDir}/*`);
101 console.log(` Including ${dir}/${versionDir}/`);
102 } else {
103 console.warn(` Skipping ${dir}/${versionDir}/ (not found)`);
104 }
105 }
106
107 for (const dir of SHARED_DIRS) {
108 const fullPath = path.join(PUBLIC_DIR, dir);
109 if (fs.existsSync(fullPath)) {
110 includePaths.push(`${dir}/*`);
111 console.log(` Including ${dir}/`);
112 }
113 }
114
115 if (includePaths.length === 0) {
116 console.error(`No documentation directories found for version ${version}`);
117 process.exit(1);
118 }
119
120 // always include llms.txt if present
121 if (fs.existsSync(path.join(PUBLIC_DIR, 'llms.txt'))) {
122 includePaths.push('llms.txt');
123 }
124
125 // fetch catalog and YAML DSL schema from the camel repo
126 if (fetchCatalogAndSchema(version)) {
127 includePaths.push('catalog/*');
128 }
129
130 // remove stale bundle
131 if (fs.existsSync(bundlePath)) {
132 fs.unlinkSync(bundlePath);
133 }
134

Callers 1

Calls 1

fetchCatalogAndSchemaFunction · 0.85

Tested by

no test coverage detected