From cceb33d791db3cdc9fe4cf5c5168b0f3c2ffda50 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Fri, 8 Sep 2023 15:20:01 -0700 Subject: [PATCH] feat(web): create script to move build to webgui repo --- web/nuxt.config.ts | 10 ++++++ web/package.json | 2 ++ web/scripts/copy-to-webgui-repo.sh | 56 ++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100755 web/scripts/copy-to-webgui-repo.sh diff --git a/web/nuxt.config.ts b/web/nuxt.config.ts index 4d730f0b7..aec4a1cdf 100644 --- a/web/nuxt.config.ts +++ b/web/nuxt.config.ts @@ -5,6 +5,16 @@ for (const k in envConfig) { process.env[k] = envConfig[k]; } +console.log('\n'); +console.log('=============================='); +console.log('========= ENV VALUES ========='); +console.log('=============================='); +console.log('[ACCOUNT URL]', process.env.VITE_ACCOUNT); +console.log('[CONNECT URL]', process.env.VITE_CONNECT); +console.log('[UNRAID.NET URL]', process.env.VITE_UNRAID_NET); +console.log('=============================='); +console.log('\n'); + /** * Used to avoid redeclaring variables in the webgui codebase. * @see alt solution https://github.com/terser/terser/issues/1001, https://github.com/terser/terser/pull/1038 diff --git a/web/package.json b/web/package.json index fd595382e..b2af2430b 100644 --- a/web/package.json +++ b/web/package.json @@ -4,7 +4,9 @@ "scripts": { "build": "nuxt build", "build:dev": "nuxt build && npm run deploy:dev", + "build:webgui": "nuxt build && npm run copy-to-webgui", "deploy:dev": "./scripts/deploy-dev.sh", + "copy-to-webgui": "./scripts/copy-to-webgui-repo.sh", "dev": "nuxt dev", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix", "generate": "nuxt generate", diff --git a/web/scripts/copy-to-webgui-repo.sh b/web/scripts/copy-to-webgui-repo.sh new file mode 100755 index 000000000..a6351c880 --- /dev/null +++ b/web/scripts/copy-to-webgui-repo.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Path to store the last used webgui path +state_file="$HOME/.copy_to_webgui_state" + +# Read the last used webgui path from the state file +if [[ -f "$state_file" ]]; then + last_webgui_path=$(cat "$state_file") +else + last_webgui_path="" +fi + +# Read the webgui path from the command-line argument or use the last used webgui path as the default +webgui_path="${1:-$last_webgui_path}" + +# Check if the webgui path is provided +if [[ -z "$webgui_path" ]]; then + echo "Please provide the absolute path to your webgui directory." + exit 1 +fi + +# Ensure that the webgui path ends with a trailing slash +if [[ ! "$webgui_path" == */ ]]; then + webgui_path="${webgui_path}/" +fi + +# Save the current webgui path to the state file +echo "$webgui_path" > "$state_file" + +# Replace the value inside the rsync command with the user's input +rsync_command="rsync -avz -e ssh .nuxt/nuxt-custom-elements/dist/unraid-components ${webgui_path}emhttp/plugins/dynamix.my.servers" + +echo "Executing the following command:" +echo "$rsync_command" + +echo "Removing the irrelevant index.html file in the unraid-components directory..." +rm -f "${webgui_path}emhttp/plugins/dynamix.my.servers/unraid-components/index.html" + +# Execute the rsync command and capture the exit code +eval "$rsync_command" +exit_code=$? + +# Play built-in sound based on the operating system +if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + afplay /System/Library/Sounds/Glass.aiff +elif [[ "$OSTYPE" == "linux-gnu" ]]; then + # Linux + paplay /usr/share/sounds/freedesktop/stereo/complete.oga +elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then + # Windows + powershell.exe -c "(New-Object Media.SoundPlayer 'C:\Windows\Media\Windows Default.wav').PlaySync()" +fi + +# Exit with the rsync command's exit code +exit $exit_code \ No newline at end of file