Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"// Build and Deploy": "",
"build": "vite build --mode=production",
"postbuild": "chmod +x dist/main.js && chmod +x dist/cli.js && node scripts/copy-plugins.js",
"build:watch": "nodemon --watch src --ext ts,js,json --exec 'tsx ./scripts/build.ts'",
"build:watch": "WATCH_MODE=true nodemon --watch src --ext ts,js,json --exec 'tsx ./scripts/build.ts'",
"build:docker": "./scripts/dc.sh run --rm builder",
"build:release": "tsx ./scripts/build.ts",
"preunraid:deploy": "pnpm build",
Expand Down
9 changes: 8 additions & 1 deletion api/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@ try {

await writeFile('package.json', JSON.stringify(parsedPackageJson, null, 4));

await $`XZ_OPT=-5 tar -cJf packed-node-modules.tar.xz node_modules`;
const compressionLevel = process.env.WATCH_MODE ? '-1' : '-5';
await $`XZ_OPT=${compressionLevel} tar -cJf packed-node-modules.tar.xz node_modules`;
// Create a subdirectory for the node modules archive
await mkdir('../node-modules-archive', { recursive: true });
await $`mv packed-node-modules.tar.xz ../node-modules-archive/`;
await $`rm -rf node_modules`;

// Clean the release directory
await $`rm -rf ../release/*`;

// Copy other files to release directory
await $`cp -r ./* ../release/`;
Comment on lines +59 to +63
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Improved reliability with explicit directory cleaning.

Explicitly cleaning the release directory before copying files ensures a clean slate for each build, preventing potential issues with stale files.

Consider adding error handling for the case when the release directory can't be cleaned or when the copy operation fails:


🏁 Script executed:

#!/bin/bash
# Check if the release directory exists and if files are being copied correctly
ls -la ../release/ 
echo "Checking if directories are properly set up and accessible"

Length of output: 206


Ensure release directory exists and handle errors in build script

Add a step to create the ../release directory if it doesn’t exist before cleaning and copying, and wrap the operations in a try/catch to surface failures:

// api/scripts/build.ts (around lines 59–63)
try {
  await $`mkdir -p ../release`;
  await $`rm -rf ../release/*`;
  await $`cp -r ./* ../release/`;
} catch (error) {
  console.error("Release setup failed:", error);
  process.exit(1);
}
  • Creates the target directory to prevent No such file or directory errors
  • Cleans out stale files explicitly
  • Logs and exits on any failure in setup or file copy
🤖 Prompt for AI Agents
In api/scripts/build.ts around lines 59 to 63, the script currently removes and
copies files to the release directory without ensuring the directory exists or
handling errors. To fix this, first add a command to create the ../release
directory if it doesn't exist, then wrap the mkdir, rm, and cp commands in a
try/catch block. In the catch block, log the error with a clear message and exit
the process with a failure code to handle any issues during directory setup or
file copying.


// chmod the cli
await $`chmod +x ./dist/cli.js`;
await $`chmod +x ./dist/main.js`;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "4.8.0",
"scripts": {
"build": "pnpm -r build",
"build:watch": "pnpm -r build:watch",
"build:watch": " pnpm -r --parallel build:watch",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove leading whitespace in build:watch command
The script value starts with a space (" pnpm -r --parallel build:watch"), which may lead to an invalid command or unexpected behavior. Remove the leading space:

- "build:watch": " pnpm -r --parallel build:watch",
+ "build:watch": "pnpm -r --parallel build:watch",
📝 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
"build:watch": " pnpm -r --parallel build:watch",
"build:watch": "pnpm -r --parallel build:watch",
🤖 Prompt for AI Agents
In package.json at line 7, remove the leading whitespace before the command in
the "build:watch" script so it starts directly with "pnpm -r --parallel
build:watch" without any preceding spaces to avoid invalid command execution.

"dev": "pnpm -r dev",
"unraid:deploy": "pnpm -r unraid:deploy",
"test": "pnpm -r test",
Expand Down
Empty file added plugin/.nvmrc
Empty file.
2 changes: 1 addition & 1 deletion plugin/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- ./scripts:/app/scripts
- ../unraid-ui/dist-wc:/app/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/uui
- ../web/.nuxt/nuxt-custom-elements/dist/unraid-components:/app/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/nuxt
- ../api/deploy/pack/:/app/source/dynamix.unraid.net/usr/local/unraid-api
- ../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
- ../api/deploy/node-modules-archive:/app/node-modules-archive
stdin_open: true # equivalent to -i
tty: true # equivalent to -t
Expand Down
2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"build:txz": "tsx builder/build-txz.ts",
"build:plugin": "tsx builder/build-plugin.ts",
"build:validate": "npm run env:validate && npm run build",
"build:watcher": "nodemon --verbose --watch 'source/**/*' --watch 'plugins/dynamix.unraid.net.plg' --ext ts,js,plg,sh --ignore '*.test.ts' --ignore 'node_modules/**' --delay 5s --exec 'pnpm run build'",
"build:watcher": "./scripts/build-watcher.sh",
"// Docker commands": "",
"build:watch": "./scripts/dc.sh pnpm run build:watcher",
"docker:build": "docker compose build",
Expand Down
11 changes: 11 additions & 0 deletions plugin/scripts/build-watcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
nodemon --verbose \
--watch 'source/**/*' \
--watch 'plugins/dynamix.unraid.net.plg' \
--ext ts,js,plg,sh,xz,json \
--ignore '*.test.ts' \
--ignore 'node_modules/**' \
--ignore 'source/dynamix.unraid.net/doinst.sh' \
--ignore 'source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/config/vendor_archive.json' \
--delay 30s \
--exec 'pnpm run build'
8 changes: 8 additions & 0 deletions plugin/scripts/dc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ API_VERSION=$([[ -n "$IS_TAGGED" ]] && echo "$PACKAGE_LOCK_VERSION" || echo "${P
# Define container name for easier management
CONTAINER_NAME="plugin-builder"

# Create the directory if it doesn't exist
# This is to prevent errors when mounting volumes in docker compose
NUXT_COMPONENTS_DIR="../web/.nuxt/nuxt-custom-elements/dist/unraid-components"
if [ ! -d "$NUXT_COMPONENTS_DIR" ]; then
echo "Creating directory $NUXT_COMPONENTS_DIR for Docker volume mount..."
mkdir -p "$NUXT_COMPONENTS_DIR"
fi

# Stop any running plugin-builder container first
echo "Stopping any running plugin-builder containers..."
docker ps -q --filter "name=${CONTAINER_NAME}" | xargs -r docker stop
Expand Down
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build:dev": "nuxi build --dotenv .env.staging && pnpm run manifest-ts && pnpm run deploy-to-unraid:dev",
"build:webgui": "pnpm run type-check && nuxi build --dotenv .env.production && pnpm run manifest-ts && pnpm run copy-to-webgui-repo",
"build": "NODE_ENV=production nuxi build --dotenv .env.production && pnpm run manifest-ts",
"prebuild:watch": "pnpm predev",
"build:watch": "nuxi build --dotenv .env.production --watch && pnpm run manifest-ts",
"generate": "nuxt generate",
"manifest-ts": "node ./scripts/add-timestamp-webcomponent-manifest.js",
Expand Down
Loading