davsclaus commented on code in PR #1666:
URL: https://github.com/apache/camel-website/pull/1666#discussion_r3427406068
##########
gulp/helpers/offline-bundle.js:
##########
@@ -0,0 +1,46 @@
+const fs = require('fs');
Review Comment:
This runs on **every** build (wired into `generate-markdown`). For a large
doc set, zipping thousands of .md files adds processing time even for local dev
builds where the bundle isn't needed. Consider gating it behind an environment
variable (e.g. `CAMEL_ENV=production`) or making it a separate gulp task.
##########
gulp/helpers/offline-bundle.js:
##########
@@ -0,0 +1,46 @@
+const fs = require('fs');
+const path = require('path');
+const { execFileSync } = require('child_process');
+
+const PUBLIC_DIR = 'public';
+const BUNDLE_NAME = 'camel-docs-offline.zip';
+
+/**
+ * Generates an offline documentation bundle: a single .zip archive of all
generated Markdown (.md)
+ * files plus /llms.txt, preserving the website directory structure. It lets
agents (and humans)
+ * with no or restricted internet access read the Camel docs locally -
download, unzip (e.g. into
+ * /tmp) and read the Markdown from there. See CAMEL-23781.
+ *
+ * Must run after the .md files have been generated (see generate-markdown
task). Uses the system
+ * `zip` tool, so no extra dependency is required.
+ */
+function generateOfflineBundle() {
+ const bundlePath = path.join(PUBLIC_DIR, BUNDLE_NAME);
+
+ if (!fs.existsSync(PUBLIC_DIR)) {
+ console.error(`Cannot generate ${BUNDLE_NAME}: '${PUBLIC_DIR}' directory
not found`);
+ return;
+ }
+
+ // remove any stale bundle so it is never zipped into itself
+ if (fs.existsSync(bundlePath)) {
+ fs.unlinkSync(bundlePath);
+ }
+
+ try {
+ // run from public/ so paths stay relative to the site root; include only
.md files and llms.txt
+ execFileSync('zip', ['-r', '-q', BUNDLE_NAME, '.', '-i', '*.md',
'llms.txt'], {
+ cwd: PUBLIC_DIR,
Review Comment:
This requires the system `zip` binary to be installed. While common on
Linux/macOS (and GitHub Actions runners), it's an undocumented dependency. If
`zip` is missing, the error is caught and logged but the build continues
silently — which could be confusing when the bundle is expected but missing.
Consider adding a pre-check:
```suggestion
// verify zip is available
try {
execFileSync('zip', ['--version'], { stdio: 'pipe' });
} catch {
console.warn(`Skipping ${BUNDLE_NAME}: 'zip' command not found`);
return;
}
// run from public/ so paths stay relative to the site root; include
only .md files and llms.txt
execFileSync('zip', ['-r', '-q', BUNDLE_NAME, '.', '-i', '*.md',
'llms.txt'], {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]