Skip to content

Conversation

@pujitm
Copy link
Member

@pujitm pujitm commented Jun 11, 2025

Summary by CodeRabbit

  • Chores
    • Updated build process to retain the node_modules directory, removing compression and archiving steps.
    • Improved plugin installation by cleaning up outdated dependency archives before reinstalling, enhancing system stability.
    • Removed vendor store file references and related bundling steps from the plugin build and installation process.
    • Enhanced dependency restoration during service start to log warnings without aborting on failure.
    • Simplified dependency management scripts by removing vendor store URL handling and download functionality.
    • Streamlined build workflows by removing artifact upload/download and validation steps related to node modules archives.
    • Updated Docker Compose configuration to remove unused volume mounts for node modules archives.
    • Added repository cleanup commands to remove top-level node_modules directories and common build artifact folders for easier maintenance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

Walkthrough

The build process was simplified by removing the creation, archiving, and movement of a compressed node_modules directory. Corresponding plugin manifest entries and vendor store bundling steps were removed. The plugin installation script now runs a cleanup command to remove outdated node_modules archives before deleting the current node_modules folder. Workflow steps uploading and downloading the node_modules archive artifact were also removed. The dependency restoration logic in the service start script and dependencies script was adjusted to be less strict and more flexible.

Changes

File(s) Change Summary
api/scripts/build.ts Removed all steps compressing, archiving, moving, and deleting node_modules directory during build.
plugin/plugins/dynamix.unraid.net.plg Removed vendor store XML entities and file reference; added cleanup command before deleting node_modules.
.github/workflows/build-plugin.yml Removed step downloading packed-node-modules artifact.
.github/workflows/main.yml Removed step uploading packed-node-modules.tar.xz artifact.
plugin/builder/build-plugin.ts Removed imports and calls related to vendor store bundling; disabled setting vendor_store_url entity.
plugin/builder/build-txz.ts Commented out vendor_store_url property in JSON config written by storeVendorArchiveInfo.
plugin/builder/build-vendor-store.ts Added deprecation notice to bundleVendorStore function indicating vendored node_modules included elsewhere.
plugin/docker-compose.yml Removed volume mount for node-modules-archive from plugin-builder service.
plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api Changed dependency handling to attempt restore of vendored plugins, log warnings on failure, and continue start.
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/dependencies.sh Made restore_dependencies backup file argument optional with fallback logic; updated usage message accordingly.
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/api_utils.sh Removed all references to vendor_store_url from get_archive_information function.
justfile Added clean-modules and clean-build recipes to remove node_modules and build artifact directories.

Possibly related PRs

Suggested reviewers

  • mdatelle
  • zackspear

Poem

🎉 A change unfolds, the archive fades,
node_modules stays, no longer cascades.
Cleanup runs with gentle sweep,
Old files vanish, new paths keep.
Build flows smooth, dependencies light,
Code dances on, in clear daylight! 🚀


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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: 0

🧹 Nitpick comments (1)
api/scripts/build.ts (1)

128-128: Confirm intentional retention of node_modules
The removal of node_modules has been commented out, so the directory will persist in the pack and release artifacts. Ensure this aligns with the Slackware packaging expectations.

Consider toggling this behavior via an env var (e.g., KEEP_NODE_MODULES) to keep builds reproducible:

-// await $`rm -rf node_modules`;
+if (!process.env.KEEP_NODE_MODULES) {
+  await $`rm -rf node_modules`;
+} else {
+  console.log('Retaining node_modules as per KEEP_NODE_MODULES flag');
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c132f28 and 699b54f.

📒 Files selected for processing (1)
  • api/scripts/build.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Build Unraid UI Library (Webcomponent Version)
  • GitHub Check: Build Web App
  • GitHub Check: Build API
  • GitHub Check: Test API
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)
  • GitHub Check: Cloudflare Pages

Copy link
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: 1

🧹 Nitpick comments (1)
plugin/plugins/dynamix.unraid.net.plg (1)

218-222: VENDOR_ARCHIVE is now dead code—drop it to avoid drift

The vendor-store <FILE> stanza was removed, but the shell variable persists:

VENDOR_ARCHIVE="/boot/config/plugins/dynamix.my.servers/&vendor_store_filename;"

It’s never referenced below, so keeping it around:

  • confuses future readers,
  • risks someone assuming the archive is still used, and
  • slightly inflates the env.

Safe to delete these two lines altogether.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 699b54f and bb9d56b.

📒 Files selected for processing (1)
  • plugin/plugins/dynamix.unraid.net.plg (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)
  • GitHub Check: Build API
  • GitHub Check: Test API
  • GitHub Check: Build Web App
  • GitHub Check: Build Unraid UI Library (Webcomponent Version)
  • GitHub Check: Cloudflare Pages

Comment on lines +234 to +236
# Clean up any old node_modules archives (on the boot drive) that don't match our current version
/etc/rc.d/rc.unraid-api cleanup-dependencies
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 11, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard rc.unraid-api cleanup-dependencies with existence & exit-status checks

/etc/rc.d/rc.unraid-api might be missing or return a non-zero status (e.g., corrupted script, permission issue).
Right now the installer would sail past the failure silently and continue, leaving stale archives behind or, worse, terminating later with a less obvious error.

-# Clean up any old node_modules archives (on the boot drive) that don't match our current version
-/etc/rc.d/rc.unraid-api cleanup-dependencies
+# Clean up any old node_modules archives (on the boot drive) that don't match our current version
+if [ -x "/etc/rc.d/rc.unraid-api" ]; then
+  /etc/rc.d/rc.unraid-api cleanup-dependencies || \
+    echo "⚠️  Dependency cleanup failed, continuing install anyway"
+else
+  echo "⚠️  /etc/rc.d/rc.unraid-api not found or not executable, skipping dependency cleanup"
+fi

Minimal defensive code prevents broken upgrades on edge systems without adding much complexity.

🤖 Prompt for AI Agents
In plugin/plugins/dynamix.unraid.net.plg around lines 234 to 236, the call to
/etc/rc.d/rc.unraid-api cleanup-dependencies lacks checks for the script's
existence and its exit status. To fix this, first verify that
/etc/rc.d/rc.unraid-api exists and is executable before running the cleanup
command. Then, after running it, check the exit status and handle any non-zero
result appropriately, such as logging an error or aborting the installation to
prevent silent failures and stale archives.

Copy link
Member Author

Choose a reason for hiding this comment

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

this file is bundled with the plugin, so it will always exist

Copy link
Contributor

Choose a reason for hiding this comment

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

@pujitm Got it—since the plugin ships its own /etc/rc.d/rc.unraid-api, the file’s absence isn’t a realistic scenario. Thanks for clarifying.

If you’re comfortable relying on that guarantee, feel free to keep the current line as-is. For belt-and-suspenders robustness you could still echo a warning when the cleanup command itself returns non-zero, but that’s purely optional:

# Optional: surface a failure while still proceeding
/etc/rc.d/rc.unraid-api cleanup-dependencies || \
  echo "⚠️  Dependency cleanup failed (non-zero exit), continuing install"

Totally fine to leave it out if you’d rather keep things concise. Let me know if you’d like me to drop the suggestion entirely.


✏️ Learnings added
Learnt from: pujitm
PR: unraid/api#1415
File: plugin/plugins/dynamix.unraid.net.plg:234-236
Timestamp: 2025-06-11T14:14:30.305Z
Learning: For the Unraid Connect plugin, the script `/etc/rc.d/rc.unraid-api` is bundled with the plugin package itself, so its presence on the target system is guaranteed during installation.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

pujitm added 3 commits June 11, 2025 10:48
since node_modules are included with the slackware package now,
`ensure` is much less useful, but `restore` is necessary to load
any api plugins, as they must be vendored after installation.
Copy link
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 (2)
plugin/builder/build-plugin.ts (1)

15-15: Deprecation dependency: verify continued import of getVendorBundleName.

build-vendor-store.ts is marked deprecated, yet this file still imports its public helper.
If that module is slated for removal, refactor the helper into a dedicated util before de-leting the source to avoid a future breaking change.

plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/dependencies.sh (1)

310-311: Usage string outdated for redownload arguments.

The help still lists redownload without its two parameters; update to avoid user confusion.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb9d56b and c2c6ff3.

📒 Files selected for processing (10)
  • .github/workflows/build-plugin.yml (0 hunks)
  • .github/workflows/main.yml (0 hunks)
  • api/scripts/build.ts (0 hunks)
  • plugin/builder/build-plugin.ts (3 hunks)
  • plugin/builder/build-txz.ts (1 hunks)
  • plugin/builder/build-vendor-store.ts (1 hunks)
  • plugin/docker-compose.yml (0 hunks)
  • plugin/plugins/dynamix.unraid.net.plg (1 hunks)
  • plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api (1 hunks)
  • plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/dependencies.sh (3 hunks)
💤 Files with no reviewable changes (4)
  • .github/workflows/main.yml
  • .github/workflows/build-plugin.yml
  • plugin/docker-compose.yml
  • api/scripts/build.ts
✅ Files skipped from review due to trivial changes (1)
  • plugin/builder/build-vendor-store.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugin/plugins/dynamix.unraid.net.plg
🧰 Additional context used
🧬 Code Graph Analysis (1)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/dependencies.sh (1)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/api_utils.sh (1)
  • get_archive_information (28-70)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build Web App
  • GitHub Check: Build Unraid UI Library (Webcomponent Version)
  • GitHub Check: Build API
  • GitHub Check: Test API
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
plugin/builder/build-plugin.ts (1)

79-81: vendor_store_url removed — confirm manifest & downstream scripts are aligned.

You dropped the vendor_store_url entity but kept vendor_store_filename.
Double-check that:

  1. dynamix.unraid.net.plg no longer declares the vendor_store_url entity (otherwise updateEntityValue will throw).
  2. No runtime scripts still need the remote URL; if they do, leave the key with an empty value instead of deleting it.
plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api (1)

32-36: Service starts even when dependencies are missing – risk of runtime failure.

dependencies.sh restore now returns success on any error; the API may start without node_modules, leading to late-crash behaviour that’s harder to diagnose.

Consider:

 "$scripts_dir/dependencies.sh" restore || {
-  echo "Failed to restore API plugin dependencies! Continuing with start, but API plugins may be unavailable."
-}
+  echo "Failed to restore API plugin dependencies! Aborting start."
+  return 1
+}

or at least exit non-zero only when the API binary subsequently fails.

@pujitm pujitm force-pushed the chore/node_modules branch from 22529b6 to 0dff2cf Compare June 11, 2025 15:35
Copy link
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)
justfile (1)

32-38: Minor: collapse inner find loop for speed & clarity

Repeatedly spawning a subshell for each build_dir is unnecessary. A single find can cover all patterns:

-build_dirs=("dist" ".nuxt" ".output" "coverage" "deploy")
-for build_dir in "${build_dirs[@]}"; do
-    find . -name "$build_dir" -type d | while read dir; do
-        echo "Removing: $dir"
-        rm -rf "$dir"
-    done
-done
+find . \( -name dist -o -name .nuxt -o -name .output -o -name coverage -o -name deploy \) \
+     -type d -print0 | while IFS= read -r -d '' dir; do
+    echo "Removing: $dir"
+    rm -rf "$dir"
+done

Fewer find invocations and null-delimited handling for robustness.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9312a02 and 7f5b876.

📒 Files selected for processing (1)
  • justfile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build API
  • GitHub Check: Test API
  • GitHub Check: Build Web App
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Cloudflare Pages

@github-actions
Copy link
Contributor

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR1415/dynamix.unraid.net.plg

@pujitm pujitm marked this pull request as ready for review June 11, 2025 16:06
@pujitm pujitm merged commit 184b76d into main Jun 11, 2025
12 checks passed
@pujitm pujitm deleted the chore/node_modules branch June 11, 2025 16:07
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