Skip to content

Commit 184b76d

Browse files
authored
chore: include node_modules in api slackware package (#1415)
instead of vendoring & uploading separately. ## 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.
1 parent c132f28 commit 184b76d

File tree

12 files changed

+63
-106
lines changed

12 files changed

+63
-106
lines changed

.github/workflows/build-plugin.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ jobs:
100100
with:
101101
name: unraid-api
102102
path: ${{ github.workspace }}/plugin/api/
103-
- name: Download PNPM Store
104-
uses: actions/download-artifact@v4
105-
with:
106-
name: packed-node-modules
107-
path: ${{ github.workspace }}/plugin/node-modules-archive/
108103
- name: Extract Unraid API
109104
run: |
110105
mkdir -p ${{ github.workspace }}/plugin/source/dynamix.unraid.net/usr/local/unraid-api
@@ -129,11 +124,6 @@ jobs:
129124
exit 1
130125
fi
131126
132-
if [ ! -f ./deploy/*.tar.xz ]; then
133-
echo "Error: .tar.xz file not found in plugin/deploy/"
134-
exit 1
135-
fi
136-
137127
- name: Upload to GHA
138128
uses: actions/upload-artifact@v4
139129
with:

.github/workflows/main.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ jobs:
185185
with:
186186
name: unraid-api
187187
path: ${{ github.workspace }}/api/deploy/unraid-api.tgz
188-
- name: Upload Node Modules to Github artifacts
189-
uses: actions/upload-artifact@v4
190-
with:
191-
name: packed-node-modules
192-
path: ${{ github.workspace }}/api/deploy/node-modules-archive/packed-node-modules.tar.xz
193188

194189
build-unraid-ui-webcomponents:
195190
name: Build Unraid UI Library (Webcomponent Version)

api/scripts/build.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,6 @@ try {
120120
}
121121
}
122122

123-
const compressionLevel = process.env.WATCH_MODE ? '-1' : '-5';
124-
await $`XZ_OPT=${compressionLevel} tar -cJf packed-node-modules.tar.xz node_modules`;
125-
// Create a subdirectory for the node modules archive
126-
await mkdir('../node-modules-archive', { recursive: true });
127-
await $`mv packed-node-modules.tar.xz ../node-modules-archive/`;
128-
await $`rm -rf node_modules`;
129-
130123
// Clean the release directory
131124
await $`rm -rf ../release/*`;
132125

justfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ setup:
1515

1616
pnpm install
1717

18+
# Removes all node_modules directories in the repository
19+
clean-modules:
20+
#!/usr/bin/env bash
21+
echo "Finding and removing all node_modules directories..."
22+
find . -name "node_modules" -type d -not -path "*/node_modules/*" | while read dir; do
23+
echo "Removing: $dir"
24+
rm -rf "$dir"
25+
done
26+
echo "All node_modules directories have been removed."
27+
28+
# Removes all build artifacts (dist, .nuxt, .output, coverage, etc.)
29+
clean-build:
30+
#!/usr/bin/env bash
31+
echo "Finding and removing build artifacts..."
32+
build_dirs=("dist" ".nuxt" ".output" "coverage" "deploy")
33+
for build_dir in "${build_dirs[@]}"; do
34+
find . -name "$build_dir" -type d | while read dir; do
35+
echo "Removing: $dir"
36+
rm -rf "$dir"
37+
done
38+
done
39+
echo "All build artifacts have been removed."
40+
1841
# restore notification files under api/dev
1942
restore-notifications:
2043
git checkout ./api/dev/notifications

plugin/builder/build-plugin.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { $ } from "zx";
33
import { escape as escapeHtml } from "html-sloppy-escaper";
44
import { dirname, join } from "node:path";
55
import { getTxzName, pluginName, startingDir, defaultArch, defaultBuild } from "./utils/consts";
6-
import { getAssetUrl, getPluginUrl } from "./utils/bucket-urls";
6+
import { getPluginUrl } from "./utils/bucket-urls";
77
import { getMainTxzUrl } from "./utils/bucket-urls";
88
import {
99
deployDir,
@@ -12,7 +12,6 @@ import {
1212
} from "./utils/paths";
1313
import { PluginEnv, setupPluginEnv } from "./cli/setup-plugin-environment";
1414
import { cleanupPluginFiles } from "./utils/cleanup";
15-
import { bundleVendorStore, getVendorBundleName } from "./build-vendor-store";
1615

1716
/**
1817
* Check if git is available
@@ -76,8 +75,6 @@ const buildPlugin = async ({
7675
txz_url: getMainTxzUrl({ baseUrl, apiVersion, tag }),
7776
txz_sha256: txzSha256,
7877
txz_name: getTxzName(apiVersion),
79-
vendor_store_url: getAssetUrl({ baseUrl, tag }, getVendorBundleName(apiVersion)),
80-
vendor_store_filename: getVendorBundleName(apiVersion),
8178
...(tag ? { tag } : {}),
8279
};
8380

@@ -123,7 +120,6 @@ const main = async () => {
123120

124121
await buildPlugin(validatedEnv);
125122
await moveTxzFile(validatedEnv);
126-
await bundleVendorStore(validatedEnv.apiVersion);
127123
} catch (error) {
128124
console.error(error);
129125
process.exit(1);

plugin/builder/build-txz.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const storeVendorArchiveInfo = async (version: string, vendorUrl: string, vendor
7373

7474
// Create a JSON config file with vendor information
7575
const configData = {
76-
vendor_store_url: vendorUrl,
76+
// vendor_store_url: vendorUrl,
7777
vendor_store_path: vendorFullPath,
7878
api_version: version
7979
};

plugin/builder/build-vendor-store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async function createNodeModulesTarball(outputPath: string): Promise<void> {
5454
* After this operation, the vendored node_modules will be available inside the `deployDir`.
5555
*
5656
* @param apiVersion Required API version to use for the vendor bundle
57+
* @deprecated vendored node_modules are now included in the API slackware package
5758
*/
5859
export async function bundleVendorStore(apiVersion: string): Promise<void> {
5960
// Ensure deploy directory exists

plugin/docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ services:
1414
- ../unraid-ui/dist-wc:/app/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/uui
1515
- ../web/.nuxt/nuxt-custom-elements/dist/unraid-components:/app/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/nuxt
1616
- ../api/deploy/release/:/app/source/dynamix.unraid.net/usr/local/unraid-api # Use the release dir instead of pack to allow watcher to not try to build with node_modules
17-
- ../api/deploy/node-modules-archive:/app/node-modules-archive
1817
stdin_open: true # equivalent to -i
1918
tty: true # equivalent to -t
2019
environment:

plugin/plugins/dynamix.unraid.net.plg

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
<!ENTITY txz_sha256 "">
1010
<!ENTITY txz_url "">
1111
<!ENTITY txz_name "">
12-
<!ENTITY vendor_store_url "">
13-
<!ENTITY vendor_store_filename "">
1412
<!ENTITY arch "x86_64">
1513
<!ENTITY build "1">
1614
<!ENTITY tag "">
@@ -47,10 +45,6 @@ exit 0
4745
]]>
4846
</INLINE>
4947
</FILE>
50-
51-
<FILE Name="/boot/config/plugins/dynamix.my.servers/&vendor_store_filename;">
52-
<URL>&vendor_store_url;</URL>
53-
</FILE>
5448

5549
<!-- download main txz -->
5650
<FILE Name="&source;">
@@ -223,7 +217,6 @@ exit 0
223217
PKG_FILE="&source;" # Full path to the package file including .txz extension
224218
PKG_URL="&txz_url;" # URL where package was downloaded from
225219
PKG_NAME="&txz_name;" # Name of the package file
226-
VENDOR_ARCHIVE="/boot/config/plugins/dynamix.my.servers/&vendor_store_filename;"
227220
<![CDATA[
228221
# Install the Slackware package
229222
echo "Installing package..."
@@ -235,6 +228,9 @@ for txz_file in /boot/config/plugins/dynamix.my.servers/dynamix.unraid.net-*.txz
235228
fi
236229
done
237230
231+
# Clean up any old node_modules archives (on the boot drive) that don't match our current version
232+
/etc/rc.d/rc.unraid-api cleanup-dependencies
233+
238234
# Remove existing node_modules directory
239235
echo "Cleaning up existing node_modules directory..."
240236
if [ -d "/usr/local/unraid-api/node_modules" ]; then

plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ uninstall() {
2929
start() {
3030
echo "Starting Unraid API service..."
3131

32-
# Ensure dependencies are installed
32+
# Restore vendored API plugins if they were installed
3333
if [ -x "$scripts_dir/dependencies.sh" ]; then
34-
"$scripts_dir/dependencies.sh" ensure || {
35-
echo "Failed to install dependencies – aborting start."
36-
return 1
34+
"$scripts_dir/dependencies.sh" restore || {
35+
echo "Failed to restore API plugin dependencies! Continuing with start, but API plugins may be unavailable."
3736
}
3837
else
3938
echo "Warning: dependencies.sh script not found or not executable"

0 commit comments

Comments
 (0)