feat: build with deploy to local unraid server

This commit is contained in:
Zack Spear
2023-06-21 13:23:36 -05:00
committed by Zack Spear
parent db469232ed
commit 3f64d8e405
4 changed files with 35 additions and 65 deletions

View File

@@ -90,7 +90,7 @@ $serverData = [
"flashBackupActivated" => empty($flashbackup_status['activated']) ? '' : 'true',
"guid" => $var['flashGUID'],
"hasRemoteApikey" => !empty($myservers['remote']['apikey']),
"internalIp" => ipaddr(),
"lanIp" => ipaddr(),
"internalPort" => $_SERVER['SERVER_PORT'],
"keyfile" => empty($var['regFILE'])? "" : str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE'])))),
"locale" => ($_SESSION['locale']) ? $_SESSION['locale'] : 'en_US',

View File

@@ -3,14 +3,13 @@
"private": true,
"scripts": {
"build": "nuxt build",
"postbuild": "npm run rebuildManifest",
"dev": "nuxt dev",
"generate": "nuxt generate",
"postgenerate": "npm run rebuildManifest",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"serve": "serve dist/nuxt-custom-elements/connect-components",
"rebuildManifest": "node postBuild.ts"
"deploy:dev": "./scripts/deploy-dev.sh",
"build:dev": "nuxt build && npm run deploy:dev"
},
"devDependencies": {
"@nuxt/devtools": "^0.6.1",

View File

@@ -1,61 +0,0 @@
// type Manifest = {
// ['connect-components.client.css']: ManifestCSS;
// ['connect-components.client.mjs']: ManifestJS;
// }
// type ManifestCSS = {
// file: string;
// src: string;
// }
// type ManifestJS = {
// css: string[];
// file: string;
// isEntry: boolean;
// src: string;
// }
const fs = require('fs');
const manifest = '.nuxt/nuxt-custom-elements/dist/connect-components/manifest.json';
const stringToRemove = '.nuxt/nuxt-custom-elements/entries/';
const originalCssKey = '.nuxt/nuxt-custom-elements/entries/connect-components.client.css';
const originalJsKey = '.nuxt/nuxt-custom-elements/entries/connect-components.client.mjs';
console.log('*****************************');
console.log('* RE-BUILDING MANIFEST.JSON *');
console.log('*****************************');
fs.readFile(manifest, 'utf8', (error, data) => {
if (error){
console.log(error);
return;
}
const parsedData = JSON.parse(data);
if ('connect-components.client.mjs' in parsedData) return console.log('Manifest already re-written');
if (!(originalJsKey in parsedData)) return console.error(`Expected JS key not in ${manifest}`);
// create new manifest with updated top-level keys
const newManifest = {
'connect-components.client.css': {
...parsedData[originalCssKey],
},
'connect-components.client.mjs': {
...parsedData[originalJsKey],
}
};
// then rewrite the manifest
fs.writeFile(manifest, JSON.stringify(newManifest, null, 2), (err) => {
if (err) {
console.log('Failed to write updated data to file', err);
return;
}
console.log('Updated file successfully');
});
// echo out the filename that needs to be created on the server
const map = new Map(Object.entries(newManifest));
const js = map.get('connect-components.client.mjs');
console.log(`JS FILE FOR WEBGUI: ${js.file}`);
});

32
scripts/deploy-dev.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# Path to store the last used server name
state_file="$HOME/.deploy_state"
# Read the last used server name from the state file
if [[ -f "$state_file" ]]; then
last_server_name=$(cat "$state_file")
else
last_server_name=""
fi
# Read the server name from the command-line argument or use the last used server name as the default
server_name="${1:-$last_server_name}"
# Check if the server name is provided
if [[ -z "$server_name" ]]; then
echo "Please provide the SSH server name."
exit 1
fi
# Save the current server name to the state file
echo "$server_name" > "$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/connect-components root@${server_name}.local:/usr/local/emhttp/plugins/dynamix.my.servers"
echo "Executing the following command:"
echo "$rsync_command"
# Execute the rsync command
eval "$rsync_command"