feat(web): create script to move build to webgui repo

This commit is contained in:
Zack Spear
2023-09-08 15:20:01 -07:00
parent 37565d55eb
commit cceb33d791
3 changed files with 68 additions and 0 deletions

View File

@@ -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

View File

@@ -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",

View File

@@ -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