Skip to content

chore: Add clean and build:clean scripts#548

Open
JakeSCahill wants to merge 1 commit intomainfrom
add-clean-build-script
Open

chore: Add clean and build:clean scripts#548
JakeSCahill wants to merge 1 commit intomainfrom
add-clean-build-script

Conversation

@JakeSCahill
Copy link
Copy Markdown
Contributor

Summary

  • Add npm run clean script to remove docs/ and .cache/ directories
  • Add npm run build:clean script that cleans then builds in one command

This prevents the glob-stream stack overflow error that occurs when the docs/ directory accumulates too many files from previous builds.

Usage

When you encounter the stack overflow error during build:

npm run build:clean

Or manually clean first:

npm run clean
npm run build

🤖 Generated with Claude Code

Add npm scripts to clean build artifacts before building. This prevents
the glob-stream stack overflow error that occurs when the docs/ directory
accumulates too many files from previous builds.

- npm run clean: removes docs/ and .cache/ directories
- npm run build:clean: cleans then builds in one command
@JakeSCahill JakeSCahill requested a review from a team as a code owner April 7, 2026 09:12
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 7, 2026

Deploy Preview for rp-cloud ready!

Name Link
🔨 Latest commit 1947fa2
🔍 Latest deploy log https://app.netlify.com/projects/rp-cloud/deploys/69d4ca96af36b300085fb980
😎 Deploy Preview https://deploy-preview-548--rp-cloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Two npm scripts were added to package.json. The clean script removes the docs output directory and .cache directory. The build:clean script sequentially executes the clean script followed by the build script, providing a combined cleanup and build workflow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides context and usage examples, but does not follow the required template structure with issue link, page previews, or checks section. Add the required template sections: issue link (Resolves #...), page previews section, and checks section with appropriate options selected.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding two new npm scripts (clean and build:clean).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-clean-build-script

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
package.json (1)

9-9: Optional: Consider Antora's built-in --clean flag as an alternative.

The implementation correctly uses && to chain the clean and build steps. However, note that Antora has a built-in --clean option (visible in gulpfile.js:14). You could potentially use:

"build:clean": "antora --to-dir docs --fetch --clean local-antora-playbook.yml"

However, Antora's --clean flag may not remove the .cache directory, so the current approach of manually cleaning both docs/ and .cache/ before building provides more thorough cleanup and is likely the better solution for addressing the glob-stream stack overflow issue mentioned in the PR objectives.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 9, The review suggests Antora's built-in --clean flag
but notes it may not remove .cache; update the package.json "build:clean" script
to either (a) switch to using "antora --clean" and also explicitly remove the
.cache directory before running Antora, or (b) keep the current chained
clean+build approach but add a short comment in package.json explaining that
manual removal of docs/ and .cache is intentional to avoid the glob-stream stack
overflow; reference the "build:clean" script, the "antora --clean" flag, and the
".cache" and "docs/" directories so the rationale and change are easy to find.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Line 7: The clean script in package.json uses the Unix-specific command "rm
-rf" which breaks on Windows; replace it with a cross-platform tool (e.g., add
rimraf or del-cli as a devDependency) and update the "clean" npm script to call
that tool (e.g., use "rimraf docs .cache" or "del-cli docs .cache") so the
"clean" script works on all platforms; ensure you add the chosen package to
devDependencies and update the "clean" entry in package.json accordingly.
- Around line 7-11: The clean script currently removes docs and .cache but not
the gulp default output, so update the "clean" npm script to also remove the
gulp output directory (./build/site) to keep build and start workflows
consistent; modify the "clean" value in package.json (referencing the "clean"
script) to delete docs, .cache and build/site so both npm run build and npm
start produce fresh outputs when preceded by npm run clean.

---

Nitpick comments:
In `@package.json`:
- Line 9: The review suggests Antora's built-in --clean flag but notes it may
not remove .cache; update the package.json "build:clean" script to either (a)
switch to using "antora --clean" and also explicitly remove the .cache directory
before running Antora, or (b) keep the current chained clean+build approach but
add a short comment in package.json explaining that manual removal of docs/ and
.cache is intentional to avoid the glob-stream stack overflow; reference the
"build:clean" script, the "antora --clean" flag, and the ".cache" and "docs/"
directories so the rationale and change are easy to find.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd57085c-be6b-4bb9-b7e1-d11e743b91b8

📥 Commits

Reviewing files that changed from the base of the PR and between 8c22b23 and 1947fa2.

📒 Files selected for processing (1)
  • package.json

Comment thread package.json
"description": "Redpanda documentation",
"license": "ISC",
"scripts": {
"clean": "rm -rf docs .cache",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Use a cross-platform solution for the clean script.

The rm -rf command is Unix/Linux/macOS specific and will fail on Windows, blocking Windows developers from using this script.

🔧 Proposed fix using rimraf for cross-platform compatibility

Install rimraf as a dev dependency:

npm install --save-dev rimraf

Then update the script:

-    "clean": "rm -rf docs .cache",
+    "clean": "rimraf docs .cache",

Alternatively, use del-cli:

npm install --save-dev del-cli
-    "clean": "rm -rf docs .cache",
+    "clean": "del docs .cache",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 7, The clean script in package.json uses the
Unix-specific command "rm -rf" which breaks on Windows; replace it with a
cross-platform tool (e.g., add rimraf or del-cli as a devDependency) and update
the "clean" npm script to call that tool (e.g., use "rimraf docs .cache" or
"del-cli docs .cache") so the "clean" script works on all platforms; ensure you
add the chosen package to devDependencies and update the "clean" entry in
package.json accordingly.

Comment thread package.json
Comment on lines +7 to 11
"clean": "rm -rf docs .cache",
"build": "antora --to-dir docs --fetch local-antora-playbook.yml",
"build:clean": "npm run clean && npm run build",
"serve": "wds --node-resolve --open / --watch --root-dir docs --port 5002",
"start": "cross-env-shell LIVERELOAD=true npx gulp"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify which directories are created by build vs. start scripts

# Check the playbook configuration
echo "=== Checking playbook configuration ==="
if [ -f "local-antora-playbook.yml" ]; then
  echo "Playbook exists. Checking output.dir configuration:"
  rg -A 2 "^output:" local-antora-playbook.yml || echo "No output.dir configured (defaults to ./build/site for gulp)"
else
  echo "Playbook file not found"
fi

# Check what directories currently exist
echo -e "\n=== Current output directories ==="
ls -la | rg "^d.*(docs|build|\.cache)" || echo "No output directories found"

# Check gulpfile for confirmation
echo -e "\n=== Gulpfile output directory logic ==="
rg -A 1 "outputDir.*=.*playbook" gulpfile.js

Repository: redpanda-data/cloud-docs

Length of output: 480


Major: Inconsistent output directories between build and start workflows.

The clean script removes docs/ and .cache/, which aligns with the build script (Line 8: --to-dir docs). However, the start script (Line 11) uses gulp with the local-antora-playbook.yml configuration. Since the playbook does not set an explicit output.dir, gulp defaults to ./build/site. This means:

  • npm run clean && npm run build ✅ works correctly
  • npm run clean && npm start ❌ leaves stale files in ./build/site

The clean script should be updated to remove both output directories:

Proposed fix
-    "clean": "rm -rf docs .cache",
+    "clean": "rm -rf docs build .cache",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"clean": "rm -rf docs .cache",
"build": "antora --to-dir docs --fetch local-antora-playbook.yml",
"build:clean": "npm run clean && npm run build",
"serve": "wds --node-resolve --open / --watch --root-dir docs --port 5002",
"start": "cross-env-shell LIVERELOAD=true npx gulp"
"clean": "rm -rf docs build .cache",
"build": "antora --to-dir docs --fetch local-antora-playbook.yml",
"build:clean": "npm run clean && npm run build",
"serve": "wds --node-resolve --open / --watch --root-dir docs --port 5002",
"start": "cross-env-shell LIVERELOAD=true npx gulp"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 7 - 11, The clean script currently removes docs
and .cache but not the gulp default output, so update the "clean" npm script to
also remove the gulp output directory (./build/site) to keep build and start
workflows consistent; modify the "clean" value in package.json (referencing the
"clean" script) to delete docs, .cache and build/site so both npm run build and
npm start produce fresh outputs when preceded by npm run clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant